Passed
Pull Request — master (#284)
by Brian
07:10
created
includes/wpinv-post-types.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -7,38 +7,38 @@  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
-add_action( 'init', 'wpinv_register_post_types', 1 );
14
+add_action('init', 'wpinv_register_post_types', 1);
15 15
 function wpinv_register_post_types() {
16 16
     
17 17
     $labels = array(
18
-        'name'               => _x( 'Invoices', 'post type general name', 'invoicing' ),
19
-        'singular_name'      => _x( 'Invoice', 'post type singular name', 'invoicing' ),
20
-        'menu_name'          => _x( 'Invoices', 'admin menu', 'invoicing' ),
21
-        'name_admin_bar'     => _x( 'Invoice', 'add new on admin bar', 'invoicing' ),
22
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
23
-        'add_new_item'       => __( 'Add New Invoice', 'invoicing' ),
24
-        'new_item'           => __( 'New Invoice', 'invoicing' ),
25
-        'edit_item'          => __( 'Edit Invoice', 'invoicing' ),
26
-        'view_item'          => __( 'View Invoice', 'invoicing' ),
27
-        'all_items'          => __( 'Invoices', 'invoicing' ),
28
-        'search_items'       => __( 'Search Invoices', 'invoicing' ),
29
-        'parent_item_colon'  => __( 'Parent Invoices:', 'invoicing' ),
30
-        'not_found'          => __( 'No invoices found.', 'invoicing' ),
31
-        'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' )
18
+        'name'               => _x('Invoices', 'post type general name', 'invoicing'),
19
+        'singular_name'      => _x('Invoice', 'post type singular name', 'invoicing'),
20
+        'menu_name'          => _x('Invoices', 'admin menu', 'invoicing'),
21
+        'name_admin_bar'     => _x('Invoice', 'add new on admin bar', 'invoicing'),
22
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
23
+        'add_new_item'       => __('Add New Invoice', 'invoicing'),
24
+        'new_item'           => __('New Invoice', 'invoicing'),
25
+        'edit_item'          => __('Edit Invoice', 'invoicing'),
26
+        'view_item'          => __('View Invoice', 'invoicing'),
27
+        'all_items'          => __('Invoices', 'invoicing'),
28
+        'search_items'       => __('Search Invoices', 'invoicing'),
29
+        'parent_item_colon'  => __('Parent Invoices:', 'invoicing'),
30
+        'not_found'          => __('No invoices found.', 'invoicing'),
31
+        'not_found_in_trash' => __('No invoices found in trash.', 'invoicing')
32 32
     );
33
-    $labels = apply_filters( 'wpinv_labels', $labels );
33
+    $labels = apply_filters('wpinv_labels', $labels);
34 34
     
35 35
     $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico';
36
-    $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon );
36
+    $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon);
37 37
 
38 38
     $cap_type = 'wpi_invoice';
39 39
     $args = array(
40 40
         'labels'             => $labels,
41
-        'description'        => __( 'This is where invoices are stored.', 'invoicing' ),
41
+        'description'        => __('This is where invoices are stored.', 'invoicing'),
42 42
         'public'             => true,
43 43
         'can_export'         => true,
44 44
         '_builtin'           => false,
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
         'has_archive'        => false,
72 72
         'hierarchical'       => false,
73 73
         'menu_position'      => null,
74
-        'supports'           => array( 'title', 'author' ),
74
+        'supports'           => array('title', 'author'),
75 75
         'menu_icon'          => 'dashicons-media-spreadsheet',
76 76
     );
77 77
             
78
-    $args = apply_filters( 'wpinv_register_post_type_invoice', $args );
78
+    $args = apply_filters('wpinv_register_post_type_invoice', $args);
79 79
     
80
-    register_post_type( 'wpi_invoice', $args );
80
+    register_post_type('wpi_invoice', $args);
81 81
 
82 82
     $cap_type = 'wpi_payment_form';
83 83
     register_post_type(
@@ -86,22 +86,22 @@  discard block
 block discarded – undo
86 86
             'wpinv_register_post_type_payment_form',
87 87
             array(
88 88
                 'labels'             => array(
89
-                    'name'               => _x( 'Payment Forms', 'post type general name', 'invoicing' ),
90
-                    'singular_name'      => _x( 'Payment Form', 'post type singular name', 'invoicing' ),
91
-                    'menu_name'          => _x( 'Payment Forms', 'admin menu', 'invoicing' ),
92
-                    'name_admin_bar'     => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ),
93
-                    'add_new'            => _x( 'Add New', 'Payment Form', 'invoicing' ),
94
-                    'add_new_item'       => __( 'Add New Payment Form', 'invoicing' ),
95
-                    'new_item'           => __( 'New Payment Form', 'invoicing' ),
96
-                    'edit_item'          => __( 'Edit Payment Form', 'invoicing' ),
97
-                    'view_item'          => __( 'View Payment Form', 'invoicing' ),
98
-                    'all_items'          => __( 'Payment Forms', 'invoicing' ),
99
-                    'search_items'       => __( 'Search Payment Forms', 'invoicing' ),
100
-                    'parent_item_colon'  => __( 'Parent Payment Forms:', 'invoicing' ),
101
-                    'not_found'          => __( 'No payment forms found.', 'invoicing' ),
102
-                    'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' )
89
+                    'name'               => _x('Payment Forms', 'post type general name', 'invoicing'),
90
+                    'singular_name'      => _x('Payment Form', 'post type singular name', 'invoicing'),
91
+                    'menu_name'          => _x('Payment Forms', 'admin menu', 'invoicing'),
92
+                    'name_admin_bar'     => _x('Payment Form', 'add new on admin bar', 'invoicing'),
93
+                    'add_new'            => _x('Add New', 'Payment Form', 'invoicing'),
94
+                    'add_new_item'       => __('Add New Payment Form', 'invoicing'),
95
+                    'new_item'           => __('New Payment Form', 'invoicing'),
96
+                    'edit_item'          => __('Edit Payment Form', 'invoicing'),
97
+                    'view_item'          => __('View Payment Form', 'invoicing'),
98
+                    'all_items'          => __('Payment Forms', 'invoicing'),
99
+                    'search_items'       => __('Search Payment Forms', 'invoicing'),
100
+                    'parent_item_colon'  => __('Parent Payment Forms:', 'invoicing'),
101
+                    'not_found'          => __('No payment forms found.', 'invoicing'),
102
+                    'not_found_in_trash' => __('No payment forms found in trash.', 'invoicing')
103 103
                 ),
104
-                'description'        => __( 'Stores payment forms.', 'invoicing' ),
104
+                'description'        => __('Stores payment forms.', 'invoicing'),
105 105
                 'public'             => false,
106 106
                 'show_ui'            => true,
107 107
                 'show_in_menu'       => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true,
@@ -112,40 +112,40 @@  discard block
 block discarded – undo
112 112
                 'has_archive'        => false,
113 113
                 'hierarchical'       => false,
114 114
                 'menu_position'      => null,
115
-                'supports'           => array( 'title' ),
115
+                'supports'           => array('title'),
116 116
                 'menu_icon'          => 'dashicons-media-form',
117 117
             )
118 118
         )
119 119
     );
120 120
     
121 121
     $items_labels = array(
122
-        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
123
-        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
124
-        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
125
-        'add_new'            => _x( 'Add New', 'wpi_item', 'invoicing' ),
126
-        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
127
-        'new_item'           => __( 'New Item', 'invoicing' ),
128
-        'edit_item'          => __( 'Edit Item', 'invoicing' ),
129
-        'view_item'          => __( 'View Item', 'invoicing' ),
130
-        'all_items'          => __( 'Items', 'invoicing' ),
131
-        'search_items'       => __( 'Search Items', 'invoicing' ),
122
+        'name'               => _x('Items', 'post type general name', 'invoicing'),
123
+        'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
124
+        'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
125
+        'add_new'            => _x('Add New', 'wpi_item', 'invoicing'),
126
+        'add_new_item'       => __('Add New Item', 'invoicing'),
127
+        'new_item'           => __('New Item', 'invoicing'),
128
+        'edit_item'          => __('Edit Item', 'invoicing'),
129
+        'view_item'          => __('View Item', 'invoicing'),
130
+        'all_items'          => __('Items', 'invoicing'),
131
+        'search_items'       => __('Search Items', 'invoicing'),
132 132
         'parent_item_colon'  => '',
133
-        'not_found'          => __( 'No items found.', 'invoicing' ),
134
-        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
133
+        'not_found'          => __('No items found.', 'invoicing'),
134
+        'not_found_in_trash' => __('No items found in trash.', 'invoicing')
135 135
     );
136
-    $items_labels = apply_filters( 'wpinv_items_labels', $items_labels );
136
+    $items_labels = apply_filters('wpinv_items_labels', $items_labels);
137 137
 
138 138
     $cap_type          = 'wpi_item';
139 139
     $invoice_item_args = array(
140 140
         'labels'                => $items_labels,
141
-        'description'           => __( 'This is where you can add new invoice items.', 'invoicing' ),
141
+        'description'           => __('This is where you can add new invoice items.', 'invoicing'),
142 142
         'public'                => false,
143 143
         'has_archive'           => false,
144 144
         '_builtin'              => false,
145 145
         'show_ui'               => true,
146 146
         'show_in_menu'          => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false,
147 147
         'show_in_nav_menus'     => false,
148
-        'supports'              => array( 'title', 'excerpt' ),
148
+        'supports'              => array('title', 'excerpt'),
149 149
         'register_meta_box_cb'  => 'wpinv_register_item_meta_boxes',
150 150
         'rewrite'               => false,
151 151
         'query_var'             => false,
@@ -172,33 +172,33 @@  discard block
 block discarded – undo
172 172
         ),
173 173
         'can_export'            => true,
174 174
     );
175
-    $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args );
175
+    $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args);
176 176
 
177
-    register_post_type( 'wpi_item', $invoice_item_args );
177
+    register_post_type('wpi_item', $invoice_item_args);
178 178
     
179 179
     $labels = array(
180
-        'name'               => _x( 'Discounts', 'post type general name', 'invoicing' ),
181
-        'singular_name'      => _x( 'Discount', 'post type singular name', 'invoicing' ),
182
-        'menu_name'          => _x( 'Discounts', 'admin menu', 'invoicing' ),
183
-        'name_admin_bar'     => _x( 'Discount', 'add new on admin bar', 'invoicing' ),
184
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
185
-        'add_new_item'       => __( 'Add New Discount', 'invoicing' ),
186
-        'new_item'           => __( 'New Discount', 'invoicing' ),
187
-        'edit_item'          => __( 'Edit Discount', 'invoicing' ),
188
-        'view_item'          => __( 'View Discount', 'invoicing' ),
189
-        'all_items'          => __( 'Discounts', 'invoicing' ),
190
-        'search_items'       => __( 'Search Discounts', 'invoicing' ),
191
-        'parent_item_colon'  => __( 'Parent Discounts:', 'invoicing' ),
192
-        'not_found'          => __( 'No discounts found.', 'invoicing' ),
193
-        'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' )
180
+        'name'               => _x('Discounts', 'post type general name', 'invoicing'),
181
+        'singular_name'      => _x('Discount', 'post type singular name', 'invoicing'),
182
+        'menu_name'          => _x('Discounts', 'admin menu', 'invoicing'),
183
+        'name_admin_bar'     => _x('Discount', 'add new on admin bar', 'invoicing'),
184
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
185
+        'add_new_item'       => __('Add New Discount', 'invoicing'),
186
+        'new_item'           => __('New Discount', 'invoicing'),
187
+        'edit_item'          => __('Edit Discount', 'invoicing'),
188
+        'view_item'          => __('View Discount', 'invoicing'),
189
+        'all_items'          => __('Discounts', 'invoicing'),
190
+        'search_items'       => __('Search Discounts', 'invoicing'),
191
+        'parent_item_colon'  => __('Parent Discounts:', 'invoicing'),
192
+        'not_found'          => __('No discounts found.', 'invoicing'),
193
+        'not_found_in_trash' => __('No discounts found in trash.', 'invoicing')
194 194
     );
195
-    $labels = apply_filters( 'wpinv_discounts_labels', $labels );
195
+    $labels = apply_filters('wpinv_discounts_labels', $labels);
196 196
 
197 197
     $cap_type = 'wpi_discount';
198 198
     
199 199
     $args = array(
200 200
         'labels'             => $labels,
201
-        'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
201
+        'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
202 202
         'public'             => false,
203 203
         'can_export'         => true,
204 204
         '_builtin'           => false,
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         ),
230 230
         'has_archive'        => false,
231 231
         'hierarchical'       => false,
232
-        'supports'           => array( 'title', 'excerpt' ),
232
+        'supports'           => array('title', 'excerpt'),
233 233
         'register_meta_box_cb'  => 'wpinv_register_discount_meta_boxes',
234 234
         'show_in_nav_menus'  => false,
235 235
         'show_in_admin_bar'  => true,
@@ -237,106 +237,106 @@  discard block
 block discarded – undo
237 237
         'menu_position'      => null,
238 238
     );
239 239
             
240
-    $args = apply_filters( 'wpinv_register_post_type_discount', $args );
240
+    $args = apply_filters('wpinv_register_post_type_discount', $args);
241 241
     
242
-    register_post_type( 'wpi_discount', $args );
242
+    register_post_type('wpi_discount', $args);
243 243
 }
244 244
 
245 245
 function wpinv_get_default_labels() {
246 246
     $defaults = array(
247
-       'singular' => __( 'Invoice', 'invoicing' ),
248
-       'plural'   => __( 'Invoices', 'invoicing' )
247
+       'singular' => __('Invoice', 'invoicing'),
248
+       'plural'   => __('Invoices', 'invoicing')
249 249
     );
250 250
     
251
-    return apply_filters( 'wpinv_default_invoices_name', $defaults );
251
+    return apply_filters('wpinv_default_invoices_name', $defaults);
252 252
 }
253 253
 
254
-function wpinv_get_label_singular( $lowercase = false ) {
254
+function wpinv_get_label_singular($lowercase = false) {
255 255
     $defaults = wpinv_get_default_labels();
256 256
     
257
-    return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
257
+    return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
258 258
 }
259 259
 
260
-function wpinv_get_label_plural( $lowercase = false ) {
260
+function wpinv_get_label_plural($lowercase = false) {
261 261
     $defaults = wpinv_get_default_labels();
262 262
     
263
-    return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
263
+    return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
264 264
 }
265 265
 
266
-function wpinv_change_default_title( $title ) {
267
-     if ( !is_admin() ) {
266
+function wpinv_change_default_title($title) {
267
+     if (!is_admin()) {
268 268
         $label = wpinv_get_label_singular();
269
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
269
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
270 270
         return $title;
271 271
      }
272 272
 
273 273
      $screen = get_current_screen();
274 274
 
275
-     if ( 'wpi_invoice' == $screen->post_type ) {
275
+     if ('wpi_invoice' == $screen->post_type) {
276 276
         $label = wpinv_get_label_singular();
277
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
277
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
278 278
      }
279 279
 
280 280
      return $title;
281 281
 }
282
-add_filter( 'enter_title_here', 'wpinv_change_default_title' );
282
+add_filter('enter_title_here', 'wpinv_change_default_title');
283 283
 
284 284
 function wpinv_register_post_status() {
285
-    register_post_status( 'wpi-pending', array(
286
-        'label'                     => _x( 'Pending', 'Invoice status', 'invoicing' ),
285
+    register_post_status('wpi-pending', array(
286
+        'label'                     => _x('Pending', 'Invoice status', 'invoicing'),
287 287
         'public'                    => true,
288 288
         'exclude_from_search'       => true,
289 289
         'show_in_admin_all_list'    => true,
290 290
         'show_in_admin_status_list' => true,
291
-        'label_count'               => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing' )
292
-    ) );
293
-    register_post_status( 'wpi-processing', array(
294
-        'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
291
+        'label_count'               => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing')
292
+    ));
293
+    register_post_status('wpi-processing', array(
294
+        'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
295 295
         'public'                    => true,
296 296
         'exclude_from_search'       => true,
297 297
         'show_in_admin_all_list'    => true,
298 298
         'show_in_admin_status_list' => true,
299
-        'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
300
-    ) );
301
-    register_post_status( 'wpi-onhold', array(
302
-        'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
299
+        'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
300
+    ));
301
+    register_post_status('wpi-onhold', array(
302
+        'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
303 303
         'public'                    => true,
304 304
         'exclude_from_search'       => true,
305 305
         'show_in_admin_all_list'    => true,
306 306
         'show_in_admin_status_list' => true,
307
-        'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
308
-    ) );
309
-    register_post_status( 'wpi-cancelled', array(
310
-        'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
307
+        'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
308
+    ));
309
+    register_post_status('wpi-cancelled', array(
310
+        'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
311 311
         'public'                    => true,
312 312
         'exclude_from_search'       => true,
313 313
         'show_in_admin_all_list'    => true,
314 314
         'show_in_admin_status_list' => true,
315
-        'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
316
-    ) );
317
-    register_post_status( 'wpi-refunded', array(
318
-        'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
315
+        'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
316
+    ));
317
+    register_post_status('wpi-refunded', array(
318
+        'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
319 319
         'public'                    => true,
320 320
         'exclude_from_search'       => true,
321 321
         'show_in_admin_all_list'    => true,
322 322
         'show_in_admin_status_list' => true,
323
-        'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
324
-    ) );
325
-    register_post_status( 'wpi-failed', array(
326
-        'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
323
+        'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
324
+    ));
325
+    register_post_status('wpi-failed', array(
326
+        'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
327 327
         'public'                    => true,
328 328
         'exclude_from_search'       => true,
329 329
         'show_in_admin_all_list'    => true,
330 330
         'show_in_admin_status_list' => true,
331
-        'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
332
-    ) );
333
-    register_post_status( 'wpi-renewal', array(
334
-        'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
331
+        'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
332
+    ));
333
+    register_post_status('wpi-renewal', array(
334
+        'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
335 335
         'public'                    => true,
336 336
         'exclude_from_search'       => true,
337 337
         'show_in_admin_all_list'    => true,
338 338
         'show_in_admin_status_list' => true,
339
-        'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
340
-    ) );
339
+        'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
340
+    ));
341 341
 }
342
-add_action( 'init', 'wpinv_register_post_status', 10 );
342
+add_action('init', 'wpinv_register_post_status', 10);
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         $currency_symbol    = wpinv_currency_symbol();
10
-        $statuses           = wpinv_get_invoice_statuses( true );
10
+        $statuses           = wpinv_get_invoice_statuses(true);
11 11
         
12
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
13
-        $invoice            = new WPInv_Invoice( $post_id );
12
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
13
+        $invoice            = new WPInv_Invoice($post_id);
14 14
         
15
-        $status             = $invoice->get_status( false ); // Current status    
15
+        $status             = $invoice->get_status(false); // Current status    
16 16
         $discount           = $invoice->get_discount();
17 17
         $discount_code      = $discount > 0 ? $invoice->get_discount_code() : '';
18 18
         $invoice_number     = $invoice->get_number();
19 19
         
20 20
         $date_created       = $invoice->get_created_date();
21
-        $datetime_created   = strtotime( $date_created );
22
-        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : '';
21
+        $datetime_created   = strtotime($date_created);
22
+        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : '';
23 23
         $date_completed     = $invoice->get_completed_date();
24
-        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a';
25
-        $title['status'] = __( 'Invoice Status:', 'invoicing' );
26
-        $title['number'] = __( 'Invoice Number:', 'invoicing' );
27
-        $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' );
24
+        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a';
25
+        $title['status'] = __('Invoice Status:', 'invoicing');
26
+        $title['number'] = __('Invoice Number:', 'invoicing');
27
+        $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing');
28 28
         
29 29
         $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice);
30 30
         $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice);
@@ -34,36 +34,36 @@  discard block
 block discarded – undo
34 34
 <div class="gdmbx2-wrap form-table">
35 35
     <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details">
36 36
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created">
37
-            <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div>
38
-            <div class="gdmbx-td"><?php echo $date_created;?></div>
37
+            <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div>
38
+            <div class="gdmbx-td"><?php echo $date_created; ?></div>
39 39
         </div>
40
-        <?php if ( $invoice->post_type == 'wpi_invoice' && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft', 'draft' ) ) ) ) { ?>
40
+        <?php if ($invoice->post_type == 'wpi_invoice' && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft', 'draft')))) { ?>
41 41
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue">
42
-            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div>
42
+            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div>
43 43
             <div class="gdmbx-td">
44
-                <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd">
45
-                <p class="wpi-meta-row wpi-meta-desc"><?php _e( 'Leave blank to disable sending auto reminder for this invoice.', 'invoicing' );?></p>
44
+                <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd">
45
+                <p class="wpi-meta-row wpi-meta-desc"><?php _e('Leave blank to disable sending auto reminder for this invoice.', 'invoicing'); ?></p>
46 46
             </div>
47 47
         </div>
48 48
         <?php } ?>
49
-        <?php do_action( 'wpinv_meta_box_details_after_due_date', $post_id ); ?>
50
-        <?php if ( $date_completed && $date_completed != 'n/a' ) { ?>
49
+        <?php do_action('wpinv_meta_box_details_after_due_date', $post_id); ?>
50
+        <?php if ($date_completed && $date_completed != 'n/a') { ?>
51 51
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed">
52
-            <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div>
53
-            <div class="gdmbx-td"><?php echo $date_completed;?></div>
52
+            <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div>
53
+            <div class="gdmbx-td"><?php echo $date_completed; ?></div>
54 54
         </div>
55 55
         <?php } ?>
56
-        <?php $is_viewed = wpinv_is_invoice_viewed( $post_id ); ?>
56
+        <?php $is_viewed = wpinv_is_invoice_viewed($post_id); ?>
57 57
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-customer-viewed">
58
-            <div class="gdmbx-th"><label><?php _e( 'Viewed by Customer:', 'invoicing' );?></label></div>
59
-            <div class="gdmbx-td"><?php ( 1 == $is_viewed ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?></div>
58
+            <div class="gdmbx-th"><label><?php _e('Viewed by Customer:', 'invoicing'); ?></label></div>
59
+            <div class="gdmbx-td"><?php (1 == $is_viewed) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?></div>
60 60
         </div>
61 61
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status">
62 62
             <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div>
63 63
             <div class="gdmbx-td">
64 64
                 <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select wpi_select2">
65
-                    <?php foreach ( $statuses as $value => $label ) { ?>
66
-                    <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option>
65
+                    <?php foreach ($statuses as $value => $label) { ?>
66
+                    <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option>
67 67
                     <?php } ?>
68 68
                 </select>
69 69
             </div>
@@ -71,117 +71,117 @@  discard block
 block discarded – undo
71 71
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout">
72 72
             <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div>
73 73
             <div class="gdmbx-td">
74
-                <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
74
+                <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
75 75
             </div>
76 76
         </div>
77
-        <?php do_action( 'wpinv_meta_box_details_inner', $post_id );
77
+        <?php do_action('wpinv_meta_box_details_inner', $post_id);
78 78
         $disable_discount = apply_filters('wpinv_disable_apply_discount', false, $invoice, $post_id);
79 79
         ?>
80
-        <?php if ( !( $is_paid = ( $invoice->is_paid() || $invoice->is_refunded() ) ) && !$disable_discount || $discount_code ) { ?>
80
+        <?php if (!($is_paid = ($invoice->is_paid() || $invoice->is_refunded())) && !$disable_discount || $discount_code) { ?>
81 81
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout">
82
-            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div>
82
+            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div>
83 83
             <div class="gdmbx-td">
84
-                <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid && !$disable_discount ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
84
+                <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid && !$disable_discount) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
85 85
             </div>
86 86
         </div>
87 87
         <?php } ?>
88 88
     </div>
89 89
 </div>
90 90
 <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout">
91
-    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label>
91
+    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label>
92 92
         <select id="wpi_save_send" name="wpi_save_send" class="wpi_select2">
93
-            <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option>
94
-            <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option>
93
+            <option value="1"><?php _e('Yes', 'invoicing'); ?></option>
94
+            <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option>
95 95
         </select>
96 96
     </p>
97 97
     <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p>
98 98
 </div>
99
-<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?>
99
+<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?>
100 100
         <?php
101 101
     }
102 102
     
103
-    public static function resend_invoice( $post ) {
103
+    public static function resend_invoice($post) {
104 104
         global $wpi_mb_invoice;
105 105
         
106
-        if ( empty( $wpi_mb_invoice ) ) {
106
+        if (empty($wpi_mb_invoice)) {
107 107
             return;
108 108
         }
109 109
         
110 110
         $text = array(
111
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing' ),
112
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
111
+            'message'       => esc_attr__('This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing'),
112
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
113 113
         );
114 114
             
115 115
         $text = apply_filters('wpinv_resend_invoice_metabox_text', $text);
116
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
116
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
117 117
         
118
-        if ( $email = $wpi_mb_invoice->get_email() ) {
118
+        if ($email = $wpi_mb_invoice->get_email()) {
119 119
             $email_actions = array();
120
-            $email_actions['email_url']      = remove_query_arg( 'wpinv-message', add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) );
121
-            $email_actions['reminder_url']   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
120
+            $email_actions['email_url']      = remove_query_arg('wpinv-message', add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID)));
121
+            $email_actions['reminder_url']   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
122 122
             
123
-            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions );
123
+            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions);
124 124
         ?>
125 125
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
126
-        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
127
-        <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
128
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
126
+        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
127
+        <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
128
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
129 129
         <?php } ?>
130 130
         <?php
131 131
         }
132 132
         
133
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
133
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
134 134
     }
135 135
     
136
-    public static function subscriptions( $post ) {
137
-        $invoice = wpinv_get_invoice( $post->ID );
136
+    public static function subscriptions($post) {
137
+        $invoice = wpinv_get_invoice($post->ID);
138 138
 
139
-        if ( ! empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
140
-            $subscription = wpinv_get_subscription( $invoice );
139
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
140
+            $subscription = wpinv_get_subscription($invoice);
141 141
 
142
-            if ( empty( $subscription ) ) {
142
+            if (empty($subscription)) {
143 143
                 ?>
144
-                <p class="wpi-meta-row"><?php echo wp_sprintf( __( 'New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing' ), '<a href="' . admin_url( 'admin.php?page=wpinv-subscriptions' ).'">', '</a>' ); ?></p>
144
+                <p class="wpi-meta-row"><?php echo wp_sprintf(__('New Subscription will be created when customer will checkout and pay the invoice. Go to: %sSubscriptions%s', 'invoicing'), '<a href="' . admin_url('admin.php?page=wpinv-subscriptions') . '">', '</a>'); ?></p>
145 145
                 <?php
146 146
                 return;
147 147
             }
148
-            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period, $subscription->frequency );
149
-            $billing = wpinv_price(wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency;
150
-            $initial = wpinv_price(wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) );
148
+            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
149
+            $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency;
150
+            $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id));
151 151
             $payments = $subscription->get_child_payments();
152 152
             ?>
153 153
             <p class="wpi-meta-row wpi-sub-label <?php echo 'status-' . $subscription->status; ?>"><?php _e('Recurring Payment', 'invoicing'); ?></p>
154
-            <?php if ( ! empty( $subscription ) && ! empty( $subscription->id ) ) { ?>
154
+            <?php if (!empty($subscription) && !empty($subscription->id)) { ?>
155 155
                 <p class="wpi-meta-row wpi-sub-id">
156
-                    <label><?php _e( 'Subscription ID:', 'invoicing' ); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
156
+                    <label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p>
157 157
             <?php } ?>
158 158
             <p class="wpi-meta-row wpi-bill-cycle">
159
-                <label><?php _e( 'Billing Cycle:', 'invoicing'); ?> </label><?php printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); ?>
159
+                <label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?>
160 160
             </p>
161 161
             <p class="wpi-meta-row wpi-billed-times">
162
-                <label><?php _e( 'Times Billed:', 'invoicing' ); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times ); ?>
162
+                <label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times); ?>
163 163
             </p>
164 164
             <p class="wpi-meta-row wpi-start-date">
165
-                <label><?php _e( 'Start Date:', 'invoicing' ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->created, current_time( 'timestamp' ) ) ); ?>
165
+                <label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?>
166 166
             </p>
167 167
             <p class="wpi-meta-row wpi-end-date">
168
-                <label><?php echo ( 'trialling' == $subscription->status ? __( 'Trialling Until:', 'invoicing' ) : __( 'Expiration Date:', 'invoicing' ) ); ?> </label><?php echo date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration, current_time( 'timestamp' ) ) ); ?>
168
+                <label><?php echo ('trialling' == $subscription->status ? __('Trialling Until:', 'invoicing') : __('Expiration Date:', 'invoicing')); ?> </label><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?>
169 169
             </p>
