Passed
Pull Request — master (#284)
by Brian
06:11
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/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.
widgets/payment-form.php 2 patches
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function __construct() {
18 18
 
19
-		$forms = get_posts(
20
-			array(
21
-				'post_type'      => 'wpi_payment_form',
22
-				'orderby'        => 'title',
23
-				'order'          => 'ASC',
24
-				'posts_per_page' => -1,
25
-				'post_status'    => array( 'publish' ),
26
-			)
27
-		);
28
-
29
-		$options = array(
30
-			'' => __('Select a Form','invoicing')
31
-		);
32
-
33
-		foreach( $forms as $form ) {
34
-			$options[ $form->ID ] = $form->post_title;
35
-		}
19
+        $forms = get_posts(
20
+            array(
21
+                'post_type'      => 'wpi_payment_form',
22
+                'orderby'        => 'title',
23
+                'order'          => 'ASC',
24
+                'posts_per_page' => -1,
25
+                'post_status'    => array( 'publish' ),
26
+            )
27
+        );
28
+
29
+        $options = array(
30
+            '' => __('Select a Form','invoicing')
31
+        );
32
+
33
+        foreach( $forms as $form ) {
34
+            $options[ $form->ID ] = $form->post_title;
35
+        }
36 36
 
37 37
         $options = array(
38 38
             'textdomain'    => 'invoicing',
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
                 'form'            => array(
51 51
                     'title'       => __( 'Payment Form', 'invoicing' ),
52 52
                     'desc'        => __( 'Select your payment form.', 'invoicing' ),
53
-					'type'        => 'select',
54
-					'options'     =>  $options,
53
+                    'type'        => 'select',
54
+                    'options'     =>  $options,
55 55
                     'desc_tip'    => true,
56 56
                     'default'     => '',
57 57
                     'advanced'    => false
@@ -64,56 +64,56 @@  discard block
 block discarded – undo
64 64
         parent::__construct( $options );
65 65
     }
66 66
 
67
-	/**
68
-	 * The Super block output function.
69
-	 *
70
-	 * @param array $args
71
-	 * @param array $widget_args
72
-	 * @param string $content
73
-	 *
74
-	 * @return string
75
-	 */
67
+    /**
68
+     * The Super block output function.
69
+     *
70
+     * @param array $args
71
+     * @param array $widget_args
72
+     * @param string $content
73
+     *
74
+     * @return string
75
+     */
76 76
     public function output( $args = array(), $widget_args = array(), $content = '' ) {
77
-		global $invoicing;
78
-
79
-		// Do we have a payment form?
80
-		if ( empty( $args['form'] ) ) {
81
-			return aui()->alert(
82
-				array(
83
-					'type'    => 'warning',
84
-					'content' => __( 'No payment form selected', 'invoicing' ),
85
-				)
86
-			);
87
-
88
-		}
89
-
90
-		// If yes, ensure that it is published.
91
-		if ( 'publish' != get_post_status( $args['form'] ) ) {
92
-			return aui()->alert(
93
-				array(
94
-					'type'    => 'warning',
95
-					'content' => __( 'This payment form is no longer active', 'invoicing' ),
96
-				)
97
-			);
98
-		}
99
-
100
-		// Get the form elements and items.
101
-		$elements = $invoicing->form_elements->get_form_elements( $args['form'] );
102
-		$items    = $invoicing->form_elements->get_form_items( $args['form'] );
103
-
104
-		ob_start();
105
-
106
-		echo "<input type='hidden' name='form_id' value='{$args['form']}'/>";
107
-		echo wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
108
-
109
-		foreach ( $elements as $element ) {
110
-			do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] );
111
-			do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] );
112
-		}
113
-
114
-		$content = ob_get_clean();
77
+        global $invoicing;
78
+
79
+        // Do we have a payment form?
80
+        if ( empty( $args['form'] ) ) {
81
+            return aui()->alert(
82
+                array(
83
+                    'type'    => 'warning',
84
+                    'content' => __( 'No payment form selected', 'invoicing' ),
85
+                )
86
+            );
87
+
88
+        }
89
+
90
+        // If yes, ensure that it is published.
91
+        if ( 'publish' != get_post_status( $args['form'] ) ) {
92
+            return aui()->alert(
93
+                array(
94
+                    'type'    => 'warning',
95
+                    'content' => __( 'This payment form is no longer active', 'invoicing' ),
96
+                )
97
+            );
98
+        }
99
+
100
+        // Get the form elements and items.
101
+        $elements = $invoicing->form_elements->get_form_elements( $args['form'] );
102
+        $items    = $invoicing->form_elements->get_form_items( $args['form'] );
103
+
104
+        ob_start();
105
+
106
+        echo "<input type='hidden' name='form_id' value='{$args['form']}'/>";
107
+        echo wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
108
+
109
+        foreach ( $elements as $element ) {
110
+            do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] );
111
+            do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] );
112
+        }
113
+
114
+        $content = ob_get_clean();
115 115
 		
116
-		return str_replace( 'sr-only', '', $content );
116
+        return str_replace( 'sr-only', '', $content );
117 117
 
118 118
     }
119 119
 
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 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
 
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
 				'orderby'        => 'title',
23 23
 				'order'          => 'ASC',
24 24
 				'posts_per_page' => -1,
25
-				'post_status'    => array( 'publish' ),
25
+				'post_status'    => array('publish'),
26 26
 			)
27 27
 		);
28 28
 
29 29
 		$options = array(
30
-			'' => __('Select a Form','invoicing')
30
+			'' => __('Select a Form', 'invoicing')
31 31
 		);
32 32
 
