Passed
Push — master ( 99ae46...ecf53c )
by Brian
05:15
created
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -225,37 +225,37 @@  discard block
 block discarded – undo
225 225
 
226 226
                                 if ( empty( $states ) ) {
227 227
 
228
-								aui()->input(
229
-								array(
230
-								'type'        => 'text',
231
-								'id'          => 'wpinv_state',
232
-								'name'        => 'wpinv_state',
233
-								'label'       => __( 'State', 'invoicing' ),
234
-								'label_type'  => 'vertical',
235
-								'placeholder' => '',
236
-								'class'       => 'form-control-sm',
237
-								'value'       => $invoice->get_state( 'edit' ),
238
-								),
239
-								true
240
-							);
228
+                                aui()->input(
229
+                                array(
230
+                                'type'        => 'text',
231
+                                'id'          => 'wpinv_state',
232
+                                'name'        => 'wpinv_state',
233
+                                'label'       => __( 'State', 'invoicing' ),
234
+                                'label_type'  => 'vertical',
235
+                                'placeholder' => '',
236
+                                'class'       => 'form-control-sm',
237
+                                'value'       => $invoice->get_state( 'edit' ),
238
+                                ),
239
+                                true
240
+                            );
241 241
 
242 242
                                 } else {
243 243
 
244
-								aui()->select(
245
-								array(
246
-								'id'               => 'wpinv_state',
247
-								'name'             => 'wpinv_state',
248
-								'label'            => __( 'State', 'invoicing' ),
249
-								'label_type'       => 'vertical',
250
-								'placeholder'      => __( 'Select a state', 'invoicing' ),
251
-								'class'            => 'form-control-sm',
252
-								'value'            => $invoice->get_state( 'edit' ),
253
-								'options'          => $states,
254
-								'data-allow-clear' => 'false',
255
-								'select2'          => true,
256
-								),
257
-								true
258
-								);
244
+                                aui()->select(
245
+                                array(
246
+                                'id'               => 'wpinv_state',
247
+                                'name'             => 'wpinv_state',
248
+                                'label'            => __( 'State', 'invoicing' ),
249
+                                'label_type'       => 'vertical',
250
+                                'placeholder'      => __( 'Select a state', 'invoicing' ),
251
+                                'class'            => 'form-control-sm',
252
+                                'value'            => $invoice->get_state( 'edit' ),
253
+                                'options'          => $states,
254
+                                'data-allow-clear' => 'false',
255
+                                'select2'          => true,
256
+                                ),
257
+                                true
258
+                                );
259 259
 
260 260
                                 }
261 261
 
@@ -381,18 +381,18 @@  discard block
 block discarded – undo
381 381
     }
382 382
 
383 383
     /**
384
-	 * Save meta box data.
385
-	 *
386
-	 * @param int $post_id
387
-	 */
388
-	public static function save( $post_id ) {
384
+     * Save meta box data.
385
+     *
386
+     * @param int $post_id
387
+     */
388
+    public static function save( $post_id ) {
389 389
 
390 390
         // Prepare the invoice.
391 391
         $invoice = new WPInv_Invoice( $post_id );
392 392
 
393 393
         // Load new data.
394 394
         $invoice->set_props(
395
-			array(
395
+            array(
396 396
                 'template'       => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
397 397
                 'email_cc'       => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
398 398
                 'disable_taxes'  => ! empty( $_POST['disable_taxes'] ),
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
                 'due_date'       => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
416 416
                 'number'         => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
417 417
                 'status'         => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
418
-			)
418
+            )
419 419
         );
420 420
 
421 421
         // Discount code.
@@ -471,6 +471,6 @@  discard block
 block discarded – undo
471 471
         }
472 472
 
473 473
         // Fires after an invoice is saved.
474
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
475
-	}
474
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
475
+    }
476 476
 }
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice  = new WPInv_Invoice( $post );
28
-        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-        $customer = new WP_User( $customer );
30
-        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+        $invoice  = new WPInv_Invoice($post);
28
+        $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+        $customer = new WP_User($customer);
30
+        $display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
         ?>
34 34
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
                         <div class="col-12 col-sm-6">
44 44
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
45 45
                                 <div>
46
-                                    <label for="post_author_override"><?php esc_html_e( 'Customer', 'invoicing' ); ?></label>
46
+                                    <label for="post_author_override"><?php esc_html_e('Customer', 'invoicing'); ?></label>
47 47
                                 </div>
48 48
                                 <div>
49
-                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
50
-                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>)
49
+                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
50
+                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>)
51 51
                                     </select>
52 52
                                 </div>
53 53
                             </div>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                                             'type'        => 'text',
61 61
                                             'id'          => 'getpaid-invoice-new-user-email',
62 62
                                             'name'        => 'wpinv_email',
63
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
63
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
64 64
                                             'label_type'  => 'vertical',
65 65
                                             'placeholder' => '[email protected]',
66 66
                                             'class'       => 'form-control-sm',
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
                             </div>
72 72
                         </div>
73 73
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
74
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
74
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
75 75
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
76 76
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
77
-                                    <?php esc_html_e( 'Fill User Details', 'invoicing' ); ?>
77
+                                    <?php esc_html_e('Fill User Details', 'invoicing'); ?>
78 78
                                 </a>
79 79
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
80 80
                                     <i aria-hidden="true" class="fa fa-plus"></i>
81
-                                    <?php esc_html_e( 'Add New User', 'invoicing' ); ?>
81
+                                    <?php esc_html_e('Add New User', 'invoicing'); ?>
82 82
                                 </a>
83 83
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
84 84
                                     <i aria-hidden="true" class="fa fa-close"></i>
85
-                                    <?php esc_html_e( 'Cancel', 'invoicing' ); ?>
85
+                                    <?php esc_html_e('Cancel', 'invoicing'); ?>
86 86
                                 </a>
87 87
                             <?php endif; ?>
88 88
                         </div>
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
                                         'type'        => 'text',
96 96
                                         'id'          => 'wpinv_first_name',
97 97
                                         'name'        => 'wpinv_first_name',
98
-                                        'label'       => __( 'First Name', 'invoicing' ),
98
+                                        'label'       => __('First Name', 'invoicing'),
99 99
                                         'label_type'  => 'vertical',
100 100
                                         'placeholder' => '',
101 101
                                         'class'       => 'form-control-sm',
102
-                                        'value'       => $invoice->get_first_name( 'edit' ),
102
+                                        'value'       => $invoice->get_first_name('edit'),
103 103
                                     ),
104 104
                                     true
105 105
                                 );
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
                                         'type'        => 'text',
113 113
                                         'id'          => 'wpinv_last_name',
114 114
                                         'name'        => 'wpinv_last_name',
115
-                                        'label'       => __( 'Last Name', 'invoicing' ),
115
+                                        'label'       => __('Last Name', 'invoicing'),
116 116
                                         'label_type'  => 'vertical',
117 117
                                         'placeholder' => '',
118 118
                                         'class'       => 'form-control-sm',
119
-                                        'value'       => $invoice->get_last_name( 'edit' ),
119
+                                        'value'       => $invoice->get_last_name('edit'),
120 120
                                     ),
121 121
                                     true
122 122
                                 );
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
                                         'type'        => 'text',
133 133
                                         'id'          => 'wpinv_company',
134 134
                                         'name'        => 'wpinv_company',
135
-                                        'label'       => __( 'Company', 'invoicing' ),
135
+                                        'label'       => __('Company', 'invoicing'),
136 136
                                         'label_type'  => 'vertical',
137 137
                                         'placeholder' => '',
138 138
                                         'class'       => 'form-control-sm',
139
-                                        'value'       => $invoice->get_company( 'edit' ),
139
+                                        'value'       => $invoice->get_company('edit'),
140 140
                                     ),
141 141
                                     true
142 142
                                 );
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
                                         'type'        => 'text',
150 150
                                         'id'          => 'wpinv_vat_number',
151 151
                                         'name'        => 'wpinv_vat_number',
152
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
152
+                                        'label'       => __('Vat Number', 'invoicing'),
153 153
                                         'label_type'  => 'vertical',
154 154
                                         'placeholder' => '',
155 155
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
156
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
156
+                                        'value'       => $invoice->get_vat_number('edit'),
157 157
                                     ),
158 158
                                     true
159 159
                                 );
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
                                         'type'        => 'text',
170 170
                                         'id'          => 'wpinv_address',
171 171
                                         'name'        => 'wpinv_address',
172
-                                        'label'       => __( 'Address', 'invoicing' ),
172
+                                        'label'       => __('Address', 'invoicing'),
173 173
                                         'label_type'  => 'vertical',
174 174
                                         'placeholder' => '',
175 175
                                         'class'       => 'form-control-sm',
176
-                                        'value'       => $invoice->get_address( 'edit' ),
176
+                                        'value'       => $invoice->get_address('edit'),
177 177
                                     ),
178 178
                                     true
179 179
                                 );
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
                                         'type'        => 'text',
187 187
                                         'id'          => 'wpinv_city',
188 188
                                         'name'        => 'wpinv_city',
189
-                                        'label'       => __( 'City', 'invoicing' ),
189
+                                        'label'       => __('City', 'invoicing'),
190 190
                                         'label_type'  => 'vertical',
191 191
                                         'placeholder' => '',
192 192
                                         'class'       => 'form-control-sm',
193
-                                        'value'       => $invoice->get_city( 'edit' ),
193
+                                        'value'       => $invoice->get_city('edit'),
194 194
                                     ),
195 195
                                     true
196 196
                                 );
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
                                     array(
206 206
                                         'id'               => 'wpinv_country',
207 207
                                         'name'             => 'wpinv_country',
208
-                                        'label'            => __( 'Country', 'invoicing' ),
208
+                                        'label'            => __('Country', 'invoicing'),
209 209
                                         'label_type'       => 'vertical',
210
-                                        'placeholder'      => __( 'Choose a country', 'invoicing' ),
210
+                                        'placeholder'      => __('Choose a country', 'invoicing'),
211 211
                                         'class'            => 'form-control-sm getpaid-recalculate-prices-on-change',
212
-                                        'value'            => $invoice->get_country( 'edit' ),
212
+                                        'value'            => $invoice->get_country('edit'),
213 213
                                         'options'          => wpinv_get_country_list(),
214 214
                                         'data-allow-clear' => 'false',
215 215
                                         'select2'          => true,
@@ -221,20 +221,20 @@  discard block
 block discarded – undo
221 221
                         <div class="col-12 col-sm-6">
222 222
                             <?php
223 223
 
224
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
224
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
225 225
 
226
-                                if ( empty( $states ) ) {
226
+                                if (empty($states)) {
227 227
 
228 228
 								aui()->input(
229 229
 								array(
230 230
 								'type'        => 'text',
231 231
 								'id'          => 'wpinv_state',
232 232
 								'name'        => 'wpinv_state',
233
-								'label'       => __( 'State', 'invoicing' ),
233
+								'label'       => __('State', 'invoicing'),
234 234
 								'label_type'  => 'vertical',
235 235
 								'placeholder' => '',
236 236
 								'class'       => 'form-control-sm',
237
-								'value'       => $invoice->get_state( 'edit' ),
237
+								'value'       => $invoice->get_state('edit'),
238 238
 								),
239 239
 								true
240 240
 							);
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 								array(
246 246
 								'id'               => 'wpinv_state',
247 247
 								'name'             => 'wpinv_state',
248
-								'label'            => __( 'State', 'invoicing' ),
248
+								'label'            => __('State', 'invoicing'),
249 249
 								'label_type'       => 'vertical',
250
-								'placeholder'      => __( 'Select a state', 'invoicing' ),
250
+								'placeholder'      => __('Select a state', 'invoicing'),
251 251
 								'class'            => 'form-control-sm',
252
-								'value'            => $invoice->get_state( 'edit' ),
252
+								'value'            => $invoice->get_state('edit'),
253 253
 								'options'          => $states,
254 254
 								'data-allow-clear' => 'false',
255 255
 								'select2'          => true,
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
                                         'type'        => 'text',
272 272
                                         'id'          => 'wpinv_zip',
273 273
                                         'name'        => 'wpinv_zip',
274
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
274
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
275 275
                                         'label_type'  => 'vertical',
276 276
                                         'placeholder' => '',
277 277
                                         'class'       => 'form-control-sm',
278
-                                        'value'       => $invoice->get_zip( 'edit' ),
278
+                                        'value'       => $invoice->get_zip('edit'),
279 279
                                     ),
280 280
                                     true
281 281
                                 );
@@ -288,11 +288,11 @@  discard block
 block discarded – undo
288 288
                                         'type'        => 'text',
289 289
                                         'id'          => 'wpinv_phone',
290 290
                                         'name'        => 'wpinv_phone',
291
-                                        'label'       => __( 'Phone', 'invoicing' ),
291
+                                        'label'       => __('Phone', 'invoicing'),
292 292
                                         'label_type'  => 'vertical',
293 293
                                         'placeholder' => '',
294 294
                                         'class'       => 'form-control-sm',
295
-                                        'value'       => $invoice->get_phone( 'edit' ),
295
+                                        'value'       => $invoice->get_phone('edit'),
296 296
                                     ),
297 297
                                     true
298 298
                                 );
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
                         </div>
301 301
                     </div>
302 302
 
303
-                    <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?>
304
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
303
+                    <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?>
304
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
305 305
 
306 306
                         <div class="row">
307 307
                             <div class="col-12 col-sm-6">
@@ -310,14 +310,14 @@  discard block
 block discarded – undo
310 310
                                         array(
311 311
                                             'id'          => 'wpinv_template',
312 312
                                             'name'        => 'wpinv_template',
313
-                                            'label'       => __( 'Template', 'invoicing' ),
313
+                                            'label'       => __('Template', 'invoicing'),
314 314
                                             'label_type'  => 'vertical',
315
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
315
+                                            'placeholder' => __('Choose a template', 'invoicing'),
316 316
                                             'class'       => 'form-control-sm',
317
-                                            'value'       => $invoice->get_template( 'edit' ),
317
+                                            'value'       => $invoice->get_template('edit'),
318 318
                                             'options'     => array(
319
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
320
-                                                'hours'    => __( 'Hours', 'invoicing' ),
319
+                                                'quantity' => __('Quantity', 'invoicing'),
320
+                                                'hours'    => __('Hours', 'invoicing'),
321 321
                                                 //'amount'   => __( 'Amount Only', 'invoicing' ),
322 322
                                             ),
323 323
                                             'data-allow-clear' => 'false',
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
                                         array(
336 336
                                             'id'          => 'wpinv_currency',
337 337
                                             'name'        => 'wpinv_currency',
338
-                                            'label'       => __( 'Currency', 'invoicing' ),
338
+                                            'label'       => __('Currency', 'invoicing'),
339 339
                                             'label_type'  => 'vertical',
340
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
340
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
341 341
                                             'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
342
-                                            'value'       => $invoice->get_currency( 'edit' ),
342
+                                            'value'       => $invoice->get_currency('edit'),
343 343
                                             'required'    => false,
344 344
                                             'data-allow-clear' => 'false',
345 345
                                             'select2'     => true,
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
                             </div>
353 353
                         </div>
354 354
 
355
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
355
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
356 356
                     <?php endif; ?>
357 357
 
358 358
                     <div class="row">
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
                                         'type'        => 'text',
364 364
                                         'id'          => 'wpinv_company_id',
365 365
                                         'name'        => 'wpinv_company_id',
366
-                                        'label'       => __( 'Company ID', 'invoicing' ),
366
+                                        'label'       => __('Company ID', 'invoicing'),
367 367
                                         'label_type'  => 'vertical',
368 368
                                         'placeholder' => '',
369 369
                                         'class'       => 'form-control-sm',
370
-                                        'value'       => $invoice->get_company_id( 'edit' ),
370
+                                        'value'       => $invoice->get_company_id('edit'),
371 371
                                     ),
372 372
                                     true
373 373
                                 );
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                         </div>
376 376
                     </div>
377 377
 
378
-                    <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
378
+                    <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
379 379
             </div>
380 380
         <?php
381 381
     }
@@ -385,51 +385,51 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
 	 * @param int $post_id
387 387
 	 */
388
-	public static function save( $post_id ) {
388
+	public static function save($post_id) {
389 389
 
390 390
         // Prepare the invoice.
391
-        $invoice = new WPInv_Invoice( $post_id );
391
+        $invoice = new WPInv_Invoice($post_id);
392 392
 
393 393
         // Load new data.
394 394
         $invoice->set_props(
395 395
 			array(
396
-                'template'       => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
397
-                'email_cc'       => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
398
-                'disable_taxes'  => ! empty( $_POST['disable_taxes'] ),
399
-                'currency'       => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
400
-                'gateway'        => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
401
-                'address'        => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
402
-                'vat_number'     => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
403
-                'company'        => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
404
-                'company_id'     => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
405
-                'zip'            => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
406
-                'state'          => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
407
-                'city'           => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
408
-                'country'        => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
409
-                'phone'          => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
410
-                'first_name'     => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
411
-                'last_name'      => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
412
-                'author'         => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
413
-                'date_created'   => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
414
-                'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
415
-                'due_date'       => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
416
-                'number'         => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
417
-                'status'         => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
396
+                'template'       => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
397
+                'email_cc'       => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
398
+                'disable_taxes'  => !empty($_POST['disable_taxes']),
399
+                'currency'       => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
400
+                'gateway'        => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null,
401
+                'address'        => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
402
+                'vat_number'     => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
403
+                'company'        => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
404
+                'company_id'     => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null,
405
+                'zip'            => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
406
+                'state'          => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
407
+                'city'           => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
408
+                'country'        => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
409
+                'phone'          => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
410
+                'first_name'     => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
411
+                'last_name'      => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
412
+                'author'         => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
413
+                'date_created'   => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
414
+                'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null,
415
+                'due_date'       => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
416
+                'number'         => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
417
+                'status'         => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
418 418
 			)
419 419
         );
420 420
 
421 421
         // Discount code.
422
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
422
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
423 423
 
424
-            if ( isset( $_POST['wpinv_discount_code'] ) ) {
425
-                $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
424
+            if (isset($_POST['wpinv_discount_code'])) {
425
+                $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code']));
426 426
             }
427 427
 
428
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
429
-            if ( $discount->exists() ) {
430
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
428
+            $discount = new WPInv_Discount($invoice->get_discount_code());
429
+            if ($discount->exists()) {
430
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
431 431
             } else {
432
-                $invoice->remove_discount( 'discount_code' );
432
+                $invoice->remove_discount('discount_code');
433 433
             }
434 434
 
435 435
             // Recalculate totals.
@@ -438,16 +438,16 @@  discard block
 block discarded – undo
438 438
         }
439 439
 
440 440
         // If we're creating a new user...
441
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
441
+        if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) {
442 442
 
443 443
             // Attempt to create the user.
444
-            $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) );
444
+            $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])));
445 445
 
446 446
             // If successful, update the invoice author.
447
-            if ( is_numeric( $user ) ) {
448
-                $invoice->set_author( $user );
447
+            if (is_numeric($user)) {
448
+                $invoice->set_author($user);
449 449
             } else {
450
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
450
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
451 451
             }
452 452
         }
453 453
 
@@ -461,16 +461,16 @@  discard block
 block discarded – undo
461 461
         $GLOBALS['wpinv_skip_invoice_notification'] = false;
462 462
 
463 463
         // (Maybe) send new user notification.
464
-        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
465
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
466
-            wp_send_new_user_notifications( $user, 'user' );
464
+        $should_send_notification = wpinv_get_option('disable_new_user_emails');
465
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
466
+            wp_send_new_user_notifications($user, 'user');
467 467
         }
468 468
 
469
-        if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
470
-            getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
469
+        if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) {
470
+            getpaid()->get('invoice_emails')->user_invoice($invoice, true);
471 471
         }
472 472
 
473 473
         // Fires after an invoice is saved.
474
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
474
+		do_action('wpinv_invoice_metabox_saved', $invoice);
475 475
 	}
476 476
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -16,82 +16,82 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Items {
18 18
 
19
-    public static function get_columns( $invoice ) {
19
+    public static function get_columns($invoice) {
20 20
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
21 21
         $columns            = array(
22
-            'id'     => __( 'ID', 'invoicing' ),
23
-            'title'  => __( 'Item', 'invoicing' ),
22
+            'id'     => __('ID', 'invoicing'),
23
+            'title'  => __('Item', 'invoicing'),
24 24
             'price'  => sprintf(
25 25
                 '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span>
26 26
                 <span class="getpaid-hide-if-hours hide-if-amount">%s</span>
27 27
                 <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>',
28
-                __( 'Amount', 'invoicing' ),
29
-                __( 'Price', 'invoicing' ),
30
-                __( 'Rate', 'invoicing' )
28
+                __('Amount', 'invoicing'),
29
+                __('Price', 'invoicing'),
30
+                __('Rate', 'invoicing')
31 31
             ),
32 32
             'qty'    => sprintf(
33 33
                 '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>',
34
-                __( 'Quantity', 'invoicing' ),
35
-                __( 'Hours', 'invoicing' )
34
+                __('Quantity', 'invoicing'),
35
+                __('Hours', 'invoicing')
36 36
             ),
37
-            'total'  => __( 'Total', 'invoicing' ),
38
-            'tax'    => __( 'Tax (%)', 'invoicing' ),
37
+            'total'  => __('Total', 'invoicing'),
38
+            'tax'    => __('Tax (%)', 'invoicing'),
39 39
             'action' => '',
40 40
         );
41 41
 
42
-        if ( ! $use_taxes ) {
43
-            unset( $columns['tax'] );
42
+        if (!$use_taxes) {
43
+            unset($columns['tax']);
44 44
         }
45 45
 
46 46
         return $columns;
47 47
     }
48 48
 
49
-    public static function output( $post, $invoice = false ) {
49
+    public static function output($post, $invoice = false) {
50 50
 
51
-        if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) {
52
-            return self::output2( $post );
51
+        if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) {
52
+            return self::output2($post);
53 53
         }
54 54
 
55
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
56
-        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id );
55
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
56
+        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id);
57 57
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
58
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
59
-        $columns            = self::get_columns( $invoice );
60
-        $cols               = count( $columns );
58
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
59
+        $columns            = self::get_columns($invoice);
60
+        $cols               = count($columns);
61 61
         $class              = '';
62 62
 
63
-        unset( $item_types['adv'] );
64
-        unset( $item_types['package'] );
63
+        unset($item_types['adv']);
64
+        unset($item_types['package']);
65 65
 
66
-        if ( $invoice->is_paid() ) {
66
+        if ($invoice->is_paid()) {
67 67
             $class .= ' wpinv-paid';
68 68
         }
69 69
 
70
-        if ( $invoice->is_refunded() ) {
70
+        if ($invoice->is_refunded()) {
71 71
             $class .= ' wpinv-refunded';
72 72
         }
73 73
 
74
-        if ( $invoice->is_recurring() ) {
74
+        if ($invoice->is_recurring()) {
75 75
             $class .= ' wpi-recurring';
76 76
         }
77 77
 
78 78
     ?>
79 79
 
80
-        <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>">
80
+        <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>">
81 81
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
82 82
 
83 83
                 <thead>
84 84
                     <tr>
85
-                        <?php foreach ( $columns as $key => $label ) : ?>
86
-                            <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th>
85
+                        <?php foreach ($columns as $key => $label) : ?>
86
+                            <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th>
87 87
                         <?php endforeach; ?>
88 88
                     </tr>
89 89
                 </thead>
90 90
 
91 91
                 <tbody class="wpinv-line-items">
92 92
                     <?php
93
-                        foreach ( $invoice->get_items() as $int => $item ) {
94
-                            self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
93
+                        foreach ($invoice->get_items() as $int => $item) {
94
+                            self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd');
95 95
                         }
96 96
                     ?>
97 97
                 </tbody>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                                             <div class="wp-clearfix">
109 109
                                                 <label class="wpi-item-name">
110 110
                                                     <span class="input-text-wrap">
111
-                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
111
+                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
112 112
                                                     </span>
113 113
                                                 </label>
114 114
                                             </div>
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                                             <div class="wp-clearfix">
117 117
                                                 <label class="wpi-item-price">
118 118
                                                     <span class="input-text-wrap">
119
-                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
-                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
119
+                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
+                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
121 121
                                                     </span>
122 122
                                                 </label>
123 123
                                             </div>
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                                             <div class="wp-clearfix">
126 126
                                                 <label class="wpi-item-name">
127 127
                                                     <span class="input-text-wrap">
128
-                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
128
+                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
129 129
                                                     </span>
130 130
                                                 </label>
131 131
                                             </div>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                                             <div class="wp-clearfix">
134 134
                                                 <label class="wpi-item-type">
135 135
                                                     <span class="input-text-wrap">
136
-                                                        <?php wpinv_html_select( array(
136
+                                                        <?php wpinv_html_select(array(
137 137
                                                             'options'          => $item_types,
138 138
                                                             'name'             => '_wpinv_quick[type]',
139 139
                                                             'id'               => '_wpinv_quick_type',
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
                                                             'show_option_all'  => false,
142 142
                                                             'show_option_none' => false,
143 143
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
144
-                                                        ) ); ?>
144
+                                                        )); ?>
145 145
                                                     </span>
146 146
                                                 </label>
147 147
                                             </div>
148 148
 
149
-                                            <?php if ( $use_taxes ) : ?>
149
+                                            <?php if ($use_taxes) : ?>
150 150
                                                 <div class="wp-clearfix">
151 151
                                                     <label class="wpi-vat-rule">
152 152
                                                         <span class="input-text-wrap">
153 153
                                                             <?php
154
-                                                                wpinv_html_select( array(
154
+                                                                wpinv_html_select(array(
155 155
                                                                     'options'          => array_merge(
156
-                                                                        array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
156
+                                                                        array('' => __('Select VAT Rule', 'invoicing')),
157 157
                                                                         getpaid_get_tax_rules()
158 158
                                                                     ),
159 159
                                                                     'name'             => '_wpinv_quick[vat_rule]',
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                                                                     'show_option_all'  => false,
162 162
                                                                     'show_option_none' => false,
163 163
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
164
-                                                                ) );
164
+                                                                ));
165 165
                                                             ?>
166 166
                                                         </span>
167 167
                                                     </label>
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
                                                     <label class="wpi-vat-class">
171 171
                                                         <span class="input-text-wrap">
172 172
                                                             <?php
173
-                                                                wpinv_html_select( array(
173
+                                                                wpinv_html_select(array(
174 174
                                                                     'options'          => array_merge(
175
-                                                                        array( '' => __( 'Select VAT Class', 'invoicing' ) ),
175
+                                                                        array('' => __('Select VAT Class', 'invoicing')),
176 176
                                                                         getpaid_get_tax_classes()
177 177
                                                                     ),
178 178
                                                                     'name'             => '_wpinv_quick[vat_class]',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                                                                     'show_option_all'  => false,
181 181
                                                                     'show_option_none' => false,
182 182
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
183
-                                                                ) );
183
+                                                                ));
184 184
                                                             ?>
185 185
                                                         </span>
186 186
                                                     </label>
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
                         </td>
202 202
                     </tr>
203 203
                     <tr class="totals">
204
-                        <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td>
204
+                        <td colspan="<?php echo ((int) $cols - 4); ?>"></td>
205 205
                         <td colspan="4">
206 206
                             <table cellspacing="0" cellpadding="0">
207 207
                                 <tr class="subtotal">
208
-                                    <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' );?></td>
209
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td>
208
+                                    <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td>
209
+                                    <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td>
210 210
                                     <td class="action"></td>
211 211
                                 </tr>
212 212
                                 <tr class="discount">
213
-                                    <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ) ; ?></td>
214
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td>
213
+                                    <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td>
214
+                                    <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td>
215 215
                                     <td class="action"></td>
216 216
                                 </tr>
217
-                                <?php if ( $use_taxes ) : ?>
217
+                                <?php if ($use_taxes) : ?>
218 218
                                 <tr class="tax">
219
-                                    <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' );?></td>
220
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td>
219
+                                    <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td>
220
+                                    <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td>
221 221
                                     <td class="action"></td>
222 222
                                 </tr>
223 223
                                 <?php endif; ?>
224 224
                                 <tr class="total">
225
-                                    <td class="name"><?php esc_html_e( 'Total:', 'invoicing' );?></td>
226
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );?></td>
225
+                                    <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td>
226
+                                    <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td>
227 227
                                     <td class="action"></td>
228 228
                                 </tr>
229 229
                             </table>
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             </table>
235 235
             <div class="wpinv-actions">
236 236
                 <?php
237
-                    if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
237
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
238 238
                         wpinv_item_dropdown(
239 239
                             array(
240 240
                                 'name'             => 'wpinv_invoice_item',
@@ -244,61 +244,61 @@  discard block
 block discarded – undo
244 244
                             )
245 245
                         );
246 246
 
247
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>';
248
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
249
-                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
247
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>';
248
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>';
249
+                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>';
250 250
 
251 251
                     }
252 252
                 ?>
253
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
253
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
254 254
             </div>
255 255
         </div>
256 256
         <?php
257 257
     }
258 258
 
259
-    public static function output_row( $columns, $item, $invoice, $class='even' ) {
259
+    public static function output_row($columns, $item, $invoice, $class = 'even') {
260 260
 
261 261
     ?>
262
-        <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>">
263
-            <?php foreach ( array_keys( $columns ) as $column ) : ?>
264
-                <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
262
+        <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>">
263
+            <?php foreach (array_keys($columns) as $column) : ?>
264
+                <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
265 265
                     <?php
266
-                        switch ( $column ) {
266
+                        switch ($column) {
267 267
                             case 'id':
268 268
                                 echo (int) $item->get_id();
269 269
                                 break;
270 270
                             case 'title':
271 271
                                 printf(
272 272
                                     '<a href="%s" target="_blank">%s</a>',
273
-                                    get_edit_post_link( $item->get_id() ),
274
-                                    esc_html( $item->get_raw_name() )
273
+                                    get_edit_post_link($item->get_id()),
274
+                                    esc_html($item->get_raw_name())
275 275
                                 );
276 276
 
277
-                                $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
278
-                                if ( $summary !== '' ) {
277
+                                $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice);
278
+                                if ($summary !== '') {
279 279
                                     printf(
280 280
                                         '<span class="meta">%s</span>',
281
-                                        wp_kses_post( wpautop( $summary ) )
281
+                                        wp_kses_post(wpautop($summary))
282 282
                                     );
283 283
                                 }
284 284
 
285 285
                                 printf(
286 286
                                     '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
287
-                                    esc_attr( $item->get_raw_name() ),
287
+                                    esc_attr($item->get_raw_name()),
288 288
                                     (int) $item->get_id()
289 289
                                 );
290 290
 
291 291
                                 printf(
292 292
                                     '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
293 293
                                     (int) $item->get_id(),
294
-                                    esc_attr( $item->get_description() )
294
+                                    esc_attr($item->get_description())
295 295
                                 );
296 296
 
297 297
                                 break;
298 298
                             case 'price':
299 299
                                 printf(
300 300
                                     '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
301
-                                    esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
301
+                                    esc_attr(getpaid_unstandardize_amount($item->get_price())),
302 302
                                     (int) $item->get_id()
303 303
                                 );
304 304
 
@@ -306,26 +306,26 @@  discard block
 block discarded – undo
306 306
                             case 'qty':
307 307
                                 printf(
308 308
                                     '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
309
-                                    floatval( $item->get_quantity() ),
309
+                                    floatval($item->get_quantity()),
310 310
                                     (int) $item->get_id()
311 311
                                 );
312 312
 
313 313
                                 break;
314 314
                             case 'total':
315
-                                wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() );
315
+                                wpinv_the_price($item->get_sub_total(), $invoice->get_currency());
316 316
 
317 317
                                 break;
318 318
                             case 'tax':
319
-                                echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%';
319
+                                echo wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%';
320 320
 
321 321
                                 break;
322 322
                             case 'action':
323
-                                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
323
+                                if (!$invoice->is_paid() && !$invoice->is_refunded()) {
324 324
                                     echo '<i class="fa fa-trash wpinv-item-remove"></i>';
325 325
                                 }
326 326
                                 break;
327 327
                         }
328
-                        do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice );
328
+                        do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice);
329 329
                     ?>
330 330
                 </td>
331 331
             <?php endforeach; ?>
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @param WP_Post $post
340 340
 	 */
341
-    public static function output2( $post ) {
341
+    public static function output2($post) {
342 342
 
343 343
         // Prepare the invoice.
344
-        $invoice = new WPInv_Invoice( $post );
344
+        $invoice = new WPInv_Invoice($post);
345 345
 
346 346
         // Invoice items.
347 347
         $items = $invoice->get_items();
@@ -349,28 +349,28 @@  discard block
 block discarded – undo
349 349
         $totals = array(
350 350
 
351 351
             'subtotal'  => array(
352
-                'label' => __( 'Items Subtotal', 'invoicing' ),
353
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
352
+                'label' => __('Items Subtotal', 'invoicing'),
353
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
354 354
             ),
355 355
 
356 356
             'discount'  => array(
357
-                'label' => __( 'Total Discount', 'invoicing' ),
358
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
357
+                'label' => __('Total Discount', 'invoicing'),
358
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
359 359
             ),
360 360
 
361 361
             'tax'       => array(
362
-                'label' => __( 'Total Tax', 'invoicing' ),
363
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
362
+                'label' => __('Total Tax', 'invoicing'),
363
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
364 364
             ),
365 365
 
366 366
             'total'     => array(
367
-                'label' => __( 'Invoice Total', 'invoicing' ),
368
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
367
+                'label' => __('Invoice Total', 'invoicing'),
368
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
369 369
             )
370 370
         );
371 371
 
372
-        if ( ! wpinv_use_taxes() ) {
373
-            unset( $totals['tax'] );
372
+        if (!wpinv_use_taxes()) {
373
+            unset($totals['tax']);
374 374
         }
375 375
 
376 376
         $item_args = array(
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             'orderby'        => 'title',
379 379
             'order'          => 'ASC',
380 380
             'posts_per_page' => -1,
381
-            'post_status'    => array( 'publish' ),
381
+            'post_status'    => array('publish'),
382 382
             'meta_query'     => array(
383 383
                 array(
384 384
                     'key'       => '_wpinv_type',
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
             }
403 403
         </style>
404 404
 
405
-                <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
405
+                <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
406 406
 
407
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
408
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
407
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
408
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
409 409
 
410 410
                         <div class="row">
411 411
                             <div class="col-12 col-sm-6">
@@ -414,15 +414,15 @@  discard block
 block discarded – undo
414 414
                                         array(
415 415
                                             'id'          => 'wpinv_template',
416 416
                                             'name'        => 'wpinv_template',
417
-                                            'label'       => __( 'Template', 'invoicing' ),
417
+                                            'label'       => __('Template', 'invoicing'),
418 418
                                             'label_type'  => 'vertical',
419
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
419
+                                            'placeholder' => __('Choose a template', 'invoicing'),
420 420
                                             'class'       => 'form-control-sm',
421
-                                            'value'       => $invoice->get_template( 'edit' ),
421
+                                            'value'       => $invoice->get_template('edit'),
422 422
                                             'options'     => array(
423
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
424
-                                                'hours'    => __( 'Hours', 'invoicing' ),
425
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
423
+                                                'quantity' => __('Quantity', 'invoicing'),
424
+                                                'hours'    => __('Hours', 'invoicing'),
425
+                                                'amount'   => __('Amount Only', 'invoicing'),
426 426
                                             ),
427 427
                                             'data-allow-clear' => 'false',
428 428
                                             'select2'          => true,
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
                                         array(
440 440
                                             'id'          => 'wpinv_currency',
441 441
                                             'name'        => 'wpinv_currency',
442
-                                            'label'       => __( 'Currency', 'invoicing' ),
442
+                                            'label'       => __('Currency', 'invoicing'),
443 443
                                             'label_type'  => 'vertical',
444
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
444
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
445 445
                                             'class'       => 'form-control-sm',
446
-                                            'value'       => $invoice->get_currency( 'edit' ),
446
+                                            'value'       => $invoice->get_currency('edit'),
447 447
                                             'required'    => false,
448 448
                                             'data-allow-clear' => 'false',
449 449
                                             'select2'          => true,
@@ -456,24 +456,24 @@  discard block
 block discarded – undo
456 456
                             </div>
457 457
                         </div>
458 458
 
459
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
459
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
460 460
                     <?php endif; ?>
461 461
 
462 462
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
463 463
                         <thead>
464 464
                             <tr>
465
-                                <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ) ?></th>
465
+                                <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing') ?></th>
466 466
                                 <th class="getpaid-quantity hide-if-amount text-right">
467
-                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span>
468
-                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span>
467
+                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span>
468
+                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span>
469 469
                                 </th>
470 470
                                 <th class="getpaid-price hide-if-amount text-right">
471
-                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ) ?></span>
472
-                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ) ?></span>
471
+                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing') ?></span>
472
+                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing') ?></span>
473 473
                                 </th>
474 474
                                 <th class="getpaid-item-subtotal text-right">
475
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ) ?></span>
476
-                                    <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ) ?></span>
475
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing') ?></span>
476
+                                    <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing') ?></span>
477 477
                                 </th>
478 478
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
479 479
                             </tr>
@@ -481,8 +481,8 @@  discard block
 block discarded – undo
481 481
 		                <tbody class="getpaid_invoice_line_items">
482 482
                             <tr class="hide-if-has-items hide-if-not-editable">
483 483
                                 <td colspan="2" class="pt-4 pb-4">
484
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ) ?></button>
485
-                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button>
484
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing') ?></button>
485
+                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button>
486 486
                                 </td>
487 487
                                 <td class="hide-if-amount">&nbsp;</th>
488 488
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
                             <div class="col-12 col-sm-6 offset-sm-6">
515 515
                                 <table class="getpaid-invoice-totals text-right w-100">
516 516
                                     <tbody>
517
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
518
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
519
-                                                <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td>
517
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
518
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
519
+                                                <td class="label"><?php echo esc_html($data['label']) ?>:</td>
520 520
                                                 <td width="1%"></td>
521
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td>
521
+                                                <td class="value"><?php echo wp_kses_post($data['value']) ?></td>
522 522
                                             </tr>
523 523
                                         <?php endforeach; ?>
524 524
                                     </tbody>
@@ -531,18 +531,18 @@  discard block
 block discarded – undo
531 531
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
532 532
                         <div class="row">
533 533
                             <div class="text-left col-12 col-sm-8">
534
-                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ) ?></button>
535
-                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ) ?></button>
536
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
534
+                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing') ?></button>
535
+                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing') ?></button>
536
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
537 537
                             </div>
538 538
                             <div class="text-right col-12 col-sm-4">
539
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ) ?></button>
539
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing') ?></button>
540 540
                             </div>
