Passed
Pull Request — master (#291)
by Brian
06:20
created
includes/class-wpinv-ajax.php 1 patch
Spacing   +295 added lines, -295 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() {
@@ -78,39 +78,39 @@  discard block
 block discarded – undo
78 78
             'buy_items' => true,
79 79
         );
80 80
 
81
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
82
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
81
+        foreach ($ajax_events as $ajax_event => $nopriv) {
82
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
83 83
             
84
-            if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) {
85
-                define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 );
84
+            if (!defined('WPI_AJAX_' . strtoupper($nopriv))) {
85
+                define('WPI_AJAX_' . strtoupper($nopriv), 1);
86 86
             }
87 87
 
88
-            if ( $nopriv ) {
89
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
88
+            if ($nopriv) {
89
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
90 90
 
91
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
91
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
92 92
             }
93 93
         }
94 94
     }
95 95
     
96 96
     public static function add_note() {
97
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
97
+        check_ajax_referer('add-invoice-note', '_nonce');
98 98
 
99
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
99
+        if (!wpinv_current_user_can_manage_invoicing()) {
100 100
             die(-1);
101 101
         }
102 102
 
103
-        $post_id   = absint( $_POST['post_id'] );
104
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
105
-        $note_type = sanitize_text_field( $_POST['note_type'] );
103
+        $post_id   = absint($_POST['post_id']);
104
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
105
+        $note_type = sanitize_text_field($_POST['note_type']);
106 106
 
107 107
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
108 108
 
109
-        if ( $post_id > 0 ) {
110
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
109
+        if ($post_id > 0) {
110
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
111 111
 
112
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
113
-                wpinv_get_invoice_note_line_item( $note_id );
112
+            if ($note_id > 0 && !is_wp_error($note_id)) {
113
+                wpinv_get_invoice_note_line_item($note_id);
114 114
             }
115 115
         }
116 116
 
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
     }
119 119
 
120 120
     public static function delete_note() {
121
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
121
+        check_ajax_referer('delete-invoice-note', '_nonce');
122 122
 
123
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
123
+        if (!wpinv_current_user_can_manage_invoicing()) {
124 124
             die(-1);
125 125
         }
126 126
 
127
-        $note_id = (int)$_POST['note_id'];
127
+        $note_id = (int) $_POST['note_id'];
128 128
 
129
-        if ( $note_id > 0 ) {
130
-            wp_delete_comment( $note_id, true );
129
+        if ($note_id > 0) {
130
+            wp_delete_comment($note_id, true);
131 131
         }
132 132
 
133 133
         die();
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
     }
141 141
     
142 142
     public static function checkout() {
143
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
144
-            define( 'WPINV_CHECKOUT', true );
143
+        if (!defined('WPINV_CHECKOUT')) {
144
+            define('WPINV_CHECKOUT', true);
145 145
         }
146 146
 
147 147
         wpinv_process_checkout();
@@ -150,53 +150,53 @@  discard block
 block discarded – undo
150 150
     
151 151
     public static function add_invoice_item() {
152 152
         global $wpi_userID, $wpinv_ip_address_country;
153
-        check_ajax_referer( 'invoice-item', '_nonce' );
154
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
153
+        check_ajax_referer('invoice-item', '_nonce');
154
+        if (!wpinv_current_user_can_manage_invoicing()) {
155 155
             die(-1);
156 156
         }
157 157
         
158
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
159
-        $invoice_id = absint( $_POST['invoice_id'] );
158
+        $item_id    = sanitize_text_field($_POST['item_id']);
159
+        $invoice_id = absint($_POST['invoice_id']);
160 160
         
161
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
161
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
162 162
             die();
163 163
         }
164 164
         
165
-        $invoice    = wpinv_get_invoice( $invoice_id );
166
-        if ( empty( $invoice ) ) {
165
+        $invoice = wpinv_get_invoice($invoice_id);
166
+        if (empty($invoice)) {
167 167
             die();
168 168
         }
169 169
         
170
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
170
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
171 171
             die(); // Don't allow modify items for paid invoice.
172 172
         }
173 173
         
174
-        if ( !empty( $_POST['user_id'] ) ) {
175
-            $wpi_userID = absint( $_POST['user_id'] ); 
174
+        if (!empty($_POST['user_id'])) {
175
+            $wpi_userID = absint($_POST['user_id']); 
176 176
         }
177 177
 
178
-        $item = new WPInv_Item( $item_id );
179
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
178
+        $item = new WPInv_Item($item_id);
179
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
180 180
             die();
181 181
         }
182 182
         
183 183
         // Validate item before adding to invoice because recurring item must be paid individually.
184
-        if ( !empty( $invoice->cart_details ) ) {
184
+        if (!empty($invoice->cart_details)) {
185 185
             $valid = true;
186 186
             
187
-            if ( $recurring_item = $invoice->get_recurring() ) {
188
-                if ( $recurring_item != $item_id ) {
187
+            if ($recurring_item = $invoice->get_recurring()) {
188
+                if ($recurring_item != $item_id) {
189 189
                     $valid = false;
190 190
                 }
191
-            } else if ( wpinv_is_recurring_item( $item_id ) ) {
191
+            } else if (wpinv_is_recurring_item($item_id)) {
192 192
                 $valid = false;
193 193
             }
194 194
             
195
-            if ( !$valid ) {
195
+            if (!$valid) {
196 196
                 $response               = array();
197 197
                 $response['success']    = false;
198
-                $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
199
-                wp_send_json( $response );
198
+                $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
199
+                wp_send_json($response);
200 200
             }
201 201
         }
202 202
         
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
         
205 205
         $data                   = array();
206 206
         $data['invoice_id']     = $invoice_id;
207
-        $data['cart_discounts'] = $invoice->get_discounts( true );
207
+        $data['cart_discounts'] = $invoice->get_discounts(true);
208 208
         
209
-        wpinv_set_checkout_session( $data );
209
+        wpinv_set_checkout_session($data);
210 210
         
211
-        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1;
211
+        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1;
212 212
 
213 213
         $args = array(
214 214
             'id'            => $item_id,
@@ -221,21 +221,21 @@  discard block
 block discarded – undo
221 221
             'fees'          => array()
222 222
         );
223 223
 
224
-        $invoice->add_item( $item_id, $args );
224
+        $invoice->add_item($item_id, $args);
225 225
         $invoice->save();
226 226
         
227
-        if ( empty( $_POST['country'] ) ) {
227
+        if (empty($_POST['country'])) {
228 228
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
229 229
         }
230
-        if ( empty( $_POST['state'] ) ) {
230
+        if (empty($_POST['state'])) {
231 231
             $_POST['state'] = $invoice->state;
232 232
         }
233 233
          
234
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
235
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
234
+        $invoice->country   = sanitize_text_field($_POST['country']);
235
+        $invoice->state     = sanitize_text_field($_POST['state']);
236 236
         
237
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
238
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
237
+        $invoice->set('country', sanitize_text_field($_POST['country']));
238
+        $invoice->set('state', sanitize_text_field($_POST['state']));
239 239
         
240 240
         $wpinv_ip_address_country = $invoice->country;
241 241
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         
244 244
         $response                       = array();
245 245
         $response['success']            = true;
246
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
246
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
247 247
         $response['data']['subtotal']   = $invoice->get_subtotal();
248 248
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
249 249
         $response['data']['tax']        = $invoice->get_tax();
@@ -255,41 +255,41 @@  discard block
 block discarded – undo
255 255
         
256 256
         wpinv_set_checkout_session($checkout_session);
257 257
         
258
-        wp_send_json( $response );
258
+        wp_send_json($response);
259 259
     }
260 260
 
261 261
 
262 262
     public static function remove_invoice_item() {
263 263
         global $wpi_userID, $wpinv_ip_address_country;
264 264
         
265
-        check_ajax_referer( 'invoice-item', '_nonce' );
266
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
265
+        check_ajax_referer('invoice-item', '_nonce');
266
+        if (!wpinv_current_user_can_manage_invoicing()) {
267 267
             die(-1);
268 268
         }
269 269
         
270
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
271
-        $invoice_id = absint( $_POST['invoice_id'] );
272
-        $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false;
270
+        $item_id    = sanitize_text_field($_POST['item_id']);
271
+        $invoice_id = absint($_POST['invoice_id']);
272
+        $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false;
273 273
         
274
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
274
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
275 275
             die();
276 276
         }
277 277
 
278
-        $invoice    = wpinv_get_invoice( $invoice_id );
279
-        if ( empty( $invoice ) ) {
278
+        $invoice = wpinv_get_invoice($invoice_id);
279
+        if (empty($invoice)) {
280 280
             die();
281 281
         }
282 282
         
283
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
283
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
284 284
             die(); // Don't allow modify items for paid invoice.
285 285
         }
286 286
         
287
-        if ( !empty( $_POST['user_id'] ) ) {
288
-            $wpi_userID = absint( $_POST['user_id'] ); 
287
+        if (!empty($_POST['user_id'])) {
288
+            $wpi_userID = absint($_POST['user_id']); 
289 289
         }
290 290
 
291
-        $item       = new WPInv_Item( $item_id );
292
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
291
+        $item = new WPInv_Item($item_id);
292
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
293 293
             die();
294 294
         }
295 295
         
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
         
298 298
         $data                   = array();
299 299
         $data['invoice_id']     = $invoice_id;
300
-        $data['cart_discounts'] = $invoice->get_discounts( true );
300
+        $data['cart_discounts'] = $invoice->get_discounts(true);
301 301
         
302
-        wpinv_set_checkout_session( $data );
302
+        wpinv_set_checkout_session($data);
303 303
 
304 304
         $args = array(
305 305
             'id'         => $item_id,
@@ -307,21 +307,21 @@  discard block
 block discarded – undo
307 307
             'cart_index' => $cart_index
308 308
         );
309 309
 
310
-        $invoice->remove_item( $item_id, $args );
310
+        $invoice->remove_item($item_id, $args);
311 311
         $invoice->save();
312 312
         
313
-        if ( empty( $_POST['country'] ) ) {
313
+        if (empty($_POST['country'])) {
314 314
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
315 315
         }
316
-        if ( empty( $_POST['state'] ) ) {
316
+        if (empty($_POST['state'])) {
317 317
             $_POST['state'] = $invoice->state;
318 318
         }
319 319
          
320
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
321
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
320
+        $invoice->country   = sanitize_text_field($_POST['country']);
321
+        $invoice->state     = sanitize_text_field($_POST['state']);
322 322
         
323
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
324
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
323
+        $invoice->set('country', sanitize_text_field($_POST['country']));
324
+        $invoice->set('state', sanitize_text_field($_POST['state']));
325 325
         
326 326
         $wpinv_ip_address_country = $invoice->country;
327 327
         
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         
330 330
         $response                       = array();
331 331
         $response['success']            = true;
332
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
332
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
333 333
         $response['data']['subtotal']   = $invoice->get_subtotal();
334 334
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
335 335
         $response['data']['tax']        = $invoice->get_tax();
@@ -341,55 +341,55 @@  discard block
 block discarded – undo
341 341
         
342 342
         wpinv_set_checkout_session($checkout_session);
343 343
         
344
-        wp_send_json( $response );
344
+        wp_send_json($response);
345 345
     }
346 346
     
347 347
     public static function create_invoice_item() {
348
-        check_ajax_referer( 'invoice-item', '_nonce' );
349
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
348
+        check_ajax_referer('invoice-item', '_nonce');
349
+        if (!wpinv_current_user_can_manage_invoicing()) {
350 350
             die(-1);
351 351
         }
352 352
         
353
-        $invoice_id = absint( $_POST['invoice_id'] );
353
+        $invoice_id = absint($_POST['invoice_id']);
354 354
 
355 355
         // Find the item
356
-        if ( !is_numeric( $invoice_id ) ) {
356
+        if (!is_numeric($invoice_id)) {
357 357
             die();
358 358
         }        
359 359
         
360
-        $invoice     = wpinv_get_invoice( $invoice_id );
361
-        if ( empty( $invoice ) ) {
360
+        $invoice = wpinv_get_invoice($invoice_id);
361
+        if (empty($invoice)) {
362 362
             die();
363 363
         }
364 364
         
365 365
         // Validate item before adding to invoice because recurring item must be paid individually.
366
-        if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) {
366
+        if (!empty($invoice->cart_details) && $invoice->get_recurring()) {
367 367
             $response               = array();
368 368
             $response['success']    = false;
369
-            $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
370
-            wp_send_json( $response );
369
+            $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
370
+            wp_send_json($response);
371 371
         }        
372 372
         
373
-        $save_item = wp_unslash( $_POST['_wpinv_quick'] );
373
+        $save_item = wp_unslash($_POST['_wpinv_quick']);
374 374
         
375 375
         $meta               = array();
376 376
         $meta['type']       = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom';
377
-        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0;
377
+        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0;
378 378
         $meta['vat_rule']   = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital';
379 379
         $meta['vat_class']  = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard';
380 380
         
381 381
         $data                   = array();
382 382
         $data['post_title']     = sanitize_text_field($save_item['name']);
383 383
         $data['post_status']    = 'publish';
384
-        $data['post_excerpt']   = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : '';
384
+        $data['post_excerpt']   = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : '';
385 385
         $data['meta']           = $meta;
386 386
         
387 387
         $item = new WPInv_Item();
388
-        $item->create( $data );
388
+        $item->create($data);
389 389
         
390
-        if ( !empty( $item ) ) {
390
+        if (!empty($item)) {
391 391
             $_POST['item_id']   = $item->ID;
392
-            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1;
392
+            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1;
393 393
             
394 394
             self::add_invoice_item();
395 395
         }
@@ -397,15 +397,15 @@  discard block
 block discarded – undo
397 397
     }
398 398
     
399 399
     public static function get_billing_details() {
400
-        check_ajax_referer( 'get-billing-details', '_nonce' );
400
+        check_ajax_referer('get-billing-details', '_nonce');
401 401
         
402
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
402
+        if (!wpinv_current_user_can_manage_invoicing()) {
403 403
             die(-1);
404 404
         }
405 405
 
406
-        $user_id            = (int)$_POST['user_id'];
406
+        $user_id            = (int) $_POST['user_id'];
407 407
         $billing_details    = wpinv_get_user_address($user_id);
408
-        $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
408
+        $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
409 409
         
410 410
         if (isset($billing_details['user_id'])) {
411 411
             unset($billing_details['user_id']);
@@ -419,20 +419,20 @@  discard block
 block discarded – undo
419 419
         $response['success']                    = true;
420 420
         $response['data']['billing_details']    = $billing_details;
421 421
         
422
-        wp_send_json( $response );
422
+        wp_send_json($response);
423 423
     }
424 424
     
425 425
     public static function admin_recalculate_totals() {
426 426
         global $wpi_userID, $wpinv_ip_address_country;
427 427
         
428
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
429
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
428
+        check_ajax_referer('wpinv-nonce', '_nonce');
429
+        if (!wpinv_current_user_can_manage_invoicing()) {
430 430
             die(-1);
431 431
         }
432 432
         
433
-        $invoice_id = absint( $_POST['invoice_id'] );        
434
-        $invoice    = wpinv_get_invoice( $invoice_id );
435
-        if ( empty( $invoice ) ) {
433
+        $invoice_id = absint($_POST['invoice_id']);        
434
+        $invoice    = wpinv_get_invoice($invoice_id);
435
+        if (empty($invoice)) {
436 436
             die();
437 437
         }
438 438
         
@@ -440,23 +440,23 @@  discard block
 block discarded – undo
440 440
         
441 441
         $data                   = array();
442 442
         $data['invoice_id']     = $invoice_id;
443
-        $data['cart_discounts'] = $invoice->get_discounts( true );
443
+        $data['cart_discounts'] = $invoice->get_discounts(true);
444 444
         
445
-        wpinv_set_checkout_session( $data );
445
+        wpinv_set_checkout_session($data);
446 446
         
447
-        if ( !empty( $_POST['user_id'] ) ) {
448
-            $wpi_userID = absint( $_POST['user_id'] ); 
447
+        if (!empty($_POST['user_id'])) {
448
+            $wpi_userID = absint($_POST['user_id']); 
449 449
         }
450 450
         
451
-        if ( empty( $_POST['country'] ) ) {
451
+        if (empty($_POST['country'])) {
452 452
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
453 453
         }
454 454
             
455
-        $invoice->country = sanitize_text_field( $_POST['country'] );
456
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
457
-        if ( isset( $_POST['state'] ) ) {
458
-            $invoice->state = sanitize_text_field( $_POST['state'] );
459
-            $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
455
+        $invoice->country = sanitize_text_field($_POST['country']);
456
+        $invoice->set('country', sanitize_text_field($_POST['country']));
457
+        if (isset($_POST['state'])) {
458
+            $invoice->state = sanitize_text_field($_POST['state']);
459
+            $invoice->set('state', sanitize_text_field($_POST['state']));
460 460
         }
461 461
         
462 462
         $wpinv_ip_address_country = $invoice->country;
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         
466 466
         $response                       = array();
467 467
         $response['success']            = true;
468
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
468
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
469 469
         $response['data']['subtotal']   = $invoice->get_subtotal();
470 470
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
471 471
         $response['data']['tax']        = $invoice->get_tax();
@@ -477,25 +477,25 @@  discard block
 block discarded – undo
477 477
         
478 478
         wpinv_set_checkout_session($checkout_session);
479 479
         
480
-        wp_send_json( $response );
480
+        wp_send_json($response);
481 481
     }
482 482
     
483 483
     public static function admin_apply_discount() {
484 484
         global $wpi_userID;
485 485
         
486
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
487
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
486
+        check_ajax_referer('wpinv-nonce', '_nonce');
487
+        if (!wpinv_current_user_can_manage_invoicing()) {
488 488
             die(-1);
489 489
         }
490 490
         
491
-        $invoice_id = absint( $_POST['invoice_id'] );
492
-        $discount_code = sanitize_text_field( $_POST['code'] );
493
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
491
+        $invoice_id = absint($_POST['invoice_id']);
492
+        $discount_code = sanitize_text_field($_POST['code']);
493
+        if (empty($invoice_id) || empty($discount_code)) {
494 494
             die();
495 495
         }
496 496
         
497
-        $invoice = wpinv_get_invoice( $invoice_id );
498
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
497
+        $invoice = wpinv_get_invoice($invoice_id);
498
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
499 499
             die();
500 500
         }
501 501
         
@@ -503,49 +503,49 @@  discard block
 block discarded – undo
503 503
         
504 504
         $data                   = array();
505 505
         $data['invoice_id']     = $invoice_id;
506
-        $data['cart_discounts'] = $invoice->get_discounts( true );
506
+        $data['cart_discounts'] = $invoice->get_discounts(true);
507 507
         
508
-        wpinv_set_checkout_session( $data );
508
+        wpinv_set_checkout_session($data);
509 509
         
510 510
         $response               = array();
511 511
         $response['success']    = false;
512
-        $response['msg']        = __( 'This discount is invalid.', 'invoicing' );
512
+        $response['msg']        = __('This discount is invalid.', 'invoicing');
513 513
         $response['data']['code'] = $discount_code;
514 514
         
515
-        if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) {
516
-            $discounts = wpinv_set_cart_discount( $discount_code );
515
+        if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) {
516
+            $discounts = wpinv_set_cart_discount($discount_code);
517 517
             
518 518
             $response['success'] = true;
519
-            $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
520
-        }  else {
519
+            $response['msg'] = __('Discount has been applied successfully.', 'invoicing');
520
+        } else {
521 521
             $errors = wpinv_get_errors();
522
-            if ( !empty( $errors['wpinv-discount-error'] ) ) {
522
+            if (!empty($errors['wpinv-discount-error'])) {
523 523
                 $response['msg'] = $errors['wpinv-discount-error'];
524 524
             }
525
-            wpinv_unset_error( 'wpinv-discount-error' );
525
+            wpinv_unset_error('wpinv-discount-error');
526 526
         }
527 527
         
528 528
         wpinv_set_checkout_session($checkout_session);
529 529
         
530
-        wp_send_json( $response );
530
+        wp_send_json($response);
531 531
     }
532 532
     
533 533
     public static function admin_remove_discount() {
534 534
         global $wpi_userID;
535 535
         
536
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
537
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
536
+        check_ajax_referer('wpinv-nonce', '_nonce');
537
+        if (!wpinv_current_user_can_manage_invoicing()) {
538 538
             die(-1);
539 539
         }
540 540
         
541
-        $invoice_id = absint( $_POST['invoice_id'] );
542
-        $discount_code = sanitize_text_field( $_POST['code'] );
543
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
541
+        $invoice_id = absint($_POST['invoice_id']);
542
+        $discount_code = sanitize_text_field($_POST['code']);
543
+        if (empty($invoice_id) || empty($discount_code)) {
544 544
             die();
545 545
         }
546 546
         
547
-        $invoice = wpinv_get_invoice( $invoice_id );
548
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
547
+        $invoice = wpinv_get_invoice($invoice_id);
548
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
549 549
             die();
550 550
         }
551 551
         
@@ -553,38 +553,38 @@  discard block
 block discarded – undo
553 553
         
554 554
         $data                   = array();
555 555
         $data['invoice_id']     = $invoice_id;
556
-        $data['cart_discounts'] = $invoice->get_discounts( true );
556
+        $data['cart_discounts'] = $invoice->get_discounts(true);
557 557
         
558
-        wpinv_set_checkout_session( $data );
558
+        wpinv_set_checkout_session($data);
559 559
         
560 560
         $response               = array();
561 561
         $response['success']    = false;
562 562
         $response['msg']        = NULL;
563 563
         
564
-        $discounts  = wpinv_unset_cart_discount( $discount_code );
564
+        $discounts = wpinv_unset_cart_discount($discount_code);
565 565
         $response['success'] = true;
566
-        $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' );
566
+        $response['msg'] = __('Discount has been removed successfully.', 'invoicing');
567 567
         
568 568
         wpinv_set_checkout_session($checkout_session);
569 569
         
570
-        wp_send_json( $response );
570
+        wp_send_json($response);
571 571
     }
572 572
     
573 573
     public static function check_email() {
574
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
575
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
574
+        check_ajax_referer('wpinv-nonce', '_nonce');
575
+        if (!wpinv_current_user_can_manage_invoicing()) {
576 576
             die(-1);
577 577
         }
578 578
         
579
-        $email = sanitize_text_field( $_POST['email'] );
579
+        $email = sanitize_text_field($_POST['email']);
580 580
         
581 581
         $response = array();
582
-        if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) {
582
+        if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) {
583 583
             $user_id            = $user_data->ID;
584 584
             $user_login         = $user_data->user_login;
585 585
             $display_name       = $user_data->display_name ? $user_data->display_name : $user_login;
586 586
             $billing_details    = wpinv_get_user_address($user_id);
587
-            $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
587
+            $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
588 588
             
589 589
             if (isset($billing_details['user_id'])) {
590 590
                 unset($billing_details['user_id']);
@@ -600,54 +600,54 @@  discard block
 block discarded – undo
600 600
             $response['data']['billing_details']    = $billing_details;
601 601
         }
602 602
         
603
-        wp_send_json( $response );
603
+        wp_send_json($response);
604 604
     }
605 605
     
606 606
     public static function run_tool() {
607
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
608
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
607
+        check_ajax_referer('wpinv-nonce', '_nonce');
608
+        if (!wpinv_current_user_can_manage_invoicing()) {
609 609
             die(-1);
610 610
         }
611 611
         
612
-        $tool = sanitize_text_field( $_POST['tool'] );
612
+        $tool = sanitize_text_field($_POST['tool']);
613 613
         
614
-        do_action( 'wpinv_run_tool' );
614
+        do_action('wpinv_run_tool');
615 615
         
616
-        if ( !empty( $tool ) ) {
617
-            do_action( 'wpinv_tool_' . $tool );
616
+        if (!empty($tool)) {
617
+            do_action('wpinv_tool_' . $tool);
618 618
         }
619 619
     }
620 620
     
621 621
     public static function apply_discount() {
622 622
         global $wpi_userID;
623 623
         
624
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
624
+        check_ajax_referer('wpinv-nonce', '_nonce');
625 625
         
626 626
         $response = array();
627 627
         
628
-        if ( isset( $_POST['code'] ) ) {
629
-            $discount_code = sanitize_text_field( $_POST['code'] );
628
+        if (isset($_POST['code'])) {
629
+            $discount_code = sanitize_text_field($_POST['code']);
630 630
 
631 631
             $response['success']        = false;
632 632
             $response['msg']            = '';
633 633
             $response['data']['code']   = $discount_code;
634 634
             
635 635
             $invoice = wpinv_get_invoice_cart();
636
-            if ( empty( $invoice->ID ) ) {
637
-                $response['msg'] = __( 'Invalid checkout request.', 'invoicing' );
638
-                wp_send_json( $response );
636
+            if (empty($invoice->ID)) {
637
+                $response['msg'] = __('Invalid checkout request.', 'invoicing');
638
+                wp_send_json($response);
639 639
             }
640 640
 
641 641
             $wpi_userID = $invoice->get_user_id();
642 642
 
643
-            if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) {
644
-                $discount       = wpinv_get_discount_by_code( $discount_code );
645
-                $discounts      = wpinv_set_cart_discount( $discount_code );
646
-                $amount         = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
647
-                $total          = wpinv_get_cart_total( null, $discounts );
648
-                $cart_totals    = wpinv_recalculate_tax( true );
643
+            if (wpinv_is_discount_valid($discount_code, $wpi_userID)) {
644
+                $discount       = wpinv_get_discount_by_code($discount_code);
645
+                $discounts      = wpinv_set_cart_discount($discount_code);
646
+                $amount         = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
647
+                $total          = wpinv_get_cart_total(null, $discounts);
648
+                $cart_totals    = wpinv_recalculate_tax(true);
649 649
             
650
-                if ( !empty( $cart_totals ) ) {
650
+                if (!empty($cart_totals)) {
651 651
                     $response['success']        = true;
652 652
                     $response['data']           = $cart_totals;
653 653
                     $response['data']['code']   = $discount_code;
@@ -656,29 +656,29 @@  discard block
 block discarded – undo
656 656
                 }
657 657
             } else {
658 658
                 $errors = wpinv_get_errors();
659
-                $response['msg']  = $errors['wpinv-discount-error'];
660
-                wpinv_unset_error( 'wpinv-discount-error' );
659
+                $response['msg'] = $errors['wpinv-discount-error'];
660
+                wpinv_unset_error('wpinv-discount-error');
661 661
             }
662 662
 
663 663
             // Allow for custom discount code handling
664
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
664
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
665 665
         }
666 666
         
667
-        wp_send_json( $response );
667
+        wp_send_json($response);
668 668
     }
669 669
     
670 670
     public static function remove_discount() {
671
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
671
+        check_ajax_referer('wpinv-nonce', '_nonce');
672 672
         
673 673
         $response = array();
674 674
         
675
-        if ( isset( $_POST['code'] ) ) {
676
-            $discount_code  = sanitize_text_field( $_POST['code'] );
677
-            $discounts      = wpinv_unset_cart_discount( $discount_code );
678
-            $total          = wpinv_get_cart_total( null, $discounts );
679
-            $cart_totals    = wpinv_recalculate_tax( true );
675
+        if (isset($_POST['code'])) {
676
+            $discount_code  = sanitize_text_field($_POST['code']);
677
+            $discounts      = wpinv_unset_cart_discount($discount_code);
678
+            $total          = wpinv_get_cart_total(null, $discounts);
679
+            $cart_totals    = wpinv_recalculate_tax(true);
680 680
             
681
-            if ( !empty( $cart_totals ) ) {
681
+            if (!empty($cart_totals)) {
682 682
                 $response['success']        = true;
683 683
                 $response['data']           = $cart_totals;
684 684
                 $response['data']['code']   = $discount_code;
@@ -687,10 +687,10 @@  discard block
 block discarded – undo
687 687
             }
688 688
             
689 689
             // Allow for custom discount code handling
690
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
690
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
691 691
         }
692 692
         
693
-        wp_send_json( $response );
693
+        wp_send_json($response);
694 694
     }
695 695
 
696 696
     /**
@@ -702,59 +702,59 @@  discard block
 block discarded – undo
702 702
         global $invoicing;
703 703
 
704 704
         // Check nonce.
705
-        if ( ! isset( $_POST['wpinv_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_payment_form'], 'wpinv_payment_form' ) ) {
706
-            wp_send_json_error( __( 'Security checks failed.', 'invoicing' ) );
705
+        if (!isset($_POST['wpinv_payment_form']) || !wp_verify_nonce($_POST['wpinv_payment_form'], 'wpinv_payment_form')) {
706
+            wp_send_json_error(__('Security checks failed.', 'invoicing'));
707 707
         }
708 708
 
709 709
         // Prepare submitted data...
710
-        $data     = wp_unslash( $_POST );
710
+        $data = wp_unslash($_POST);
711 711
 
712 712
         // ... form fields...
713
-        if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) {
714
-            wp_send_json_error( __( 'This payment form is no longer active.', 'invoicing' ) );
713
+        if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) {
714
+            wp_send_json_error(__('This payment form is no longer active.', 'invoicing'));
715 715
         }
716 716
 
717
-        if ( empty( $data['billing_email'] ) || ! is_email( $data['billing_email'] ) ) {
718
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
717
+        if (empty($data['billing_email']) || !is_email($data['billing_email'])) {
718
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
719 719
         }
720 720
 
721 721
         $prepared = array(
722
-            'billing_email'                    => sanitize_email( $data['billing_email'] ),
723
-            __( 'Billing Email', 'invoicing' ) => sanitize_email( $data['billing_email'] ),
724
-            __( 'Form Id', 'invoicing' )       => absint( $data['form_id'] ),
722
+            'billing_email'                    => sanitize_email($data['billing_email']),
723
+            __('Billing Email', 'invoicing') => sanitize_email($data['billing_email']),
724
+            __('Form Id', 'invoicing')       => absint($data['form_id']),
725 725
         );
726 726
 
727
-        $prepared['billing_email'] = sanitize_email( $data['billing_email'] );
727
+        $prepared['billing_email'] = sanitize_email($data['billing_email']);
728 728
 
729
-        $fields = $invoicing->form_elements->get_form_elements( $data['form_id'] );
729
+        $fields = $invoicing->form_elements->get_form_elements($data['form_id']);
730 730
 
731 731
         // ... and form items.
732
-        $items          = $invoicing->form_elements->get_form_items( $data['form_id'] );
732
+        $items          = $invoicing->form_elements->get_form_items($data['form_id']);
733 733
         $prepared_items = array();
734 734
 
735
-        if ( ! empty( $data['wpinv-items'] ) ) {
735
+        if (!empty($data['wpinv-items'])) {
736 736
 
737
-            $selected_items = wpinv_clean( $data['wpinv-items'] );
737
+            $selected_items = wpinv_clean($data['wpinv-items']);
738 738
 
739
-            foreach ( $items as $item ) {
739
+            foreach ($items as $item) {
740 740
 
741
-                if ( ! isset( $selected_items[ $item['id'] ] ) ) {
741
+                if (!isset($selected_items[$item['id']])) {
742 742
                     continue;
743 743
                 }
744 744
 
745 745
                 // Custom pricing.
746
-                if ( ! empty( $item['custom_price'] ) ) {
746
+                if (!empty($item['custom_price'])) {
747 747
 
748
-                    $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] );
749
-                    $set_price     = wpinv_sanitize_amount( $selected_items[ $item['id'] ] );
748
+                    $minimum_price = wpinv_sanitize_amount($item['minimum_price']);
749
+                    $set_price     = wpinv_sanitize_amount($selected_items[$item['id']]);
750 750
 
751
-                    if ( $set_price < $minimum_price ) {
752
-                        wp_send_json_error( __( 'The provided amount is less than the minimum allowed value.', 'invoicing' ) );
751
+                    if ($set_price < $minimum_price) {
752
+                        wp_send_json_error(__('The provided amount is less than the minimum allowed value.', 'invoicing'));
753 753
                     }
754 754
 
755 755
                     $prepared_items[] = array(
756 756
                         'id'           =>$item['id'],
757
-                        'item_price'   => wpinv_sanitize_amount( $item['price'] ),
757
+                        'item_price'   => wpinv_sanitize_amount($item['price']),
758 758
                         'custom_price' => $set_price,
759 759
                         'name'         => $item['title'],
760 760
                     );
@@ -763,8 +763,8 @@  discard block
 block discarded – undo
763 763
 
764 764
                     $prepared_items[] = array(
765 765
                         'id'           => $item['id'],
766
-                        'item_price'   => wpinv_sanitize_amount( $item['price'] ),
767
-                        'custom_price' => wpinv_sanitize_amount( $item['price'] ),
766
+                        'item_price'   => wpinv_sanitize_amount($item['price']),
767
+                        'custom_price' => wpinv_sanitize_amount($item['price']),
768 768
                         'name'         => $item['title'],
769 769
                     );
770 770
 
@@ -774,45 +774,45 @@  discard block
 block discarded – undo
774 774
 
775 775
         } else {
776 776
 
777
-            wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) );
777
+            wp_send_json_error(__('You have not selected any items.', 'invoicing'));
778 778
 
779 779
         }
780 780
 
781 781
         // Are all required fields provided?
782
-        foreach ( $fields as $field ) {
782
+        foreach ($fields as $field) {
783 783
 
784
-            if ( ! empty( $field['premade'] ) ) {
784
+            if (!empty($field['premade'])) {
785 785
                 continue;
786 786
             }
787 787
 
788
-            if ( ! empty( $field['required'] ) && empty( $data[ $field['id'] ] ) ) {
789
-                wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) );
788
+            if (!empty($field['required']) && empty($data[$field['id']])) {
789
+                wp_send_json_error(__('Some required fields have not been filled.', 'invoicing'));
790 790
             }
791 791
 
792
-            if ( isset( $data[ $field['id'] ] ) ) {
792
+            if (isset($data[$field['id']])) {
793 793
                 $label = $field['id'];
794 794
 
795
-                if ( isset( $field['label'] ) ) {
795
+                if (isset($field['label'])) {
796 796
                     $label = $field['label'];
797 797
                 }
798 798
 
799
-                $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] );
799
+                $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]);
800 800
             }
801 801
 
802 802
         }
803 803
         
804
-        $user = get_user_by( 'email', $prepared['billing_email'] );
804
+        $user = get_user_by('email', $prepared['billing_email']);
805 805
 
806
-        if ( empty( $user ) ) {
807
-            $user = wpinv_create_user( $prepared['billing_email'] );
806
+        if (empty($user)) {
807
+            $user = wpinv_create_user($prepared['billing_email']);
808 808
         }
809 809
 
810
-        if ( is_wp_error( $user ) ) {
811
-            wp_send_json_error( $user->get_error_message() );
810
+        if (is_wp_error($user)) {
811
+            wp_send_json_error($user->get_error_message());
812 812
         }
813 813
 
814
-        if ( is_numeric( $user ) ) {
815
-            $user = get_user_by( 'id', $user );
814
+        if (is_numeric($user)) {
815
+            $user = get_user_by('id', $user);
816 816
         }
817 817
 
818 818
         // Create the invoice.
@@ -826,18 +826,18 @@  discard block
 block discarded – undo
826 826
             true
827 827
         );
828 828
 
829
-        if ( is_wp_error( $created ) ) {
830
-            wp_send_json_error( $created->get_error_message() );
829
+        if (is_wp_error($created)) {
830
+            wp_send_json_error($created->get_error_message());
831 831
         }
832 832
 
833
-        if ( empty( $created ) ) {
834
-            wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) );
833
+        if (empty($created)) {
834
+            wp_send_json_error(__('Could not create your invoice.', 'invoicing'));
835 835
         }
836 836
 
837
-        unset( $prepared['billing_email'] );
838
-        update_post_meta( $created->ID, 'payment_form_data', $prepared );
837
+        unset($prepared['billing_email']);
838
+        update_post_meta($created->ID, 'payment_form_data', $prepared);
839 839
 
840
-        wp_send_json_success( $created->get_view_url( true ) );
840
+        wp_send_json_success($created->get_view_url(true));
841 841
 
842 842
     }
843 843
 
@@ -849,53 +849,53 @@  discard block
 block discarded – undo
849 849
     public static function buy_items() {
850 850
         $user_id = get_current_user_id();
851 851
 
852
-        if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page
853
-            wp_send_json( array(
854
-                'success' => wp_login_url( wp_get_referer() )
855
-            ) );
852
+        if (empty($user_id)) { // If not logged in then lets redirect to the login page
853
+            wp_send_json(array(
854
+                'success' => wp_login_url(wp_get_referer())
855
+            ));
856 856
         } else {
857 857
             // Only check nonce if logged in as it could be cached when logged out.
858
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
859
-                wp_send_json( array(
860
-                    'error' => __( 'Security checks failed.', 'invoicing' )
861
-                ) );
858
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
859
+                wp_send_json(array(
860
+                    'error' => __('Security checks failed.', 'invoicing')
861
+                ));
862 862
                 wp_die();
863 863
             }
864 864
 
865 865
             // allow to set a custom price through post_id
866 866
             $items = $_POST['items'];
867
-            $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0;
868
-            $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0;
867
+            $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
868
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
869 869
 
870 870
             $cart_items = array();
871
-            if ( $items ) {
872
-                $items = explode( ',', $items );
871
+            if ($items) {
872
+                $items = explode(',', $items);
873 873
 
874
-                foreach( $items as $item ) {
874
+                foreach ($items as $item) {
875 875
                     $item_id = $item;
876 876
                     $quantity = 1;
877 877
 
878
-                    if ( strpos( $item, '|' ) !== false ) {
879
-                        $item_parts = explode( '|', $item );
878
+                    if (strpos($item, '|') !== false) {
879
+                        $item_parts = explode('|', $item);
880 880
                         $item_id = $item_parts[0];
881 881
                         $quantity = $item_parts[1];
882 882
                     }
883 883
 
884
-                    if ( $item_id && $quantity ) {
884
+                    if ($item_id && $quantity) {
885 885
                         $cart_items_arr = array(
886
-                            'id'            => (int)$item_id,
887
-                            'quantity'      => (int)$quantity
886
+                            'id'            => (int) $item_id,
887
+                            'quantity'      => (int) $quantity
888 888
                         );
889 889
 
890 890
                         // If there is a related post id then add it to meta
891
-                        if ( $related_post_id ) {
891
+                        if ($related_post_id) {
892 892
                             $cart_items_arr['meta'] = array(
893 893
                                 'post_id'   => $related_post_id
894 894
                             );
895 895
                         }
896 896
 
897 897
                         // If there is a custom price then set it.
898
-                        if ( $custom_item_price ) {
898
+                        if ($custom_item_price) {
899 899
                             $cart_items_arr['custom_price'] = $custom_item_price;
900 900
                         }
901 901
 
@@ -911,37 +911,37 @@  discard block
 block discarded – undo
911 911
              * @param int $related_post_id The related post id if any.
912 912
              * @since 1.0.0
913 913
              */
914
-            $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id );
914
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
915 915
 
916 916
             // Make sure its not in the cart already, if it is then redirect to checkout.
917 917
             $cart_invoice = wpinv_get_invoice_cart();
918 918
 
919
-            if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) {
920
-                wp_send_json( array(
919
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
920
+                wp_send_json(array(
921 921
                     'success' =>  $cart_invoice->get_checkout_payment_url()
922
-                ) );
922
+                ));
923 923
                 wp_die();
924 924
             }
925 925
 
926 926
             // Check if user has invoice with same items waiting to be paid.
927
-            $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' );
928
-            if ( !empty( $user_invoices ) ) {
929
-                foreach( $user_invoices as $user_invoice ) {
927
+            $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending');
928
+            if (!empty($user_invoices)) {
929
+                foreach ($user_invoices as $user_invoice) {
930 930
                     $user_cart_details = array();
931
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
931
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
932 932
                     $cart_details = $invoice->get_cart_details();
933 933
 
934
-                    if ( !empty( $cart_details ) ) {
935
-                        foreach ( $cart_details as $invoice_item ) {
934
+                    if (!empty($cart_details)) {
935
+                        foreach ($cart_details as $invoice_item) {
936 936
                             $ii_arr = array();
937
-                            $ii_arr['id'] = (int)$invoice_item['id'];
938
-                            $ii_arr['quantity'] = (int)$invoice_item['quantity'];
937
+                            $ii_arr['id'] = (int) $invoice_item['id'];
938
+                            $ii_arr['quantity'] = (int) $invoice_item['quantity'];
939 939
 
940
-                            if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) {
940
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
941 941
                                 $ii_arr['meta'] = $invoice_item['meta'];
942 942
                             }
943 943
 
944
-                            if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) {
944
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
945 945
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
946 946
                             }
947 947
 
@@ -949,17 +949,17 @@  discard block
 block discarded – undo
949 949
                         }
950 950
                     }
951 951
 
952
-                    if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) {
953
-                        wp_send_json( array(
952
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
953
+                        wp_send_json(array(
954 954
                             'success' =>  $invoice->get_checkout_payment_url()
955
-                        ) );
955
+                        ));
956 956
                         wp_die();
957 957
                     }
958 958
                 }
959 959
             }
960 960
 
961 961
             // Create invoice and send user to checkout
962
-            if ( !empty( $cart_items ) ) {
962
+            if (!empty($cart_items)) {
963 963
                 $invoice_data = array(
964 964
                     'status'        =>  'wpi-pending',
965 965
                     'created_via'   =>  'wpi',
@@ -967,21 +967,21 @@  discard block
 block discarded – undo
967 967
                     'cart_details'  =>  $cart_items,
968 968
                 );
969 969
 
970
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
970
+                $invoice = wpinv_insert_invoice($invoice_data, true);
971 971
 
972
-                if ( !empty( $invoice ) && isset( $invoice->ID ) ) {
973
-                    wp_send_json( array(
972
+                if (!empty($invoice) && isset($invoice->ID)) {
973
+                    wp_send_json(array(
974 974
                         'success' =>  $invoice->get_checkout_payment_url()
975
-                    ) );
975
+                    ));
976 976
                 } else {
977
-                    wp_send_json( array(
978
-                        'error' => __( 'Invoice failed to create', 'invoicing' )
979
-                    ) );
977
+                    wp_send_json(array(
978
+                        'error' => __('Invoice failed to create', 'invoicing')
979
+                    ));
980 980
                 }
981 981
             } else {
982
-                wp_send_json( array(
983
-                    'error' => __( 'Items not valid.', 'invoicing' )
984
-                ) );
982
+                wp_send_json(array(
983
+                    'error' => __('Items not valid.', 'invoicing')
984
+                ));
985 985
             }
986 986
         }
987 987
 
Please login to merge, or discard this patch.
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +450 added lines, -450 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,11 +207,11 @@  discard block
 block discarded – undo
207 207
 
208 208
             array( 
209 209
                 'type' => 'billing_email',
210
-                'name' => __( 'Billing Email', 'invoicing' ),
210
+                'name' => __('Billing Email', 'invoicing'),
211 211
                 'defaults'  => array(
212 212
                     'placeholder'  => '[email protected]',
213 213
                     'value'        => '',
214
-                    'label'        => __( 'Billing Email', 'invoicing' ),
214
+                    'label'        => __('Billing Email', 'invoicing'),
215 215
                     'description'  => '',
216 216
                     'premade'      => true,
217 217
                 )
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
             array( 
232 232
                 'type' => 'items',
233
-                'name' => __( 'Items', 'invoicing' ),
233
+                'name' => __('Items', 'invoicing'),
234 234
                 'defaults'  => array(
235 235
                     'value'        => '',
236 236
                     'items_type'   => 'total',
@@ -241,25 +241,25 @@  discard block
 block discarded – undo
241 241
 
242 242
             array( 
243 243
                 'type'       => 'pay_button',
244
-                'name'       => __( 'Payment Button', 'invoicing' ),
244
+                'name'       => __('Payment Button', 'invoicing'),
245 245
                 'defaults'   => array(
246 246
                     'value'        => '',
247 247
                     'class'        => 'btn-primary',
248
-                    'label'        => __( 'Pay Now »', 'invoicing' ),
249
-                    'description'  => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
248
+                    'label'        => __('Pay Now »', 'invoicing'),
249
+                    'description'  => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
250 250
                     'premade'      => true,
251 251
                 )
252 252
             )
253 253
         );
254 254
 
255
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
255
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
256 256
         return $this->elements;
257 257
     }
258 258
 
259 259
     /**
260 260
      * Returns the restrict markup.
261 261
      */
262
-    public function get_restrict_markup( $field, $field_type ) {
262
+    public function get_restrict_markup($field, $field_type) {
263 263
         $restrict = "$field.type=='$field_type'";
264 264
         return "v-if=\"$restrict\"";
265 265
     }
@@ -267,15 +267,15 @@  discard block
 block discarded – undo
267 267
     /**
268 268
      * Renders the title element template.
269 269
      */
270
-    public function render_heading_template( $field ) {
271
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
270
+    public function render_heading_template($field) {
271
+        $restrict = $this->get_restrict_markup($field, 'heading');
272 272
         echo "<component :is='$field.level' $restrict v-html='$field.text'></component>";
273 273
     }
274 274
 
275 275
     /**
276 276
      * Renders the title element on the frontend.
277 277
      */
278
-    public function frontend_render_heading_template( $field ) {
278
+    public function frontend_render_heading_template($field) {
279 279
         $tag = $field['level'];
280 280
         echo "<$tag>{$field['text']}</$tag>";
281 281
     }
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
     /**
284 284
      * Renders the edit title element template.
285 285
      */
286
-    public function edit_heading_template( $field ) {
287
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
288
-        $label    = __( 'Heading', 'invoicing' );
289
-        $label2   = __( 'Select Heading Level', 'invoicing' );
286
+    public function edit_heading_template($field) {
287
+        $restrict = $this->get_restrict_markup($field, 'heading');
288
+        $label    = __('Heading', 'invoicing');
289
+        $label2   = __('Select Heading Level', 'invoicing');
290 290
         $id       = $field . '.id + "_edit"';
291 291
         $id2      = $field . '.id + "_edit2"';
292 292
 
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
     /**
319 319
      * Renders a paragraph element template.
320 320
      */
321
-    public function render_paragraph_template( $field ) {
322
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
321
+    public function render_paragraph_template($field) {
322
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
323 323
         $label    = "$field.text";
324 324
         echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>";
325 325
     }
@@ -327,16 +327,16 @@  discard block
 block discarded – undo
327 327
     /**
328 328
      * Renders the paragraph element on the frontend.
329 329
      */
330
-    public function frontend_render_paragraph_template( $field ) {
330
+    public function frontend_render_paragraph_template($field) {
331 331
         echo "<p>{$field['text']}</p>";
332 332
     }
333 333
 
334 334
     /**
335 335
      * Renders the edit paragraph element template.
336 336
      */
337
-    public function edit_paragraph_template( $field ) {
338
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
339
-        $label    = __( 'Enter your text', 'invoicing' );
337
+    public function edit_paragraph_template($field) {
338
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
339
+        $label    = __('Enter your text', 'invoicing');
340 340
         $id       = $field . '.id + "_edit"';
341 341
         echo "
342 342
             <div $restrict>
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
     /**
353 353
      * Renders the text element template.
354 354
      */
355
-    public function render_text_template( $field ) {
356
-        $restrict = $this->get_restrict_markup( $field, 'text' );
355
+    public function render_text_template($field) {
356
+        $restrict = $this->get_restrict_markup($field, 'text');
357 357
         $label    = "$field.label";
358 358
         echo "
359 359
             <div $restrict>
@@ -367,23 +367,23 @@  discard block
 block discarded – undo
367 367
     /**
368 368
      * Renders the text element on the frontend.
369 369
      */
370
-    public function frontend_render_text_template( $field ) {
370
+    public function frontend_render_text_template($field) {
371 371
         
372 372
         echo "<div class='form-group'>";
373 373
 
374 374
         echo aui()->input(
375 375
             array(
376
-                'name'       => esc_attr( $field['id'] ),
377
-                'id'         => esc_attr( $field['id'] ),
378
-                'placeholder'=> esc_attr( $field['placeholder'] ),
376
+                'name'       => esc_attr($field['id']),
377
+                'id'         => esc_attr($field['id']),
378
+                'placeholder'=> esc_attr($field['placeholder']),
379 379
                 'required'   => (bool) $field['required'],
380
-                'label'      => wp_kses_post( $field['label'] ),
380
+                'label'      => wp_kses_post($field['label']),
381 381
                 'no_wrap'    => true,
382 382
             )
383 383
         );
384 384
 
385
-        if ( ! empty( $field['description'] ) ) {
386
-            $description = wp_kses_post( $field['description'] );
385
+        if (!empty($field['description'])) {
386
+            $description = wp_kses_post($field['description']);
387 387
             echo "<small class='form-text text-muted'>$description</small>";
388 388
         }
389 389
 
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
     /**
395 395
      * Renders the edit text element template.
396 396
      */
397
-    public function edit_text_template( $field ) {
398
-        $restrict = $this->get_restrict_markup( $field, 'text' );
399
-        $label    = __( 'Field Label', 'invoicing' );
397
+    public function edit_text_template($field) {
398
+        $restrict = $this->get_restrict_markup($field, 'text');
399
+        $label    = __('Field Label', 'invoicing');
400 400
         $id       = $field . '.id + "_edit"';
401
-        $label2   = __( 'Placeholder text', 'invoicing' );
401
+        $label2   = __('Placeholder text', 'invoicing');
402 402
         $id2      = $field . '.id + "_edit2"';
403
-        $label3   = __( 'Help text', 'invoicing' );
404
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
403
+        $label3   = __('Help text', 'invoicing');
404
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
405 405
         $id3      = $field . '.id + "_edit3"';
406
-        $label5   = __( 'Is this field required?', 'invoicing' );
406
+        $label5   = __('Is this field required?', 'invoicing');
407 407
         $id4      = $field . '.id + "_edit4"';
408 408
         echo "
409 409
             <div $restrict>
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
     /**
432 432
      * Renders the textarea element template.
433 433
      */
434
-    public function render_textarea_template( $field ) {
435
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
434
+    public function render_textarea_template($field) {
435
+        $restrict = $this->get_restrict_markup($field, 'textarea');
436 436
         $label    = "$field.label";
437 437
         echo "
438 438
             <div $restrict>
@@ -446,24 +446,24 @@  discard block
 block discarded – undo
446 446
     /**
447 447
      * Renders the textarea element on the frontend.
448 448
      */
449
-    public function frontend_render_textarea_template( $field ) {
449
+    public function frontend_render_textarea_template($field) {
450 450
         
451 451
         echo "<div class='form-group'>";
452 452
 
453 453
         echo aui()->textarea(
454 454
             array(
455
-                'name'       => esc_attr( $field['id'] ),
456
-                'id'         => esc_attr( $field['id'] ),
457
-                'placeholder'=> esc_attr( $field['placeholder'] ),
455
+                'name'       => esc_attr($field['id']),
456
+                'id'         => esc_attr($field['id']),
457
+                'placeholder'=> esc_attr($field['placeholder']),
458 458
                 'required'   => (bool) $field['required'],
459
-                'label'      => wp_kses_post( $field['label'] ),
459
+                'label'      => wp_kses_post($field['label']),
460 460
                 'no_wrap'    => true,
461 461
                 'rows'       => 3,
462 462
             )
463 463
         );
464 464
 
465
-        if ( ! empty( $field['description'] ) ) {
466
-            $description = wp_kses_post( $field['description'] );
465
+        if (!empty($field['description'])) {
466
+            $description = wp_kses_post($field['description']);
467 467
             echo "<small class='form-text text-muted'>$description</small>";
468 468
         }
469 469
 
@@ -474,16 +474,16 @@  discard block
 block discarded – undo
474 474
     /**
475 475
      * Renders the edit textarea element template.
476 476
      */
477
-    public function edit_textarea_template( $field ) {
478
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
479
-        $label    = __( 'Field Label', 'invoicing' );
477
+    public function edit_textarea_template($field) {
478
+        $restrict = $this->get_restrict_markup($field, 'textarea');
479
+        $label    = __('Field Label', 'invoicing');
480 480
         $id       = $field . '.id + "_edit"';
481
-        $label2   = __( 'Placeholder text', 'invoicing' );
481
+        $label2   = __('Placeholder text', 'invoicing');
482 482
         $id2      = $field . '.id + "_edit2"';
483
-        $label3   = __( 'Help text', 'invoicing' );
484
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
483
+        $label3   = __('Help text', 'invoicing');
484
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
485 485
         $id3      = $field . '.id + "_edit3"';
486
-        $label5   = __( 'Is this field required?', 'invoicing' );
486
+        $label5   = __('Is this field required?', 'invoicing');
487 487
         $id4      = $field . '.id + "_edit4"';
488 488
         echo "
489 489
             <div $restrict>
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
     /**
512 512
      * Renders the select element template.
513 513
      */
514
-    public function render_select_template( $field ) {
515
-        $restrict    = $this->get_restrict_markup( $field, 'select' );
514
+    public function render_select_template($field) {
515
+        $restrict    = $this->get_restrict_markup($field, 'select');
516 516
         $label       = "$field.label";
517 517
         $placeholder = "$field.placeholder";
518 518
         $id          = $field . '.id';
@@ -531,24 +531,24 @@  discard block
 block discarded – undo
531 531
     /**
532 532
      * Renders the select element on the frontend.
533 533
      */
534
-    public function frontend_render_select_template( $field ) {
534
+    public function frontend_render_select_template($field) {
535 535
         
536 536
         echo "<div class='form-group'>";
537 537
 
538 538
         echo aui()->select(
539 539
             array(
540
-                'name'       => esc_attr( $field['id'] ),
541
-                'id'         => esc_attr( $field['id'] ),
542
-                'placeholder'=> esc_attr( $field['placeholder'] ),
540
+                'name'       => esc_attr($field['id']),
541
+                'id'         => esc_attr($field['id']),
542
+                'placeholder'=> esc_attr($field['placeholder']),
543 543
                 'required'   => (bool) $field['required'],
544
-                'label'      => wp_kses_post( $field['label'] ),
544
+                'label'      => wp_kses_post($field['label']),
545 545
                 'no_wrap'    => true,
546
-                'options'    => array_combine( $field['options'], $field['options'] ),
546
+                'options'    => array_combine($field['options'], $field['options']),
547 547
             )
548 548
         );
549 549
 
550
-        if ( ! empty( $field['description'] ) ) {
551
-            $description = wp_kses_post( $field['description'] );
550
+        if (!empty($field['description'])) {
551
+            $description = wp_kses_post($field['description']);
552 552
             echo "<small class='form-text text-muted'>$description</small>";
553 553
         }
554 554
 
@@ -559,18 +559,18 @@  discard block
 block discarded – undo
559 559
     /**
560 560
      * Renders the edit select element template.
561 561
      */
562
-    public function edit_select_template( $field ) {
563
-        $restrict = $this->get_restrict_markup( $field, 'select' );
564
-        $label    = __( 'Field Label', 'invoicing' );
562
+    public function edit_select_template($field) {
563
+        $restrict = $this->get_restrict_markup($field, 'select');
564
+        $label    = __('Field Label', 'invoicing');
565 565
         $id       = $field . '.id + "_edit"';
566
-        $label2   = __( 'Placeholder text', 'invoicing' );
566
+        $label2   = __('Placeholder text', 'invoicing');
567 567
         $id2      = $field . '.id + "_edit2"';
568
-        $label3   = __( 'Help text', 'invoicing' );
569
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
568
+        $label3   = __('Help text', 'invoicing');
569
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
570 570
         $id3      = $field . '.id + "_edit3"';
571
-        $label5   = __( 'Is this field required?', 'invoicing' );
571
+        $label5   = __('Is this field required?', 'invoicing');
572 572
         $id4      = $field . '.id + "_edit4"';
573
-        $label6   = __( 'Available Options', 'invoicing' );
573
+        $label6   = __('Available Options', 'invoicing');
574 574
         echo "
575 575
             <div $restrict>
576 576
                 <div class='form-group'>
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
     /**
609 609
      * Renders the checkbox element template.
610 610
      */
611
-    public function render_checkbox_template( $field ) {
612
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
611
+    public function render_checkbox_template($field) {
612
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
613 613
         $label    = "$field.label";
614 614
         echo "
615 615
             <div class='form-check' $restrict>
@@ -623,24 +623,24 @@  discard block
 block discarded – undo
623 623
     /**
624 624
      * Renders the checkbox element on the frontend.
625 625
      */
626
-    public function frontend_render_checkbox_template( $field ) {
626
+    public function frontend_render_checkbox_template($field) {
627 627
         
628 628
         echo "<div class='form-group'>";
629 629
 
630 630
         echo aui()->input(
631 631
             array(
632
-                'name'       => esc_attr( $field['id'] ),
633
-                'id'         => esc_attr( $field['id'] ),
632
+                'name'       => esc_attr($field['id']),
633
+                'id'         => esc_attr($field['id']),
634 634
                 'required'   => (bool) $field['required'],
635
-                'label'      => wp_kses_post( $field['label'] ),
635
+                'label'      => wp_kses_post($field['label']),
636 636
                 'no_wrap'    => true,
637
-                'value'      => esc_attr__( 'Yes', 'invoicing' ),
637
+                'value'      => esc_attr__('Yes', 'invoicing'),
638 638
                 'type'       => 'checkbox',
639 639
             )
640 640
         );
641 641
 
642
-        if ( ! empty( $field['description'] ) ) {
643
-            $description = wp_kses_post( $field['description'] );
642
+        if (!empty($field['description'])) {
643
+            $description = wp_kses_post($field['description']);
644 644
             echo "<small class='form-text text-muted'>$description</small>";
645 645
         }
646 646
 
@@ -651,14 +651,14 @@  discard block
 block discarded – undo
651 651
     /**
652 652
      * Renders the edit checkbox element template.
653 653
      */
654
-    public function edit_checkbox_template( $field ) {
655
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
656
-        $label    = __( 'Field Label', 'invoicing' );
654
+    public function edit_checkbox_template($field) {
655
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
656
+        $label    = __('Field Label', 'invoicing');
657 657
         $id       = $field . '.id + "_edit"';
658
-        $label2   = __( 'Help text', 'invoicing' );
659
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
658
+        $label2   = __('Help text', 'invoicing');
659
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
660 660
         $id2      = $field . '.id + "_edit2"';
661
-        $label4   = __( 'Is this field required?', 'invoicing' );
661
+        $label4   = __('Is this field required?', 'invoicing');
662 662
         $id3      = $field . '.id + "_edit3"';
663 663
         echo "
664 664
             <div $restrict>
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
     /**
683 683
      * Renders the radio element template.
684 684
      */
685
-    public function render_radio_template( $field ) {
686
-        $restrict    = $this->get_restrict_markup( $field, 'radio' );
685
+    public function render_radio_template($field) {
686
+        $restrict    = $this->get_restrict_markup($field, 'radio');
687 687
         $label       = "$field.label";
688 688
         $id          = $field . '.id';
689 689
         echo "
@@ -701,20 +701,20 @@  discard block
 block discarded – undo
701 701
     /**
702 702
      * Renders the radio element on the frontend.
703 703
      */
704
-    public function frontend_render_radio_template( $field ) {
704
+    public function frontend_render_radio_template($field) {
705 705
         
706 706
         echo "<div class='form-group'>";
707 707
 
708
-        if ( ! empty( $field['label'] ) ) {
709
-            $label = wp_kses_post( $field['label'] );
708
+        if (!empty($field['label'])) {
709
+            $label = wp_kses_post($field['label']);
710 710
             echo "<legend class='col-form-label'>$label</legend>";
711 711
         }
712 712
 
713
-        foreach( $field['options'] as $index => $option ) {
713
+        foreach ($field['options'] as $index => $option) {
714 714
             $id    = $field['id'] . $index;
715 715
             $name  = $field['id'];
716
-            $value = esc_attr( $option );
717
-            $label = wp_kses_post( $option );
716
+            $value = esc_attr($option);
717
+            $label = wp_kses_post($option);
718 718
 
719 719
             echo "
720 720
                 <div class='form-check'>
@@ -724,8 +724,8 @@  discard block
 block discarded – undo
724 724
             ";
725 725
         }
726 726
 
727
-        if ( ! empty( $field['description'] ) ) {
728
-            $description = wp_kses_post( $field['description'] );
727
+        if (!empty($field['description'])) {
728
+            $description = wp_kses_post($field['description']);
729 729
             echo "<small class='form-text text-muted'>$description</small>";
730 730
         }
731 731
 
@@ -736,16 +736,16 @@  discard block
 block discarded – undo
736 736
     /**
737 737
      * Renders the edit radio element template.
738 738
      */
739
-    public function edit_radio_template( $field ) {
740
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
741
-        $label    = __( 'Field Label', 'invoicing' );
739
+    public function edit_radio_template($field) {
740
+        $restrict = $this->get_restrict_markup($field, 'radio');
741
+        $label    = __('Field Label', 'invoicing');
742 742
         $id       = $field . '.id + "_edit"';
743
-        $label2   = __( 'Help text', 'invoicing' );
744
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
743
+        $label2   = __('Help text', 'invoicing');
744
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
745 745
         $id2      = $field . '.id + "_edit3"';
746
-        $label4   = __( 'Is this field required?', 'invoicing' );
746
+        $label4   = __('Is this field required?', 'invoicing');
747 747
         $id3      = $field . '.id + "_edit4"';
748
-        $label5   = __( 'Available Options', 'invoicing' );
748
+        $label5   = __('Available Options', 'invoicing');
749 749
         echo "
750 750
             <div $restrict>
751 751
                 <div class='form-group'>
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
     /**
780 780
      * Renders the email element template.
781 781
      */
782
-    public function render_email_template( $field ) {
783
-        $restrict = $this->get_restrict_markup( $field, 'email' );
782
+    public function render_email_template($field) {
783
+        $restrict = $this->get_restrict_markup($field, 'email');
784 784
         $label    = "$field.label";
785 785
         echo "
786 786
             <div $restrict>
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
     /**
795 795
      * Renders the billing_email element template.
796 796
      */
797
-    public function render_billing_email_template( $field ) {
798
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
797
+    public function render_billing_email_template($field) {
798
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
799 799
         $label    = "$field.label";
800 800
         echo "
801 801
             <div $restrict>
@@ -809,24 +809,24 @@  discard block
 block discarded – undo
809 809
     /**
810 810
      * Renders the email element on the frontend.
811 811
      */
812
-    public function frontend_render_email_template( $field ) {
812
+    public function frontend_render_email_template($field) {
813 813
         
814 814
         echo "<div class='form-group'>";
815 815
 
816 816
         echo aui()->input(
817 817
             array(
818
-                'name'       => esc_attr( $field['id'] ),
819
-                'id'         => esc_attr( $field['id'] ),
818
+                'name'       => esc_attr($field['id']),
819
+                'id'         => esc_attr($field['id']),
820 820
                 'required'   => (bool) $field['required'],
821
-                'label'      => wp_kses_post( $field['label'] ),
821
+                'label'      => wp_kses_post($field['label']),
822 822
                 'no_wrap'    => true,
823
-                'placeholder' => esc_attr( $field['placeholder'] ),
823
+                'placeholder' => esc_attr($field['placeholder']),
824 824
                 'type'       => 'email',
825 825
             )
826 826
         );
827 827
 
828
-        if ( ! empty( $field['description'] ) ) {
829
-            $description = wp_kses_post( $field['description'] );
828
+        if (!empty($field['description'])) {
829
+            $description = wp_kses_post($field['description']);
830 830
             echo "<small class='form-text text-muted'>$description</small>";
831 831
         }
832 832
 
@@ -837,30 +837,30 @@  discard block
 block discarded – undo
837 837
     /**
838 838
      * Renders the billing email element on the frontend.
839 839
      */
840
-    public function frontend_render_billing_email_template( $field ) {
840
+    public function frontend_render_billing_email_template($field) {
841 841
         
842 842
         echo "<div class='form-group'>";
843 843
         $value = '';
844 844
 
845
-        if ( is_user_logged_in() ) {
845
+        if (is_user_logged_in()) {
846 846
             $user  = wp_get_current_user();
847
-            $value = sanitize_email( $user->user_email );
847
+            $value = sanitize_email($user->user_email);
848 848
         }
849 849
         echo aui()->input(
850 850
             array(
851 851
                 'name'       => 'billing_email',
852 852
                 'value'      => $value,
853
-                'id'         => esc_attr( $field['id'] ),
853
+                'id'         => esc_attr($field['id']),
854 854
                 'required'   => true,
855
-                'label'      => wp_kses_post( $field['label'] ),
855
+                'label'      => wp_kses_post($field['label']),
856 856
                 'no_wrap'    => true,
857
-                'placeholder' => esc_attr( $field['placeholder'] ),
857
+                'placeholder' => esc_attr($field['placeholder']),
858 858
                 'type'       => 'email',
859 859
             )
860 860
         );
861 861
 
862
-        if ( ! empty( $field['description'] ) ) {
863
-            $description = wp_kses_post( $field['description'] );
862
+        if (!empty($field['description'])) {
863
+            $description = wp_kses_post($field['description']);
864 864
             echo "<small class='form-text text-muted'>$description</small>";
865 865
         }
866 866
 
@@ -871,16 +871,16 @@  discard block
 block discarded – undo
871 871
     /**
872 872
      * Renders the edit email element template.
873 873
      */
874
-    public function edit_email_template( $field ) {
875
-        $restrict = $this->get_restrict_markup( $field, 'email' );
876
-        $label    = __( 'Field Label', 'invoicing' );
874
+    public function edit_email_template($field) {
875
+        $restrict = $this->get_restrict_markup($field, 'email');
876
+        $label    = __('Field Label', 'invoicing');
877 877
         $id       = $field . '.id + "_edit"';
878
-        $label2   = __( 'Placeholder text', 'invoicing' );
878
+        $label2   = __('Placeholder text', 'invoicing');
879 879
         $id2      = $field . '.id + "_edit2"';
880
-        $label3   = __( 'Help text', 'invoicing' );
881
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
880
+        $label3   = __('Help text', 'invoicing');
881
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
882 882
         $id3      = $field . '.id + "_edit3"';
883
-        $label5   = __( 'Is this field required?', 'invoicing' );
883
+        $label5   = __('Is this field required?', 'invoicing');
884 884
         $id4      = $field . '.id + "_edit4"';
885 885
         echo "
886 886
             <div $restrict>
@@ -908,16 +908,16 @@  discard block
 block discarded – undo
908 908
     /**
909 909
      * Renders the edit billing_email element template.
910 910
      */
911
-    public function edit_billing_email_template( $field ) {
912
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
913
-        $label    = __( 'Field Label', 'invoicing' );
911
+    public function edit_billing_email_template($field) {
912
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
913
+        $label    = __('Field Label', 'invoicing');
914 914
         $id       = $field . '.id + "_edit"';
915
-        $label2   = __( 'Placeholder text', 'invoicing' );
915
+        $label2   = __('Placeholder text', 'invoicing');
916 916
         $id2      = $field . '.id + "_edit2"';
917
-        $label3   = __( 'Help text', 'invoicing' );
918
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
917
+        $label3   = __('Help text', 'invoicing');
918
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
919 919
         $id3      = $field . '.id + "_edit3"';
920
-        $label5   = __( 'Is this field required?', 'invoicing' );
920
+        $label5   = __('Is this field required?', 'invoicing');
921 921
         $id4      = $field . '.id + "_edit4"';
922 922
         echo "
923 923
             <div $restrict>
@@ -941,8 +941,8 @@  discard block
 block discarded – undo
941 941
     /**
942 942
      * Renders the website element template.
943 943
      */
944
-    public function render_website_template( $field ) {
945
-        $restrict = $this->get_restrict_markup( $field, 'website' );
944
+    public function render_website_template($field) {
945
+        $restrict = $this->get_restrict_markup($field, 'website');
946 946
         $label    = "$field.label";
947 947
         echo "
948 948
             <div $restrict>
@@ -956,24 +956,24 @@  discard block
 block discarded – undo
956 956
     /**
957 957
      * Renders the website element on the frontend.
958 958
      */
959
-    public function frontend_render_website_template( $field ) {
959
+    public function frontend_render_website_template($field) {
960 960
         
961 961
         echo "<div class='form-group'>";
962 962
 
963 963
         echo aui()->input(
964 964
             array(
965
-                'name'       => esc_attr( $field['id'] ),
966
-                'id'         => esc_attr( $field['id'] ),
965
+                'name'       => esc_attr($field['id']),
966
+                'id'         => esc_attr($field['id']),
967 967
                 'required'   => (bool) $field['required'],
968
-                'label'      => wp_kses_post( $field['label'] ),
968
+                'label'      => wp_kses_post($field['label']),
969 969
                 'no_wrap'    => true,
970
-                'placeholder' => esc_attr( $field['placeholder'] ),
970
+                'placeholder' => esc_attr($field['placeholder']),
971 971
                 'type'       => 'url',
972 972
             )
973 973
         );
974 974
 
975
-        if ( ! empty( $field['description'] ) ) {
976
-            $description = wp_kses_post( $field['description'] );
975
+        if (!empty($field['description'])) {
976
+            $description = wp_kses_post($field['description']);
977 977
             echo "<small class='form-text text-muted'>$description</small>";
978 978
         }
979 979
 
@@ -984,16 +984,16 @@  discard block
 block discarded – undo
984 984
     /**
985 985
      * Renders the edit website element template.
986 986
      */
987
-    public function edit_website_template( $field ) {
988
-        $restrict = $this->get_restrict_markup( $field, 'website' );
989
-        $label    = __( 'Field Label', 'invoicing' );
987
+    public function edit_website_template($field) {
988
+        $restrict = $this->get_restrict_markup($field, 'website');
989
+        $label    = __('Field Label', 'invoicing');
990 990
         $id       = $field . '.id + "_edit"';
991
-        $label2   = __( 'Placeholder text', 'invoicing' );
991
+        $label2   = __('Placeholder text', 'invoicing');
992 992
         $id2      = $field . '.id + "_edit2"';
993
-        $label3   = __( 'Help text', 'invoicing' );
994
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
993
+        $label3   = __('Help text', 'invoicing');
994
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
995 995
         $id3      = $field . '.id + "_edit3"';
996
-        $label5   = __( 'Is this field required?', 'invoicing' );
996
+        $label5   = __('Is this field required?', 'invoicing');
997 997
         $id4      = $field . '.id + "_edit4"';
998 998
         echo "
999 999
             <div $restrict>
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
     /**
1022 1022
      * Renders the date element template.
1023 1023
      */
1024
-    public function render_date_template( $field ) {
1025
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1024
+    public function render_date_template($field) {
1025
+        $restrict = $this->get_restrict_markup($field, 'date');
1026 1026
         $label    = "$field.label";
1027 1027
         echo "
1028 1028
             <div $restrict>
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
     /**
1037 1037
      * Renders the date element on the frontend.
1038 1038
      */
1039
-    public function frontend_render_date_template( $field ) {
1039
+    public function frontend_render_date_template($field) {
1040 1040
         
1041 1041
         echo "<div class='form-group'>";
1042 1042
 
1043 1043
         echo aui()->input(
1044 1044
             array(
1045
-                'name'       => esc_attr( $field['id'] ),
1046
-                'id'         => esc_attr( $field['id'] ),
1045
+                'name'       => esc_attr($field['id']),
1046
+                'id'         => esc_attr($field['id']),
1047 1047
                 'required'   => (bool) $field['required'],
1048
-                'label'      => wp_kses_post( $field['label'] ),
1049
-                'placeholder' => esc_attr( $field['placeholder'] ),
1048
+                'label'      => wp_kses_post($field['label']),
1049
+                'placeholder' => esc_attr($field['placeholder']),
1050 1050
                 'no_wrap'    => true,
1051 1051
                 'type'       => 'date',
1052 1052
             )
1053 1053
         );
1054 1054
 
1055
-        if ( ! empty( $field['description'] ) ) {
1056
-            $description = wp_kses_post( $field['description'] );
1055
+        if (!empty($field['description'])) {
1056
+            $description = wp_kses_post($field['description']);
1057 1057
             echo "<small class='form-text text-muted'>$description</small>";
1058 1058
         }
1059 1059
 
@@ -1064,16 +1064,16 @@  discard block
 block discarded – undo
1064 1064
     /**
1065 1065
      * Renders the edit date element template.
1066 1066
      */
1067
-    public function edit_date_template( $field ) {
1068
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1069
-        $label    = __( 'Field Label', 'invoicing' );
1067
+    public function edit_date_template($field) {
1068
+        $restrict = $this->get_restrict_markup($field, 'date');
1069
+        $label    = __('Field Label', 'invoicing');
1070 1070
         $id       = $field . '.id + "_edit"';
1071
-        $label2   = __( 'Placeholder text', 'invoicing' );
1071
+        $label2   = __('Placeholder text', 'invoicing');
1072 1072
         $id2      = $field . '.id + "_edit2"';
1073
-        $label3   = __( 'Help text', 'invoicing' );
1074
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1073
+        $label3   = __('Help text', 'invoicing');
1074
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1075 1075
         $id3      = $field . '.id + "_edit3"';
1076
-        $label5   = __( 'Is this field required?', 'invoicing' );
1076
+        $label5   = __('Is this field required?', 'invoicing');
1077 1077
         $id4      = $field . '.id + "_edit4"';
1078 1078
         echo "
1079 1079
             <div $restrict>
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
     /**
1102 1102
      * Renders the time element template.
1103 1103
      */
1104
-    public function render_time_template( $field ) {
1105
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1104
+    public function render_time_template($field) {
1105
+        $restrict = $this->get_restrict_markup($field, 'time');
1106 1106
         $label    = "$field.label";
1107 1107
         echo "
1108 1108
             <div $restrict>
@@ -1116,24 +1116,24 @@  discard block
 block discarded – undo
1116 1116
     /**
1117 1117
      * Renders the time element on the frontend.
1118 1118
      */
1119
-    public function frontend_render_time_template( $field ) {
1119
+    public function frontend_render_time_template($field) {
1120 1120
         
1121 1121
         echo "<div class='form-group'>";
1122 1122
 
1123 1123
         echo aui()->input(
1124 1124
             array(
1125
-                'name'       => esc_attr( $field['id'] ),
1126
-                'id'         => esc_attr( $field['id'] ),
1125
+                'name'       => esc_attr($field['id']),
1126
+                'id'         => esc_attr($field['id']),
1127 1127
                 'required'   => (bool) $field['required'],
1128
-                'label'      => wp_kses_post( $field['label'] ),
1128
+                'label'      => wp_kses_post($field['label']),
1129 1129
                 'no_wrap'    => true,
1130
-                'placeholder' => esc_attr( $field['placeholder'] ),
1130
+                'placeholder' => esc_attr($field['placeholder']),
1131 1131
                 'type'       => 'time',
1132 1132
             )
1133 1133
         );
1134 1134
 
1135
-        if ( ! empty( $field['description'] ) ) {
1136
-            $description = wp_kses_post( $field['description'] );
1135
+        if (!empty($field['description'])) {
1136
+            $description = wp_kses_post($field['description']);
1137 1137
             echo "<small class='form-text text-muted'>$description</small>";
1138 1138
         }
1139 1139
 
@@ -1144,16 +1144,16 @@  discard block
 block discarded – undo
1144 1144
     /**
1145 1145
      * Renders the edit time element template.
1146 1146
      */
1147
-    public function edit_time_template( $field ) {
1148
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1149
-        $label    = __( 'Field Label', 'invoicing' );
1147
+    public function edit_time_template($field) {
1148
+        $restrict = $this->get_restrict_markup($field, 'time');
1149
+        $label    = __('Field Label', 'invoicing');
1150 1150
         $id       = $field . '.id + "_edit"';
1151
-        $label2   = __( 'Placeholder text', 'invoicing' );
1151
+        $label2   = __('Placeholder text', 'invoicing');
1152 1152
         $id2      = $field . '.id + "_edit2"';
1153
-        $label3   = __( 'Help text', 'invoicing' );
1154
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1153
+        $label3   = __('Help text', 'invoicing');
1154
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1155 1155
         $id3      = $field . '.id + "_edit3"';
1156
-        $label5   = __( 'Is this field required?', 'invoicing' );
1156
+        $label5   = __('Is this field required?', 'invoicing');
1157 1157
         $id4      = $field . '.id + "_edit4"';
1158 1158
         echo "
1159 1159
             <div $restrict>
@@ -1181,8 +1181,8 @@  discard block
 block discarded – undo
1181 1181
     /**
1182 1182
      * Renders the number element template.
1183 1183
      */
1184
-    public function render_number_template( $field ) {
1185
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1184
+    public function render_number_template($field) {
1185
+        $restrict = $this->get_restrict_markup($field, 'number');
1186 1186
         $label    = "$field.label";
1187 1187
         echo "
1188 1188
             <div $restrict>
@@ -1196,24 +1196,24 @@  discard block
 block discarded – undo
1196 1196
     /**
1197 1197
      * Renders the number element on the frontend.
1198 1198
      */
1199
-    public function frontend_render_number_template( $field ) {
1199
+    public function frontend_render_number_template($field) {
1200 1200
         
1201 1201
         echo "<div class='form-group'>";
1202 1202
 
1203 1203
         echo aui()->input(
1204 1204
             array(
1205
-                'name'       => esc_attr( $field['id'] ),
1206
-                'id'         => esc_attr( $field['id'] ),
1205
+                'name'       => esc_attr($field['id']),
1206
+                'id'         => esc_attr($field['id']),
1207 1207
                 'required'   => (bool) $field['required'],
1208
-                'label'      => wp_kses_post( $field['label'] ),
1209
-                'placeholder' => esc_attr( $field['placeholder'] ),
1208
+                'label'      => wp_kses_post($field['label']),
1209
+                'placeholder' => esc_attr($field['placeholder']),
1210 1210
                 'no_wrap'    => true,
1211 1211
                 'type'       => 'number',
1212 1212
             )
1213 1213
         );
1214 1214
 
1215
-        if ( ! empty( $field['description'] ) ) {
1216
-            $description = wp_kses_post( $field['description'] );
1215
+        if (!empty($field['description'])) {
1216
+            $description = wp_kses_post($field['description']);
1217 1217
             echo "<small class='form-text text-muted'>$description</small>";
1218 1218
         }
1219 1219
 
@@ -1224,16 +1224,16 @@  discard block
 block discarded – undo
1224 1224
     /**
1225 1225
      * Renders the edit number element template.
1226 1226
      */
1227
-    public function edit_number_template( $field ) {
1228
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1229
-        $label    = __( 'Field Label', 'invoicing' );
1227
+    public function edit_number_template($field) {
1228
+        $restrict = $this->get_restrict_markup($field, 'number');
1229
+        $label    = __('Field Label', 'invoicing');
1230 1230
         $id       = $field . '.id + "_edit"';
1231
-        $label2   = __( 'Placeholder text', 'invoicing' );
1231
+        $label2   = __('Placeholder text', 'invoicing');
1232 1232
         $id2      = $field . '.id + "_edit2"';
1233
-        $label3   = __( 'Help text', 'invoicing' );
1234
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1233
+        $label3   = __('Help text', 'invoicing');
1234
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1235 1235
         $id3      = $field . '.id + "_edit3"';
1236
-        $label5   = __( 'Is this field required?', 'invoicing' );
1236
+        $label5   = __('Is this field required?', 'invoicing');
1237 1237
         $id4      = $field . '.id + "_edit4"';
1238 1238
         echo "
1239 1239
             <div $restrict>
@@ -1261,23 +1261,23 @@  discard block
 block discarded – undo
1261 1261
     /**
1262 1262
      * Renders the separator element template.
1263 1263
      */
1264
-    public function render_separator_template( $field ) {
1265
-        $restrict = $this->get_restrict_markup( $field, 'separator' );
1264
+    public function render_separator_template($field) {
1265
+        $restrict = $this->get_restrict_markup($field, 'separator');
1266 1266
         echo "<hr class='featurette-divider mt-0 mb-2' $restrict>";
1267 1267
     }
1268 1268
 
1269 1269
     /**
1270 1270
      * Renders the separator element on the frontend.
1271 1271
      */
1272
-    public function frontend_render_separator_template( $field ) {
1272
+    public function frontend_render_separator_template($field) {
1273 1273
         echo '<hr class="featurette-divider mt-0 mb-2" />';
1274 1274
     }
1275 1275
 
1276 1276
     /**
1277 1277
      * Renders the pay button element template.
1278 1278
      */
1279
-    public function render_pay_button_template( $field ) {
1280
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1279
+    public function render_pay_button_template($field) {
1280
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1281 1281
         $label    = "$field.label";
1282 1282
         echo "
1283 1283
             <div $restrict>
@@ -1290,24 +1290,24 @@  discard block
 block discarded – undo
1290 1290
     /**
1291 1291
      * Renders the pay_button element on the frontend.
1292 1292
      */
1293
-    public function frontend_render_pay_button_template( $field ) {
1293
+    public function frontend_render_pay_button_template($field) {
1294 1294
         
1295 1295
         echo "<div class='form-group'>";
1296 1296
 
1297
-        $class = 'btn btn-block submit-button ' . sanitize_html_class( $field['class'] );
1297
+        $class = 'btn btn-block submit-button ' . sanitize_html_class($field['class']);
1298 1298
         echo aui()->input(
1299 1299
             array(
1300
-                'name'       => esc_attr( $field['id'] ),
1301
-                'id'         => esc_attr( $field['id'] ),
1302
-                'value'      => esc_attr( $field['label'] ),
1300
+                'name'       => esc_attr($field['id']),
1301
+                'id'         => esc_attr($field['id']),
1302
+                'value'      => esc_attr($field['label']),
1303 1303
                 'no_wrap'    => true,
1304 1304
                 'type'       => 'submit',
1305 1305
                 'class'      => $class,
1306 1306
             )
1307 1307
         );
1308 1308
 
1309
-        if ( ! empty( $field['description'] ) ) {
1310
-            $description = wp_kses_post( $field['description'] );
1309
+        if (!empty($field['description'])) {
1310
+            $description = wp_kses_post($field['description']);
1311 1311
             echo "<small class='form-text text-muted'>$description</small>";
1312 1312
         }
1313 1313
 
@@ -1318,14 +1318,14 @@  discard block
 block discarded – undo
1318 1318
     /**
1319 1319
      * Renders the pay button element template.
1320 1320
      */
1321
-    public function edit_pay_button_template( $field ) {
1322
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1323
-        $label    = __( 'Button Text', 'invoicing' );
1321
+    public function edit_pay_button_template($field) {
1322
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1323
+        $label    = __('Button Text', 'invoicing');
1324 1324
         $id       = $field . '.id + "_edit"';
1325
-        $label2   = __( 'Help text', 'invoicing' );
1326
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1325
+        $label2   = __('Help text', 'invoicing');
1326
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1327 1327
         $id2      = $field . '.id + "_edit2"';
1328
-        $label4   = esc_attr__( 'Button Type', 'invoicing' );
1328
+        $label4   = esc_attr__('Button Type', 'invoicing');
1329 1329
         $id3      = $field . '.id + "_edit3"';
1330 1330
         echo "
1331 1331
             <div $restrict>
@@ -1341,15 +1341,15 @@  discard block
 block discarded – undo
1341 1341
                     <label :for='$id3'>$label4</label>
1342 1342
 
1343 1343
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1344
-                        <option value='btn-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1345
-                        <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1346
-                        <option value='btn-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1347
-                        <option value='btn-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1348
-                        <option value='btn-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1349
-                        <option value='btn-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1350
-                        <option value='btn-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1351
-                        <option value='btn-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1352
-                        <option value='btn-link'>"      . __( 'Link', 'invoicing' ) ."</option>
1344
+                        <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option>
1345
+                        <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option>
1346
+                        <option value='btn-success'>"   . __('Success', 'invoicing') . "</option>
1347
+                        <option value='btn-danger'>"    . __('Danger', 'invoicing') . "</option>
1348
+                        <option value='btn-warning'>"   . __('Warning', 'invoicing') . "</option>
1349
+                        <option value='btn-info'>"      . __('Info', 'invoicing') . "</option>
1350
+                        <option value='btn-light'>"     . __('Light', 'invoicing') . "</option>
1351
+                        <option value='btn-dark'>"      . __('Dark', 'invoicing') . "</option>
1352
+                        <option value='btn-link'>"      . __('Link', 'invoicing') . "</option>
1353 1353
                     </select>
1354 1354
                 </div>
1355 1355
             </div>
@@ -1360,8 +1360,8 @@  discard block
 block discarded – undo
1360 1360
     /**
1361 1361
      * Renders the alert element template.
1362 1362
      */
1363
-    public function render_alert_template( $field ) {
1364
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1363
+    public function render_alert_template($field) {
1364
+        $restrict = $this->get_restrict_markup($field, 'alert');
1365 1365
         $text     = "$field.text";
1366 1366
         echo "
1367 1367
             <div $restrict class='alert' :class='$field.class' role='alert'>
@@ -1376,15 +1376,15 @@  discard block
 block discarded – undo
1376 1376
     /**
1377 1377
      * Renders the alert element on the frontend.
1378 1378
      */
1379
-    public function frontend_render_alert_template( $field ) {
1379
+    public function frontend_render_alert_template($field) {
1380 1380
         
1381 1381
         echo "<div class='form-group'>";
1382 1382
 
1383 1383
         echo aui()->alert(
1384 1384
             array(
1385
-                'content'     => wp_kses_post( $field['text'] ),
1385
+                'content'     => wp_kses_post($field['text']),
1386 1386
                 'dismissible' => $field['dismissible'],
1387
-                'type'        => str_replace( 'alert-', '', $field['class'] ),
1387
+                'type'        => str_replace('alert-', '', $field['class']),
1388 1388
             )
1389 1389
         );
1390 1390
 
@@ -1395,14 +1395,14 @@  discard block
 block discarded – undo
1395 1395
     /**
1396 1396
      * Renders the alert element template.
1397 1397
      */
1398
-    public function edit_alert_template( $field ) {
1399
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1400
-        $label    = __( 'Alert Text', 'invoicing' );
1401
-        $label2   = esc_attr__( 'Enter your alert text here', 'invoicing' );
1398
+    public function edit_alert_template($field) {
1399
+        $restrict = $this->get_restrict_markup($field, 'alert');
1400
+        $label    = __('Alert Text', 'invoicing');
1401
+        $label2   = esc_attr__('Enter your alert text here', 'invoicing');
1402 1402
         $id       = $field . '.id + "_edit"';
1403
-        $label3   = __( 'Is Dismissible?', 'invoicing' );
1403
+        $label3   = __('Is Dismissible?', 'invoicing');
1404 1404
         $id2      = $field . '.id + "_edit2"';
1405
-        $label4   = esc_attr__( 'Alert Type', 'invoicing' );
1405
+        $label4   = esc_attr__('Alert Type', 'invoicing');
1406 1406
         $id3      = $field . '.id + "_edit3"';
1407 1407
         echo "
1408 1408
             <div $restrict>
@@ -1418,14 +1418,14 @@  discard block
 block discarded – undo
1418 1418
                     <label :for='$id3'>$label4</label>
1419 1419
 
1420 1420
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1421
-                        <option value='alert-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1422
-                        <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1423
-                        <option value='alert-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1424
-                        <option value='alert-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1425
-                        <option value='alert-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1426
-                        <option value='alert-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1427
-                        <option value='alert-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1428
-                        <option value='alert-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1421
+                        <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option>
1422
+                        <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option>
1423
+                        <option value='alert-success'>"   . __('Success', 'invoicing') . "</option>
1424
+                        <option value='alert-danger'>"    . __('Danger', 'invoicing') . "</option>
1425
+                        <option value='alert-warning'>"   . __('Warning', 'invoicing') . "</option>
1426
+                        <option value='alert-info'>"      . __('Info', 'invoicing') . "</option>
1427
+                        <option value='alert-light'>"     . __('Light', 'invoicing') . "</option>
1428
+                        <option value='alert-dark'>"      . __('Dark', 'invoicing') . "</option>
1429 1429
                     </select>
1430 1430
                 </div>
1431 1431
             </div>
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
     /**
1437 1437
      * Renders the discount element template.
1438 1438
      */
1439
-    public function render_discount_template( $field ) {
1440
-        $restrict  = $this->get_restrict_markup( $field, 'discount' );
1439
+    public function render_discount_template($field) {
1440
+        $restrict = $this->get_restrict_markup($field, 'discount');
1441 1441
         ?>
1442 1442
 
1443 1443
             <div <?php echo $restrict; ?> class="discount_field  border rounded p-3">
@@ -1454,13 +1454,13 @@  discard block
 block discarded – undo
1454 1454
     /**
1455 1455
      * Renders the discount element on the frontend.
1456 1456
      */
1457
-    public function frontend_render_discount_template( $field ) {
1457
+    public function frontend_render_discount_template($field) {
1458 1458
         
1459
-        $placeholder = esc_attr( $field['input_label'] );
1460
-        $label       = sanitize_text_field( $field['button_label'] );
1459
+        $placeholder = esc_attr($field['input_label']);
1460
+        $label       = sanitize_text_field($field['button_label']);
1461 1461
         $description = '';
1462 1462
 
1463
-        if ( ! empty( $field['description'] ) ) {
1463
+        if (!empty($field['description'])) {
1464 1464
             $description = "<small class='form-text text-muted'>{$field['description']}</small>";
1465 1465
         }
1466 1466
 ?>
@@ -1481,12 +1481,12 @@  discard block
 block discarded – undo
1481 1481
     /**
1482 1482
      * Renders the discount element template.
1483 1483
      */
1484
-    public function edit_discount_template( $field ) {
1485
-        $restrict = $this->get_restrict_markup( $field, 'discount' );
1486
-        $label    = __( 'Discount Input Placeholder', 'invoicing' );
1487
-        $label2   = __( 'Help Text', 'invoicing' );
1488
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1489
-        $label4   = __( 'Button Text', 'invoicing' );
1484
+    public function edit_discount_template($field) {
1485
+        $restrict = $this->get_restrict_markup($field, 'discount');
1486
+        $label    = __('Discount Input Placeholder', 'invoicing');
1487
+        $label2   = __('Help Text', 'invoicing');
1488
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1489
+        $label4   = __('Button Text', 'invoicing');
1490 1490
         $id       = $field . '.id + "_edit"';
1491 1491
         $id2      = $field . '.id + "_edit2"';
1492 1492
         $id3      = $field . '.id + "_edit3"';
@@ -1515,8 +1515,8 @@  discard block
 block discarded – undo
1515 1515
     /**
1516 1516
      * Renders the items element template.
1517 1517
      */
1518
-    public function render_items_template( $field ) {
1519
-        $restrict  = $this->get_restrict_markup( $field, 'items' );
1518
+    public function render_items_template($field) {
1519
+        $restrict = $this->get_restrict_markup($field, 'items');
1520 1520
         echo "
1521 1521
             <div $restrict class='item_totals'>
1522 1522
 
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
                 <div v-if='$field.items_type == \"select\"'>
1573 1573
 
1574 1574
                     <select class='form-control custom-select'>
1575
-                        <option value='' disabled selected='selected'>"        . __( 'Select an option', 'invoicing' ) ."</option>
1575
+                        <option value='' disabled selected='selected'>" . __('Select an option', 'invoicing') . "</option>
1576 1576
                         <option v-for='(item, index) in form_items' :value='index'>{{item.title}} &nbsp;{{formatPrice(item.price)}}</option>
1577 1577
                     </select>
1578 1578
                 </div>
@@ -1593,30 +1593,30 @@  discard block
 block discarded – undo
1593 1593
     /**
1594 1594
      * Renders the items element on the frontend.
1595 1595
      */
1596
-    public function frontend_render_items_template( $field, $items ) {
1596
+    public function frontend_render_items_template($field, $items) {
1597 1597
         
1598 1598
         echo "<div class='form-group item_totals'>";
1599 1599
         
1600
-        $id = esc_attr( $field['id'] );
1601
-        if ( 'total' == $field[ 'items_type' ] ) {
1600
+        $id = esc_attr($field['id']);
1601
+        if ('total' == $field['items_type']) {
1602 1602
             $total = 0;
1603 1603
 
1604 1604
             ?>
1605 1605
             <div class="border item_totals_type_total">
1606 1606
 
1607 1607
                 <?php
1608
-                    foreach( $items as $item ) {
1609
-                        $total = $total + floatval( $item['price'] );
1608
+                    foreach ($items as $item) {
1609
+                        $total = $total + floatval($item['price']);
1610 1610
                 ?>
1611 1611
                     <div  class="item_totals_item">
1612 1612
                         <div class='row pl-2 pr-2 pt-2'>
1613
-                            <div class='col-8'><?php echo esc_html( $item['title'] ) ?></div>
1613
+                            <div class='col-8'><?php echo esc_html($item['title']) ?></div>
1614 1614
 
1615
-                            <?php  if ( empty( $item['custom_price'] ) ) { ?>
1615
+                            <?php  if (empty($item['custom_price'])) { ?>
1616 1616
 
1617 1617
                                 <div class='col-4'>
1618
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1619
-                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1618
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1619
+                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1620 1620
                                 </div>
1621 1621
 
1622 1622
                             <?php } else {?>
@@ -1624,15 +1624,15 @@  discard block
 block discarded – undo
1624 1624
                                 <div class='col-4'>
1625 1625
                                     <div class='input-group'>
1626 1626
 
1627
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1627
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1628 1628
                                             <div class='input-group-prepend'>
1629 1629
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1630 1630
                                             </div>
1631 1631
                                         <?php } ?>
1632 1632
 
1633
-                                        <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'] ); ?>'>
1633
+                                        <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']); ?>'>
1634 1634
                                     
1635
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1635
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1636 1636
                                             <div class='input-group-append'>
1637 1637
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1638 1638
                                             </div>
@@ -1643,32 +1643,32 @@  discard block
 block discarded – undo
1643 1643
                             <?php } ?>
1644 1644
 
1645 1645
                         </div>
1646
-                        <?php if ( ! empty( $item['description'] )) { ?>
1647
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1646
+                        <?php if (!empty($item['description'])) { ?>
1647
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1648 1648
                         <?php } ?>
1649 1649
                     </div>
1650 1650
                 <?php } ?>
1651 1651
 
1652 1652
                 <div class='mt-4 border-top item_totals_total'>
1653 1653
                     <div class='row p-2'>
1654
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1655
-                        <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>
1654
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1655
+                        <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>
1656 1656
                     </div>
1657 1657
                 </div>
1658 1658
 
1659 1659
             </div>
1660 1660
         <?php } ?>
1661 1661
 
1662
-        <?php if ( 'radio' == $field[ 'items_type' ] ) { ?>
1662
+        <?php if ('radio' == $field['items_type']) { ?>
1663 1663
             <div class="item_totals_type_radio">
1664 1664
 
1665
-                <?php foreach( $items as $index => $item ) { ?>
1665
+                <?php foreach ($items as $index => $item) { ?>
1666 1666
                     <div  class="form-check">
1667
-                        <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'>
1668
-                        <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>
1667
+                        <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'>
1668
+                        <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>
1669 1669
                     </div>
1670
-                    <?php if ( ! empty( $item['description'] )) { ?>
1671
-                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1670
+                    <?php if (!empty($item['description'])) { ?>
1671
+                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1672 1672
                     <?php } ?>
1673 1673
                 <?php } ?>
1674 1674
 
@@ -1678,17 +1678,17 @@  discard block
 block discarded – undo
1678 1678
 
1679 1679
                         $total = 0;
1680 1680
 
1681
-                        foreach ( $items as $item ) {
1681
+                        foreach ($items as $item) {
1682 1682
 
1683 1683
                             $class = 'd-none';
1684 1684
                             $name  = '';
1685
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) {
1685
+                            if (!empty($item['required']) || !isset($totals_selected_radio_item)) {
1686 1686
 
1687
-                                $total = $total + floatval( $item['price'] );
1687
+                                $total = $total + floatval($item['price']);
1688 1688
                                 $class = '';
1689 1689
                                 $name  = "wpinv-items[{$item['id']}]";
1690 1690
 
1691
-                                if ( empty( $item['required'] ) ) {
1691
+                                if (empty($item['required'])) {
1692 1692
                                     $totals_selected_radio_item = 1;
1693 1693
                                 }
1694 1694
 
@@ -1700,13 +1700,13 @@  discard block
 block discarded – undo
1700 1700
 
1701 1701
                     <div  class="item_totals_item <?php echo $class; ?>" data-id="<?php echo (int) $item['id']; ?>">
1702 1702
                         <div class='row pl-2 pr-2 pt-2'>
1703
-                            <div class='col-8'><?php echo esc_html( $item['title'] ) ?></div>
1703
+                            <div class='col-8'><?php echo esc_html($item['title']) ?></div>
1704 1704
 
1705
-                            <?php  if ( empty( $item['custom_price'] ) ) { ?>
1705
+                            <?php  if (empty($item['custom_price'])) { ?>
1706 1706
 
1707 1707
                                 <div class='col-4'>
1708
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1709
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1708
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1709
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1710 1710
                                 </div>
1711 1711
 
1712 1712
                             <?php } else {?>
@@ -1714,15 +1714,15 @@  discard block
 block discarded – undo
1714 1714
                                 <div class='col-4'>
1715 1715
                                     <div class='input-group'>
1716 1716
 
1717
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1717
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1718 1718
                                             <div class='input-group-prepend'>
1719 1719
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1720 1720
                                             </div>
1721 1721
                                         <?php } ?>
1722 1722
 
1723
-                                        <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'] ); ?>'>
1723
+                                        <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']); ?>'>
1724 1724
                                     
1725
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1725
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1726 1726
                                             <div class='input-group-append'>
1727 1727
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1728 1728
                                             </div>
@@ -1733,16 +1733,16 @@  discard block
 block discarded – undo
1733 1733
                             <?php } ?>
1734 1734
 
1735 1735
                         </div>
1736
-                        <?php if ( ! empty( $item['description'] )) { ?>
1737
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1736
+                        <?php if (!empty($item['description'])) { ?>
1737
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1738 1738
                         <?php } ?>
1739 1739
                     </div>
1740 1740
                 <?php } ?>
1741 1741
 
1742 1742
                 <div class='mt-4 border-top item_totals_total'>
1743 1743
                     <div class='row p-2'>
1744
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1745
-                        <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>
1744
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1745
+                        <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>
1746 1746
                     </div>
1747 1747
                 </div>
1748 1748
 
@@ -1750,17 +1750,17 @@  discard block
 block discarded – undo
1750 1750
             </div>
1751 1751
         <?php } ?>
1752 1752
 
1753
-        <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?>
1753
+        <?php if ('checkbox' == $field['items_type']) { ?>
1754 1754
 
1755 1755
             <div class="item_totals_type_checkbox">
1756 1756
 
1757 1757
                 <?php
1758
-                    foreach ( $items as $index => $item ) {
1759
-                        $title = sanitize_text_field(  $item['title'] );
1760
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
1761
-                        $item_id    = esc_attr( $id . "_$index" );
1762
-                        $value = esc_attr( $item['id'] );
1763
-                        $checked = checked( ! isset( $selected_checkbox_item ), true, false );
1758
+                    foreach ($items as $index => $item) {
1759
+                        $title = sanitize_text_field($item['title']);
1760
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
1761
+                        $item_id = esc_attr($id . "_$index");
1762
+                        $value = esc_attr($item['id']);
1763
+                        $checked = checked(!isset($selected_checkbox_item), true, false);
1764 1764
                         $selected_checkbox_item = 1;
1765 1765
 
1766 1766
                         echo "
@@ -1769,7 +1769,7 @@  discard block
 block discarded – undo
1769 1769
                                 <label for='$item_id' class='custom-control-label'>$title &nbsp; ($price)</label>
1770 1770
                             </div>";
1771 1771
 
1772
-                        if ( ! empty( $item['description'] ) ) {
1772
+                        if (!empty($item['description'])) {
1773 1773
                             echo "<small class='form-text text-muted'>{$item['description']}</small>";
1774 1774
                         }
1775 1775
                     }
@@ -1781,17 +1781,17 @@  discard block
 block discarded – undo
1781 1781
 
1782 1782
                         $total = 0;
1783 1783
 
1784
-                        foreach ( $items as $item ) {
1784
+                        foreach ($items as $item) {
1785 1785
 
1786 1786
                             $class = 'd-none';
1787 1787
                             $name  = '';
1788
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) {
1788
+                            if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) {
1789 1789
 
1790
-                                $total = $total + floatval( $item['price'] );
1790
+                                $total = $total + floatval($item['price']);
1791 1791
                                 $class = '';
1792 1792
                                 $name  = "wpinv-items[{$item['id']}]";
1793 1793
 
1794
-                                if ( empty( $item['required'] ) ) {
1794
+                                if (empty($item['required'])) {
1795 1795
                                     $totals_selected_checkbox_item = 1;
1796 1796
                                 }
1797 1797
 
@@ -1803,13 +1803,13 @@  discard block
 block discarded – undo
1803 1803
 
1804 1804
                     <div  class="item_totals_item <?php echo $class; ?>" data-id="<?php echo (int) $item['id']; ?>">
1805 1805
                         <div class='row pl-2 pr-2 pt-2'>
1806
-                            <div class='col-8'><?php echo esc_html( $item['title'] ) ?></div>
1806
+                            <div class='col-8'><?php echo esc_html($item['title']) ?></div>
1807 1807
 
1808
-                            <?php  if ( empty( $item['custom_price'] ) ) { ?>
1808
+                            <?php  if (empty($item['custom_price'])) { ?>
1809 1809
 
1810 1810
                                 <div class='col-4'>
1811
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1812
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1811
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1812
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1813 1813
                                 </div>
1814 1814
 
1815 1815
                             <?php } else {?>
@@ -1817,15 +1817,15 @@  discard block
 block discarded – undo
1817 1817
                                 <div class='col-4'>
1818 1818
                                     <div class='input-group'>
1819 1819
 
1820
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1820
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1821 1821
                                             <div class='input-group-prepend'>
1822 1822
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1823 1823
                                             </div>
1824 1824
                                         <?php } ?>
1825 1825
 
1826
-                                        <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'] ); ?>'>
1826
+                                        <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']); ?>'>
1827 1827
                                     
1828
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1828
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1829 1829
                                             <div class='input-group-append'>
1830 1830
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1831 1831
                                             </div>
@@ -1836,23 +1836,23 @@  discard block
 block discarded – undo
1836 1836
                             <?php } ?>
1837 1837
 
1838 1838
                         </div>
1839
-                        <?php if ( ! empty( $item['description'] )) { ?>
1840
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1839
+                        <?php if (!empty($item['description'])) { ?>
1840
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1841 1841
                         <?php } ?>
1842 1842
                     </div>
1843 1843
                 <?php } ?>
1844 1844
 
1845 1845
                 <div class='mt-4 border-top item_totals_total'>
1846 1846
                     <div class='row p-2'>
1847
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1848
-                        <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>
1847
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1848
+                        <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>
1849 1849
                     </div>
1850 1850
                 </div>
1851 1851
             </div>
1852 1852
             </div>
1853 1853
         <?php } ?>
1854 1854
 
1855
-        <?php if ( 'select' == $field[ 'items_type' ] ) { ?>
1855
+        <?php if ('select' == $field['items_type']) { ?>
1856 1856
 
1857 1857
             <div class="item_totals_type_select">
1858 1858
 
@@ -1860,12 +1860,12 @@  discard block
 block discarded – undo
1860 1860
 
1861 1861
                     $options  = array();
1862 1862
                     $selected = '';
1863
-                    foreach ( $items as $index => $item ) {
1864
-                        $title = sanitize_text_field(  $item['title'] );
1865
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
1866
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
1863
+                    foreach ($items as $index => $item) {
1864
+                        $title = sanitize_text_field($item['title']);
1865
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
1866
+                        $options[$item['id']] = "$title &nbsp; ($price)";
1867 1867
 
1868
-                        if ( ! isset( $selected_item ) ) {
1868
+                        if (!isset($selected_item)) {
1869 1869
                             $selected = $item['id'];
1870 1870
                             $selected_item = 1;
1871 1871
                         }
@@ -1876,7 +1876,7 @@  discard block
 block discarded – undo
1876 1876
                         array(
1877 1877
                                 'name'        => 'payment-form-items',
1878 1878
                                 'id'          => $id,
1879
-                                'placeholder' => __( 'Select an item', 'invoicing' ),
1879
+                                'placeholder' => __('Select an item', 'invoicing'),
1880 1880
                                 'no_wrap'     => true,
1881 1881
                                 'options'     => $options,
1882 1882
                                 'class'       => 'wpi_select2 wpinv-items-select-selector',
@@ -1891,17 +1891,17 @@  discard block
 block discarded – undo
1891 1891
 
1892 1892
                         $total = 0;
1893 1893
 
1894
-                        foreach ( $items as $item ) {
1894
+                        foreach ($items as $item) {
1895 1895
 
1896 1896
                             $class = 'd-none';
1897 1897
                             $name  = '';
1898
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
1898
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
1899 1899
 
1900
-                                $total = $total + floatval( $item['price'] );
1900
+                                $total = $total + floatval($item['price']);
1901 1901
                                 $class = '';
1902 1902
                                 $name  = "wpinv-items[{$item['id']}]";
1903 1903
 
1904
-                                if ( empty( $item['required'] ) ) {
1904
+                                if (empty($item['required'])) {
1905 1905
                                     $totals_selected_select_item = 1;
1906 1906
                                 }
1907 1907
 
@@ -1913,13 +1913,13 @@  discard block
 block discarded – undo
1913 1913
 
1914 1914
                     <div  class="item_totals_item <?php echo $class; ?>" data-id="<?php echo (int) $item['id']; ?>">
1915 1915
                         <div class='row pl-2 pr-2 pt-2'>
1916
-                            <div class='col-8'><?php echo esc_html( $item['title'] ) ?></div>
1916
+                            <div class='col-8'><?php echo esc_html($item['title']) ?></div>
1917 1917
 
1918
-                            <?php  if ( empty( $item['custom_price'] ) ) { ?>
1918
+                            <?php  if (empty($item['custom_price'])) { ?>
1919 1919
 
1920 1920
                                 <div class='col-4'>
1921
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1922
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1921
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1922
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1923 1923
                                 </div>
1924 1924
 
1925 1925
                             <?php } else {?>
@@ -1927,15 +1927,15 @@  discard block
 block discarded – undo
1927 1927
                                 <div class='col-4'>
1928 1928
                                     <div class='input-group'>
1929 1929
 
1930
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1930
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1931 1931
                                             <div class='input-group-prepend'>
1932 1932
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1933 1933
                                             </div>
1934 1934
                                         <?php } ?>
1935 1935
 
1936
-                                        <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'] ); ?>'>
1936
+                                        <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']); ?>'>
1937 1937
                                     
1938
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1938
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1939 1939
                                             <div class='input-group-append'>
1940 1940
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1941 1941
                                             </div>
@@ -1946,23 +1946,23 @@  discard block
 block discarded – undo
1946 1946
                             <?php } ?>
1947 1947
 
1948 1948
                         </div>
1949
-                        <?php if ( ! empty( $item['description'] )) { ?>
1950
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1949
+                        <?php if (!empty($item['description'])) { ?>
1950
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1951 1951
                         <?php } ?>
1952 1952
                     </div>
1953 1953
                 <?php } ?>
1954 1954
 
1955 1955
                 <div class='mt-4 border-top item_totals_total'>
1956 1956
                     <div class='row p-2'>
1957
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1958
-                        <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>
1957
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1958
+                        <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>
1959 1959
                     </div>
1960 1960
                 </div>
1961 1961
 
1962 1962
             </div>
1963 1963
         <?php } ?>
1964 1964
 
1965
-        <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?>
1965
+        <?php if ('multi_select' == $field['items_type']) { ?>
1966 1966
 
1967 1967
             <div class="item_totals_type_multi_select">
1968 1968
 
@@ -1971,13 +1971,13 @@  discard block
 block discarded – undo
1971 1971
                     $options  = array();
1972 1972
                     $selected = array();
1973 1973
 
1974
-                    foreach ( $items as $index => $item ) {
1975
-                        $title = sanitize_text_field(  $item['title'] );
1976
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
1977
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
1974
+                    foreach ($items as $index => $item) {
1975
+                        $title = sanitize_text_field($item['title']);
1976
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
1977
+                        $options[$item['id']] = "$title &nbsp; ($price)";
1978 1978
 
1979
-                        if ( ! isset( $selected_item ) ) {
1980
-                            $selected = array( $item['id'] );
1979
+                        if (!isset($selected_item)) {
1980
+                            $selected = array($item['id']);
1981 1981
                             $selected_item = 1;
1982 1982
                         }
1983 1983
 
@@ -2002,17 +2002,17 @@  discard block
 block discarded – undo
2002 2002
 
2003 2003
                         $total = 0;
2004 2004
 
2005
-                        foreach ( $items as $item ) {
2005
+                        foreach ($items as $item) {
2006 2006
 
2007 2007
                             $class = 'd-none';
2008 2008
                             $name  = '';
2009
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2009
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2010 2010
 
2011
-                                $total = $total + floatval( $item['price'] );
2011
+                                $total = $total + floatval($item['price']);
2012 2012
                                 $class = '';
2013 2013
                                 $name  = "wpinv-items[{$item['id']}]";
2014 2014
 
2015
-                                if ( empty( $item['required'] ) ) {
2015
+                                if (empty($item['required'])) {
2016 2016
                                     $totals_selected_select_item = 1;
2017 2017
                                 }
2018 2018
 
@@ -2024,13 +2024,13 @@  discard block
 block discarded – undo
2024 2024
 
2025 2025
                     <div  class="item_totals_item <?php echo $class; ?>" data-id="<?php echo (int) $item['id']; ?>">
2026 2026
                         <div class='row pl-2 pr-2 pt-2'>
2027
-                            <div class='col-8'><?php echo esc_html( $item['title'] ) ?></div>
2027
+                            <div class='col-8'><?php echo esc_html($item['title']) ?></div>
2028 2028
 
2029
-                            <?php  if ( empty( $item['custom_price'] ) ) { ?>
2029
+                            <?php  if (empty($item['custom_price'])) { ?>
2030 2030
 
2031 2031
                                 <div class='col-4'>
2032
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2033
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2032
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2033
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2034 2034
                                 </div>
2035 2035
 
2036 2036
                             <?php } else {?>
@@ -2038,15 +2038,15 @@  discard block
 block discarded – undo
2038 2038
                                 <div class='col-4'>
2039 2039
                                     <div class='input-group'>
2040 2040
 
2041
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2041
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2042 2042
                                             <div class='input-group-prepend'>
2043 2043
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2044 2044
                                             </div>
2045 2045
                                         <?php } ?>
2046 2046
 
2047
-                                        <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'] ); ?>'>
2047
+                                        <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']); ?>'>
2048 2048
                                     
2049
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2049
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2050 2050
                                             <div class='input-group-append'>
2051 2051
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2052 2052
                                             </div>
@@ -2057,23 +2057,23 @@  discard block
 block discarded – undo
2057 2057
                             <?php } ?>
2058 2058
 
2059 2059
                         </div>
2060
-                        <?php if ( ! empty( $item['description'] )) { ?>
2061
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2060
+                        <?php if (!empty($item['description'])) { ?>
2061
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2062 2062
                         <?php } ?>
2063 2063
                     </div>
2064 2064
                 <?php } ?>
2065 2065
 
2066 2066
                 <div class='mt-4 border-top item_totals_total'>
2067 2067
                     <div class='row p-2'>
2068
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2069
-                        <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>
2068
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2069
+                        <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>
2070 2070
                     </div>
2071 2071
                 </div>
2072 2072
 
2073 2073
             </div>
2074 2074
         <?php } ?>
2075
-        <?php if ( ! empty( $field[ 'description' ] ) ) { ?>
2076
-            <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small>
2075
+        <?php if (!empty($field['description'])) { ?>
2076
+            <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small>
2077 2077
         <?php } ?>
2078 2078
         </div>
2079 2079
         <?php
@@ -2082,18 +2082,18 @@  discard block
 block discarded – undo
2082 2082
     /**
2083 2083
      * Renders the items element template.
2084 2084
      */
2085
-    public function edit_items_template( $field ) {
2086
-        $restrict = $this->get_restrict_markup( $field, 'items' );
2087
-        $label    = __( 'Let customers...', 'invoicing' );
2088
-        $label2   = __( 'Available Items', 'invoicing' );
2089
-        $label3   = esc_attr__( 'Add some help text for this element', 'invoicing' );
2085
+    public function edit_items_template($field) {
2086
+        $restrict = $this->get_restrict_markup($field, 'items');
2087
+        $label    = __('Let customers...', 'invoicing');
2088
+        $label2   = __('Available Items', 'invoicing');
2089
+        $label3   = esc_attr__('Add some help text for this element', 'invoicing');
2090 2090
         $id       = $field . '.id + "_edit"';
2091 2091
         $id2      = $field . '.id + "_edit2"';
2092 2092
         $id3      = $field . '.id + "_edit3"';
2093 2093
         $id4      = $field . '.id + "_edit4"';
2094
-        $label4   = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' );
2095
-        $label5   = esc_attr__( 'Allow users to pay what they want', 'invoicing' );
2096
-        $label6   = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' );
2094
+        $label4   = esc_attr__('This will be shown to the customer as the recommended price', 'invoicing');
2095
+        $label5   = esc_attr__('Allow users to pay what they want', 'invoicing');
2096
+        $label6   = esc_attr__('Enter the minimum price that a user can pay', 'invoicing');
2097 2097
         echo "<div $restrict>
2098 2098
 
2099 2099
                 <label>$label2</label>
@@ -2153,7 +2153,7 @@  discard block
 block discarded – undo
2153 2153
                 <div class='form-group mt-2'>
2154 2154
 
2155 2155
                     <select class='form-control custom-select' v-model='selected_item'>
2156
-                        <option value=''>"        . __( 'Add an existing item to the form', 'invoicing' ) ."</option>
2156
+                        <option value=''>" . __('Add an existing item to the form', 'invoicing') . "</option>
2157 2157
                         <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option>
2158 2158
                     </select>
2159 2159
 
@@ -2168,11 +2168,11 @@  discard block
 block discarded – undo
2168 2168
                     <label :for='$id2'>$label</label>
2169 2169
 
2170 2170
                     <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'>
2171
-                        <option value='total'>"        . __( 'Buy all items on the list', 'invoicing' ) ."</option>
2172
-                        <option value='radio'>"        . __( 'Select a single item from the list', 'invoicing' ) ."</option>
2173
-                        <option value='checkbox'>"     . __( 'Select one or more items on the list', 'invoicing' ) ."</option>
2174
-                        <option value='select'>"       . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option>
2175
-                        <option value='multi_select'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option>
2171
+                        <option value='total'>" . __('Buy all items on the list', 'invoicing') . "</option>
2172
+                        <option value='radio'>"        . __('Select a single item from the list', 'invoicing') . "</option>
2173
+                        <option value='checkbox'>"     . __('Select one or more items on the list', 'invoicing') . "</option>
2174
+                        <option value='select'>"       . __('Select a single item from a dropdown', 'invoicing') . "</option>
2175
+                        <option value='multi_select'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option>
2176 2176
                     </select>
2177 2177
 
2178 2178
                 </div>
@@ -2197,26 +2197,26 @@  discard block
 block discarded – undo
2197 2197
             'orderby'        => 'title',
2198 2198
             'order'          => 'ASC',
2199 2199
             'posts_per_page' => -1,
2200
-            'post_status'    => array( 'publish' ),
2200
+            'post_status'    => array('publish'),
2201 2201
         );
2202 2202
     
2203
-        $items      = get_posts( apply_filters( 'wpinv_item_dropdown_query_args', $item_args ) );
2203
+        $items = get_posts(apply_filters('wpinv_item_dropdown_query_args', $item_args));
2204 2204
 
2205
-        if ( empty( $items ) ) {
2205
+        if (empty($items)) {
2206 2206
             return array();
2207 2207
         }
2208 2208
 
2209
-        $options    = array();
2210
-        foreach ( $items as $item ) {
2211
-            $title         = esc_html( $item->post_title );
2212
-            $title        .= wpinv_get_item_suffix( $item->ID, false );
2213
-            $id            = absint( $item->ID );
2214
-            $price         = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) );
2215
-            $recurring     = (bool) get_post_meta( $id, '_wpinv_is_recurring', true );
2209
+        $options = array();
2210
+        foreach ($items as $item) {
2211
+            $title         = esc_html($item->post_title);
2212
+            $title        .= wpinv_get_item_suffix($item->ID, false);
2213
+            $id            = absint($item->ID);
2214
+            $price         = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true));
2215
+            $recurring     = (bool) get_post_meta($id, '_wpinv_is_recurring', true);
2216 2216
             $description   = $item->post_excerpt;
2217
-            $custom_price  = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true );
2218
-            $minimum_price = (float) get_post_meta( $id, '_minimum_price', true );
2219
-            $options[]     = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price' );
2217
+            $custom_price  = (bool) get_post_meta($id, '_wpinv_dynamic_pricing', true);
2218
+            $minimum_price = (float) get_post_meta($id, '_minimum_price', true);
2219
+            $options[]     = compact('title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price');
2220 2220
 
2221 2221
         }
2222 2222
         return $options;
@@ -2226,38 +2226,38 @@  discard block
 block discarded – undo
2226 2226
     /**
2227 2227
      * Returns an array of items for the currently being edited form.
2228 2228
      */
2229
-    public function get_form_items( $id = false ) {
2229
+    public function get_form_items($id = false) {
2230 2230
         
2231
-        if ( empty( $id ) ) {
2232
-            return wpinv_get_data( 'sample-payment-form-items' );
2231
+        if (empty($id)) {
2232
+            return wpinv_get_data('sample-payment-form-items');
2233 2233
         }
2234 2234
         
2235
-        $form_elements = get_post_meta( $id, 'wpinv_form_items', true );
2235
+        $form_elements = get_post_meta($id, 'wpinv_form_items', true);
2236 2236
 
2237
-        if ( is_array( $form_elements ) ) {
2237
+        if (is_array($form_elements)) {
2238 2238
             return $form_elements;
2239 2239
         }
2240 2240
 
2241
-        return wpinv_get_data( 'sample-payment-form-items' );
2241
+        return wpinv_get_data('sample-payment-form-items');
2242 2242
 
2243 2243
     }
2244 2244
 
2245 2245
     /**
2246 2246
      * Returns an array of elements for the currently being edited form.
2247 2247
      */
2248
-    public function get_form_elements( $id = false ) {
2248
+    public function get_form_elements($id = false) {
2249 2249
 
2250
-        if ( empty( $id ) ) {
2251
-            return wpinv_get_data( 'sample-payment-form' );
2250
+        if (empty($id)) {
2251
+            return wpinv_get_data('sample-payment-form');
2252 2252
         }
2253 2253
         
2254
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
2254
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
2255 2255
 
2256
-        if ( is_array( $form_elements ) ) {
2256
+        if (is_array($form_elements)) {
2257 2257
             return $form_elements;
2258 2258
         }
2259 2259
 
2260
-        return wpinv_get_data( 'sample-payment-form' );
2260
+        return wpinv_get_data('sample-payment-form');
2261 2261
     }
2262 2262
 
2263 2263
 }
Please login to merge, or discard this patch.