170
-            <?php if ( $subscription->status ) { ?>
170
+            <?php if ($subscription->status) { ?>
171 171
                 <p class="wpi-meta-row wpi-sub-status">
172
-                    <label><?php _e( 'Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
172
+                    <label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $subscription->get_status_label(); ?>
173 173
                 </p>
174 174
             <?php } ?>
175
-            <?php if ( !empty( $payments ) ) { ?>
176
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
175
+            <?php if (!empty($payments)) { ?>
176
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
177 177
                 <ul id="wpi-sub-payments">
178
-                <?php foreach ( $payments as $payment ) {
178
+                <?php foreach ($payments as $payment) {
179 179
                     $invoice_id = $payment->ID;
180 180
                     ?>
181 181
                     <li>
182
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
183
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
184
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
182
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
183
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
184
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
185 185
                     </li>
186 186
                 <?php } ?>
187 187
                 </ul>
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
         }
190 190
     }
191 191
     
192
-    public static function renewals( $post ) {
193
-        $invoice = wpinv_get_invoice( $post->ID );
192
+    public static function renewals($post) {
193
+        $invoice = wpinv_get_invoice($post->ID);
194 194
         
195
-        if ( wpinv_is_subscription_payment( $invoice ) ) {
196
-            $parent_url = get_edit_post_link( $invoice->parent_invoice );
197
-            $parent_id  = wpinv_get_invoice_number( $invoice->parent_invoice );
198
-            $subscription = wpinv_get_subscription( $invoice );
195
+        if (wpinv_is_subscription_payment($invoice)) {
196
+            $parent_url = get_edit_post_link($invoice->parent_invoice);
197
+            $parent_id  = wpinv_get_invoice_number($invoice->parent_invoice);
198
+            $subscription = wpinv_get_subscription($invoice);
199 199
         ?>
200
-        <?php if ( ! empty( $subscription ) ) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $subscription->id ) ); ?>" title="<?php esc_attr_e( 'View or edit subscription', 'invoicing' ); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
201
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
200
+        <?php if (!empty($subscription)) { ?><p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><a href="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $subscription->id)); ?>" title="<?php esc_attr_e('View or edit subscription', 'invoicing'); ?>" target="_blank"><?php echo $subscription->id; ?></a></p><?php } ?>
201
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
202 202
         <?php
203 203
         }
204 204
     }
@@ -206,47 +206,47 @@  discard block
 block discarded – undo
206 206
     /**
207 207
      * Renders a metabox to edit a payment form.
208 208
      */
209
-    public static function payment_form( $post ) {
210
-        WPInv_Meta_Box_Form_Items::output_options( $post );
209
+    public static function payment_form($post) {
210
+        WPInv_Meta_Box_Form_Items::output_options($post);
211 211
     }
212 212
 
213 213
     /**
214 214
      * Renders a metabox to select items.
215 215
      */
216
-    public static function payment_form_items( $post ) {
217
-        WPInv_Meta_Box_Form_Items::output( $post );
216
+    public static function payment_form_items($post) {
217
+        WPInv_Meta_Box_Form_Items::output($post);
218 218
     }
219 219
     
220
-    public static function payment_meta( $post ) {
220
+    public static function payment_meta($post) {
221 221
         global $wpi_mb_invoice;
222 222
 
223
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
224
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded() ) {
223
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
224
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid() && !$wpi_mb_invoice->is_refunded()) {
225 225
             $set_dateway = true;
226 226
         }
227 227
         
228 228
         ?>
229 229
         <p class="wpi-meta-row">
230
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
231
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
230
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
231
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
232 232
             <select required="required" id="wpinv_gateway" class="wpi_select2" name="wpinv_gateway">
233
-                <?php foreach ( $gateways as $name => $gateway ) {
234
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
233
+                <?php foreach ($gateways as $name => $gateway) {
234
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
235 235
                         continue;
236 236
                     }
237 237
                     ?>
238
-                <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
238
+                <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
239 239
                 <?php } ?>
240 240
             </select>
241 241
         <?php } else { 
242
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_admin_label( $wpi_mb_invoice->gateway ) );
242
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_admin_label($wpi_mb_invoice->gateway));
243 243
         } ?>
244 244
         </p>
245
-        <?php if ( $key = $wpi_mb_invoice->get_key() ) { ?>
246
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $key ); ?></p>
245
+        <?php if ($key = $wpi_mb_invoice->get_key()) { ?>
246
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $key); ?></p>
247 247
         <?php } ?>
248
-        <?php if ( $wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded() ) { ?>
249
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
248
+        <?php if ($wpi_mb_invoice->is_paid() || $wpi_mb_invoice->is_refunded()) { ?>
249
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
250 250
         <?php } ?>
251 251
         <?php
252 252
     }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-form-items.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -144,11 +144,11 @@
 block discarded – undo
144 144
         <?php
145 145
     }
146 146
 
147
-     /**
148
-     * Outputs the payment options.
149
-     *
150
-     * @param WP_Post $post
151
-     */
147
+        /**
148
+         * Outputs the payment options.
149
+         *
150
+         * @param WP_Post $post
151
+         */
152 152
     public static function output_options( $post ) {
153 153
 
154 154
         $post_id             = ! empty( $post->ID ) ? $post->ID : 0;
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Form_Items {
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @param WP_Post $post
13 13
      */
14
-    public static function output( $post ) {
14
+    public static function output($post) {
15 15
 
16
-        $items = get_post_meta( $post->ID, 'wpinv_payment_form_items', true );
16
+        $items = get_post_meta($post->ID, 'wpinv_payment_form_items', true);
17 17
 
18
-        if ( empty( $items ) || ! is_array( $items ) ) {
18
+        if (empty($items) || !is_array($items)) {
19 19
             $items = array();
20 20
         }
21 21
 
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 
27 27
                 <thead>
28 28
                     <tr>
29
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
30
-                        <th class="title"><?php _e( 'Name', 'invoicing' );?></th>
31
-                        <th class="desc"><?php _e( 'Description', 'invoicing' );?></th>
32
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
29
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
30
+                        <th class="title"><?php _e('Name', 'invoicing'); ?></th>
31
+                        <th class="desc"><?php _e('Description', 'invoicing'); ?></th>
32
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
33 33
                         <th class="action"></th>
34 34
                     </tr>
35 35
                 </thead>
@@ -37,32 +37,32 @@  discard block
 block discarded – undo
37 37
                 <tbody class="wpinv-line-items">
38 38
                     <?php
39 39
 
40
-                        foreach ( $items as $item_data ) {
40
+                        foreach ($items as $item_data) {
41 41
 
42
-                            $id   = isset( $item['id'] ) ? (int) $item['id'] : 0;
43
-                            $item = new WPInv_Item( $id );
42
+                            $id   = isset($item['id']) ? (int) $item['id'] : 0;
43
+                            $item = new WPInv_Item($id);
44 44
 
45
-                            if ( empty( $item ) || $item->post_type != 'wpi_item' ) {
45
+                            if (empty($item) || $item->post_type != 'wpi_item') {
46 46
                                 continue;
47 47
                             }
48 48
                             
49
-                            $name          = isset( $item_data['name'] ) ? sanitize_text_field( $item_data['name'] ) : $item->get_name();
50
-                            $price         = isset( $item_data['price'] ) ? wpinv_format_amount( $item_data['price'] ) : $item->get_price();
51
-                            $description   = isset( $item_data['description'] ) ? esc_textarea( $item_data['description'] ) : $item->get_summary();
49
+                            $name          = isset($item_data['name']) ? sanitize_text_field($item_data['name']) : $item->get_name();
50
+                            $price         = isset($item_data['price']) ? wpinv_format_amount($item_data['price']) : $item->get_price();
51
+                            $description   = isset($item_data['description']) ? esc_textarea($item_data['description']) : $item->get_summary();
52 52
 
53 53
                     ?>
54 54
 
55 55
                     <tr class="item" data-item-id="<?php echo $id; ?>">
56 56
                         <td class="id"><?php echo $id; ?></td>
57 57
                         <td class="title">
58
-                            <a href="<?php echo esc_url( get_edit_post_link( $id ) ); ?>" target="_blank"><?php echo $name ; ?></a>
59
-                            <?php echo wpinv_get_item_suffix( $id ); ?>
58
+                            <a href="<?php echo esc_url(get_edit_post_link($id)); ?>" target="_blank"><?php echo $name; ?></a>
59
+                            <?php echo wpinv_get_item_suffix($id); ?>
60 60
                         </td>
61 61
                         <td class="meta">
62
-                            <?php echo $description ; ?>
62
+                            <?php echo $description; ?>
63 63
                         </td>
64 64
                         <td class="price">
65
-                            <?php echo $price ; ?>
65
+                            <?php echo $price; ?>
66 66
                         </td>
67 67
                     </tr>
68 68
 
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
                         <td class="id"></td>
73 73
 
74 74
                         <td class="title">
75
-                            <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" id="wpinv_create_payment_form_item_name" />
75
+                            <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" id="wpinv_create_payment_form_item_name" />
76 76
 
77 77
                             <div class="wp-clearfix">
78 78
                                 <label class="wpi-item-actions">
79 79
                                     <span class="input-text-wrap">
80
-                                        <input type="button" value="<?php esc_attr_e( 'Add', 'invoicing' ); ?>" class="button button-primary" id="wpinv-payment-form-save-item">
80
+                                        <input type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" id="wpinv-payment-form-save-item">
81 81
                                         <input type="button" value="Cancel" class="button button-secondary" id="wpinv-payment-form-cancel-item">
82 82
                                     </span>
83 83
                                 </label>
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                         </td>
86 86
 
87 87
                         <td class="meta">
88
-                            <textarea placeholder="<?php esc_attr_e( 'Item description', 'invoicing' ) ?>" id="wpinv_create_payment_form_item_description" class="large-text" rows="3"></textarea>
88
+                            <textarea placeholder="<?php esc_attr_e('Item description', 'invoicing') ?>" id="wpinv_create_payment_form_item_description" class="large-text" rows="3"></textarea>
89 89
                         </td>
90 90
 
91 91
                         <td class="price">
@@ -100,17 +100,17 @@  discard block
 block discarded – undo
100 100
 
101 101
                 <?php
102 102
 
103
-                    echo wpinv_item_dropdown( array(
103
+                    echo wpinv_item_dropdown(array(
104 104
                         'name'             => 'wpinv_payment_form_item',
105 105
                         'id'               => 'wpinv_payment_form_item',
106 106
                         'show_recurring'   => true,
107 107
                         'class'            => 'wpi_select2',
108
-                    ) );
108
+                    ));
109 109
 
110 110
                 ?>
111 111
 
112
-                <input type="button" value="<?php esc_attr_e( 'Add item to form', 'invoicing'); ?>" class="button button-primary" id="wpinv-payment-form-add-item" />
113
-                <input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-payment-form-new-item" />
112
+                <input type="button" value="<?php esc_attr_e('Add item to form', 'invoicing'); ?>" class="button button-primary" id="wpinv-payment-form-add-item" />
113
+                <input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-payment-form-new-item" />
114 114
 
115 115
             </div>
116 116
         </div>
@@ -122,23 +122,23 @@  discard block
 block discarded – undo
122 122
      *
123 123
      * @param WP_Post $post
124 124
      */
125
-    public static function output_options( $post ) {
125
+    public static function output_options($post) {
126 126
 
127
-        $post_id             = ! empty( $post->ID ) ? $post->ID : 0;
128
-        $success_page        = get_post_meta( $post->ID, 'wpinv_success_page', true );
129
-        $button_text         = get_post_meta( $post->ID, 'wpinv_button_text', true );
130
-        $processing_text     = get_post_meta( $post->ID, 'wpinv_processing_text', true );
131
-        $supports_quantities = (int) get_post_meta( $post->ID, 'wpinv_form_supports_quantities', true );
132
-        $supports_discounts  = (int) get_post_meta( $post->ID, 'wpinv_form_supports_discounts', true );
133
-        $enable_taxes        = (int) get_post_meta( $post->ID, 'wpinv_form_supports_quantities', true );
127
+        $post_id             = !empty($post->ID) ? $post->ID : 0;
128
+        $success_page        = get_post_meta($post->ID, 'wpinv_success_page', true);
129
+        $button_text         = get_post_meta($post->ID, 'wpinv_button_text', true);
130
+        $processing_text     = get_post_meta($post->ID, 'wpinv_processing_text', true);
131
+        $supports_quantities = (int) get_post_meta($post->ID, 'wpinv_form_supports_quantities', true);
132
+        $supports_discounts  = (int) get_post_meta($post->ID, 'wpinv_form_supports_discounts', true);
133
+        $enable_taxes        = (int) get_post_meta($post->ID, 'wpinv_form_supports_quantities', true);
134 134
 
135 135
         $values = array(
136
-            'success_page'         => empty( $success_page ) ? wpinv_get_success_page_uri() : $success_page,
137
-            'button_text'          => empty( $button_text ) ? __( 'Pay Now', 'invoicing' ) : $button_text,
138
-            'processing_text'      => empty( $processing_text ) ? __( 'Processing', 'invoicing' ) : $processing_text,
139
-            'supports_quantities'  => empty( $supports_quantities ) ? 0 : 1,
140
-            'enable_taxes'         => empty( $enable_taxes ) ? 0 : 1,
141
-            'supports_discounts'   => empty( $supports_discounts ) ? 0 : 1,
136
+            'success_page'         => empty($success_page) ? wpinv_get_success_page_uri() : $success_page,
137
+            'button_text'          => empty($button_text) ? __('Pay Now', 'invoicing') : $button_text,
138
+            'processing_text'      => empty($processing_text) ? __('Processing', 'invoicing') : $processing_text,
139
+            'supports_quantities'  => empty($supports_quantities) ? 0 : 1,
140
+            'enable_taxes'         => empty($enable_taxes) ? 0 : 1,
141
+            'supports_discounts'   => empty($supports_discounts) ? 0 : 1,
142 142
         );
143 143
 
144 144
         ?>
@@ -148,31 +148,31 @@  discard block
 block discarded – undo
148 148
                 <tbody>
149 149
 
150 150
                     <tr class="form-field-success_page">
151
-                        <th scope="row"><label for="field_success_page"><?php _e( 'Success Page', 'invoicing' ); ?></label></th>
151
+                        <th scope="row"><label for="field_success_page"><?php _e('Success Page', 'invoicing'); ?></label></th>
152 152
                         <td>
153 153
                             <div>
154
-                                <input type="text" class="regular-text" name="success_page" id="field_success_page" value="<?php echo esc_attr( $values['success_page'] ); ?>">
155
-                                <p class="description"><?php _e( 'Where should we redirect users after successfuly completing their payment?', 'invoicing' ); ?></p>
154
+                                <input type="text" class="regular-text" name="success_page" id="field_success_page" value="<?php echo esc_attr($values['success_page']); ?>">
155
+                                <p class="description"><?php _e('Where should we redirect users after successfuly completing their payment?', 'invoicing'); ?></p>
156 156
                             </div>
157 157
                         </td>
158 158
                     </tr>
159 159
 
160 160
                     <tr class="form-field-button_text">
161
-                        <th scope="row"><label for="field_button_text"><?php _e( 'Button Text', 'invoicing' ); ?></label></th>
161
+                        <th scope="row"><label for="field_button_text"><?php _e('Button Text', 'invoicing'); ?></label></th>
162 162
                         <td>
163 163
                             <div>
164
-                                <input type="text" class="regular-text" name="button_text" id="field_button_text" value="<?php echo esc_attr( $values['button_text'] ); ?>">
165
-                                <p class="description"><?php _e( 'Payment button text', 'invoicing' ); ?></p>
164
+                                <input type="text" class="regular-text" name="button_text" id="field_button_text" value="<?php echo esc_attr($values['button_text']); ?>">
165
+                                <p class="description"><?php _e('Payment button text', 'invoicing'); ?></p>
166 166
                             </div>
167 167
                         </td>
168 168
                     </tr>
169 169
 
170 170
                     <tr class="form-field-processing_text">
171
-                        <th scope="row"><label for="field_processing_text"><?php _e( 'Processing Text', 'invoicing' ); ?></label></th>
171
+                        <th scope="row"><label for="field_processing_text"><?php _e('Processing Text', 'invoicing'); ?></label></th>
172 172
                         <td>
173 173
                             <div>
174
-                                <input type="text" class="regular-text" name="processing_text" id="field_processing_text" value="<?php echo esc_attr( $values['processing_text'] ); ?>">
175
-                                <p class="description"><?php _e( 'Processing payment button text', 'invoicing' ); ?></p>
174
+                                <input type="text" class="regular-text" name="processing_text" id="field_processing_text" value="<?php echo esc_attr($values['processing_text']); ?>">
175
+                                <p class="description"><?php _e('Processing payment button text', 'invoicing'); ?></p>
176 176
                             </div>
177 177
                         </td>
178 178
                     </tr>
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
                         <td>
183 183
                             <div>
184 184
                                 <label>
185
-                                    <input type="checkbox" name="supports_quantities" id="field_supports_quantities" value="1" <?php checked( $values['supports_quantities'], 1 ); ?>>
186
-                                    <span><?php _e( 'Let users set custom item quantities', 'invoicing' ); ?></span>
185
+                                    <input type="checkbox" name="supports_quantities" id="field_supports_quantities" value="1" <?php checked($values['supports_quantities'], 1); ?>>
186
+                                    <span><?php _e('Let users set custom item quantities', 'invoicing'); ?></span>
187 187
                                 </label>
188 188
                             </div>
189 189
                         </td>
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
                         <td>
195 195
                             <div>
196 196
                                 <label>
197
-                                    <input type="checkbox" name="enable_taxes" id="field_enable_taxes" value="1" <?php checked( $values['enable_taxes'], 1 ); ?>>
198
-                                    <span><?php _e( 'Enable tax calculations', 'invoicing' ); ?></span>
197
+                                    <input type="checkbox" name="enable_taxes" id="field_enable_taxes" value="1" <?php checked($values['enable_taxes'], 1); ?>>
198
+                                    <span><?php _e('Enable tax calculations', 'invoicing'); ?></span>
199 199
                                 </label>
200 200
                             </div>
201 201
                         </td>
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
                         <td>
207 207
                             <div>
208 208
                                 <label>
209
-                                    <input type="checkbox" name="supports_discounts" id="field_supports_discounts" value="1" <?php checked( $values['supports_discounts'], 1 ); ?>>
210
-                                    <span><?php _e( 'Enable coupon codes', 'invoicing' ); ?></span>
209
+                                    <input type="checkbox" name="supports_discounts" id="field_supports_discounts" value="1" <?php checked($values['supports_discounts'], 1); ?>>
210
+                                    <span><?php _e('Enable coupon codes', 'invoicing'); ?></span>
211 211
                                 </label>
212 212
                             </div>
213 213
                         </td>
@@ -224,15 +224,15 @@  discard block
 block discarded – undo
224 224
      *
225 225
      * @param WP_Post $post
226 226
      */
227
-    public static function form_design ( $post ) {
227
+    public static function form_design($post) {
228 228
         ?>
229 229
 
230 230
         <div id="wpinv-form-builder" style="display: flex; flex-flow: wrap;">
231 231
 
232 232
             <div class="wpinv-form-builder-left" style="flex: 0 0 320px;">
233 233
                 <div class="wpinv-form-builder-tabs nav-tab-wrapper">
234
-                    <a @click.prevent="active_tab='new_item'" class="nav-tab" :class="{ 'nav-tab-active': active_tab=='new_item' }" href="#"><?php _e( 'Add new element', 'invoicing' ); ?></a>
235
-                    <a @click.prevent="active_tab='edit_item'" class="nav-tab" :class="{ 'nav-tab-active': active_tab=='edit_item' }" href="#"><?php _e( 'Edit element', 'invoicing' ); ?></a>
234
+                    <a @click.prevent="active_tab='new_item'" class="nav-tab" :class="{ 'nav-tab-active': active_tab=='new_item' }" href="#"><?php _e('Add new element', 'invoicing'); ?></a>
235
+                    <a @click.prevent="active_tab='edit_item'" class="nav-tab" :class="{ 'nav-tab-active': active_tab=='edit_item' }" href="#"><?php _e('Edit element', 'invoicing'); ?></a>
236 236
                 </div>
237 237
 
238 238
                 <div class="wpinv-form-builder-tab-content bsui" style="margin-top: 16px;">
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 
263 263
             <draggable class="section bsui" v-model="form_elements" group="fields" tag="div" style="min-height: 100%; font-size: 16px;">
264 264
                 <div v-for="form_element in form_elements" class="form-group">
265
-                    <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
265
+                    <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
266 266
                 </div>
267 267
             </draggable>
268 268
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         <?php
274 274
     }
275 275
 
276
-    public static function save( $post_id, $data, $post ) {
276
+    public static function save($post_id, $data, $post) {
277 277
 
278 278
     }
279 279
 }
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Spacing   +299 added lines, -299 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() {
@@ -79,39 +79,39 @@  discard block
 block discarded – undo
79 79
             'buy_items' => true,
80 80
         );
81 81
 
82
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
83
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
82
+        foreach ($ajax_events as $ajax_event => $nopriv) {
83
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
84 84
             
85
-            if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) {
86
-                define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 );
85
+            if (!defined('WPI_AJAX_' . strtoupper($nopriv))) {
86
+                define('WPI_AJAX_' . strtoupper($nopriv), 1);
87 87
             }
88 88
 
89
-            if ( $nopriv ) {
90
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
89
+            if ($nopriv) {
90
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
91 91
 
92
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
92
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
93 93
             }
94 94
         }
95 95
     }
96 96
     
97 97
     public static function add_note() {
98
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
98
+        check_ajax_referer('add-invoice-note', '_nonce');
99 99
 
100
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
100
+        if (!wpinv_current_user_can_manage_invoicing()) {
101 101
             die(-1);
102 102
         }
103 103
 
104
-        $post_id   = absint( $_POST['post_id'] );
105
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
106
-        $note_type = sanitize_text_field( $_POST['note_type'] );
104
+        $post_id   = absint($_POST['post_id']);
105
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
106
+        $note_type = sanitize_text_field($_POST['note_type']);
107 107
 
108 108
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
109 109
 
110
-        if ( $post_id > 0 ) {
111
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
110
+        if ($post_id > 0) {
111
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
112 112
 
113
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
114
-                wpinv_get_invoice_note_line_item( $note_id );
113
+            if ($note_id > 0 && !is_wp_error($note_id)) {
114
+                wpinv_get_invoice_note_line_item($note_id);
115 115
             }
116 116
         }
117 117
 
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
     }
120 120
 
121 121
     public static function delete_note() {
122
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
122
+        check_ajax_referer('delete-invoice-note', '_nonce');
123 123
 
124
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
124
+        if (!wpinv_current_user_can_manage_invoicing()) {
125 125
             die(-1);
126 126
         }
127 127
 
128
-        $note_id = (int)$_POST['note_id'];
128
+        $note_id = (int) $_POST['note_id'];
129 129
 
130
-        if ( $note_id > 0 ) {
131
-            wp_delete_comment( $note_id, true );
130
+        if ($note_id > 0) {
131
+            wp_delete_comment($note_id, true);
132 132
         }
133 133
 
134 134
         die();
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
     }
142 142
     
143 143
     public static function checkout() {
144
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
145
-            define( 'WPINV_CHECKOUT', true );
144
+        if (!defined('WPINV_CHECKOUT')) {
145
+            define('WPINV_CHECKOUT', true);
146 146
         }
147 147
 
148 148
         wpinv_process_checkout();
@@ -151,53 +151,53 @@  discard block
 block discarded – undo
151 151
     
152 152
     public static function add_invoice_item() {
153 153
         global $wpi_userID, $wpinv_ip_address_country;
154
-        check_ajax_referer( 'invoice-item', '_nonce' );
155
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
154
+        check_ajax_referer('invoice-item', '_nonce');
155
+        if (!wpinv_current_user_can_manage_invoicing()) {
156 156
             die(-1);
157 157
         }
158 158
         
159
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
160
-        $invoice_id = absint( $_POST['invoice_id'] );
159
+        $item_id    = sanitize_text_field($_POST['item_id']);
160
+        $invoice_id = absint($_POST['invoice_id']);
161 161
         
162
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
162
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
163 163
             die();
164 164
         }
165 165
         
166
-        $invoice    = wpinv_get_invoice( $invoice_id );
167
-        if ( empty( $invoice ) ) {
166
+        $invoice = wpinv_get_invoice($invoice_id);
167
+        if (empty($invoice)) {
168 168
             die();
169 169
         }
170 170
         
171
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
171
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
172 172
             die(); // Don't allow modify items for paid invoice.
173 173
         }
174 174
         
175
-        if ( !empty( $_POST['user_id'] ) ) {
176
-            $wpi_userID = absint( $_POST['user_id'] ); 
175
+        if (!empty($_POST['user_id'])) {
176
+            $wpi_userID = absint($_POST['user_id']); 
177 177
         }
178 178
 
179
-        $item = new WPInv_Item( $item_id );
180
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
179
+        $item = new WPInv_Item($item_id);
180
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
181 181
             die();
182 182
         }
183 183
         
184 184
         // Validate item before adding to invoice because recurring item must be paid individually.
185
-        if ( !empty( $invoice->cart_details ) ) {
185
+        if (!empty($invoice->cart_details)) {
186 186
             $valid = true;
187 187
             
188
-            if ( $recurring_item = $invoice->get_recurring() ) {
189
-                if ( $recurring_item != $item_id ) {
188
+            if ($recurring_item = $invoice->get_recurring()) {
189
+                if ($recurring_item != $item_id) {
190 190
                     $valid = false;
191 191
                 }
192
-            } else if ( wpinv_is_recurring_item( $item_id ) ) {
192
+            } else if (wpinv_is_recurring_item($item_id)) {
193 193
                 $valid = false;
194 194
             }
195 195
             
196
-            if ( !$valid ) {
196
+            if (!$valid) {
197 197
                 $response               = array();
198 198
                 $response['success']    = false;
199
-                $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
200
-                wp_send_json( $response );
199
+                $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
200
+                wp_send_json($response);
201 201
             }
202 202
         }
203 203
         
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
         
206 206
         $data                   = array();
207 207
         $data['invoice_id']     = $invoice_id;
208
-        $data['cart_discounts'] = $invoice->get_discounts( true );
208
+        $data['cart_discounts'] = $invoice->get_discounts(true);
209 209
         
210
-        wpinv_set_checkout_session( $data );
210
+        wpinv_set_checkout_session($data);
211 211
         
212
-        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1;
212
+        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1;
213 213
 
214 214
         $args = array(
215 215
             'id'            => $item_id,
@@ -222,21 +222,21 @@  discard block
 block discarded – undo
222 222
             'fees'          => array()
223 223
         );
224 224
 
225
-        $invoice->add_item( $item_id, $args );
225
+        $invoice->add_item($item_id, $args);
226 226
         $invoice->save();
227 227
         
228
-        if ( empty( $_POST['country'] ) ) {
228
+        if (empty($_POST['country'])) {
229 229
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
230 230
         }
231
-        if ( empty( $_POST['state'] ) ) {
231
+        if (empty($_POST['state'])) {
232 232
             $_POST['state'] = $invoice->state;
233 233
         }
234 234
          
235
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
236
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
235
+        $invoice->country   = sanitize_text_field($_POST['country']);
236
+        $invoice->state     = sanitize_text_field($_POST['state']);
237 237
         
238
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
239
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
238
+        $invoice->set('country', sanitize_text_field($_POST['country']));
239
+        $invoice->set('state', sanitize_text_field($_POST['state']));
240 240
         
241 241
         $wpinv_ip_address_country = $invoice->country;
242 242
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         
245 245
         $response                       = array();
246 246
         $response['success']            = true;
247
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
247
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
248 248
         $response['data']['subtotal']   = $invoice->get_subtotal();
249 249
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
250 250
         $response['data']['tax']        = $invoice->get_tax();
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         
257 257
         wpinv_set_checkout_session($checkout_session);
258 258
         
259
-        wp_send_json( $response );
259
+        wp_send_json($response);
260 260
     }
261 261
 
262 262
     /**
@@ -265,70 +265,70 @@  discard block
 block discarded – undo
265 265
     public static function add_payment_form_item() {
266 266
 
267 267
         // Check nonce...
268
-        check_ajax_referer( 'invoice-item', '_nonce' );
268
+        check_ajax_referer('invoice-item', '_nonce');
269 269
 
270 270
         // ... and user capability.
271
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
272
-            wp_send_json_error( __( 'You do not have permission to do that.', 'invoicing' ) );
271
+        if (!wpinv_current_user_can_manage_invoicing()) {
272
+            wp_send_json_error(__('You do not have permission to do that.', 'invoicing'));
273 273
             die(-1);
274 274
         }
275 275
 
276 276
         // Prepare the item and the invoice.
277
-        $item_id = absint( $_POST['item_id'] );
278
-        $form_id = absint( $_POST['form_id'] );
277
+        $item_id = absint($_POST['item_id']);
278
+        $form_id = absint($_POST['form_id']);
279 279
         
280
-        if ( empty( $item_id ) || empty( $form_id ) ) {
281
-            wp_send_json_error( __( 'Invalid form or item.', 'invoicing' ) );
280
+        if (empty($item_id) || empty($form_id)) {
281
+            wp_send_json_error(__('Invalid form or item.', 'invoicing'));
282 282
         }
283 283
 
284
-        $new_item = new WPInv_Item( $item_id );
285
-        if ( empty( $new_item ) || $new_item->post_type != 'wpi_item' ) {
286
-            wp_send_json_error( __( 'Invalid item.', 'invoicing' ) );
284
+        $new_item = new WPInv_Item($item_id);
285
+        if (empty($new_item) || $new_item->post_type != 'wpi_item') {
286
+            wp_send_json_error(__('Invalid item.', 'invoicing'));
287 287
         }
288 288
 
289 289
         // Fetch existing items.
290
-        $items = get_post_meta( $form_id, 'wpinv_payment_form_items', true );
290
+        $items = get_post_meta($form_id, 'wpinv_payment_form_items', true);
291 291
 
292
-        if ( empty( $items ) || is_array( $items ) ) {
292
+        if (empty($items) || is_array($items)) {
293 293
             $items = array();
294 294
         }
295 295
 
296 296
         // Only one recurring item per form please.
297
-        $has_recurring = wpinv_is_recurring_item( $item_id );
298
-        foreach ( $items as $index => $item_data ) {
297
+        $has_recurring = wpinv_is_recurring_item($item_id);
298
+        foreach ($items as $index => $item_data) {
299 299
 
300 300
             $id   = $item_data['id'];
301
-            $item = new WPInv_Item( $id );
301
+            $item = new WPInv_Item($id);
302 302
 
303
-            if ( empty( $item ) || $item->post_type != 'wpi_item' ) {
304
-                unset( $items[ $index ] );
303
+            if (empty($item) || $item->post_type != 'wpi_item') {
304
+                unset($items[$index]);
305 305
                 continue;
306 306
             }
307 307
 
308
-            if ( $item_id == $id ) {
309
-                unset( $items[ $index ] );
308
+            if ($item_id == $id) {
309
+                unset($items[$index]);
310 310
             }
311 311
 
312
-            if ( $item->is_recurring() ) {
312
+            if ($item->is_recurring()) {
313 313
                 $has_recurring = true;
314 314
             }
315 315
 
316 316
         }
317 317
 
318
-        $items[] = array( 'id' => $new_item->ID );
318
+        $items[] = array('id' => $new_item->ID);
319 319
 
320 320
         // One recurring item per form.
321
-        if ( $has_recurring && 1 < count( $items ) ) {
322
-            wp_send_json_error( __( 'You can not add item because recurring items must be paid individually!', 'invoicing' ) );
321
+        if ($has_recurring && 1 < count($items)) {
322
+            wp_send_json_error(__('You can not add item because recurring items must be paid individually!', 'invoicing'));
323 323
         }
324 324
 
325
-        update_post_meta( $form_id, 'wpinv_payment_form_items', $items );
325
+        update_post_meta($form_id, 'wpinv_payment_form_items', $items);
326 326
 
327 327
         ob_start();
328
-        WPInv_Meta_Box_Form_Items::output( get_post( $form_id ) );
328
+        WPInv_Meta_Box_Form_Items::output(get_post($form_id));
329 329
         $items = ob_get_clean();
330 330
         
331
-        wp_send_json_success( $items );
331
+        wp_send_json_success($items);
332 332
     }
333 333
 
334 334
     /**
@@ -337,44 +337,44 @@  discard block
 block discarded – undo
337 337
     public static function create_payment_form_item() {
338 338
 
339 339
         // Check nonce...
340
-        check_ajax_referer( 'invoice-item', '_nonce' );
340
+        check_ajax_referer('invoice-item', '_nonce');
341 341
 
342 342
         // ... and user capability.
343
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
344
-            wp_send_json_error( __( 'You do not have permission to do that.', 'invoicing' ) );
343
+        if (!wpinv_current_user_can_manage_invoicing()) {
344
+            wp_send_json_error(__('You do not have permission to do that.', 'invoicing'));
345 345
             die(-1);
346 346
         }
347 347
 
348 348
         // Item data.
349
-        $form_id          = absint( $_POST['form_id'] );
350
-        $item_price       = wpinv_sanitize_amount( $_POST['item_price'] );
351
-        $item_name        = sanitize_text_field( $_POST['item_name'] );
352
-        $item_description = wp_kses_post( $_POST['item_description'] );
349
+        $form_id          = absint($_POST['form_id']);
350
+        $item_price       = wpinv_sanitize_amount($_POST['item_price']);
351
+        $item_name        = sanitize_text_field($_POST['item_name']);
352
+        $item_description = wp_kses_post($_POST['item_description']);
353 353
         
354
-        if ( empty( $item_name ) ) {
355
-            wp_send_json_error( __( 'Specify a name for your item.', 'invoicing' ) );
354
+        if (empty($item_name)) {
355
+            wp_send_json_error(__('Specify a name for your item.', 'invoicing'));
356 356
         }
357 357
 
358 358
         // Fetch existing items.
359
-        $items = get_post_meta( $form_id, 'wpinv_payment_form_items', true );
359
+        $items = get_post_meta($form_id, 'wpinv_payment_form_items', true);
360 360
 
361
-        if ( empty( $items ) || is_array( $items ) ) {
361
+        if (empty($items) || is_array($items)) {
362 362
             $items = array();
363 363
         }
364 364
 
365 365
         // Only one recurring item per form please.
366
-        foreach ( $items as $index => $item_data ) {
366
+        foreach ($items as $index => $item_data) {
367 367
 
368 368
             $id   = $item_data['id'];
369
-            $item = new WPInv_Item( $id );
369
+            $item = new WPInv_Item($id);
370 370
 
371
-            if ( empty( $item ) || $item->post_type != 'wpi_item' ) {
372
-                unset( $items[ $index ] );
371
+            if (empty($item) || $item->post_type != 'wpi_item') {
372
+                unset($items[$index]);
373 373
                 continue;
374 374
             }
375 375
 
376
-            if ( $item->is_recurring() ) {
377
-                wp_send_json_error( __( 'You can not add item because recurring items must be paid individually!', 'invoicing' ) );
376
+            if ($item->is_recurring()) {
377
+                wp_send_json_error(__('You can not add item because recurring items must be paid individually!', 'invoicing'));
378 378
             }
379 379
 
380 380
         }
@@ -391,56 +391,56 @@  discard block
 block discarded – undo
391 391
             )
392 392
         );
393 393
         
394
-        $item  = new WPInv_Item();
395
-        $item->create( $data );
394
+        $item = new WPInv_Item();
395
+        $item->create($data);
396 396
 
397
-        if ( empty( $item ) ) {
398
-            wp_send_json_error( __( 'Error creating item', 'invoicing' ) );
397
+        if (empty($item)) {
398
+            wp_send_json_error(__('Error creating item', 'invoicing'));
399 399
             die();
400 400
         }
401 401
 
402
-        $items[] = array( 'id' => $item->ID );
402
+        $items[] = array('id' => $item->ID);
403 403
 
404
-        update_post_meta( $form_id, 'wpinv_payment_form_items', $items );
404
+        update_post_meta($form_id, 'wpinv_payment_form_items', $items);
405 405
 
406 406
         ob_start();
407
-        WPInv_Meta_Box_Form_Items::output( get_post( $form_id ) );
407
+        WPInv_Meta_Box_Form_Items::output(get_post($form_id));
408 408
         $items = ob_get_clean();
409 409
         
410
-        wp_send_json_success( $items );
410
+        wp_send_json_success($items);
411 411
     }
412 412
 
413 413
     public static function remove_invoice_item() {
414 414
         global $wpi_userID, $wpinv_ip_address_country;
415 415
         
416
-        check_ajax_referer( 'invoice-item', '_nonce' );
417
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
416
+        check_ajax_referer('invoice-item', '_nonce');
417
+        if (!wpinv_current_user_can_manage_invoicing()) {
418 418
             die(-1);
419 419
         }
420 420
         
421
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
422
-        $invoice_id = absint( $_POST['invoice_id'] );
423
-        $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false;
421
+        $item_id    = sanitize_text_field($_POST['item_id']);
422
+        $invoice_id = absint($_POST['invoice_id']);
423
+        $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false;
424 424
         
425
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
425
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
426 426
             die();
427 427
         }
428 428
 
429
-        $invoice    = wpinv_get_invoice( $invoice_id );
430
-        if ( empty( $invoice ) ) {
429
+        $invoice = wpinv_get_invoice($invoice_id);
430
+        if (empty($invoice)) {
431 431
             die();
432 432
         }
433 433
         
434
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
434
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
435 435
             die(); // Don't allow modify items for paid invoice.
436 436
         }
437 437
         
438
-        if ( !empty( $_POST['user_id'] ) ) {
439
-            $wpi_userID = absint( $_POST['user_id'] ); 
438
+        if (!empty($_POST['user_id'])) {
439
+            $wpi_userID = absint($_POST['user_id']); 
440 440
         }
441 441
 
442
-        $item       = new WPInv_Item( $item_id );
443
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
442
+        $item = new WPInv_Item($item_id);
443
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
444 444
             die();
445 445
         }
446 446
         
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
         
449 449
         $data                   = array();
450 450
         $data['invoice_id']     = $invoice_id;
451
-        $data['cart_discounts'] = $invoice->get_discounts( true );
451
+        $data['cart_discounts'] = $invoice->get_discounts(true);
452 452
         
453
-        wpinv_set_checkout_session( $data );
453
+        wpinv_set_checkout_session($data);
454 454
 
455 455
         $args = array(
456 456
             'id'         => $item_id,
@@ -458,21 +458,21 @@  discard block
 block discarded – undo
458 458
             'cart_index' => $cart_index
459 459
         );
460 460
 
461
-        $invoice->remove_item( $item_id, $args );
461
+        $invoice->remove_item($item_id, $args);
462 462
         $invoice->save();
463 463
         
464
-        if ( empty( $_POST['country'] ) ) {
464
+        if (empty($_POST['country'])) {
465 465
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
466 466
         }
467
-        if ( empty( $_POST['state'] ) ) {
467
+        if (empty($_POST['state'])) {
468 468
             $_POST['state'] = $invoice->state;
469 469
         }
470 470
          
471
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
472
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
471
+        $invoice->country   = sanitize_text_field($_POST['country']);
472
+        $invoice->state     = sanitize_text_field($_POST['state']);
473 473
         
474
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
475
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
474
+        $invoice->set('country', sanitize_text_field($_POST['country']));
475
+        $invoice->set('state', sanitize_text_field($_POST['state']));
476 476
         
477 477
         $wpinv_ip_address_country = $invoice->country;
478 478
         
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
         
481 481
         $response                       = array();
482 482
         $response['success']            = true;
483
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
483
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
484 484
         $response['data']['subtotal']   = $invoice->get_subtotal();
485 485
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
486 486
         $response['data']['tax']        = $invoice->get_tax();
@@ -492,55 +492,55 @@  discard block
 block discarded – undo
492 492
         
493 493
         wpinv_set_checkout_session($checkout_session);
494 494
         
495
-        wp_send_json( $response );
495
+        wp_send_json($response);
496 496
     }
497 497
     
498 498
     public static function create_invoice_item() {
499
-        check_ajax_referer( 'invoice-item', '_nonce' );
500
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
499
+        check_ajax_referer('invoice-item', '_nonce');
500
+        if (!wpinv_current_user_can_manage_invoicing()) {
501 501
             die(-1);
502 502
         }
503 503
         
504
-        $invoice_id = absint( $_POST['invoice_id'] );
504
+        $invoice_id = absint($_POST['invoice_id']);
505 505
 
506 506
         // Find the item
507
-        if ( !is_numeric( $invoice_id ) ) {
507
+        if (!is_numeric($invoice_id)) {
508 508
             die();
509 509
         }        
510 510
         
511
-        $invoice     = wpinv_get_invoice( $invoice_id );
512
-        if ( empty( $invoice ) ) {
511
+        $invoice = wpinv_get_invoice($invoice_id);
512
+        if (empty($invoice)) {
513 513
             die();
514 514
         }
515 515
         
516 516
         // Validate item before adding to invoice because recurring item must be paid individually.
517
-        if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) {
517
+        if (!empty($invoice->cart_details) && $invoice->get_recurring()) {
518 518
             $response               = array();
519 519
             $response['success']    = false;
520
-            $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
521
-            wp_send_json( $response );
520
+            $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
521
+            wp_send_json($response);
522 522
         }        
523 523
         
524
-        $save_item = wp_unslash( $_POST['_wpinv_quick'] );
524
+        $save_item = wp_unslash($_POST['_wpinv_quick']);
525 525
         
526 526
         $meta               = array();
527 527
         $meta['type']       = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom';
528
-        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0;
528
+        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0;
529 529
         $meta['vat_rule']   = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital';
530 530
         $meta['vat_class']  = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard';
531 531
         
532 532
         $data                   = array();
533 533
         $data['post_title']     = sanitize_text_field($save_item['name']);
534 534
         $data['post_status']    = 'publish';
535
-        $data['post_excerpt']   = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : '';
535
+        $data['post_excerpt']   = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : '';
536 536
         $data['meta']           = $meta;
537 537
         
538 538
         $item = new WPInv_Item();
539
-        $item->create( $data );
539
+        $item->create($data);
540 540
         
541
-        if ( !empty( $item ) ) {
541
+        if (!empty($item)) {
542 542
             $_POST['item_id']   = $item->ID;
543
-            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1;
543
+            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1;
544 544
             
545 545
             self::add_invoice_item();
546 546
         }
@@ -548,15 +548,15 @@  discard block
 block discarded – undo
548 548
     }
549 549
     
550 550
     public static function get_billing_details() {
551
-        check_ajax_referer( 'get-billing-details', '_nonce' );
551
+        check_ajax_referer('get-billing-details', '_nonce');
552 552
         
553
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
553
+        if (!wpinv_current_user_can_manage_invoicing()) {
554 554
             die(-1);
555 555
         }
556 556
 
557
-        $user_id            = (int)$_POST['user_id'];
557
+        $user_id            = (int) $_POST['user_id'];
558 558
         $billing_details    = wpinv_get_user_address($user_id);
559
-        $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
559
+        $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
560 560
         
561 561
         if (isset($billing_details['user_id'])) {
562 562
             unset($billing_details['user_id']);
@@ -570,20 +570,20 @@  discard block
 block discarded – undo
570 570
         $response['success']                    = true;
571 571
         $response['data']['billing_details']    = $billing_details;
572 572
         
573
-        wp_send_json( $response );
573
+        wp_send_json($response);
574 574
     }
575 575
     
576 576
     public static function admin_recalculate_totals() {
577 577
         global $wpi_userID, $wpinv_ip_address_country;
578 578
         
579
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
580
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
579
+        check_ajax_referer('wpinv-nonce', '_nonce');
580
+        if (!wpinv_current_user_can_manage_invoicing()) {
581 581
             die(-1);
582 582
         }
583 583
         
584
-        $invoice_id = absint( $_POST['invoice_id'] );        
585
-        $invoice    = wpinv_get_invoice( $invoice_id );
586
-        if ( empty( $invoice ) ) {
584
+        $invoice_id = absint($_POST['invoice_id']);        
585
+        $invoice    = wpinv_get_invoice($invoice_id);
586
+        if (empty($invoice)) {
587 587
             die();
588 588
         }
589 589
         
@@ -591,23 +591,23 @@  discard block
 block discarded – undo
591 591
         
592 592
         $data                   = array();
593 593
         $data['invoice_id']     = $invoice_id;
594
-        $data['cart_discounts'] = $invoice->get_discounts( true );
594
+        $data['cart_discounts'] = $invoice->get_discounts(true);
595 595
         
596
-        wpinv_set_checkout_session( $data );
596
+        wpinv_set_checkout_session($data);
597 597
         
598
-        if ( !empty( $_POST['user_id'] ) ) {
599
-            $wpi_userID = absint( $_POST['user_id'] ); 
598
+        if (!empty($_POST['user_id'])) {
599
+            $wpi_userID = absint($_POST['user_id']); 
600 600
         }
601 601
         
602
-        if ( empty( $_POST['country'] ) ) {
602
+        if (empty($_POST['country'])) {
603 603
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
604 604
         }
605 605
             
606
-        $invoice->country = sanitize_text_field( $_POST['country'] );
607
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
608
-        if ( isset( $_POST['state'] ) ) {
609
-            $invoice->state = sanitize_text_field( $_POST['state'] );
610
-            $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
606
+        $invoice->country = sanitize_text_field($_POST['country']);
607
+        $invoice->set('country', sanitize_text_field($_POST['country']));
608
+        if (isset($_POST['state'])) {
609
+            $invoice->state = sanitize_text_field($_POST['state']);
610
+            $invoice->set('state', sanitize_text_field($_POST['state']));
611 611
         }
612 612
         
613 613
         $wpinv_ip_address_country = $invoice->country;
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
         
617 617
         $response                       = array();
618 618
         $response['success']            = true;
619
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
619
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
620 620
         $response['data']['subtotal']   = $invoice->get_subtotal();
621 621
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
622 622
         $response['data']['tax']        = $invoice->get_tax();
@@ -628,25 +628,25 @@  discard block
 block discarded – undo
628 628
         
629 629
         wpinv_set_checkout_session($checkout_session);
630 630
         
631
-        wp_send_json( $response );
631
+        wp_send_json($response);
632 632
     }
633 633
     
634 634
     public static function admin_apply_discount() {
635 635
         global $wpi_userID;
636 636
         
637
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
638
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
637
+        check_ajax_referer('wpinv-nonce', '_nonce');
638
+        if (!wpinv_current_user_can_manage_invoicing()) {
639 639
             die(-1);
640 640
         }
641 641
         
642
-        $invoice_id = absint( $_POST['invoice_id'] );
643
-        $discount_code = sanitize_text_field( $_POST['code'] );
644
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
642
+        $invoice_id = absint($_POST['invoice_id']);
643
+        $discount_code = sanitize_text_field($_POST['code']);
644
+        if (empty($invoice_id) || empty($discount_code)) {
645 645
             die();
646 646
         }
647 647
         
648
-        $invoice = wpinv_get_invoice( $invoice_id );
649
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
648
+        $invoice = wpinv_get_invoice($invoice_id);
649
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
650 650
             die();
651 651
         }
652 652
         
@@ -654,49 +654,49 @@  discard block
 block discarded – undo
654 654
         
655 655
         $data                   = array();
656 656
         $data['invoice_id']     = $invoice_id;
657
-        $data['cart_discounts'] = $invoice->get_discounts( true );
657
+        $data['cart_discounts'] = $invoice->get_discounts(true);
658 658
         
659
-        wpinv_set_checkout_session( $data );
659
+        wpinv_set_checkout_session($data);
660 660
         
661 661
         $response               = array();
662 662
         $response['success']    = false;
663
-        $response['msg']        = __( 'This discount is invalid.', 'invoicing' );
663
+        $response['msg']        = __('This discount is invalid.', 'invoicing');
664 664
         $response['data']['code'] = $discount_code;
665 665
         
666
-        if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) {
667
-            $discounts = wpinv_set_cart_discount( $discount_code );
666
+        if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) {
667
+            $discounts = wpinv_set_cart_discount($discount_code);
668 668
             
669 669
             $response['success'] = true;
670
-            $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
671
-        }  else {
670
+            $response['msg'] = __('Discount has been applied successfully.', 'invoicing');
671
+        } else {
672 672
             $errors = wpinv_get_errors();
673
-            if ( !empty( $errors['wpinv-discount-error'] ) ) {
673
+            if (!empty($errors['wpinv-discount-error'])) {
674 674
                 $response['msg'] = $errors['wpinv-discount-error'];
675 675
             }
676
-            wpinv_unset_error( 'wpinv-discount-error' );
676
+            wpinv_unset_error('wpinv-discount-error');
677 677
         }
678 678
         
679 679
         wpinv_set_checkout_session($checkout_session);
680 680
         
681
-        wp_send_json( $response );
681
+        wp_send_json($response);
682 682
     }
683 683
     
684 684
     public static function admin_remove_discount() {
685 685
         global $wpi_userID;
686 686
         
687
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
688
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
687
+        check_ajax_referer('wpinv-nonce', '_nonce');
688
+        if (!wpinv_current_user_can_manage_invoicing()) {
689 689
             die(-1);
690 690
         }
691 691
         
692
-        $invoice_id = absint( $_POST['invoice_id'] );
693
-        $discount_code = sanitize_text_field( $_POST['code'] );
694
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
692
+        $invoice_id = absint($_POST['invoice_id']);
693
+        $discount_code = sanitize_text_field($_POST['code']);
694
+        if (empty($invoice_id) || empty($discount_code)) {
695 695
             die();
696 696
         }
697 697
         
698
-        $invoice = wpinv_get_invoice( $invoice_id );
699
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
698
+        $invoice = wpinv_get_invoice($invoice_id);
699
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
700 700
             die();
701 701
         }
702 702
         
@@ -704,38 +704,38 @@  discard block
 block discarded – undo
704 704
         
705 705
         $data                   = array();
706 706
         $data['invoice_id']     = $invoice_id;
707
-        $data['cart_discounts'] = $invoice->get_discounts( true );
707
+        $data['cart_discounts'] = $invoice->get_discounts(true);
708 708
         
709
-        wpinv_set_checkout_session( $data );
709
+        wpinv_set_checkout_session($data);
710 710
         
711 711
         $response               = array();
712 712
         $response['success']    = false;
713 713
         $response['msg']        = NULL;
714 714
         
715
-        $discounts  = wpinv_unset_cart_discount( $discount_code );
715
+        $discounts = wpinv_unset_cart_discount($discount_code);
716 716
         $response['success'] = true;
717
-        $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' );
717
+        $response['msg'] = __('Discount has been removed successfully.', 'invoicing');
718 718
         
719 719
         wpinv_set_checkout_session($checkout_session);
720 720
         
721
-        wp_send_json( $response );
721
+        wp_send_json($response);
722 722
     }
723 723
     
724 724
     public static function check_email() {
725
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
726
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
725
+        check_ajax_referer('wpinv-nonce', '_nonce');
726
+        if (!wpinv_current_user_can_manage_invoicing()) {
727 727
             die(-1);
728 728
         }
729 729
         
730
-        $email = sanitize_text_field( $_POST['email'] );
730
+        $email = sanitize_text_field($_POST['email']);
731 731
         
732 732
         $response = array();
733
-        if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) {
733
+        if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) {
734 734
             $user_id            = $user_data->ID;
735 735
             $user_login         = $user_data->user_login;
736 736
             $display_name       = $user_data->display_name ? $user_data->display_name : $user_login;
737 737
             $billing_details    = wpinv_get_user_address($user_id);
738
-            $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
738
+            $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
739 739
             
740 740
             if (isset($billing_details['user_id'])) {
741 741
                 unset($billing_details['user_id']);
@@ -751,54 +751,54 @@  discard block
 block discarded – undo
751 751
             $response['data']['billing_details']    = $billing_details;
752 752
         }
753 753
         
754
-        wp_send_json( $response );
754
+        wp_send_json($response);
755 755
     }
756 756
     
757 757
     public static function run_tool() {
758
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
759
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
758
+        check_ajax_referer('wpinv-nonce', '_nonce');
759
+        if (!wpinv_current_user_can_manage_invoicing()) {
760 760
             die(-1);
761 761
         }
762 762
         
763
-        $tool = sanitize_text_field( $_POST['tool'] );
763
+        $tool = sanitize_text_field($_POST['tool']);
764 764
         
765
-        do_action( 'wpinv_run_tool' );
765
+        do_action('wpinv_run_tool');
766 766
         
767
-        if ( !empty( $tool ) ) {
768
-            do_action( 'wpinv_tool_' . $tool );
767
+        if (!empty($tool)) {
768
+            do_action('wpinv_tool_' . $tool);
769 769
         }
770 770
     }
771 771
     
772 772
     public static function apply_discount() {
773 773
         global $wpi_userID;
774 774
         
775
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
775
+        check_ajax_referer('wpinv-nonce', '_nonce');
776 776
         
777 777
         $response = array();
778 778
         
779
-        if ( isset( $_POST['code'] ) ) {
780
-            $discount_code = sanitize_text_field( $_POST['code'] );
779
+        if (isset($_POST['code'])) {
780
+            $discount_code = sanitize_text_field($_POST['code']);
781 781
 
782 782
             $response['success']        = false;
783 783
             $response['msg']            = '';
784 784
             $response['data']['code']   = $discount_code;
785 785
             
786 786
             $invoice = wpinv_get_invoice_cart();
787
-            if ( empty( $invoice->ID ) ) {
788
-                $response['msg'] = __( 'Invalid checkout request.', 'invoicing' );
789
-                wp_send_json( $response );
787
+            if (empty($invoice->ID)) {
788
+                $response['msg'] = __('Invalid checkout request.', 'invoicing');
789
+                wp_send_json($response);
790 790
             }
791 791
 
792 792
             $wpi_userID = $invoice->get_user_id();
793 793
 
794
-            if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) {
795
-                $discount       = wpinv_get_discount_by_code( $discount_code );
796
-                $discounts      = wpinv_set_cart_discount( $discount_code );
797
-                $amount         = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
798
-                $total          = wpinv_get_cart_total( null, $discounts );
799
-                $cart_totals    = wpinv_recalculate_tax( true );
794
+            if (wpinv_is_discount_valid($discount_code, $wpi_userID)) {
795
+                $discount       = wpinv_get_discount_by_code($discount_code);
796
+                $discounts      = wpinv_set_cart_discount($discount_code);
797
+                $amount         = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
798
+                $total          = wpinv_get_cart_total(null, $discounts);
799
+                $cart_totals    = wpinv_recalculate_tax(true);
800 800
             
801
-                if ( !empty( $cart_totals ) ) {
801
+                if (!empty($cart_totals)) {
802 802
                     $response['success']        = true;
803 803
                     $response['data']           = $cart_totals;
804 804
                     $response['data']['code']   = $discount_code;
@@ -807,29 +807,29 @@  discard block
 block discarded – undo
807 807
                 }
808 808
             } else {
809 809
                 $errors = wpinv_get_errors();
810
-                $response['msg']  = $errors['wpinv-discount-error'];
811
-                wpinv_unset_error( 'wpinv-discount-error' );
810
+                $response['msg'] = $errors['wpinv-discount-error'];
811
+                wpinv_unset_error('wpinv-discount-error');
812 812
             }
813 813
 
814 814
             // Allow for custom discount code handling
815
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
815
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
816 816
         }
817 817
         
818
-        wp_send_json( $response );
818
+        wp_send_json($response);
819 819
     }
820 820
     
821 821
     public static function remove_discount() {
822
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
822
+        check_ajax_referer('wpinv-nonce', '_nonce');
823 823
         
824 824
         $response = array();
825 825
         
826
-        if ( isset( $_POST['code'] ) ) {
827
-            $discount_code  = sanitize_text_field( $_POST['code'] );
828
-            $discounts      = wpinv_unset_cart_discount( $discount_code );
829
-            $total          = wpinv_get_cart_total( null, $discounts );
830
-            $cart_totals    = wpinv_recalculate_tax( true );
826
+        if (isset($_POST['code'])) {
827
+            $discount_code  = sanitize_text_field($_POST['code']);
828
+            $discounts      = wpinv_unset_cart_discount($discount_code);
829
+            $total          = wpinv_get_cart_total(null, $discounts);
830
+            $cart_totals    = wpinv_recalculate_tax(true);
831 831
             
832
-            if ( !empty( $cart_totals ) ) {
832
+            if (!empty($cart_totals)) {
833 833
                 $response['success']        = true;
834 834
                 $response['data']           = $cart_totals;
835 835
                 $response['data']['code']   = $discount_code;
@@ -838,10 +838,10 @@  discard block
 block discarded – undo
838 838
             }
839 839
             
840 840
             // Allow for custom discount code handling
841
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
841
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
842 842
         }
843 843
         
844
-        wp_send_json( $response );
844
+        wp_send_json($response);
845 845
     }
846 846
 
847 847
 
@@ -853,53 +853,53 @@  discard block
 block discarded – undo
853 853
     public static function buy_items() {
854 854
         $user_id = get_current_user_id();
855 855
 
856
-        if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page
857
-            wp_send_json( array(
858
-                'success' => wp_login_url( wp_get_referer() )
859
-            ) );
856
+        if (empty($user_id)) { // If not logged in then lets redirect to the login page
857
+            wp_send_json(array(
858
+                'success' => wp_login_url(wp_get_referer())
859
+            ));
860 860
         } else {
861 861
             // Only check nonce if logged in as it could be cached when logged out.
862
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
863
-                wp_send_json( array(
864
-                    'error' => __( 'Security checks failed.', 'invoicing' )
865
-                ) );
862
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
863
+                wp_send_json(array(
864
+                    'error' => __('Security checks failed.', 'invoicing')
865
+                ));
866 866
                 wp_die();
867 867
             }
868 868
 
869 869
             // allow to set a custom price through post_id
870 870
             $items = $_POST['items'];
871
-            $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0;
872
-            $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0;
871
+            $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
872
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
873 873
 
874 874
             $cart_items = array();
875
-            if ( $items ) {
876
-                $items = explode( ',', $items );
875
+            if ($items) {
876
+                $items = explode(',', $items);
877 877
 
878
-                foreach( $items as $item ) {
878
+                foreach ($items as $item) {
879 879
                     $item_id = $item;
880 880
                     $quantity = 1;
881 881
 
882
-                    if ( strpos( $item, '|' ) !== false ) {
883
-                        $item_parts = explode( '|', $item );
882
+                    if (strpos($item, '|') !== false) {
883
+                        $item_parts = explode('|', $item);
884 884
                         $item_id = $item_parts[0];
885 885
                         $quantity = $item_parts[1];
886 886
                     }
887 887
 
888
-                    if ( $item_id && $quantity ) {
888
+                    if ($item_id && $quantity) {
889 889
                         $cart_items_arr = array(
890
-                            'id'            => (int)$item_id,
891
-                            'quantity'      => (int)$quantity
890
+                            'id'            => (int) $item_id,
891
+                            'quantity'      => (int) $quantity
892 892
                         );
893 893
 
894 894
                         // If there is a related post id then add it to meta
895
-                        if ( $related_post_id ) {
895
+                        if ($related_post_id) {
896 896
                             $cart_items_arr['meta'] = array(
897 897
                                 'post_id'   => $related_post_id
898 898
                             );
899 899
                         }
900 900
 
901 901
                         // If there is a custom price then set it.
902
-                        if ( $custom_item_price ) {
902
+                        if ($custom_item_price) {
903 903
                             $cart_items_arr['custom_price'] = $custom_item_price;
904 904
                         }
905 905
 
@@ -915,37 +915,37 @@  discard block
 block discarded – undo
915 915
              * @param int $related_post_id The related post id if any.
916 916
              * @since 1.0.0
917 917
              */
918
-            $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id );
918
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
919 919
 
920 920
             // Make sure its not in the cart already, if it is then redirect to checkout.
921 921
             $cart_invoice = wpinv_get_invoice_cart();
922 922
 
923
-            if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) {
924
-                wp_send_json( array(
923
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
924
+                wp_send_json(array(
925 925
                     'success' =>  $cart_invoice->get_checkout_payment_url()
926
-                ) );
926
+                ));
927 927
                 wp_die();
928 928
             }
929 929
 
930 930
             // Check if user has invoice with same items waiting to be paid.
931
-            $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' );
932
-            if ( !empty( $user_invoices ) ) {
933
-                foreach( $user_invoices as $user_invoice ) {
931
+            $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending');
932
+            if (!empty($user_invoices)) {
933
+                foreach ($user_invoices as $user_invoice) {
934 934
                     $user_cart_details = array();
935
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
935
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
936 936
                     $cart_details = $invoice->get_cart_details();
937 937
 
938
-                    if ( !empty( $cart_details ) ) {
939
-                        foreach ( $cart_details as $invoice_item ) {
938
+                    if (!empty($cart_details)) {
939
+                        foreach ($cart_details as $invoice_item) {
940 940
                             $ii_arr = array();
941
-                            $ii_arr['id'] = (int)$invoice_item['id'];
942
-                            $ii_arr['quantity'] = (int)$invoice_item['quantity'];
941
+                            $ii_arr['id'] = (int) $invoice_item['id'];
942
+                            $ii_arr['quantity'] = (int) $invoice_item['quantity'];
943 943
 
944
-                            if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) {
944
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
945 945
                                 $ii_arr['meta'] = $invoice_item['meta'];
946 946
                             }
947 947
 
948
-                            if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) {
948
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
949 949
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
950 950
                             }
951 951
 
@@ -953,17 +953,17 @@  discard block
 block discarded – undo
953 953
                         }
954 954
                     }
955 955
 
956
-                    if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) {
957
-                        wp_send_json( array(
956
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
957
+                        wp_send_json(array(
958 958
                             'success' =>  $invoice->get_checkout_payment_url()
959
-                        ) );
959
+                        ));
960 960
                         wp_die();
961 961
                     }
962 962
                 }
963 963
             }
964 964
 
965 965
             // Create invoice and send user to checkout
966
-            if ( !empty( $cart_items ) ) {
966
+            if (!empty($cart_items)) {
967 967
                 $invoice_data = array(
968 968
                     'status'        =>  'wpi-pending',
969 969
                     'created_via'   =>  'wpi',
@@ -971,21 +971,21 @@  discard block
 block discarded – undo
971 971
                     'cart_details'  =>  $cart_items,
972 972
                 );
973 973
 
974
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
974
+                $invoice = wpinv_insert_invoice($invoice_data, true);
975 975
 
976
-                if ( !empty( $invoice ) && isset( $invoice->ID ) ) {
977
-                    wp_send_json( array(
976
+                if (!empty($invoice) && isset($invoice->ID)) {
977
+                    wp_send_json(array(
978 978
                         'success' =>  $invoice->get_checkout_payment_url()
979
-                    ) );
979
+                    ));
980 980
                 } else {
981
-                    wp_send_json( array(
982
-                        'error' => __( 'Invoice failed to create', 'invoicing' )
983
-                    ) );
981
+                    wp_send_json(array(
982
+                        'error' => __('Invoice failed to create', 'invoicing')
983
+                    ));
984 984
                 }
985 985
             } else {
986
-                wp_send_json( array(
987
-                    'error' => __( 'Items not valid.', 'invoicing' )
988
-                ) );
986
+                wp_send_json(array(
987
+                    'error' => __('Items not valid.', 'invoicing')
988
+                ));
989 989
             }
990 990
         }
991 991
 
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +743 added lines, -743 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-if ( !is_admin() ) {
15
-    add_filter( 'template_include', 'wpinv_template', 10, 1 );
16
-    add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' );
17
-    add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' );
18
-    add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' );
14
+if (!is_admin()) {
15
+    add_filter('template_include', 'wpinv_template', 10, 1);
16
+    add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar');
17
+    add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions');
18
+    add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions');
19 19
 }
20 20
 
21 21
 function wpinv_template_path() {
22
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
22
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
23 23
 }
24 24
 
25
-function wpinv_display_invoice_top_bar( $invoice ) {
26
-    if ( empty( $invoice ) ) {
25
+function wpinv_display_invoice_top_bar($invoice) {
26
+    if (empty($invoice)) {
27 27
         return;
28 28
     }
29 29
     ?>
30 30
     <div class="row wpinv-top-bar no-print">
31 31
         <div class="container">
32 32
             <div class="col-xs-6">
33
-                <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?>
33
+                <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?>
34 34
             </div>
35 35
             <div class="col-xs-6 text-right">
36
-                <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?>
36
+                <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?>
37 37
             </div>
38 38
         </div>
39 39
     </div>
40 40
     <?php
41 41
 }
42 42
 
43
-function wpinv_invoice_display_left_actions( $invoice ) {
44
-    if ( empty( $invoice ) ) {
43
+function wpinv_invoice_display_left_actions($invoice) {
44
+    if (empty($invoice)) {
45 45
         return; // Exit if invoice is not set.
46 46
     }
47 47
     
48
-    if ( $invoice->post_type == 'wpi_invoice' ) {
49
-        if ( $invoice->needs_payment() ) {
50
-            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php
48
+    if ($invoice->post_type == 'wpi_invoice') {
49
+        if ($invoice->needs_payment()) {
50
+            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php
51 51
         }
52 52
     }
53 53
     do_action('wpinv_invoice_display_left_actions', $invoice);
54 54
 }
55 55
 
56
-function wpinv_invoice_display_right_actions( $invoice ) {
57
-    if ( empty( $invoice ) ) {
56
+function wpinv_invoice_display_right_actions($invoice) {
57
+    if (empty($invoice)) {
58 58
         return; // Exit if invoice is not set.
59 59
     }
60 60
 
61
-    if ( $invoice->post_type == 'wpi_invoice' ) { ?>
62
-        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a>
63
-        <?php if ( is_user_logged_in() ) { ?>
64
-        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a>
61
+    if ($invoice->post_type == 'wpi_invoice') { ?>
62
+        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a>
63
+        <?php if (is_user_logged_in()) { ?>
64
+        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a>
65 65
         <?php }
66 66
     }
67 67
     do_action('wpinv_invoice_display_right_actions', $invoice);
68 68
 }
69 69
 
70
-function wpinv_before_invoice_content( $content ) {
70
+function wpinv_before_invoice_content($content) {
71 71
     global $post;
72 72
 
73
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
73
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
74 74
         ob_start();
75
-        do_action( 'wpinv_before_invoice_content', $post->ID );
75
+        do_action('wpinv_before_invoice_content', $post->ID);
76 76
         $content = ob_get_clean() . $content;
77 77
     }
78 78
 
79 79
     return $content;
80 80
 }
81
-add_filter( 'the_content', 'wpinv_before_invoice_content' );
81
+add_filter('the_content', 'wpinv_before_invoice_content');
82 82
 
83
-function wpinv_after_invoice_content( $content ) {
83
+function wpinv_after_invoice_content($content) {
84 84
     global $post;
85 85
 
86
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
86
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
87 87
         ob_start();
88
-        do_action( 'wpinv_after_invoice_content', $post->ID );
88
+        do_action('wpinv_after_invoice_content', $post->ID);
89 89
         $content .= ob_get_clean();
90 90
     }
91 91
 
92 92
     return $content;
93 93
 }
94
-add_filter( 'the_content', 'wpinv_after_invoice_content' );
94
+add_filter('the_content', 'wpinv_after_invoice_content');
95 95
 
96 96
 function wpinv_get_templates_dir() {
97 97
     return WPINV_PLUGIN_DIR . 'templates';
@@ -101,105 +101,105 @@  discard block
 block discarded – undo
101 101
     return WPINV_PLUGIN_URL . 'templates';
102 102
 }
103 103
 
104
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105
-    if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
104
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
105
+    if (!empty($args) && is_array($args)) {
106
+		extract($args);
107 107
 	}
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
109
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
110 110
 	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
111
+	$located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path);
112 112
 
113
-	if ( ! file_exists( $located ) ) {
114
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
113
+	if (!file_exists($located)) {
114
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
115 115
 		return;
116 116
 	}
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
119 119
 
120
-	include( $located );
120
+	include($located);
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
123 123
 }
124 124
 
125
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
125
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
126 126
 	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
127
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
128 128
 	return ob_get_clean();
129 129
 }
130 130
 
131
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
132
-    if ( ! $template_path ) {
131
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
132
+    if (!$template_path) {
133 133
         $template_path = wpinv_template_path();
134 134
     }
135 135
 
136
-    if ( ! $default_path ) {
136
+    if (!$default_path) {
137 137
         $default_path = WPINV_PLUGIN_DIR . 'templates/';
138 138
     }
139 139
 
140 140
     // Look within passed path within the theme - this is priority.
141 141
     $template = locate_template(
142 142
         array(
143
-            trailingslashit( $template_path ) . $template_name,
143
+            trailingslashit($template_path) . $template_name,
144 144
             $template_name
145 145
         )
146 146
     );
147 147
 
148 148
     // Get default templates/
149
-    if ( !$template && $default_path ) {
150
-        $template = trailingslashit( $default_path ) . $template_name;
149
+    if (!$template && $default_path) {
150
+        $template = trailingslashit($default_path) . $template_name;
151 151
     }
152 152
 
153 153
     // Return what we found.
154
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path );
154
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path);
155 155
 }
156 156
 
157
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
157
+function wpinv_get_template_part($slug, $name = null, $load = true) {
158
+	do_action('get_template_part_' . $slug, $slug, $name);
159 159
 
160 160
 	// Setup possible parts
161 161
 	$templates = array();
162
-	if ( isset( $name ) )
162
+	if (isset($name))
163 163
 		$templates[] = $slug . '-' . $name . '.php';
164 164
 	$templates[] = $slug . '.php';
165 165
 
166 166
 	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
167
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
168 168
 
169 169
 	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
170
+	return wpinv_locate_tmpl($templates, $load, false);
171 171
 }
172 172
 
173
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
173
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
174 174
 	// No file found yet
175 175
 	$located = false;
176 176
 
177 177
 	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
178
+	foreach ((array) $template_names as $template_name) {
179 179
 
180 180
 		// Continue if template is empty
181
-		if ( empty( $template_name ) )
181
+		if (empty($template_name))
182 182
 			continue;
183 183
 
184 184
 		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
185
+		$template_name = ltrim($template_name, '/');
186 186
 
187 187
 		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
188
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
190
+			if (file_exists($template_path . $template_name)) {
191 191
 				$located = $template_path . $template_name;
192 192
 				break;
193 193
 			}
194 194
 		}
195 195
 
196
-		if( !empty( $located ) ) {
196
+		if (!empty($located)) {
197 197
 			break;
198 198
 		}
199 199
 	}
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+	if ((true == $load) && !empty($located))
202
+		load_template($located, $require_once);
203 203
 
204 204
 	return $located;
205 205
 }
@@ -208,159 +208,159 @@  discard block
 block discarded – undo
208 208
 	$template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210 210
 	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
211
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
212
+		10 => trailingslashit(get_template_directory()) . $template_dir,
213 213
 		100 => wpinv_get_templates_dir()
214 214
 	);
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
217 217
 
218 218
 	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
219
+	ksort($file_paths, SORT_NUMERIC);
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+	return array_map('trailingslashit', $file_paths);
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230 230
 	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234
+	$pages[] = wpinv_get_option('invoice_subscription_page');
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
236
+	if (!wpinv_is_checkout() && !is_page($pages)) {
237 237
 		return;
238 238
 	}
239 239
 
240 240
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
242
+add_action('wp_head', 'wpinv_checkout_meta_tags');
243 243
 
244
-function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
244
+function wpinv_add_body_classes($class) {
245
+	$classes = (array) $class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
247
+	if (wpinv_is_checkout()) {
248 248
 		$classes[] = 'wpinv-checkout';
249 249
 		$classes[] = 'wpinv-page';
250 250
 	}
251 251
 
252
-	if( wpinv_is_success_page() ) {
252
+	if (wpinv_is_success_page()) {
253 253
 		$classes[] = 'wpinv-success';
254 254
 		$classes[] = 'wpinv-page';
255 255
 	}
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
257
+	if (wpinv_is_failed_transaction_page()) {
258 258
 		$classes[] = 'wpinv-failed-transaction';
259 259
 		$classes[] = 'wpinv-page';
260 260
 	}
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
262
+	if (wpinv_is_invoice_history_page()) {
263 263
 		$classes[] = 'wpinv-history';
264 264
 		$classes[] = 'wpinv-page';
265 265
 	}
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
267
+	if (wpinv_is_subscriptions_history_page()) {
268 268
 		$classes[] = 'wpinv-subscription';
269 269
 		$classes[] = 'wpinv-page';
270 270
 	}
271 271
 
272
-	if( wpinv_is_test_mode() ) {
272
+	if (wpinv_is_test_mode()) {
273 273
 		$classes[] = 'wpinv-test-mode';
274 274
 		$classes[] = 'wpinv-page';
275 275
 	}
276 276
 
277
-	return array_unique( $classes );
277
+	return array_unique($classes);
278 278
 }
279
-add_filter( 'body_class', 'wpinv_add_body_classes' );
279
+add_filter('body_class', 'wpinv_add_body_classes');
280 280
 
281
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
282
-    $args = array( 'nopaging' => true );
281
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
282
+    $args = array('nopaging' => true);
283 283
 
284
-    if ( ! empty( $status ) )
284
+    if (!empty($status))
285 285
         $args['post_status'] = $status;
286 286
 
287
-    $discounts = wpinv_get_discounts( $args );
287
+    $discounts = wpinv_get_discounts($args);
288 288
     $options   = array();
289 289
 
290
-    if ( $discounts ) {
291
-        foreach ( $discounts as $discount ) {
292
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
290
+    if ($discounts) {
291
+        foreach ($discounts as $discount) {
292
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
293 293
         }
294 294
     } else {
295
-        $options[0] = __( 'No discounts found', 'invoicing' );
295
+        $options[0] = __('No discounts found', 'invoicing');
296 296
     }
297 297
 
298
-    $output = wpinv_html_select( array(
298
+    $output = wpinv_html_select(array(
299 299
         'name'             => $name,
300 300
         'selected'         => $selected,
301 301
         'options'          => $options,
302 302
         'show_option_all'  => false,
303 303
         'show_option_none' => false,
304
-    ) );
304
+    ));
305 305
 
306 306
     return $output;
307 307
 }
308 308
 
309
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
310
-    $current     = date( 'Y' );
311
-    $start_year  = $current - absint( $years_before );
312
-    $end_year    = $current + absint( $years_after );
313
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
309
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
310
+    $current     = date('Y');
311
+    $start_year  = $current - absint($years_before);
312
+    $end_year    = $current + absint($years_after);
313
+    $selected    = empty($selected) ? date('Y') : $selected;
314 314
     $options     = array();
315 315
 
316
-    while ( $start_year <= $end_year ) {
317
-        $options[ absint( $start_year ) ] = $start_year;
316
+    while ($start_year <= $end_year) {
317
+        $options[absint($start_year)] = $start_year;
318 318
         $start_year++;
319 319
     }
320 320
 
321
-    $output = wpinv_html_select( array(
321
+    $output = wpinv_html_select(array(
322 322
         'name'             => $name,
323 323
         'selected'         => $selected,
324 324
         'options'          => $options,
325 325
         'show_option_all'  => false,
326 326
         'show_option_none' => false
327
-    ) );
327
+    ));
328 328
 
329 329
     return $output;
330 330
 }
331 331
 
332
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
332
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
333 333
 
334 334
     $options = array(
335
-        '1'  => __( 'January', 'invoicing' ),
336
-        '2'  => __( 'February', 'invoicing' ),
337
-        '3'  => __( 'March', 'invoicing' ),
338
-        '4'  => __( 'April', 'invoicing' ),
339
-        '5'  => __( 'May', 'invoicing' ),
340
-        '6'  => __( 'June', 'invoicing' ),
341
-        '7'  => __( 'July', 'invoicing' ),
342
-        '8'  => __( 'August', 'invoicing' ),
343
-        '9'  => __( 'September', 'invoicing' ),
344
-        '10' => __( 'October', 'invoicing' ),
345
-        '11' => __( 'November', 'invoicing' ),
346
-        '12' => __( 'December', 'invoicing' ),
335
+        '1'  => __('January', 'invoicing'),
336
+        '2'  => __('February', 'invoicing'),
337
+        '3'  => __('March', 'invoicing'),
338
+        '4'  => __('April', 'invoicing'),
339
+        '5'  => __('May', 'invoicing'),
340
+        '6'  => __('June', 'invoicing'),
341
+        '7'  => __('July', 'invoicing'),
342
+        '8'  => __('August', 'invoicing'),
343
+        '9'  => __('September', 'invoicing'),
344
+        '10' => __('October', 'invoicing'),
345
+        '11' => __('November', 'invoicing'),
346
+        '12' => __('December', 'invoicing'),
347 347
     );
348 348
 
349 349
     // If no month is selected, default to the current month
350
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
350
+    $selected = empty($selected) ? date('n') : $selected;
351 351
 
352
-    $output = wpinv_html_select( array(
352
+    $output = wpinv_html_select(array(
353 353
         'name'             => $name,
354 354
         'selected'         => $selected,
355 355
         'options'          => $options,
356 356
         'show_option_all'  => false,
357 357
         'show_option_none' => false
358
-    ) );
358
+    ));
359 359
 
360 360
     return $output;
361 361
 }
362 362
 
363
-function wpinv_html_select( $args = array() ) {
363
+function wpinv_html_select($args = array()) {
364 364
     $defaults = array(
365 365
         'options'          => array(),
366 366
         'name'             => null,
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
         'selected'         => 0,
370 370
         'placeholder'      => null,
371 371
         'multiple'         => false,
372
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
373
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
372
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
373
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
374 374
         'data'             => array(),
375 375
         'onchange'         => null,
376 376
         'required'         => false,
@@ -378,74 +378,74 @@  discard block
 block discarded – undo
378 378
         'readonly'         => false,
379 379
     );
380 380
 
381
-    $args = wp_parse_args( $args, $defaults );
381
+    $args = wp_parse_args($args, $defaults);
382 382
 
383 383
     $data_elements = '';
384
-    foreach ( $args['data'] as $key => $value ) {
385
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
384
+    foreach ($args['data'] as $key => $value) {
385
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
386 386
     }
387 387
 
388
-    if( $args['multiple'] ) {
388
+    if ($args['multiple']) {
389 389
         $multiple = ' MULTIPLE';
390 390
     } else {
391 391
         $multiple = '';
392 392
     }
393 393
 
394
-    if( $args['placeholder'] ) {
394
+    if ($args['placeholder']) {
395 395
         $placeholder = $args['placeholder'];
396 396
     } else {
397 397
         $placeholder = '';
398 398
     }
399 399
     
400 400
     $options = '';
401
-    if( !empty( $args['onchange'] ) ) {
402
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
401
+    if (!empty($args['onchange'])) {
402
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
403 403
     }
404 404
     
405
-    if( !empty( $args['required'] ) ) {
405
+    if (!empty($args['required'])) {
406 406
         $options .= ' required="required"';
407 407
     }
408 408
     
409
-    if( !empty( $args['disabled'] ) ) {
409
+    if (!empty($args['disabled'])) {
410 410
         $options .= ' disabled';
411 411
     }
412 412
     
413
-    if( !empty( $args['readonly'] ) ) {
413
+    if (!empty($args['readonly'])) {
414 414
         $options .= ' readonly';
415 415
     }
416 416
 
417
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
418
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
417
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
418
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
419 419
 
420
-    if ( $args['show_option_all'] ) {
421
-        if( $args['multiple'] ) {
422
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
420
+    if ($args['show_option_all']) {
421
+        if ($args['multiple']) {
422
+            $selected = selected(true, in_array(0, $args['selected']), false);
423 423
         } else {
424
-            $selected = selected( $args['selected'], 0, false );
424
+            $selected = selected($args['selected'], 0, false);
425 425
         }
426
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
426
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
427 427
     }
428 428
 
429
-    if ( !empty( $args['options'] ) ) {
429
+    if (!empty($args['options'])) {
430 430
 
431
-        if ( $args['show_option_none'] ) {
432
-            if( $args['multiple'] ) {
433
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
431
+        if ($args['show_option_none']) {
432
+            if ($args['multiple']) {
433
+                $selected = selected(true, in_array("", $args['selected']), false);
434 434
             } else {
435
-                $selected = selected( $args['selected'] === "", true, false );
435
+                $selected = selected($args['selected'] === "", true, false);
436 436
             }
437
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
437
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
438 438
         }
439 439
 
440
-        foreach( $args['options'] as $key => $option ) {
440
+        foreach ($args['options'] as $key => $option) {
441 441
 
442
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
443
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
442
+            if ($args['multiple'] && is_array($args['selected'])) {
443
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
444 444
             } else {
445
-                $selected = selected( $args['selected'], $key, false );
445
+                $selected = selected($args['selected'], $key, false);
446 446
             }
447 447
 
448
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
448
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
449 449
         }
450 450
     }
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     return $output;
455 455
 }
456 456
 
457
-function wpinv_item_dropdown( $args = array() ) {
457
+function wpinv_item_dropdown($args = array()) {
458 458
     $defaults = array(
459 459
         'name'              => 'wpi_item',
460 460
         'id'                => 'wpi_item',
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         'multiple'          => false,
463 463
         'selected'          => 0,
464 464
         'number'            => 100,
465
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
466
-        'data'              => array( 'search-type' => 'item' ),
465
+        'placeholder'       => __('Choose a item', 'invoicing'),
466
+        'data'              => array('search-type' => 'item'),
467 467
         'show_option_all'   => false,
468 468
         'show_option_none'  => false,
469 469
         'show_recurring'    => false,
470 470
     );
471 471
 
472
-    $args = wp_parse_args( $args, $defaults );
472
+    $args = wp_parse_args($args, $defaults);
473 473
 
474 474
     $item_args = array(
475 475
         'post_type'      => 'wpi_item',
@@ -478,44 +478,44 @@  discard block
 block discarded – undo
478 478
         'posts_per_page' => $args['number']
479 479
     );
480 480
     
481
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
481
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
482 482
 
483
-    $items      = get_posts( $item_args );
483
+    $items      = get_posts($item_args);
484 484
     $options    = array();
485
-    if ( $items ) {
486
-        foreach ( $items as $item ) {
487
-            $title = esc_html( $item->post_title );
485
+    if ($items) {
486
+        foreach ($items as $item) {
487
+            $title = esc_html($item->post_title);
488 488
             
489
-            if ( !empty( $args['show_recurring'] ) ) {
490
-                $title .= wpinv_get_item_suffix( $item->ID, false );
489
+            if (!empty($args['show_recurring'])) {
490
+                $title .= wpinv_get_item_suffix($item->ID, false);
491 491
             }
492 492
             
493
-            $options[ absint( $item->ID ) ] = $title;
493
+            $options[absint($item->ID)] = $title;
494 494
         }
495 495
     }
496 496
 
497 497
     // This ensures that any selected items are included in the drop down
498
-    if( is_array( $args['selected'] ) ) {
499
-        foreach( $args['selected'] as $item ) {
500
-            if( ! in_array( $item, $options ) ) {
501
-                $title = get_the_title( $item );
502
-                if ( !empty( $args['show_recurring'] ) ) {
503
-                    $title .= wpinv_get_item_suffix( $item, false );
498
+    if (is_array($args['selected'])) {
499
+        foreach ($args['selected'] as $item) {
500
+            if (!in_array($item, $options)) {
501
+                $title = get_the_title($item);
502
+                if (!empty($args['show_recurring'])) {
503
+                    $title .= wpinv_get_item_suffix($item, false);
504 504
                 }
505 505
                 $options[$item] = $title;
506 506
             }
507 507
         }
508
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
509
-        if ( ! in_array( $args['selected'], $options ) ) {
510
-            $title = get_the_title( $args['selected'] );
511
-            if ( !empty( $args['show_recurring'] ) ) {
512
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
508
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
509
+        if (!in_array($args['selected'], $options)) {
510
+            $title = get_the_title($args['selected']);
511
+            if (!empty($args['show_recurring'])) {
512
+                $title .= wpinv_get_item_suffix($args['selected'], false);
513 513
             }
514
-            $options[$args['selected']] = get_the_title( $args['selected'] );
514
+            $options[$args['selected']] = get_the_title($args['selected']);
515 515
         }
516 516
     }
517 517
 
518
-    $output = wpinv_html_select( array(
518
+    $output = wpinv_html_select(array(
519 519
         'name'             => $args['name'],
520 520
         'selected'         => $args['selected'],
521 521
         'id'               => $args['id'],
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
         'show_option_all'  => $args['show_option_all'],
527 527
         'show_option_none' => $args['show_option_none'],
528 528
         'data'             => $args['data'],
529
-    ) );
529
+    ));
530 530
 
531 531
     return $output;
532 532
 }
533 533
 
534
-function wpinv_html_checkbox( $args = array() ) {
534
+function wpinv_html_checkbox($args = array()) {
535 535
     $defaults = array(
536 536
         'name'     => null,
537 537
         'current'  => null,
@@ -542,38 +542,38 @@  discard block
 block discarded – undo
542 542
         )
543 543
     );
544 544
 
545
-    $args = wp_parse_args( $args, $defaults );
545
+    $args = wp_parse_args($args, $defaults);
546 546
 
547
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
547
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
548 548
     $options = '';
549
-    if ( ! empty( $args['options']['disabled'] ) ) {
549
+    if (!empty($args['options']['disabled'])) {
550 550
         $options .= ' disabled="disabled"';
551
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
551
+    } elseif (!empty($args['options']['readonly'])) {
552 552
         $options .= ' readonly';
553 553
     }
554 554
 
555
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
555
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
556 556
 
557 557
     return $output;
558 558
 }
559 559
 
560
-function wpinv_html_text( $args = array() ) {
560
+function wpinv_html_text($args = array()) {
561 561
     // Backwards compatibility
562
-    if ( func_num_args() > 1 ) {
562
+    if (func_num_args() > 1) {
563 563
         $args = func_get_args();
564 564
 
565 565
         $name  = $args[0];
566
-        $value = isset( $args[1] ) ? $args[1] : '';
567
-        $label = isset( $args[2] ) ? $args[2] : '';
568
-        $desc  = isset( $args[3] ) ? $args[3] : '';
566
+        $value = isset($args[1]) ? $args[1] : '';
567
+        $label = isset($args[2]) ? $args[2] : '';
568
+        $desc  = isset($args[3]) ? $args[3] : '';
569 569
     }
570 570
 
571 571
     $defaults = array(
572 572
         'id'           => '',
573
-        'name'         => isset( $name )  ? $name  : 'text',
574
-        'value'        => isset( $value ) ? $value : null,
575
-        'label'        => isset( $label ) ? $label : null,
576
-        'desc'         => isset( $desc )  ? $desc  : null,
573
+        'name'         => isset($name) ? $name : 'text',
574
+        'value'        => isset($value) ? $value : null,
575
+        'label'        => isset($label) ? $label : null,
576
+        'desc'         => isset($desc) ? $desc : null,
577 577
         'placeholder'  => '',
578 578
         'class'        => 'regular-text',
579 579
         'disabled'     => false,
@@ -583,51 +583,51 @@  discard block
 block discarded – undo
583 583
         'data'         => false
584 584
     );
585 585
 
586
-    $args = wp_parse_args( $args, $defaults );
586
+    $args = wp_parse_args($args, $defaults);
587 587
 
588
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
588
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
589 589
     $options = '';
590
-    if( $args['required'] ) {
590
+    if ($args['required']) {
591 591
         $options .= ' required="required"';
592 592
     }
593
-    if( $args['readonly'] ) {
593
+    if ($args['readonly']) {
594 594
         $options .= ' readonly';
595 595
     }
596
-    if( $args['readonly'] ) {
596
+    if ($args['readonly']) {
597 597
         $options .= ' readonly';
598 598
     }
599 599
 
600 600
     $data = '';
601
-    if ( !empty( $args['data'] ) ) {
602
-        foreach ( $args['data'] as $key => $value ) {
603
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
601
+    if (!empty($args['data'])) {
602
+        foreach ($args['data'] as $key => $value) {
603
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
604 604
         }
605 605
     }
606 606
 
607
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
608
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
609
-    if ( ! empty( $args['desc'] ) ) {
610
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
607
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
608
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
609
+    if (!empty($args['desc'])) {
610
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
611 611
     }
612 612
 
613
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
613
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
614 614
 
615 615
     $output .= '</span>';
616 616
 
617 617
     return $output;
618 618
 }
619 619
 
620
-function wpinv_html_date_field( $args = array() ) {
621
-    if( empty( $args['class'] ) ) {
620
+function wpinv_html_date_field($args = array()) {
621
+    if (empty($args['class'])) {
622 622
         $args['class'] = 'wpiDatepicker';
623
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
623
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
624 624
         $args['class'] .= ' wpiDatepicker';
625 625
     }
626 626
 
627
-    return wpinv_html_text( $args );
627
+    return wpinv_html_text($args);
628 628
 }
629 629
 
630
-function wpinv_html_textarea( $args = array() ) {
630
+function wpinv_html_textarea($args = array()) {
631 631
     $defaults = array(
632 632
         'name'        => 'textarea',
633 633
         'value'       => null,
@@ -638,31 +638,31 @@  discard block
 block discarded – undo
638 638
         'placeholder' => '',
639 639
     );
640 640
 
641
-    $args = wp_parse_args( $args, $defaults );
641
+    $args = wp_parse_args($args, $defaults);
642 642
 
643
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
643
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
644 644
     $disabled = '';
645
-    if( $args['disabled'] ) {
645
+    if ($args['disabled']) {
646 646
         $disabled = ' disabled="disabled"';
647 647
     }
648 648
 
649
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
650
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
651
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
649
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
650
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
651
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
652 652
 
653
-    if ( ! empty( $args['desc'] ) ) {
654
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
653
+    if (!empty($args['desc'])) {
654
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
655 655
     }
656 656
     $output .= '</span>';
657 657
 
658 658
     return $output;
659 659
 }
660 660
 
661
-function wpinv_html_ajax_user_search( $args = array() ) {
661
+function wpinv_html_ajax_user_search($args = array()) {
662 662
     $defaults = array(
663 663
         'name'        => 'user_id',
664 664
         'value'       => null,
665
-        'placeholder' => __( 'Enter username', 'invoicing' ),
665
+        'placeholder' => __('Enter username', 'invoicing'),
666 666
         'label'       => null,
667 667
         'desc'        => null,
668 668
         'class'       => '',
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
         'data'        => false
672 672
     );
673 673
 
674
-    $args = wp_parse_args( $args, $defaults );
674
+    $args = wp_parse_args($args, $defaults);
675 675
 
676 676
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
677 677
 
678 678
     $output  = '<span class="wpinv_user_search_wrap">';
679
-        $output .= wpinv_html_text( $args );
680
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
679
+        $output .= wpinv_html_text($args);
680
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
681 681
     $output .= '</span>';
682 682
 
683 683
     return $output;
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 function wpinv_ip_geolocation() {
687 687
     global $wpinv_euvat;
688 688
     
689
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
689
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
690 690
     $content    = '';
691 691
     $iso        = '';
692 692
     $country    = '';
@@ -697,69 +697,69 @@  discard block
 block discarded – undo
697 697
     $credit     = '';
698 698
     $address    = '';
699 699
     
700
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
700
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
701 701
         try {
702 702
             $iso        = $geoip2_city->country->isoCode;
703 703
             $country    = $geoip2_city->country->name;
704
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
704
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
705 705
             $city       = $geoip2_city->city->name;
706 706
             $longitude  = $geoip2_city->location->longitude;
707 707
             $latitude   = $geoip2_city->location->latitude;
708
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
709
-        } catch( Exception $e ) { }
708
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
709
+        } catch (Exception $e) { }
710 710
     }
711 711
     
712
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
712
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
713 713
         try {
714
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
714
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
715 715
             
716
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
716
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
717 717
                 $iso        = $load_xml->geoplugin_countryCode;
718 718
                 $country    = $load_xml->geoplugin_countryName;
719
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
720
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
719
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
720
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
721 721
                 $longitude  = $load_xml->geoplugin_longitude;
722 722
                 $latitude   = $load_xml->geoplugin_latitude;
723 723
                 $credit     = $load_xml->geoplugin_credit;
724
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
724
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
725 725
             }
726
-        } catch( Exception $e ) { }
726
+        } catch (Exception $e) { }
727 727
     }
728 728
     
729
-    if ( $iso && $longitude && $latitude ) {
730
-        if ( $city ) {
729
+    if ($iso && $longitude && $latitude) {
730
+        if ($city) {
731 731
             $address .= $city . ', ';
732 732
         }
733 733
         
734
-        if ( $region ) {
734
+        if ($region) {
735 735
             $address .= $region . ', ';
736 736
         }
737 737
         
738 738
         $address .= $country . ' (' . $iso . ')';
739
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
740
-        $content .= '<p>'. $credit . '</p>';
739
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
740
+        $content .= '<p>' . $credit . '</p>';
741 741
     } else {
742
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
742
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
743 743
     }
744 744
     ?>
745 745
 <!DOCTYPE html>
746
-<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
746
+<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
747 747
 <body>
748
-    <?php if ( $latitude && $latitude ) { ?>
748
+    <?php if ($latitude && $latitude) { ?>
749 749
     <div id="map"></div>
750 750
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
751 751
         <script type="text/javascript">
752 752
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
753 753
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
754 754
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
755
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
755
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
756 756
 
757 757
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
758 758
 
759 759
         var marker = new L.Marker(latlng);
760 760
         map.addLayer(marker);
761 761
 
762
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
762
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
763 763
     </script>
764 764
     <?php } ?>
765 765
     <div style="height:100px"><?php echo $content; ?></div>
@@ -767,18 +767,18 @@  discard block
 block discarded – undo
767 767
 <?php
768 768
     exit;
769 769
 }
770
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
771
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
770
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
771
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
772 772
 
773 773
 // Set up the template for the invoice.
774
-function wpinv_template( $template ) {
774
+function wpinv_template($template) {
775 775
     global $post, $wp_query;
776 776
     
777
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
778
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
779
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
777
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
778
+        if (wpinv_user_can_view_invoice($post->ID)) {
779
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
780 780
         } else {
781
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
781
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
782 782
         }
783 783
     }
784 784
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 
788 788
 function wpinv_get_business_address() {
789 789
     $business_address   = wpinv_store_address();
790
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
790
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
791 791
     
792 792
     /*
793 793
     $default_country    = wpinv_get_default_country();
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
     
812 812
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
813 813
     
814
-    return apply_filters( 'wpinv_get_business_address', $business_address );
814
+    return apply_filters('wpinv_get_business_address', $business_address);
815 815
 }
816 816
 
817 817
 function wpinv_display_from_address() {
@@ -821,107 +821,107 @@  discard block
 block discarded – undo
821 821
     if (empty($from_name)) {
822 822
         $from_name = wpinv_get_business_name();
823 823
     }
824
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
824
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
825 825
     <div class="wrapper col-xs-10">
826
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
827
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
828
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
826
+        <div class="name"><?php echo esc_html($from_name); ?></div>
827
+        <?php if ($address = wpinv_get_business_address()) { ?>
828
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
829 829
         <?php } ?>
830
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
831
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
830
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
831
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
832 832
         <?php } ?>
833 833
     </div>
834 834
     <?php
835 835
 }
836 836
 
837
-function wpinv_watermark( $id = 0 ) {
838
-    $output = wpinv_get_watermark( $id );
837
+function wpinv_watermark($id = 0) {
838
+    $output = wpinv_get_watermark($id);
839 839
     
840
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
840
+    return apply_filters('wpinv_get_watermark', $output, $id);
841 841
 }
842 842
 
843
-function wpinv_get_watermark( $id ) {
844
-    if ( !$id > 0 ) {
843
+function wpinv_get_watermark($id) {
844
+    if (!$id > 0) {
845 845
         return NULL;
846 846
     }
847
-    $invoice = wpinv_get_invoice( $id );
847
+    $invoice = wpinv_get_invoice($id);
848 848
     
849
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
850
-        if ( $invoice->is_paid() ) {
851
-            return __( 'Paid', 'invoicing' );
849
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
850
+        if ($invoice->is_paid()) {
851
+            return __('Paid', 'invoicing');
852 852
         }
853
-        if ( $invoice->is_refunded() ) {
854
-            return __( 'Refunded', 'invoicing' );
853
+        if ($invoice->is_refunded()) {
854
+            return __('Refunded', 'invoicing');
855 855
         }
856
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
857
-            return __( 'Cancelled', 'invoicing' );
856
+        if ($invoice->has_status(array('wpi-cancelled'))) {
857
+            return __('Cancelled', 'invoicing');
858 858
         }
859 859
     }
860 860
     
861 861
     return NULL;
862 862
 }
863 863
 
864
-function wpinv_display_invoice_details( $invoice ) {
864
+function wpinv_display_invoice_details($invoice) {
865 865
     global $wpinv_euvat;
866 866
     
867 867
     $invoice_id = $invoice->ID;
868 868
     $vat_name   = $wpinv_euvat->get_vat_name();
869 869
     $use_taxes  = wpinv_use_taxes();
870 870
     
871
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
871
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
872 872
     ?>
873 873
     <table class="table table-bordered table-sm">
874
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
874
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
875 875
             <tr class="wpi-row-number">
876
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
877
-                <td><?php echo esc_html( $invoice_number ); ?></td>
876
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
877
+                <td><?php echo esc_html($invoice_number); ?></td>
878 878
             </tr>
879 879
         <?php } ?>
880 880
         <tr class="wpi-row-status">
881
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
882
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
881
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
882
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
883 883
         </tr>
884
-        <?php if ( $invoice->is_renewal() ) { ?>
884
+        <?php if ($invoice->is_renewal()) { ?>
885 885
         <tr class="wpi-row-parent">
886
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
887
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
886
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
887
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
888 888
         </tr>
889 889
         <?php } ?>
890
-        <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
890
+        <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
891 891
             <tr class="wpi-row-gateway">
892
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
892
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
893 893
                 <td><?php echo $gateway_name; ?></td>
894 894
             </tr>
895 895
         <?php } ?>
896
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
896
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
897 897
             <tr class="wpi-row-date">
898
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
898
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
899 899
                 <td><?php echo $invoice_date; ?></td>
900 900
             </tr>
901 901
         <?php } ?>
902
-        <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?>
903
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
902
+        <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?>
903
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
904 904
             <tr class="wpi-row-date">
905
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
905
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
906 906
                 <td><?php echo $due_date; ?></td>
907 907
             </tr>
908 908
         <?php } ?>
909
-        <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?>
910
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
909
+        <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?>
910
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
911 911
             <tr class="wpi-row-ovatno">
912
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
912
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
913 913
                 <td><?php echo $owner_vat_number; ?></td>
914 914
             </tr>
915 915
         <?php } ?>
916
-        <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?>
916
+        <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?>
917 917
             <tr class="wpi-row-uvatno">
918
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
918
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
919 919
                 <td><?php echo $user_vat_number; ?></td>
920 920
             </tr>
921 921
         <?php } ?>
922 922
         <tr class="table-active tr-total wpi-row-total">
923
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
924
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
923
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
924
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
925 925
         </tr>
926 926
     </table>
927 927
 <?php
@@ -937,84 +937,84 @@  discard block
 block discarded – undo
937 937
  * @param  string $separator How to separate address lines.
938 938
  * @return string
939 939
  */
940
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
940
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
941 941
 
942 942
     // Retrieve the address markup...
943
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
944
-    $format = wpinv_get_full_address_format( $country );
943
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
944
+    $format = wpinv_get_full_address_format($country);
945 945
 
946 946
     // ... and the replacements.
947
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
947
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
948 948
 
949
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
949
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
950 950
     
951 951
 	// Remove unavailable tags.
952
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
952
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
953 953
 
954 954
     // Clean up white space.
955
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
956
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
955
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
956
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
957 957
     
958 958
     // Break newlines apart and remove empty lines/trim commas and white space.
959
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
959
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
960 960
 
961 961
     // Add html breaks.
962
-	$formatted_address = implode( $separator, $formatted_address );
962
+	$formatted_address = implode($separator, $formatted_address);
963 963
 
964 964
 	// We're done!
965 965
 	return $formatted_address;
966 966
     
967 967
 }
968 968
 
969
-function wpinv_display_to_address( $invoice_id = 0 ) {
970
-    $invoice = wpinv_get_invoice( $invoice_id );
969
+function wpinv_display_to_address($invoice_id = 0) {
970
+    $invoice = wpinv_get_invoice($invoice_id);
971 971
     
972
-    if ( empty( $invoice ) ) {
972
+    if (empty($invoice)) {
973 973
         return NULL;
974 974
     }
975 975
     
976 976
     $billing_details = $invoice->get_user_info();
977
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
977
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
978 978
     $output .= '<div class="wrapper col-xs-10">';
979 979
     
980 980
     ob_start();
981
-    do_action( 'wpinv_display_to_address_top', $invoice );
981
+    do_action('wpinv_display_to_address_top', $invoice);
982 982
     $output .= ob_get_clean();
983 983
     
984
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
984
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
985 985
 
986
-    if ( $address_row ) {
986
+    if ($address_row) {
987 987
         $output .= '<div class="address">' . $address_row . '</div>';
988 988
     }
989 989
 
990
-    if ( $phone = $invoice->get_phone() ) {
991
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
990
+    if ($phone = $invoice->get_phone()) {
991
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
992 992
     }
993
-    if ( $email = $invoice->get_email() ) {
994
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
993
+    if ($email = $invoice->get_email()) {
994
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
995 995
     }
996 996
 
997 997
     ob_start();
998
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
998
+    do_action('wpinv_display_to_address_bottom', $invoice);
999 999
     $output .= ob_get_clean();
1000 1000
     
1001 1001
     $output .= '</div>';
1002
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
1002
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
1003 1003
 
1004 1004
     echo $output;
1005 1005
 }
1006 1006
 
1007
-function wpinv_display_line_items( $invoice_id = 0 ) {
1007
+function wpinv_display_line_items($invoice_id = 0) {
1008 1008
     global $wpinv_euvat, $ajax_cart_details;
1009
-    $invoice            = wpinv_get_invoice( $invoice_id );
1009
+    $invoice            = wpinv_get_invoice($invoice_id);
1010 1010
     $quantities_enabled = wpinv_item_quantities_enabled();
1011 1011
     $use_taxes          = wpinv_use_taxes();
1012
-    if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
1012
+    if (!$use_taxes && (float) $invoice->get_tax() > 0) {
1013 1013
         $use_taxes = true;
1014 1014
     }
1015
-    $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
1016
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
1017
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
1015
+    $zero_tax           = !(float) $invoice->get_tax() > 0 ? true : false;
1016
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
1017
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
1018 1018
 
1019 1019
     $cart_details       = $invoice->get_cart_details();
1020 1020
     $ajax_cart_details  = $cart_details;
@@ -1023,67 +1023,67 @@  discard block
 block discarded – undo
1023 1023
     <table class="table table-sm table-bordered table-responsive">
1024 1024
         <thead>
1025 1025
             <tr>
1026
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1027
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1026
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1027
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1028 1028
                 <?php if ($quantities_enabled) { ?>
1029
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1029
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1030 1030
                 <?php } ?>
1031 1031
                 <?php if ($use_taxes && !$zero_tax) { ?>
1032 1032
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1033 1033
                 <?php } ?>
1034
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1034
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1035 1035
             </tr>
1036 1036
         </thead>
1037 1037
         <tbody>
1038 1038
         <?php 
1039
-            if ( !empty( $cart_details ) ) {
1040
-                do_action( 'wpinv_display_line_items_start', $invoice );
1039
+            if (!empty($cart_details)) {
1040
+                do_action('wpinv_display_line_items_start', $invoice);
1041 1041
 
1042 1042
                 $count = 0;
1043 1043
                 $cols  = 3;
1044
-                foreach ( $cart_details as $key => $cart_item ) {
1045
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1046
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1047
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1048
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1044
+                foreach ($cart_details as $key => $cart_item) {
1045
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1046
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1047
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1048
+                    $quantity   = !empty($cart_item['quantity']) && (int) $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1049 1049
 
1050
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1050
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1051 1051
                     $summary    = '';
1052
-	                $item_name    = '';
1052
+	                $item_name = '';
1053 1053
                     $cols       = 3;
1054
-                    if ( !empty($item) ) {
1054
+                    if (!empty($item)) {
1055 1055
                         $item_name  = $item->get_name();
1056 1056
                         $summary    = $item->get_summary();
1057 1057
                     }
1058
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1058
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1059 1059
 
1060
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1060
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1061 1061
 
1062 1062
                     $item_tax       = '';
1063 1063
                     $tax_rate       = '';
1064
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1065
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1066
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1067
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1064
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1065
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1066
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1067
+                        $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1068 1068
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1069 1069
                     }
1070 1070
 
1071 1071
                     $line_item_tax = $item_tax . $tax_rate;
1072 1072
 
1073
-                    if ( $line_item_tax === '' ) {
1073
+                    if ($line_item_tax === '') {
1074 1074
                         $line_item_tax = 0; // Zero tax
1075 1075
                     }
1076 1076
 
1077
-                    $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols );
1077
+                    $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols);
1078 1078
 
1079
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1080
-                        $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1081
-                        if ( $summary !== '' ) {
1082
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1079
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1080
+                        $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1081
+                        if ($summary !== '') {
1082
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1083 1083
                         }
1084 1084
                         $line_item .= '</td>';
1085 1085
 
1086
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1086
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1087 1087
                         if ($quantities_enabled) {
1088 1088
                             $cols++;
1089 1089
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1092,55 +1092,55 @@  discard block
 block discarded – undo
1092 1092
                             $cols++;
1093 1093
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1094 1094
                         }
1095
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1095
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1096 1096
                     $line_item .= '</tr>';
1097 1097
 
1098
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1098
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1099 1099
 
1100 1100
                     $count++;
1101 1101
                 }
1102 1102
 
1103
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1103
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1104 1104
                 ?>
1105 1105
                 <tr class="row-sub-total row_odd">
1106
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1107
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1106
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1107
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1108 1108
                 </tr>
1109 1109
                 <?php
1110
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1110
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1111 1111
                 
1112
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1113
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1112
+                if (wpinv_discount($invoice_id, false) > 0) {
1113
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1114 1114
                     ?>
1115 1115
                         <tr class="row-discount">
1116
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1117
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1116
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1117
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1118 1118
                         </tr>
1119 1119
                     <?php
1120
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1120
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1121 1121
                 }
1122 1122
 
1123
-                if ( $use_taxes ) {
1124
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1123
+                if ($use_taxes) {
1124
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1125 1125
                     ?>
1126 1126
                     <tr class="row-tax">
1127
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1128
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1127
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1128
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1129 1129
                     </tr>
1130 1130
                     <?php
1131
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1131
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1132 1132
                 }
1133 1133
 
1134
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1134
+                do_action('wpinv_display_before_total', $invoice, $cols);
1135 1135
                 ?>
1136 1136
                 <tr class="table-active row-total">
1137
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1138
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1137
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1138
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1139 1139
                 </tr>
1140 1140
                 <?php
1141
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1141
+                do_action('wpinv_display_after_total', $invoice, $cols);
1142 1142
 
1143
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1143
+                do_action('wpinv_display_line_end', $invoice, $cols);
1144 1144
             }
1145 1145
         ?>
1146 1146
         </tbody>
@@ -1152,56 +1152,56 @@  discard block
 block discarded – undo
1152 1152
 /**
1153 1153
  * @param WPInv_Invoice $invoice
1154 1154
  */
1155
-function wpinv_display_invoice_notes( $invoice ) {
1155
+function wpinv_display_invoice_notes($invoice) {
1156 1156
 
1157
-    $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' );
1157
+    $notes = wpinv_get_invoice_notes($invoice->ID, 'customer');
1158 1158
 
1159
-    if ( empty( $notes ) ) {
1159
+    if (empty($notes)) {
1160 1160
         return;
1161 1161
     }
1162 1162
 
1163 1163
     echo '<div class="wpi_invoice_notes_container">';
1164
-    echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>';
1164
+    echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>';
1165 1165
     echo '<ul class="wpi_invoice_notes">';
1166 1166
 
1167
-    foreach( $notes as $note ) {
1168
-        wpinv_get_invoice_note_line_item( $note );
1167
+    foreach ($notes as $note) {
1168
+        wpinv_get_invoice_note_line_item($note);
1169 1169
     }
1170 1170
 
1171 1171
     echo '</ul>';
1172 1172
     echo '</div>';
1173 1173
 }
1174
-add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' );
1174
+add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes');
1175 1175
 
1176
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {
1176
+function wpinv_display_invoice_totals($invoice_id = 0) {
1177 1177
     $use_taxes = wpinv_use_taxes();
1178 1178
 
1179
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1179
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1180 1180
     ?>
1181 1181
     <table class="table table-sm table-bordered table-responsive">
1182 1182
         <tbody>
1183
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1183
+            <?php do_action('wpinv_before_display_totals'); ?>
1184 1184
             <tr class="row-sub-total">
1185
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1186
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1185
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1186
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1187 1187
             </tr>
1188
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1189
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1188
+            <?php do_action('wpinv_after_display_totals'); ?>
1189
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1190 1190
                 <tr class="row-discount">
1191
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1192
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1191
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1192
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1193 1193
                 </tr>
1194
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1194
+            <?php do_action('wpinv_after_display_discount'); ?>
1195 1195
             <?php } ?>
1196
-            <?php if ( $use_taxes ) { ?>
1196
+            <?php if ($use_taxes) { ?>
1197 1197
             <tr class="row-tax">
1198
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1199
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1198
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1199
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1200 1200
             </tr>
1201
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1201
+            <?php do_action('wpinv_after_display_tax'); ?>
1202 1202
             <?php } ?>
1203
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1204
-                <?php foreach ( $fees as $fee ) { ?>
1203
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1204
+                <?php foreach ($fees as $fee) { ?>
1205 1205
                     <tr class="row-fee">
1206 1206
                         <td class="rate"><?php echo $fee['label']; ?></td>
1207 1207
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1209,82 +1209,82 @@  discard block
 block discarded – undo
1209 1209
                 <?php } ?>
1210 1210
             <?php } ?>
1211 1211
             <tr class="table-active row-total">
1212
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1213
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1212
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1213
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1214 1214
             </tr>
1215
-            <?php do_action( 'wpinv_after_totals' ); ?>
1215
+            <?php do_action('wpinv_after_totals'); ?>
1216 1216
         </tbody>
1217 1217
 
1218 1218
     </table>
1219 1219
 
1220
-    <?php do_action( 'wpinv_after_totals_table' );
1220
+    <?php do_action('wpinv_after_totals_table');
1221 1221
 }
1222 1222
 
1223
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1224
-    $invoice = wpinv_get_invoice( $invoice_id );
1223
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1224
+    $invoice = wpinv_get_invoice($invoice_id);
1225 1225
 
1226 1226
     ob_start();
1227
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1228
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1227
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1228
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1229 1229
         ?>
1230 1230
         <div class="wpi-payment-info">
1231
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1232
-            <?php if ( $gateway_title ) { ?>
1233
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1231
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1232
+            <?php if ($gateway_title) { ?>
1233
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1234 1234
             <?php } ?>
1235 1235
         </div>
1236 1236
         <?php
1237 1237
     }
1238
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1238
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1239 1239
     $outout = ob_get_clean();
1240 1240
 
1241
-    if ( $echo ) {
1241
+    if ($echo) {
1242 1242
         echo $outout;
1243 1243
     } else {
1244 1244
         return $outout;
1245 1245
     }
1246 1246
 }
1247 1247
 
1248
-function wpinv_display_style( $invoice ) {
1249
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1248
+function wpinv_display_style($invoice) {
1249
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1250 1250
 
1251
-    wp_print_styles( 'open-sans' );
1252
-    wp_print_styles( 'wpinv-single-style' );
1251
+    wp_print_styles('open-sans');
1252
+    wp_print_styles('wpinv-single-style');
1253 1253
 
1254 1254
     $custom_css = wpinv_get_option('template_custom_css');
1255
-    if(isset($custom_css) && !empty($custom_css)){
1256
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1257
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1255
+    if (isset($custom_css) && !empty($custom_css)) {
1256
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1257
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1258 1258
         echo '<style type="text/css">';
1259 1259
         echo $custom_css;
1260 1260
         echo '</style>';
1261 1261
     }
1262 1262
 }
1263
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1264
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1263
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1264
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1265 1265
 
1266 1266
 function wpinv_checkout_billing_details() {
1267
-    $invoice_id = (int)wpinv_get_invoice_cart_id();
1267
+    $invoice_id = (int) wpinv_get_invoice_cart_id();
1268 1268
     if (empty($invoice_id)) {
1269
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1269
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1270 1270
         return null;
1271 1271
     }
1272 1272
 
1273
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1273
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1274 1274
     if (empty($invoice)) {
1275
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1275
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1276 1276
         return null;
1277 1277
     }
1278 1278
     $user_id        = $invoice->get_user_id();
1279 1279
     $user_info      = $invoice->get_user_info();
1280
-    $address_info   = wpinv_get_user_address( $user_id );
1280
+    $address_info   = wpinv_get_user_address($user_id);
1281 1281
 
1282
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1282
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1283 1283
         $user_info['first_name'] = $user_info['first_name'];
1284 1284
         $user_info['last_name'] = $user_info['last_name'];
1285 1285
     }
1286 1286
 
1287
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1287
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1288 1288
         $user_info['country']   = $address_info['country'];
1289 1289
         $user_info['state']     = $address_info['state'];
1290 1290
         $user_info['city']      = $address_info['city'];
@@ -1300,98 +1300,98 @@  discard block
 block discarded – undo
1300 1300
         'address'
1301 1301
     );
1302 1302
 
1303
-    foreach ( $address_fields as $field ) {
1304
-        if ( empty( $user_info[$field] ) ) {
1303
+    foreach ($address_fields as $field) {
1304
+        if (empty($user_info[$field])) {
1305 1305
             $user_info[$field] = $address_info[$field];
1306 1306
         }
1307 1307
     }
1308 1308
 
1309
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1309
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1310 1310
 }
1311 1311
 
1312 1312
 function wpinv_admin_get_line_items($invoice = array()) {
1313 1313
     $item_quantities    = wpinv_item_quantities_enabled();
1314 1314
     $use_taxes          = wpinv_use_taxes();
1315 1315
 
1316
-    if ( empty( $invoice ) ) {
1316
+    if (empty($invoice)) {
1317 1317
         return NULL;
1318 1318
     }
1319 1319
 
1320 1320
     $cart_items = $invoice->get_cart_details();
1321
-    if ( empty( $cart_items ) ) {
1321
+    if (empty($cart_items)) {
1322 1322
         return NULL;
1323 1323
     }
1324 1324
     ob_start();
1325 1325
 
1326
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1326
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1327 1327
 
1328 1328
     $count = 0;
1329
-    foreach ( $cart_items as $key => $cart_item ) {
1329
+    foreach ($cart_items as $key => $cart_item) {
1330 1330
         $item_id    = $cart_item['id'];
1331
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1331
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1332 1332
 
1333 1333
         if (empty($wpi_item)) {
1334 1334
             continue;
1335 1335
         }
1336 1336
 
1337
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1338
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1339
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1337
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1338
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1339
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1340 1340
         $can_remove     = true;
1341 1341
 
1342
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1342
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1343 1343
 
1344 1344
         $item_tax       = '';
1345 1345
         $tax_rate       = '';
1346
-        if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1347
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1348
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1349
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1346
+        if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1347
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1348
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1349
+            $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1350 1350
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1351 1351
         }
1352 1352
         $line_item_tax = $item_tax . $tax_rate;
1353 1353
 
1354
-        if ( $line_item_tax === '' ) {
1354
+        if ($line_item_tax === '') {
1355 1355
             $line_item_tax = 0; // Zero tax
1356 1356
         }
1357 1357
 
1358
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1358
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1359 1359
             $line_item .= '<td class="id">' . $item_id . '</td>';
1360
-            $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item );
1361
-            if ( $summary !== '' ) {
1362
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1360
+            $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item);
1361
+            if ($summary !== '') {
1362
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1363 1363
             }
1364 1364
             $line_item .= '</td>';
1365 1365
             $line_item .= '<td class="price">' . $item_price . '</td>';
1366 1366
             
1367
-            if ( $item_quantities ) {
1368
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1367
+            if ($item_quantities) {
1368
+                if (count($cart_items) == 1 && $quantity <= 1) {
1369 1369
                     $can_remove = false;
1370 1370
                 }
1371 1371
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1372 1372
             } else {
1373
-                if ( count( $cart_items ) == 1 ) {
1373
+                if (count($cart_items) == 1) {
1374 1374
                     $can_remove = false;
1375 1375
                 }
1376 1376
             }
1377 1377
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1378 1378
             
1379
-            if ( $use_taxes ) {
1379
+            if ($use_taxes) {
1380 1380
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1381 1381
             }
1382 1382
             $line_item .= '<td class="action">';
1383
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
1383
+            if (!$invoice->is_paid() && !$invoice->is_refunded()) {
1384 1384
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1385 1385
             }
1386 1386
             $line_item .= '</td>';
1387 1387
         $line_item .= '</tr>';
1388 1388
 
1389
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1389
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1390 1390
 
1391 1391
         $count++;
1392 1392
     } 
1393 1393
 
1394
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1394
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1395 1395
 
1396 1396
     return ob_get_clean();
1397 1397
 }
@@ -1403,32 +1403,32 @@  discard block
 block discarded – undo
1403 1403
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1404 1404
 
1405 1405
     //Maybe update the prices
1406
-    if(! empty( $_GET['wpi_dynamic_item'] ) && ! empty( $_GET['wpi_dynamic_price'] ) ) {
1406
+    if (!empty($_GET['wpi_dynamic_item']) && !empty($_GET['wpi_dynamic_price'])) {
1407 1407
 
1408 1408
         //If the invoice exists, update it with new pricing details
1409
-        if (! empty( $wpi_checkout_id ) ) {
1409
+        if (!empty($wpi_checkout_id)) {
1410 1410
 
1411 1411
             $_invoice       = wpinv_get_invoice_cart();
1412 1412
             $_cart_details  = $_invoice->get_cart_details();
1413
-            $_dynamic_item  = sanitize_text_field( $_GET['wpi_dynamic_item'] );
1413
+            $_dynamic_item  = sanitize_text_field($_GET['wpi_dynamic_item']);
1414 1414
 
1415 1415
             //First, fetch the item
1416
-            $item    = new WPInv_Item( $_dynamic_item );
1416
+            $item = new WPInv_Item($_dynamic_item);
1417 1417
     
1418 1418
             //Next, ensure it supports dynamic pricing...
1419
-            if( $item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing() ) {
1419
+            if ($item->supports_dynamic_pricing() && $item->get_is_dynamic_pricing()) {
1420 1420
                 
1421 1421
                 //... and that the new price is not lower than the minimum price
1422
-                $_dynamic_price = (float) wpinv_sanitize_amount( sanitize_text_field( $_GET['wpi_dynamic_price'] ) );
1423
-                if( $_dynamic_price < $item->get_minimum_price() ) {
1422
+                $_dynamic_price = (float) wpinv_sanitize_amount(sanitize_text_field($_GET['wpi_dynamic_price']));
1423
+                if ($_dynamic_price < $item->get_minimum_price()) {
1424 1424
                     $_dynamic_price = $item->get_minimum_price();
1425 1425
                 }
1426 1426
 
1427 1427
                 //Finally, update our invoice with the new price
1428
-                if ( !empty( $_cart_details ) ) {
1428
+                if (!empty($_cart_details)) {
1429 1429
 
1430
-                    foreach ( $_cart_details as $key => $item ) {
1431
-                        if ( !empty( $item['id'] ) && $_dynamic_item == $item['id'] ) {
1430
+                    foreach ($_cart_details as $key => $item) {
1431
+                        if (!empty($item['id']) && $_dynamic_item == $item['id']) {
1432 1432
                             $_cart_details[$key]['custom_price'] = $_dynamic_price;
1433 1433
                             $_cart_details[$key]['item_price']   = $_dynamic_price;
1434 1434
                         }
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
 
1437 1437
                     $_meta = $_invoice->get_meta();
1438 1438
                     $_meta['cart_details'] = $_cart_details;
1439
-                    $_invoice->set( 'payment_meta', $_meta );
1440
-                    $_invoice->set( 'cart_details', $_cart_details );
1439
+                    $_invoice->set('payment_meta', $_meta);
1440
+                    $_invoice->set('cart_details', $_cart_details);
1441 1441
                     $_invoice->recalculate_totals();
1442 1442
 
1443 1443
                 }
@@ -1448,60 +1448,60 @@  discard block
 block discarded – undo
1448 1448
 
1449 1449
     }
1450 1450
 
1451
-    $form_action  = esc_url( wpinv_get_checkout_uri() );
1451
+    $form_action = esc_url(wpinv_get_checkout_uri());
1452 1452
 
1453 1453
     ob_start();
1454
-	    do_action( 'wpinv_checkout_content_before' );
1454
+	    do_action('wpinv_checkout_content_before');
1455 1455
         echo '<div id="wpinv_checkout_wrap">';
1456 1456
 
1457
-        if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) {
1457
+        if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) {
1458 1458
             ?>
1459 1459
             <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive">
1460
-                <?php do_action( 'wpinv_before_checkout_form' ); ?>
1460
+                <?php do_action('wpinv_before_checkout_form'); ?>
1461 1461
                 <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST">
1462 1462
                     <?php
1463
-                    do_action( 'wpinv_checkout_form_top' );
1464
-                    do_action( 'wpinv_checkout_billing_info' );
1465
-                    do_action( 'wpinv_checkout_cart' );
1466
-                    do_action( 'wpinv_payment_mode_select'  );
1467
-                    do_action( 'wpinv_checkout_form_bottom' )
1463
+                    do_action('wpinv_checkout_form_top');
1464
+                    do_action('wpinv_checkout_billing_info');
1465
+                    do_action('wpinv_checkout_cart');
1466
+                    do_action('wpinv_payment_mode_select');
1467
+                    do_action('wpinv_checkout_form_bottom')
1468 1468
                     ?>
1469 1469
                 </form>
1470
-                <?php do_action( 'wpinv_after_purchase_form' ); ?>
1470
+                <?php do_action('wpinv_after_purchase_form'); ?>
1471 1471
             </div><!--end #wpinv_checkout_form_wrap-->
1472 1472
         <?php
1473 1473
         } else {
1474
-            do_action( 'wpinv_cart_empty' );
1474
+            do_action('wpinv_cart_empty');
1475 1475
         }
1476 1476
         echo '</div><!--end #wpinv_checkout_wrap-->';
1477
-	    do_action( 'wpinv_checkout_content_after' );
1477
+	    do_action('wpinv_checkout_content_after');
1478 1478
     return ob_get_clean();
1479 1479
 }
1480 1480
 
1481
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1481
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1482 1482
     global $ajax_cart_details;
1483 1483
     $ajax_cart_details = $cart_details;
1484 1484
 
1485 1485
     ob_start();
1486
-    do_action( 'wpinv_before_checkout_cart' );
1486
+    do_action('wpinv_before_checkout_cart');
1487 1487
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1488 1488
         echo '<div id="wpinv_checkout_cart_wrap">';
1489
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1489
+            wpinv_get_template_part('wpinv-checkout-cart');
1490 1490
         echo '</div>';
1491 1491
     echo '</div>';
1492
-    do_action( 'wpinv_after_checkout_cart' );
1492
+    do_action('wpinv_after_checkout_cart');
1493 1493
     $content = ob_get_clean();
1494 1494
 
1495
-    if ( $echo ) {
1495
+    if ($echo) {
1496 1496
         echo $content;
1497 1497
     } else {
1498 1498
         return $content;
1499 1499
     }
1500 1500
 }
1501
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1501
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1502 1502
 
1503 1503
 function wpinv_empty_cart_message() {
1504
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1504
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1505 1505
 }
1506 1506
 
1507 1507
 /**
@@ -1513,83 +1513,83 @@  discard block
 block discarded – undo
1513 1513
 function wpinv_empty_checkout_cart() {
1514 1514
 	echo wpinv_empty_cart_message();
1515 1515
 }
1516
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1516
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1517 1517
 
1518 1518
 function wpinv_update_cart_button() {
1519
-    if ( !wpinv_item_quantities_enabled() )
1519
+    if (!wpinv_item_quantities_enabled())
1520 1520
         return;
1521 1521
 ?>
1522
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1522
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1523 1523
     <input type="hidden" name="wpi_action" value="update_cart"/>
1524 1524
 <?php
1525 1525
 }
1526 1526
 
1527 1527
 function wpinv_checkout_cart_columns() {
1528 1528
     $default = 3;
1529
-    if ( wpinv_item_quantities_enabled() ) {
1529
+    if (wpinv_item_quantities_enabled()) {
1530 1530
         $default++;
1531 1531
     }
1532 1532
     
1533
-    if ( wpinv_use_taxes() ) {
1533
+    if (wpinv_use_taxes()) {
1534 1534
         $default++;
1535 1535
     }
1536 1536
 
1537
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1537
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1538 1538
 }
1539 1539
 
1540 1540
 function wpinv_display_cart_messages() {
1541 1541
     global $wpi_session;
1542 1542
 
1543
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1543
+    $messages = $wpi_session->get('wpinv_cart_messages');
1544 1544
 
1545
-    if ( $messages ) {
1546
-        foreach ( $messages as $message_id => $message ) {
1545
+    if ($messages) {
1546
+        foreach ($messages as $message_id => $message) {
1547 1547
             // Try and detect what type of message this is
1548
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1548
+            if (strpos(strtolower($message), 'error')) {
1549 1549
                 $type = 'error';
1550
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1550
+            } elseif (strpos(strtolower($message), 'success')) {
1551 1551
                 $type = 'success';
1552 1552
             } else {
1553 1553
                 $type = 'info';
1554 1554
             }
1555 1555
 
1556
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1556
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1557 1557
 
1558
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1558
+            echo '<div class="' . implode(' ', $classes) . '">';
1559 1559
                 // Loop message codes and display messages
1560 1560
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1561 1561
             echo '</div>';
1562 1562
         }
1563 1563
 
1564 1564
         // Remove all of the cart saving messages
1565
-        $wpi_session->set( 'wpinv_cart_messages', null );
1565
+        $wpi_session->set('wpinv_cart_messages', null);
1566 1566
     }
1567 1567
 }
1568
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1568
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1569 1569
 
1570 1570
 function wpinv_discount_field() {
1571
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1571
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1572 1572
         return; // Only show before a payment method has been selected if ajax is disabled
1573 1573
     }
1574 1574
 
1575
-    if ( !wpinv_is_checkout() ) {
1575
+    if (!wpinv_is_checkout()) {
1576 1576
         return;
1577 1577
     }
1578 1578
 
1579
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1579
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1580 1580
     ?>
1581 1581
     <div id="wpinv-discount-field" class="panel panel-default">
1582 1582
         <div class="panel-body">
1583 1583
             <p>
1584
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1585
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1584
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1585
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1586 1586
             </p>
1587 1587
             <div class="form-group row">
1588 1588
                 <div class="col-sm-4">
1589
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1589
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1590 1590
                 </div>
1591 1591
                 <div class="col-sm-3">
1592
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1592
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1593 1593
                 </div>
1594 1594
                 <div style="clear:both"></div>
1595 1595
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1602,10 +1602,10 @@  discard block
 block discarded – undo
1602 1602
 <?php
1603 1603
     }
1604 1604
 }
1605
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1605
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1606 1606
 
1607 1607
 function wpinv_agree_to_terms_js() {
1608
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1608
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1609 1609
 ?>
1610 1610
 <script type="text/javascript">
1611 1611
     jQuery(document).ready(function($){
@@ -1620,125 +1620,125 @@  discard block
 block discarded – undo
1620 1620
 <?php
1621 1621
     }
1622 1622
 }
1623
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1623
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1624 1624
 
1625 1625
 function wpinv_payment_mode_select() {
1626
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1627
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1628
-    $invoice = wpinv_get_invoice( 0, true );
1626
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1627
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1628
+    $invoice = wpinv_get_invoice(0, true);
1629 1629
 
1630 1630
     do_action('wpinv_payment_mode_top');
1631
-    $invoice_id = (int)$invoice->ID;
1632
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1631
+    $invoice_id = (int) $invoice->ID;
1632
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1633 1633
     ?>
1634
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>>
1635
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1634
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>>
1635
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1636 1636
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1637
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div>
1637
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div>
1638 1638
                 <div class="panel-body list-group wpi-payment_methods">
1639 1639
                     <?php
1640
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1641
-
1642
-                    if ( !empty( $gateways ) ) {
1643
-                        foreach ( $gateways as $gateway_id => $gateway ) {
1644
-                            $checked       = checked( $gateway_id, $chosen_gateway, false );
1645
-                            $button_label  = wpinv_get_gateway_button_label( $gateway_id );
1646
-                            $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id );
1647
-                            $description   = wpinv_get_gateway_description( $gateway_id );
1640
+                    do_action('wpinv_payment_mode_before_gateways');
1641
+
1642
+                    if (!empty($gateways)) {
1643
+                        foreach ($gateways as $gateway_id => $gateway) {
1644
+                            $checked       = checked($gateway_id, $chosen_gateway, false);
1645
+                            $button_label  = wpinv_get_gateway_button_label($gateway_id);
1646
+                            $gateway_label = wpinv_get_gateway_checkout_label($gateway_id);
1647
+                            $description   = wpinv_get_gateway_description($gateway_id);
1648 1648
                             ?>
1649 1649
                             <div class="list-group-item">
1650 1650
                                 <div class="radio">
1651
-                                    <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label>
1651
+                                    <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label>
1652 1652
                                 </div>
1653
-                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1654
-                                    <?php if ( !empty( $description ) ) { ?>
1655
-                                        <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div>
1653
+                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1654
+                                    <?php if (!empty($description)) { ?>
1655
+                                        <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div>
1656 1656
                                     <?php } ?>
1657
-                                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1657
+                                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1658 1658
                                 </div>
1659 1659
                             </div>
1660 1660
                             <?php
1661 1661
                         }
1662 1662
                     } else {
1663
-                        echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>';
1663
+                        echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>';
1664 1664
                     }
1665 1665
 
1666
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1666
+                    do_action('wpinv_payment_mode_after_gateways');
1667 1667
                     ?>
1668 1668
                 </div>
1669 1669
             </div>
1670
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1670
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1671 1671
     </div>
1672 1672
     <?php
1673 1673
     do_action('wpinv_payment_mode_bottom');
1674 1674
 }
1675
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1675
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1676 1676
 
1677 1677
 function wpinv_checkout_billing_info() {
1678
-    if ( wpinv_is_checkout() ) {
1678
+    if (wpinv_is_checkout()) {
1679 1679
         $billing_details    = wpinv_checkout_billing_details();
1680
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1680
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1681 1681
         ?>
1682 1682
         <div id="wpinv-fields" class="clearfix">
1683 1683
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1684
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1684
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1685 1685
                 <div id="wpinv-fields-box" class="panel-body">
1686
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1686
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1687 1687
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1688
-                        <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1688
+                        <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1689 1689
                         <?php
1690
-                        echo wpinv_html_text( array(
1690
+                        echo wpinv_html_text(array(
1691 1691
                                 'id'            => 'wpinv_first_name',
1692 1692
                                 'name'          => 'wpinv_first_name',
1693 1693
                                 'value'         => $billing_details['first_name'],
1694 1694
                                 'class'         => 'wpi-input form-control',
1695
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1696
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1697
-                            ) );
1695
+                                'placeholder'   => __('First name', 'invoicing'),
1696
+                                'required'      => (bool) wpinv_get_option('fname_mandatory'),
1697
+                            ));
1698 1698
                         ?>
1699 1699
                     </p>
1700 1700
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1701
-                        <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1701
+                        <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1702 1702
                         <?php
1703
-                        echo wpinv_html_text( array(
1703
+                        echo wpinv_html_text(array(
1704 1704
                                 'id'            => 'wpinv_last_name',
1705 1705
                                 'name'          => 'wpinv_last_name',
1706 1706
                                 'value'         => $billing_details['last_name'],
1707 1707
                                 'class'         => 'wpi-input form-control',
1708
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1709
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1710
-                            ) );
1708
+                                'placeholder'   => __('Last name', 'invoicing'),
1709
+                                'required'      => (bool) wpinv_get_option('lname_mandatory'),
1710
+                            ));
1711 1711
                         ?>
1712 1712
                     </p>
1713 1713
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1714
-                        <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1714
+                        <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1715 1715
                         <?php
1716
-                        echo wpinv_html_text( array(
1716
+                        echo wpinv_html_text(array(
1717 1717
                                 'id'            => 'wpinv_address',
1718 1718
                                 'name'          => 'wpinv_address',
1719 1719
                                 'value'         => $billing_details['address'],
1720 1720
                                 'class'         => 'wpi-input form-control',
1721
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1722
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1723
-                            ) );
1721
+                                'placeholder'   => __('Address', 'invoicing'),
1722
+                                'required'      => (bool) wpinv_get_option('address_mandatory'),
1723
+                            ));
1724 1724
                         ?>
1725 1725
                     </p>
1726 1726
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1727
-                        <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1727
+                        <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1728 1728
                         <?php
1729
-                        echo wpinv_html_text( array(
1729
+                        echo wpinv_html_text(array(
1730 1730
                                 'id'            => 'wpinv_city',
1731 1731
                                 'name'          => 'wpinv_city',
1732 1732
                                 'value'         => $billing_details['city'],
1733 1733
                                 'class'         => 'wpi-input form-control',
1734
-                                'placeholder'   => __( 'City', 'invoicing' ),
1735
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1736
-                            ) );
1734
+                                'placeholder'   => __('City', 'invoicing'),
1735
+                                'required'      => (bool) wpinv_get_option('city_mandatory'),
1736
+                            ));
1737 1737
                         ?>
1738 1738
                     </p>
1739 1739
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1740
-                        <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1741
-                        <?php echo wpinv_html_select( array(
1740
+                        <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1741
+                        <?php echo wpinv_html_select(array(
1742 1742
                             'options'          => wpinv_get_country_list(),
1743 1743
                             'name'             => 'wpinv_country',
1744 1744
                             'id'               => 'wpinv_country',
@@ -1746,16 +1746,16 @@  discard block
 block discarded – undo
1746 1746
                             'show_option_all'  => false,
1747 1747
                             'show_option_none' => false,
1748 1748
                             'class'            => 'wpi-input form-control wpi_select2',
1749
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1750
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1751
-                        ) ); ?>
1749
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1750
+                            'required'         => (bool) wpinv_get_option('country_mandatory'),
1751
+                        )); ?>
1752 1752
                     </p>
1753 1753
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1754
-                        <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1754
+                        <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1755 1755
                         <?php
1756
-                        $states = wpinv_get_country_states( $selected_country );
1757
-                        if( !empty( $states ) ) {
1758
-                            echo wpinv_html_select( array(
1756
+                        $states = wpinv_get_country_states($selected_country);
1757
+                        if (!empty($states)) {
1758
+                            echo wpinv_html_select(array(
1759 1759
                                 'options'          => $states,
1760 1760
                                 'name'             => 'wpinv_state',
1761 1761
                                 'id'               => 'wpinv_state',
@@ -1763,61 +1763,61 @@  discard block
 block discarded – undo
1763 1763
                                 'show_option_all'  => false,
1764 1764
                                 'show_option_none' => false,
1765 1765
                                 'class'            => 'wpi-input form-control wpi_select2',
1766
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1767
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1768
-                            ) );
1766
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1767
+                                'required'         => (bool) wpinv_get_option('state_mandatory'),
1768
+                            ));
1769 1769
                         } else {
1770
-                            echo wpinv_html_text( array(
1770
+                            echo wpinv_html_text(array(
1771 1771
                                 'name'          => 'wpinv_state',
1772 1772
                                 'value'         => $billing_details['state'],
1773 1773
                                 'id'            => 'wpinv_state',
1774 1774
                                 'class'         => 'wpi-input form-control',
1775
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1776
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1777
-                            ) );
1775
+                                'placeholder'   => __('State / Province', 'invoicing'),
1776
+                                'required'      => (bool) wpinv_get_option('state_mandatory'),
1777
+                            ));
1778 1778
                         }
1779 1779
                         ?>
1780 1780
                     </p>
1781 1781
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1782
-                        <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1782
+                        <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1783 1783
                         <?php
1784
-                        echo wpinv_html_text( array(
1784
+                        echo wpinv_html_text(array(
1785 1785
                                 'name'          => 'wpinv_zip',
1786 1786
                                 'value'         => $billing_details['zip'],
1787 1787
                                 'id'            => 'wpinv_zip',
1788 1788
                                 'class'         => 'wpi-input form-control',
1789
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1790
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1791
-                            ) );
1789
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1790
+                                'required'      => (bool) wpinv_get_option('zip_mandatory'),
1791
+                            ));
1792 1792
                         ?>
1793 1793
                     </p>
1794 1794
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1795
-                        <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1795
+                        <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1796 1796
                         <?php
1797
-                        echo wpinv_html_text( array(
1797
+                        echo wpinv_html_text(array(
1798 1798
                                 'id'            => 'wpinv_phone',
1799 1799
                                 'name'          => 'wpinv_phone',
1800 1800
                                 'value'         => $billing_details['phone'],
1801 1801
                                 'class'         => 'wpi-input form-control',
1802
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1803
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1804
-                            ) );
1802
+                                'placeholder'   => __('Phone', 'invoicing'),
1803
+                                'required'      => (bool) wpinv_get_option('phone_mandatory'),
1804
+                            ));
1805 1805
                         ?>
1806 1806
                     </p>
1807
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1807
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1808 1808
                     <div class="clearfix"></div>
1809 1809
                 </div>
1810 1810
             </div>
1811
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1811
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1812 1812
         </div>
1813 1813
         <?php
1814 1814
     }
1815 1815
 }
1816
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1816
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1817 1817
 
1818 1818
 function wpinv_checkout_hidden_fields() {
1819 1819
 ?>
1820
-    <?php if ( is_user_logged_in() ) { ?>
1820
+    <?php if (is_user_logged_in()) { ?>
1821 1821
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1822 1822
     <?php } ?>
1823 1823
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1827,9 +1827,9 @@  discard block
 block discarded – undo
1827 1827
 function wpinv_checkout_button_purchase() {
1828 1828
     ob_start();
1829 1829
 ?>
1830
-    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/>
1830
+    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/>
1831 1831
 <?php
1832
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1832
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1833 1833
 }
1834 1834
 
1835 1835
 function wpinv_checkout_total() {
@@ -1838,84 +1838,84 @@  discard block
 block discarded – undo
1838 1838
 <div id="wpinv_checkout_total" class="panel panel-info">
1839 1839
     <div class="panel-body">
1840 1840
     <?php
1841
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1841
+    do_action('wpinv_purchase_form_before_checkout_total');
1842 1842
     ?>
1843
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1843
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1844 1844
     <?php
1845
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1845
+    do_action('wpinv_purchase_form_after_checkout_total');
1846 1846
     ?>
1847 1847
     </div>
1848 1848
 </div>
1849 1849
 <?php
1850 1850
 }
1851
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1851
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1852 1852
 
1853 1853
 function wpinv_checkout_accept_tandc() {
1854
-    $page = wpinv_get_option( 'tandc_page' );
1854
+    $page = wpinv_get_option('tandc_page');
1855 1855
     ?>
1856 1856
     <div id="wpinv_checkout_tandc" class="panel panel-success">
1857 1857
         <div class="panel-body">
1858 1858
             <?php echo wpinv_get_policy_text(); ?>
1859 1859
             <?php
1860
-            if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){
1861
-                $terms_link = esc_url( get_permalink( $page ) );
1860
+            if (isset($page) && (int) $page > 0 && apply_filters('wpinv_checkout_show_terms', true)) {
1861
+                $terms_link = esc_url(get_permalink($page));
1862 1862
                 ?>
1863 1863
                 <label class="">
1864
-                    <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I&rsquo;ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms &amp; conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span>
1864
+                    <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I&rsquo;ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms &amp; conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span>
1865 1865
                 </label>
1866 1866
             <?php } ?>
1867 1867
         </div>
1868 1868
     </div>
1869 1869
     <?php
1870 1870
 }
1871
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 );
1871
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995);
1872 1872
 
1873 1873
 function wpinv_checkout_submit() {
1874 1874
 ?>
1875 1875
 <div id="wpinv_purchase_submit" class="panel panel-success">
1876 1876
     <div class="panel-body text-center">
1877 1877
     <?php
1878
-    do_action( 'wpinv_purchase_form_before_submit' );
1878
+    do_action('wpinv_purchase_form_before_submit');
1879 1879
     wpinv_checkout_hidden_fields();
1880 1880
     echo wpinv_checkout_button_purchase();
1881
-    do_action( 'wpinv_purchase_form_after_submit' );
1881
+    do_action('wpinv_purchase_form_after_submit');
1882 1882
     ?>
1883 1883
     </div>
1884 1884
 </div>
1885 1885
 <?php
1886 1886
 }
1887
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1887
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1888 1888
 
1889
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1890
-    $invoice = wpinv_get_invoice( $invoice_id );
1889
+function wpinv_receipt_billing_address($invoice_id = 0) {
1890
+    $invoice = wpinv_get_invoice($invoice_id);
1891 1891
 
1892
-    if ( empty( $invoice ) ) {
1892
+    if (empty($invoice)) {
1893 1893
         return NULL;
1894 1894
     }
1895 1895
 
1896 1896
     $billing_details = $invoice->get_user_info();
1897
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1897
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1898 1898
 
1899 1899
     ob_start();
1900 1900
     ?>
1901 1901
     <table class="table table-bordered table-sm wpi-billing-details">
1902 1902
         <tbody>
1903 1903
             <tr class="wpi-receipt-name">
1904
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1905
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1904
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1905
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1906 1906
             </tr>
1907 1907
             <tr class="wpi-receipt-email">
1908
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1909
-                <td><?php echo $billing_details['email'] ;?></td>
1908
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1909
+                <td><?php echo $billing_details['email']; ?></td>
1910 1910
             </tr>
1911 1911
             <tr class="wpi-receipt-address">
1912
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1913
-                <td><?php echo $address_row ;?></td>
1912
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1913
+                <td><?php echo $address_row; ?></td>
1914 1914
             </tr>
1915
-            <?php if ( $billing_details['phone'] ) { ?>
1915
+            <?php if ($billing_details['phone']) { ?>
1916 1916
             <tr class="wpi-receipt-phone">
1917
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1918
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1917
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1918
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1919 1919
             </tr>
1920 1920
             <?php } ?>
1921 1921
         </tbody>
@@ -1923,74 +1923,74 @@  discard block
 block discarded – undo
1923 1923
     <?php
1924 1924
     $output = ob_get_clean();
1925 1925
     
1926
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1926
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1927 1927
 
1928 1928
     echo $output;
1929 1929
 }
1930 1930
 
1931
-function wpinv_filter_success_page_content( $content ) {
1932
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1933
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1934
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1931
+function wpinv_filter_success_page_content($content) {
1932
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1933
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1934
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1935 1935
         }
1936 1936
     }
1937 1937
 
1938 1938
     return $content;
1939 1939
 }
1940
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1940
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1941 1941
 
1942
-function wpinv_receipt_actions( $invoice ) {
1943
-    if ( !empty( $invoice ) ) {
1942
+function wpinv_receipt_actions($invoice) {
1943
+    if (!empty($invoice)) {
1944 1944
         $actions = array();
1945 1945
 
1946
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1947
-            $actions['print']   = array(
1948
-                'url'  => $invoice->get_view_url( true ),
1949
-                'name' => __( 'Print Invoice', 'invoicing' ),
1946
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1947
+            $actions['print'] = array(
1948
+                'url'  => $invoice->get_view_url(true),
1949
+                'name' => __('Print Invoice', 'invoicing'),
1950 1950
                 'class' => 'btn-primary',
1951 1951
             );
1952 1952
         }
1953 1953
 
1954
-        if ( is_user_logged_in() ) {
1954
+        if (is_user_logged_in()) {
1955 1955
             $actions['history'] = array(
1956 1956
                 'url'  => wpinv_get_history_page_uri(),
1957
-                'name' => __( 'Invoice History', 'invoicing' ),
1957
+                'name' => __('Invoice History', 'invoicing'),
1958 1958
                 'class' => 'btn-warning',
1959 1959
             );
1960 1960
         }
1961 1961
 
1962
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1962
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1963 1963
 
1964
-        if ( !empty( $actions ) ) {
1964
+        if (!empty($actions)) {
1965 1965
         ?>
1966 1966
         <div class="wpinv-receipt-actions text-right">
1967
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1968
-            <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a>
1967
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1968
+            <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a>
1969 1969
             <?php } ?>
1970 1970
         </div>
1971 1971
         <?php
1972 1972
         }
1973 1973
     }
1974 1974
 }
1975
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1975
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1976 1976
 
1977
-function wpinv_invoice_link( $invoice_id ) {
1978
-    $invoice = wpinv_get_invoice( $invoice_id );
1977
+function wpinv_invoice_link($invoice_id) {
1978
+    $invoice = wpinv_get_invoice($invoice_id);
1979 1979
 
1980
-    if ( empty( $invoice ) ) {
1980
+    if (empty($invoice)) {
1981 1981
         return NULL;
1982 1982
     }
1983 1983
 
1984
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1984
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1985 1985
 
1986
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1986
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1987 1987
 }
1988 1988
 
1989
-function wpinv_invoice_subscription_details( $invoice ) {
1990
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1991
-        $subscription = wpinv_get_subscription( $invoice, true );
1989
+function wpinv_invoice_subscription_details($invoice) {
1990
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1991
+        $subscription = wpinv_get_subscription($invoice, true);
1992 1992
 
1993
-        if ( empty( $subscription ) ) {
1993
+        if (empty($subscription)) {
1994 1994
             return;
1995 1995
         }
1996 1996
 
@@ -2001,15 +2001,15 @@  discard block
 block discarded – undo
2001 2001
         $payments = $subscription->get_child_payments();
2002 2002
         ?>
2003 2003
         <div class="wpinv-subscriptions-details">
2004
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
2004
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
2005 2005
             <table class="table">
2006 2006
                 <thead>
2007 2007
                     <tr>
2008
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
2009
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
2010
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
2011
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
2012
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
2008
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
2009
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
2010
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
2011
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
2012
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
2013 2013
                     </tr>
2014 2014
                 </thead>
2015 2015
                 <tbody>
@@ -2023,29 +2023,29 @@  discard block
 block discarded – undo
2023 2023
                 </tbody>
2024 2024
             </table>
2025 2025
         </div>
2026
-        <?php if ( !empty( $payments ) ) { ?>
2026
+        <?php if (!empty($payments)) { ?>
2027 2027
         <div class="wpinv-renewal-payments">
2028
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
2028
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
2029 2029
             <table class="table">
2030 2030
                 <thead>
2031 2031
                     <tr>
2032 2032
                         <th>#</th>
2033
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
2034
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
2035
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
2033
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
2034
+                        <th><?php _e('Date', 'invoicing'); ?></th>
2035
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
2036 2036
                     </tr>
2037 2037
                 </thead>
2038 2038
                 <tbody>
2039 2039
                     <?php
2040 2040
                         $i = 1;
2041
-                        foreach ( $payments as $payment ) {
2041
+                        foreach ($payments as $payment) {
2042 2042
                             $invoice_id = $payment->ID;
2043 2043
                     ?>
2044 2044
                     <tr>
2045
-                        <th scope="row"><?php echo $i;?></th>
2046
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
2047
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
2048
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
2045
+                        <th scope="row"><?php echo $i; ?></th>
2046
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
2047
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
2048
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
2049 2049
                     </tr>
2050 2050
                     <?php $i++; } ?>
2051 2051
                 </tbody>
@@ -2056,52 +2056,52 @@  discard block
 block discarded – undo
2056 2056
     }
2057 2057
 }
2058 2058
 
2059
-function wpinv_cart_total_label( $label, $invoice ) {
2060
-    if ( empty( $invoice ) ) {
2059
+function wpinv_cart_total_label($label, $invoice) {
2060
+    if (empty($invoice)) {
2061 2061
         return $label;
2062 2062
     }
2063 2063
 
2064 2064
     $prefix_label = '';
2065
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
2066
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2067
-    } else if ( $invoice->is_renewal() ) {
2068
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
2065
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
2066
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2067
+    } else if ($invoice->is_renewal()) {
2068
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2069 2069
     }
2070 2070
 
2071
-    if ( $prefix_label != '' ) {
2072
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2071
+    if ($prefix_label != '') {
2072
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2073 2073
     }
2074 2074
 
2075 2075
     return $label;
2076 2076
 }
2077
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2078
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2079
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2077
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2078
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2079
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2080 2080
 
2081
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2081
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2082 2082
 
2083
-function wpinv_invoice_print_description( $invoice ) {
2084
-    if ( empty( $invoice ) ) {
2083
+function wpinv_invoice_print_description($invoice) {
2084
+    if (empty($invoice)) {
2085 2085
         return NULL;
2086 2086
     }
2087
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2087
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2088 2088
         ?>
2089 2089
         <div class="row wpinv-lower">
2090 2090
             <div class="col-sm-12 wpinv-description">
2091
-                <?php echo wpautop( $description ); ?>
2091
+                <?php echo wpautop($description); ?>
2092 2092
             </div>
2093 2093
         </div>
2094 2094
         <?php
2095 2095
     }
2096 2096
 }
2097
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2097
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2098 2098
 
2099
-function wpinv_invoice_print_payment_info( $invoice ) {
2100
-    if ( empty( $invoice ) ) {
2099
+function wpinv_invoice_print_payment_info($invoice) {
2100
+    if (empty($invoice)) {
2101 2101
         return NULL;
2102 2102
     }
2103 2103
 
2104
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2104
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2105 2105
         ?>
2106 2106
         <div class="row wpinv-payments">
2107 2107
             <div class="col-sm-12">
@@ -2113,43 +2113,43 @@  discard block
 block discarded – undo
2113 2113
 }
2114 2114
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2115 2115
 
2116
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2117
-    if ( empty( $note ) ) {
2116
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2117
+    if (empty($note)) {
2118 2118
         return NULL;
2119 2119
     }
2120 2120
 
2121
-    if ( is_int( $note ) ) {
2122
-        $note = get_comment( $note );
2121
+    if (is_int($note)) {
2122
+        $note = get_comment($note);
2123 2123
     }
2124 2124
 
2125
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2125
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2126 2126
         return NULL;
2127 2127
     }
2128 2128
 
2129
-    $note_classes   = array( 'note' );
2130
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2129
+    $note_classes   = array('note');
2130
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2131 2131
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
2132
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2133
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2132
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2133
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2134 2134
 
2135 2135
     ob_start();
2136 2136
     ?>
2137
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2137
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2138 2138
         <div class="note_content">
2139
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2139
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2140 2140
         </div>
2141 2141
         <p class="meta">
2142
-            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
2143
-            <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?>
2144
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2142
+            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
2143
+            <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?>
2144
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2145 2145
             <?php } ?>
2146 2146
         </p>
2147 2147
     </li>
2148 2148
     <?php
2149 2149
     $note_content = ob_get_clean();
2150
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2150
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2151 2151
 
2152
-    if ( $echo ) {
2152
+    if ($echo) {
2153 2153
         echo $note_content;
2154 2154
     } else {
2155 2155
         return $note_content;
@@ -2159,43 +2159,43 @@  discard block
 block discarded – undo
2159 2159
 function wpinv_invalid_invoice_content() {
2160 2160
     global $post;
2161 2161
 
2162
-    $invoice = wpinv_get_invoice( $post->ID );
2162
+    $invoice = wpinv_get_invoice($post->ID);
2163 2163
 
2164
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
2165
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2166
-        if ( is_user_logged_in() ) {
2167
-            if ( wpinv_require_login_to_checkout() ) {
2168
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2169
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2164
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
2165
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2166
+        if (is_user_logged_in()) {
2167
+            if (wpinv_require_login_to_checkout()) {
2168
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2169
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2170 2170
                 }
2171 2171
             }
2172 2172
         } else {
2173
-            if ( wpinv_require_login_to_checkout() ) {
2174
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2175
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2173
+            if (wpinv_require_login_to_checkout()) {
2174
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2175
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2176 2176
                 }
2177 2177
             }
2178 2178
         }
2179 2179
     } else {
2180
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2180
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2181 2181
     }
2182 2182
     ?>
2183 2183
     <div class="row wpinv-row-invalid">
2184 2184
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2185
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2185
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2186 2186
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2187 2187
         </div>
2188 2188
     </div>
2189 2189
     <?php
2190 2190
 }
2191
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2191
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2192 2192
 
2193
-add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2194
-function wpinv_force_company_name_field(){
2193
+add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2194
+function wpinv_force_company_name_field() {
2195 2195
     $invoice = wpinv_get_invoice_cart();
2196
-    $user_id = wpinv_get_user_id( $invoice->ID );
2197
-    $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
2198
-    if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) {
2196
+    $user_id = wpinv_get_user_id($invoice->ID);
2197
+    $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
2198
+    if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) {
2199 2199
         ?>
2200 2200
         <p class="wpi-cart-field wpi-col2 wpi-colf">
2201 2201
             <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
@@ -2220,21 +2220,21 @@  discard block
 block discarded – undo
2220 2220
  * @return string
2221 2221
  */
2222 2222
 function wpinv_get_policy_text() {
2223
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
2223
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
2224 2224
 
2225
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
2225
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
2226 2226
 
2227
-    if(!$privacy_page_id){
2228
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
2227
+    if (!$privacy_page_id) {
2228
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
2229 2229
     }
2230 2230
 
2231
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
2231
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
2232 2232
 
2233 2233
     $find_replace = array(
2234 2234
         '[wpinv_privacy_policy]' => $privacy_link,
2235 2235
     );
2236 2236
 
2237
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
2237
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
2238 2238
 
2239 2239
     return wp_kses_post(wpautop($privacy_text));
2240 2240
 }
@@ -2243,25 +2243,25 @@  discard block
 block discarded – undo
2243 2243
 /**
2244 2244
  * Allows the user to set their own price for an invoice item
2245 2245
  */
2246
-function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) {
2246
+function wpinv_checkout_cart_item_name_your_price($cart_item, $key) {
2247 2247
     
2248 2248
     //Ensure we have an item id
2249
-    if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) {
2249
+    if (!is_array($cart_item) || empty($cart_item['id'])) {
2250 2250
         return;
2251 2251
     }
2252 2252
 
2253 2253
     //Fetch the item
2254 2254
     $item_id = $cart_item['id'];
2255
-    $item    = new WPInv_Item( $item_id );
2255
+    $item    = new WPInv_Item($item_id);
2256 2256
     
2257
-    if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) {
2257
+    if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) {
2258 2258
         return;
2259 2259
     }
2260 2260
 
2261 2261
     //Fetch the dynamic pricing "strings"
2262
-    $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) );
2263
-    $minimum_price_text   = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) );
2264
-    $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) );
2262
+    $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing')));
2263
+    $minimum_price_text   = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing')));
2264
+    $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing')));
2265 2265
 
2266 2266
     //Display a "name_your_price" button
2267 2267
     echo " &mdash; <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>";
@@ -2270,7 +2270,7 @@  discard block
 block discarded – undo
2270 2270
     echo '<div class="name-your-price-miniform">';
2271 2271
     
2272 2272
     //Maybe display the recommended price
2273
-    if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) {
2273
+    if ($item->get_price() > 0 && !empty($suggested_price_text)) {
2274 2274
         $suggested_price = $item->get_the_price();
2275 2275
         echo "<div>$suggested_price_text &mdash; $suggested_price</div>";
2276 2276
     }
@@ -2278,50 +2278,50 @@  discard block
 block discarded – undo
2278 2278
     //Display the update price form
2279 2279
     $symbol         = wpinv_currency_symbol();
2280 2280
     $position       = wpinv_currency_position();
2281
-    $minimum        = esc_attr( $item->get_minimum_price() );
2282
-    $price          = esc_attr( $cart_item['item_price'] );
2283
-    $update         = esc_attr__( "Update", 'invoicing' );
2281
+    $minimum        = esc_attr($item->get_minimum_price());
2282
+    $price          = esc_attr($cart_item['item_price']);
2283
+    $update         = esc_attr__("Update", 'invoicing');
2284 2284
 
2285 2285
     //Ensure it supports dynamic prici
2286
-    if( $price < $minimum ) {
2286
+    if ($price < $minimum) {
2287 2287
         $price = $minimum;
2288 2288
     }
2289 2289
 
2290 2290
     echo '<label>';
2291 2291
     echo $position != 'right' ? $symbol . '&nbsp;' : '';
2292 2292
     echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />";
2293
-    echo $position == 'right' ? '&nbsp;' . $symbol : '' ;
2293
+    echo $position == 'right' ? '&nbsp;' . $symbol : '';
2294 2294
     echo "</label>";
2295 2295
     echo "<input type='hidden' value='$item_id' class='wpi-field-item' />";
2296 2296
     echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>";
2297 2297
 
2298 2298
     //Maybe display the minimum price
2299
-    if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) {
2300
-        $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) );
2299
+    if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) {
2300
+        $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price()));
2301 2301
         echo "<div>$minimum_price_text &mdash; $minimum_price</div>";
2302 2302
     }
2303 2303
 
2304 2304
     echo "</div>";
2305 2305
 
2306 2306
 }
2307
-add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 );
2307
+add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2);
2308 2308
 
2309 2309
 function wpinv_oxygen_fix_conflict() {
2310 2310
     global $ct_ignore_post_types;
2311 2311
 
2312
-    if ( ! is_array( $ct_ignore_post_types ) ) {
2312
+    if (!is_array($ct_ignore_post_types)) {
2313 2313
         $ct_ignore_post_types = array();
2314 2314
     }
2315 2315
 
2316
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
2316
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
2317 2317
 
2318
-    foreach ( $post_types as $post_type ) {
2318
+    foreach ($post_types as $post_type) {
2319 2319
         $ct_ignore_post_types[] = $post_type;
2320 2320
 
2321 2321
         // Ignore post type
2322
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
2322
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
2323 2323
     }
2324 2324
 
2325
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
2326
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
2325
+    remove_filter('template_include', 'wpinv_template', 10, 1);
2326
+    add_filter('template_include', 'wpinv_template', 999, 1);
2327 2327
 }
2328 2328
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/composer/autoload_static.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,33 +6,33 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5
8 8
 {
9
-    public static $files = array (
9
+    public static $files = array(
10 10
         'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php',
11 11
         '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php',
12 12
     );
13 13
 
14
-    public static $prefixLengthsPsr4 = array (
14
+    public static $prefixLengthsPsr4 = array(
15 15
         'C' => 
16
-        array (
16
+        array(
17 17
             'Composer\\Installers\\' => 20,
18 18
         ),
19 19
     );
20 20
 
21
-    public static $prefixDirsPsr4 = array (
21
+    public static $prefixDirsPsr4 = array(
22 22
         'Composer\\Installers\\' => 
23
-        array (
23
+        array(
24 24
             0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
25 25
         ),
26 26
     );
27 27
 
28
-    public static $classMap = array (
28
+    public static $classMap = array(
29 29
         'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php',
30 30
         'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php',
31 31
     );
32 32
 
33 33
     public static function getInitializer(ClassLoader $loader)
34 34
     {
35
-        return \Closure::bind(function () use ($loader) {
35
+        return \Closure::bind(function() use ($loader) {
36 36
             $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4;
37 37
             $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4;
38 38
             $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap;
Please login to merge, or discard this patch.
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +43 added lines, -43 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,10 +13,10 @@  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
-            if ( method_exists( $this, "render_{$element}_template" ) ) {
19
-                add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 );
18
+            if (method_exists($this, "render_{$element}_template")) {
19
+                add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2);
20 20
             }
21 21
         }
22 22
         
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function get_elements() {
29 29
 
30
-        if ( ! empty( $this->elements ) ) {
30
+        if (!empty($this->elements)) {
31 31
             return $this->elements;
32 32
         }
33 33
 
@@ -35,73 +35,73 @@  discard block
 block discarded – undo
35 35
 
36 36
             array(
37 37
                 'type' => 'heading',
38
-                'name' => __( 'Heading', 'invoicing' ),
38
+                'name' => __('Heading', 'invoicing'),
39 39
             ),
40 40
 
41 41
             array(
42 42
                 'type' => 'paragraph',
43
-                'name' => __( 'Paragraph', 'invoicing' ),
43
+                'name' => __('Paragraph', 'invoicing'),
44 44
             ),
45 45
 
46 46
             array(
47 47
                 'type' => 'text',
48
-                'name' => __( 'Text Input', 'invoicing' ),
48
+                'name' => __('Text Input', 'invoicing'),
49 49
             ),
50 50
 
51 51
             array(
52 52
                 'type' => 'textarea',
53
-                'name' => __( 'Textarea', 'invoicing' ),
53
+                'name' => __('Textarea', 'invoicing'),
54 54
             ),
55 55
 
56 56
             array(
57 57
                 'type' => 'select',
58
-                'name' => __( 'Dropdown', 'invoicing' ),
58
+                'name' => __('Dropdown', 'invoicing'),
59 59
             ),
60 60
 
61 61
             array(
62 62
                 'type' => 'checkbox',
63
-                'name' => __( 'Checkboxes', 'invoicing' ),
63
+                'name' => __('Checkboxes', 'invoicing'),
64 64
             ),
65 65
 
66 66
             array( 
67 67
                 'type' => 'radio',
68
-                'name' => __( 'Multiple Choice', 'invoicing' ),
68
+                'name' => __('Multiple Choice', 'invoicing'),
69 69
             ),
70 70
 
71 71
             array( 
72 72
                 'type' => 'date',
73
-                'name' => __( 'Date', 'invoicing' ),
73
+                'name' => __('Date', 'invoicing'),
74 74
             ),
75 75
 
76 76
             array( 
77 77
                 'type' => 'time',
78
-                'name' => __( 'Time', 'invoicing' ),
78
+                'name' => __('Time', 'invoicing'),
79 79
             ),
80 80
 
81 81
             array( 
82 82
                 'type' => 'number',
83
-                'name' => __( 'Number', 'invoicing' ),
83
+                'name' => __('Number', 'invoicing'),
84 84
             ),
85 85
 
86 86
             array( 
87 87
                 'type' => 'website',
88
-                'name' => __( 'Website', 'invoicing' ),
88
+                'name' => __('Website', 'invoicing'),
89 89
             ),
90 90
 
91 91
             array( 
92 92
                 'type' => 'email',
93
-                'name' => __( 'Email', 'invoicing' ),
93
+                'name' => __('Email', 'invoicing'),
94 94
             ),
95 95
         );
96 96
 
97
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
97
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
98 98
         return $this->elements;
99 99
     }
100 100
 
101 101
     /**
102 102
      * Returns the restrict markup.
103 103
      */
104
-    public function get_restrict_markup( $field, $field_type ) {
104
+    public function get_restrict_markup($field, $field_type) {
105 105
         $restrict = "$field.type=='$field_type'";
106 106
         return "v-if=\"$restrict\"";
107 107
     }
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
     /**
110 110
      * Renders the title element template.
111 111
      */
112
-    public function render_heading_template( $field ) {
113
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
112
+    public function render_heading_template($field) {
113
+        $restrict = $this->get_restrict_markup($field, 'heading');
114 114
         $label    = "$field.name";
115 115
         echo "<h1 $restrict v-html='$label'></h1>";
116 116
     }
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
     /**
119 119
      * Renders a paragraph element template.
120 120
      */
121
-    public function render_paragraph_template( $field ) {
122
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
121
+    public function render_paragraph_template($field) {
122
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
123 123
         $label    = "$field.name";
124 124
         echo "<p $restrict v-html='$label'></p>";
125 125
     }
@@ -127,8 +127,8 @@  discard block
 block discarded – undo
127 127
     /**
128 128
      * Renders the text element template.
129 129
      */
130
-    public function render_text_template( $field ) {
131
-        $restrict = $this->get_restrict_markup( $field, 'text' );
130
+    public function render_text_template($field) {
131
+        $restrict = $this->get_restrict_markup($field, 'text');
132 132
         $label    = "$field.name";
133 133
         echo "<div $restrict><label $restrict>{{" . $label . "}}</label>";
134 134
         echo "<input class='form-control' type='text'></div>";
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
     /**
138 138
      * Renders the textarea element template.
139 139
      */
140
-    public function render_textarea_template( $field ) {
141
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
140
+    public function render_textarea_template($field) {
141
+        $restrict = $this->get_restrict_markup($field, 'textarea');
142 142
         $label    = "$field.name";
143 143
         echo "<div $restrict><label>{{" . $label . "}}</label>";
144 144
         echo "<textarea class='form-control' rows='3'></textarea></div>";
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
     /**
148 148
      * Renders the select element template.
149 149
      */
150
-    public function render_select_template( $field ) {
151
-        $restrict = $this->get_restrict_markup( $field, 'select' );
150
+    public function render_select_template($field) {
151
+        $restrict = $this->get_restrict_markup($field, 'select');
152 152
         $label    = "$field.name";
153 153
         echo "<div $restrict><label>{{" . $label . "}}</label>";
154 154
         echo "<select class='form-control custom-select'></select></div>";
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
     /**
158 158
      * Renders the checkbox element template.
159 159
      */
160
-    public function render_checkbox_template( $field ) {
161
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
160
+    public function render_checkbox_template($field) {
161
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
162 162
         $label    = "$field.name";
163 163
         echo "<div class='form-check' $restrict>";
164 164
         echo "<input class='form-check-input' type='checkbox' />";
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
     /**
170 170
      * Renders radio select fields.
171 171
      */
172
-    public function render_radio_template( $field ) {
173
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
172
+    public function render_radio_template($field) {
173
+        $restrict = $this->get_restrict_markup($field, 'radio');
174 174
         $label    = "$field.name";
175 175
         echo "<div class='form-check' $restrict>";
176 176
         echo "<input class='form-check-input' type='radio' />";
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
     /**
182 182
      * Renders the email element template.
183 183
      */
184
-    public function render_email_template( $field ) {
185
-        $restrict = $this->get_restrict_markup( $field, 'email' );
184
+    public function render_email_template($field) {
185
+        $restrict = $this->get_restrict_markup($field, 'email');
186 186
         $label    = "$field.name";
187 187
         echo "<div $restrict><label $restrict>{{" . $label . "}}</label>";
188 188
         echo "<input class='form-control' type='email'></div>";
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
     /**
192 192
      * Renders the website element template.
193 193
      */
194
-    public function render_website_template( $field ) {
195
-        $restrict = $this->get_restrict_markup( $field, 'website' );
194
+    public function render_website_template($field) {
195
+        $restrict = $this->get_restrict_markup($field, 'website');
196 196
         $label    = "$field.name";
197 197
         echo "<div $restrict><label $restrict>{{" . $label . "}}</label>";
198 198
         echo "<input class='form-control' type='url'></div>";
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
     /**
202 202
      * Renders the date element template.
203 203
      */
204
-    public function render_date_template( $field ) {
205
-        $restrict = $this->get_restrict_markup( $field, 'date' );
204
+    public function render_date_template($field) {
205
+        $restrict = $this->get_restrict_markup($field, 'date');
206 206
         $label    = "$field.name";
207 207
         echo "<div $restrict><label $restrict>{{" . $label . "}}</label>";
208 208
         echo "<input class='form-control' type='date'></div>";
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
     /**
212 212
      * Renders the time element template.
213 213
      */
214
-    public function render_time_template( $field ) {
215
-        $restrict = $this->get_restrict_markup( $field, 'time' );
214
+    public function render_time_template($field) {
215
+        $restrict = $this->get_restrict_markup($field, 'time');
216 216
         $label    = "$field.name";
217 217
         echo "<div $restrict><label $restrict>{{" . $label . "}}</label>";
218 218
         echo "<input class='form-control' type='time'></div>";
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
     /**
222 222
      * Renders the number element template.
223 223
      */
224
-    public function render_number_template( $field ) {
225
-        $restrict = $this->get_restrict_markup( $field, 'number' );
224
+    public function render_number_template($field) {
225
+        $restrict = $this->get_restrict_markup($field, 'number');
226 226
         $label    = "$field.name";
227 227
         echo "<div $restrict><label $restrict>{{" . $label . "}}</label>";
228 228
         echo "<input class='form-control' type='number'></div>";
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -1,70 +1,70 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
27
-    add_meta_box( 'wpinv-payment-form', __( 'Payment Options', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_form', 'wpi_payment_form', 'normal', 'high' );
28
-    add_meta_box( 'wpinv-payment-form-items', __( 'Items', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_form_items', 'wpi_payment_form', 'normal' );
29
-    add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'WPInv_Meta_Box_Form_Items::form_design', 'wpi_payment_form', 'normal' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27
+    add_meta_box('wpinv-payment-form', __('Payment Options', 'invoicing'), 'WPInv_Meta_Box_Details::payment_form', 'wpi_payment_form', 'normal', 'high');
28
+    add_meta_box('wpinv-payment-form-items', __('Items', 'invoicing'), 'WPInv_Meta_Box_Details::payment_form_items', 'wpi_payment_form', 'normal');
29
+    add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'WPInv_Meta_Box_Form_Items::form_design', 'wpi_payment_form', 'normal');
30 30
    
31
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
32
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
33
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
31
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
32
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
33
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
34 34
 
35 35
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
36 36
 }
37
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
37
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
38 38
 
39
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
40
-    remove_action( 'save_post', __FUNCTION__ );
39
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
40
+    remove_action('save_post', __FUNCTION__);
41 41
     
42 42
     // $post_id and $post are required
43
-    if ( empty( $post_id ) || empty( $post ) ) {
43
+    if (empty($post_id) || empty($post)) {
44 44
         return;
45 45
     }
46 46
         
47
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
47
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
48 48
         return;
49 49
     }
50 50
     
51 51
     // Dont' save meta boxes for revisions or autosaves
52
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
52
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
53 53
         return;
54 54
     }
55 55
         
56
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
57
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
56
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
57
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
58 58
             return;
59 59
         }
60 60
     
61
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
62
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
61
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
62
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
63 63
         }
64
-    } else if ( $post->post_type == 'wpi_item' ) {
64
+    } else if ($post->post_type == 'wpi_item') {
65 65
         // verify nonce
66
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
67
-            $fields                                 = array();
66
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
67
+            $fields = array();
68 68
             $fields['_wpinv_price']              = 'wpinv_item_price';
69 69
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
70 70
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -79,96 +79,96 @@  discard block
 block discarded – undo
79 79
             $fields['_wpinv_dynamic_pricing']    = 'wpinv_name_your_price';
80 80
             $fields['_minimum_price']            = 'wpinv_minimum_price';
81 81
             
82
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
82
+            if (!isset($_POST['wpinv_is_recurring'])) {
83 83
                 $_POST['wpinv_is_recurring'] = 0;
84 84
             }
85 85
 
86
-            if ( !isset( $_POST['wpinv_name_your_price'] ) ) {
86
+            if (!isset($_POST['wpinv_name_your_price'])) {
87 87
                 $_POST['wpinv_name_your_price'] = 0;
88 88
             }
89 89
             
90
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
90
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
91 91
                 $_POST['wpinv_free_trial'] = 0;
92 92
             }
93 93
             
94
-            foreach ( $fields as $field => $name ) {
95
-                if ( isset( $_POST[ $name ] ) ) {
96
-                    $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id );
94
+            foreach ($fields as $field => $name) {
95
+                if (isset($_POST[$name])) {
96
+                    $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id);
97 97
 
98
-                    if ( !$allowed ) {
98
+                    if (!$allowed) {
99 99
                         continue;
100 100
                     }
101 101
 
102
-                    if ( $field == '_wpinv_price' ) {
103
-                        $value = wpinv_sanitize_amount( $_POST[ $name ] );
102
+                    if ($field == '_wpinv_price') {
103
+                        $value = wpinv_sanitize_amount($_POST[$name]);
104 104
                     } else {
105
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
105
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
106 106
                     }
107 107
                     
108
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
109
-                    update_post_meta( $post_id, $field, $value );
108
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
109
+                    update_post_meta($post_id, $field, $value);
110 110
                 }
111 111
             }
112 112
             
113
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
114
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
113
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
114
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
115 115
             }
116 116
         }
117 117
     }
118 118
 }
119
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
119
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
120 120
 
121 121
 function wpinv_register_item_meta_boxes() {    
122 122
     global $wpinv_euvat;
123 123
     
124
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
124
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
125 125
 
126
-    if ( $wpinv_euvat->allow_vat_rules() ) {
127
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
126
+    if ($wpinv_euvat->allow_vat_rules()) {
127
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
128 128
     }
129 129
     
130
-    if ( $wpinv_euvat->allow_vat_classes() ) {
131
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
130
+    if ($wpinv_euvat->allow_vat_classes()) {
131
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
132 132
     }
133 133
     
134
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
135
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
134
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
135
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
136 136
 }
137 137
 
138 138
 function wpinv_register_discount_meta_boxes() {
139
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
139
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
140 140
 }
141 141
 
142
-function wpinv_discount_metabox_details( $post ) {
142
+function wpinv_discount_metabox_details($post) {
143 143
     $discount_id    = $post->ID;
144
-    $discount       = wpinv_get_discount( $discount_id );
144
+    $discount       = wpinv_get_discount($discount_id);
145 145
     
146
-    $type               = wpinv_get_discount_type( $discount_id );
147
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
148
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
149
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
150
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
151
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
152
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
153
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
154
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
155
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
146
+    $type               = wpinv_get_discount_type($discount_id);
147
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
148
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
149
+    $min_total          = wpinv_get_discount_min_total($discount_id);
150
+    $max_total          = wpinv_get_discount_max_total($discount_id);
151
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
152
+    $single_use         = wpinv_discount_is_single_use($discount_id);
153
+    $recurring          = (bool) wpinv_discount_is_recurring($discount_id);
154
+    $start_date         = wpinv_get_discount_start_date($discount_id);
155
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
156 156
     
157
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
158
-        $start_time         = strtotime( $start_date );
159
-        $start_h            = date_i18n( 'H', $start_time );
160
-        $start_m            = date_i18n( 'i', $start_time );
161
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
157
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
158
+        $start_time         = strtotime($start_date);
159
+        $start_h            = date_i18n('H', $start_time);
160
+        $start_m            = date_i18n('i', $start_time);
161
+        $start_date         = date_i18n('Y-m-d', $start_time);
162 162
     } else {
163 163
         $start_h            = '00';
164 164
         $start_m            = '00';
165 165
     }
166 166
 
167
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
168
-        $expiration_time    = strtotime( $expiration_date );
169
-        $expiration_h       = date_i18n( 'H', $expiration_time );
170
-        $expiration_m       = date_i18n( 'i', $expiration_time );
171
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
167
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
168
+        $expiration_time    = strtotime($expiration_date);
169
+        $expiration_h       = date_i18n('H', $expiration_time);
170
+        $expiration_m       = date_i18n('i', $expiration_time);
171
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
172 172
     } else {
173 173
         $expiration_h       = '23';
174 174
         $expiration_m       = '59';
@@ -178,207 +178,207 @@  discard block
 block discarded – undo
178 178
     $max_total          = $max_total > 0 ? $max_total : '';
179 179
     $max_uses           = $max_uses > 0 ? $max_uses : '';
180 180
 ?>
181
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
182
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
181
+<?php do_action('wpinv_discount_form_top', $post); ?>
182
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
183 183
 <table class="form-table wpi-form-table">
184 184
     <tbody>
185
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
186
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
185
+        <?php do_action('wpinv_discount_form_first', $post); ?>
186
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
187 187
         <tr>
188 188
             <th valign="top" scope="row">
189
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
189
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
190 190
             </th>
191 191
             <td>
192
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
193
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
192
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
193
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
194 194
             </td>
195 195
         </tr>
196
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
196
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
197 197
         <tr>
198 198
             <th valign="top" scope="row">
199
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
199
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
200 200
             </th>
201 201
             <td>
202 202
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
203
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
204
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
203
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
204
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
205 205
                     <?php } ?>
206 206
                 </select>
207
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
207
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
208 208
             </td>
209 209
         </tr>
210
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
210
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
211 211
         <tr>
212 212
             <th valign="top" scope="row">
213
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
213
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
214 214
             </th>
215 215
             <td>
216
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
217
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
218
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
216
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
217
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
218
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
219 219
             </td>
220 220
         </tr>
221
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
221
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
222 222
         <tr>
223 223
             <th valign="top" scope="row">
224
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
224
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
225 225
             </th>
226 226
             <td>
227
-                <p><?php echo wpinv_item_dropdown( array(
227
+                <p><?php echo wpinv_item_dropdown(array(
228 228
                         'name'              => 'items[]',
229 229
                         'id'                => 'items',
230 230
                         'selected'          => $item_reqs,
231 231
                         'multiple'          => true,
232 232
                         'class'             => 'medium-text wpi_select2',
233
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
233
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
234 234
                         'show_recurring'    => true,
235
-                    ) ); ?>
235
+                    )); ?>
236 236
                 </p>
237
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
237
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
238 238
             </td>
239 239
         </tr>
240
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
240
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
241 241
         <tr>
242 242
             <th valign="top" scope="row">
243
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
243
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
244 244
             </th>
245 245
             <td>
246
-                <p><?php echo wpinv_item_dropdown( array(
246
+                <p><?php echo wpinv_item_dropdown(array(
247 247
                         'name'              => 'excluded_items[]',
248 248
                         'id'                => 'excluded_items',
249 249
                         'selected'          => $excluded_items,
250 250
                         'multiple'          => true,
251 251
                         'class'             => 'medium-text wpi_select2',
252
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
252
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
253 253
                         'show_recurring'    => true,
254
-                    ) ); ?>
254
+                    )); ?>
255 255
                 </p>
256
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
256
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
257 257
             </td>
258 258
         </tr>
259
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
259
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
260 260
         <tr>
261 261
             <th valign="top" scope="row">
262
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
262
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
263 263
             </th>
264 264
             <td>
265
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
266
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
267
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
265
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
266
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
267
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
268 268
                     <?php } ?>
269 269
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
270
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
271
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
270
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
271
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
272 272
                     <?php } ?>
273 273
                 </select>
274
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
274
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
275 275
             </td>
276 276
         </tr>
277
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
277
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
278 278
         <tr>
279 279
             <th valign="top" scope="row">
280
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
280
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
281 281
             </th>
282 282
             <td>
283
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
284
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
285
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
283
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
284
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
285
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
286 286
                     <?php } ?>
287 287
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
288
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
289
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
288
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
289
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
290 290
                     <?php } ?>
291 291
                 </select>
292
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
292
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
293 293
             </td>
294 294
         </tr>
295
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
295
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
296 296
         <tr>
297 297
             <th valign="top" scope="row">
298
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
298
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
299 299
             </th>
300 300
             <td>
301 301
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
302
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
302
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
303 303
             </td>
304 304
         </tr>
305
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
305
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
306 306
         <tr>
307 307
             <th valign="top" scope="row">
308
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
308
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
309 309
             </th>
310 310
             <td>
311 311
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
312
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
312
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
313 313
             </td>
314 314
         </tr>
315
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
315
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
316 316
         <tr>
317 317
             <th valign="top" scope="row">
318
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
318
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
319 319
             </th>
320 320
             <td>
321 321
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
322
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
323
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
322
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
323
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
324 324
                 </select>
325
-                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
325
+                <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
326 326
             </td>
327 327
         </tr>
328
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
328
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
329 329
         <tr>
330 330
             <th valign="top" scope="row">
331
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
331
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
332 332
             </th>
333 333
             <td>
334 334
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
335
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
335
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
336 336
             </td>
337 337
         </tr>
338
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
338
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
339 339
         <tr>
340 340
             <th valign="top" scope="row">
341
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
341
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
342 342
             </th>
343 343
             <td>
344
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
345
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
344
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
345
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
346 346
             </td>
347 347
         </tr>
348
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
348
+        <?php do_action('wpinv_discount_form_last', $post); ?>
349 349
     </tbody>
350 350
 </table>
351
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
351
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
352 352
     <?php
353 353
 }
354 354
 
355
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
356
-    $post_type = !empty( $post ) ? $post->post_type : '';
355
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
356
+    $post_type = !empty($post) ? $post->post_type : '';
357 357
     
358
-    if ( $post_type != 'wpi_discount' ) {
358
+    if ($post_type != 'wpi_discount') {
359 359
         return;
360 360
     }
361 361
     
362
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
362
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
363 363
         return;
364 364
     }
365 365
     
366
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
366
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
367 367
         return;
368 368
     }
369 369
     
370
-    if ( !current_user_can( wpinv_get_capability(), $post_id ) ) {
370
+    if (!current_user_can(wpinv_get_capability(), $post_id)) {
371 371
         return;
372 372
     }
373 373
     
374
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
374
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
375 375
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
376 376
     }
377 377
 
378
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
378
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
379 379
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
380 380
     }
381 381
     
382
-    return /** @scrutinizer ignore-call */ wpinv_store_discount( $post_id, $_POST, $post, $update );
382
+    return /** @scrutinizer ignore-call */ wpinv_store_discount($post_id, $_POST, $post, $update);
383 383
 }
384
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
385 384
\ No newline at end of file
385
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
386 386
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
171 171
         require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
172 172
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
173
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
174
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
175
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
176
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
177
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
173
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
174
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
175
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
176
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
177
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
178 178
         require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
179 179
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
180 180
 
@@ -474,16 +474,16 @@  discard block
 block discarded – undo
474 474
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
475 475
     }
476 476
 
477
-	/**
478
-	 * Register widgets
479
-	 *
480
-	 */
481
-	public function register_widgets() {
482
-		register_widget( "WPInv_Checkout_Widget" );
483
-		register_widget( "WPInv_History_Widget" );
484
-		register_widget( "WPInv_Receipt_Widget" );
485
-		register_widget( "WPInv_Subscriptions_Widget" );
486
-		register_widget( "WPInv_Buy_Item_Widget" );
487
-		register_widget( "WPInv_Messages_Widget" );
488
-	}
477
+    /**
478
+     * Register widgets
479
+     *
480
+     */
481
+    public function register_widgets() {
482
+        register_widget( "WPInv_Checkout_Widget" );
483
+        register_widget( "WPInv_History_Widget" );
484
+        register_widget( "WPInv_Receipt_Widget" );
485
+        register_widget( "WPInv_Subscriptions_Widget" );
486
+        register_widget( "WPInv_Buy_Item_Widget" );
487
+        register_widget( "WPInv_Messages_Widget" );
488
+    }
489 489
 }
490 490
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array(&$this, 'wpinv_actions'));
48 48
         
49
-        if ( class_exists( 'BuddyPress' ) ) {
50
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
49
+        if (class_exists('BuddyPress')) {
50
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
51 51
         }
52 52
 
53
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
53
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
54
+        add_action('widgets_init', array(&$this, 'register_widgets'));
55 55
 
56
-        if ( is_admin() ) {
57
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
58
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
59
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
56
+        if (is_admin()) {
57
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
58
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
59
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
60 60
 
61 61
         } else {
62
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
62
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
63 63
         }
64 64
         
65 65
         /**
@@ -69,28 +69,28 @@  discard block
 block discarded – undo
69 69
          *
70 70
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
71 71
          */
72
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
72
+        do_action_ref_array('wpinv_actions', array(&$this));
73 73
 
74
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
74
+        add_action('admin_init', array(&$this, 'activation_redirect'));
75 75
     }
76 76
 
77 77
     /**
78 78
      * Maybe show the AyeCode Connect Notice.
79 79
      */
80
-    public function init_ayecode_connect_helper(){
80
+    public function init_ayecode_connect_helper() {
81 81
         // AyeCode Connect notice
82
-        if ( is_admin() ){
82
+        if (is_admin()) {
83 83
             // set the strings so they can be translated
84 84
             $strings = array(
85
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
86
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
87
-                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
88
-                'connect_button'    => __("Connect Site","invoicing"),
89
-                'connecting_button'    => __("Connecting...","invoicing"),
90
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
91
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
85
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
86
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
87
+                'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
88
+                'connect_button'    => __("Connect Site", "invoicing"),
89
+                'connecting_button'    => __("Connecting...", "invoicing"),
90
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
91
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
92 92
             );
93
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
93
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
94 94
         }
95 95
     }
96 96
     
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
         /* Internationalize the text strings used. */
99 99
         $this->load_textdomain();
100 100
 
101
-        do_action( 'wpinv_loaded' );
101
+        do_action('wpinv_loaded');
102 102
 
103 103
         // Fix oxygen page builder conflict
104
-        if ( function_exists( 'ct_css_output' ) ) {
104
+        if (function_exists('ct_css_output')) {
105 105
             wpinv_oxygen_fix_conflict();
106 106
         }
107 107
     }
@@ -111,233 +111,233 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @since 1.0
113 113
      */
114
-    public function load_textdomain( $locale = NULL ) {
115
-        if ( empty( $locale ) ) {
116
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
114
+    public function load_textdomain($locale = NULL) {
115
+        if (empty($locale)) {
116
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
117 117
         }
118 118
 
119
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
119
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
120 120
         
121
-        unload_textdomain( 'invoicing' );
122
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
123
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
121
+        unload_textdomain('invoicing');
122
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
123
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
124 124
         
125 125
         /**
126 126
          * Define language constants.
127 127
          */
128
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
128
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
129 129
     }
130 130
         
131 131
     public function includes() {
132 132
         global $wpinv_options;
133 133
         
134
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
134
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
135 135
         $wpinv_options = wpinv_get_settings();
136 136
         
137
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
138
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
140
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
142
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
143
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
144
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
145
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
146
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
147
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
148
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
149
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
150
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
151
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
152
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
153
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
154
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
155
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
156
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
157
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
158
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
160
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
163
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
164
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
165
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
166
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
168
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
169
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
170
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
171
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
172
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
173
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
174
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
175
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
176
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
177
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
178
-        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
179
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
180
-
181
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
182
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
137
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
138
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
140
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
142
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
143
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
144
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
145
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
146
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
147
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
148
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
149
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
150
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
151
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
152
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
153
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
154
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
155
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
156
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
157
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
158
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
160
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
163
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
164
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
165
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
166
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
168
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
169
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
170
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
171
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
172
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
173
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
174
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
175
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
176
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
177
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
178
+        require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
179
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
180
+
181
+        if (!class_exists('WPInv_EUVat')) {
182
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
183 183
         }
184 184
         
185
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
186
-        if ( !empty( $gateways ) ) {
187
-            foreach ( $gateways as $gateway ) {
188
-                if ( $gateway == 'manual' ) {
185
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
186
+        if (!empty($gateways)) {
187
+            foreach ($gateways as $gateway) {
188
+                if ($gateway == 'manual') {
189 189
                     continue;
190 190
                 }
191 191
                 
192 192
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
193 193
                 
194
-                if ( file_exists( $gateway_file ) ) {
195
-                    require_once( $gateway_file );
194
+                if (file_exists($gateway_file)) {
195
+                    require_once($gateway_file);
196 196
                 }
197 197
             }
198 198
         }
199
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
199
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
200 200
         
201
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
202
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
203
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
204
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
201
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
202
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
203
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
204
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
205 205
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
206
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
207
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
208
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-form-items.php' );
209
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
210
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
211
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
212
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
213
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
206
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
207
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
208
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-form-items.php');
209
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
210
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
211
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
212
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
213
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
214 214
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
215 215
             // load the user class only on the users.php page
216 216
             global $pagenow;
217
-            if($pagenow=='users.php'){
217
+            if ($pagenow == 'users.php') {
218 218
                 new WPInv_Admin_Users();
219 219
             }
220 220
         }
221 221
 
222 222
         // Register cli commands
223
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
224
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
225
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
223
+        if (defined('WP_CLI') && WP_CLI) {
224
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
225
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
226 226
         }
227 227
         
228 228
         // include css inliner
229
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
230
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
229
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
230
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
231 231
         }
232 232
         
233
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
233
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
234 234
     }
235 235
     
236 236
     public function init() {
237 237
     }
238 238
     
239 239
     public function admin_init() {
240
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
240
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
241 241
     }
242 242
 
243 243
     public function activation_redirect() {
244 244
         // Bail if no activation redirect
245
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
245
+        if (!get_transient('_wpinv_activation_redirect')) {
246 246
             return;
247 247
         }
248 248
 
249 249
         // Delete the redirect transient
250
-        delete_transient( '_wpinv_activation_redirect' );
250
+        delete_transient('_wpinv_activation_redirect');
251 251
 
252 252
         // Bail if activating from network, or bulk
253
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
253
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
254 254
             return;
255 255
         }
256 256
 
257
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
257
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
258 258
         exit;
259 259
     }
260 260
     
261 261
     public function enqueue_scripts() {
262
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
262
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
263 263
         
264
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
265
-        wp_enqueue_style( 'wpinv_front_style' );
264
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
265
+        wp_enqueue_style('wpinv_front_style');
266 266
                
267 267
         // Register scripts
268
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
269
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  WPINV_VERSION );
268
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
269
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION);
270 270
 
271 271
         $localize                         = array();
272
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
273
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
272
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
273
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
274 274
         $localize['currency_symbol']      = wpinv_currency_symbol();
275 275
         $localize['currency_pos']         = wpinv_currency_position();
276 276
         $localize['thousand_sep']         = wpinv_thousands_separator();
277 277
         $localize['decimal_sep']          = wpinv_decimal_separator();
278 278
         $localize['decimals']             = wpinv_decimals();
279
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
279
+        $localize['txtComplete']          = __('Complete', 'invoicing');
280 280
         $localize['UseTaxes']             = wpinv_use_taxes();
281
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
281
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
282 282
 
283
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
283
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
284 284
         
285
-        wp_enqueue_script( 'jquery-blockui' );
285
+        wp_enqueue_script('jquery-blockui');
286 286
         $autofill_api = wpinv_get_option('address_autofill_api');
287 287
         $autofill_active = wpinv_get_option('address_autofill_active');
288
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
289
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
290
-                wp_dequeue_script( 'google-maps-api' );
288
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
289
+            if (wp_script_is('google-maps-api', 'enqueued')) {
290
+                wp_dequeue_script('google-maps-api');
291 291
             }
292
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
293
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
292
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
293
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
294 294
         }
295 295
 
296
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
297
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
296
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
297
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
298 298
 
299
-        wp_enqueue_script( 'wpinv-front-script' );
300
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
299
+        wp_enqueue_script('wpinv-front-script');
300
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
301 301
     }
302 302
 
303 303
     public function admin_enqueue_scripts() {
304 304
         global $post, $pagenow;
305 305
         
306 306
         $post_type  = wpinv_admin_post_type();
307
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
308
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
307
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
308
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
309 309
 
310 310
         $jquery_ui_css = false;
311
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
311
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
312 312
             $jquery_ui_css = true;
313
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
313
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
314 314
             $jquery_ui_css = true;
315 315
         }
316
-        if ( $jquery_ui_css ) {
317
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
318
-            wp_enqueue_style( 'jquery-ui-css' );
316
+        if ($jquery_ui_css) {
317
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
318
+            wp_enqueue_style('jquery-ui-css');
319 319
         }
320 320
 
321
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
322
-        wp_enqueue_style( 'wpinv_meta_box_style' );
321
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
322
+        wp_enqueue_style('wpinv_meta_box_style');
323 323
         
324
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
325
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
326
-        wp_enqueue_style( 'wpinv_admin_style' );
324
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
325
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
326
+        wp_enqueue_style('wpinv_admin_style');
327 327
 
328
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
329
-        if ( $page == 'wpinv-subscriptions' ) {
330
-            wp_enqueue_script( 'jquery-ui-datepicker' );
328
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
329
+        if ($page == 'wpinv-subscriptions') {
330
+            wp_enqueue_script('jquery-ui-datepicker');
331 331
         }
332 332
         
333
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
334
-            wp_enqueue_script( 'jquery-ui-datepicker' );
333
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
334
+            wp_enqueue_script('jquery-ui-datepicker');
335 335
         }
336 336
 
337
-        wp_enqueue_style( 'wp-color-picker' );
338
-        wp_enqueue_script( 'wp-color-picker' );
337
+        wp_enqueue_style('wp-color-picker');
338
+        wp_enqueue_script('wp-color-picker');
339 339
         
340
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
340
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
341 341
 
342 342
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
343 343
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
             }
349 349
         }
350 350
 
351
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
352
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
351
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
352
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
353 353
 
354
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
355
-        wp_enqueue_script( 'wpinv-admin-script' );
354
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
355
+        wp_enqueue_script('wpinv-admin-script');
356 356
         
357 357
         $localize                               = array();
358
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
359
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
360
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
361
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
362
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
363
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
364
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
358
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
359
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
360
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
361
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
362
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
363
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
364
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
365 365
         $localize['tax']                        = wpinv_tax_amount();
366 366
         $localize['discount']                   = wpinv_discount_amount();
367 367
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -369,83 +369,83 @@  discard block
 block discarded – undo
369 369
         $localize['thousand_sep']               = wpinv_thousands_separator();
370 370
         $localize['decimal_sep']                = wpinv_decimal_separator();
371 371
         $localize['decimals']                   = wpinv_decimals();
372
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
373
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
374
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
375
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
376
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
377
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
378
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
379
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
380
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
381
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
382
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
383
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
384
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
385
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
386
-
387
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
388
-
389
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
390
-
391
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
392
-        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
393
-        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
394
-
395
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
396
-        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
372
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
373
+        $localize['status_publish']             = wpinv_status_nicename('publish');
374
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
375
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
376
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
377
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
378
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
379
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
380
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
381
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
382
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
383
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
384
+        $localize['action_edit']                = __('Edit', 'invoicing');
385
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
386
+
387
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
388
+
389
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
390
+
391
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
392
+        wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
393
+        wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
394
+
395
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
396
+        wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
397 397
         
398
-        wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
398
+        wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
399 399
             'elements'      => $this->form_elements->get_elements(),
400 400
             'form_elements' => array(),
401
-        ) );
401
+        ));
402 402
         
403
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
403
+        wp_enqueue_script('wpinv-admin-payment-form-script');
404 404
 
405
-        if ( $page == 'wpinv-subscriptions' ) {
406
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
407
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
405
+        if ($page == 'wpinv-subscriptions') {
406
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
407
+            wp_enqueue_script('wpinv-sub-admin-script');
408 408
         }
409 409
     }
410 410
     
411
-    public function admin_body_class( $classes ) {
411
+    public function admin_body_class($classes) {
412 412
         global $pagenow, $post, $current_screen;
413 413
         
414
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) {
414
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) {
415 415
             $classes .= ' wpinv-cpt';
416 416
         }
417 417
         
418
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
418
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
419 419
 
420
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
421
-        if ( $add_class ) {
422
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
420
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
421
+        if ($add_class) {
422
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
423 423
         }
424 424
         
425 425
         $settings_class = array();
426
-        if ( $page == 'wpinv-settings' ) {
427
-            if ( !empty( $_REQUEST['tab'] ) ) {
428
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
426
+        if ($page == 'wpinv-settings') {
427
+            if (!empty($_REQUEST['tab'])) {
428
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
429 429
             }
430 430
             
431
-            if ( !empty( $_REQUEST['section'] ) ) {
432
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
431
+            if (!empty($_REQUEST['section'])) {
432
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
433 433
             }
434 434
             
435
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
435
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
436 436
         }
437 437
         
438
-        if ( !empty( $settings_class ) ) {
439
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
438
+        if (!empty($settings_class)) {
439
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
440 440
         }
441 441
         
442 442
         $post_type = wpinv_admin_post_type();
443 443
 
444
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
444
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
445 445
             return $classes .= ' wpinv';
446 446
         }
447 447
         
448
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
448
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
449 449
             $classes .= ' wpi-editable-n';
450 450
         }
451 451
 
@@ -457,21 +457,21 @@  discard block
 block discarded – undo
457 457
     }
458 458
     
459 459
     public function wpinv_actions() {
460
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
461
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
460
+        if (isset($_REQUEST['wpi_action'])) {
461
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
462 462
         }
463 463
     }
464 464
     
465
-    public function pre_get_posts( $wp_query ) {
466
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
467
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
465
+    public function pre_get_posts($wp_query) {
466
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
467
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
468 468
         }
469 469
         
470 470
         return $wp_query;
471 471
     }
472 472
     
473 473
     public function bp_invoicing_init() {
474
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
474
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
475 475
     }
476 476
 
477 477
 	/**
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 	 *
480 480
 	 */
481 481
 	public function register_widgets() {
482
-		register_widget( "WPInv_Checkout_Widget" );
483
-		register_widget( "WPInv_History_Widget" );
484
-		register_widget( "WPInv_Receipt_Widget" );
485
-		register_widget( "WPInv_Subscriptions_Widget" );
486
-		register_widget( "WPInv_Buy_Item_Widget" );
487
-		register_widget( "WPInv_Messages_Widget" );
482
+		register_widget("WPInv_Checkout_Widget");
483
+		register_widget("WPInv_History_Widget");
484
+		register_widget("WPInv_Receipt_Widget");
485
+		register_widget("WPInv_Subscriptions_Widget");
486
+		register_widget("WPInv_Buy_Item_Widget");
487
+		register_widget("WPInv_Messages_Widget");
488 488
 	}
489 489
 }
490 490
\ No newline at end of file
Please login to merge, or discard this patch.