541 541
                         </div>
542 542
                     </div>
543 543
 
544 544
                     <div class="getpaid-invoice-item-actions hide-if-editable">
545
-                        <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
545
+                        <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p>
546 546
                     </div>
547 547
 
548 548
                     <!-- Add items to an invoice -->
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
                         <div class="modal-dialog modal-dialog-centered" role="document">
551 551
                             <div class="modal-content">
552 552
                                 <div class="modal-header">
553
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( "Add Item(s)", 'invoicing' ); ?></h5>
554
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>">
553
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e("Add Item(s)", 'invoicing'); ?></h5>
554
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>">
555 555
                                         <span aria-hidden="true">&times;</span>
556 556
                                     </button>
557 557
                                 </div>
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
                                     <table class="widefat">
560 560
                                         <thead>
561 561
                                             <tr>
562
-                                                <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ) ?></th>
562
+                                                <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing') ?></th>
563 563
                                                 <th class="pr-0 text-right hide-if-amount">
564
-                                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ) ?></span>
565
-                                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ) ?></span>
564
+                                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing') ?></span>
565
+                                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing') ?></span>
566 566
                                                 </th>
567 567
                                             </tr>
568 568
                                         </thead>
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
 								            <tr>
571 571
 									            <td class="pl-0 text-left">
572 572
                                                     <select class="regular-text getpaid-add-invoice-item-select">
573
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
574
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
575
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option>
573
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
574
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
575
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option>
576 576
                                                         <?php endforeach; ?>
577 577
                                                     </select>
578 578
                                                 </td>
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 						            </table>
585 585
                                 </div>
586 586
                                 <div class="modal-footer">
587
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
588
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button>
587
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
588
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button>
589 589
                                 </div>
590 590
                             </div>
591 591
                         </div>
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
                         <div class="modal-dialog modal-dialog-centered" role="document">
597 597
                             <div class="modal-content">
598 598
                                 <div class="modal-header">
599
-                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( "Create Item", 'invoicing' ); ?></h5>
600
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>">
599
+                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e("Create Item", 'invoicing'); ?></h5>
600
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>">
601 601
                                         <span aria-hidden="true">&times;</span>
602 602
                                     </button>
603 603
                                 </div>
@@ -605,27 +605,27 @@  discard block
 block discarded – undo
605 605
                                     <div class="getpaid-create-item-div">
606 606
                                         <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id">
607 607
                                         <label class="form-group w-100">
608
-                                            <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span>
609
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
608
+                                            <span><?php esc_html_e('Name', 'invoicing'); ?></span>
609
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
610 610
                                         </label>
611 611
                                         <label class="form-group w-100">
612
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span>
613
-                                            <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span>
614
-                                            <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price">
612
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span>
613
+                                            <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span>
614
+                                            <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price">
615 615
                                         </label>
616 616
                                         <label class="form-group w-100 hide-if-amount">
617
-                                            <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span>
617
+                                            <span><?php esc_html_e('Quantity', 'invoicing'); ?></span>
618 618
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
619 619
                                         </label>
620 620
                                         <label class="form-group w-100">
621
-                                            <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span>
622
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
621
+                                            <span><?php esc_html_e('Item Description', 'invoicing'); ?></span>
622
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
623 623
                                         </label>
624 624
                                     </div>
625 625
                                 </div>
626 626
                                 <div class="modal-footer">
627
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
628
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button>
627
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
628
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button>
629 629
                                 </div>
630 630
                             </div>
631 631
                         </div>
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
                         <div class="modal-dialog modal-dialog-centered" role="document">
637 637
                             <div class="modal-content">
638 638
                                 <div class="modal-header">
639
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( "Edit Item", 'invoicing' ); ?></h5>
640
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( "Close", 'invoicing' ); ?>">
639
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e("Edit Item", 'invoicing'); ?></h5>
640
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e("Close", 'invoicing'); ?>">
641 641
                                         <span aria-hidden="true">&times;</span>
642 642
                                     </button>
643 643
                                 </div>
@@ -645,27 +645,27 @@  discard block
 block discarded – undo
645 645
                                     <div class="getpaid-edit-item-div">
646 646
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
647 647
                                         <label class="form-group w-100">
648
-                                            <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span>
649
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
648
+                                            <span><?php esc_html_e('Name', 'invoicing'); ?></span>
649
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
650 650
                                         </label>
651 651
                                         <label class="form-group w-100">
652
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span>
653
-                                            <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span>
654
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
652
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span>
653
+                                            <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span>
654
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
655 655
                                         </label>
656 656
                                         <label class="form-group w-100 hide-if-amount">
657
-                                            <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span>
657
+                                            <span><?php esc_html_e('Quantity', 'invoicing'); ?></span>
658 658
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
659 659
                                         </label>
660 660
                                         <label class="form-group w-100">
661
-                                            <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span>
662
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
661
+                                            <span><?php esc_html_e('Item Description', 'invoicing'); ?></span>
662
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
663 663
                                         </label>
664 664
                                     </div>
665 665
                                 </div>
666 666
                                 <div class="modal-footer">
667
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
668
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button>
667
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
668
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button>
669 669
                                 </div>
670 670
                             </div>
671 671
                         </div>
Please login to merge, or discard this patch.
includes/admin/register-settings.php 2 patches
Indentation   +305 added lines, -305 removed lines patch added patch discarded remove patch
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
     $name       = isset( $option['name'] ) ? $option['name'] : '';
193 193
     $cb         = "wpinv_{$option['type']}_callback";
194 194
     $section    = "wpinv_settings_{$tab}_$section";
195
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
195
+    $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
196 196
 
197
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
-		$tip   = wpinv_clean( $option['desc'] );
199
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
-		unset( $option['desc'] );
201
-	}
197
+    if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
+        $tip   = wpinv_clean( $option['desc'] );
199
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
+        unset( $option['desc'] );
201
+    }
202 202
 
203 203
     // Loop through all tabs.
204 204
     add_settings_field(
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
             'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
226 226
             'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
227 227
             'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
228
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
228
+            'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
+            'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
+            'style'           => isset( $option['style'] ) ? $option['style'] : '',
231 231
             'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232 232
             'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
244
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245 245
 }
246 246
 
247 247
 /**
@@ -260,18 +260,18 @@  discard block
 block discarded – undo
260 260
  */
261 261
 function wpinv_settings_sanitize( $input = array() ) {
262 262
 
263
-	$wpinv_options = wpinv_get_options();
264
-	$raw_referrer  = wp_get_raw_referer();
263
+    $wpinv_options = wpinv_get_options();
264
+    $raw_referrer  = wp_get_raw_referer();
265 265
 
266 266
     if ( empty( $raw_referrer ) ) {
267
-		return array_merge( $wpinv_options, $input );
267
+        return array_merge( $wpinv_options, $input );
268 268
     }
269 269
 
270 270
     wp_parse_str( $raw_referrer, $referrer );
271 271
 
272
-	if ( in_array( 'gp-setup', $referrer ) ) {
273
-		return array_merge( $wpinv_options, $input );
274
-	}
272
+    if ( in_array( 'gp-setup', $referrer ) ) {
273
+        return array_merge( $wpinv_options, $input );
274
+    }
275 275
 
276 276
     $settings = wpinv_get_registered_settings();
277 277
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
         }
294 294
 
295 295
         // General filter
296
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
296
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
297 297
 
298
-		// Key specific filter.
299
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
298
+        // Key specific filter.
299
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
300 300
     }
301 301
 
302 302
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 
340 340
     foreach ( $new_rates as $rate ) {
341 341
 
342
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-		$rate['name']    = sanitize_text_field( $rate['name'] );
344
-		$rate['state']   = sanitize_text_field( $rate['state'] );
345
-		$rate['country'] = sanitize_text_field( $rate['country'] );
346
-		$rate['global']  = empty( $rate['state'] );
347
-		$tax_rates[]     = $rate;
342
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
+        $rate['name']    = sanitize_text_field( $rate['name'] );
344
+        $rate['state']   = sanitize_text_field( $rate['state'] );
345
+        $rate['country'] = sanitize_text_field( $rate['country'] );
346
+        $rate['global']  = empty( $rate['state'] );
347
+        $tax_rates[]     = $rate;
348 348
 
349
-	}
349
+    }
350 350
 
351 351
     update_option( 'wpinv_tax_rates', $tax_rates );
352 352
 
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
     $tabs['general']  = __( 'General', 'invoicing' );
360 360
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
361 361
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
362
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
362
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
363 363
 
364
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
366
-	}
364
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
366
+    }
367 367
 
368 368
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
369 369
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -394,52 +394,52 @@  discard block
 block discarded – undo
394 394
         'general'      => apply_filters(
395 395
             'wpinv_settings_sections_general',
396 396
             array(
397
-				'main'             => __( 'General Settings', 'invoicing' ),
398
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
399
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
-				'labels'           => __( 'Label Texts', 'invoicing' ),
397
+                'main'             => __( 'General Settings', 'invoicing' ),
398
+                'page_section'     => __( 'Page Settings', 'invoicing' ),
399
+                'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
+                'labels'           => __( 'Label Texts', 'invoicing' ),
401 401
             )
402 402
         ),
403 403
         'gateways'     => apply_filters(
404 404
             'wpinv_settings_sections_gateways',
405 405
             array(
406
-				'main' => __( 'Gateway Settings', 'invoicing' ),
406
+                'main' => __( 'Gateway Settings', 'invoicing' ),
407 407
             )
408 408
         ),
409 409
         'taxes'        => apply_filters(
410 410
             'wpinv_settings_sections_taxes',
411 411
             array(
412
-				'main'  => __( 'Tax Settings', 'invoicing' ),
413
-				'rates' => __( 'Tax Rates', 'invoicing' ),
414
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
412
+                'main'  => __( 'Tax Settings', 'invoicing' ),
413
+                'rates' => __( 'Tax Rates', 'invoicing' ),
414
+                'vat'   => __( 'EU VAT Settings', 'invoicing' ),
415 415
             )
416 416
         ),
417 417
         'emails'       => apply_filters(
418 418
             'wpinv_settings_sections_emails',
419 419
             array(
420
-				'main' => __( 'Email Settings', 'invoicing' ),
420
+                'main' => __( 'Email Settings', 'invoicing' ),
421 421
             )
422 422
         ),
423 423
 
424
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
424
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
425 425
 
426 426
         'privacy'      => apply_filters(
427 427
             'wpinv_settings_sections_privacy',
428 428
             array(
429
-				'main' => __( 'Privacy policy', 'invoicing' ),
429
+                'main' => __( 'Privacy policy', 'invoicing' ),
430 430
             )
431 431
         ),
432 432
         'misc'         => apply_filters(
433 433
             'wpinv_settings_sections_misc',
434 434
             array(
435
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
436
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
+                'main'       => __( 'Miscellaneous', 'invoicing' ),
436
+                'custom-css' => __( 'Custom CSS', 'invoicing' ),
437 437
             )
438 438
         ),
439 439
         'tools'        => apply_filters(
440 440
             'wpinv_settings_sections_tools',
441 441
             array(
442
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
442
+                'main' => __( 'Diagnostic Tools', 'invoicing' ),
443 443
             )
444 444
         ),
445 445
     );
@@ -450,46 +450,46 @@  discard block
 block discarded – undo
450 450
 }
451 451
 
452 452
 function wpinv_get_pages( $with_slug = false, $default_label = null ) {
453
-	$pages_options = array();
453
+    $pages_options = array();
454 454
 
455
-	if ( $default_label !== null && $default_label !== false ) {
456
-		$pages_options = array( '' => $default_label ); // Blank option
457
-	}
455
+    if ( $default_label !== null && $default_label !== false ) {
456
+        $pages_options = array( '' => $default_label ); // Blank option
457
+    }
458 458
 
459
-	$pages = get_pages();
460
-	if ( $pages ) {
461
-		foreach ( $pages as $page ) {
462
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
459
+    $pages = get_pages();
460
+    if ( $pages ) {
461
+        foreach ( $pages as $page ) {
462
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
463 463
             $pages_options[ $page->ID ] = $title;
464
-		}
465
-	}
464
+        }
465
+    }
466 466
 
467
-	return $pages_options;
467
+    return $pages_options;
468 468
 }
469 469
 
470 470
 function wpinv_header_callback( $args ) {
471
-	if ( ! empty( $args['desc'] ) ) {
471
+    if ( ! empty( $args['desc'] ) ) {
472 472
         echo wp_kses_post( $args['desc'] );
473 473
     }
474 474
 }
475 475
 
476 476
 function wpinv_hidden_callback( $args ) {
477 477
 
478
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
479
-	$value   = wpinv_get_option( $args['id'], $std );
478
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
479
+    $value   = wpinv_get_option( $args['id'], $std );
480 480
 
481
-	if ( isset( $args['set_value'] ) ) {
482
-		$value = $args['set_value'];
483
-	}
481
+    if ( isset( $args['set_value'] ) ) {
482
+        $value = $args['set_value'];
483
+    }
484 484
 
485
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
-		$args['readonly'] = true;
487
-		$name  = '';
488
-	} else {
489
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
490
-	}
485
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
486
+        $args['readonly'] = true;
487
+        $name  = '';
488
+    } else {
489
+        $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
490
+    }
491 491
 
492
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
492
+    echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
493 493
 
494 494
 }
495 495
 
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
  */
499 499
 function wpinv_checkbox_callback( $args ) {
500 500
 
501
-	$std = isset( $args['std'] ) ? $args['std'] : '';
502
-	$std = wpinv_get_option( $args['id'], $std );
503
-	$id  = esc_attr( $args['id'] );
501
+    $std = isset( $args['std'] ) ? $args['std'] : '';
502
+    $std = wpinv_get_option( $args['id'], $std );
503
+    $id  = esc_attr( $args['id'] );
504 504
 
505
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
506
-	?>
505
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
506
+    ?>
507 507
 		<fieldset>
508 508
 			<label>
509 509
 				<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -515,75 +515,75 @@  discard block
 block discarded – undo
515 515
 
516 516
 function wpinv_multicheck_callback( $args ) {
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
519
+    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+    if ( ! empty( $args['options'] ) ) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = wpinv_get_option( $args['id'], $std );
523
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
524
+        $value   = wpinv_get_option( $args['id'], $std );
525 525
 
526
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
526
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
527 527
         foreach ( $args['options'] as $key => $option ) :
528
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
-			if ( in_array( $sanitize_key, $value ) ) {
530
-				$enabled = $sanitize_key;
531
-			} else {
532
-				$enabled = null;
533
-			}
534
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
536
-		endforeach;
537
-		echo '</div>';
538
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
539
-	}
528
+            $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
+            if ( in_array( $sanitize_key, $value ) ) {
530
+                $enabled = $sanitize_key;
531
+            } else {
532
+                $enabled = null;
533
+            }
534
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
536
+        endforeach;
537
+        echo '</div>';
538
+        echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
539
+    }
540 540
 }
541 541
 
542 542
 function wpinv_payment_icons_callback( $args ) {
543 543
 
544 544
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
-	$value   = wpinv_get_option( $args['id'], false );
545
+    $value   = wpinv_get_option( $args['id'], false );
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach ( $args['options'] as $key => $option ) {
547
+    if ( ! empty( $args['options'] ) ) {
548
+        foreach ( $args['options'] as $key => $option ) {
549 549
             $sanitize_key = wpinv_sanitize_key( $key );
550 550
 
551
-			if ( empty( $value ) ) {
552
-				$enabled = $option;
553
-			} else {
554
-				$enabled = null;
555
-			}
556
-
557
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558
-
559
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
560
-
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
-				} else {
564
-				$card = strtolower( str_replace( ' ', '', $option ) );
565
-
566
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
568
-					} else {
569
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
570
-					$content_dir = WP_CONTENT_DIR;
571
-
572
-					if ( function_exists( 'wp_normalize_path' ) ) {
573
-						// Replaces backslashes with forward slashes for Windows systems
574
-						$image = wp_normalize_path( $image );
575
-						$content_dir = wp_normalize_path( $content_dir );
576
-						}
577
-
578
-					$image = str_replace( $content_dir, content_url(), $image );
579
-					}
580
-
581
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582
-				}
583
-			echo wp_kses_post( $option ) . '</label>';
584
-		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
-	}
551
+            if ( empty( $value ) ) {
552
+                $enabled = $option;
553
+            } else {
554
+                $enabled = null;
555
+            }
556
+
557
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558
+
559
+                echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
560
+
561
+                if ( wpinv_string_is_image_url( $key ) ) {
562
+                echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
+                } else {
564
+                $card = strtolower( str_replace( ' ', '', $option ) );
565
+
566
+                if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
+                    $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
568
+                    } else {
569
+                    $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
570
+                    $content_dir = WP_CONTENT_DIR;
571
+
572
+                    if ( function_exists( 'wp_normalize_path' ) ) {
573
+                        // Replaces backslashes with forward slashes for Windows systems
574
+                        $image = wp_normalize_path( $image );
575
+                        $content_dir = wp_normalize_path( $content_dir );
576
+                        }
577
+
578
+                    $image = str_replace( $content_dir, content_url(), $image );
579
+                    }
580
+
581
+                echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582
+                }
583
+            echo wp_kses_post( $option ) . '</label>';
584
+        }
585
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
586
+    }
587 587
 }
588 588
 
589 589
 /**
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
  */
592 592
 function wpinv_radio_callback( $args ) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
596
-	?>
594
+    $std = isset( $args['std'] ) ? $args['std'] : '';
595
+    $std = wpinv_get_option( $args['id'], $std );
596
+    ?>
597 597
 		<fieldset>
598 598
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599 599
 				<?php foreach ( $args['options'] as $key => $option ) : ?>
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+    getpaid_settings_description_callback( $args );
611 611
 }
612 612
 
613 613
 /**
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
  */
616 616
 function getpaid_settings_description_callback( $args ) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
619
-		$description = $args['desc'];
620
-		echo wp_kses_post( "<p class='description'>$description</p>" );
621
-	}
618
+    if ( ! empty( $args['desc'] ) ) {
619
+        $description = $args['desc'];
620
+        echo wp_kses_post( "<p class='description'>$description</p>" );
621
+    }
622 622
 
623 623
 }
624 624
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
  */
628 628
 function wpinv_gateways_callback() {
629 629
 
630
-	?>
630
+    ?>
631 631
 		</td>
632 632
 	</tr>
633 633
 	<tr class="bsui">
@@ -641,26 +641,26 @@  discard block
 block discarded – undo
641 641
 
642 642
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
643 643
     $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
645
-	$value   = wpinv_get_option( $args['id'], $std );
644
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
645
+    $value   = wpinv_get_option( $args['id'], $std );
646 646
 
647
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
647
+    echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
649
+    foreach ( $args['options'] as $key => $option ) :
650 650
 
651
-		echo '<option value="' . esc_attr( $key ) . '" ';
651
+        echo '<option value="' . esc_attr( $key ) . '" ';
652 652
 
653
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654 654
             selected( $key, $args['selected'] );
655 655
         } else {
656 656
             selected( $key, $value );
657 657
         }
658 658
 
659
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
660
-	endforeach;
659
+        echo '>' . esc_html( $option['admin_label'] ) . '</option>';
660
+    endforeach;
661 661
 
662
-	echo '</select>';
663
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
662
+    echo '</select>';
663
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
664 664
 }
665 665
 
666 666
 /**
@@ -671,38 +671,38 @@  discard block
 block discarded – undo
671 671
  */
672 672
 function wpinv_settings_attrs_helper( $args ) {
673 673
 
674
-	$value = isset( $args['std'] ) ? $args['std'] : '';
675
-	$id    = esc_attr( $args['id'] );
676
-	$value = is_scalar( $value ) ? $value : '';
677
-
678
-	$attrs = array(
679
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
680
-		'readonly' => ! empty( $args['faux'] ),
681
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
682
-		'id'       => 'wpinv-settings-' . $args['id'],
683
-		'style'    => $args['style'],
684
-		'class'    => $args['class'],
685
-		'placeholder' => $args['placeholder'],
686
-		'data-placeholder' => $args['placeholder'],
687
-	);
674
+    $value = isset( $args['std'] ) ? $args['std'] : '';
675
+    $id    = esc_attr( $args['id'] );
676
+    $value = is_scalar( $value ) ? $value : '';
677
+
678
+    $attrs = array(
679
+        'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
680
+        'readonly' => ! empty( $args['faux'] ),
681
+        'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
682
+        'id'       => 'wpinv-settings-' . $args['id'],
683
+        'style'    => $args['style'],
684
+        'class'    => $args['class'],
685
+        'placeholder' => $args['placeholder'],
686
+        'data-placeholder' => $args['placeholder'],
687
+    );
688 688
 
689
-	if ( ! empty( $args['onchange'] ) ) {
690
-		$attrs['onchange'] = $args['onchange'];
691
-	}
689
+    if ( ! empty( $args['onchange'] ) ) {
690
+        $attrs['onchange'] = $args['onchange'];
691
+    }
692 692
 
693
-	foreach ( $attrs as $key => $value ) {
693
+    foreach ( $attrs as $key => $value ) {
694 694
 
695
-		if ( false === $value ) {
696
-			continue;
697
-		}
695
+        if ( false === $value ) {
696
+            continue;
697
+        }
698 698
 
699
-		if ( true === $value ) {
700
-			echo ' ' . esc_attr( $key );
701
-		} else {
702
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
703
-		}
699
+        if ( true === $value ) {
700
+            echo ' ' . esc_attr( $key );
701
+        } else {
702
+            echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
703
+        }
704 704
 
705
-	}
705
+    }
706 706
 
707 707
 }
708 708
 
@@ -711,9 +711,9 @@  discard block
 block discarded – undo
711 711
  */
712 712
 function wpinv_text_callback( $args ) {
713 713
 
714
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
714
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
715 715
 
716
-	?>
716
+    ?>
717 717
 		<label style="width: 100%;">
718 718
 			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
719 719
 			<?php echo wp_kses_post( $desc ); ?>
@@ -727,9 +727,9 @@  discard block
 block discarded – undo
727 727
  */
728 728
 function wpinv_number_callback( $args ) {
729 729
 
730
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
730
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
731 731
 
732
-	?>
732
+    ?>
733 733
 		<label style="width: 100%;">
734 734
 			<input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
735 735
 			<?php echo wp_kses_post( $desc ); ?>
@@ -741,34 +741,34 @@  discard block
 block discarded – undo
741 741
 function wpinv_textarea_callback( $args ) {
742 742
 
743 743
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
744
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
745
-	$value   = wpinv_get_option( $args['id'], $std );
744
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
745
+    $value   = wpinv_get_option( $args['id'], $std );
746 746
 
747 747
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
748 748
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
749 749
 
750
-	echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
-	echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
750
+    echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
+    echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
752 752
 
753 753
 }
754 754
 
755 755
 function wpinv_password_callback( $args ) {
756 756
 
757 757
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
758
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
759
-	$value   = wpinv_get_option( $args['id'], $std );
758
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
759
+    $value   = wpinv_get_option( $args['id'], $std );
760 760
 
761
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
762
-	echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
763
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
761
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
762
+    echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
763
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
764 764
 
765 765
 }
766 766
 
767 767
 function wpinv_missing_callback( $args ) {
768
-	printf(
769
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
770
-		'<strong>' . $args['id'] . '</strong>'
771
-	);
768
+    printf(
769
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
770
+        '<strong>' . $args['id'] . '</strong>'
771
+    );
772 772
 }
773 773
 
774 774
 /**
@@ -776,13 +776,13 @@  discard block
 block discarded – undo
776 776
  */
777 777
 function wpinv_select_callback( $args ) {
778 778
 
779
-	$desc   = wp_kses_post( $args['desc'] );
780
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
781
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
782
-	$value  = wpinv_get_option( $args['id'], $value );
783
-	$rand   = uniqid( 'random_id' );
779
+    $desc   = wp_kses_post( $args['desc'] );
780
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
781
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
782
+    $value  = wpinv_get_option( $args['id'], $value );
783
+    $rand   = uniqid( 'random_id' );
784 784
 
785
-	?>
785
+    ?>
786 786
 		<label style="width: 100%;">
787 787
 			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
788 788
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -815,50 +815,50 @@  discard block
 block discarded – undo
815 815
 function wpinv_color_select_callback( $args ) {
816 816
 
817 817
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
818
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
819
-	$value   = wpinv_get_option( $args['id'], $std );
818
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
819
+    $value   = wpinv_get_option( $args['id'], $std );
820 820
 
821
-	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
821
+    echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
822 822
 
823
-	foreach ( $args['options'] as $option => $color ) {
824
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
825
-	}
823
+    foreach ( $args['options'] as $option => $color ) {
824
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
825
+    }
826 826
 
827
-	echo '</select>';
828
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
827
+    echo '</select>';
828
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
829 829
 
830 830
 }
831 831
 
832 832
 function wpinv_rich_editor_callback( $args ) {
833
-	global $wp_version;
833
+    global $wp_version;
834 834
 
835 835
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
836 836
 
837
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
838
-	$value   = wpinv_get_option( $args['id'], $std );
837
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
838
+    $value   = wpinv_get_option( $args['id'], $std );
839 839
 
840
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
841
-		$value = $std;
842
-	}
840
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
841
+        $value = $std;
842
+    }
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
845 845
 
846
-	echo '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
-		wp_editor(
846
+    echo '<div class="getpaid-settings-editor-input">';
847
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
+        wp_editor(
849 849
             stripslashes( $value ),
850 850
             'wpinv_settings_' . esc_attr( $args['id'] ),
851 851
             array(
852
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
853
-				'textarea_rows' => absint( $rows ),
854
-				'media_buttons' => false,
852
+                'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
853
+                'textarea_rows' => absint( $rows ),
854
+                'media_buttons' => false,
855 855
             )
856 856
         );
857
-	} else {
858
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
859
-	}
857
+    } else {
858
+        echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
859
+    }
860 860
 
861
-	echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
861
+    echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
862 862
 
863 863
 }
864 864
 
@@ -866,51 +866,51 @@  discard block
 block discarded – undo
866 866
 
867 867
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
868 868
 