33
-		foreach( $forms as $form ) {
34
-			$options[ $form->ID ] = $form->post_title;
33
+		foreach ($forms as $form) {
34
+			$options[$form->ID] = $form->post_title;
35 35
 		}
36 36
 
37 37
         $options = array(
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
             'block-keywords'=> "['invoicing','buy', 'buy item', 'pay', 'payment form']",
42 42
             'class_name'     => __CLASS__,
43 43
             'base_id'       => 'wpinv_payment_form',
44
-            'name'          => __('Invoicing > Payment Form','invoicing'),
44
+            'name'          => __('Invoicing > Payment Form', 'invoicing'),
45 45
             'widget_ops'    => array(
46 46
                 'classname'   => 'wpinv-payment-form-class bsui',
47
-                'description' => esc_html__('Displays a payment form.','invoicing'),
47
+                'description' => esc_html__('Displays a payment form.', 'invoicing'),
48 48
             ),
49 49
             'arguments'           => array(
50 50
                 'form'            => array(
51
-                    'title'       => __( 'Payment Form', 'invoicing' ),
52
-                    'desc'        => __( 'Select your payment form.', 'invoicing' ),
51
+                    'title'       => __('Payment Form', 'invoicing'),
52
+                    'desc'        => __('Select your payment form.', 'invoicing'),
53 53
 					'type'        => 'select',
54 54
 					'options'     =>  $options,
55 55
                     'desc_tip'    => true,
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         );
62 62
 
63 63
 
64
-        parent::__construct( $options );
64
+        parent::__construct($options);
65 65
     }
66 66
 
67 67
 	/**
@@ -73,47 +73,47 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return string
75 75
 	 */
76
-    public function output( $args = array(), $widget_args = array(), $content = '' ) {
76
+    public function output($args = array(), $widget_args = array(), $content = '') {
77 77
 		global $invoicing;
78 78
 
79 79
 		// Do we have a payment form?
80
-		if ( empty( $args['form'] ) ) {
80
+		if (empty($args['form'])) {
81 81
 			return aui()->alert(
82 82
 				array(
83 83
 					'type'    => 'warning',
84
-					'content' => __( 'No payment form selected', 'invoicing' ),
84
+					'content' => __('No payment form selected', 'invoicing'),
85 85
 				)
86 86
 			);
87 87
 
88 88
 		}
89 89
 
90 90
 		// If yes, ensure that it is published.
91
-		if ( 'publish' != get_post_status( $args['form'] ) ) {
91
+		if ('publish' != get_post_status($args['form'])) {
92 92
 			return aui()->alert(
93 93
 				array(
94 94
 					'type'    => 'warning',
95
-					'content' => __( 'This payment form is no longer active', 'invoicing' ),
95
+					'content' => __('This payment form is no longer active', 'invoicing'),
96 96
 				)
97 97
 			);
98 98
 		}
99 99
 
100 100
 		// Get the form elements and items.
101
-		$elements = $invoicing->form_elements->get_form_elements( $args['form'] );
102
-		$items    = $invoicing->form_elements->get_form_items( $args['form'] );
101
+		$elements = $invoicing->form_elements->get_form_elements($args['form']);
102
+		$items    = $invoicing->form_elements->get_form_items($args['form']);
103 103
 
104 104
 		ob_start();
105 105
 
106 106
 		echo "<input type='hidden' name='form_id' value='{$args['form']}'/>";
107
-		echo wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
107
+		echo wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
108 108
 
109
-		foreach ( $elements as $element ) {
110
-			do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] );
111
-			do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] );
109
+		foreach ($elements as $element) {
110
+			do_action('wpinv_frontend_render_payment_form_element', $element, $items, $args['form']);
111
+			do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form']);
112 112
 		}
113 113
 
114 114
 		$content = ob_get_clean();
115 115
 		
116
-		return str_replace( 'sr-only', '', $content );
116
+		return str_replace('sr-only', '', $content);
117 117
 
118 118
     }
119 119
 
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -1,69 +1,69 @@  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' );
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 27
 
28
-    add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
28
+    add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
29 29
    
30
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
31
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
32
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
30
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
31
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
32
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
33 33
 
34 34
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
35 35
 }
36
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
36
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
37 37
 
38
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
39
-    remove_action( 'save_post', __FUNCTION__ );
38
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
39
+    remove_action('save_post', __FUNCTION__);
40 40
     
41 41
     // $post_id and $post are required
42
-    if ( empty( $post_id ) || empty( $post ) ) {
42
+    if (empty($post_id) || empty($post)) {
43 43
         return;
44 44
     }
45 45
         
46
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
46
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
47 47
         return;
48 48
     }
49 49
     
50 50
     // Dont' save meta boxes for revisions or autosaves
51
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
51
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
52 52
         return;
53 53
     }
54 54
         
55
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
56
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
55
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
56
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
57 57
             return;
58 58
         }
59 59
     
60
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
61
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
60
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
61
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
62 62
         }
63
-    } else if ( $post->post_type == 'wpi_item' ) {
63
+    } else if ($post->post_type == 'wpi_item') {
64 64
         // verify nonce
65
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
66
-            $fields                                 = array();
65
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
66
+            $fields = array();
67 67
             $fields['_wpinv_price']              = 'wpinv_item_price';
68 68
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
69 69
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -78,96 +78,96 @@  discard block
 block discarded – undo
78 78
             $fields['_wpinv_dynamic_pricing']    = 'wpinv_name_your_price';
79 79
             $fields['_minimum_price']            = 'wpinv_minimum_price';
80 80
             
81
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
81
+            if (!isset($_POST['wpinv_is_recurring'])) {
82 82
                 $_POST['wpinv_is_recurring'] = 0;
83 83
             }
84 84
 
85
-            if ( !isset( $_POST['wpinv_name_your_price'] ) ) {
85
+            if (!isset($_POST['wpinv_name_your_price'])) {
86 86
                 $_POST['wpinv_name_your_price'] = 0;
87 87
             }
88 88
             
89
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
89
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
90 90
                 $_POST['wpinv_free_trial'] = 0;
91 91
             }
92 92
             
93
-            foreach ( $fields as $field => $name ) {
94
-                if ( isset( $_POST[ $name ] ) ) {
95
-                    $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id );
93
+            foreach ($fields as $field => $name) {
94
+                if (isset($_POST[$name])) {
95
+                    $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id);
96 96
 
97
-                    if ( !$allowed ) {
97
+                    if (!$allowed) {
98 98
                         continue;
99 99
                     }
100 100
 
101
-                    if ( $field == '_wpinv_price' ) {
102
-                        $value = wpinv_sanitize_amount( $_POST[ $name ] );
101
+                    if ($field == '_wpinv_price') {
102
+                        $value = wpinv_sanitize_amount($_POST[$name]);
103 103
                     } else {
104
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
104
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
105 105
                     }
106 106
                     
107
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
108
-                    update_post_meta( $post_id, $field, $value );
107
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
108
+                    update_post_meta($post_id, $field, $value);
109 109
                 }
110 110
             }
111 111
             
112
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
113
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
112
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
113
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
114 114
             }
115 115
         }
116 116
     }
