Passed
Pull Request — master (#284)
by Brian
04:40
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/class-wpinv.php 1 patch
Spacing   +216 added lines, -216 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();
@@ -32,33 +32,33 @@  discard block
 block discarded – undo
32 32
     }
33 33
     
34 34
     public function define_constants() {
35
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
36
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
35
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
36
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
37 37
     }
38 38
     
39 39
     private function actions() {
40 40
         /* Internationalize the text strings used. */
41
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
41
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
42 42
         
43 43
         /* Perform actions on admin initialization. */
44
-        add_action( 'admin_init', array( &$this, 'admin_init') );
45
-        add_action( 'init', array( &$this, 'init' ), 3 );
46
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
44
+        add_action('admin_init', array(&$this, 'admin_init'));
45
+        add_action('init', array(&$this, 'init'), 3);
46
+        add_action('init', array(&$this, 'wpinv_actions'));
47 47
         
48
-        if ( class_exists( 'BuddyPress' ) ) {
49
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
48
+        if (class_exists('BuddyPress')) {
49
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
50 50
         }
51 51
 
52
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
53
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
52
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
53
+        add_action('widgets_init', array(&$this, 'register_widgets'));
54 54
 
55
-        if ( is_admin() ) {
56
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
57
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
58
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
55
+        if (is_admin()) {
56
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
57
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
58
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
59 59
 
60 60
         } else {
61
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
61
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
62 62
         }
63 63
         
64 64
         /**
@@ -68,28 +68,28 @@  discard block
 block discarded – undo
68 68
          *
69 69
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
70 70
          */
71
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
71
+        do_action_ref_array('wpinv_actions', array(&$this));
72 72
 
73
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
73
+        add_action('admin_init', array(&$this, 'activation_redirect'));
74 74
     }
75 75
 
76 76
     /**
77 77
      * Maybe show the AyeCode Connect Notice.
78 78
      */
79
-    public function init_ayecode_connect_helper(){
79
+    public function init_ayecode_connect_helper() {
80 80
         // AyeCode Connect notice
81
-        if ( is_admin() ){
81
+        if (is_admin()) {
82 82
             // set the strings so they can be translated
83 83
             $strings = array(
84
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
85
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
86
-                '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>" ),
87
-                'connect_button'    => __("Connect Site","invoicing"),
88
-                'connecting_button'    => __("Connecting...","invoicing"),
89
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
90
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
84
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
85
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
86
+                '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>"),
87
+                'connect_button'    => __("Connect Site", "invoicing"),
88
+                'connecting_button'    => __("Connecting...", "invoicing"),
89
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
90
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
91 91
             );
92
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
92
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
93 93
         }
94 94
     }
95 95
     
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
         /* Internationalize the text strings used. */
98 98
         $this->load_textdomain();
99 99
 
100
-        do_action( 'wpinv_loaded' );
100
+        do_action('wpinv_loaded');
101 101
 
102 102
         // Fix oxygen page builder conflict
103
-        if ( function_exists( 'ct_css_output' ) ) {
103
+        if (function_exists('ct_css_output')) {
104 104
             wpinv_oxygen_fix_conflict();
105 105
         }
106 106
     }
@@ -110,230 +110,230 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @since 1.0
112 112
      */
113
-    public function load_textdomain( $locale = NULL ) {
114
-        if ( empty( $locale ) ) {
115
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
113
+    public function load_textdomain($locale = NULL) {
114
+        if (empty($locale)) {
115
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
116 116
         }
117 117
 
118
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
118
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
119 119
         
120
-        unload_textdomain( 'invoicing' );
121
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
122
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
120
+        unload_textdomain('invoicing');
121
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
122
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
123 123
         
124 124
         /**
125 125
          * Define language constants.
126 126
          */
127
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
127
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
128 128
     }
129 129
         
130 130
     public function includes() {
131 131
         global $wpinv_options;
132 132
         
133
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
133
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
134 134
         $wpinv_options = wpinv_get_settings();
135 135
         
136
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
137
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
138
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
140
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
142
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
143
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
144
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
145
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
146
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
147
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
148
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
149
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
150
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
151
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
152
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
153
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
154
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
155
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
156
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
157
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
158
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
160
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
163
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
164
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
165
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
166
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
168
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
169
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
170
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
171
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
172
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
173
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
174
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
175
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
176
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
177
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
178
-
179
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
180
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
136
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
137
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
138
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
140
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
142
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
143
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
144
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
145
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
146
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
147
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
148
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
149
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
150
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
151
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
152
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
153
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
154
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
155
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
156
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
157
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
158
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
160
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
163
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
164
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
165
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
166
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
168
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
169
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
170
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
171
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
172
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
173
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
174
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
175
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
176
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
177
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
178
+
179
+        if (!class_exists('WPInv_EUVat')) {
180
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
181 181
         }
182 182
         
183
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
184
-        if ( !empty( $gateways ) ) {
185
-            foreach ( $gateways as $gateway ) {
186
-                if ( $gateway == 'manual' ) {
183
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
184
+        if (!empty($gateways)) {
185
+            foreach ($gateways as $gateway) {
186
+                if ($gateway == 'manual') {
187 187
                     continue;
188 188
                 }
189 189
                 
190 190
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
191 191
                 
192
-                if ( file_exists( $gateway_file ) ) {
193
-                    require_once( $gateway_file );
192
+                if (file_exists($gateway_file)) {
193
+                    require_once($gateway_file);
194 194
                 }
195 195
             }
196 196
         }
197
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
197
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
198 198
         
199
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
200
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
201
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
202
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
199
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
200
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
201
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
202
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
203 203
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
204
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
205
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
206
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
207
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
208
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
209
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
210
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
204
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
205
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
206
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
207
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
208
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
209
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
210
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
211 211
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
212 212
             // load the user class only on the users.php page
213 213
             global $pagenow;
214
-            if($pagenow=='users.php'){
214
+            if ($pagenow == 'users.php') {
215 215
                 new WPInv_Admin_Users();
216 216
             }
217 217
         }
218 218
 
219 219
         // Register cli commands
220
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
221
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
222
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
220
+        if (defined('WP_CLI') && WP_CLI) {
221
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
222
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
223 223
         }
224 224
         
225 225
         // include css inliner
226
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
227
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
226
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
227
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
228 228
         }
229 229
         
230
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
230
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
231 231
     }
232 232
     
233 233
     public function init() {
234 234
     }
235 235
     
236 236
     public function admin_init() {
237
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
237
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
238 238
     }
239 239
 
240 240
     public function activation_redirect() {
241 241
         // Bail if no activation redirect
242
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
242
+        if (!get_transient('_wpinv_activation_redirect')) {
243 243
             return;
244 244
         }
245 245
 
246 246
         // Delete the redirect transient
247
-        delete_transient( '_wpinv_activation_redirect' );
247
+        delete_transient('_wpinv_activation_redirect');
248 248
 
249 249
         // Bail if activating from network, or bulk
250
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
250
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
251 251
             return;
252 252
         }
253 253
 
254
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
254
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
255 255
         exit;
256 256
     }
257 257
     
258 258
     public function enqueue_scripts() {
259
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
259
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
260 260
         
261
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
262
-        wp_enqueue_style( 'wpinv_front_style' );
261
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
262
+        wp_enqueue_style('wpinv_front_style');
263 263
                
264 264
         // Register scripts
265
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
266
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  WPINV_VERSION );
265
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
266
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION);
267 267
 
268 268
         $localize                         = array();
269
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
270
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
269
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
270
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
271 271
         $localize['currency_symbol']      = wpinv_currency_symbol();
272 272
         $localize['currency_pos']         = wpinv_currency_position();
273 273
         $localize['thousand_sep']         = wpinv_thousands_separator();
274 274
         $localize['decimal_sep']          = wpinv_decimal_separator();
275 275
         $localize['decimals']             = wpinv_decimals();
276
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
276
+        $localize['txtComplete']          = __('Complete', 'invoicing');
277 277
         $localize['UseTaxes']             = wpinv_use_taxes();
278
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
278
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
279 279
 
280
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
280
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
281 281
         
282
-        wp_enqueue_script( 'jquery-blockui' );
282
+        wp_enqueue_script('jquery-blockui');
283 283
         $autofill_api = wpinv_get_option('address_autofill_api');
284 284
         $autofill_active = wpinv_get_option('address_autofill_active');
285
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
286
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
287
-                wp_dequeue_script( 'google-maps-api' );
285
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
286
+            if (wp_script_is('google-maps-api', 'enqueued')) {
287
+                wp_dequeue_script('google-maps-api');
288 288
             }
289
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
290
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
289
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
290
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
291 291
         }
292 292
 
293
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
294
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
293
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
294
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
295 295
 
296
-        wp_enqueue_script( 'wpinv-front-script' );
297
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
296
+        wp_enqueue_script('wpinv-front-script');
297
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
298 298
     }
299 299
 
300 300
     public function admin_enqueue_scripts() {
301 301
         global $post, $pagenow;
302 302
         
303 303
         $post_type  = wpinv_admin_post_type();
304
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
305
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
304
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
305
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
306 306
 
307 307
         $jquery_ui_css = false;
308
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
308
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
309 309
             $jquery_ui_css = true;
310
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
310
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
311 311
             $jquery_ui_css = true;
312 312
         }
313
-        if ( $jquery_ui_css ) {
314
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
315
-            wp_enqueue_style( 'jquery-ui-css' );
313
+        if ($jquery_ui_css) {
314
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
315
+            wp_enqueue_style('jquery-ui-css');
316 316
         }
317 317
 
318
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
319
-        wp_enqueue_style( 'wpinv_meta_box_style' );
318
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
319
+        wp_enqueue_style('wpinv_meta_box_style');
320 320
         
321
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
322
-        wp_enqueue_style( 'wpinv_admin_style' );
321
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
322
+        wp_enqueue_style('wpinv_admin_style');
323 323
 
324
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
325
-        if ( $page == 'wpinv-subscriptions' ) {
326
-            wp_enqueue_script( 'jquery-ui-datepicker' );
324
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
325
+        if ($page == 'wpinv-subscriptions') {
326
+            wp_enqueue_script('jquery-ui-datepicker');
327 327
         }
328 328
         
329
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
330
-            wp_enqueue_script( 'jquery-ui-datepicker' );
329
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
330
+            wp_enqueue_script('jquery-ui-datepicker');
331 331
         }
332 332
 
333
-        wp_enqueue_style( 'wp-color-picker' );
334
-        wp_enqueue_script( 'wp-color-picker' );
333
+        wp_enqueue_style('wp-color-picker');
334
+        wp_enqueue_script('wp-color-picker');
335 335
         
336
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
336
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
337 337
 
338 338
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
339 339
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -344,20 +344,20 @@  discard block
 block discarded – undo
344 344
             }
345 345
         }
346 346
 
347
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
348
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
347
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
348
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
349 349
 
350
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
351
-        wp_enqueue_script( 'wpinv-admin-script' );
350
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
351
+        wp_enqueue_script('wpinv-admin-script');
352 352
         
353 353
         $localize                               = array();
354
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
355
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
356
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
357
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
358
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
359
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
360
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
354
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
355
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
356
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
357
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
358
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
359
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
360
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
361 361
         $localize['tax']                        = wpinv_tax_amount();
362 362
         $localize['discount']                   = wpinv_discount_amount();
363 363
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -365,69 +365,69 @@  discard block
 block discarded – undo
365 365
         $localize['thousand_sep']               = wpinv_thousands_separator();
366 366
         $localize['decimal_sep']                = wpinv_decimal_separator();
367 367
         $localize['decimals']                   = wpinv_decimals();
368
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
369
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
370
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
371
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
372
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
373
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
374
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
375
-        $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' );
376
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
377
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
378
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
379
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
380
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
381
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
382
-
383
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
384
-
385
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
386
-
387
-        if ( $page == 'wpinv-subscriptions' ) {
388
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
389
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
368
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
369
+        $localize['status_publish']             = wpinv_status_nicename('publish');
370
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
371
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
372
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
373
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
374
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
375
+        $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');
376
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
377
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
378
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
379
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
380
+        $localize['action_edit']                = __('Edit', 'invoicing');
381
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
382
+
383
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
384
+
385
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
386
+
387
+        if ($page == 'wpinv-subscriptions') {
388
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
389
+            wp_enqueue_script('wpinv-sub-admin-script');
390 390
         }
391 391
     }
392 392
     
393
-    public function admin_body_class( $classes ) {
393
+    public function admin_body_class($classes) {
394 394
         global $pagenow, $post, $current_screen;
395 395
         
396
-        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' ) ) {
396
+        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')) {
397 397
             $classes .= ' wpinv-cpt';
398 398
         }
399 399
         
400
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
400
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
401 401
 
402
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
403
-        if ( $add_class ) {
404
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
402
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
403
+        if ($add_class) {
404
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
405 405
         }
406 406
         
407 407
         $settings_class = array();
408
-        if ( $page == 'wpinv-settings' ) {
409
-            if ( !empty( $_REQUEST['tab'] ) ) {
410
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
408
+        if ($page == 'wpinv-settings') {
409
+            if (!empty($_REQUEST['tab'])) {
410
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
411 411
             }
412 412
             
413
-            if ( !empty( $_REQUEST['section'] ) ) {
414
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
413
+            if (!empty($_REQUEST['section'])) {
414
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
415 415
             }
416 416
             
417
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
417
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
418 418
         }
419 419
         
420
-        if ( !empty( $settings_class ) ) {
421
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
420
+        if (!empty($settings_class)) {
421
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
422 422
         }
423 423
         
424 424
         $post_type = wpinv_admin_post_type();
425 425
 
426
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
426
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
427 427
             return $classes .= ' wpinv';
428 428
         }
429 429
         
430
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
430
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
431 431
             $classes .= ' wpi-editable-n';
432 432
         }
433 433
 
@@ -439,21 +439,21 @@  discard block
 block discarded – undo
439 439
     }
440 440
     
441 441
     public function wpinv_actions() {
442
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
443
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
442
+        if (isset($_REQUEST['wpi_action'])) {
443
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
444 444
         }
445 445
     }
446 446
     
447
-    public function pre_get_posts( $wp_query ) {
448
-        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() ) {
449
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
447
+    public function pre_get_posts($wp_query) {
448
+        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()) {
449
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
450 450
         }
451 451
         
452 452
         return $wp_query;
453 453
     }
454 454
     
455 455
     public function bp_invoicing_init() {
456
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
456
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
457 457
     }
458 458
 
459 459
 	/**
@@ -461,11 +461,11 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 */
463 463
 	public function register_widgets() {
464
-		register_widget( "WPInv_Checkout_Widget" );
465
-		register_widget( "WPInv_History_Widget" );
466
-		register_widget( "WPInv_Receipt_Widget" );
467
-		register_widget( "WPInv_Subscriptions_Widget" );
468
-		register_widget( "WPInv_Buy_Item_Widget" );
469
-		register_widget( "WPInv_Messages_Widget" );
464
+		register_widget("WPInv_Checkout_Widget");
465
+		register_widget("WPInv_History_Widget");
466
+		register_widget("WPInv_Receipt_Widget");
467
+		register_widget("WPInv_Subscriptions_Widget");
468
+		register_widget("WPInv_Buy_Item_Widget");
469
+		register_widget("WPInv_Messages_Widget");
470 470
 	}
471 471
 }
472 472
\ No newline at end of file
Please login to merge, or discard this patch.