869
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
870
-	$value   = wpinv_get_option( $args['id'], $std );
869
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
870
+    $value   = wpinv_get_option( $args['id'], $std );
871 871
 
872
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
873
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
874
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
875
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
872
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
873
+    echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
874
+    echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
875
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
876 876
 
877 877
 }
878 878
 
879 879
 function wpinv_color_callback( $args ) {
880 880
 
881
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
882
-	$value       = wpinv_get_option( $args['id'], $std );
881
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
882
+    $value       = wpinv_get_option( $args['id'], $std );
883 883
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
884 884
 
885
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
886
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
885
+    echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
886
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
887 887
 
888 888
 }
889 889
 
890 890
 function wpinv_country_states_callback( $args ) {
891 891
 
892
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
893
-	$value   = wpinv_get_option( $args['id'], $std );
892
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
893
+    $value   = wpinv_get_option( $args['id'], $std );
894 894
 
895 895
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
896 896
 
897
-	if ( isset( $args['placeholder'] ) ) {
898
-		$placeholder = $args['placeholder'];
899
-	} else {
900
-		$placeholder = '';
901
-	}
897
+    if ( isset( $args['placeholder'] ) ) {
898
+        $placeholder = $args['placeholder'];
899
+    } else {
900
+        $placeholder = '';
901
+    }
902 902
 
903
-	$states = wpinv_get_country_states();
903
+    $states = wpinv_get_country_states();
904 904
 
905
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
906
-	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
905
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
906
+    echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
907 907
 
908
-	foreach ( $states as $option => $name ) {
909
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
910
-	}
908
+    foreach ( $states as $option => $name ) {
909
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
910
+    }
911 911
 
912
-	echo '</select>';
913
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
912
+    echo '</select>';
913
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
914 914
 
915 915
 }
916 916
 
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
  */
920 920
 function wpinv_tax_rates_callback() {
921 921
 
922
-	?>
922
+    ?>
923 923
 		</td>
924 924
 	</tr>
925 925
 	<tr class="bsui">
@@ -934,17 +934,17 @@  discard block
 block discarded – undo
934 934
  * Displays a tax rate' edit row.
935 935
  */
936 936
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
937
-	ob_start();
937
+    ob_start();
938 938
 
939
-	$key                      = sanitize_key( $key );
940
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
941
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
939
+    $key                      = sanitize_key( $key );
940
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
941
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
942 942
 
943
-	if ( $echo ) {
944
-		echo ob_get_clean();
945
-	} else {
946
-		return ob_get_clean();
947
-	}
943
+    if ( $echo ) {
944
+        echo ob_get_clean();
945
+    } else {
946
+        return ob_get_clean();
947
+    }
948 948
 
949 949
 }
950 950
 
@@ -976,14 +976,14 @@  discard block
 block discarded – undo
976 976
                 <td>
977 977
 					<a href="
978 978
                     <?php
979
-						echo esc_url(
980
-							wp_nonce_url(
981
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
982
-								'getpaid-nonce',
983
-								'getpaid-nonce'
984
-							)
985
-						);
986
-					?>
979
+                        echo esc_url(
980
+                            wp_nonce_url(
981
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
982
+                                'getpaid-nonce',
983
+                                'getpaid-nonce'
984
+                            )
985
+                        );
986
+                    ?>
987 987
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
988 988
                 </td>
989 989
             </tr>
@@ -995,14 +995,14 @@  discard block
 block discarded – undo
995 995
                 <td>
996 996
 					<a href="
997 997
                     <?php
998
-						echo esc_url(
999
-							wp_nonce_url(
1000
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1001
-								'getpaid-nonce',
1002
-								'getpaid-nonce'
1003
-							)
1004
-						);
1005
-					?>
998
+                        echo esc_url(
999
+                            wp_nonce_url(
1000
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1001
+                                'getpaid-nonce',
1002
+                                'getpaid-nonce'
1003
+                            )
1004
+                        );
1005
+                    ?>
1006 1006
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1007 1007
                 </td>
1008 1008
             </tr>
@@ -1014,14 +1014,14 @@  discard block
 block discarded – undo
1014 1014
                 <td>
1015 1015
 					<a href="
1016 1016
                     <?php
1017
-						echo esc_url(
1018
-							wp_nonce_url(
1019
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1020
-								'getpaid-nonce',
1021
-								'getpaid-nonce'
1022
-							)
1023
-						);
1024
-					?>
1017
+                        echo esc_url(
1018
+                            wp_nonce_url(
1019
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1020
+                                'getpaid-nonce',
1021
+                                'getpaid-nonce'
1022
+                            )
1023
+                        );
1024
+                    ?>
1025 1025
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1026 1026
                 </td>
1027 1027
             </tr>
@@ -1034,14 +1034,14 @@  discard block
 block discarded – undo
1034 1034
                 <td>
1035 1035
 					<a href="
1036 1036
                     <?php
1037
-						echo esc_url(
1038
-							wp_nonce_url(
1039
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1040
-								'getpaid-nonce',
1041
-								'getpaid-nonce'
1042
-							)
1043
-						);
1044
-					?>
1037
+                        echo esc_url(
1038
+                            wp_nonce_url(
1039
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1040
+                                'getpaid-nonce',
1041
+                                'getpaid-nonce'
1042
+                            )
1043
+                        );
1044
+                    ?>
1045 1045
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1046 1046
                 </td>
1047 1047
             </tr>
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
                 <td>
1055 1055
 					<a href="
1056 1056
                     <?php
1057
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1058
-					?>
1057
+                        echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1058
+                    ?>
1059 1059
                     " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1060 1060
                 </td>
1061 1061
             </tr>
@@ -1069,19 +1069,19 @@  discard block
 block discarded – undo
1069 1069
 
1070 1070
 
1071 1071
 function wpinv_descriptive_text_callback( $args ) {
1072
-	echo wp_kses_post( $args['desc'] );
1072
+    echo wp_kses_post( $args['desc'] );
1073 1073
 }
1074 1074
 
1075 1075
 function wpinv_raw_html_callback( $args ) {
1076
-	echo wp_kses_post( $args['desc'] );
1076
+    echo wp_kses_post( $args['desc'] );
1077 1077
 }
1078 1078
 
1079 1079
 function wpinv_hook_callback( $args ) {
1080
-	do_action( 'wpinv_' . $args['id'], $args );
1080
+    do_action( 'wpinv_' . $args['id'], $args );
1081 1081
 }
1082 1082
 
1083 1083
 function wpinv_set_settings_cap() {
1084
-	return wpinv_get_capability();
1084
+    return wpinv_get_capability();
1085 1085
 }
1086 1086
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1087 1087
 
@@ -1105,15 +1105,15 @@  discard block
 block discarded – undo
1105 1105
  */
1106 1106
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1107 1107
 
1108
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1109
-	$link = sprintf(
1110
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1111
-		$url,
1112
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1113
-	);
1108
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1109
+    $link = sprintf(
1110
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1111
+        $url,
1112
+        esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1113
+    );
1114 1114
 
1115
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1115
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1116 1116
 
1117
-	return "$description $link";
1117
+    return "$description $link";
1118 1118
 
1119 1119
 }
Please login to merge, or discard this patch.
Spacing   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
     global $wpinv_options;
42 42
 
43 43
     // Try fetching the saved options.