117 117
 }
118
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
118
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
119 119
 
120 120
 function wpinv_register_item_meta_boxes() {    
121 121
     global $wpinv_euvat;
122 122
     
123
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
123
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
124 124
 
125
-    if ( $wpinv_euvat->allow_vat_rules() ) {
126
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
125
+    if ($wpinv_euvat->allow_vat_rules()) {
126
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
127 127
     }
128 128
     
129
-    if ( $wpinv_euvat->allow_vat_classes() ) {
130
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
129
+    if ($wpinv_euvat->allow_vat_classes()) {
130
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
131 131
     }
132 132
     
133
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
134
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
133
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
134
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
135 135
 }
136 136
 
137 137
 function wpinv_register_discount_meta_boxes() {
138
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
138
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
139 139
 }
140 140
 
141
-function wpinv_discount_metabox_details( $post ) {
141
+function wpinv_discount_metabox_details($post) {
142 142
     $discount_id    = $post->ID;
143
-    $discount       = wpinv_get_discount( $discount_id );
143
+    $discount       = wpinv_get_discount($discount_id);
144 144
     
145
-    $type               = wpinv_get_discount_type( $discount_id );
146
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
147
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
148
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
149
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
150
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
151
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
152
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
153
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
154
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
145
+    $type               = wpinv_get_discount_type($discount_id);
146
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
147
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
148
+    $min_total          = wpinv_get_discount_min_total($discount_id);
149
+    $max_total          = wpinv_get_discount_max_total($discount_id);
150
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
151
+    $single_use         = wpinv_discount_is_single_use($discount_id);
152
+    $recurring          = (bool) wpinv_discount_is_recurring($discount_id);
153
+    $start_date         = wpinv_get_discount_start_date($discount_id);
154
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
155 155
     
156
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
157
-        $start_time         = strtotime( $start_date );
158
-        $start_h            = date_i18n( 'H', $start_time );
159
-        $start_m            = date_i18n( 'i', $start_time );
160
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
156
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
157
+        $start_time         = strtotime($start_date);
158
+        $start_h            = date_i18n('H', $start_time);
159
+        $start_m            = date_i18n('i', $start_time);
160
+        $start_date         = date_i18n('Y-m-d', $start_time);
161 161
     } else {
162 162
         $start_h            = '00';
163 163
         $start_m            = '00';
164 164
     }
165 165
 
166
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
167
-        $expiration_time    = strtotime( $expiration_date );
168
-        $expiration_h       = date_i18n( 'H', $expiration_time );
169
-        $expiration_m       = date_i18n( 'i', $expiration_time );
170
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
166
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
167
+        $expiration_time    = strtotime($expiration_date);
168
+        $expiration_h       = date_i18n('H', $expiration_time);
169
+        $expiration_m       = date_i18n('i', $expiration_time);
170
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
171 171
     } else {
172 172
         $expiration_h       = '23';
173 173
         $expiration_m       = '59';
@@ -177,207 +177,207 @@  discard block
 block discarded – undo
177 177
     $max_total          = $max_total > 0 ? $max_total : '';
178 178
     $max_uses           = $max_uses > 0 ? $max_uses : '';
179 179
 ?>
180
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
181
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
180
+<?php do_action('wpinv_discount_form_top', $post); ?>
181
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
182 182
 <table class="form-table wpi-form-table">
183 183
     <tbody>
184
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
185
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
184
+        <?php do_action('wpinv_discount_form_first', $post); ?>
185
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
186 186
         <tr>
187 187
             <th valign="top" scope="row">
188
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
188
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
189 189
             </th>
190 190
             <td>
191
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
192
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
191
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
192
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
193 193
             </td>
194 194
         </tr>
195
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
195
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
196 196
         <tr>
197 197
             <th valign="top" scope="row">
198
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
198
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
199 199
             </th>
200 200
             <td>
201 201
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
202
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
203
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
202
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
203
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
204 204
                     <?php } ?>
205 205
                 </select>
206
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
206
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
207 207
             </td>
208 208
         </tr>
209
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
209
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
210 210
         <tr>
211 211
             <th valign="top" scope="row">
212
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
212
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
213 213
             </th>
214 214
             <td>
215
-                <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>
216
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
217
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
215
+                <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>
216
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
217
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
218 218
             </td>
219 219
         </tr>
220
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
220
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
221 221
         <tr>
222 222
             <th valign="top" scope="row">
223
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
223
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
224 224
             </th>
225 225
             <td>
226
-                <p><?php echo wpinv_item_dropdown( array(
226
+                <p><?php echo wpinv_item_dropdown(array(
227 227
                         'name'              => 'items[]',
228 228
                         'id'                => 'items',
229 229
                         'selected'          => $item_reqs,
230 230
                         'multiple'          => true,
231 231
                         'class'             => 'medium-text wpi_select2',
232
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
232
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
233 233
                         'show_recurring'    => true,
234
-                    ) ); ?>
234
+                    )); ?>
235 235
                 </p>
236
-                <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>
236
+                <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 237
             </td>
238 238
         </tr>
239
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
239
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
240 240
         <tr>
241 241
             <th valign="top" scope="row">
242
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
242
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
243 243
             </th>
244 244
             <td>
245
-                <p><?php echo wpinv_item_dropdown( array(
245
+                <p><?php echo wpinv_item_dropdown(array(
246 246
                         'name'              => 'excluded_items[]',
247 247
                         'id'                => 'excluded_items',
248 248
                         'selected'          => $excluded_items,
249 249
                         'multiple'          => true,
250 250
                         'class'             => 'medium-text wpi_select2',
251
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
251
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
252 252
                         'show_recurring'    => true,
253
-                    ) ); ?>
253
+                    )); ?>
254 254
                 </p>
255
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
255
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
256 256
             </td>
257 257
         </tr>
258
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
258
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
259 259
         <tr>
260 260
             <th valign="top" scope="row">
261
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
261
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
262 262
             </th>
263 263
             <td>
264
-                <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">
265
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
266
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
264
+                <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">
265
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
266
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
267 267
                     <?php } ?>
268 268
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
269
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
270
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
269
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
270
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
271 271
                     <?php } ?>
272 272
                 </select>
273
-                <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>
273
+                <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 274
             </td>
275 275
         </tr>
276
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
276
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
277 277
         <tr>
278 278
             <th valign="top" scope="row">
279
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
279
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
280 280
             </th>
281 281
             <td>
282
-                <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">
283
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
284
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
282
+                <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">
283
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
284
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
285 285
                     <?php } ?>
286 286
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
287
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
288
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
287
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
288
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
289 289
                     <?php } ?>
290 290
                 </select>
291
-                <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>
291
+                <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 292
             </td>
293 293
         </tr>
294
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
294
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
295 295
         <tr>
296 296
             <th valign="top" scope="row">
297
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
297
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
298 298
             </th>
299 299
             <td>
300 300
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
301
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
301
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
302 302
             </td>
303 303
         </tr>
304
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
304
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
305 305
         <tr>
306 306
             <th valign="top" scope="row">
307
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
307
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
308 308
             </th>
309 309
             <td>
310 310
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
311
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
311
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
312 312
             </td>
313 313
         </tr>
314
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
314
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
315 315
         <tr>
316 316
             <th valign="top" scope="row">
317
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
317
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
318 318
             </th>
319 319
             <td>
320 320
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
321
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
322
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
321
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
322
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
323 323
                 </select>
324
-                <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>
324
+                <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 325
             </td>
326 326
         </tr>
327
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
327
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
328 328
         <tr>
329 329
             <th valign="top" scope="row">
330
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
330
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
331 331
             </th>
332 332
             <td>
333 333
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
334
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
334
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
335 335
             </td>
336 336
         </tr>
337
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
337
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
338 338
         <tr>
339 339
             <th valign="top" scope="row">
340
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
340
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
341 341
             </th>
342 342
             <td>
343
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
344
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
343
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
344
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
345 345
             </td>
346 346
         </tr>
347
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
347
+        <?php do_action('wpinv_discount_form_last', $post); ?>
348 348
     </tbody>
349 349
 </table>
350
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
350
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
351 351
     <?php
352 352
 }
353 353
 
354
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
355
-    $post_type = !empty( $post ) ? $post->post_type : '';
354
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
355
+    $post_type = !empty($post) ? $post->post_type : '';
356 356
     
357
-    if ( $post_type != 'wpi_discount' ) {
357
+    if ($post_type != 'wpi_discount') {
358 358
         return;
359 359
     }
360 360
     
361
-    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' ) ) ) {
361
+    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 362
         return;
363 363
     }
364 364
     
365
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
365
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
366 366
         return;
367 367
     }
368 368
     
369
-    if ( !current_user_can( wpinv_get_capability(), $post_id ) ) {
369
+    if (!current_user_can(wpinv_get_capability(), $post_id)) {
370 370
         return;
371 371
     }
372 372
     
373
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
373
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
374 374
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
375 375
     }
376 376
 
377
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
377
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
378 378
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
379 379
     }
380 380
     
381
-    return /** @scrutinizer ignore-call */ wpinv_store_discount( $post_id, $_POST, $post, $update );
381
+    return /** @scrutinizer ignore-call */ wpinv_store_discount($post_id, $_POST, $post, $update);
382 382
 }