44
-    if ( empty( $wpinv_options ) ) {
45
-        $wpinv_options = get_option( 'wpinv_settings' );
44
+    if (empty($wpinv_options)) {
45
+        $wpinv_options = get_option('wpinv_settings');
46 46
     }
47 47
 
48 48
     // If that fails, don't fetch the default settings to prevent a loop.
49
-    if ( ! is_array( $wpinv_options ) ) {
49
+    if (!is_array($wpinv_options)) {
50 50
         $wpinv_options = array();
51 51
     }
52 52
 
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
  * @param mixed $default The default value to use if the setting has not been set.
61 61
  * @return mixed
62 62
  */
63
-function wpinv_get_option( $key = '', $default = false ) {
63
+function wpinv_get_option($key = '', $default = false) {
64 64
 
65 65
     $options = wpinv_get_options();
66
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
67
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
66
+    $value   = isset($options[$key]) ? $options[$key] : $default;
67
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
68 68
 
69
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
69
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
70 70
 }
71 71
 
72 72
 /**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
  * @param array $options the new options.
76 76
  * @return bool
77 77
  */
78
-function wpinv_update_options( $options ) {
78
+function wpinv_update_options($options) {
79 79
     global $wpinv_options;
80 80
 
81 81
     // update the option.
82
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
82
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
83 83
         $wpinv_options = $options;
84 84
         return true;
85 85
     }
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  * @param mixed $value The setting value.
95 95
  * @return bool
96 96
  */
97
-function wpinv_update_option( $key = '', $value = false ) {
97
+function wpinv_update_option($key = '', $value = false) {
98 98
 
99 99
     // If no key, exit.
100
-    if ( empty( $key ) ) {
100
+    if (empty($key)) {
101 101
         return false;
102 102
     }
103 103
 
104 104
     // Maybe delete the option instead.
105
-    if ( is_null( $value ) ) {
106
-        return wpinv_delete_option( $key );
105
+    if (is_null($value)) {
106
+        return wpinv_delete_option($key);
107 107
     }
108 108
 
109 109
     // Prepare the new options.
110 110
     $options         = wpinv_get_options();
111
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
111
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
112 112
 
113 113
     // Save the new options.
114
-    return wpinv_update_options( $options );
114
+    return wpinv_update_options($options);
115 115
 
116 116
 }
117 117
 
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
  * @param string $key the setting key.
122 122
  * @return bool
123 123
  */
124
-function wpinv_delete_option( $key = '' ) {
124
+function wpinv_delete_option($key = '') {
125 125
 
126 126
     // If no key, exit
127
-    if ( empty( $key ) ) {
127
+    if (empty($key)) {
128 128
         return false;
129 129
     }
130 130
 
131 131
     $options = wpinv_get_options();
132 132
 
133
-    if ( isset( $options[ $key ] ) ) {
134
-        unset( $options[ $key ] );
135
-        return wpinv_update_options( $options );
133
+    if (isset($options[$key])) {
134
+        unset($options[$key]);
135
+        return wpinv_update_options($options);
136 136
     }
137 137
 
138 138
     return true;
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 function wpinv_register_settings() {
147 147
 
148 148
     // Loop through all tabs.
149
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
149
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
150 150
 
151 151
         // In each tab, loop through sections.
152
-        foreach ( $sections as $section => $settings ) {
152
+        foreach ($sections as $section => $settings) {
153 153
 
154 154
             // Check for backwards compatibility
155
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
156
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
155
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
156
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
157 157
                 $section = 'main';
158 158
                 $settings = $sections;
159 159
             }
@@ -166,18 +166,18 @@  discard block
 block discarded – undo
166 166
                 'wpinv_settings_' . $tab . '_' . $section
167 167
             );
168 168
 
169
-            foreach ( $settings as $option ) {
170
-                if ( ! empty( $option['id'] ) ) {
171
-                    wpinv_register_settings_option( $tab, $section, $option );
169
+            foreach ($settings as $option) {
170
+                if (!empty($option['id'])) {
171
+                    wpinv_register_settings_option($tab, $section, $option);
172 172
                 }
173 173
             }
174 174
 }
175 175
     }
176 176
 
177 177
     // Creates our settings in the options table.
178
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
178
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
179 179
 }
180
-add_action( 'admin_init', 'wpinv_register_settings' );
180
+add_action('admin_init', 'wpinv_register_settings');
181 181
 
182 182
 /**
183 183
  * Register a single settings option.
@@ -187,49 +187,49 @@  discard block
 block discarded – undo
187 187
  * @param string $option
188 188
  *
189 189
  */
190
-function wpinv_register_settings_option( $tab, $section, $option ) {
190
+function wpinv_register_settings_option($tab, $section, $option) {
191 191
 
192
-    $name       = isset( $option['name'] ) ? $option['name'] : '';
192
+    $name       = isset($option['name']) ? $option['name'] : '';
193 193
     $cb         = "wpinv_{$option['type']}_callback";
194 194
     $section    = "wpinv_settings_{$tab}_$section";
195
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
195
+	$is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page'];
196 196
 
197
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
198
-		$tip   = wpinv_clean( $option['desc'] );
197
+	if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) {
198
+		$tip   = wpinv_clean($option['desc']);
199 199
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
200
-		unset( $option['desc'] );
200
+		unset($option['desc']);
201 201
 	}
202 202
 
203 203
     // Loop through all tabs.
204 204
     add_settings_field(
205 205
         'wpinv_settings[' . $option['id'] . ']',
206 206
         $name,
207
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
207
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
208 208
         $section,
209 209
         $section,
210 210
         array(
211 211
             'section'         => $section,
212
-            'id'              => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ),
213
-            'desc'            => isset( $option['desc'] ) ? $option['desc'] : '',
212
+            'id'              => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
213
+            'desc'            => isset($option['desc']) ? $option['desc'] : '',
214 214
             'name'            => $name,
215
-            'size'            => isset( $option['size'] ) ? $option['size'] : null,
216
-            'options'         => isset( $option['options'] ) ? $option['options'] : '',
217
-            'selected'        => isset( $option['selected'] ) ? $option['selected'] : null,
218
-            'std'             => isset( $option['std'] ) ? $option['std'] : '',
219
-            'min'             => isset( $option['min'] ) ? $option['min'] : 0,
220
-            'max'             => isset( $option['max'] ) ? $option['max'] : 999999,
221
-            'step'            => isset( $option['step'] ) ? $option['step'] : 1,
222
-            'placeholder'     => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
223
-            'allow_blank'     => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
224
-            'readonly'        => isset( $option['readonly'] ) ? $option['readonly'] : false,
225
-            'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
226
-            'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
227
-            'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
228
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
229
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
230
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
231
-            'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
-            'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
215
+            'size'            => isset($option['size']) ? $option['size'] : null,
216
+            'options'         => isset($option['options']) ? $option['options'] : '',
217
+            'selected'        => isset($option['selected']) ? $option['selected'] : null,
218
+            'std'             => isset($option['std']) ? $option['std'] : '',
219
+            'min'             => isset($option['min']) ? $option['min'] : 0,
220
+            'max'             => isset($option['max']) ? $option['max'] : 999999,
221
+            'step'            => isset($option['step']) ? $option['step'] : 1,
222
+            'placeholder'     => isset($option['placeholder']) ? $option['placeholder'] : null,
223
+            'allow_blank'     => isset($option['allow_blank']) ? $option['allow_blank'] : true,
224
+            'readonly'        => isset($option['readonly']) ? $option['readonly'] : false,
225
+            'faux'            => isset($option['faux']) ? $option['faux'] : false,
226
+            'onchange'        => isset($option['onchange']) ? $option['onchange'] : '',
227
+            'custom'          => isset($option['custom']) ? $option['custom'] : '',
228
+			'default_content' => isset($option['default_content']) ? $option['default_content'] : '',
229
+			'class'           => isset($option['class']) ? $option['class'] : '',
230
+			'style'           => isset($option['style']) ? $option['style'] : '',
231
+            'cols'            => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
+            'rows'            => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
234 234
     );
235 235
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
244
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
245 245
 }
246 246
 
247 247
 /**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
  * @return array
251 251
  */
252 252
 function getpaid_get_integration_settings() {
253
-    return apply_filters( 'getpaid_integration_settings', array() );
253
+    return apply_filters('getpaid_integration_settings', array());
254 254
 }
255 255
 
256 256
 /**
@@ -258,126 +258,126 @@  discard block
 block discarded – undo
258 258
  *
259 259
  * @return array
260 260
  */
261
-function wpinv_settings_sanitize( $input = array() ) {
261
+function wpinv_settings_sanitize($input = array()) {
262 262
 
263 263
 	$wpinv_options = wpinv_get_options();
264 264
 	$raw_referrer  = wp_get_raw_referer();
265 265
 
266
-    if ( empty( $raw_referrer ) ) {
267
-		return array_merge( $wpinv_options, $input );
266
+    if (empty($raw_referrer)) {
267
+		return array_merge($wpinv_options, $input);
268 268
     }
269 269
 
270
-    wp_parse_str( $raw_referrer, $referrer );
270
+    wp_parse_str($raw_referrer, $referrer);
271 271
 
272
-	if ( in_array( 'gp-setup', $referrer ) ) {
273
-		return array_merge( $wpinv_options, $input );
272
+	if (in_array('gp-setup', $referrer)) {
273
+		return array_merge($wpinv_options, $input);
274 274
 	}
275 275
 
276 276
     $settings = wpinv_get_registered_settings();
277
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
278
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
277
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
278
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
279 279
 
280 280
     $input = $input ? $input : array();
281
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
282
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
281
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
282
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
283 283
 
284 284
     // Loop through each setting being saved and pass it through a sanitization filter
285
-    foreach ( $input as $key => $value ) {
285
+    foreach ($input as $key => $value) {
286 286
 
287 287
         // Get the setting type (checkbox, select, etc)
288
-        $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false;
288
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
289 289
 
290
-        if ( $type ) {
290
+        if ($type) {
291 291
             // Field type specific filter
292
-            $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key );
292
+            $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key);
293 293
         }
294 294
 
295 295
         // General filter
296
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
296
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
297 297
 
298 298
 		// Key specific filter.
299
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
299
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
300 300
     }
301 301
 
302 302
     // Loop through the whitelist and unset any that are empty for the tab being saved
303
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
304
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
303
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
304
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
305 305
 
306
-    $found_settings   = array_merge( $main_settings, $section_settings );
306
+    $found_settings   = array_merge($main_settings, $section_settings);
307 307
 
308
-    if ( ! empty( $found_settings ) ) {
309
-        foreach ( $found_settings as $key => $value ) {
308
+    if (!empty($found_settings)) {
309
+        foreach ($found_settings as $key => $value) {
310 310
 
311 311
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
312
-            if ( is_numeric( $key ) ) {
312
+            if (is_numeric($key)) {
313 313
                 $key = $value['id'];
314 314
             }
315 315
 
316
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
317
-                unset( $wpinv_options[ $key ] );
316
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
317
+                unset($wpinv_options[$key]);
318 318
             }
319 319
         }
320 320
     }
321 321
 
322 322
     // Merge our new settings with the existing
323
-    $output = array_merge( $wpinv_options, $input );
323
+    $output = array_merge($wpinv_options, $input);
324 324
 
325
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
325
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
326 326
 
327 327
     return $output;
328 328
 }
329
-add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 );
330
-add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' );
329
+add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1);
330
+add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount');
331 331
 
332
-function wpinv_settings_sanitize_tax_rates( $input ) {
333
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
332
+function wpinv_settings_sanitize_tax_rates($input) {
333
+    if (!wpinv_current_user_can_manage_invoicing()) {
334 334
         return $input;
335 335
     }
336 336
 
337
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array();
337
+    $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array();
338 338
     $tax_rates = array();
339 339
 
340
-    foreach ( $new_rates as $rate ) {
340
+    foreach ($new_rates as $rate) {
341 341
 
342
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
343
-		$rate['name']    = sanitize_text_field( $rate['name'] );
344
-		$rate['state']   = sanitize_text_field( $rate['state'] );
345
-		$rate['country'] = sanitize_text_field( $rate['country'] );
346
-		$rate['global']  = empty( $rate['state'] );
342
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
343
+		$rate['name']    = sanitize_text_field($rate['name']);
344
+		$rate['state']   = sanitize_text_field($rate['state']);
345
+		$rate['country'] = sanitize_text_field($rate['country']);
346
+		$rate['global']  = empty($rate['state']);
347 347
 		$tax_rates[]     = $rate;
348 348
 
349 349
 	}
350 350
 
351
-    update_option( 'wpinv_tax_rates', $tax_rates );
351
+    update_option('wpinv_tax_rates', $tax_rates);
352 352
 
353 353
     return $input;
354 354
 }
355
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
355
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
356 356
 
357 357
 function wpinv_get_settings_tabs() {
358 358
     $tabs             = array();
359
-    $tabs['general']  = __( 'General', 'invoicing' );
360
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
361
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
362
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
359
+    $tabs['general']  = __('General', 'invoicing');
360
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
361
+    $tabs['taxes']    = __('Taxes', 'invoicing');
362
+	$tabs['emails'] = __('Emails', 'invoicing');
363 363
 
364
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
365
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
364
+	if (count(getpaid_get_integration_settings()) > 0) {
365
+		$tabs['integrations'] = __('Integrations', 'invoicing');
366 366
 	}
367 367
 
368
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
369
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
370
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
368
+    $tabs['privacy']  = __('Privacy', 'invoicing');
369
+    $tabs['misc']     = __('Misc', 'invoicing');
370
+    $tabs['tools']    = __('Tools', 'invoicing');
371 371
 
372
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
372
+    return apply_filters('wpinv_settings_tabs', $tabs);
373 373
 }
374 374
 
375
-function wpinv_get_settings_tab_sections( $tab = false ) {
375
+function wpinv_get_settings_tab_sections($tab = false) {
376 376
     $tabs     = false;
377 377
     $sections = wpinv_get_registered_settings_sections();
378 378
 
379
-    if ( $tab && ! empty( $sections[ $tab ] ) ) {
380
-        $tabs = $sections[ $tab ];
379
+    if ($tab && !empty($sections[$tab])) {
380
+        $tabs = $sections[$tab];
381 381
     }
382 382
 
383 383
     return $tabs;
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 function wpinv_get_registered_settings_sections() {
387 387
     static $sections = false;
388 388
 
389
-    if ( false !== $sections ) {
389
+    if (false !== $sections) {
390 390
         return $sections;
391 391
     }
392 392
 
@@ -394,230 +394,230 @@  discard block
 block discarded – undo
394 394
         'general'      => apply_filters(
395 395
             'wpinv_settings_sections_general',
396 396
             array(
397
-				'main'             => __( 'General Settings', 'invoicing' ),
398
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
399
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
400
-				'labels'           => __( 'Label Texts', 'invoicing' ),
397
+				'main'             => __('General Settings', 'invoicing'),
398
+				'page_section'     => __('Page Settings', 'invoicing'),
399
+				'currency_section' => __('Currency Settings', 'invoicing'),
400
+				'labels'           => __('Label Texts', 'invoicing'),
401 401
             )
402 402
         ),
403 403
         'gateways'     => apply_filters(
404 404
             'wpinv_settings_sections_gateways',
405 405
             array(
406
-				'main' => __( 'Gateway Settings', 'invoicing' ),
406
+				'main' => __('Gateway Settings', 'invoicing'),
407 407
             )
408 408
         ),
409 409
         'taxes'        => apply_filters(
410 410
             'wpinv_settings_sections_taxes',
411 411
             array(
412
-				'main'  => __( 'Tax Settings', 'invoicing' ),
413
-				'rates' => __( 'Tax Rates', 'invoicing' ),
414
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
412
+				'main'  => __('Tax Settings', 'invoicing'),
413
+				'rates' => __('Tax Rates', 'invoicing'),
414
+				'vat'   => __('EU VAT Settings', 'invoicing'),
415 415
             )
416 416
         ),
417 417
         'emails'       => apply_filters(
418 418
             'wpinv_settings_sections_emails',
419 419
             array(
420
-				'main' => __( 'Email Settings', 'invoicing' ),
420
+				'main' => __('Email Settings', 'invoicing'),
421 421
             )
422 422
         ),
423 423
 
424
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
424
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
425 425
 
426 426
         'privacy'      => apply_filters(
427 427
             'wpinv_settings_sections_privacy',
428 428
             array(
429
-				'main' => __( 'Privacy policy', 'invoicing' ),
429
+				'main' => __('Privacy policy', 'invoicing'),
430 430
             )
431 431
         ),
432 432
         'misc'         => apply_filters(
433 433
             'wpinv_settings_sections_misc',
434 434
             array(
435
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
436
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
435
+				'main'       => __('Miscellaneous', 'invoicing'),
436
+				'custom-css' => __('Custom CSS', 'invoicing'),
437 437
             )
438 438
         ),
439 439
         'tools'        => apply_filters(
440 440
             'wpinv_settings_sections_tools',
441 441
             array(
442
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
442
+				'main' => __('Diagnostic Tools', 'invoicing'),
443 443
             )
444 444
         ),
445 445
     );
446 446
 
447
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
447
+    $sections = apply_filters('wpinv_settings_sections', $sections);
448 448
 
449 449
     return $sections;
450 450
 }
451 451
 
452
-function wpinv_get_pages( $with_slug = false, $default_label = null ) {
452
+function wpinv_get_pages($with_slug = false, $default_label = null) {
453 453
 	$pages_options = array();
454 454
 
455
-	if ( $default_label !== null && $default_label !== false ) {
456
-		$pages_options = array( '' => $default_label ); // Blank option
455
+	if ($default_label !== null && $default_label !== false) {
456
+		$pages_options = array('' => $default_label); // Blank option
457 457
 	}
458 458
 
459 459
 	$pages = get_pages();
460
-	if ( $pages ) {
461
-		foreach ( $pages as $page ) {
460
+	if ($pages) {
461
+		foreach ($pages as $page) {
462 462
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
463
-            $pages_options[ $page->ID ] = $title;
463
+            $pages_options[$page->ID] = $title;
464 464
 		}
465 465
 	}
466 466
 
467 467
 	return $pages_options;
468 468
 }
469 469
 
470
-function wpinv_header_callback( $args ) {
471
-	if ( ! empty( $args['desc'] ) ) {
472
-        echo wp_kses_post( $args['desc'] );
470
+function wpinv_header_callback($args) {
471
+	if (!empty($args['desc'])) {
472
+        echo wp_kses_post($args['desc']);
473 473
     }
474 474
 }
475 475
 
476
-function wpinv_hidden_callback( $args ) {
476
+function wpinv_hidden_callback($args) {
477 477
 
478
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
479
-	$value   = wpinv_get_option( $args['id'], $std );
478
+	$std     = isset($args['std']) ? $args['std'] : '';
479
+	$value   = wpinv_get_option($args['id'], $std);
480 480
 
481
-	if ( isset( $args['set_value'] ) ) {
481
+	if (isset($args['set_value'])) {
482 482
 		$value = $args['set_value'];
483 483
 	}
484 484
 
485
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
485
+	if (isset($args['faux']) && true === $args['faux']) {
486 486
 		$args['readonly'] = true;
487
-		$name  = '';
487
+		$name = '';
488 488
 	} else {
489
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
489
+		$name = 'wpinv_settings[' . esc_attr($args['id']) . ']';
490 490
 	}
491 491
 
492
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
492
+	echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />';
493 493
 
494 494
 }
495 495
 
496 496
 /**
497 497
  * Displays a checkbox settings callback.
498 498
  */
499
-function wpinv_checkbox_callback( $args ) {
499
+function wpinv_checkbox_callback($args) {
500 500
 
501
-	$std = isset( $args['std'] ) ? $args['std'] : '';
502
-	$std = wpinv_get_option( $args['id'], $std );
503
-	$id  = esc_attr( $args['id'] );
501
+	$std = isset($args['std']) ? $args['std'] : '';
502
+	$std = wpinv_get_option($args['id'], $std);
503
+	$id  = esc_attr($args['id']);
504 504
 
505
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
505
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
506 506
 	?>
507 507
 		<fieldset>
508 508
 			<label>
509
-				<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
510
-				<?php echo wp_kses_post( $args['desc'] ); ?>
509
+				<input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
510
+				<?php echo wp_kses_post($args['desc']); ?>
511 511
 			</label>
512 512
 		</fieldset>
513 513
 	<?php
514 514
 }
515 515
 
516
-function wpinv_multicheck_callback( $args ) {
516
+function wpinv_multicheck_callback($args) {
517 517
 
518
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
519
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518
+	$sanitize_id = wpinv_sanitize_key($args['id']);
519
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
520 520
 
521
-	if ( ! empty( $args['options'] ) ) {
521
+	if (!empty($args['options'])) {
522 522
 
523
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
524
-		$value   = wpinv_get_option( $args['id'], $std );
523
+		$std     = isset($args['std']) ? $args['std'] : array();
524
+		$value   = wpinv_get_option($args['id'], $std);
525 525
 
526
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
527
-        foreach ( $args['options'] as $key => $option ) :
528
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
529
-			if ( in_array( $sanitize_key, $value ) ) {
526
+		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">';
527
+        foreach ($args['options'] as $key => $option) :
528
+			$sanitize_key = esc_attr(wpinv_sanitize_key($key));
529
+			if (in_array($sanitize_key, $value)) {
530 530
 				$enabled = $sanitize_key;
531 531
 			} else {
532 532
 				$enabled = null;
533 533
 			}
534
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
535
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
534
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
535
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>';
536 536
 		endforeach;
537 537
 		echo '</div>';
538
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
538
+		echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
539 539
 	}
540 540
 }
541 541
 
542
-function wpinv_payment_icons_callback( $args ) {
542
+function wpinv_payment_icons_callback($args) {
543 543
 
544
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
545
-	$value   = wpinv_get_option( $args['id'], false );
544
+    $sanitize_id = wpinv_sanitize_key($args['id']);
545
+	$value = wpinv_get_option($args['id'], false);
546 546
 
547
-	if ( ! empty( $args['options'] ) ) {
548
-		foreach ( $args['options'] as $key => $option ) {
549
-            $sanitize_key = wpinv_sanitize_key( $key );
547
+	if (!empty($args['options'])) {
548
+		foreach ($args['options'] as $key => $option) {
549
+            $sanitize_key = wpinv_sanitize_key($key);
550 550
 
551
-			if ( empty( $value ) ) {
551
+			if (empty($value)) {
552 552
 				$enabled = $option;
553 553
 			} else {
554 554
 				$enabled = null;
555 555
 			}
556 556
 
557
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
557
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
558 558
 
559
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
559
+				echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
560 560
 
561
-				if ( wpinv_string_is_image_url( $key ) ) {
562
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
+				if (wpinv_string_is_image_url($key)) {
562
+				echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563 563
 				} else {
564
-				$card = strtolower( str_replace( ' ', '', $option ) );
564
+				$card = strtolower(str_replace(' ', '', $option));
565 565
 
566
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
567
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
+				if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
567
+					$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
568 568
 					} else {
569
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
569
+					$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
570 570
 					$content_dir = WP_CONTENT_DIR;
571 571
 
572
-					if ( function_exists( 'wp_normalize_path' ) ) {
572
+					if (function_exists('wp_normalize_path')) {
573 573
 						// Replaces backslashes with forward slashes for Windows systems
574
-						$image = wp_normalize_path( $image );
575
-						$content_dir = wp_normalize_path( $content_dir );
574
+						$image = wp_normalize_path($image);
575
+						$content_dir = wp_normalize_path($content_dir);
576 576
 						}
577 577
 
578
-					$image = str_replace( $content_dir, content_url(), $image );
578
+					$image = str_replace($content_dir, content_url(), $image);
579 579
 					}
580 580
 
581
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
581
+				echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
582 582
 				}
583
-			echo wp_kses_post( $option ) . '</label>';
583
+			echo wp_kses_post($option) . '</label>';
584 584
 		}
585
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
585
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
586 586
 	}
587 587
 }
588 588
 
589 589
 /**
590 590
  * Displays a radio settings field.
591 591
  */
592
-function wpinv_radio_callback( $args ) {
592
+function wpinv_radio_callback($args) {
593 593
 
594
-	$std = isset( $args['std'] ) ? $args['std'] : '';
595
-	$std = wpinv_get_option( $args['id'], $std );
594
+	$std = isset($args['std']) ? $args['std'] : '';
595
+	$std = wpinv_get_option($args['id'], $std);
596 596
 	?>
597 597
 		<fieldset>
598
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
599
-				<?php foreach ( $args['options'] as $key => $option ) : ?>
598
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
599
+				<?php foreach ($args['options'] as $key => $option) : ?>
600 600
 					<li>
601 601
 						<label>
602
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
603
-							<?php echo wp_kses_post( $option ); ?>
602
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
603
+							<?php echo wp_kses_post($option); ?>
604 604
 						</label>
605 605
 					</li>
606 606
 				<?php endforeach; ?>
607 607
 			</ul>
608 608
 		</fieldset>
609 609
 	<?php
610
-	getpaid_settings_description_callback( $args );
610
+	getpaid_settings_description_callback($args);
611 611
 }
612 612
 
613 613
 /**
614 614
  * Displays a description if available.
615 615
  */
616
-function getpaid_settings_description_callback( $args ) {
616
+function getpaid_settings_description_callback($args) {
617 617
 
618
-	if ( ! empty( $args['desc'] ) ) {
618
+	if (!empty($args['desc'])) {
619 619
 		$description = $args['desc'];
620
-		echo wp_kses_post( "<p class='description'>$description</p>" );
620
+		echo wp_kses_post("<p class='description'>$description</p>");
621 621
 	}
622 622
 
623 623
 }
@@ -632,35 +632,35 @@  discard block
 block discarded – undo
632 632
 	</tr>
633 633
 	<tr class="bsui">
634 634
     	<td colspan="2" class="p-0">
635
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
635
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
636 636
 
637 637
 	<?php
638 638
 }
639 639
 
640
-function wpinv_gateway_select_callback( $args ) {
640
+function wpinv_gateway_select_callback($args) {
641 641
 
642
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
643
-    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
645
-	$value   = wpinv_get_option( $args['id'], $std );
642
+    $sanitize_id = wpinv_sanitize_key($args['id']);
643
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
644
+	$std     = isset($args['std']) ? $args['std'] : '';
645
+	$value   = wpinv_get_option($args['id'], $std);
646 646
 
647
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
647
+	echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
649
+	foreach ($args['options'] as $key => $option) :
650 650
 
651
-		echo '<option value="' . esc_attr( $key ) . '" ';
651
+		echo '<option value="' . esc_attr($key) . '" ';
652 652
 
653
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
654
-            selected( $key, $args['selected'] );
653
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
654
+            selected($key, $args['selected']);
655 655
         } else {
656
-            selected( $key, $value );
656
+            selected($key, $value);
657 657
         }
658 658
 
659
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
659
+		echo '>' . esc_html($option['admin_label']) . '</option>';
660 660
 	endforeach;
661 661
 
662 662
 	echo '</select>';
663
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
663
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
664 664
 }
665 665
 
666 666
 /**
@@ -669,16 +669,16 @@  discard block
 block discarded – undo
669 669
  * @param array $args
670 670
  * @return string
671 671
  */
672
-function wpinv_settings_attrs_helper( $args ) {
672
+function wpinv_settings_attrs_helper($args) {
673 673
 
674
-	$value = isset( $args['std'] ) ? $args['std'] : '';
675
-	$id    = esc_attr( $args['id'] );
676
-	$value = is_scalar( $value ) ? $value : '';
674
+	$value = isset($args['std']) ? $args['std'] : '';
675
+	$id    = esc_attr($args['id']);
676
+	$value = is_scalar($value) ? $value : '';
677 677
 
678 678
 	$attrs = array(
679
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
680
-		'readonly' => ! empty( $args['faux'] ),
681
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
679
+		'name'     => !empty($args['faux']) ? false : "wpinv_settings[$id]",
680
+		'readonly' => !empty($args['faux']),
681
+		'value'    => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value),
682 682
 		'id'       => 'wpinv-settings-' . $args['id'],
683 683
 		'style'    => $args['style'],
684 684
 		'class'    => $args['class'],
@@ -686,20 +686,20 @@  discard block
 block discarded – undo
686 686
 		'data-placeholder' => $args['placeholder'],
687 687
 	);
688 688
 
689
-	if ( ! empty( $args['onchange'] ) ) {
689
+	if (!empty($args['onchange'])) {
690 690
 		$attrs['onchange'] = $args['onchange'];
691 691
 	}
692 692
 
693
-	foreach ( $attrs as $key => $value ) {
693
+	foreach ($attrs as $key => $value) {
694 694
 
695
-		if ( false === $value ) {
695
+		if (false === $value) {
696 696
 			continue;
697 697
 		}
698 698
 
699
-		if ( true === $value ) {
700
-			echo ' ' . esc_attr( $key );
699
+		if (true === $value) {
700
+			echo ' ' . esc_attr($key);
701 701
 		} else {
702
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
702
+			echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"';
703 703
 		}
704 704
 
705 705
 	}
@@ -709,14 +709,14 @@  discard block
 block discarded – undo
709 709
 /**
710 710
  * Displays a text input settings callback.
711 711
  */
712
-function wpinv_text_callback( $args ) {
712
+function wpinv_text_callback($args) {
713 713
 
714
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
714
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
715 715
 
716 716
 	?>
717 717
 		<label style="width: 100%;">
718
-			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
719
-			<?php echo wp_kses_post( $desc ); ?>
718
+			<input type="text" <?php wpinv_settings_attrs_helper($args); ?>>
719
+			<?php echo wp_kses_post($desc); ?>
720 720
 		</label>
721 721
 	<?php
722 722
 
@@ -725,48 +725,48 @@  discard block
 block discarded – undo
725 725
 /**
726 726
  * Displays a number input settings callback.
727 727
  */
728
-function wpinv_number_callback( $args ) {
728
+function wpinv_number_callback($args) {
729 729
 
730
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
730
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
731 731
 
732 732
 	?>
733 733
 		<label style="width: 100%;">
734
-			<input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
735
-			<?php echo wp_kses_post( $desc ); ?>
734
+			<input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>>
735
+			<?php echo wp_kses_post($desc); ?>
736 736
 		</label>
737 737
 	<?php
738 738
 
739 739
 }
740 740
 
741
-function wpinv_textarea_callback( $args ) {
741
+function wpinv_textarea_callback($args) {
742 742
 
743
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
744
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
745
-	$value   = wpinv_get_option( $args['id'], $std );
743
+    $sanitize_id = wpinv_sanitize_key($args['id']);
744
+	$std     = isset($args['std']) ? $args['std'] : '';
745
+	$value   = wpinv_get_option($args['id'], $std);
746 746
 
747
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
748
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
747
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
748
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
749 749
 
750
-	echo '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
751
-	echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
750
+	echo '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
751
+	echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
752 752
 
753 753
 }
754 754
 
755
-function wpinv_password_callback( $args ) {
755
+function wpinv_password_callback($args) {
756 756
 
757
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
758
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
759
-	$value   = wpinv_get_option( $args['id'], $std );
757
+    $sanitize_id = wpinv_sanitize_key($args['id']);
758
+	$std     = isset($args['std']) ? $args['std'] : '';
759
+	$value   = wpinv_get_option($args['id'], $std);
760 760
 
761
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
762
-	echo '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
763
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
761
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
762
+	echo '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
763
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
764 764
 
765 765
 }
766 766
 
767
-function wpinv_missing_callback( $args ) {
767
+function wpinv_missing_callback($args) {
768 768
 	printf(
769
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
769
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
770 770
 		'<strong>' . $args['id'] . '</strong>'
771 771
 	);
772 772
 }
@@ -774,34 +774,34 @@  discard block
 block discarded – undo
774 774
 /**
775 775
  * Displays a number input settings callback.
776 776
  */
777
-function wpinv_select_callback( $args ) {
777
+function wpinv_select_callback($args) {
778 778
 
779
-	$desc   = wp_kses_post( $args['desc'] );
780
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
781
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
782
-	$value  = wpinv_get_option( $args['id'], $value );
783
-	$rand   = uniqid( 'random_id' );
779
+	$desc   = wp_kses_post($args['desc']);
780
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
781
+	$value  = isset($args['std']) ? $args['std'] : '';
782
+	$value  = wpinv_get_option($args['id'], $value);
783
+	$rand   = uniqid('random_id');
784 784
 
785 785
 	?>
786 786
 		<label style="width: 100%;">
787
-			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
788
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
789
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
787
+			<select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true">
788
+				<?php foreach ($args['options'] as $option => $name) : ?>
789
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option>
790 790
 				<?php endforeach; ?>
791 791
 			</select>
792 792
 
793
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
794
-				<a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a>
793
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
794
+				<a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a>
795 795
 			<?php endif; ?>
796 796
 
797
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
798
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a>
797
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
798
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a>
799 799
 				<div id='<?php echo $rand; ?>' style='display:none;'>
800 800
 					<div>
801
-						<h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3>
802
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea>
803
-						<h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3>
804
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea>
801
+						<h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3>
802
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea>
803
+						<h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3>
804
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea>
805 805
 					</div>
806 806
 				</div>
807 807
 			<?php endif; ?>
@@ -812,89 +812,89 @@  discard block
 block discarded – undo
812 812
 
813 813
 }
814 814
 
815
-function wpinv_color_select_callback( $args ) {
815
+function wpinv_color_select_callback($args) {
816 816
 
817
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
818
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
819
-	$value   = wpinv_get_option( $args['id'], $std );
817
+    $sanitize_id = wpinv_sanitize_key($args['id']);
818
+	$std     = isset($args['std']) ? $args['std'] : '';
819
+	$value   = wpinv_get_option($args['id'], $std);
820 820
 
821
-	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
821
+	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
822 822
 
823
-	foreach ( $args['options'] as $option => $color ) {
824
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
823
+	foreach ($args['options'] as $option => $color) {
824
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>';
825 825
 	}
826 826
 
827 827
 	echo '</select>';
828
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
828
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
829 829
 
830 830
 }
831 831
 
832
-function wpinv_rich_editor_callback( $args ) {
832
+function wpinv_rich_editor_callback($args) {
833 833
 	global $wp_version;
834 834
 
835
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
835
+    $sanitize_id = wpinv_sanitize_key($args['id']);
836 836
 
837
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
838
-	$value   = wpinv_get_option( $args['id'], $std );
837
+	$std     = isset($args['std']) ? $args['std'] : '';
838
+	$value   = wpinv_get_option($args['id'], $std);
839 839
 
840
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
840
+	if (!empty($args['allow_blank']) && empty($value)) {
841 841
 		$value = $std;
842 842
 	}
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+	$rows = isset($args['size']) ? $args['size'] : 20;
845 845
 
846 846
 	echo '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
847
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
848 848
 		wp_editor(
849
-            stripslashes( $value ),
850
-            'wpinv_settings_' . esc_attr( $args['id'] ),
849
+            stripslashes($value),
850
+            'wpinv_settings_' . esc_attr($args['id']),
851 851
             array(
852
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
853
-				'textarea_rows' => absint( $rows ),
852
+				'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']',
853
+				'textarea_rows' => absint($rows),
854 854
 				'media_buttons' => false,
855 855
             )
856 856
         );
857 857
 	} else {
858
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
858
+		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
859 859
 	}
860 860
 
861
-	echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
861
+	echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
862 862
 
863 863
 }
864 864
 
865
-function wpinv_upload_callback( $args ) {
865
+function wpinv_upload_callback($args) {
866 866
 
867
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
867
+    $sanitize_id = wpinv_sanitize_key($args['id']);
868 868
 
869
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
870
-	$value   = wpinv_get_option( $args['id'], $std );
869
+	$std     = isset($args['std']) ? $args['std'] : '';
870
+	$value   = wpinv_get_option($args['id'], $std);
871 871
 
872
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
873
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
874
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
875
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
872
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
873
+	echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
874
+	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
875
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
876 876
 
877 877
 }
878 878
 
879
-function wpinv_color_callback( $args ) {
879
+function wpinv_color_callback($args) {
880 880
 
881
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
882
-	$value       = wpinv_get_option( $args['id'], $std );
883
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
881
+	$std         = isset($args['std']) ? $args['std'] : '';
882
+	$value       = wpinv_get_option($args['id'], $std);
883
+    $sanitize_id = wpinv_sanitize_key($args['id']);
884 884
 
885
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
886
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
885
+	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />';
886
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
887 887
 
888 888
 }
889 889
 
890
-function wpinv_country_states_callback( $args ) {
890
+function wpinv_country_states_callback($args) {
891 891
 
892
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
893
-	$value   = wpinv_get_option( $args['id'], $std );
892
+	$std     = isset($args['std']) ? $args['std'] : '';
893
+	$value   = wpinv_get_option($args['id'], $std);
894 894
 
895
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
895
+    $sanitize_id = wpinv_sanitize_key($args['id']);
896 896
 
897
-	if ( isset( $args['placeholder'] ) ) {
897
+	if (isset($args['placeholder'])) {
898 898
 		$placeholder = $args['placeholder'];
899 899
 	} else {
900 900
 		$placeholder = '';
@@ -902,15 +902,15 @@  discard block
 block discarded – undo
902 902
 
903 903
 	$states = wpinv_get_country_states();
904 904
 
905
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
906
-	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
905
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
906
+	echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
907 907
 
908
-	foreach ( $states as $option => $name ) {
909
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
908
+	foreach ($states as $option => $name) {
909
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>';
910 910
 	}
911 911
 
912 912
 	echo '</select>';
913
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
913
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
914 914
 
915 915
 }
916 916
 
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 	</tr>
925 925
 	<tr class="bsui">
926 926
     	<td colspan="2" class="p-0">
927
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
927
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
928 928
 
929 929
 	<?php
930 930
 
@@ -933,14 +933,14 @@  discard block
 block discarded – undo
933 933
 /**
934 934
  * Displays a tax rate' edit row.
935 935
  */
936
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
936
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
937 937
 	ob_start();
938 938
 
939
-	$key                      = sanitize_key( $key );
940
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
941
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
939
+	$key                      = sanitize_key($key);
940
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
941
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
942 942
 
943
-	if ( $echo ) {
943
+	if ($echo) {
944 944
 		echo ob_get_clean();
945 945
 	} else {
946 946
 		return ob_get_clean();
@@ -949,152 +949,152 @@  discard block
 block discarded – undo
949 949
 }
950 950
 
951 951
 
952
-function wpinv_tools_callback( $args ) {
952
+function wpinv_tools_callback($args) {
953 953
     ?>
954 954
     </td><tr>
955 955
     <td colspan="2" class="wpinv_tools_tdbox">
956 956
     <?php
957
-    if ( $args['desc'] ) {
957
+    if ($args['desc']) {
958 958
 ?>
959 959
 <p><?php echo $args['desc']; ?></p><?php } ?>
960
-    <?php do_action( 'wpinv_tools_before' ); ?>
960
+    <?php do_action('wpinv_tools_before'); ?>
961 961
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
962 962
         <thead>
963 963
             <tr>
964
-                <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th>
965
-                <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th>
966
-                <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th>
964
+                <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th>
965
+                <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th>
966
+                <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th>
967 967
             </tr>
968 968
         </thead>
969 969
 
970 970
         <tbody>
971 971
 			<tr>
972
-                <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td>
972
+                <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td>
973 973
                 <td>
974
-                    <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
974
+                    <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
975 975
                 </td>
976 976
                 <td>
977 977
 					<a href="
978 978
                     <?php
979 979
 						echo esc_url(
980 980
 							wp_nonce_url(
981
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
981
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
982 982
 								'getpaid-nonce',
983 983
 								'getpaid-nonce'
984 984
 							)
985 985
 						);
986 986
 					?>
987
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
987
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
988 988
                 </td>
989 989
             </tr>
990 990
 			<tr>
991
-                <td><?php esc_html_e( 'Create Database Tables', 'invoicing' ); ?></td>
991
+                <td><?php esc_html_e('Create Database Tables', 'invoicing'); ?></td>
992 992
                 <td>
993
-                    <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
993
+                    <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
994 994
                 </td>
995 995
                 <td>
996 996
 					<a href="
997 997
                     <?php
998 998
 						echo esc_url(
999 999
 							wp_nonce_url(
1000
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1000
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
1001 1001
 								'getpaid-nonce',
1002 1002
 								'getpaid-nonce'
1003 1003
 							)
1004 1004
 						);
1005 1005
 					?>
1006
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1006
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1007 1007
                 </td>
1008 1008
             </tr>
1009 1009
 			<tr>
1010
-                <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td>
1010
+                <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td>
1011 1011
                 <td>
1012
-                    <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
1012
+                    <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
1013 1013
                 </td>
1014 1014
                 <td>
1015 1015
 					<a href="
1016 1016
                     <?php
1017 1017
 						echo esc_url(
1018 1018
 							wp_nonce_url(
1019
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1019
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
1020 1020
 								'getpaid-nonce',
1021 1021
 								'getpaid-nonce'
1022 1022
 							)
1023 1023
 						);
1024 1024
 					?>
1025
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1025
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1026 1026
                 </td>
1027 1027
             </tr>
1028 1028
 
1029 1029
 			<tr>
1030
-                <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td>
1030
+                <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td>
1031 1031
                 <td>
1032
-                    <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1032
+                    <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1033 1033
                 </td>
1034 1034
                 <td>
1035 1035
 					<a href="
1036 1036
                     <?php
1037 1037
 						echo esc_url(
1038 1038
 							wp_nonce_url(
1039
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1039
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1040 1040
 								'getpaid-nonce',
1041 1041
 								'getpaid-nonce'
1042 1042
 							)
1043 1043
 						);
1044 1044
 					?>
1045
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1045
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1046 1046
                 </td>
1047 1047
             </tr>
1048 1048
 
1049 1049
 			<tr>
1050
-                <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td>
1050
+                <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td>
1051 1051
                 <td>
1052
-                    <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small>
1052
+                    <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small>
1053 1053
                 </td>
1054 1054
                 <td>
1055 1055
 					<a href="
1056 1056
                     <?php
1057
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1057
+						echo esc_url(admin_url('index.php?page=gp-setup'));
1058 1058
 					?>
1059
-                    " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1059
+                    " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a>
1060 1060
                 </td>
1061 1061
             </tr>
1062 1062
 
1063
-			<?php do_action( 'wpinv_tools_row' ); ?>
1063
+			<?php do_action('wpinv_tools_row'); ?>
1064 1064
         </tbody>
1065 1065
     </table>
1066
-    <?php do_action( 'wpinv_tools_after' ); ?>
1066
+    <?php do_action('wpinv_tools_after'); ?>
1067 1067
     <?php
1068 1068
 }
1069 1069
 
1070 1070
 
1071
-function wpinv_descriptive_text_callback( $args ) {
1072
-	echo wp_kses_post( $args['desc'] );
1071
+function wpinv_descriptive_text_callback($args) {
1072
+	echo wp_kses_post($args['desc']);
1073 1073
 }
1074 1074
 
1075
-function wpinv_raw_html_callback( $args ) {
1076
-	echo wp_kses_post( $args['desc'] );
1075
+function wpinv_raw_html_callback($args) {
1076
+	echo wp_kses_post($args['desc']);
1077 1077
 }
1078 1078
 
1079
-function wpinv_hook_callback( $args ) {
1080
-	do_action( 'wpinv_' . $args['id'], $args );
1079
+function wpinv_hook_callback($args) {
1080
+	do_action('wpinv_' . $args['id'], $args);
1081 1081
 }
1082 1082
 
1083 1083
 function wpinv_set_settings_cap() {
1084 1084
 	return wpinv_get_capability();
1085 1085
 }
1086
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1086
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1087 1087
 
1088 1088
 
1089
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1090
-    $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1091
-    $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1089
+function wpinv_on_update_settings($old_value, $value, $option) {
1090
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1091
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1092 1092
 
1093
-    if ( $old != $new ) {
1094
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1093
+    if ($old != $new) {
1094
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1095 1095
     }
1096 1096
 }
1097
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1097
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1098 1098
 
1099 1099
 /**
1100 1100
  * Returns the merge tags help text.
@@ -1103,16 +1103,16 @@  discard block
 block discarded – undo
1103 1103
  *
1104 1104
  * @return string
1105 1105
  */
1106
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1106
+function wpinv_get_merge_tags_help_text($subscription = false) {
1107 1107
 
1108 1108
 	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1109 1109
 	$link = sprintf(
1110 1110
 		'<strong><a href="%s" target="_blank">%s</a></strong>',
1111 1111
 		$url,
1112
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1112
+		esc_html__('View available merge tags.', 'wpinv-quotes')
1113 1113
 	);
1114 1114
 
1115
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1115
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1116 1116
 
1117 1117
 	return "$description $link";
1118 1118
 
Please login to merge, or discard this patch.
includes/wpinv-address-functions.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+    $country = wpinv_get_option( 'default_country', 'UK' );
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+    return apply_filters( 'wpinv_default_country', $country );
19 19
 }
20 20
 
21 21
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function wpinv_sanitize_country( $country ) {
38 38
 
39
-	// Enure the country is specified
39
+    // Enure the country is specified
40 40
     if ( empty( $country ) ) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+    $state = wpinv_get_option( 'default_state', '' );
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+    return apply_filters( 'wpinv_default_state', $state );
72 72
 }
73 73
 
74 74
 function wpinv_state_name( $state_code = '', $country_code = '' ) {
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 
304 304
     $country = wpinv_sanitize_country( $country );
305 305
 
306
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
307
-		if ( false !== array_search( $country, $countries, true ) ) {
308
-			return $continent_code;
309
-		}
310
-	}
306
+    foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
307
+        if ( false !== array_search( $country, $countries, true ) ) {
308
+            return $continent_code;
309
+        }
310
+    }
311 311
 
312 312
     return '';
313 313
 
@@ -599,31 +599,31 @@  discard block
 block discarded – undo
599 599
 }
600 600
 
601 601
 function wpinv_get_states_field() {
602
-	if ( empty( $_POST['country'] ) ) {
603
-		$_POST['country'] = wpinv_get_default_country();
604
-	}
605
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
602
+    if ( empty( $_POST['country'] ) ) {
603
+        $_POST['country'] = wpinv_get_default_country();
604
+    }
605
+    $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
606 606
 
607
-	if ( ! empty( $states ) ) {
608
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
607
+    if ( ! empty( $states ) ) {
608
+        $sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
609 609
 
610 610
         $class  = isset( $_POST['class'] ) ? esc_attr( sanitize_text_field( $_POST['class'] ) ) : '';
611 611
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
612 612
 
613 613
         $args  = array(
614
-			'name'             => $sanitized_field_name,
615
-			'id'               => $sanitized_field_name,
616
-			'class'            => implode( ' ', array_unique( explode( ' ', $class ) ) ),
617
-			'options'          => array_merge( array( '' => '' ), $states ),
618
-			'show_option_all'  => false,
619
-			'show_option_none' => false,
620
-		);
621
-
622
-		wpinv_html_select( $args );
623
-
624
-	} else {
625
-		echo 'nostates';
626
-	}
614
+            'name'             => $sanitized_field_name,
615
+            'id'               => $sanitized_field_name,
616
+            'class'            => implode( ' ', array_unique( explode( ' ', $class ) ) ),
617
+            'options'          => array_merge( array( '' => '' ), $states ),
618
+            'show_option_all'  => false,
619
+            'show_option_none' => false,
620
+        );
621
+
622
+        wpinv_html_select( $args );
623
+
624
+    } else {
625
+        echo 'nostates';
626
+    }
627 627
 
628 628
 }
629 629
 
@@ -642,47 +642,47 @@  discard block
 block discarded – undo
642 642
  */
643 643
 function wpinv_get_address_formats() {
644 644
 
645
-		return apply_filters(
645
+        return apply_filters(
646 646
             'wpinv_localisation_address_formats',
647
-			array(
648
-				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
649
-				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
650
-				'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
651
-				'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
652
-				'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}&nbsp;&nbsp;{{zip}}\n{{country}}",
653
-				'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
-				'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
655
-				'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
656
-				'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
657
-				'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
658
-				'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
-				'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
-				'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
-				'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
662
-				'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
663
-				'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
664
-				'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
665
-				'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
666
-				'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
667
-				'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
668
-				'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
669
-				'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
670
-				'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
671
-				'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
672
-				'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
-				'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
674
-				'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
-				'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
-				'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
-				'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
-				'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
679
-				'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
-				'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
681
-				'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
682
-				'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
683
-				'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
684
-			)
685
-		);
647
+            array(
648
+                'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
649
+                'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
650
+                'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
651
+                'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
652
+                'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}&nbsp;&nbsp;{{zip}}\n{{country}}",
653
+                'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
+                'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
655
+                'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
656
+                'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
657
+                'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
658
+                'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
+                'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
+                'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
+                'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
662
+                'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
663
+                'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
664
+                'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
665
+                'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
666
+                'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
667
+                'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
668
+                'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
669
+                'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
670
+                'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
671
+                'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
672
+                'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
+                'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
674
+                'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
+                'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
+                'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
+                'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
+                'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
679
+                'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
+                'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
681
+                'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
682
+                'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
683
+                'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
684
+            )
685
+        );
686 686
 }
687 687
 
688 688
 /**
@@ -699,21 +699,21 @@  discard block
 block discarded – undo
699 699
     }
700 700
 
701 701
     // Get all formats.
702
-	$formats = wpinv_get_address_formats();
702
+    $formats = wpinv_get_address_formats();
703 703
 
704
-	// Get format for the specified country.
705
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
704
+    // Get format for the specified country.
705
+    $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
706 706
 
707 707
     /**
708
-	 * Filters the address format to use on Invoices.
708
+     * Filters the address format to use on Invoices.
709 709
      *
710 710
      * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed.
711
-	 *
712
-	 * @since 1.0.13
713
-	 *
714
-	 * @param string $format  The address format to use.
711
+     *
712
+     * @since 1.0.13
713
+     *
714
+     * @param string $format  The address format to use.
715 715
      * @param string $country The country who's address format is being retrieved.
716
-	 */
716
+     */
717 717
     return apply_filters( 'wpinv_get_full_address_format', $format, $country );
718 718
 }
719 719
 
@@ -734,8 +734,8 @@  discard block
 block discarded – undo
734 734
         'country'    => '',
735 735
         'zip'        => '',
736 736
         'first_name' => '',
737
-		'last_name'  => '',
738
-		'company'    => '',
737
+        'last_name'  => '',
738
+        'company'    => '',
739 739
     );
740 740
 
741 741
     $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
@@ -756,14 +756,14 @@  discard block
 block discarded – undo
756 756
     $args['country_code'] = $country;
757 757
 
758 758
     /**
759
-	 * Filters the address format replacements to use on Invoices.
759
+     * Filters the address format replacements to use on Invoices.
760
+     *
761
+     *
762
+     * @since 1.0.13
760 763
      *
761
-	 *
762
-	 * @since 1.0.13
763
-	 *
764
-	 * @param array $replacements  The address replacements to use.
764
+     * @param array $replacements  The address replacements to use.
765 765
      * @param array $billing_details  The billing details to use.
766
-	 */
766
+     */
767 767
     $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
768 768
 
769 769
     $return = array();
@@ -786,5 +786,5 @@  discard block
 block discarded – undo
786 786
  * @return string
787 787
  */
788 788
 function wpinv_trim_formatted_address_line( $line ) {
789
-	return trim( $line, ', ' );
789
+    return trim( $line, ', ' );
790 790
 }
Please login to merge, or discard this patch.
Spacing   +143 added lines, -143 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' ) ) {
10
+if (!defined('WPINC')) {
11 11
     exit;
12 12
 }
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+	$country = wpinv_get_option('default_country', 'UK');
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+	return apply_filters('wpinv_default_country', $country);
19 19
 }
20 20
 
21 21
 /**
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string
25 25
  */
26
-function getpaid_get_ip_country( $ip_address = '' ) {
27
-    $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true );
26
+function getpaid_get_ip_country($ip_address = '') {
27
+    $country = GetPaid_Geolocation::geolocate_ip($ip_address, true);
28 28
     return $country['country'];
29 29
 }
30 30
 
@@ -34,59 +34,59 @@  discard block
 block discarded – undo
34 34
  * @param string $country The country code to sanitize
35 35
  * @return array
36 36
  */
37
-function wpinv_sanitize_country( $country ) {
37
+function wpinv_sanitize_country($country) {
38 38
 
39 39
 	// Enure the country is specified
40
-    if ( empty( $country ) ) {
40
+    if (empty($country)) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
43
-    return trim( wpinv_utf8_strtoupper( $country ) );
43
+    return trim(wpinv_utf8_strtoupper($country));
44 44
 
45 45
 }
46 46
 
47
-function wpinv_is_base_country( $country ) {
47
+function wpinv_is_base_country($country) {
48 48
     $base_country = wpinv_get_default_country();
49 49
 
50
-    if ( $base_country === 'UK' ) {
50
+    if ($base_country === 'UK') {
51 51
         $base_country = 'GB';
52 52
     }
53
-    if ( $country == 'UK' ) {
53
+    if ($country == 'UK') {
54 54
         $country = 'GB';
55 55
     }
56 56
 
57
-    return ( $country && $country === $base_country ) ? true : false;
57
+    return ($country && $country === $base_country) ? true : false;
58 58
 }
59 59
 
60
-function wpinv_country_name( $country_code = '' ) {
60
+function wpinv_country_name($country_code = '') {
61 61
     $countries = wpinv_get_country_list();
62 62
     $country_code = $country_code == 'UK' ? 'GB' : $country_code;
63
-    $country = isset( $countries[ $country_code ] ) ? $countries[ $country_code ] : $country_code;
63
+    $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code;
64 64
 
65
-    return apply_filters( 'wpinv_country_name', $country, $country_code );
65
+    return apply_filters('wpinv_country_name', $country, $country_code);
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+	$state = wpinv_get_option('default_state', '');
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+	return apply_filters('wpinv_default_state', $state);
72 72
 }
73 73
 
74
-function wpinv_state_name( $state_code = '', $country_code = '' ) {
74
+function wpinv_state_name($state_code = '', $country_code = '') {
75 75
     $state = $state_code;
76 76
 
77
-    if ( ! empty( $country_code ) ) {
78
-        $states = wpinv_get_country_states( $country_code );
77
+    if (!empty($country_code)) {
78
+        $states = wpinv_get_country_states($country_code);
79 79
 
80
-        $state = ! empty( $states ) && isset( $states[ $state_code ] ) ? $states[ $state_code ] : $state;
80
+        $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state;
81 81
     }
82 82
 
83
-    return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code );
83
+    return apply_filters('wpinv_state_name', $state, $state_code, $country_code);
84 84
 }
85 85
 
86 86
 function wpinv_store_address() {
87
-    $address = wpinv_get_option( 'store_address', '' );
87
+    $address = wpinv_get_option('store_address', '');
88 88
 
89
-    return apply_filters( 'wpinv_store_address', $address );
89
+    return apply_filters('wpinv_store_address', $address);
90 90
 }
91 91
 
92 92
 /**
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  *
95 95
  * @param WPInv_Invoice $invoice
96 96
  */
97
-function getpaid_maybe_add_default_address( &$invoice ) {
97
+function getpaid_maybe_add_default_address(&$invoice) {
98 98
 
99 99
     $user_id = $invoice->get_user_id();
100 100
 
101 101
     // Abort if the invoice belongs to no one.
102
-    if ( empty( $user_id ) ) {
102
+    if (empty($user_id)) {
103 103
         return;
104 104
     }
105 105
 
106 106
     // Fill in defaults whenever necessary.
107
-    foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) {
107
+    foreach (wpinv_get_user_address($user_id) as $key => $value) {
108 108
 
109
-        if ( is_callable( $invoice, "get_$key" ) ) {
110
-            $current = call_user_func( array( $invoice, "get_$key" ) );
109
+        if (is_callable($invoice, "get_$key")) {
110
+            $current = call_user_func(array($invoice, "get_$key"));
111 111
 
112
-            if ( empty( $current ) ) {
112
+            if (empty($current)) {
113 113
                 $method = "set_$key";
114
-                $invoice->$method( $value );
114
+                $invoice->$method($value);
115 115
             }
116 116
 }
117 117
 }
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
     $address_fields = apply_filters(
129 129
         'getpaid_user_address_fields',
130 130
         array(
131
-            'first_name' => __( 'First Name', 'invoicing' ),
132
-            'last_name'  => __( 'Last Name', 'invoicing' ),
133
-            'address'    => __( 'Address', 'invoicing' ),
134
-            'city'       => __( 'City', 'invoicing' ),
135
-            'country'    => __( 'Country', 'invoicing' ),
136
-            'state'      => __( 'State', 'invoicing' ),
137
-            'zip'        => __( 'Zip/Postal Code', 'invoicing' ),
138
-            'phone'      => __( 'Phone Number', 'invoicing' ),
139
-            'company'    => __( 'Company', 'invoicing' ),
140
-            'company_id' => __( 'Company ID', 'invoicing' ),
141
-            'vat_number' => __( 'VAT Number', 'invoicing' ),
131
+            'first_name' => __('First Name', 'invoicing'),
132
+            'last_name'  => __('Last Name', 'invoicing'),
133
+            'address'    => __('Address', 'invoicing'),
134
+            'city'       => __('City', 'invoicing'),
135
+            'country'    => __('Country', 'invoicing'),
136
+            'state'      => __('State', 'invoicing'),
137
+            'zip'        => __('Zip/Postal Code', 'invoicing'),
138
+            'phone'      => __('Phone Number', 'invoicing'),
139
+            'company'    => __('Company', 'invoicing'),
140
+            'company_id' => __('Company ID', 'invoicing'),
141
+            'vat_number' => __('VAT Number', 'invoicing'),
142 142
         )
143 143
     );
144 144
 
145
-    if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) {
146
-        unset( $address_fields['vat_number'] );
145
+    if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) {
146
+        unset($address_fields['vat_number']);
147 147
     }
148 148
 
149 149
     return $address_fields;
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return bool
156 156
  */
157
-function getpaid_is_address_field_whitelisted( $key ) {
158
-    return array_key_exists( $key, getpaid_user_address_fields() );
157
+function getpaid_is_address_field_whitelisted($key) {
158
+    return array_key_exists($key, getpaid_user_address_fields());
159 159
 }
160 160
 
161 161
 /**
@@ -165,30 +165,30 @@  discard block
 block discarded – undo
165 165
  *
166 166
  * @param WPInv_Invoice $invoice
167 167
  */
168
-function getpaid_save_invoice_user_address( $invoice ) {
168
+function getpaid_save_invoice_user_address($invoice) {
169 169
 
170 170
     // Retrieve the invoice.
171
-    $invoice = wpinv_get_invoice( $invoice );
171
+    $invoice = wpinv_get_invoice($invoice);
172 172
 
173 173
     // Abort if it does not exist.
174
-    if ( empty( $invoice ) || $invoice->is_renewal() ) {
174
+    if (empty($invoice) || $invoice->is_renewal()) {
175 175
         return;
176 176
     }
177 177
 
178
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
178
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
179 179
 
180
-        if ( is_callable( array( $invoice, "get_$field" ) ) ) {
181
-            $value = call_user_func( array( $invoice, "get_$field" ) );
180
+        if (is_callable(array($invoice, "get_$field"))) {
181
+            $value = call_user_func(array($invoice, "get_$field"));
182 182
 
183 183
             // Only save if it is not empty.
184
-            if ( ! empty( $value ) ) {
185
-                update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value );
184
+            if (!empty($value)) {
185
+                update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value);
186 186
             }
187 187
 }
188 188
 }
189 189
 
190 190
 }
191
-add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' );
191
+add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address');
192 192
 
193 193
 /**
194 194
  * Retrieves a saved user address.
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
  * @param bool $with_default Whether or not we should use the default country and state.
198 198
  * @return array
199 199
  */
200
-function wpinv_get_user_address( $user_id = 0, $with_default = true ) {
200
+function wpinv_get_user_address($user_id = 0, $with_default = true) {
201 201
 
202 202
     // Prepare the user id.
203
-    $user_id   = empty( $user_id ) ? get_current_user_id() : $user_id;
204
-    $user_info = get_userdata( $user_id );
203
+    $user_id   = empty($user_id) ? get_current_user_id() : $user_id;
204
+    $user_info = get_userdata($user_id);
205 205
 
206 206
     // Abort if non exists.
207
-    if ( empty( $user_info ) ) {
207
+    if (empty($user_info)) {
208 208
         return array();
209 209
     }
210 210
 
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
         'email'   => $user_info->user_email,
215 215
     );
216 216
 
217
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
218
-        $address[ $field ] = getpaid_get_user_address_field( $user_id, $field );
217
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
218
+        $address[$field] = getpaid_get_user_address_field($user_id, $field);
219 219
     }
220 220
 
221
-    $address = array_filter( $address );
221
+    $address = array_filter($address);
222 222
 
223
-    if ( ! $with_default ) {
223
+    if (!$with_default) {
224 224
         return $address;
225 225
     }
226 226
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         'country'    => wpinv_get_default_country(),
232 232
     );
233 233
 
234
-    return getpaid_array_merge_if_empty( $address, $defaults );
234
+    return getpaid_array_merge_if_empty($address, $defaults);
235 235
 
236 236
 }
237 237
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @param string $field The field to use.
243 243
  * @return string|null
244 244
  */
245
-function getpaid_get_user_address_field( $user_id, $field ) {
245
+function getpaid_get_user_address_field($user_id, $field) {
246 246
 
247 247
     $prefixes = array(
248 248
         '_wpinv_',
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
         '',
251 251
     );
252 252
 
253
-    foreach ( $prefixes as $prefix ) {
253
+    foreach ($prefixes as $prefix) {
254 254
 
255 255
         // Meta table.
256
-        $value = get_user_meta( $user_id, $prefix . $field, true );
256
+        $value = get_user_meta($user_id, $prefix . $field, true);
257 257
 
258 258
         // UWP table.
259
-        $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
259
+        $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
260 260
 
261
-        if ( ! empty( $value ) ) {
261
+        if (!empty($value)) {
262 262
             return $value;
263 263
         }
264 264
 }
@@ -274,16 +274,16 @@  discard block
 block discarded – undo
274 274
  * @param string $return What to return.
275 275
  * @return array
276 276
  */
277
-function wpinv_get_continents( $return = 'all' ) {
277
+function wpinv_get_continents($return = 'all') {
278 278
 
279
-    $continents = wpinv_get_data( 'continents' );
279
+    $continents = wpinv_get_data('continents');
280 280
 
281
-    switch ( $return ) {
281
+    switch ($return) {
282 282
         case 'name':
283
-            return wp_list_pluck( $continents, 'name' );
283
+            return wp_list_pluck($continents, 'name');
284 284
             break;
285 285
         case 'countries':
286
-            return wp_list_pluck( $continents, 'countries' );
286
+            return wp_list_pluck($continents, 'countries');
287 287
             break;
288 288
         default:
289 289
             return $continents;
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
  * @param string $country Country code. If no code is specified, defaults to the default country.
300 300
  * @return string
301 301
  */
302
-function wpinv_get_continent_code_for_country( $country = false ) {
302
+function wpinv_get_continent_code_for_country($country = false) {
303 303
 
304
-    $country = wpinv_sanitize_country( $country );
304
+    $country = wpinv_sanitize_country($country);
305 305
 
306
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
307
-		if ( false !== array_search( $country, $countries, true ) ) {
306
+	foreach (wpinv_get_continents('countries') as $continent_code => $countries) {
307
+		if (false !== array_search($country, $countries, true)) {
308 308
 			return $continent_code;
309 309
 		}
310 310
 	}
@@ -320,13 +320,13 @@  discard block
 block discarded – undo
320 320
  * @param string $country Country code. If no code is specified, defaults to the default country.
321 321
  * @return array
322 322
  */
323
-function wpinv_get_country_calling_code( $country = null ) {
323
+function wpinv_get_country_calling_code($country = null) {
324 324
 
325
-    $country = wpinv_sanitize_country( $country );
326
-    $codes   = wpinv_get_data( 'phone-codes' );
327
-    $code    = isset( $codes[ $country ] ) ? $codes[ $country ] : '';
325
+    $country = wpinv_sanitize_country($country);
326
+    $codes   = wpinv_get_data('phone-codes');
327
+    $code    = isset($codes[$country]) ? $codes[$country] : '';
328 328
 
329
-    if ( is_array( $code ) ) {
329
+    if (is_array($code)) {
330 330
         return $code[0];
331 331
     }
332 332
     return $code;
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
  * @param bool $first_empty Whether or not the first item in the list should be empty
340 340
  * @return array
341 341
  */
342
-function wpinv_get_country_list( $first_empty = false ) {
343
-    return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty );
342
+function wpinv_get_country_list($first_empty = false) {
343
+    return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty);
344 344
 }
345 345
 
346 346
 /**
@@ -350,22 +350,22 @@  discard block
 block discarded – undo
350 350
  * @param bool $first_empty Whether or not the first item in the list should be empty
351 351
  * @return array
352 352
  */
353
-function wpinv_get_country_states( $country = null, $first_empty = false ) {
353
+function wpinv_get_country_states($country = null, $first_empty = false) {
354 354
 
355 355
     // Prepare the country.
356
-    $country = wpinv_sanitize_country( $country );
356
+    $country = wpinv_sanitize_country($country);
357 357
 
358 358
     // Fetch all states.
359
-    $all_states = wpinv_get_data( 'states' );
359
+    $all_states = wpinv_get_data('states');
360 360
 
361 361
     // Fetch the specified country's states.
362
-    $states     = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array();
363
-    $states     = apply_filters( "wpinv_{$country}_states", $states );
364
-    $states     = apply_filters( 'wpinv_country_states', $states, $country );
362
+    $states     = isset($all_states[$country]) ? $all_states[$country] : array();
363
+    $states     = apply_filters("wpinv_{$country}_states", $states);
364
+    $states     = apply_filters('wpinv_country_states', $states, $country);
365 365
 
366
-    asort( $states );
366
+    asort($states);
367 367
 
368
-    return wpinv_maybe_add_empty_option( $states, $first_empty );
368
+    return wpinv_maybe_add_empty_option($states, $first_empty);
369 369
 }
370 370
 
371 371
 /**
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
  * @return array
376 376
  */
377 377
 function wpinv_get_us_states_list() {
378
-    return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) );
378
+    return apply_filters('wpinv_usa_states', wpinv_get_country_states('US'));
379 379
 }
380 380
 
381 381
 /**
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
  * @return array
386 386
  */
387 387
 function wpinv_get_canada_states_list() {
388
-    return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) );
388
+    return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA'));
389 389
 }
390 390
 
391 391
 /**
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
  * @return array
396 396
  */
397 397
 function wpinv_get_australia_states_list() {
398
-    return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) );
398
+    return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU'));
399 399
 }
400 400
 
401 401
 /**
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
  * @return array
406 406
  */
407 407
 function wpinv_get_bangladesh_states_list() {
408
-    return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) );
408
+    return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD'));
409 409
 }
410 410
 
411 411
 /**
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
  * @return array
416 416
  */
417 417
 function wpinv_get_brazil_states_list() {
418
-    return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) );
418
+    return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR'));
419 419
 }
420 420
 
421 421
 /**
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
  * @return array
426 426
  */
427 427
 function wpinv_get_bulgaria_states_list() {
428
-    return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) );
428
+    return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG'));
429 429
 }
430 430
 
431 431
 /**
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
  * @return array
436 436
  */
437 437
 function wpinv_get_hong_kong_states_list() {
438
-    return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) );
438
+    return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK'));
439 439
 }
440 440
 
441 441
 /**
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
  * @return array
446 446
  */
447 447
 function wpinv_get_hungary_states_list() {
448
-    return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) );
448
+    return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU'));
449 449
 }
450 450
 
451 451
 /**
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
  * @return array
456 456
  */
457 457
 function wpinv_get_japan_states_list() {
458
-    return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) );
458
+    return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP'));
459 459
 }
460 460
 
461 461
 /**
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
  * @return array
466 466
  */
467 467
 function wpinv_get_china_states_list() {
468
-    return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) );
468
+    return apply_filters('wpinv_china_states', wpinv_get_country_states('CN'));
469 469
 }
470 470
 
471 471
 /**
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
  * @return array
476 476
  */
477 477
 function wpinv_get_new_zealand_states_list() {
478
-    return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) );
478
+    return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ'));
479 479
 }
480 480
 
481 481
 /**
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
  * @return array
486 486
  */
487 487
 function wpinv_get_peru_states_list() {
488
-    return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) );
488
+    return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE'));
489 489
 }
490 490
 
491 491
 /**
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
  * @return array
496 496
  */
497 497
 function wpinv_get_indonesia_states_list() {
498
-    return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) );
498
+    return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID'));
499 499
 }
500 500
 
501 501
 /**
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
  * @return array
506 506
  */
507 507
 function wpinv_get_india_states_list() {
508
-    return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) );
508
+    return apply_filters('wpinv_india_states', wpinv_get_country_states('IN'));
509 509
 }
510 510
 
511 511
 /**
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
  * @return array
516 516
  */
517 517
 function wpinv_get_iran_states_list() {
518
-    return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) );
518
+    return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR'));
519 519
 }
520 520
 
521 521
 /**
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
  * @return array
526 526
  */
527 527
 function wpinv_get_italy_states_list() {
528
-    return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) );
528
+    return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT'));
529 529
 }
530 530
 
531 531
 /**
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
  * @return array
536 536
  */
537 537
 function wpinv_get_malaysia_states_list() {
538
-    return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) );
538
+    return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY'));
539 539
 }
540 540
 
541 541
 /**
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
  * @return array
546 546
  */
547 547
 function wpinv_get_mexico_states_list() {
548
-    return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) );
548
+    return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX'));
549 549
 }
550 550
 
551 551
 /**
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
  * @return array
556 556
  */
557 557
 function wpinv_get_nepal_states_list() {
558
-    return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) );
558
+    return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP'));
559 559
 }
560 560
 
561 561
 /**
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
  * @return array
566 566
  */
567 567
 function wpinv_get_south_africa_states_list() {
568
-    return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) );
568
+    return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA'));
569 569
 }
570 570
 
571 571
 /**
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
  * @return array
576 576
  */
577 577
 function wpinv_get_thailand_states_list() {
578
-    return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) );
578
+    return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH'));
579 579
 }
580 580
 
581 581
 /**
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
  * @return array
586 586
  */
587 587
 function wpinv_get_turkey_states_list() {
588
-    return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) );
588
+    return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR'));
589 589
 }
590 590
 
591 591
 /**
@@ -595,31 +595,31 @@  discard block
 block discarded – undo
595 595
  * @return array
596 596
  */
597 597
 function wpinv_get_spain_states_list() {
598
-    return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) );
598
+    return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES'));
599 599
 }
600 600
 
601 601
 function wpinv_get_states_field() {
602
-	if ( empty( $_POST['country'] ) ) {
602
+	if (empty($_POST['country'])) {
603 603
 		$_POST['country'] = wpinv_get_default_country();
604 604
 	}
605
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
605
+	$states = wpinv_get_country_states(sanitize_text_field($_POST['country']));
606 606
 
607
-	if ( ! empty( $states ) ) {
608
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
607
+	if (!empty($states)) {
608
+		$sanitized_field_name = sanitize_text_field($_POST['field_name']);
609 609
 
610
-        $class  = isset( $_POST['class'] ) ? esc_attr( sanitize_text_field( $_POST['class'] ) ) : '';
610
+        $class  = isset($_POST['class']) ? esc_attr(sanitize_text_field($_POST['class'])) : '';
611 611
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
612 612
 
613
-        $args  = array(
613
+        $args = array(
614 614
 			'name'             => $sanitized_field_name,
615 615
 			'id'               => $sanitized_field_name,
616
-			'class'            => implode( ' ', array_unique( explode( ' ', $class ) ) ),
617
-			'options'          => array_merge( array( '' => '' ), $states ),
616
+			'class'            => implode(' ', array_unique(explode(' ', $class))),
617
+			'options'          => array_merge(array('' => ''), $states),
618 618
 			'show_option_all'  => false,
619 619
 			'show_option_none' => false,
620 620
 		);
621 621
 
622
-		wpinv_html_select( $args );
622
+		wpinv_html_select($args);
623 623
 
624 624
 	} else {
625 625
 		echo 'nostates';
@@ -627,10 +627,10 @@  discard block
 block discarded – undo
627 627
 
628 628
 }
629 629
 
630
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
631
-    $country = ! empty( $country ) ? $country : wpinv_get_default_country();
630
+function wpinv_default_billing_country($country = '', $user_id = 0) {
631
+    $country = !empty($country) ? $country : wpinv_get_default_country();
632 632
 
633
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
633
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
634 634
 }
635 635
 
636 636
 /**
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
  * @see `wpinv_get_invoice_address_replacements`
693 693
  * @return string
694 694
  */
695
-function wpinv_get_full_address_format( $country = false ) {
695
+function wpinv_get_full_address_format($country = false) {
696 696
 
697
-    if ( empty( $country ) ) {
697
+    if (empty($country)) {
698 698
         $country = wpinv_get_default_country();
699 699
     }
700 700
 
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	$formats = wpinv_get_address_formats();
703 703
 
704 704
 	// Get format for the specified country.
705
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
705
+	$format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default'];
706 706
 
707 707
     /**
708 708
 	 * Filters the address format to use on Invoices.
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 	 * @param string $format  The address format to use.
715 715
      * @param string $country The country who's address format is being retrieved.
716 716
 	 */
717
-    return apply_filters( 'wpinv_get_full_address_format', $format, $country );
717
+    return apply_filters('wpinv_get_full_address_format', $format, $country);
718 718
 }
719 719
 
720 720
 /**
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
  * @param array $billing_details customer's billing details
726 726
  * @return array
727 727
  */
728
-function wpinv_get_invoice_address_replacements( $billing_details ) {
728
+function wpinv_get_invoice_address_replacements($billing_details) {
729 729
 
730 730
     $default_args = array(
731 731
         'address'    => '',
@@ -738,15 +738,15 @@  discard block
 block discarded – undo
738 738
 		'company'    => '',
739 739
     );
740 740
 
741
-    $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
741
+    $args    = map_deep(wp_parse_args($billing_details, $default_args), 'trim');
742 742
     $state   = $args['state'];
743 743
     $country = $args['country'];
744 744
 
745 745
     // Handle full country name.
746
-    $full_country = empty( $country ) ? $country : wpinv_country_name( $country );
746
+    $full_country = empty($country) ? $country : wpinv_country_name($country);
747 747
 
748 748
     // Handle full state name.
749
-    $full_state   = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state;
749
+    $full_state   = ($country && $state) ? wpinv_state_name($state, $country) : $state;
750 750
 
751 751
     $args['postcode']    = $args['zip'];
752 752
     $args['name']        = $args['first_name'] . ' ' . $args['last_name'];
@@ -764,14 +764,14 @@  discard block
 block discarded – undo
764 764
 	 * @param array $replacements  The address replacements to use.
765 765
      * @param array $billing_details  The billing details to use.
766 766
 	 */
767
-    $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
767
+    $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details);
768 768
 
769 769
     $return = array();
770 770
 
771
-    foreach ( $replacements as $key => $value ) {
772
-        $value  = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : '';
773
-        $return[ '{{' . $key . '}}' ] = $value;
774
-        $return[ '{{' . $key . '_upper}}' ] = wpinv_utf8_strtoupper( $value );
771
+    foreach ($replacements as $key => $value) {
772
+        $value = is_scalar($value) ? trim(sanitize_text_field($value)) : '';
773
+        $return['{{' . $key . '}}'] = $value;
774
+        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value);
775 775
     }
776 776
 
777 777
     return $return;
@@ -785,6 +785,6 @@  discard block
 block discarded – undo
785 785
  * @since 1.0.14
786 786
  * @return string
787 787
  */
788
-function wpinv_trim_formatted_address_line( $line ) {
789
-	return trim( $line, ', ' );
788
+function wpinv_trim_formatted_address_line($line) {
789
+	return trim($line, ', ');
790 790
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142 142
 function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
143
+    return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
144 144
 }
145 145
 
146 146
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+    return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
162 162
 }
163 163
 
164 164
 /**
@@ -175,125 +175,125 @@  discard block
 block discarded – undo
175 175
 }
176 176
 
177 177
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
178
+    do_action( 'get_template_part_' . $slug, $slug, $name );
179 179
 
180
-	// Setup possible parts
181
-	$templates = array();
182
-	if ( isset( $name ) ) {
183
-		$templates[] = $slug . '-' . $name . '.php';
180
+    // Setup possible parts
181
+    $templates = array();
182
+    if ( isset( $name ) ) {
183
+        $templates[] = $slug . '-' . $name . '.php';
184 184
     }
185
-	$templates[] = $slug . '.php';
185
+    $templates[] = $slug . '.php';
186 186
 
187
-	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+    // Allow template parts to be filtered
188
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
189 189
 
190
-	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+    // Return the part that is found
191
+    return wpinv_locate_tmpl( $templates, $load, false );
192 192
 }
193 193
 
194 194
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
195
-	// No file found yet
196
-	$located = false;
195
+    // No file found yet
196
+    $located = false;
197 197
 
198
-	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
198
+    // Try to find a template file
199
+    foreach ( (array)$template_names as $template_name ) {
200 200
 
201
-		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
203
-			continue;
201
+        // Continue if template is empty
202
+        if ( empty( $template_name ) ) {
203
+            continue;
204 204
         }
205 205
 
206
-		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
206
+        // Trim off any slashes from the template name
207
+        $template_name = ltrim( $template_name, '/' );
208 208
 
209
-		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
209
+        // try locating this template file by looping through the template paths
210
+        foreach ( wpinv_get_theme_template_paths() as $template_path ) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
213
-				$located = $template_path . $template_name;
214
-				break;
215
-			}
216
-		}
212
+            if ( file_exists( $template_path . $template_name ) ) {
213
+                $located = $template_path . $template_name;
214
+                break;
215
+            }
216
+        }
217 217
 
218
-		if ( ! empty( $located ) ) {
219
-			break;
220
-		}
221
-	}
218
+        if ( ! empty( $located ) ) {
219
+            break;
220
+        }
221
+    }
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+    if ( ( true == $load ) && ! empty( $located ) ) {
224
+        load_template( $located, $require_once );
225 225
     }
226 226
 
227
-	return $located;
227
+    return $located;
228 228
 }
229 229
 
230 230
 function wpinv_get_theme_template_paths() {
231
-	$template_dir = wpinv_get_theme_template_dir_name();
231
+    $template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233
-	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
236
-		100 => wpinv_get_templates_dir(),
237
-	);
233
+    $file_paths = array(
234
+        1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
+        10  => trailingslashit( get_template_directory() ) . $template_dir,
236
+        100 => wpinv_get_templates_dir(),
237
+    );
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
240 240
 
241
-	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
241
+    // sort the file paths based on priority
242
+    ksort( $file_paths, SORT_NUMERIC );
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+    return array_map( 'trailingslashit', $file_paths );
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249
-	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
249
+    $pages   = array();
250
+    $pages[] = wpinv_get_option( 'success_page' );
251
+    $pages[] = wpinv_get_option( 'failure_page' );
252
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
253
+    $pages[] = wpinv_get_option( 'invoice_subscription_page' );
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
-		return;
257
-	}
255
+    if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
+        return;
257
+    }
258 258
 
259
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
259
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261 261
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
262 262
 
263 263
 function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
264
+    $classes = (array)$class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
267
-		$classes[] = 'wpinv-checkout';
268
-		$classes[] = 'wpinv-page';
269
-	}
266
+    if ( wpinv_is_checkout() ) {
267
+        $classes[] = 'wpinv-checkout';
268
+        $classes[] = 'wpinv-page';
269
+    }
270 270
 
271
-	if ( wpinv_is_success_page() ) {
272
-		$classes[] = 'wpinv-success';
273
-		$classes[] = 'wpinv-page';
274
-	}
271
+    if ( wpinv_is_success_page() ) {
272
+        $classes[] = 'wpinv-success';
273
+        $classes[] = 'wpinv-page';
274
+    }
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
277
-		$classes[] = 'wpinv-failed-transaction';
278
-		$classes[] = 'wpinv-page';
279
-	}
276
+    if ( wpinv_is_failed_transaction_page() ) {
277
+        $classes[] = 'wpinv-failed-transaction';
278
+        $classes[] = 'wpinv-page';
279
+    }
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
282
-		$classes[] = 'wpinv-history';
283
-		$classes[] = 'wpinv-page';
284
-	}
281
+    if ( wpinv_is_invoice_history_page() ) {
282
+        $classes[] = 'wpinv-history';
283
+        $classes[] = 'wpinv-page';
284
+    }
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
287
-		$classes[] = 'wpinv-subscription';
288
-		$classes[] = 'wpinv-page';
289
-	}
286
+    if ( wpinv_is_subscriptions_history_page() ) {
287
+        $classes[] = 'wpinv-subscription';
288
+        $classes[] = 'wpinv-page';
289
+    }
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
292
-		$classes[] = 'wpinv-test-mode';
293
-		$classes[] = 'wpinv-page';
294
-	}
291
+    if ( wpinv_is_test_mode() ) {
292
+        $classes[] = 'wpinv-test-mode';
293
+        $classes[] = 'wpinv-page';
294
+    }
295 295
 
296
-	return array_unique( $classes );
296
+    return array_unique( $classes );
297 297
 }
298 298
 add_filter( 'body_class', 'wpinv_add_body_classes' );
299 299
 
@@ -458,16 +458,16 @@  discard block
 block discarded – undo
458 458
 
459 459
     wpinv_html_select(
460 460
         array(
461
-			'name'             => $args['name'],
462
-			'selected'         => $args['selected'],
463
-			'id'               => $args['id'],
464
-			'class'            => $args['class'],
465
-			'options'          => $options,
466
-			'multiple'         => $args['multiple'],
467
-			'placeholder'      => $args['placeholder'],
468
-			'show_option_all'  => $args['show_option_all'],
469
-			'show_option_none' => $args['show_option_none'],
470
-			'data'             => $args['data'],
461
+            'name'             => $args['name'],
462
+            'selected'         => $args['selected'],
463
+            'id'               => $args['id'],
464
+            'class'            => $args['class'],
465
+            'options'          => $options,
466
+            'multiple'         => $args['multiple'],
467
+            'placeholder'      => $args['placeholder'],
468
+            'show_option_all'  => $args['show_option_all'],
469
+            'show_option_none' => $args['show_option_none'],
470
+            'data'             => $args['data'],
471 471
         )
472 472
     );
473 473
 
@@ -767,21 +767,21 @@  discard block
 block discarded – undo
767 767
 
768 768
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
769 769
 
770
-	// Remove unavailable tags.
770
+    // Remove unavailable tags.
771 771
     $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
772 772
 
773 773
     // Clean up white space.
774
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
774
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
775 775
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
776 776
 
777 777
     // Break newlines apart and remove empty lines/trim commas and white space.
778
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
778
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
779 779
 
780 780
     // Add html breaks.
781
-	$formatted_address = implode( $separator, $formatted_address );
781
+    $formatted_address = implode( $separator, $formatted_address );
782 782
 
783
-	// We're done!
784
-	return $formatted_address;
783
+    // We're done!
784
+    return $formatted_address;
785 785
 
786 786
 }
787 787
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 function getpaid_display_invoice_subscriptions( $invoice ) {
828 828
 
829 829
     // Subscriptions.
830
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
830
+    $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
831 831
 
832 832
     if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
833 833
         return;
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 }
1040 1040
 
1041 1041
 function wpinv_empty_cart_message() {
1042
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1042
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1043 1043
 }
1044 1044
 
1045 1045
 /**
@@ -1237,9 +1237,9 @@  discard block
 block discarded – undo
1237 1237
 
1238 1238
     if ( 0 == count( $form->get_items() ) ) {
1239 1239
         aui()->alert(
1240
-			array(
1241
-				'type'    => 'warning',
1242
-				'content' => __( 'No published items found', 'invoicing' ),
1240
+            array(
1241
+                'type'    => 'warning',
1242
+                'content' => __( 'No published items found', 'invoicing' ),
1243 1243
             ),
1244 1244
             true
1245 1245
         );
@@ -1262,10 +1262,10 @@  discard block
 block discarded – undo
1262 1262
     $invoice = wpinv_get_invoice( $invoice_id );
1263 1263
 
1264 1264
     if ( empty( $invoice ) ) {
1265
-		aui()->alert(
1266
-			array(
1267
-				'type'    => 'warning',
1268
-				'content' => __( 'Invoice not found', 'invoicing' ),
1265
+        aui()->alert(
1266
+            array(
1267
+                'type'    => 'warning',
1268
+                'content' => __( 'Invoice not found', 'invoicing' ),
1269 1269
             ),
1270 1270
             true
1271 1271
         );
@@ -1273,10 +1273,10 @@  discard block
 block discarded – undo
1273 1273
     }
1274 1274
 
1275 1275
     if ( $invoice->is_paid() ) {
1276
-		aui()->alert(
1277
-			array(
1278
-				'type'    => 'warning',
1279
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1276
+        aui()->alert(
1277
+            array(
1278
+                'type'    => 'warning',
1279
+                'content' => __( 'Invoice has already been paid', 'invoicing' ),
1280 1280
             ),
1281 1281
             true
1282 1282
         );
@@ -1340,7 +1340,7 @@  discard block
 block discarded – undo
1340 1340
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1341 1341
     }
1342 1342
 
1343
-	if ( ! empty( $items ) ) {
1343
+    if ( ! empty( $items ) ) {
1344 1344
         $items  = esc_attr( $items );
1345 1345
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1346 1346
     }
@@ -1526,21 +1526,21 @@  discard block
 block discarded – undo
1526 1526
 
1527 1527
         return aui()->select(
1528 1528
             array(
1529
-				'options'          => $states,
1530
-				'name'             => esc_attr( $field_name ),
1531
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1532
-				'value'            => sanitize_text_field( $state ),
1533
-				'placeholder'      => $placeholder,
1534
-				'required'         => $required,
1535
-				'label'            => wp_kses_post( $label ),
1536
-				'label_type'       => 'vertical',
1537
-				'help_text'        => $help_text,
1538
-				'class'            => 'getpaid-address-field wpinv_state',
1539
-				'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1540
-				'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1541
-				'extra_attributes' => array(
1542
-					'autocomplete' => 'address-level1',
1543
-				),
1529
+                'options'          => $states,
1530
+                'name'             => esc_attr( $field_name ),
1531
+                'id'               => sanitize_html_class( $field_name ) . $uniqid,
1532
+                'value'            => sanitize_text_field( $state ),
1533
+                'placeholder'      => $placeholder,
1534
+                'required'         => $required,
1535
+                'label'            => wp_kses_post( $label ),
1536
+                'label_type'       => 'vertical',
1537
+                'help_text'        => $help_text,
1538
+                'class'            => 'getpaid-address-field wpinv_state',
1539
+                'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1540
+                'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1541
+                'extra_attributes' => array(
1542
+                    'autocomplete' => 'address-level1',
1543
+                ),
1544 1544
             ),
1545 1545
             $echo
1546 1546
         );
Please login to merge, or discard this patch.
Spacing   +436 added lines, -436 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Displays an invoice.
11 11
  *
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,58 +170,58 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) ) {
182
+	if (isset($name)) {
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
     }
185 185
 	$templates[] = $slug . '.php';
186 186
 
187 187
 	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
188
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
189 189
 
190 190
 	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
191
+	return wpinv_locate_tmpl($templates, $load, false);
192 192
 }
193 193
 
194
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
194
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
195 195
 	// No file found yet
196 196
 	$located = false;
197 197
 
198 198
 	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
199
+	foreach ((array) $template_names as $template_name) {
200 200
 
201 201
 		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
202
+		if (empty($template_name)) {
203 203
 			continue;
204 204
         }
205 205
 
206 206
 		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
207
+		$template_name = ltrim($template_name, '/');
208 208
 
209 209
 		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
210
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
212
+			if (file_exists($template_path . $template_name)) {
213 213
 				$located = $template_path . $template_name;
214 214
 				break;
215 215
 			}
216 216
 		}
217 217
 
218
-		if ( ! empty( $located ) ) {
218
+		if (!empty($located)) {
219 219
 			break;
220 220
 		}
221 221
 	}
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+	if ((true == $load) && !empty($located)) {
224
+		load_template($located, $require_once);
225 225
     }
226 226
 
227 227
 	return $located;
@@ -231,73 +231,73 @@  discard block
 block discarded – undo
231 231
 	$template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233 233
 	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
234
+		1   => trailingslashit(get_stylesheet_directory()) . $template_dir,
235
+		10  => trailingslashit(get_template_directory()) . $template_dir,
236 236
 		100 => wpinv_get_templates_dir(),
237 237
 	);
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
240 240
 
241 241
 	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
242
+	ksort($file_paths, SORT_NUMERIC);
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+	return array_map('trailingslashit', $file_paths);
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249 249
 	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
250
+	$pages[] = wpinv_get_option('success_page');
251
+	$pages[] = wpinv_get_option('failure_page');
252
+	$pages[] = wpinv_get_option('invoice_history_page');
253
+	$pages[] = wpinv_get_option('invoice_subscription_page');
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
255
+	if (!wpinv_is_checkout() && !is_page($pages)) {
256 256
 		return;
257 257
 	}
258 258
 
259 259
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
261
+add_action('wp_head', 'wpinv_checkout_meta_tags');
262 262
 
263
-function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
263
+function wpinv_add_body_classes($class) {
264
+	$classes = (array) $class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
266
+	if (wpinv_is_checkout()) {
267 267
 		$classes[] = 'wpinv-checkout';
268 268
 		$classes[] = 'wpinv-page';
269 269
 	}
270 270
 
271
-	if ( wpinv_is_success_page() ) {
271
+	if (wpinv_is_success_page()) {
272 272
 		$classes[] = 'wpinv-success';
273 273
 		$classes[] = 'wpinv-page';
274 274
 	}
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
276
+	if (wpinv_is_failed_transaction_page()) {
277 277
 		$classes[] = 'wpinv-failed-transaction';
278 278
 		$classes[] = 'wpinv-page';
279 279
 	}
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
281
+	if (wpinv_is_invoice_history_page()) {
282 282
 		$classes[] = 'wpinv-history';
283 283
 		$classes[] = 'wpinv-page';
284 284
 	}
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
286
+	if (wpinv_is_subscriptions_history_page()) {
287 287
 		$classes[] = 'wpinv-subscription';
288 288
 		$classes[] = 'wpinv-page';
289 289
 	}
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
291
+	if (wpinv_is_test_mode()) {
292 292
 		$classes[] = 'wpinv-test-mode';
293 293
 		$classes[] = 'wpinv-page';
294 294
 	}
295 295
 
296
-	return array_unique( $classes );
296
+	return array_unique($classes);
297 297
 }
298
-add_filter( 'body_class', 'wpinv_add_body_classes' );
298
+add_filter('body_class', 'wpinv_add_body_classes');
299 299
 
300
-function wpinv_html_select( $args = array() ) {
300
+function wpinv_html_select($args = array()) {
301 301
     $defaults = array(
302 302
         'options'          => array(),
303 303
         'name'             => null,
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
         'selected'         => 0,
307 307
         'placeholder'      => null,
308 308
         'multiple'         => false,
309
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
310
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
309
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
310
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
311 311
         'data'             => array(),
312 312
         'onchange'         => null,
313 313
         'required'         => false,
@@ -315,79 +315,79 @@  discard block
 block discarded – undo
315 315
         'readonly'         => false,
316 316
     );
317 317
 
318
-    $args = wp_parse_args( $args, $defaults );
318
+    $args = wp_parse_args($args, $defaults);
319 319
 
320 320
     $attrs = array(
321 321
         'name'     => $args['name'],
322 322
         'id'       => $args['id'],
323
-        'class'    => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ),
324
-        'multiple' => ! empty( $args['multiple'] ),
325
-        'readonly' => ! empty( $args['readonly'] ),
326
-        'disabled' => ! empty( $args['disabled'] ),
327
-        'required' => ! empty( $args['required'] ),
328
-        'onchange' => ! empty( $args['onchange'] ),
323
+        'class'    => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))),
324
+        'multiple' => !empty($args['multiple']),
325
+        'readonly' => !empty($args['readonly']),
326
+        'disabled' => !empty($args['disabled']),
327
+        'required' => !empty($args['required']),
328
+        'onchange' => !empty($args['onchange']),
329 329
     );
330 330
 
331
-    if ( $args['placeholder'] ) {
331
+    if ($args['placeholder']) {
332 332
         $attrs['data-placeholder'] = $args['placeholder'];
333 333
     }
334 334
 
335
-    if ( $args['onchange'] ) {
335
+    if ($args['onchange']) {
336 336
         $attrs['onchange'] = $args['onchange'];
337 337
     }
338 338
 
339
-    foreach ( $args['data'] as $key => $value ) {
339
+    foreach ($args['data'] as $key => $value) {
340 340
         $attrs["data-$key"] = $value;
341 341
     }
342 342
 
343 343
     echo '<select ';
344 344
 
345
-    foreach ( $attrs as $attr => $value ) {
345
+    foreach ($attrs as $attr => $value) {
346 346
         
347
-        if ( false === $value ) {
347
+        if (false === $value) {
348 348
             continue;
349 349
         }
350 350
 
351
-        if ( true === $value ) {
352
-            echo ' ' . esc_attr( $attr );
351
+        if (true === $value) {
352
+            echo ' ' . esc_attr($attr);
353 353
         } else {
354
-            echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"';
354
+            echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"';
355 355
         }
356 356
 
357 357
     }
358 358
 
359 359
     echo '>';
360 360
 
361
-    if ( $args['show_option_all'] ) {
362
-        if ( $args['multiple'] ) {
363
-            $selected = in_array( 0, $args['selected'] );
361
+    if ($args['show_option_all']) {
362
+        if ($args['multiple']) {
363
+            $selected = in_array(0, $args['selected']);
364 364
         } else {
365
-            $selected = empty( $args['selected'] );
365
+            $selected = empty($args['selected']);
366 366
         }
367
-        echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>';
367
+        echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>';
368 368
     }
369 369
 
370
-    if ( ! empty( $args['options'] ) ) {
370
+    if (!empty($args['options'])) {
371 371
 
372
-        if ( $args['show_option_none'] ) {
373
-            if ( $args['multiple'] ) {
374
-                $selected = in_array( '', $args['selected'] );
372
+        if ($args['show_option_none']) {
373
+            if ($args['multiple']) {
374
+                $selected = in_array('', $args['selected']);
375 375
             } else {
376 376
                 $selected = $args['selected'] === '';
377 377
             }
378 378
 
379
-            echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>';
379
+            echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>';
380 380
         }
381 381
 
382
-        foreach ( $args['options'] as $key => $option ) {
382
+        foreach ($args['options'] as $key => $option) {
383 383
 
384
-            if ( $args['multiple'] && is_array( $args['selected'] ) ) {
385
-                $selected = in_array( $key, $args['selected'] );
384
+            if ($args['multiple'] && is_array($args['selected'])) {
385
+                $selected = in_array($key, $args['selected']);
386 386
             } else {
387 387
                 $selected = $args['selected'] == $key;
388 388
             }
389 389
 
390
-            echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>';
390
+            echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>';
391 391
         }
392 392
     }
393 393
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 
396 396
 }
397 397
 
398
-function wpinv_item_dropdown( $args = array() ) {
398
+function wpinv_item_dropdown($args = array()) {
399 399
     $defaults = array(
400 400
         'name'             => 'wpi_item',
401 401
         'id'               => 'wpi_item',
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
         'multiple'         => false,
404 404
         'selected'         => 0,
405 405
         'number'           => -1,
406
-        'placeholder'      => __( 'Choose a item', 'invoicing' ),
407
-        'data'             => array( 'search-type' => 'item' ),
406
+        'placeholder'      => __('Choose a item', 'invoicing'),
407
+        'data'             => array('search-type' => 'item'),
408 408
         'show_option_all'  => false,
409 409
         'show_option_none' => false,
410 410
         'show_recurring'   => false,
411 411
     );
412 412
 
413
-    $args = wp_parse_args( $args, $defaults );
413
+    $args = wp_parse_args($args, $defaults);
414 414
 
415 415
     $item_args = array(
416 416
         'post_type'      => 'wpi_item',
@@ -419,40 +419,40 @@  discard block
 block discarded – undo
419 419
         'posts_per_page' => $args['number'],
420 420
     );
421 421
 
422
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
422
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
423 423
 
424
-    $items      = get_posts( $item_args );
424
+    $items      = get_posts($item_args);
425 425
     $options    = array();
426
-    if ( $items ) {
427
-        foreach ( $items as $item ) {
428
-            $title = esc_html( $item->post_title );
426
+    if ($items) {
427
+        foreach ($items as $item) {
428
+            $title = esc_html($item->post_title);
429 429
 
430
-            if ( ! empty( $args['show_recurring'] ) ) {
431
-                $title .= wpinv_get_item_suffix( $item->ID, false );
430
+            if (!empty($args['show_recurring'])) {
431
+                $title .= wpinv_get_item_suffix($item->ID, false);
432 432
             }
433 433
 
434
-            $options[ absint( $item->ID ) ] = $title;
434
+            $options[absint($item->ID)] = $title;
435 435
         }
436 436
     }
437 437
 
438 438
     // This ensures that any selected items are included in the drop down
439
-    if ( is_array( $args['selected'] ) ) {
440
-        foreach ( $args['selected'] as $item ) {
441
-            if ( ! in_array( $item, $options ) ) {
442
-                $title = get_the_title( $item );
443
-                if ( ! empty( $args['show_recurring'] ) ) {
444
-                    $title .= wpinv_get_item_suffix( $item, false );
439
+    if (is_array($args['selected'])) {
440
+        foreach ($args['selected'] as $item) {
441
+            if (!in_array($item, $options)) {
442
+                $title = get_the_title($item);
443
+                if (!empty($args['show_recurring'])) {
444
+                    $title .= wpinv_get_item_suffix($item, false);
445 445
                 }
446
-                $options[ $item ] = $title;
446
+                $options[$item] = $title;
447 447
             }
448 448
         }
449
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
450
-        if ( ! in_array( $args['selected'], $options ) ) {
451
-            $title = get_the_title( $args['selected'] );
452
-            if ( ! empty( $args['show_recurring'] ) ) {
453
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
449
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
450
+        if (!in_array($args['selected'], $options)) {
451
+            $title = get_the_title($args['selected']);
452
+            if (!empty($args['show_recurring'])) {
453
+                $title .= wpinv_get_item_suffix($args['selected'], false);
454 454
             }
455
-            $options[ $args['selected'] ] = get_the_title( $args['selected'] );
455
+            $options[$args['selected']] = get_the_title($args['selected']);
456 456
         }
457 457
     }
458 458
 
@@ -488,16 +488,16 @@  discard block
 block discarded – undo
488 488
     );
489 489
 
490 490
     $options = array();
491
-    if ( $items ) {
492
-        foreach ( $items as $item ) {
493
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
491
+    if ($items) {
492
+        foreach ($items as $item) {
493
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
494 494
         }
495 495
     }
496 496
 
497 497
     return $options;
498 498
 }
499 499
 
500
-function wpinv_html_checkbox( $args = array() ) {
500
+function wpinv_html_checkbox($args = array()) {
501 501
     $defaults = array(
502 502
         'name'    => null,
503 503
         'current' => null,
@@ -508,17 +508,17 @@  discard block
 block discarded – undo
508 508
         ),
509 509
     );
510 510
 
511
-    $args = wp_parse_args( $args, $defaults );
511
+    $args = wp_parse_args($args, $defaults);
512 512
 
513
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
513
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
514 514
     $attr  = '';
515
-    if ( ! empty( $args['options']['disabled'] ) ) {
515
+    if (!empty($args['options']['disabled'])) {
516 516
         $attr .= ' disabled="disabled"';
517
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
517
+    } elseif (!empty($args['options']['readonly'])) {
518 518
         $attr .= ' readonly';
519 519
     }
520 520
 
521
-    $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
521
+    $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
522 522
 
523 523
     return $output;
524 524
 }
@@ -526,34 +526,34 @@  discard block
 block discarded – undo
526 526
 /**
527 527
  * Displays a hidden field.
528 528
  */
529
-function getpaid_hidden_field( $name, $value ) {
530
-    echo "<input type='hidden' name='" . esc_attr( $name ) . "' value=' " . esc_attr( $value ) . "' />";
529
+function getpaid_hidden_field($name, $value) {
530
+    echo "<input type='hidden' name='" . esc_attr($name) . "' value=' " . esc_attr($value) . "' />";
531 531
 }
532 532
 
533 533
 /**
534 534
  * Displays a submit field.
535 535
  */
536
-function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) {
537
-    echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />";
536
+function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') {
537
+    echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />";
538 538
 }
539 539
 
540
-function wpinv_html_text( $args = array() ) {
540
+function wpinv_html_text($args = array()) {
541 541
     // Backwards compatibility
542
-    if ( func_num_args() > 1 ) {
542
+    if (func_num_args() > 1) {
543 543
         $args = func_get_args();
544 544
 
545 545
         $name  = $args[0];
546
-        $value = isset( $args[1] ) ? $args[1] : '';
547
-        $label = isset( $args[2] ) ? $args[2] : '';
548
-        $desc  = isset( $args[3] ) ? $args[3] : '';
546
+        $value = isset($args[1]) ? $args[1] : '';
547
+        $label = isset($args[2]) ? $args[2] : '';
548
+        $desc  = isset($args[3]) ? $args[3] : '';
549 549
     }
550 550
 
551 551
     $defaults = array(
552 552
         'id'           => '',
553
-        'name'         => isset( $name ) ? $name : 'text',
554
-        'value'        => isset( $value ) ? $value : null,
555
-        'label'        => isset( $label ) ? $label : null,
556
-        'desc'         => isset( $desc ) ? $desc : null,
553
+        'name'         => isset($name) ? $name : 'text',
554
+        'value'        => isset($value) ? $value : null,
555
+        'label'        => isset($label) ? $label : null,
556
+        'desc'         => isset($desc) ? $desc : null,
557 557
         'placeholder'  => '',
558 558
         'class'        => 'regular-text',
559 559
         'disabled'     => false,
@@ -563,41 +563,41 @@  discard block
 block discarded – undo
563 563
         'data'         => false,
564 564
     );
565 565
 
566
-    $args = wp_parse_args( $args, $defaults );
566
+    $args = wp_parse_args($args, $defaults);
567 567
 
568
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
568
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
569 569
     $options = '';
570
-    if ( $args['required'] ) {
570
+    if ($args['required']) {
571 571
         $options .= ' required="required"';
572 572
     }
573
-    if ( $args['readonly'] ) {
573
+    if ($args['readonly']) {
574 574
         $options .= ' readonly';
575 575
     }
576
-    if ( $args['readonly'] ) {
576
+    if ($args['readonly']) {
577 577
         $options .= ' readonly';
578 578
     }
579 579
 
580 580
     $data = '';
581
-    if ( ! empty( $args['data'] ) ) {
582
-        foreach ( $args['data'] as $key => $value ) {
583
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
581
+    if (!empty($args['data'])) {
582
+        foreach ($args['data'] as $key => $value) {
583
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
584 584
         }
585 585
     }
586 586
 
587
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
588
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
589
-    if ( ! empty( $args['desc'] ) ) {
590
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
587
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
588
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
589
+    if (!empty($args['desc'])) {
590
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
591 591
     }
592 592
 
593
-    $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 ) . '/>';
593
+    $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) . '/>';
594 594
 
595 595
     $output .= '</span>';
596 596
 
597 597
     return $output;
598 598
 }
599 599
 
600
-function wpinv_html_textarea( $args = array() ) {
600
+function wpinv_html_textarea($args = array()) {
601 601
     $defaults = array(
602 602
         'name'        => 'textarea',
603 603
         'value'       => null,
@@ -608,31 +608,31 @@  discard block
 block discarded – undo
608 608
         'placeholder' => '',
609 609
     );
610 610
 
611
-    $args = wp_parse_args( $args, $defaults );
611
+    $args = wp_parse_args($args, $defaults);
612 612
 
613
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
613
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
614 614
     $disabled = '';
615
-    if ( $args['disabled'] ) {
615
+    if ($args['disabled']) {
616 616
         $disabled = ' disabled="disabled"';
617 617
     }
618 618
 
619
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
620
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
621
-    $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>';
619
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
620
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
621
+    $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>';
622 622
 
623
-    if ( ! empty( $args['desc'] ) ) {
624
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
623
+    if (!empty($args['desc'])) {
624
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
625 625
     }
626 626
     $output .= '</span>';
627 627
 
628 628
     return $output;
629 629
 }
630 630
 
631
-function wpinv_html_ajax_user_search( $args = array() ) {
631
+function wpinv_html_ajax_user_search($args = array()) {
632 632
     $defaults = array(
633 633
         'name'         => 'user_id',
634 634
         'value'        => null,
635
-        'placeholder'  => __( 'Enter username', 'invoicing' ),
635
+        'placeholder'  => __('Enter username', 'invoicing'),
636 636
         'label'        => null,
637 637
         'desc'         => null,
638 638
         'class'        => '',
@@ -641,13 +641,13 @@  discard block
 block discarded – undo
641 641
         'data'         => false,
642 642
     );
643 643
 
644
-    $args = wp_parse_args( $args, $defaults );
644
+    $args = wp_parse_args($args, $defaults);
645 645
 
646 646
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
647 647
 
648 648
     $output  = '<span class="wpinv_user_search_wrap">';
649
-        $output .= wpinv_html_text( $args );
650
-        $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>';
649
+        $output .= wpinv_html_text($args);
650
+        $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>';
651 651
     $output .= '</span>';
652 652
 
653 653
     return $output;
@@ -658,44 +658,44 @@  discard block
 block discarded – undo
658 658
  *
659 659
  * @param string $template the template that is currently being used.
660 660
  */
661
-function wpinv_template( $template ) {
661
+function wpinv_template($template) {
662 662
     global $post;
663 663
 
664
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
664
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
665 665
 
666 666
         // If the user can view this invoice, display it.
667
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
667
+        if (wpinv_user_can_view_invoice($post->ID)) {
668 668
 
669
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
669
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
670 670
 
671 671
         // Else display an error message.
672 672
         } else {
673 673
 
674
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
674
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
675 675
 
676 676
         }
677 677
 }
678 678
 
679 679
     return $template;
680 680
 }
681
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
681
+add_filter('template_include', 'wpinv_template', 10, 1);
682 682
 
683 683
 function wpinv_get_business_address() {
684 684
     $business_address   = wpinv_store_address();
685
-    $business_address   = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : '';
685
+    $business_address   = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : '';
686 686
 
687 687
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
688 688
 
689
-    return apply_filters( 'wpinv_get_business_address', $business_address );
689
+    return apply_filters('wpinv_get_business_address', $business_address);
690 690
 }
691 691
 
692 692
 /**
693 693
  * Displays the company address.
694 694
  */
695 695
 function wpinv_display_from_address() {
696
-    wpinv_get_template( 'invoice/company-address.php' );
696
+    wpinv_get_template('invoice/company-address.php');
697 697
 }
698
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
698
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
699 699
 
700 700
 /**
701 701
  * Generates a watermark text for an invoice.
@@ -703,9 +703,9 @@  discard block
 block discarded – undo
703 703
  * @param WPInv_Invoice $invoice
704 704
  * @return string
705 705
  */
706
-function wpinv_watermark( $invoice ) {
707
-    $watermark = wpinv_get_watermark( $invoice );
708
-    return apply_filters( 'wpinv_get_watermark', $watermark, $invoice );
706
+function wpinv_watermark($invoice) {
707
+    $watermark = wpinv_get_watermark($invoice);
708
+    return apply_filters('wpinv_get_watermark', $watermark, $invoice);
709 709
 }
710 710
 
711 711
 /**
@@ -714,37 +714,37 @@  discard block
 block discarded – undo
714 714
  * @param WPInv_Invoice $invoice
715 715
  * @return string
716 716
  */
717
-function wpinv_get_watermark( $invoice ) {
717
+function wpinv_get_watermark($invoice) {
718 718
     return $invoice->get_status_nicename();
719 719
 }
720 720
 
721 721
 /**
722 722
  * @deprecated
723 723
  */
724
-function wpinv_display_invoice_details( $invoice ) {
725
-    return getpaid_invoice_meta( $invoice );
724
+function wpinv_display_invoice_details($invoice) {
725
+    return getpaid_invoice_meta($invoice);
726 726
 }
727 727
 
728 728
 /**
729 729
  * Displays invoice meta.
730 730
  */
731
-function getpaid_invoice_meta( $invoice ) {
731
+function getpaid_invoice_meta($invoice) {
732 732
 
733
-    $invoice = new WPInv_Invoice( $invoice );
733
+    $invoice = new WPInv_Invoice($invoice);
734 734
 
735 735
     // Ensure that we have an invoice.
736
-    if ( 0 == $invoice->get_id() ) {
736
+    if (0 == $invoice->get_id()) {
737 737
         return;
738 738
     }
739 739
 
740 740
     // Get the invoice meta.
741
-    $meta = getpaid_get_invoice_meta( $invoice );
741
+    $meta = getpaid_get_invoice_meta($invoice);
742 742
 
743 743
     // Display the meta.
744
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
744
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
745 745
 
746 746
 }
747
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
747
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
748 748
 
749 749
 /**
750 750
  * Retrieves the address markup to use on Invoices.
@@ -756,29 +756,29 @@  discard block
 block discarded – undo
756 756
  * @param  string $separator How to separate address lines.
757 757
  * @return string
758 758
  */
759
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
759
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
760 760
 
761 761
     // Retrieve the address markup...
762
-    $country = empty( $billing_details['country'] ) ? '' : $billing_details['country'];
763
-    $format = wpinv_get_full_address_format( $country );
762
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
763
+    $format = wpinv_get_full_address_format($country);
764 764
 
765 765
     // ... and the replacements.
766
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
766
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
767 767
 
768
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
768
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
769 769
 
770 770
 	// Remove unavailable tags.
771
-    $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
771
+    $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address);
772 772
 
773 773
     // Clean up white space.
774
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
775
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
774
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
775
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
776 776
 
777 777
     // Break newlines apart and remove empty lines/trim commas and white space.
778
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
778
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
779 779
 
780 780
     // Add html breaks.
781
-	$formatted_address = implode( $separator, $formatted_address );
781
+	$formatted_address = implode($separator, $formatted_address);
782 782
 
783 783
 	// We're done!
784 784
 	return $formatted_address;
@@ -790,119 +790,119 @@  discard block
 block discarded – undo
790 790
  *
791 791
  * @param WPInv_Invoice $invoice
792 792
  */
793
-function wpinv_display_to_address( $invoice = 0 ) {
794
-    if ( ! empty( $invoice ) ) {
795
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
793
+function wpinv_display_to_address($invoice = 0) {
794
+    if (!empty($invoice)) {
795
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
796 796
     }
797 797
 }
798
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
798
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
799 799
 
800 800
 
801 801
 /**
802 802
  * Displays invoice line items.
803 803
  */
804
-function wpinv_display_line_items( $invoice_id = 0 ) {
804
+function wpinv_display_line_items($invoice_id = 0) {
805 805
 
806 806
     // Prepare the invoice.
807
-    $invoice = new WPInv_Invoice( $invoice_id );
807
+    $invoice = new WPInv_Invoice($invoice_id);
808 808
 
809 809
     // Abort if there is no invoice.
810
-    if ( 0 == $invoice->get_id() ) {
810
+    if (0 == $invoice->get_id()) {
811 811
         return;
812 812
     }
813 813
 
814 814
     // Line item columns.
815
-    $columns = getpaid_invoice_item_columns( $invoice );
816
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
815
+    $columns = getpaid_invoice_item_columns($invoice);
816
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
817 817
 
818
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
818
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
819 819
 }
820
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
820
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
821 821
 
822 822
 /**
823 823
  * Displays invoice subscriptions.
824 824
  *
825 825
  * @param WPInv_Invoice $invoice
826 826
  */
827
-function getpaid_display_invoice_subscriptions( $invoice ) {
827
+function getpaid_display_invoice_subscriptions($invoice) {
828 828
 
829 829
     // Subscriptions.
830
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
830
+	$subscriptions = getpaid_get_invoice_subscriptions($invoice);
831 831
 
832
-    if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
832
+    if (empty($subscriptions) || !$invoice->is_recurring()) {
833 833
         return;
834 834
     }
835 835
 
836
-    $main_subscription = getpaid_get_invoice_subscription( $invoice );
836
+    $main_subscription = getpaid_get_invoice_subscription($invoice);
837 837
 
838 838
     // Display related subscriptions.
839
-    if ( is_array( $subscriptions ) ) {
840
-        printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) );
841
-        getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false );
839
+    if (is_array($subscriptions)) {
840
+        printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing'));
841
+        getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false);
842 842
     }
843 843
 
844
-    if ( $main_subscription->get_total_payments() > 1 ) {
845
-        printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) );
846
-        getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false );
844
+    if ($main_subscription->get_total_payments() > 1) {
845
+        printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing'));
846
+        getpaid_admin_subscription_invoice_details_metabox($main_subscription, false);
847 847
     }
848 848
 
849 849
 }
850
-add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 );
851
-add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 );
850
+add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55);
851
+add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11);
852 852
 
853 853
 /**
854 854
  * Displays invoice notices on invoices.
855 855
  */
856 856
 function wpinv_display_invoice_notice() {
857 857
 
858
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
859
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
858
+    $label  = wpinv_get_option('vat_invoice_notice_label');
859
+    $notice = wpinv_get_option('vat_invoice_notice');
860 860
 
861
-    if ( empty( $label ) && empty( $notice ) ) {
861
+    if (empty($label) && empty($notice)) {
862 862
         return;
863 863
     }
864 864
 
865 865
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
866 866
 
867
-    if ( ! empty( $label ) ) {
868
-        $label = esc_html( $label );
867
+    if (!empty($label)) {
868
+        $label = esc_html($label);
869 869
         echo "<h5>$label</h5>";
870 870
     }
871 871
 
872
-    if ( ! empty( $notice ) ) {
873
-        echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>';
872
+    if (!empty($notice)) {
873
+        echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>';
874 874
     }
875 875
 
876 876
     echo '</div>';
877 877
 }
878
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
878
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
879 879
 
880 880
 /**
881 881
  * @param WPInv_Invoice $invoice
882 882
  */
883
-function wpinv_display_invoice_notes( $invoice ) {
883
+function wpinv_display_invoice_notes($invoice) {
884 884
 
885 885
     // Retrieve the notes.
886
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
886
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
887 887
 
888 888
     // Abort if we have non.
889
-    if ( empty( $notes ) ) {
889
+    if (empty($notes)) {
890 890
         return;
891 891
     }
892 892
 
893 893
     // Echo the note.
894 894
     echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">';
895
-    echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __( 'Notes', 'invoicing' ) . '</h2>';
895
+    echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __('Notes', 'invoicing') . '</h2>';
896 896
     echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">';
897 897
 
898
-    foreach ( $notes as $note ) {
899
-        wpinv_get_invoice_note_line_item( $note );
898
+    foreach ($notes as $note) {
899
+        wpinv_get_invoice_note_line_item($note);
900 900
     }
901 901
 
902 902
     echo '</ul>';
903 903
     echo '</div>';
904 904
 }
905
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
905
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
906 906
 
907 907
 /**
908 908
  * Loads scripts on our invoice templates.
@@ -910,32 +910,32 @@  discard block
 block discarded – undo
910 910
 function wpinv_display_style() {
911 911
 
912 912
     // Make sure that all scripts have been loaded.
913
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
914
-        do_action( 'wp_enqueue_scripts' );
913
+    if (!did_action('wp_enqueue_scripts')) {
914
+        do_action('wp_enqueue_scripts');
915 915
     }
916 916
 
917 917
     // Register the invoices style.
918
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
918
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
919 919
 
920 920
     // Load required styles
921
-    wp_print_styles( 'wpinv-single-style' );
922
-    wp_print_styles( 'ayecode-ui' );
921
+    wp_print_styles('wpinv-single-style');
922
+    wp_print_styles('ayecode-ui');
923 923
 
924 924
     // Maybe load custom css.
925
-    $custom_css = wpinv_get_option( 'template_custom_css' );
925
+    $custom_css = wpinv_get_option('template_custom_css');
926 926
 
927
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
928
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
929
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
927
+    if (isset($custom_css) && !empty($custom_css)) {
928
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
929
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
930 930
         echo '<style type="text/css">';
931
-        echo wp_kses_post( $custom_css );
931
+        echo wp_kses_post($custom_css);
932 932
         echo '</style>';
933 933
     }
934 934
 
935 935
     wp_site_icon();
936 936
 }
937
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
938
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
937
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
938
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
939 939
 
940 940
 
941 941
 /**
@@ -947,41 +947,41 @@  discard block
 block discarded – undo
947 947
     // Retrieve the current invoice.
948 948
     $invoice_id = getpaid_get_current_invoice_id();
949 949
 
950
-    if ( empty( $invoice_id ) ) {
950
+    if (empty($invoice_id)) {
951 951
 
952 952
         return aui()->alert(
953 953
             array(
954 954
                 'type'    => 'warning',
955
-                'content' => __( 'Invalid invoice', 'invoicing' ),
955
+                'content' => __('Invalid invoice', 'invoicing'),
956 956
             )
957 957
         );
958 958
 
959 959
     }
960 960
 
961 961
     // Can the user view this invoice?
962
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
962
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
963 963
 
964 964
         return aui()->alert(
965 965
             array(
966 966
                 'type'    => 'warning',
967
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
967
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
968 968
             )
969 969
         );
970 970
 
971 971
     }
972 972
 
973 973
     // Ensure that it is not yet paid for.
974
-    $invoice = new WPInv_Invoice( $invoice_id );
974
+    $invoice = new WPInv_Invoice($invoice_id);
975 975
 
976 976
     // Maybe mark it as viewed.
977
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
977
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
978 978
 
979
-    if ( $invoice->is_paid() ) {
979
+    if ($invoice->is_paid()) {
980 980
 
981 981
         return aui()->alert(
982 982
             array(
983 983
                 'type'    => 'success',
984
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
984
+                'content' => __('This invoice has already been paid.', 'invoicing'),
985 985
             )
986 986
         );
987 987
 
@@ -991,15 +991,15 @@  discard block
 block discarded – undo
991 991
     $wpi_checkout_id = $invoice_id;
992 992
 
993 993
     // Retrieve appropriate payment form.
994
-    $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) );
995
-    $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
994
+    $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form'));
995
+    $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form());
996 996
 
997
-    if ( ! $payment_form->exists() ) {
997
+    if (!$payment_form->exists()) {
998 998
 
999 999
         return aui()->alert(
1000 1000
             array(
1001 1001
                 'type'    => 'warning',
1002
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1002
+                'content' => __('Error loading the payment form', 'invoicing'),
1003 1003
             )
1004 1004
         );
1005 1005
 
@@ -1008,29 +1008,29 @@  discard block
 block discarded – undo
1008 1008
     // Set the invoice.
1009 1009
     $payment_form->invoice = $invoice;
1010 1010
 
1011
-    if ( ! $payment_form->is_default() ) {
1011
+    if (!$payment_form->is_default()) {
1012 1012
 
1013 1013
         $items    = array();
1014 1014
         $item_ids = array();
1015 1015
 
1016
-        foreach ( $invoice->get_items() as $item ) {
1017
-            if ( ! in_array( $item->get_id(), $item_ids ) ) {
1016
+        foreach ($invoice->get_items() as $item) {
1017
+            if (!in_array($item->get_id(), $item_ids)) {
1018 1018
                 $item_ids[] = $item->get_id();
1019 1019
                 $items[]    = $item;
1020 1020
             }
1021 1021
         }
1022 1022
 
1023
-        foreach ( $payment_form->get_items() as $item ) {
1024
-            if ( ! in_array( $item->get_id(), $item_ids ) ) {
1023
+        foreach ($payment_form->get_items() as $item) {
1024
+            if (!in_array($item->get_id(), $item_ids)) {
1025 1025
                 $item_ids[] = $item->get_id();
1026 1026
                 $items[]    = $item;
1027 1027
             }
1028 1028
         }
1029 1029
 
1030
-        $payment_form->set_items( $items );
1030
+        $payment_form->set_items($items);
1031 1031
 
1032 1032
     } else {
1033
-        $payment_form->set_items( $invoice->get_items() );
1033
+        $payment_form->set_items($invoice->get_items());
1034 1034
     }
1035 1035
 
1036 1036
     // Generate the html.
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
 }
1040 1040
 
1041 1041
 function wpinv_empty_cart_message() {
1042
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1042
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1043 1043
 }
1044 1044
 
1045 1045
 /**
@@ -1057,76 +1057,76 @@  discard block
 block discarded – undo
1057 1057
         true
1058 1058
     );
1059 1059
 }
1060
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1060
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1061 1061
 
1062 1062
 /**
1063 1063
  * Filters the receipt page.
1064 1064
  */
1065
-function wpinv_filter_success_page_content( $content ) {
1065
+function wpinv_filter_success_page_content($content) {
1066 1066
 
1067 1067
     // Maybe abort early.
1068
-    if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) {
1068
+    if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) {
1069 1069
         return $content;
1070 1070
     }
1071 1071
 
1072 1072
     // Ensure this is our page.
1073
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1073
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1074 1074
 
1075
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1076
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1075
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1076
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1077 1077
 
1078 1078
     }
1079 1079
 
1080 1080
     return $content;
1081 1081
 }
1082
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1082
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1083 1083
 
1084
-function wpinv_invoice_link( $invoice_id ) {
1085
-    $invoice = wpinv_get_invoice( $invoice_id );
1084
+function wpinv_invoice_link($invoice_id) {
1085
+    $invoice = wpinv_get_invoice($invoice_id);
1086 1086
 
1087
-    if ( empty( $invoice ) ) {
1087
+    if (empty($invoice)) {
1088 1088
         return null;
1089 1089
     }
1090 1090
 
1091
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1091
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1092 1092
 
1093
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1093
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1094 1094
 }
1095 1095
 
1096
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1097
-    if ( empty( $note ) ) {
1096
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1097
+    if (empty($note)) {
1098 1098
         return null;
1099 1099
     }
1100 1100
 
1101
-    if ( is_int( $note ) ) {
1102
-        $note = get_comment( $note );
1101
+    if (is_int($note)) {
1102
+        $note = get_comment($note);
1103 1103
     }
1104 1104
 
1105
-    if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1105
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1106 1106
         return null;
1107 1107
     }
1108 1108
 
1109
-    $note_classes   = array( 'note' );
1110
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1109
+    $note_classes   = array('note');
1110
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1111 1111
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1112
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1113
-    $note_classes   = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1112
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1113
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1114 1114
 
1115 1115
     ob_start();
1116 1116
     ?>
1117
-    <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2">
1117
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2">
1118 1118
         <div class="note_content">
1119 1119
 
1120
-            <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?>
1120
+            <?php echo wp_kses_post(wptexturize($note->comment_content)); ?>
1121 1121
 
1122
-            <?php if ( ! is_admin() ) : ?>
1122
+            <?php if (!is_admin()) : ?>
1123 1123
                 <em class="small form-text text-muted mt-0">
1124 1124
                     <?php
1125 1125
                         printf(
1126
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1126
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1127 1127
                             $note->comment_author,
1128
-                            getpaid_format_date_value( $note->comment_date ),
1129
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1128
+                            getpaid_format_date_value($note->comment_date),
1129
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1130 1130
                         );
1131 1131
                     ?>
1132 1132
                 </em>
@@ -1134,21 +1134,21 @@  discard block
 block discarded – undo
1134 1134
 
1135 1135
         </div>
1136 1136
 
1137
-        <?php if ( is_admin() ) : ?>
1137
+        <?php if (is_admin()) : ?>
1138 1138
 
1139 1139
             <p class="meta px-4 py-2">
1140
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1140
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1141 1141
                     <?php
1142 1142
                         printf(
1143
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1143
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1144 1144
                             $note->comment_author,
1145
-                            getpaid_format_date_value( $note->comment_date ),
1146
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1145
+                            getpaid_format_date_value($note->comment_date),
1146
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1147 1147
                         );
1148 1148
                     ?>
1149 1149
                 </abbr>&nbsp;&nbsp;
1150
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1151
-                    <a href="#" class="delete_note"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a>
1150
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1151
+                    <a href="#" class="delete_note"><?php esc_html_e('Delete note', 'invoicing'); ?></a>
1152 1152
                 <?php } ?>
1153 1153
             </p>
1154 1154
 
@@ -1157,10 +1157,10 @@  discard block
 block discarded – undo
1157 1157
     </li>
1158 1158
     <?php
1159 1159
     $note_content = ob_get_clean();
1160
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1160
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1161 1161
 
1162
-    if ( $echo ) {
1163
-        echo wp_kses_post( $note_content );
1162
+    if ($echo) {
1163
+        echo wp_kses_post($note_content);
1164 1164
     } else {
1165 1165
         return $note_content;
1166 1166
     }
@@ -1173,43 +1173,43 @@  discard block
 block discarded – undo
1173 1173
  * @return string
1174 1174
  */
1175 1175
 function wpinv_get_policy_text() {
1176
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1176
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1177 1177
 
1178
-    $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]' ) );
1178
+    $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]'));
1179 1179
 
1180
-    if ( ! $privacy_page_id ) {
1181
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1180
+    if (!$privacy_page_id) {
1181
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1182 1182
     }
1183 1183
 
1184
-    $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' );
1184
+    $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');
1185 1185
 
1186 1186
     $find_replace = array(
1187 1187
         '[wpinv_privacy_policy]' => $privacy_link,
1188 1188
     );
1189 1189
 
1190
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1190
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1191 1191
 
1192
-    return wp_kses_post( wpautop( $privacy_text ) );
1192
+    return wp_kses_post(wpautop($privacy_text));
1193 1193
 }
1194 1194
 
1195 1195
 function wpinv_oxygen_fix_conflict() {
1196 1196
     global $ct_ignore_post_types;
1197 1197
 
1198
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1198
+    if (!is_array($ct_ignore_post_types)) {
1199 1199
         $ct_ignore_post_types = array();
1200 1200
     }
1201 1201
 
1202
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' );
1202
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form');
1203 1203
 
1204
-    foreach ( $post_types as $post_type ) {
1204
+    foreach ($post_types as $post_type) {
1205 1205
         $ct_ignore_post_types[] = $post_type;
1206 1206
 
1207 1207
         // Ignore post type
1208
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1208
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1209 1209
     }
1210 1210
 
1211
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1212
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1211
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1212
+    add_filter('template_include', 'wpinv_template', 999, 1);
1213 1213
 }
1214 1214
 
1215 1215
 /**
@@ -1217,10 +1217,10 @@  discard block
 block discarded – undo
1217 1217
  *
1218 1218
  * @param GetPaid_Payment_Form $form
1219 1219
  */
1220
-function getpaid_display_payment_form( $form ) {
1220
+function getpaid_display_payment_form($form) {
1221 1221
 
1222
-    if ( is_numeric( $form ) ) {
1223
-        $form = new GetPaid_Payment_Form( $form );
1222
+    if (is_numeric($form)) {
1223
+        $form = new GetPaid_Payment_Form($form);
1224 1224
     }
1225 1225
 
1226 1226
     $form->display();
@@ -1230,61 +1230,61 @@  discard block
 block discarded – undo
1230 1230
 /**
1231 1231
  * Helper function to display a item payment form on the frontend.
1232 1232
  */
1233
-function getpaid_display_item_payment_form( $items ) {
1233
+function getpaid_display_item_payment_form($items) {
1234 1234
 
1235
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1236
-    $form->set_items( $items );
1235
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1236
+    $form->set_items($items);
1237 1237
 
1238
-    if ( 0 == count( $form->get_items() ) ) {
1238
+    if (0 == count($form->get_items())) {
1239 1239
         aui()->alert(
1240 1240
 			array(
1241 1241
 				'type'    => 'warning',
1242
-				'content' => __( 'No published items found', 'invoicing' ),
1242
+				'content' => __('No published items found', 'invoicing'),
1243 1243
             ),
1244 1244
             true
1245 1245
         );
1246 1246
         return;
1247 1247
     }
1248 1248
 
1249
-    $extra_items     = esc_attr( getpaid_convert_items_to_string( $items ) );
1250
-    $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items );
1249
+    $extra_items     = esc_attr(getpaid_convert_items_to_string($items));
1250
+    $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items);
1251 1251
     $extra_items     = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />";
1252 1252
     $extra_items    .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />";
1253 1253
 
1254
-    $form->display( $extra_items );
1254
+    $form->display($extra_items);
1255 1255
 }
1256 1256
 
1257 1257
 /**
1258 1258
  * Helper function to display an invoice payment form on the frontend.
1259 1259
  */
1260
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1260
+function getpaid_display_invoice_payment_form($invoice_id) {
1261 1261
 
1262
-    $invoice = wpinv_get_invoice( $invoice_id );
1262
+    $invoice = wpinv_get_invoice($invoice_id);
1263 1263
 
1264
-    if ( empty( $invoice ) ) {
1264
+    if (empty($invoice)) {
1265 1265
 		aui()->alert(
1266 1266
 			array(
1267 1267
 				'type'    => 'warning',
1268
-				'content' => __( 'Invoice not found', 'invoicing' ),
1268
+				'content' => __('Invoice not found', 'invoicing'),
1269 1269
             ),
1270 1270
             true
1271 1271
         );
1272 1272
         return;
1273 1273
     }
1274 1274
 
1275
-    if ( $invoice->is_paid() ) {
1275
+    if ($invoice->is_paid()) {
1276 1276
 		aui()->alert(
1277 1277
 			array(
1278 1278
 				'type'    => 'warning',
1279
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1279
+				'content' => __('Invoice has already been paid', 'invoicing'),
1280 1280
             ),
1281 1281
             true
1282 1282
         );
1283 1283
         return;
1284 1284
     }
1285 1285
 
1286
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1287
-    $form->set_items( $invoice->get_items() );
1286
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1287
+    $form->set_items($invoice->get_items());
1288 1288
 
1289 1289
     $form->display();
1290 1290
 }
@@ -1292,23 +1292,23 @@  discard block
 block discarded – undo
1292 1292
 /**
1293 1293
  * Helper function to convert item string to array.
1294 1294
  */
1295
-function getpaid_convert_items_to_array( $items ) {
1296
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1295
+function getpaid_convert_items_to_array($items) {
1296
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1297 1297
     $prepared = array();
1298 1298
 
1299
-    foreach ( $items as $item ) {
1300
-        $data = array_map( 'trim', explode( '|', $item ) );
1299
+    foreach ($items as $item) {
1300
+        $data = array_map('trim', explode('|', $item));
1301 1301
 
1302
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1302
+        if (empty($data[0]) || !is_numeric($data[0])) {
1303 1303
             continue;
1304 1304
         }
1305 1305
 
1306 1306
         $quantity = 1;
1307
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1307
+        if (isset($data[1]) && is_numeric($data[1])) {
1308 1308
             $quantity = (float) $data[1];
1309 1309
         }
1310 1310
 
1311
-        $prepared[ $data[0] ] = $quantity;
1311
+        $prepared[$data[0]] = $quantity;
1312 1312
 
1313 1313
     }
1314 1314
 
@@ -1318,13 +1318,13 @@  discard block
 block discarded – undo
1318 1318
 /**
1319 1319
  * Helper function to convert item array to string.
1320 1320
  */
1321
-function getpaid_convert_items_to_string( $items ) {
1321
+function getpaid_convert_items_to_string($items) {
1322 1322
     $prepared = array();
1323 1323
 
1324
-    foreach ( $items as $item => $quantity ) {
1324
+    foreach ($items as $item => $quantity) {
1325 1325
         $prepared[] = "$item|$quantity";
1326 1326
     }
1327
-    return implode( ',', $prepared );
1327
+    return implode(',', $prepared);
1328 1328
 }
1329 1329
 
1330 1330
 /**
@@ -1332,21 +1332,21 @@  discard block
 block discarded – undo
1332 1332
  *
1333 1333
  * Provide a label and one of $form, $items or $invoice.
1334 1334
  */
1335
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1336
-    $label = sanitize_text_field( $label );
1335
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1336
+    $label = sanitize_text_field($label);
1337 1337
 
1338
-    if ( ! empty( $form ) ) {
1339
-        $form  = esc_attr( $form );
1338
+    if (!empty($form)) {
1339
+        $form = esc_attr($form);
1340 1340
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1341 1341
     }
1342 1342
 
1343
-	if ( ! empty( $items ) ) {
1344
-        $items  = esc_attr( $items );
1343
+	if (!empty($items)) {
1344
+        $items = esc_attr($items);
1345 1345
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1346 1346
     }
1347 1347
 
1348
-    if ( ! empty( $invoice ) ) {
1349
-        $invoice  = esc_attr( $invoice );
1348
+    if (!empty($invoice)) {
1349
+        $invoice = esc_attr($invoice);
1350 1350
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>";
1351 1351
     }
1352 1352
 
@@ -1357,18 +1357,18 @@  discard block
 block discarded – undo
1357 1357
  *
1358 1358
  * @param WPInv_Invoice $invoice
1359 1359
  */
1360
-function getpaid_the_invoice_description( $invoice ) {
1360
+function getpaid_the_invoice_description($invoice) {
1361 1361
     $description = $invoice->get_description();
1362 1362
 
1363
-    if ( empty( $description ) ) {
1363
+    if (empty($description)) {
1364 1364
         return;
1365 1365
     }
1366 1366
 
1367
-    $description = wp_kses_post( wpautop( $description ) );
1367
+    $description = wp_kses_post(wpautop($description));
1368 1368
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>$description</em></small>";
1369 1369
 }
1370
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1371
-add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 );
1370
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1371
+add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100);
1372 1372
 
1373 1373
 /**
1374 1374
  * Render element on a form.
@@ -1376,60 +1376,60 @@  discard block
 block discarded – undo
1376 1376
  * @param array $element
1377 1377
  * @param GetPaid_Payment_Form $form
1378 1378
  */
1379
-function getpaid_payment_form_element( $element, $form ) {
1379
+function getpaid_payment_form_element($element, $form) {
1380 1380
 
1381 1381
     // Set up the args.
1382
-    $element_type    = trim( $element['type'] );
1382
+    $element_type    = trim($element['type']);
1383 1383
     $element['form'] = $form;
1384
-    extract( $element );
1384
+    extract($element);
1385 1385
 
1386 1386
     // Try to locate the appropriate template.
1387
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1387
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1388 1388
 
1389 1389
     // Abort if this is not our element.
1390
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1390
+    if (empty($located) || !file_exists($located)) {
1391 1391
         return;
1392 1392
     }
1393 1393
 
1394 1394
     // Generate the class and id of the element.
1395
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1396
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1395
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1396
+    $id            = isset($id) ? $id : uniqid('gp');
1397 1397
 
1398 1398
     // Echo the opening wrapper.
1399 1399
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1400 1400
 
1401 1401
     // Fires before displaying a given element type's content.
1402
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1402
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1403 1403
 
1404 1404
     // Include the template for the element.
1405 1405
     include $located;
1406 1406
 
1407 1407
     // Fires after displaying a given element type's content.
1408
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1408
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1409 1409
 
1410 1410
     // Echo the closing wrapper.
1411 1411
     echo '</div>';
1412 1412
 }
1413
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1413
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1414 1414
 
1415 1415
 /**
1416 1416
  * Render an element's edit page.
1417 1417
  *
1418 1418
  * @param WP_Post $post
1419 1419
  */
1420
-function getpaid_payment_form_edit_element_template( $post ) {
1420
+function getpaid_payment_form_edit_element_template($post) {
1421 1421
 
1422 1422
     // Retrieve all elements.
1423
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1423
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1424 1424
 
1425
-    foreach ( $all_elements as $element ) {
1425
+    foreach ($all_elements as $element) {
1426 1426
 
1427 1427
         // Try to locate the appropriate template.
1428
-        $element = esc_attr( sanitize_key( $element ) );
1429
-        $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" );
1428
+        $element = esc_attr(sanitize_key($element));
1429
+        $located = wpinv_locate_template("payment-forms-admin/edit/$element.php");
1430 1430
 
1431 1431
         // Continue if this is not our element.
1432
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1432
+        if (empty($located) || !file_exists($located)) {
1433 1433
             continue;
1434 1434
         }
1435 1435
 
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
     }
1441 1441
 
1442 1442
 }
1443
-add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' );
1443
+add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template');
1444 1444
 
1445 1445
 /**
1446 1446
  * Render an element's preview.
@@ -1449,16 +1449,16 @@  discard block
 block discarded – undo
1449 1449
 function getpaid_payment_form_render_element_preview_template() {
1450 1450
 
1451 1451
     // Retrieve all elements.
1452
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1452
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1453 1453
 
1454
-    foreach ( $all_elements as $element ) {
1454
+    foreach ($all_elements as $element) {
1455 1455
 
1456 1456
         // Try to locate the appropriate template.
1457
-        $element = sanitize_key( $element );
1458
-        $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" );
1457
+        $element = sanitize_key($element);
1458
+        $located = wpinv_locate_template("payment-forms-admin/previews/$element.php");
1459 1459
 
1460 1460
         // Continue if this is not our element.
1461
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1461
+        if (empty($located) || !file_exists($located)) {
1462 1462
             continue;
1463 1463
         }
1464 1464
 
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
     }
1470 1470
 
1471 1471
 }
1472
-add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' );
1472
+add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template');
1473 1473
 
1474 1474
 /**
1475 1475
  * Shows a list of gateways that support recurring payments.
@@ -1477,17 +1477,17 @@  discard block
 block discarded – undo
1477 1477
 function wpinv_get_recurring_gateways_text() {
1478 1478
     $gateways = array();
1479 1479
 
1480
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1481
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1482
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1480
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1481
+        if (wpinv_gateway_support_subscription($key)) {
1482
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1483 1483
         }
1484 1484
     }
1485 1485
 
1486
-    if ( empty( $gateways ) ) {
1487
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>';
1486
+    if (empty($gateways)) {
1487
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>';
1488 1488
     }
1489 1489
 
1490
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>';
1490
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>';
1491 1491
 
1492 1492
 }
1493 1493
 
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
  * @return GetPaid_Template
1498 1498
  */
1499 1499
 function getpaid_template() {
1500
-    return getpaid()->get( 'template' );
1500
+    return getpaid()->get('template');
1501 1501
 }
1502 1502
 
1503 1503
 /**
@@ -1506,8 +1506,8 @@  discard block
 block discarded – undo
1506 1506
  * @param array args
1507 1507
  * @return string
1508 1508
  */
1509
-function getpaid_paginate_links( $args ) {
1510
-    return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) );
1509
+function getpaid_paginate_links($args) {
1510
+    return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args));
1511 1511
 }
1512 1512
 
1513 1513
 /**
@@ -1517,22 +1517,22 @@  discard block
 block discarded – undo
1517 1517
  * @param string state
1518 1518
  * @return string
1519 1519
  */
1520
-function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) {
1520
+function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) {
1521 1521
 
1522
-    $states = wpinv_get_country_states( $country );
1523
-    $uniqid = uniqid( '_' );
1522
+    $states = wpinv_get_country_states($country);
1523
+    $uniqid = uniqid('_');
1524 1524
 
1525
-    if ( ! empty( $states ) ) {
1525
+    if (!empty($states)) {
1526 1526
 
1527 1527
         return aui()->select(
1528 1528
             array(
1529 1529
 				'options'          => $states,
1530
-				'name'             => esc_attr( $field_name ),
1531
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1532
-				'value'            => sanitize_text_field( $state ),
1530
+				'name'             => esc_attr($field_name),
1531
+				'id'               => sanitize_html_class($field_name) . $uniqid,
1532
+				'value'            => sanitize_text_field($state),
1533 1533
 				'placeholder'      => $placeholder,
1534 1534
 				'required'         => $required,
1535
-				'label'            => wp_kses_post( $label ),
1535
+				'label'            => wp_kses_post($label),
1536 1536
 				'label_type'       => 'vertical',
1537 1537
 				'help_text'        => $help_text,
1538 1538
 				'class'            => 'getpaid-address-field wpinv_state',
@@ -1549,14 +1549,14 @@  discard block
 block discarded – undo
1549 1549
 
1550 1550
     return aui()->input(
1551 1551
         array(
1552
-            'name'             => esc_attr( $field_name ),
1553
-            'id'               => sanitize_html_class( $field_name ) . $uniqid,
1552
+            'name'             => esc_attr($field_name),
1553
+            'id'               => sanitize_html_class($field_name) . $uniqid,
1554 1554
             'placeholder'      => $placeholder,
1555 1555
             'required'         => $required,
1556
-            'label'            => wp_kses_post( $label ),
1556
+            'label'            => wp_kses_post($label),
1557 1557
             'label_type'       => 'vertical',
1558 1558
             'help_text'        => $help_text,
1559
-            'value'            => sanitize_text_field( $state ),
1559
+            'value'            => sanitize_text_field($state),
1560 1560
             'class'            => 'getpaid-address-field wpinv_state',
1561 1561
             'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1562 1562
             'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
@@ -1575,16 +1575,16 @@  discard block
 block discarded – undo
1575 1575
  * @param array $element
1576 1576
  * @return string
1577 1577
  */
1578
-function getpaid_get_form_element_grid_class( $element ) {
1578
+function getpaid_get_form_element_grid_class($element) {
1579 1579
 
1580 1580
     $class = 'col-12';
1581
-    $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width'];
1581
+    $width = empty($element['grid_width']) ? 'full' : $element['grid_width'];
1582 1582
 
1583
-    if ( $width == 'half' ) {
1583
+    if ($width == 'half') {
1584 1584
         $class .= ' col-md-6';
1585 1585
     }
1586 1586
 
1587
-    if ( $width == 'third' ) {
1587
+    if ($width == 'third') {
1588 1588
         $class .= ' col-md-4';
1589 1589
     }
1590 1590
 
@@ -1599,15 +1599,15 @@  discard block
 block discarded – undo
1599 1599
  *
1600 1600
  * @return string
1601 1601
  */
1602
-function getpaid_embed_url( $payment_form = false, $items = false ) {
1602
+function getpaid_embed_url($payment_form = false, $items = false) {
1603 1603
 
1604 1604
     return add_query_arg(
1605 1605
         array(
1606 1606
             'getpaid_embed' => 1,
1607
-            'form'          => $payment_form ? absint( $payment_form ) : false,
1608
-            'item'          => $items ? urlencode( $items ) : false,
1607
+            'form'          => $payment_form ? absint($payment_form) : false,
1608
+            'item'          => $items ? urlencode($items) : false,
1609 1609
         ),
1610
-        home_url( 'index.php' )
1610
+        home_url('index.php')
1611 1611
     );
1612 1612
 
1613 1613
 }
@@ -1617,13 +1617,13 @@  discard block
 block discarded – undo
1617 1617
  *
1618 1618
  * @return string
1619 1619
  */
1620
-function getpaid_filter_embed_template( $template ) {
1620
+function getpaid_filter_embed_template($template) {
1621 1621
 
1622
-    if ( isset( $_GET['getpaid_embed'] ) ) {
1623
-        wpinv_get_template( 'payment-forms/embed.php' );
1622
+    if (isset($_GET['getpaid_embed'])) {
1623
+        wpinv_get_template('payment-forms/embed.php');
1624 1624
         exit;
1625 1625
     }
1626 1626
 
1627 1627
     return $template;
1628 1628
 }
1629
-add_filter( 'template_include', 'getpaid_filter_embed_template' );
1629
+add_filter('template_include', 'getpaid_filter_embed_template');
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+                    foreach ( $tabs as $key => $label ) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
70
-					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-					$url   = esc_url(
68
+                    $key   = sanitize_key( $key );
69
+                    $label = esc_html( $label );
70
+                    $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                    $url   = esc_url(
72 72
                         add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73 73
                     );
74 74
 
75
-				echo "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>";
75
+                echo "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>";
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	/**
97
-	 * Retrieves reports page tabs.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	public function get_tabs() {
96
+    /**
97
+     * Retrieves reports page tabs.
98
+     *
99
+     * @return array
100
+     */
101
+    public function get_tabs() {
102 102
 
103
-		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
106
-		);
103
+        $tabs = array(
104
+            'reports' => __( 'Reports', 'invoicing' ),
105
+            'export'  => __( 'Export', 'invoicing' ),
106
+        );
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
-	}
108
+        return apply_filters( 'getpaid_report_tabs', $tabs );
109
+    }
110 110
 
111
-	/**
112
-	 * Displays the reports tab.
113
-	 *
114
-	 */
115
-	public function display_reports_tab() {
111
+    /**
112
+     * Displays the reports tab.
113
+     *
114
+     */
115
+    public function display_reports_tab() {
116 116
 
117
-		$reports = new GetPaid_Reports_Report();
118
-		$reports->display();
117
+        $reports = new GetPaid_Reports_Report();
118
+        $reports->display();
119 119
 
120
-	}
120
+    }
121 121
 
122
-	/**
123
-	 * Displays the exports tab.
124
-	 *
125
-	 */
126
-	public function display_exports_tab() {
122
+    /**
123
+     * Displays the exports tab.
124
+     *
125
+     */
126
+    public function display_exports_tab() {
127 127
 
128
-		$exports = new GetPaid_Reports_Export();
129
-		$exports->display();
128
+        $exports = new GetPaid_Reports_Export();
129
+        $exports->display();
130 130
 
131
-	}
131
+    }
132 132
 
133
-	/**
134
-	 * Donwnloads a graph.
135
-	 *
136
-	 * @param array $args
137
-	 */
138
-	public function download_graph( $args ) {
133
+    /**
134
+     * Donwnloads a graph.
135
+     *
136
+     * @param array $args
137
+     */
138
+    public function download_graph( $args ) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
141
-			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
143
-		}
140
+        if ( ! empty( $args['graph'] ) ) {
141
+            $downloader = new GetPaid_Graph_Downloader();
142
+            $downloader->download( $args['graph'] );
143
+        }
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Exports invoices.
149
-	 *
150
-	 * @param array $args
151
-	 */
152
-	public function export_invoices( $args ) {
147
+    /**
148
+     * Exports invoices.
149
+     *
150
+     * @param array $args
151
+     */
152
+    public function export_invoices( $args ) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+        if ( ! empty( $args['post_type'] ) ) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
157
-				$downloader = new GetPaid_Subscription_Exporter();
158
-			} else {
159
-				$downloader = new GetPaid_Invoice_Exporter();
160
-			}
156
+            if ( 'subscriptions' === $args['post_type'] ) {
157
+                $downloader = new GetPaid_Subscription_Exporter();
158
+            } else {
159
+                $downloader = new GetPaid_Invoice_Exporter();
160
+            }
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
163
-		}
162
+            $downloader->export( $args['post_type'], $args );
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo esc_html($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
68
+					$key   = sanitize_key($key);
69
+					$label = esc_html($label);
70 70
 					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 					$url   = esc_url(
72
-                        add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+                        add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
                     );
74 74
 
75 75
 				echo "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>";
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true);
93 93
 
94 94
 	}
95 95
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	public function get_tabs() {
102 102
 
103 103
 		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
104
+			'reports' => __('Reports', 'invoicing'),
105
+			'export'  => __('Export', 'invoicing'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
108
+		return apply_filters('getpaid_report_tabs', $tabs);
109 109
 	}
110 110
 
111 111
 	/**
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $args
137 137
 	 */
138
-	public function download_graph( $args ) {
138
+	public function download_graph($args) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
140
+		if (!empty($args['graph'])) {
141 141
 			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
142
+			$downloader->download($args['graph']);
143 143
 		}
144 144
 
145 145
 	}
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $args
151 151
 	 */
152
-	public function export_invoices( $args ) {
152
+	public function export_invoices($args) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+		if (!empty($args['post_type'])) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
156
+			if ('subscriptions' === $args['post_type']) {
157 157
 				$downloader = new GetPaid_Subscription_Exporter();
158 158
 			} else {
159 159
 				$downloader = new GetPaid_Invoice_Exporter();
160 160
 			}
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
162
+			$downloader->export($args['post_type'], $args);
163 163
 		}
164 164
 
165 165
 	}
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param string $amount The amount to sanitize.
58 58
  * @return float
59 59
  */
60
-function getpaid_standardize_amount( $amount ) {
60
+function getpaid_standardize_amount($amount) {
61 61
 
62
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
63
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
64
-    if ( is_numeric( $amount ) ) {
65
-        return floatval( $amount );
62
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
63
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
64
+    if (is_numeric($amount)) {
65
+        return floatval($amount);
66 66
     }
67 67
 
68 68
     // Cast the remaining to a float.
69
-    return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) );
69
+    return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount));
70 70
 
71 71
 }
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @param string $amount The amount to sanitize.
77 77
  */
78
-function getpaid_unstandardize_amount( $amount ) {
79
-    return str_replace( '.', wpinv_decimal_separator(), $amount );
78
+function getpaid_unstandardize_amount($amount) {
79
+    return str_replace('.', wpinv_decimal_separator(), $amount);
80 80
 }
81 81
 
82 82
 /**
@@ -84,23 +84,23 @@  discard block
 block discarded – undo
84 84
  *
85 85
  * @param string $amount The amount to sanitize.
86 86
  */
87
-function wpinv_sanitize_amount( $amount ) {
87
+function wpinv_sanitize_amount($amount) {
88 88
 
89
-    if ( is_numeric( $amount ) ) {
90
-        return floatval( $amount );
89
+    if (is_numeric($amount)) {
90
+        return floatval($amount);
91 91
     }
92 92
 
93 93
     // Separate the decimals and thousands.
94
-    $amount    = explode( wpinv_decimal_separator(), $amount );
94
+    $amount    = explode(wpinv_decimal_separator(), $amount);
95 95
 
96 96
     // Remove thousands.
97
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
97
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
98 98
 
99 99
     // Convert back to string.
100
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
100
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
101 101
 
102 102
     // Cast the remaining to a float.
103
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
103
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
104 104
 
105 105
 }
106 106
 
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
  * @param float $amount
111 111
  * @param float|string|int|null $decimals
112 112
  */
113
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
113
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
114 114
 
115
-    if ( $decimals === null ) {
115
+    if ($decimals === null) {
116 116
         $decimals = wpinv_decimals();
117 117
     }
118 118
 
119
-    if ( $use_sprintf ) {
120
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
119
+    if ($use_sprintf) {
120
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
121 121
     } else {
122
-        $amount = round( (float) $amount, absint( $decimals ) );
122
+        $amount = round((float) $amount, absint($decimals));
123 123
     }
124 124
 
125
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
125
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
126 126
 }
127 127
 
128 128
 /**
@@ -134,32 +134,32 @@  discard block
 block discarded – undo
134 134
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
135 135
  * @return array
136 136
  */
137
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
137
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
138 138
 
139 139
 	$invoice_statuses = array(
140
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
141
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
142
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
143
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
146
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
147
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
140
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
141
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
142
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
143
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
144
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
145
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
146
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
147
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
148 148
     );
149 149
 
150
-    if ( $draft ) {
151
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
150
+    if ($draft) {
151
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
152 152
     }
153 153
 
154
-    if ( $trashed ) {
155
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
154
+    if ($trashed) {
155
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
156 156
     }
157 157
 
158
-    if ( $invoice instanceof WPInv_Invoice ) {
158
+    if ($invoice instanceof WPInv_Invoice) {
159 159
         $invoice = $invoice->get_post_type();
160 160
     }
161 161
 
162
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
162
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
163 163
 }
164 164
 
165 165
 /**
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
  * @param string $status The raw status
169 169
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
170 170
  */
171
-function wpinv_status_nicename( $status, $invoice = false ) {
172
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
173
-    $status   = isset( $statuses[ $status ] ) ? $statuses[ $status ] : $status;
171
+function wpinv_status_nicename($status, $invoice = false) {
172
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
173
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
174 174
 
175
-    return sanitize_text_field( $status );
175
+    return sanitize_text_field($status);
176 176
 }
177 177
 
178 178
 /**
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @param string $current
182 182
  */
183
-function wpinv_get_currency( $current = '' ) {
183
+function wpinv_get_currency($current = '') {
184 184
 
185
-    if ( empty( $current ) ) {
186
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
185
+    if (empty($current)) {
186
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
187 187
     }
188 188
 
189
-    return trim( strtoupper( $current ) );
189
+    return trim(strtoupper($current));
190 190
 }
191 191
 
192 192
 /**
@@ -194,25 +194,25 @@  discard block
 block discarded – undo
194 194
  *
195 195
  * @param string|null $currency The currency code. Defaults to the default currency.
196 196
  */
197
-function wpinv_currency_symbol( $currency = null ) {
197
+function wpinv_currency_symbol($currency = null) {
198 198
 
199 199
     // Prepare the currency.
200
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
200
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
201 201
 
202 202
     // Fetch all symbols.
203 203
     $symbols = wpinv_get_currency_symbols();
204 204
 
205 205
     // Fetch this currencies symbol.
206
-    $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : $currency;
206
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
207 207
 
208 208
     // Filter the symbol.
209
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
209
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
210 210
 }
211 211
 
212 212
 function wpinv_currency_position() {
213
-    $position = wpinv_get_option( 'currency_position', 'left' );
213
+    $position = wpinv_get_option('currency_position', 'left');
214 214
 
215
-    return apply_filters( 'wpinv_currency_position', $position );
215
+    return apply_filters('wpinv_currency_position', $position);
216 216
 }
217 217
 
218 218
 /**
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
  *
221 221
  * @param $string|null $current
222 222
  */
223
-function wpinv_thousands_separator( $current = null ) {
223
+function wpinv_thousands_separator($current = null) {
224 224
 
225
-    if ( null == $current ) {
226
-        $current = wpinv_get_option( 'thousands_separator', ',' );
225
+    if (null == $current) {
226
+        $current = wpinv_get_option('thousands_separator', ',');
227 227
     }
228 228
 
229
-    return trim( $current );
229
+    return trim($current);
230 230
 }
231 231
 
232 232
 /**
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
  *
235 235
  * @param $string|null $current
236 236
  */
237
-function wpinv_decimal_separator( $current = null ) {
237
+function wpinv_decimal_separator($current = null) {
238 238
 
239
-    if ( null == $current ) {
240
-        $current = wpinv_get_option( 'decimal_separator', '.' );
239
+    if (null == $current) {
240
+        $current = wpinv_get_option('decimal_separator', '.');
241 241
     }
242 242
 
243
-    return trim( $current );
243
+    return trim($current);
244 244
 }
245 245
 
246 246
 /**
@@ -248,27 +248,27 @@  discard block
 block discarded – undo
248 248
  *
249 249
  * @param $string|null $current
250 250
  */
251
-function wpinv_decimals( $current = null ) {
251
+function wpinv_decimals($current = null) {
252 252
 
253
-    if ( null == $current ) {
254
-        $current = wpinv_get_option( 'decimals', 2 );
253
+    if (null == $current) {
254
+        $current = wpinv_get_option('decimals', 2);
255 255
     }
256 256
 
257
-    return absint( $current );
257
+    return absint($current);
258 258
 }
259 259
 
260 260
 /**
261 261
  * Retrieves a list of all supported currencies.
262 262
  */
263 263
 function wpinv_get_currencies() {
264
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
264
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
265 265
 }
266 266
 
267 267
 /**
268 268
  * Retrieves a list of all currency symbols.
269 269
  */
270 270
 function wpinv_get_currency_symbols() {
271
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
271
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
272 272
 }
273 273
 
274 274
 /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	$currency_pos = wpinv_currency_position();
281 281
 	$format       = '%1$s%2$s';
282 282
 
283
-	switch ( $currency_pos ) {
283
+	switch ($currency_pos) {
284 284
 		case 'left':
285 285
 			$format = '%1$s%2$s';
286 286
 			break;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			break;
296 296
 	}
297 297
 
298
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
298
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
299 299
 }
300 300
 
301 301
 /**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
  * @param  string $currency Currency.
306 306
  * @return string
307 307
  */
308
-function wpinv_the_price( $amount = 0, $currency = '' ) {
309
-    echo wp_kses_post( wpinv_price( $amount, $currency ) );
308
+function wpinv_the_price($amount = 0, $currency = '') {
309
+    echo wp_kses_post(wpinv_price($amount, $currency));
310 310
 }
311 311
 
312 312
 /**
@@ -316,25 +316,25 @@  discard block
 block discarded – undo
316 316
  * @param  string $currency Currency.
317 317
  * @return string
318 318
  */
319
-function wpinv_price( $amount = 0, $currency = '' ) {
319
+function wpinv_price($amount = 0, $currency = '') {
320 320
 
321 321
     // Backwards compatibility.
322
-    $amount             = wpinv_sanitize_amount( $amount );
322
+    $amount             = wpinv_sanitize_amount($amount);
323 323
 
324 324
     // Prepare variables.
325
-    $currency           = wpinv_get_currency( $currency );
325
+    $currency           = wpinv_get_currency($currency);
326 326
     $amount             = (float) $amount;
327 327
     $unformatted_amount = $amount;
328 328
     $negative           = $amount < 0;
329
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
330
-    $amount             = wpinv_format_amount( $amount );
329
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
330
+    $amount             = wpinv_format_amount($amount);
331 331
 
332 332
     // Format the amount.
333 333
     $format             = getpaid_get_price_format();
334
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
334
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
335 335
 
336 336
     // Filter the formatting.
337
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
337
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
338 338
 }
339 339
 
340 340
 /**
@@ -345,25 +345,25 @@  discard block
 block discarded – undo
345 345
  * @param  bool     $calculate Whether or not to apply separators.
346 346
  * @return string
347 347
  */
348
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
348
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
349 349
     $thousands_sep = wpinv_thousands_separator();
350 350
     $decimal_sep   = wpinv_decimal_separator();
351
-    $decimals      = wpinv_decimals( $decimals );
352
-    $amount        = wpinv_sanitize_amount( $amount );
351
+    $decimals      = wpinv_decimals($decimals);
352
+    $amount        = wpinv_sanitize_amount($amount);
353 353
 
354
-    if ( $calculate ) {
354
+    if ($calculate) {
355 355
         return $amount;
356 356
     }
357 357
 
358 358
     // Fomart the amount.
359
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
359
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
360 360
 }
361 361
 
362
-function wpinv_sanitize_key( $key ) {
362
+function wpinv_sanitize_key($key) {
363 363
     $raw_key = $key;
364
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
364
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
365 365
 
366
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
366
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
367 367
 }
368 368
 
369 369
 /**
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
  *
372 372
  * @param $str the file whose extension should be retrieved.
373 373
  */
374
-function wpinv_get_file_extension( $str ) {
375
-    $filetype = wp_check_filetype( $str );
374
+function wpinv_get_file_extension($str) {
375
+    $filetype = wp_check_filetype($str);
376 376
     return $filetype['ext'];
377 377
 }
378 378
 
@@ -381,16 +381,16 @@  discard block
 block discarded – undo
381 381
  *
382 382
  * @param string $string
383 383
  */
384
-function wpinv_string_is_image_url( $string ) {
385
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
386
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
384
+function wpinv_string_is_image_url($string) {
385
+    $extension = strtolower(wpinv_get_file_extension($string));
386
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
387 387
 }
388 388
 
389 389
 /**
390 390
  * Returns the current URL.
391 391
  */
392 392
 function wpinv_get_current_page_url() {
393
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
393
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
394 394
 }
395 395
 
396 396
 /**
@@ -400,46 +400,46 @@  discard block
 block discarded – undo
400 400
  * @param string $name  Constant name.
401 401
  * @param mixed  $value Value.
402 402
  */
403
-function getpaid_maybe_define_constant( $name, $value ) {
404
-	if ( ! defined( $name ) ) {
405
-		define( $name, $value );
403
+function getpaid_maybe_define_constant($name, $value) {
404
+	if (!defined($name)) {
405
+		define($name, $value);
406 406
 	}
407 407
 }
408 408
 
409 409
 function wpinv_get_php_arg_separator_output() {
410
-	return ini_get( 'arg_separator.output' );
410
+	return ini_get('arg_separator.output');
411 411
 }
412 412
 
413
-function wpinv_rgb_from_hex( $color ) {
414
-    $color = str_replace( '#', '', $color );
413
+function wpinv_rgb_from_hex($color) {
414
+    $color = str_replace('#', '', $color);
415 415
 
416 416
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
417
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
418
-    if ( empty( $color ) ) {
417
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
418
+    if (empty($color)) {
419 419
         return null;
420 420
     }
421 421
 
422
-    $color = str_split( $color );
422
+    $color = str_split($color);
423 423
 
424 424
     $rgb      = array();
425
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
426
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
427
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
425
+    $rgb['R'] = hexdec($color[0] . $color[1]);
426
+    $rgb['G'] = hexdec($color[2] . $color[3]);
427
+    $rgb['B'] = hexdec($color[4] . $color[5]);
428 428
 
429 429
     return $rgb;
430 430
 }
431 431
 
432
-function wpinv_hex_darker( $color, $factor = 30 ) {
433
-    $base  = wpinv_rgb_from_hex( $color );
432
+function wpinv_hex_darker($color, $factor = 30) {
433
+    $base  = wpinv_rgb_from_hex($color);
434 434
     $color = '#';
435 435
 
436
-    foreach ( $base as $k => $v ) {
436
+    foreach ($base as $k => $v) {
437 437
         $amount      = $v / 100;
438
-        $amount      = round( $amount * $factor );
438
+        $amount      = round($amount * $factor);
439 439
         $new_decimal = $v - $amount;
440 440
 
441
-        $new_hex_component = dechex( $new_decimal );
442
-        if ( strlen( $new_hex_component ) < 2 ) {
441
+        $new_hex_component = dechex($new_decimal);
442
+        if (strlen($new_hex_component) < 2) {
443 443
             $new_hex_component = '0' . $new_hex_component;
444 444
         }
445 445
         $color .= $new_hex_component;
@@ -448,18 +448,18 @@  discard block
 block discarded – undo
448 448
     return $color;
449 449
 }
450 450
 
451
-function wpinv_hex_lighter( $color, $factor = 30 ) {
452
-    $base  = wpinv_rgb_from_hex( $color );
451
+function wpinv_hex_lighter($color, $factor = 30) {
452
+    $base  = wpinv_rgb_from_hex($color);
453 453
     $color = '#';
454 454
 
455
-    foreach ( $base as $k => $v ) {
455
+    foreach ($base as $k => $v) {
456 456
         $amount      = 255 - $v;
457 457
         $amount      = $amount / 100;
458
-        $amount      = round( $amount * $factor );
458
+        $amount      = round($amount * $factor);
459 459
         $new_decimal = $v + $amount;
460 460
 
461
-        $new_hex_component = dechex( $new_decimal );
462
-        if ( strlen( $new_hex_component ) < 2 ) {
461
+        $new_hex_component = dechex($new_decimal);
462
+        if (strlen($new_hex_component) < 2) {
463 463
             $new_hex_component = '0' . $new_hex_component;
464 464
         }
465 465
         $color .= $new_hex_component;
@@ -468,22 +468,22 @@  discard block
 block discarded – undo
468 468
     return $color;
469 469
 }
470 470
 
471
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
472
-    $hex = str_replace( '#', '', $color );
471
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
472
+    $hex = str_replace('#', '', $color);
473 473
 
474
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
475
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
476
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
474
+    $c_r = hexdec(substr($hex, 0, 2));
475
+    $c_g = hexdec(substr($hex, 2, 2));
476
+    $c_b = hexdec(substr($hex, 4, 2));
477 477
 
478
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
478
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
479 479
 
480 480
     return $brightness > 155 ? $dark : $light;
481 481
 }
482 482
 
483
-function wpinv_format_hex( $hex ) {
484
-    $hex = trim( str_replace( '#', '', $hex ) );
483
+function wpinv_format_hex($hex) {
484
+    $hex = trim(str_replace('#', '', $hex));
485 485
 
486
-    if ( strlen( $hex ) == 3 ) {
486
+    if (strlen($hex) == 3) {
487 487
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
488 488
     }
489 489
 
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
504 504
  * @return string
505 505
  */
506
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
507
-    if ( function_exists( 'mb_strimwidth' ) ) {
508
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
506
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
507
+    if (function_exists('mb_strimwidth')) {
508
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
509 509
     }
510 510
 
511
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
511
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
512 512
 }
513 513
 
514 514
 /**
@@ -520,28 +520,28 @@  discard block
 block discarded – undo
520 520
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
521 521
  * @return int Returns the number of characters in string.
522 522
  */
523
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
524
-    if ( function_exists( 'mb_strlen' ) ) {
525
-        return mb_strlen( $str, $encoding );
523
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
524
+    if (function_exists('mb_strlen')) {
525
+        return mb_strlen($str, $encoding);
526 526
     }
527 527
 
528
-    return strlen( $str );
528
+    return strlen($str);
529 529
 }
530 530
 
531
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
532
-    if ( function_exists( 'mb_strtolower' ) ) {
533
-        return mb_strtolower( $str, $encoding );
531
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
532
+    if (function_exists('mb_strtolower')) {
533
+        return mb_strtolower($str, $encoding);
534 534
     }
535 535
 
536
-    return strtolower( $str );
536
+    return strtolower($str);
537 537
 }
538 538
 
539
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
540
-    if ( function_exists( 'mb_strtoupper' ) ) {
541
-        return mb_strtoupper( $str, $encoding );
539
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
540
+    if (function_exists('mb_strtoupper')) {
541
+        return mb_strtoupper($str, $encoding);
542 542
     }
543 543
 
544
-    return strtoupper( $str );
544
+    return strtoupper($str);
545 545
 }
546 546
 
547 547
 /**
@@ -555,12 +555,12 @@  discard block
 block discarded – undo
555 555
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
556 556
  * @return int Returns the position of the first occurrence of search in the string.
557 557
  */
558
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
559
-    if ( function_exists( 'mb_strpos' ) ) {
560
-        return mb_strpos( $str, $find, $offset, $encoding );
558
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
559
+    if (function_exists('mb_strpos')) {
560
+        return mb_strpos($str, $find, $offset, $encoding);
561 561
     }
562 562
 
563
-    return strpos( $str, $find, $offset );
563
+    return strpos($str, $find, $offset);
564 564
 }
565 565
 
566 566
 /**
@@ -574,12 +574,12 @@  discard block
 block discarded – undo
574 574
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
575 575
  * @return int Returns the position of the last occurrence of search.
576 576
  */
577
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
578
-    if ( function_exists( 'mb_strrpos' ) ) {
579
-        return mb_strrpos( $str, $find, $offset, $encoding );
577
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
578
+    if (function_exists('mb_strrpos')) {
579
+        return mb_strrpos($str, $find, $offset, $encoding);
580 580
     }
581 581
 
582
-    return strrpos( $str, $find, $offset );
582
+    return strrpos($str, $find, $offset);
583 583
 }
584 584
 
585 585
 /**
@@ -594,16 +594,16 @@  discard block
 block discarded – undo
594 594
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
595 595
  * @return string
596 596
  */
597
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
598
-    if ( function_exists( 'mb_substr' ) ) {
599
-        if ( $length === null ) {
600
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
597
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
598
+    if (function_exists('mb_substr')) {
599
+        if ($length === null) {
600
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
601 601
         } else {
602
-            return mb_substr( $str, $start, $length, $encoding );
602
+            return mb_substr($str, $start, $length, $encoding);
603 603
         }
604 604
     }
605 605
 
606
-    return substr( $str, $start, $length );
606
+    return substr($str, $start, $length);
607 607
 }
608 608
 
609 609
 /**
@@ -615,48 +615,48 @@  discard block
 block discarded – undo
615 615
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
616 616
  * @return string The width of string.
617 617
  */
618
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
619
-    if ( function_exists( 'mb_strwidth' ) ) {
620
-        return mb_strwidth( $str, $encoding );
618
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
619
+    if (function_exists('mb_strwidth')) {
620
+        return mb_strwidth($str, $encoding);
621 621
     }
622 622
 
623
-    return wpinv_utf8_strlen( $str, $encoding );
623
+    return wpinv_utf8_strlen($str, $encoding);
624 624
 }
625 625
 
626
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
627
-    if ( function_exists( 'mb_strlen' ) ) {
628
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
626
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
627
+    if (function_exists('mb_strlen')) {
628
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
629 629
         $str_end = '';
630 630
 
631
-        if ( $lower_str_end ) {
632
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
631
+        if ($lower_str_end) {
632
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
633 633
         } else {
634
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
634
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
635 635
         }
636 636
 
637 637
         return $first_letter . $str_end;
638 638
     }
639 639
 
640
-    return ucfirst( $str );
640
+    return ucfirst($str);
641 641
 }
642 642
 
643
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
644
-    if ( function_exists( 'mb_convert_case' ) ) {
645
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
643
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
644
+    if (function_exists('mb_convert_case')) {
645
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
646 646
     }
647 647
 
648
-    return ucwords( $str );
648
+    return ucwords($str);
649 649
 }
650 650
 
651
-function wpinv_period_in_days( $period, $unit ) {
652
-    $period = absint( $period );
651
+function wpinv_period_in_days($period, $unit) {
652
+    $period = absint($period);
653 653
 
654
-    if ( $period > 0 ) {
655
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
654
+    if ($period > 0) {
655
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
656 656
             $period = $period * 7;
657
-        } elseif ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
657
+        } elseif (in_array(strtolower($unit), array('m', 'month', 'months'))) {
658 658
             $period = $period * 30;
659
-        } elseif ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
659
+        } elseif (in_array(strtolower($unit), array('y', 'year', 'years'))) {
660 660
             $period = $period * 365;
661 661
         }
662 662
     }
@@ -664,14 +664,14 @@  discard block
 block discarded – undo
664 664
     return $period;
665 665
 }
666 666
 
667
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
668
-    if ( function_exists( 'cal_days_in_month' ) ) {
669
-        return cal_days_in_month( $calendar, $month, $year );
667
+function wpinv_cal_days_in_month($calendar, $month, $year) {
668
+    if (function_exists('cal_days_in_month')) {
669
+        return cal_days_in_month($calendar, $month, $year);
670 670
     }
671 671
 
672 672
     // Fallback in case the calendar extension is not loaded in PHP
673 673
     // Only supports Gregorian calendar
674
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
674
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
675 675
 }
676 676
 
677 677
 /**
@@ -682,27 +682,27 @@  discard block
 block discarded – undo
682 682
  *
683 683
  * @return string
684 684
  */
685
-function wpi_help_tip( $tip, $allow_html = false, $is_vue = false, $echo = false ) {
685
+function wpi_help_tip($tip, $allow_html = false, $is_vue = false, $echo = false) {
686 686
 
687
-    if ( $allow_html ) {
688
-        $tip = wpi_sanitize_tooltip( $tip );
687
+    if ($allow_html) {
688
+        $tip = wpi_sanitize_tooltip($tip);
689 689
     } else {
690
-        $tip = strip_tags( $tip );
690
+        $tip = strip_tags($tip);
691 691
     }
692 692
 
693
-    if ( $is_vue ) {
693
+    if ($is_vue) {
694 694
 
695
-        if ( $echo ) {
696
-            echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
695
+        if ($echo) {
696
+            echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
697 697
         } else {
698
-            return '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
698
+            return '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
699 699
         }
700 700
 }
701 701
 
702
-    if ( $echo ) {
703
-        echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
702
+    if ($echo) {
703
+        echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
704 704
     } else {
705
-        return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
705
+        return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
706 706
     }
707 707
 }
708 708
 
@@ -714,9 +714,9 @@  discard block
 block discarded – undo
714 714
  * @param string $var
715 715
  * @return string
716 716
  */
717
-function wpi_sanitize_tooltip( $var ) {
717
+function wpi_sanitize_tooltip($var) {
718 718
     return wp_kses(
719
-        html_entity_decode( $var ),
719
+        html_entity_decode($var),
720 720
         array(
721 721
 			'br'     => array(),
722 722
 			'em'     => array(),
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
  */
740 740
 function wpinv_get_screen_ids() {
741 741
 
742
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
742
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
743 743
 
744 744
     $screen_ids = array(
745 745
         'toplevel_page_' . $screen_id,
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
         'gp-setup', // setup wizard
762 762
     );
763 763
 
764
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
764
+    return apply_filters('wpinv_screen_ids', $screen_ids);
765 765
 }
766 766
 
767 767
 /**
@@ -772,14 +772,14 @@  discard block
 block discarded – undo
772 772
  * @param array|string $list List of values.
773 773
  * @return array Sanitized array of values.
774 774
  */
775
-function wpinv_parse_list( $list ) {
775
+function wpinv_parse_list($list) {
776 776
 
777
-    if ( empty( $list ) ) {
777
+    if (empty($list)) {
778 778
         $list = array();
779 779
     }
780 780
 
781
-	if ( ! is_array( $list ) ) {
782
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
781
+	if (!is_array($list)) {
782
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
783 783
 	}
784 784
 
785 785
 	return $list;
@@ -793,16 +793,16 @@  discard block
 block discarded – undo
793 793
  * @param string $key Type of data to fetch.
794 794
  * @return mixed Fetched data.
795 795
  */
796
-function wpinv_get_data( $key ) {
796
+function wpinv_get_data($key) {
797 797
 
798 798
     // Try fetching it from the cache.
799
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
800
-    if ( $data ) {
799
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
800
+    if ($data) {
801 801
         return $data;
802 802
     }
803 803
 
804
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
805
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
804
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
805
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
806 806
 
807 807
 	return $data;
808 808
 }
@@ -816,10 +816,10 @@  discard block
 block discarded – undo
816 816
  * @param bool $first_empty Whether or not the first item in the list should be empty
817 817
  * @return mixed Fetched data.
818 818
  */
819
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
819
+function wpinv_maybe_add_empty_option($options, $first_empty) {
820 820
 
821
-    if ( ! empty( $options ) && $first_empty ) {
822
-        return array_merge( array( '' => '' ), $options );
821
+    if (!empty($options) && $first_empty) {
822
+        return array_merge(array('' => ''), $options);
823 823
     }
824 824
     return $options;
825 825
 
@@ -831,21 +831,21 @@  discard block
 block discarded – undo
831 831
  * @param mixed $var Data to sanitize.
832 832
  * @return string|array
833 833
  */
834
-function wpinv_clean( $var ) {
834
+function wpinv_clean($var) {
835 835
 
836
-	if ( is_array( $var ) ) {
837
-		return array_map( 'wpinv_clean', $var );
836
+	if (is_array($var)) {
837
+		return array_map('wpinv_clean', $var);
838 838
     }
839 839
 
840
-    if ( is_object( $var ) ) {
841
-		$object_vars = get_object_vars( $var );
842
-		foreach ( $object_vars as $property_name => $property_value ) {
843
-			$var->$property_name = wpinv_clean( $property_value );
840
+    if (is_object($var)) {
841
+		$object_vars = get_object_vars($var);
842
+		foreach ($object_vars as $property_name => $property_value) {
843
+			$var->$property_name = wpinv_clean($property_value);
844 844
         }
845 845
         return $var;
846 846
 	}
847 847
 
848
-    return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
848
+    return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var;
849 849
 }
850 850
 
851 851
 /**
@@ -854,43 +854,43 @@  discard block
 block discarded – undo
854 854
  * @param string $str Data to convert.
855 855
  * @return string|array
856 856
  */
857
-function getpaid_convert_price_string_to_options( $str ) {
857
+function getpaid_convert_price_string_to_options($str) {
858 858
 
859
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
860
-    $options     = array();
859
+	$raw_options = array_map('trim', explode(',', $str));
860
+    $options = array();
861 861
 
862
-    foreach ( $raw_options as $option ) {
862
+    foreach ($raw_options as $option) {
863 863
 
864
-        if ( '' == $option ) {
864
+        if ('' == $option) {
865 865
             continue;
866 866
         }
867 867
 
868
-        $option = array_map( 'trim', explode( '|', $option ) );
868
+        $option = array_map('trim', explode('|', $option));
869 869
 
870 870
         $price = null;
871 871
         $label = null;
872 872
 
873
-        if ( isset( $option[0] ) && '' != $option[0] ) {
874
-            $label  = $option[0];
873
+        if (isset($option[0]) && '' != $option[0]) {
874
+            $label = $option[0];
875 875
         }
876 876
 
877
-        if ( isset( $option[1] ) && '' != $option[1] ) {
877
+        if (isset($option[1]) && '' != $option[1]) {
878 878
             $price = $option[1];
879 879
         }
880 880
 
881
-        if ( ! isset( $price ) ) {
881
+        if (!isset($price)) {
882 882
             $price = $label;
883 883
         }
884 884
 
885
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
885
+        if (!isset($price) || !is_numeric($price)) {
886 886
             continue;
887 887
         }
888 888
 
889
-        if ( ! isset( $label ) ) {
889
+        if (!isset($label)) {
890 890
             $label = $price;
891 891
         }
892 892
 
893
-        $options[ "$label|$price" ] = $label;
893
+        $options["$label|$price"] = $label;
894 894
     }
895 895
 
896 896
     return $options;
@@ -899,27 +899,27 @@  discard block
 block discarded – undo
899 899
 /**
900 900
  * Returns the help tip.
901 901
  */
902
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
903
-    $additional_classes = sanitize_html_class( $additional_classes );
904
-    $tip                = esc_attr__( $tip );
902
+function getpaid_get_help_tip($tip, $additional_classes = '') {
903
+    $additional_classes = sanitize_html_class($additional_classes);
904
+    $tip                = esc_attr__($tip);
905 905
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
906 906
 }
907 907
 
908 908
 /**
909 909
  * Formats a date
910 910
  */
911
-function getpaid_format_date( $date, $with_time = false ) {
911
+function getpaid_format_date($date, $with_time = false) {
912 912
 
913
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
913
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
914 914
         return '';
915 915
     }
916 916
 
917 917
     $format = getpaid_date_format();
918 918
 
919
-    if ( $with_time ) {
919
+    if ($with_time) {
920 920
         $format .= ' ' . getpaid_time_format();
921 921
     }
922
-    return date_i18n( $format, strtotime( $date ) );
922
+    return date_i18n($format, strtotime($date));
923 923
 
924 924
 }
925 925
 
@@ -928,9 +928,9 @@  discard block
 block discarded – undo
928 928
  *
929 929
  * @return string
930 930
  */
931
-function getpaid_format_date_value( $date, $default = '&mdash;', $with_time = false ) {
932
-    $date = getpaid_format_date( $date, $with_time );
933
-    return empty( $date ) ? $default : $date;
931
+function getpaid_format_date_value($date, $default = '&mdash;', $with_time = false) {
932
+    $date = getpaid_format_date($date, $with_time);
933
+    return empty($date) ? $default : $date;
934 934
 }
935 935
 
936 936
 /**
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
  * @return string
940 940
  */
941 941
 function getpaid_date_format() {
942
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
942
+	return apply_filters('getpaid_date_format', get_option('date_format'));
943 943
 }
944 944
 
945 945
 /**
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
  * @return string
949 949
  */
950 950
 function getpaid_time_format() {
951
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
951
+	return apply_filters('getpaid_time_format', get_option('time_format'));
952 952
 }
953 953
 
954 954
 /**
@@ -958,16 +958,16 @@  discard block
 block discarded – undo
958 958
  * @param  integer $limit Limit size in characters.
959 959
  * @return string
960 960
  */
961
-function getpaid_limit_length( $string, $limit ) {
961
+function getpaid_limit_length($string, $limit) {
962 962
     $str_limit = $limit - 3;
963 963
 
964
-	if ( function_exists( 'mb_strimwidth' ) ) {
965
-		if ( mb_strlen( $string ) > $limit ) {
966
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
964
+	if (function_exists('mb_strimwidth')) {
965
+		if (mb_strlen($string) > $limit) {
966
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
967 967
 		}
968 968
 	} else {
969
-		if ( strlen( $string ) > $limit ) {
970
-			$string = substr( $string, 0, $str_limit ) . '...';
969
+		if (strlen($string) > $limit) {
970
+			$string = substr($string, 0, $str_limit) . '...';
971 971
 		}
972 972
 	}
973 973
     return $string;
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
  * @since 1.0.19
982 982
  */
983 983
 function getpaid_api() {
984
-    return getpaid()->get( 'api' );
984
+    return getpaid()->get('api');
985 985
 }
986 986
 
987 987
 /**
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
  * @since 1.0.19
992 992
  */
993 993
 function getpaid_post_types() {
994
-    return getpaid()->get( 'post_types' );
994
+    return getpaid()->get('post_types');
995 995
 }
996 996
 
997 997
 /**
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
  * @since 1.0.19
1002 1002
  */
1003 1003
 function getpaid_session() {
1004
-    return getpaid()->get( 'session' );
1004
+    return getpaid()->get('session');
1005 1005
 }
1006 1006
 
1007 1007
 /**
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
  * @since 1.0.19
1012 1012
  */
1013 1013
 function getpaid_notes() {
1014
-    return getpaid()->get( 'notes' );
1014
+    return getpaid()->get('notes');
1015 1015
 }
1016 1016
 
1017 1017
 /**
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
  * @return GetPaid_Admin
1021 1021
  */
1022 1022
 function getpaid_admin() {
1023
-    return getpaid()->get( 'admin' );
1023
+    return getpaid()->get('admin');
1024 1024
 }
1025 1025
 
1026 1026
 /**
@@ -1030,8 +1030,8 @@  discard block
 block discarded – undo
1030 1030
  * @param string $base the base url
1031 1031
  * @return string
1032 1032
  */
1033
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
1034
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
1033
+function getpaid_get_authenticated_action_url($action, $base = false) {
1034
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
1035 1035
 }
1036 1036
 
1037 1037
 /**
@@ -1039,11 +1039,11 @@  discard block
 block discarded – undo
1039 1039
  *
1040 1040
  * @return string
1041 1041
  */
1042
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
1042
+function getpaid_get_post_type_label($post_type, $plural = true) {
1043 1043
 
1044
-    $post_type = get_post_type_object( $post_type );
1044
+    $post_type = get_post_type_object($post_type);
1045 1045
 
1046
-    if ( ! is_object( $post_type ) ) {
1046
+    if (!is_object($post_type)) {
1047 1047
         return null;
1048 1048
     }
1049 1049
 
@@ -1056,18 +1056,18 @@  discard block
 block discarded – undo
1056 1056
  *
1057 1057
  * @return mixed|null
1058 1058
  */
1059
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1059
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1060 1060
 
1061
-    if ( ! is_array( $array ) ) {
1061
+    if (!is_array($array)) {
1062 1062
         return null;
1063 1063
     }
1064 1064
 
1065
-    if ( ! empty( $secondary_key ) ) {
1066
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1067
-        return getpaid_get_array_field( $array, $key );
1065
+    if (!empty($secondary_key)) {
1066
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1067
+        return getpaid_get_array_field($array, $key);
1068 1068
     }
1069 1069
 
1070
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1070
+    return isset($array[$key]) ? $array[$key] : null;
1071 1071
 
1072 1072
 }
1073 1073
 
@@ -1076,12 +1076,12 @@  discard block
 block discarded – undo
1076 1076
  *
1077 1077
  * @return array
1078 1078
  */
1079
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1079
+function getpaid_array_merge_if_empty($args, $defaults) {
1080 1080
 
1081
-    foreach ( $defaults as $key => $value ) {
1081
+    foreach ($defaults as $key => $value) {
1082 1082
 
1083
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1084
-            $args[ $key ] = $value;
1083
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1084
+            $args[$key] = $value;
1085 1085
         }
1086 1086
 }
1087 1087
 
@@ -1098,12 +1098,12 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
     $types = get_allowed_mime_types();
1100 1100
 
1101
-    if ( isset( $types['htm|html'] ) ) {
1102
-		unset( $types['htm|html'] );
1101
+    if (isset($types['htm|html'])) {
1102
+		unset($types['htm|html']);
1103 1103
 	}
1104 1104
 
1105
-    if ( isset( $types['js'] ) ) {
1106
-		unset( $types['js'] );
1105
+    if (isset($types['js'])) {
1106
+		unset($types['js']);
1107 1107
 	}
1108 1108
 
1109 1109
     return $types;
@@ -1111,34 +1111,34 @@  discard block
 block discarded – undo
1111 1111
 }
1112 1112
 
1113 1113
 
1114
-function getpaid_user_delete_invoice( $data ) {
1114
+function getpaid_user_delete_invoice($data) {
1115 1115
 
1116 1116
     // Ensure there is an invoice to delete.
1117
-    if ( empty( $data['invoice_id'] ) ) {
1117
+    if (empty($data['invoice_id'])) {
1118 1118
         return;
1119 1119
     }
1120 1120
 
1121
-    $invoice = new WPInv_Invoice( (int) $data['invoice_id'] );
1121
+    $invoice = new WPInv_Invoice((int) $data['invoice_id']);
1122 1122
 
1123 1123
     // Ensure that it exists and that it belongs to the current user.
1124
-    if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) {
1125
-        wpinv_set_error( 'invalid_invoice', __( 'You do not have permission to delete this invoice', 'invoicing' ) );
1124
+    if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) {
1125
+        wpinv_set_error('invalid_invoice', __('You do not have permission to delete this invoice', 'invoicing'));
1126 1126
 
1127 1127
     // Can it be deleted?
1128
-    } elseif ( ! $invoice->needs_payment() ) {
1129
-        wpinv_set_error( 'cannot_delete', __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ) );
1128
+    } elseif (!$invoice->needs_payment()) {
1129
+        wpinv_set_error('cannot_delete', __('This invoice cannot be deleted as it has already been paid.', 'invoicing'));
1130 1130
 
1131 1131
     // Delete it.
1132 1132
     } else {
1133 1133
 
1134 1134
         $invoice->delete();
1135
-        wpinv_set_error( 'delete', __( 'The invoice has been deleted.', 'invoicing' ), 'info' );
1135
+        wpinv_set_error('delete', __('The invoice has been deleted.', 'invoicing'), 'info');
1136 1136
     }
1137 1137
 
1138
-    $redirect = remove_query_arg( array( 'getpaid-action', 'getpaid-nonce', 'invoice_id' ) );
1138
+    $redirect = remove_query_arg(array('getpaid-action', 'getpaid-nonce', 'invoice_id'));
1139 1139
 
1140
-    wp_safe_redirect( $redirect );
1140
+    wp_safe_redirect($redirect);
1141 1141
     exit;
1142 1142
 
1143 1143
 }
1144
-add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' );
1144
+add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice');
Please login to merge, or discard this patch.