383
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
384 383
\ No newline at end of file
384
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
385 385
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-payment-form.php 1 patch
Spacing   +41 added lines, -41 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_Payment_Form {
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @param WP_Post $post
13 13
      */
14
-    public static function output ( $post ) {
15
-        $success_page        = get_post_meta( $post->ID, 'wpinv_success_page', true );
16
-        $success_page        = empty( $success_page ) ? wpinv_get_success_page_uri() : $success_page
14
+    public static function output($post) {
15
+        $success_page        = get_post_meta($post->ID, 'wpinv_success_page', true);
16
+        $success_page        = empty($success_page) ? wpinv_get_success_page_uri() : $success_page
17 17
         ?>
18 18
 
19 19
         <div id="wpinv-form-builder" style="display: flex; flex-flow: wrap;">
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
             <div class="wpinv-form-builder-left bsui" style="flex: 0 0 320px;">
22 22
                 <ul class="wpinv-form-builder-tabs  nav nav-tabs">
23 23
                     <li class='nav-item' v-if="active_tab!='new_item'">
24
-                        <a @click.prevent="active_tab='new_item'" class="nav-link p-3" :class="{ 'active': active_tab=='new_item' }" href="#"><?php _e( 'Add new element', 'invoicing' ); ?></a>
24
+                        <a @click.prevent="active_tab='new_item'" class="nav-link p-3" :class="{ 'active': active_tab=='new_item' }" href="#"><?php _e('Add new element', 'invoicing'); ?></a>
25 25
                     </li>
26 26
                     <li class='nav-item' v-if='false'>
27
-                        <a @click.prevent="active_tab='edit_item'" class="nav-link p-3" :class="{ 'active': active_tab=='edit_item' }" href="#"><?php _e( 'Edit element', 'invoicing' ); ?></a>
27
+                        <a @click.prevent="active_tab='edit_item'" class="nav-link p-3" :class="{ 'active': active_tab=='edit_item' }" href="#"><?php _e('Edit element', 'invoicing'); ?></a>
28 28
                     </li>
29 29
                     <li class='nav-item' v-if='false'>
30
-                        <a @click.prevent="active_tab='settings'" class="nav-link p-3" :class="{ 'active': active_tab=='settings' }" href="#"><?php _e( 'Settings', 'invoicing' ); ?></a>
30
+                        <a @click.prevent="active_tab='settings'" class="nav-link p-3" :class="{ 'active': active_tab=='settings' }" href="#"><?php _e('Settings', 'invoicing'); ?></a>
31 31
                     </li>
32 32
                 </ul>
33 33
 
34 34
                 <div class="wpinv-form-builder-tab-content bsui" style="margin-top: 16px;">
35 35
                     <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
36 36
                         <div class="wpinv-form-builder-add-field-types">
37
-                            <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>
37
+                            <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
38 38
                             <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable">
39 39
                                 <li v-for="element in elements" style="width: 49%; background-color: #fafafa; margin-bottom: 9px; cursor: move; border: 1px solid #eeeeee;" @click.prevent="addField(element)">
40 40
                                     <button class="button btn" style="width: 100%; cursor: move;">
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
                     <div class="wpinv-form-builder-tab-pane bsui" v-if="active_tab=='edit_item'" style="font-size: 16px;">
51 51
                         <div class="wpinv-form-builder-edit-field-wrapper">
52
-                            <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
52
+                            <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
53 53
                             <div>
54
-                                <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)"><?php _e( 'Delete Field', 'invoicing' ); ?></button>
54
+                                <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)"><?php _e('Delete Field', 'invoicing'); ?></button>
55 55
                             </div>
56 56
                         </div>
57 57
                     </div>
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
                         <div class="wpinv-form-builder-settings-wrapper">
61 61
                         
62 62
                             <div class='form-group'>
63
-                                <label for="wpi-success-page"><?php _e( 'Success Page', 'invoicing' ); ?></label>
64
-                                <input  placeholder="https://" id='wpi-success-page' value="<?php echo esc_url( $success_page ); ?>" class='form-control' type='text'>
65
-                                <small class='form-text text-muted'><?php _e( 'Where should we redirect users after successfuly completing their payment?', 'invoicing' ); ?></small>
63
+                                <label for="wpi-success-page"><?php _e('Success Page', 'invoicing'); ?></label>
64
+                                <input  placeholder="https://" id='wpi-success-page' value="<?php echo esc_url($success_page); ?>" class='form-control' type='text'>
65
+                                <small class='form-text text-muted'><?php _e('Where should we redirect users after successfuly completing their payment?', 'invoicing'); ?></small>
66 66
                             </div>
67 67
 
68 68
                         </div>
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 
74 74
             <div class="wpinv-form-builder-right" style="flex: 1; padding-top: 40px;border-left: 1px solid #ddd;padding-left: 20px;min-height: 520px;margin-left: 10px;">
75 75
 
76
-                <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
77
-                <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p>
76
+                <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
77
+                <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p>
78 78
 
79 79
                 <draggable class="section bsui" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 16px;">
80 80
                     <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="{ active: active_form_element==form_element &&  active_tab=='edit_item' }" @click="active_tab = 'edit_item'; active_form_element = form_element">
81
-                        <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
81
+                        <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
82 82
                     </div>
83 83
                 </draggable>
84 84
             </div>
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             <textarea style="display:none;" name="wpinv_form_items" v-model="itemString"></textarea>
88 88
         </div>
89 89
         
90
-        <?php wp_nonce_field( 'wpinv_save_payment_form', 'wpinv_save_payment_form' ) ;?>
90
+        <?php wp_nonce_field('wpinv_save_payment_form', 'wpinv_save_payment_form'); ?>
91 91
 
92 92
         <?php
93 93
     }
@@ -95,83 +95,83 @@  discard block
 block discarded – undo
95 95
     /**
96 96
      * Saves our payment forms.
97 97
      */
98
-    public static function save( $post_id, $post ) {
98
+    public static function save($post_id, $post) {
99 99
 
100
-        remove_action( 'save_post', 'WPInv_Meta_Box_Payment_Form::save' );
100
+        remove_action('save_post', 'WPInv_Meta_Box_Payment_Form::save');
101 101
 
102 102
         // $post_id and $post are required.
103
-        if ( empty( $post_id ) || empty( $post ) ) {
103
+        if (empty($post_id) || empty($post)) {
104 104
             return;
105 105
         }
106 106
         
107 107
         // Ensure that this user can edit the post.
108
-        if ( ! current_user_can( 'edit_post', $post_id ) ) {
108
+        if (!current_user_can('edit_post', $post_id)) {
109 109
             return;
110 110
         }
111 111
 
112 112
         // Dont' save meta boxes for revisions or autosaves
113
-        if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
113
+        if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
114 114
             return;
115 115
         }
116 116
 
117 117
         // Do not save for ajax requests.
118
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
118
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
119 119
             return;
120 120
         }
121 121
 
122 122
         // Confirm the security nonce.
123
-        if ( empty( $_POST['wpinv_save_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_save_payment_form'], 'wpinv_save_payment_form' ) ) {
123
+        if (empty($_POST['wpinv_save_payment_form']) || !wp_verify_nonce($_POST['wpinv_save_payment_form'], 'wpinv_save_payment_form')) {
124 124
             return;
125 125
         }
126 126
 
127 127
         // Save form items.
128
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
128
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
129 129
 
130
-        if ( empty( $form_items ) ) {
130
+        if (empty($form_items)) {
131 131
             $form_items = array();
132 132
         }
133 133
 
134
-        update_post_meta( $post_id, 'wpinv_form_items', self::maybe_save_items( $form_items ) );
134
+        update_post_meta($post_id, 'wpinv_form_items', self::maybe_save_items($form_items));
135 135
 
136 136
         // Save form elements.
137
-        $wpinv_form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
138
-        if ( empty( $wpinv_form_elements ) ) {
137
+        $wpinv_form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
138
+        if (empty($wpinv_form_elements)) {
139 139
             $wpinv_form_elements = array();
140 140
         }
141 141
 
142
-        update_post_meta( $post_id, 'wpinv_form_elements', $wpinv_form_elements );
142
+        update_post_meta($post_id, 'wpinv_form_elements', $wpinv_form_elements);
143 143
     }
144 144
 
145 145
     /**
146 146
      * Saves unsaved form items.
147 147
      */
148
-    public static function maybe_save_items( $items ) {
148
+    public static function maybe_save_items($items) {
149 149
 
150 150
         $saved = array();
151 151
 
152
-        foreach( $items as $item ) {
152
+        foreach ($items as $item) {
153 153
 
154
-            if ( is_numeric( $item['id'] ) ) {
154
+            if (is_numeric($item['id'])) {
155 155
                 $saved[] = $item;
156 156
                 continue;
157 157
             }
158 158
 
159 159
             $data = array(
160
-                'post_title'   => sanitize_text_field( $item['title'] ),
161
-                'post_excerpt' => wp_kses_post( $item['description'] ),
160
+                'post_title'   => sanitize_text_field($item['title']),
161
+                'post_excerpt' => wp_kses_post($item['description']),
162 162
                 'post_status'  => 'publish',
163 163
                 'meta'         => array(
164 164
                     'type'      => 'custom',
165
-                    'price'     => wpinv_sanitize_amount( $item['price'] ),
165
+                    'price'     => wpinv_sanitize_amount($item['price']),
166 166
                     'vat_rule'  => 'digital',
167 167
                     'vat_class' => '_standard',
168 168
                 )
169 169
             );
170 170
             
171
-            $new_item  = new WPInv_Item();
172
-            $new_item->create( $data );
171
+            $new_item = new WPInv_Item();
172
+            $new_item->create($data);
173 173
     
174
-            if ( ! empty( $new_item ) ) {
174
+            if (!empty($new_item)) {
175 175
                 $item['id'] = $new_item->ID;
176 176
                 $saved[] = $item;
177 177
             }
@@ -184,5 +184,5 @@  discard block
 block discarded – undo
184 184
 
185 185
 }
186 186
 
187
-add_action( 'save_post_wpi_payment_form', 'WPInv_Meta_Box_Payment_Form::save', 10, 2 );
187
+add_action('save_post_wpi_payment_form', 'WPInv_Meta_Box_Payment_Form::save', 10, 2);
188 188
 
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +16 added lines, -16 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 . 'widgets/payment-form.php' );
180 180
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
@@ -487,17 +487,17 @@  discard block
 block discarded – undo
487 487
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
488 488
     }
489 489
 
490
-	/**
491
-	 * Register widgets
492
-	 *
493
-	 */
494
-	public function register_widgets() {
495
-		register_widget( "WPInv_Checkout_Widget" );
496
-		register_widget( "WPInv_History_Widget" );
497
-		register_widget( "WPInv_Receipt_Widget" );
498
-		register_widget( "WPInv_Subscriptions_Widget" );
499
-		register_widget( "WPInv_Buy_Item_Widget" );
490
+    /**
491
+     * Register widgets
492
+     *
493
+     */
494
+    public function register_widgets() {
495
+        register_widget( "WPInv_Checkout_Widget" );
496
+        register_widget( "WPInv_History_Widget" );
497
+        register_widget( "WPInv_Receipt_Widget" );
498
+        register_widget( "WPInv_Subscriptions_Widget" );
499
+        register_widget( "WPInv_Buy_Item_Widget" );
500 500
         register_widget( "WPInv_Messages_Widget" );
501 501
         register_widget( 'WPInv_Payment_Form_Widget' );
502
-	}
502
+    }
503 503
 }
504 504
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +232 added lines, -232 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,234 +111,234 @@  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 . 'widgets/payment-form.php' );
180
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
181
-
182
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
183
-            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 . 'widgets/payment-form.php');
180
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
181
+
182
+        if (!class_exists('WPInv_EUVat')) {
183
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
184 184
         }
185 185
         
186
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
187
-        if ( !empty( $gateways ) ) {
188
-            foreach ( $gateways as $gateway ) {
189
-                if ( $gateway == 'manual' ) {
186
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
187
+        if (!empty($gateways)) {
188
+            foreach ($gateways as $gateway) {
189
+                if ($gateway == 'manual') {
190 190
                     continue;
191 191
                 }
192 192
                 
193 193
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
194 194
                 
195
-                if ( file_exists( $gateway_file ) ) {
196
-                    require_once( $gateway_file );
195
+                if (file_exists($gateway_file)) {
196
+                    require_once($gateway_file);
197 197
                 }
198 198
             }
199 199
         }
200
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
200
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
201 201
         
202
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
203
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
204
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
205
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
202
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
203
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
204
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
205
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
206 206
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
207
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
208
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
209
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
210
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
211
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
212
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
213
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
214
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
207
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
208
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
209
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
210
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
211
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
212
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
213
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
214
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
215 215
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
216 216
             // load the user class only on the users.php page
217 217
             global $pagenow;
218
-            if($pagenow=='users.php'){
218
+            if ($pagenow == 'users.php') {
219 219
                 new WPInv_Admin_Users();
220 220
             }
221 221
         }
222 222
 
223 223
         // Register cli commands
224
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
225
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
226
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
224
+        if (defined('WP_CLI') && WP_CLI) {
225
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
226
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
227 227
         }
228 228
         
229 229
         // include css inliner
230
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
231
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
230
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
231
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
232 232
         }
233 233
         
234
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
234
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
235 235
     }
236 236
     
237 237
     public function init() {
238 238
     }
239 239
     
240 240
     public function admin_init() {
241
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
241
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
242 242
     }
243 243
 
244 244
     public function activation_redirect() {
245 245
         // Bail if no activation redirect
246
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
246
+        if (!get_transient('_wpinv_activation_redirect')) {
247 247
             return;
248 248
         }
249 249
 
250 250
         // Delete the redirect transient
251
-        delete_transient( '_wpinv_activation_redirect' );
251
+        delete_transient('_wpinv_activation_redirect');
252 252
 
253 253
         // Bail if activating from network, or bulk
254
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
254
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
255 255
             return;
256 256
         }
257 257
 
258
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
258
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
259 259
         exit;
260 260
     }
261 261
     
262 262
     public function enqueue_scripts() {
263
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
263
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
264 264
         
265
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
266
-        wp_enqueue_style( 'wpinv_front_style' );
265
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
266
+        wp_enqueue_style('wpinv_front_style');
267 267
                
268 268
         // Register scripts
269
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
270
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  WPINV_VERSION );
269
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
270
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION);
271 271
 
272 272
         $localize                         = array();
273
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
274
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
273
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
274
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
275 275
         $localize['currency_symbol']      = wpinv_currency_symbol();
276 276
         $localize['currency_pos']         = wpinv_currency_position();
277 277
         $localize['thousand_sep']         = wpinv_thousands_separator();
278 278
         $localize['decimal_sep']          = wpinv_decimal_separator();
279 279
         $localize['decimals']             = wpinv_decimals();
280
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
280
+        $localize['txtComplete']          = __('Complete', 'invoicing');
281 281
         $localize['UseTaxes']             = wpinv_use_taxes();
282
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
282
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
283 283
 
284
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
284
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
285 285
         
286
-        wp_enqueue_script( 'jquery-blockui' );
286
+        wp_enqueue_script('jquery-blockui');
287 287
         $autofill_api = wpinv_get_option('address_autofill_api');
288 288
         $autofill_active = wpinv_get_option('address_autofill_active');
289
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
290
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
291
-                wp_dequeue_script( 'google-maps-api' );
289
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
290
+            if (wp_script_is('google-maps-api', 'enqueued')) {
291
+                wp_dequeue_script('google-maps-api');
292 292
             }
293
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
294
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
293
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
294
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
295 295
         }
296 296
 
297
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
298
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
297
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
298
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
299 299
 
300
-        wp_enqueue_script( 'wpinv-front-script' );
301
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
300
+        wp_enqueue_script('wpinv-front-script');
301
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
302 302
     }
303 303
 
304
-    public function admin_enqueue_scripts( $hook ) {
304
+    public function admin_enqueue_scripts($hook) {
305 305
         global $post, $pagenow;
306 306
         
307 307
         $post_type  = wpinv_admin_post_type();
308
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
309
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
308
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
309
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
310 310
 
311 311
         $jquery_ui_css = false;
312
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
312
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
313 313
             $jquery_ui_css = true;
314
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
314
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
315 315
             $jquery_ui_css = true;
316 316
         }
317
-        if ( $jquery_ui_css ) {
318
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
319
-            wp_enqueue_style( 'jquery-ui-css' );
317
+        if ($jquery_ui_css) {
318
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
319
+            wp_enqueue_style('jquery-ui-css');
320 320
         }
321 321
 
322
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
323
-        wp_enqueue_style( 'wpinv_meta_box_style' );
322
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
323
+        wp_enqueue_style('wpinv_meta_box_style');
324 324
         
325
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
326
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
327
-        wp_enqueue_style( 'wpinv_admin_style' );
325
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
326
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
327
+        wp_enqueue_style('wpinv_admin_style');
328 328
 
329
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
330
-        if ( $page == 'wpinv-subscriptions' ) {
331
-            wp_enqueue_script( 'jquery-ui-datepicker' );
329
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
330
+        if ($page == 'wpinv-subscriptions') {
331
+            wp_enqueue_script('jquery-ui-datepicker');
332 332
         }
333 333
         
334
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
335
-            wp_enqueue_script( 'jquery-ui-datepicker' );
334
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
335
+            wp_enqueue_script('jquery-ui-datepicker');
336 336
         }
337 337
 
338
-        wp_enqueue_style( 'wp-color-picker' );
339
-        wp_enqueue_script( 'wp-color-picker' );
338
+        wp_enqueue_style('wp-color-picker');
339
+        wp_enqueue_script('wp-color-picker');
340 340
         
341
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
341
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
342 342
 
343 343
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
344 344
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -349,20 +349,20 @@  discard block
 block discarded – undo
349 349
             }
350 350
         }
351 351
 
352
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
353
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
352
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
353
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
354 354
 
355
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
356
-        wp_enqueue_script( 'wpinv-admin-script' );
355
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
356
+        wp_enqueue_script('wpinv-admin-script');
357 357
         
358 358
         $localize                               = array();
359
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
360
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
361
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
362
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
363
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
364
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
365
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
359
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
360
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
361
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
362
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
363
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
364
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
365
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
366 366
         $localize['tax']                        = wpinv_tax_amount();
367 367
         $localize['discount']                   = wpinv_discount_amount();
368 368
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -370,95 +370,95 @@  discard block
 block discarded – undo
370 370
         $localize['thousand_sep']               = wpinv_thousands_separator();
371 371
         $localize['decimal_sep']                = wpinv_decimal_separator();
372 372
         $localize['decimals']                   = wpinv_decimals();
373
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
374
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
375
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
376
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
377
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
378
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
379
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
380
-        $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' );
381
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
382
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
383
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
384
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
385
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
386
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
387
-
388
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
389
-
390
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
373
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
374
+        $localize['status_publish']             = wpinv_status_nicename('publish');
375
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
376
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
377
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
378
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
379
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
380
+        $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');
381
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
382
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
383
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
384
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
385
+        $localize['action_edit']                = __('Edit', 'invoicing');
386
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
387
+
388
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
389
+
390
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
391 391
 
392 392
         // Load payment form scripts on our admin pages only.
393
-        if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) {
393
+        if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) {
394 394
 
395
-            wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
396
-            wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
397
-            wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
395
+            wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
396
+            wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
397
+            wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
398 398
 
399
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
400
-            wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
399
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
400
+            wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
401 401
         
402
-            wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
402
+            wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
403 403
                 'elements'      => $this->form_elements->get_elements(),
404
-                'form_elements' => $this->form_elements->get_form_elements( $post->ID ),
404
+                'form_elements' => $this->form_elements->get_form_elements($post->ID),
405 405
                 'all_items'     => $this->form_elements->get_published_items(),
406 406
                 'currency'      => wpinv_currency_symbol(),
407 407
                 'position'      => wpinv_currency_position(),
408 408
                 'decimals'      => (int) wpinv_decimals(),
409 409
                 'thousands_sep' => wpinv_thousands_separator(),
410 410
                 'decimals_sep'  => wpinv_decimal_separator(),
411
-                'form_items'    => $this->form_elements->get_form_items( $post->ID ),
412
-            ) );
411
+                'form_items'    => $this->form_elements->get_form_items($post->ID),
412
+            ));
413 413
 
414
-            wp_enqueue_script( 'wpinv-admin-payment-form-script' );
414
+            wp_enqueue_script('wpinv-admin-payment-form-script');
415 415
         }
416 416
 
417
-        if ( $page == 'wpinv-subscriptions' ) {
418
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
419
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
417
+        if ($page == 'wpinv-subscriptions') {
418
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
419
+            wp_enqueue_script('wpinv-sub-admin-script');
420 420
         }
421 421
 
422 422
     }
423 423
     
424
-    public function admin_body_class( $classes ) {
424
+    public function admin_body_class($classes) {
425 425
         global $pagenow, $post, $current_screen;
426 426
         
427
-        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' ) ) {
427
+        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')) {
428 428
             $classes .= ' wpinv-cpt';
429 429
         }
430 430
         
431
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
431
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
432 432
 
433
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
434
-        if ( $add_class ) {
435
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
433
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
434
+        if ($add_class) {
435
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
436 436
         }
437 437
         
438 438
         $settings_class = array();
439
-        if ( $page == 'wpinv-settings' ) {
440
-            if ( !empty( $_REQUEST['tab'] ) ) {
441
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
439
+        if ($page == 'wpinv-settings') {
440
+            if (!empty($_REQUEST['tab'])) {
441
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
442 442
             }
443 443
             
444
-            if ( !empty( $_REQUEST['section'] ) ) {
445
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
444
+            if (!empty($_REQUEST['section'])) {
445
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
446 446
             }
447 447
             
448
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
448
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
449 449
         }
450 450
         
451
-        if ( !empty( $settings_class ) ) {
452
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
451
+        if (!empty($settings_class)) {
452
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
453 453
         }
454 454
         
455 455
         $post_type = wpinv_admin_post_type();
456 456
 
457
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
457
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
458 458
             return $classes .= ' wpinv';
459 459
         }
460 460
         
461
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
461
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
462 462
             $classes .= ' wpi-editable-n';
463 463
         }
464 464
 
@@ -470,21 +470,21 @@  discard block
 block discarded – undo
470 470
     }
471 471
     
472 472
     public function wpinv_actions() {
473
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
474
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
473
+        if (isset($_REQUEST['wpi_action'])) {
474
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
475 475
         }
476 476
     }
477 477
     
478
-    public function pre_get_posts( $wp_query ) {
479
-        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() ) {
480
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
478
+    public function pre_get_posts($wp_query) {
479
+        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()) {
480
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
481 481
         }
482 482
         
483 483
         return $wp_query;
484 484
     }
485 485
     
486 486
     public function bp_invoicing_init() {
487
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
487
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
488 488
     }
489 489
 
490 490
 	/**
@@ -492,12 +492,12 @@  discard block
 block discarded – undo
492 492
 	 *
493 493
 	 */
494 494
 	public function register_widgets() {
495
-		register_widget( "WPInv_Checkout_Widget" );
496
-		register_widget( "WPInv_History_Widget" );
497
-		register_widget( "WPInv_Receipt_Widget" );
498
-		register_widget( "WPInv_Subscriptions_Widget" );
499
-		register_widget( "WPInv_Buy_Item_Widget" );
500
-        register_widget( "WPInv_Messages_Widget" );
501
-        register_widget( 'WPInv_Payment_Form_Widget' );
495
+		register_widget("WPInv_Checkout_Widget");
496
+		register_widget("WPInv_History_Widget");
497
+		register_widget("WPInv_Receipt_Widget");
498
+		register_widget("WPInv_Subscriptions_Widget");
499
+		register_widget("WPInv_Buy_Item_Widget");
500
+        register_widget("WPInv_Messages_Widget");
501
+        register_widget('WPInv_Payment_Form_Widget');
502 502
 	}
503 503
 }
504 504
\ No newline at end of file
Please login to merge, or discard this patch.
includes/data/sample-payment-form-items.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 return array(
14 14
 
15 15
     array(
16 16
 
17
-        'title'       => __( 'My Cool Item', 'invoicing' ),
17
+        'title'       => __('My Cool Item', 'invoicing'),
18 18
         'id'          => 'fxhnagzi',
19 19
         'price'       => '999.00',
20 20
         'recurring'   => false,
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
     array(
26 26
 
27
-        'title'       => __( 'Shipping Fee', 'invoicing' ),
27
+        'title'       => __('Shipping Fee', 'invoicing'),
28 28
         'id'          => 'rxnymibri',
29 29
         'price'       => '19.99',
30 30
         'recurring'   => false,
Please login to merge, or discard this patch.