Passed
Push — master ( 82bd21...0587d7 )
by Brian
05:01
created
includes/admin/register-settings.php 2 patches
Indentation   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = wpinv_clean( $option['desc'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = wpinv_clean( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228 228
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229 229
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
230
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
232 232
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233 233
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
246 246
 }
247 247
 
248 248
 /**
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
  */
262 262
 function wpinv_settings_sanitize( $input = array() ) {
263 263
 
264
-	$wpinv_options = wpinv_get_options();
265
-	$raw_referrer  = wp_get_raw_referer();
264
+    $wpinv_options = wpinv_get_options();
265
+    $raw_referrer  = wp_get_raw_referer();
266 266
 
267 267
     if ( empty( $raw_referrer ) ) {
268 268
         return $input;
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 
271 271
     wp_parse_str( $raw_referrer, $referrer );
272 272
 
273
-	if ( empty( $referrer['tab'] ) ) {
273
+    if ( empty( $referrer['tab'] ) ) {
274 274
         return $input;
275
-	}
275
+    }
276 276
 
277 277
     $settings = wpinv_get_registered_settings();
278 278
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
         }
295 295
 
296 296
         // General filter
297
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
297
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
298 298
 
299
-		// Key specific filter.
300
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
299
+        // Key specific filter.
300
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
301 301
     }
302 302
 
303 303
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
 
354 354
     foreach ( $new_rates as $rate ) {
355 355
 
356
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
357
-		$rate['name']    = sanitize_text_field( $rate['name'] );
358
-		$rate['state']   = sanitize_text_field( $rate['state'] );
359
-		$rate['country'] = sanitize_text_field( $rate['country'] );
360
-		$rate['global']  = empty( $rate['state'] );
361
-		$tax_rates[]     = $rate;
356
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
357
+        $rate['name']    = sanitize_text_field( $rate['name'] );
358
+        $rate['state']   = sanitize_text_field( $rate['state'] );
359
+        $rate['country'] = sanitize_text_field( $rate['country'] );
360
+        $rate['global']  = empty( $rate['state'] );
361
+        $tax_rates[]     = $rate;
362 362
 
363
-	}
363
+    }
364 364
 
365 365
     update_option( 'wpinv_tax_rates', $tax_rates );
366 366
 
@@ -378,11 +378,11 @@  discard block
 block discarded – undo
378 378
     $tabs['general']  = __( 'General', 'invoicing' );
379 379
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
380 380
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
381
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
381
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
382 382
 
383
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
384
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
385
-	}
383
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
384
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
385
+    }
386 386
 
387 387
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
388 388
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
         ) ),
421 421
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
422 422
             'main'  => __( 'Tax Settings', 'invoicing' ),
423
-			'rates' => __( 'Tax Rates', 'invoicing' ),
424
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
423
+            'rates' => __( 'Tax Rates', 'invoicing' ),
424
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
425 425
         ) ),
426 426
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
427 427
             'main' => __( 'Email Settings', 'invoicing' ),
428
-		) ),
428
+        ) ),
429 429
 
430
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
430
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
431 431
 
432 432
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
433 433
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -447,51 +447,51 @@  discard block
 block discarded – undo
447 447
 }
448 448
 
449 449
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
450
-	$pages_options = array();
450
+    $pages_options = array();
451 451
 
452
-	if( $default_label !== NULL && $default_label !== false ) {
453
-		$pages_options = array( '' => $default_label ); // Blank option
454
-	}
452
+    if( $default_label !== NULL && $default_label !== false ) {
453
+        $pages_options = array( '' => $default_label ); // Blank option
454
+    }
455 455
 
456
-	$pages = get_pages();
457
-	if ( $pages ) {
458
-		foreach ( $pages as $page ) {
459
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
456
+    $pages = get_pages();
457
+    if ( $pages ) {
458
+        foreach ( $pages as $page ) {
459
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
460 460
             $pages_options[ $page->ID ] = $title;
461
-		}
462
-	}
461
+        }
462
+    }
463 463
 
464
-	return $pages_options;
464
+    return $pages_options;
465 465
 }
466 466
 
467 467
 function wpinv_header_callback( $args ) {
468
-	if ( !empty( $args['desc'] ) ) {
468
+    if ( !empty( $args['desc'] ) ) {
469 469
         echo $args['desc'];
470 470
     }
471 471
 }
472 472
 
473 473
 function wpinv_hidden_callback( $args ) {
474
-	global $wpinv_options;
475
-
476
-	if ( isset( $args['set_value'] ) ) {
477
-		$value = $args['set_value'];
478
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
479
-		$value = $wpinv_options[ $args['id'] ];
480
-	} else {
481
-		$value = isset( $args['std'] ) ? $args['std'] : '';
482
-	}
483
-
484
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
485
-		$args['readonly'] = true;
486
-		$value = isset( $args['std'] ) ? $args['std'] : '';
487
-		$name  = '';
488
-	} else {
489
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
490
-	}
491
-
492
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
474
+    global $wpinv_options;
475
+
476
+    if ( isset( $args['set_value'] ) ) {
477
+        $value = $args['set_value'];
478
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
479
+        $value = $wpinv_options[ $args['id'] ];
480
+    } else {
481
+        $value = isset( $args['std'] ) ? $args['std'] : '';
482
+    }
483
+
484
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
485
+        $args['readonly'] = true;
486
+        $value = isset( $args['std'] ) ? $args['std'] : '';
487
+        $name  = '';
488
+    } else {
489
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
490
+    }
491
+
492
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
493 493
     
494
-	echo $html;
494
+    echo $html;
495 495
 }
496 496
 
497 497
 /**
@@ -499,12 +499,12 @@  discard block
 block discarded – undo
499 499
  */
500 500
 function wpinv_checkbox_callback( $args ) {
501 501
 
502
-	$std = isset( $args['std'] ) ? $args['std'] : '';
503
-	$std = wpinv_get_option( $args['id'], $std );
504
-	$id  = esc_attr( $args['id'] );
502
+    $std = isset( $args['std'] ) ? $args['std'] : '';
503
+    $std = wpinv_get_option( $args['id'], $std );
504
+    $id  = esc_attr( $args['id'] );
505 505
 
506
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
507
-	?>
506
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
507
+    ?>
508 508
 		<fieldset>
509 509
 			<label>
510 510
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -516,77 +516,77 @@  discard block
 block discarded – undo
516 516
 
517 517
 function wpinv_multicheck_callback( $args ) {
518 518
 	
519
-	global $wpinv_options;
519
+    global $wpinv_options;
520 520
 
521
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
522
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
521
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
522
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
523 523
 
524
-	if ( ! empty( $args['options'] ) ) {
524
+    if ( ! empty( $args['options'] ) ) {
525 525
 
526
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
527
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
526
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
527
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
528 528
 
529
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
529
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
530 530
         foreach( $args['options'] as $key => $option ):
531
-			$sanitize_key = wpinv_sanitize_key( $key );
532
-			if ( in_array( $sanitize_key, $value ) ) { 
533
-				$enabled = $sanitize_key;
534
-			} else { 
535
-				$enabled = NULL; 
536
-			}
537
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
538
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
539
-		endforeach;
540
-		echo '</div>';
541
-		echo '<p class="description">' . $args['desc'] . '</p>';
542
-	}
531
+            $sanitize_key = wpinv_sanitize_key( $key );
532
+            if ( in_array( $sanitize_key, $value ) ) { 
533
+                $enabled = $sanitize_key;
534
+            } else { 
535
+                $enabled = NULL; 
536
+            }
537
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
538
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
539
+        endforeach;
540
+        echo '</div>';
541
+        echo '<p class="description">' . $args['desc'] . '</p>';
542
+    }
543 543
 }
544 544
 
545 545
 function wpinv_payment_icons_callback( $args ) {
546
-	global $wpinv_options;
546
+    global $wpinv_options;
547 547
     
548 548
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
549 549
 
550
-	if ( ! empty( $args['options'] ) ) {
551
-		foreach( $args['options'] as $key => $option ) {
550
+    if ( ! empty( $args['options'] ) ) {
551
+        foreach( $args['options'] as $key => $option ) {
552 552
             $sanitize_key = wpinv_sanitize_key( $key );
553 553
             
554
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
555
-				$enabled = $option;
556
-			} else {
557
-				$enabled = NULL;
558
-			}
559
-
560
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
561
-
562
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
563
-
564
-				if ( wpinv_string_is_image_url( $key ) ) {
565
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
566
-				} else {
567
-					$card = strtolower( str_replace( ' ', '', $option ) );
568
-
569
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
570
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
571
-					} else {
572
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
573
-						$content_dir = WP_CONTENT_DIR;
574
-
575
-						if ( function_exists( 'wp_normalize_path' ) ) {
576
-							// Replaces backslashes with forward slashes for Windows systems
577
-							$image = wp_normalize_path( $image );
578
-							$content_dir = wp_normalize_path( $content_dir );
579
-						}
580
-
581
-						$image = str_replace( $content_dir, content_url(), $image );
582
-					}
583
-
584
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
585
-				}
586
-			echo $option . '</label>';
587
-		}
588
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
589
-	}
554
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
555
+                $enabled = $option;
556
+            } else {
557
+                $enabled = NULL;
558
+            }
559
+
560
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
561
+
562
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
563
+
564
+                if ( wpinv_string_is_image_url( $key ) ) {
565
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
566
+                } else {
567
+                    $card = strtolower( str_replace( ' ', '', $option ) );
568
+
569
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
570
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
571
+                    } else {
572
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
573
+                        $content_dir = WP_CONTENT_DIR;
574
+
575
+                        if ( function_exists( 'wp_normalize_path' ) ) {
576
+                            // Replaces backslashes with forward slashes for Windows systems
577
+                            $image = wp_normalize_path( $image );
578
+                            $content_dir = wp_normalize_path( $content_dir );
579
+                        }
580
+
581
+                        $image = str_replace( $content_dir, content_url(), $image );
582
+                    }
583
+
584
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
585
+                }
586
+            echo $option . '</label>';
587
+        }
588
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
589
+    }
590 590
 }
591 591
 
592 592
 /**
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
  */
595 595
 function wpinv_radio_callback( $args ) {
596 596
 
597
-	$std = isset( $args['std'] ) ? $args['std'] : '';
598
-	$std = wpinv_get_option( $args['id'], $std );
599
-	?>
597
+    $std = isset( $args['std'] ) ? $args['std'] : '';
598
+    $std = wpinv_get_option( $args['id'], $std );
599
+    ?>
600 600
 		<fieldset>
601 601
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
602 602
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 			</ul>
611 611
 		</fieldset>
612 612
 	<?php
613
-	getpaid_settings_description_callback( $args );
613
+    getpaid_settings_description_callback( $args );
614 614
 }
615 615
 
616 616
 /**
@@ -618,10 +618,10 @@  discard block
 block discarded – undo
618 618
  */
619 619
 function getpaid_settings_description_callback( $args ) {
620 620
 
621
-	if ( ! empty( $args['desc'] ) ) {
622
-		$description = wp_kses_post( $args['desc'] );
623
-		echo "<p class='description'>$description</p>";
624
-	}
621
+    if ( ! empty( $args['desc'] ) ) {
622
+        $description = wp_kses_post( $args['desc'] );
623
+        echo "<p class='description'>$description</p>";
624
+    }
625 625
 
626 626
 }
627 627
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
  */
631 631
 function wpinv_gateways_callback() {
632 632
 
633
-	?>
633
+    ?>
634 634
 		</td>
635 635
 	</tr>
636 636
 	<tr class="bsui">
@@ -641,24 +641,24 @@  discard block
 block discarded – undo
641 641
 }
642 642
 
643 643
 function wpinv_gateway_select_callback($args) {
644
-	global $wpinv_options;
644
+    global $wpinv_options;
645 645
     
646 646
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
647 647
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
648 648
 
649
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
649
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
650 650
 
651
-	foreach ( $args['options'] as $key => $option ) :
652
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651
+    foreach ( $args['options'] as $key => $option ) :
652
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653 653
             $selected = selected( $key, $args['selected'], false );
654 654
         } else {
655 655
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
656 656
         }
657
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
658
-	endforeach;
657
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
658
+    endforeach;
659 659
 
660
-	echo '</select>';
661
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
660
+    echo '</select>';
661
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
662 662
 }
663 663
 
664 664
 /**
@@ -669,29 +669,29 @@  discard block
 block discarded – undo
669 669
  */
670 670
 function wpinv_settings_attrs_helper( $args ) {
671 671
 
672
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
673
-	$id           = esc_attr( $args['id'] );
674
-	$placeholder  = esc_attr( $args['placeholder'] );
672
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
673
+    $id           = esc_attr( $args['id'] );
674
+    $placeholder  = esc_attr( $args['placeholder'] );
675 675
 
676
-	if ( ! empty( $args['faux'] ) ) {
677
-		$args['readonly'] = true;
678
-		$name             = '';
679
-	} else {
680
-		$value  = wpinv_get_option( $args['id'], $value );
681
-		$name   = "wpinv_settings[$id]";
682
-	}
676
+    if ( ! empty( $args['faux'] ) ) {
677
+        $args['readonly'] = true;
678
+        $name             = '';
679
+    } else {
680
+        $value  = wpinv_get_option( $args['id'], $value );
681
+        $name   = "wpinv_settings[$id]";
682
+    }
683 683
 
684
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
-	$class    = esc_attr( $args['class'] );
686
-	$style    = esc_attr( $args['style'] );
687
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
684
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
+    $class    = esc_attr( $args['class'] );
686
+    $style    = esc_attr( $args['style'] );
687
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
688 688
 
689
-	$onchange = '';
689
+    $onchange = '';
690 690
     if ( ! empty( $args['onchange'] ) ) {
691 691
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
692
-	}
692
+    }
693 693
 
694
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
694
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
695 695
 }
696 696
 
697 697
 /**
@@ -699,11 +699,11 @@  discard block
 block discarded – undo
699 699
  */
700 700
 function wpinv_text_callback( $args ) {
701 701
 
702
-	$desc = wp_kses_post( $args['desc'] );
703
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
-	$attr = wpinv_settings_attrs_helper( $args );
702
+    $desc = wp_kses_post( $args['desc'] );
703
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
+    $attr = wpinv_settings_attrs_helper( $args );
705 705
 
706
-	?>
706
+    ?>
707 707
 		<label style="width: 100%;">
708 708
 			<input type="text" <?php echo $attr; ?>>
709 709
 			<?php echo $desc; ?>
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
  */
718 718
 function wpinv_number_callback( $args ) {
719 719
 
720
-	$desc = wp_kses_post( $args['desc'] );
721
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
-	$attr = wpinv_settings_attrs_helper( $args );
723
-	$max  = intval( $args['max'] );
724
-	$min  = intval( $args['min'] );
725
-	$step = floatval( $args['step'] );
720
+    $desc = wp_kses_post( $args['desc'] );
721
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
+    $attr = wpinv_settings_attrs_helper( $args );
723
+    $max  = intval( $args['max'] );
724
+    $min  = intval( $args['min'] );
725
+    $step = floatval( $args['step'] );
726 726
 
727
-	?>
727
+    ?>
728 728
 		<label style="width: 100%;">
729 729
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
730 730
 			<?php echo $desc; ?>
@@ -734,48 +734,48 @@  discard block
 block discarded – undo
734 734
 }
735 735
 
736 736
 function wpinv_textarea_callback( $args ) {
737
-	global $wpinv_options;
737
+    global $wpinv_options;
738 738
     
739 739
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
740 740
 
741
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
-		$value = $wpinv_options[ $args['id'] ];
743
-	} else {
744
-		$value = isset( $args['std'] ) ? $args['std'] : '';
745
-	}
741
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
+        $value = $wpinv_options[ $args['id'] ];
743
+    } else {
744
+        $value = isset( $args['std'] ) ? $args['std'] : '';
745
+    }
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
-	$html = '<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
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750
+    $html = '<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
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
752 752
 
753
-	echo $html;
753
+    echo $html;
754 754
 }
755 755
 
756 756
 function wpinv_password_callback( $args ) {
757
-	global $wpinv_options;
757
+    global $wpinv_options;
758 758
     
759 759
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
760 760
 
761
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
-		$value = $wpinv_options[ $args['id'] ];
763
-	} else {
764
-		$value = isset( $args['std'] ) ? $args['std'] : '';
765
-	}
761
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
+        $value = $wpinv_options[ $args['id'] ];
763
+    } else {
764
+        $value = isset( $args['std'] ) ? $args['std'] : '';
765
+    }
766 766
 
767
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
-	$html = '<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 ) . '"/>';
769
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
767
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
+    $html = '<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 ) . '"/>';
769
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
770 770
 
771
-	echo $html;
771
+    echo $html;
772 772
 }
773 773
 
774 774
 function wpinv_missing_callback($args) {
775
-	printf(
776
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
777
-		'<strong>' . $args['id'] . '</strong>'
778
-	);
775
+    printf(
776
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
777
+        '<strong>' . $args['id'] . '</strong>'
778
+    );
779 779
 }
780 780
 
781 781
 /**
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
  */
784 784
 function wpinv_select_callback( $args ) {
785 785
 
786
-	$desc   = wp_kses_post( $args['desc'] );
787
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
-	$attr   = wpinv_settings_attrs_helper( $args );
789
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
790
-	$value  = wpinv_get_option( $args['id'], $value );
786
+    $desc   = wp_kses_post( $args['desc'] );
787
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
+    $attr   = wpinv_settings_attrs_helper( $args );
789
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
790
+    $value  = wpinv_get_option( $args['id'], $value );
791 791
 
792
-	?>
792
+    ?>
793 793
 		<label style="width: 100%;">
794 794
 			<select <?php echo $attr; ?>>
795 795
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -803,123 +803,123 @@  discard block
 block discarded – undo
803 803
 }
804 804
 
805 805
 function wpinv_color_select_callback( $args ) {
806
-	global $wpinv_options;
806
+    global $wpinv_options;
807 807
     
808 808
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
809 809
 
810
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
-		$value = $wpinv_options[ $args['id'] ];
812
-	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
814
-	}
810
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
+        $value = $wpinv_options[ $args['id'] ];
812
+    } else {
813
+        $value = isset( $args['std'] ) ? $args['std'] : '';
814
+    }
815 815
 
816
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
816
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
817 817
 
818
-	foreach ( $args['options'] as $option => $color ) {
819
-		$selected = selected( $option, $value, false );
820
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
821
-	}
818
+    foreach ( $args['options'] as $option => $color ) {
819
+        $selected = selected( $option, $value, false );
820
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
821
+    }
822 822
 
823
-	$html .= '</select>';
824
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
823
+    $html .= '</select>';
824
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
825 825
 
826
-	echo $html;
826
+    echo $html;
827 827
 }
828 828
 
829 829
 function wpinv_rich_editor_callback( $args ) {
830
-	global $wpinv_options, $wp_version;
830
+    global $wpinv_options, $wp_version;
831 831
     
832 832
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
833 833
 
834
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
-		$value = $wpinv_options[ $args['id'] ];
834
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
+        $value = $wpinv_options[ $args['id'] ];
836 836
 
837
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
-			$value = isset( $args['std'] ) ? $args['std'] : '';
839
-		}
840
-	} else {
841
-		$value = isset( $args['std'] ) ? $args['std'] : '';
842
-	}
837
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
+            $value = isset( $args['std'] ) ? $args['std'] : '';
839
+        }
840
+    } else {
841
+        $value = isset( $args['std'] ) ? $args['std'] : '';
842
+    }
843 843
 
844
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
844
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
845 845
 
846
-	$html = '<div class="getpaid-settings-editor-input">';
847
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
-		ob_start();
849
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
850
-		$html .= ob_get_clean();
851
-	} else {
852
-		$html .= '<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>';
853
-	}
846
+    $html = '<div class="getpaid-settings-editor-input">';
847
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
848
+        ob_start();
849
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
850
+        $html .= ob_get_clean();
851
+    } else {
852
+        $html .= '<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>';
853
+    }
854 854
 
855
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
855
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
856 856
 
857
-	echo $html;
857
+    echo $html;
858 858
 }
859 859
 
860 860
 function wpinv_upload_callback( $args ) {
861
-	global $wpinv_options;
861
+    global $wpinv_options;
862 862
     
863 863
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
864 864
 
865
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
866
-		$value = $wpinv_options[$args['id']];
867
-	} else {
868
-		$value = isset($args['std']) ? $args['std'] : '';
869
-	}
865
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
866
+        $value = $wpinv_options[$args['id']];
867
+    } else {
868
+        $value = isset($args['std']) ? $args['std'] : '';
869
+    }
870 870
 
871
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
-	$html = '<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 ) ) . '"/>';
873
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
871
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
+    $html = '<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 ) ) . '"/>';
873
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
875 875
 
876
-	echo $html;
876
+    echo $html;
877 877
 }
878 878
 
879 879
 function wpinv_color_callback( $args ) {
880
-	global $wpinv_options;
880
+    global $wpinv_options;
881 881
     
882 882
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
-		$value = $wpinv_options[ $args['id'] ];
886
-	} else {
887
-		$value = isset( $args['std'] ) ? $args['std'] : '';
888
-	}
884
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
+        $value = $wpinv_options[ $args['id'] ];
886
+    } else {
887
+        $value = isset( $args['std'] ) ? $args['std'] : '';
888
+    }
889 889
 
890
-	$default = isset( $args['std'] ) ? $args['std'] : '';
890
+    $default = isset( $args['std'] ) ? $args['std'] : '';
891 891
 
892
-	$html = '<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( $default ) . '" />';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+    $html = '<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( $default ) . '" />';
893
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
894 894
 
895
-	echo $html;
895
+    echo $html;
896 896
 }
897 897
 
898 898
 function wpinv_country_states_callback($args) {
899
-	global $wpinv_options;
899
+    global $wpinv_options;
900 900
     
901 901
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
902 902
 
903
-	if ( isset( $args['placeholder'] ) ) {
904
-		$placeholder = $args['placeholder'];
905
-	} else {
906
-		$placeholder = '';
907
-	}
903
+    if ( isset( $args['placeholder'] ) ) {
904
+        $placeholder = $args['placeholder'];
905
+    } else {
906
+        $placeholder = '';
907
+    }
908 908
 
909
-	$states = wpinv_get_country_states();
909
+    $states = wpinv_get_country_states();
910 910
 
911
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
913 913
 
914
-	foreach ( $states as $option => $name ) {
915
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
917
-	}
914
+    foreach ( $states as $option => $name ) {
915
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
917
+    }
918 918
 
919
-	$html .= '</select>';
920
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
919
+    $html .= '</select>';
920
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
921 921
 
922
-	echo $html;
922
+    echo $html;
923 923
 }
924 924
 
925 925
 /**
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
  */
928 928
 function wpinv_tax_rates_callback() {
929 929
 	
930
-	?>
930
+    ?>
931 931
 		</td>
932 932
 	</tr>
933 933
 	<tr class="bsui">
@@ -942,17 +942,17 @@  discard block
 block discarded – undo
942 942
  * Displays a tax rate' edit row.
943 943
  */
944 944
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
945
-	ob_start();
945
+    ob_start();
946 946
 
947
-	$key                      = sanitize_key( $key );
948
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
947
+    $key                      = sanitize_key( $key );
948
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
950 950
 
951
-	if ( $echo ) {
952
-		echo ob_get_clean();
953
-	} else {
954
-		return ob_get_clean(); 
955
-	}
951
+    if ( $echo ) {
952
+        echo ob_get_clean();
953
+    } else {
954
+        return ob_get_clean(); 
955
+    }
956 956
 
957 957
 }
958 958
 
@@ -980,14 +980,14 @@  discard block
 block discarded – undo
980 980
                 </td>
981 981
                 <td>
982 982
 					<a href="<?php
983
-						echo esc_url(
984
-							wp_nonce_url(
985
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
986
-								'getpaid-nonce',
987
-								'getpaid-nonce'
988
-							)
989
-						);
990
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
983
+                        echo esc_url(
984
+                            wp_nonce_url(
985
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
986
+                                'getpaid-nonce',
987
+                                'getpaid-nonce'
988
+                            )
989
+                        );
990
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
991 991
                 </td>
992 992
             </tr>
993 993
 			<tr>
@@ -997,14 +997,14 @@  discard block
 block discarded – undo
997 997
                 </td>
998 998
                 <td>
999 999
 					<a href="<?php
1000
-						echo esc_url(
1001
-							wp_nonce_url(
1002
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1003
-								'getpaid-nonce',
1004
-								'getpaid-nonce'
1005
-							)
1006
-						);
1007
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1000
+                        echo esc_url(
1001
+                            wp_nonce_url(
1002
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1003
+                                'getpaid-nonce',
1004
+                                'getpaid-nonce'
1005
+                            )
1006
+                        );
1007
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1008 1008
                 </td>
1009 1009
             </tr>
1010 1010
 			<tr>
@@ -1014,14 +1014,14 @@  discard block
 block discarded – undo
1014 1014
                 </td>
1015 1015
                 <td>
1016 1016
 					<a href="<?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
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
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
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1025 1025
                 </td>
1026 1026
             </tr>
1027 1027
 
@@ -1032,14 +1032,14 @@  discard block
 block discarded – undo
1032 1032
                 </td>
1033 1033
                 <td>
1034 1034
 					<a href="<?php
1035
-						echo esc_url(
1036
-							wp_nonce_url(
1037
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1038
-								'getpaid-nonce',
1039
-								'getpaid-nonce'
1040
-							)
1041
-						);
1042
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1035
+                        echo esc_url(
1036
+                            wp_nonce_url(
1037
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1038
+                                'getpaid-nonce',
1039
+                                'getpaid-nonce'
1040
+                            )
1041
+                        );
1042
+                    ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1043 1043
                 </td>
1044 1044
             </tr>
1045 1045
 
@@ -1053,19 +1053,19 @@  discard block
 block discarded – undo
1053 1053
 
1054 1054
 
1055 1055
 function wpinv_descriptive_text_callback( $args ) {
1056
-	echo wp_kses_post( $args['desc'] );
1056
+    echo wp_kses_post( $args['desc'] );
1057 1057
 }
1058 1058
 
1059 1059
 function wpinv_raw_html_callback( $args ) {
1060
-	echo $args['desc'];
1060
+    echo $args['desc'];
1061 1061
 }
1062 1062
 
1063 1063
 function wpinv_hook_callback( $args ) {
1064
-	do_action( 'wpinv_' . $args['id'], $args );
1064
+    do_action( 'wpinv_' . $args['id'], $args );
1065 1065
 }
1066 1066
 
1067 1067
 function wpinv_set_settings_cap() {
1068
-	return wpinv_get_capability();
1068
+    return wpinv_get_capability();
1069 1069
 }
1070 1070
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1071 1071
 
Please login to merge, or discard this patch.
Spacing   +379 added lines, -379 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
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( ! is_array( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (!is_array($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,47 +190,47 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name    = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name    = isset($option['name']) ? $option['name'] : '';
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = wpinv_clean( $option['desc'] );
199
+	if (isset($option['desc']) && !empty($option['help-tip'])) {
200
+		$tip   = wpinv_clean($option['desc']);
201 201
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
202
+		unset($option['desc']);
203 203
 	}
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
207 207
         'wpinv_settings[' . $option['id'] . ']',
208 208
         $name,
209
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
209
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
210 210
         $section,
211 211
         $section,
212 212
         array(
213 213
             'section'     => $section,
214
-            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
215
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
214
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
215
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
216 216
             'name'        => $name,
217
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
218
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
219
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
220
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
221
-            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
222
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
223
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
224
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
225
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
226
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
227
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229
-            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
232
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
217
+            'size'        => isset($option['size']) ? $option['size'] : null,
218
+            'options'     => isset($option['options']) ? $option['options'] : '',
219
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
220
+            'std'         => isset($option['std']) ? $option['std'] : '',
221
+            'min'         => isset($option['min']) ? $option['min'] : 0,
222
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
223
+            'step'        => isset($option['step']) ? $option['step'] : 1,
224
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
225
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
226
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
227
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
228
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
229
+            'custom'      => isset($option['custom']) ? $option['custom'] : '',
230
+			'class'       => isset($option['class']) ? $option['class'] : '',
231
+			'style'       => isset($option['style']) ? $option['style'] : '',
232
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
235 235
     );
236 236
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
246 246
 }
247 247
 
248 248
 /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
  * @return array
252 252
  */
253 253
 function getpaid_get_integration_settings() {
254
-    return apply_filters( 'getpaid_integration_settings', array() );
254
+    return apply_filters('getpaid_integration_settings', array());
255 255
 }
256 256
 
257 257
 /**
@@ -259,144 +259,144 @@  discard block
 block discarded – undo
259 259
  * 
260 260
  * @return array
261 261
  */
262
-function wpinv_settings_sanitize( $input = array() ) {
262
+function wpinv_settings_sanitize($input = array()) {
263 263
 
264 264
 	$wpinv_options = wpinv_get_options();
265 265
 	$raw_referrer  = wp_get_raw_referer();
266 266
 
267
-    if ( empty( $raw_referrer ) ) {
267
+    if (empty($raw_referrer)) {
268 268
         return $input;
269 269
     }
270 270
 
271
-    wp_parse_str( $raw_referrer, $referrer );
271
+    wp_parse_str($raw_referrer, $referrer);
272 272
 
273
-	if ( empty( $referrer['tab'] ) ) {
273
+	if (empty($referrer['tab'])) {
274 274
         return $input;
275 275
 	}
276 276
 
277 277
     $settings = wpinv_get_registered_settings();
278
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
279
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
278
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
279
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
280 280
 
281 281
     $input = $input ? $input : array();
282
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
283
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
282
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
283
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
284 284
 
285 285
     // Loop through each setting being saved and pass it through a sanitization filter
286
-    foreach ( $input as $key => $value ) {
286
+    foreach ($input as $key => $value) {
287 287
 
288 288
         // Get the setting type (checkbox, select, etc)
289
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
289
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
290 290
 
291
-        if ( $type ) {
291
+        if ($type) {
292 292
             // Field type specific filter
293
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
293
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
294 294
         }
295 295
 
296 296
         // General filter
297
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
297
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
298 298
 
299 299
 		// Key specific filter.
300
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
300
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
301 301
     }
302 302
 
303 303
     // Loop through the whitelist and unset any that are empty for the tab being saved
304
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
305
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
304
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
305
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
306 306
 
307
-    $found_settings   = array_merge( $main_settings, $section_settings );
307
+    $found_settings   = array_merge($main_settings, $section_settings);
308 308
 
309
-    if ( ! empty( $found_settings ) ) {
310
-        foreach ( $found_settings as $key => $value ) {
309
+    if (!empty($found_settings)) {
310
+        foreach ($found_settings as $key => $value) {
311 311
 
312 312
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
313
-            if ( is_numeric( $key ) ) {
313
+            if (is_numeric($key)) {
314 314
                 $key = $value['id'];
315 315
             }
316 316
 
317
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
318
-                unset( $wpinv_options[ $key ] );
317
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
318
+                unset($wpinv_options[$key]);
319 319
             }
320 320
         }
321 321
     }
322 322
 
323 323
     // Merge our new settings with the existing
324
-    $output = array_merge( $wpinv_options, $input );
324
+    $output = array_merge($wpinv_options, $input);
325 325
 
326
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
326
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
327 327
 
328 328
     return $output;
329 329
 }
330 330
 
331
-function wpinv_settings_sanitize_misc_accounting( $input ) {
331
+function wpinv_settings_sanitize_misc_accounting($input) {
332 332
 
333
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
333
+    if (!wpinv_current_user_can_manage_invoicing()) {
334 334
         return $input;
335 335
     }
336 336
 
337
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
337
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
338 338
         // Shows an admin notice about upgrading previous order numbers
339
-        getpaid_session()->set( 'upgrade_sequential', '1' );
339
+        getpaid_session()->set('upgrade_sequential', '1');
340 340
     }
341 341
 
342 342
     return $input;
343 343
 }
344
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
344
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
345 345
 
346
-function wpinv_settings_sanitize_tax_rates( $input ) {
347
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
346
+function wpinv_settings_sanitize_tax_rates($input) {
347
+    if (!wpinv_current_user_can_manage_invoicing()) {
348 348
         return $input;
349 349
     }
350 350
 
351
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
351
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
352 352
     $tax_rates = array();
353 353
 
354
-    foreach ( $new_rates as $rate ) {
354
+    foreach ($new_rates as $rate) {
355 355
 
356
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
357
-		$rate['name']    = sanitize_text_field( $rate['name'] );
358
-		$rate['state']   = sanitize_text_field( $rate['state'] );
359
-		$rate['country'] = sanitize_text_field( $rate['country'] );
360
-		$rate['global']  = empty( $rate['state'] );
356
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
357
+		$rate['name']    = sanitize_text_field($rate['name']);
358
+		$rate['state']   = sanitize_text_field($rate['state']);
359
+		$rate['country'] = sanitize_text_field($rate['country']);
360
+		$rate['global']  = empty($rate['state']);
361 361
 		$tax_rates[]     = $rate;
362 362
 
363 363
 	}
364 364
 
365
-    update_option( 'wpinv_tax_rates', $tax_rates );
365
+    update_option('wpinv_tax_rates', $tax_rates);
366 366
 
367 367
     return $input;
368 368
 }
369
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
369
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
370 370
 
371
-function wpinv_sanitize_text_field( $input ) {
372
-    return trim( $input );
371
+function wpinv_sanitize_text_field($input) {
372
+    return trim($input);
373 373
 }
374
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
374
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
375 375
 
376 376
 function wpinv_get_settings_tabs() {
377 377
     $tabs             = array();
378
-    $tabs['general']  = __( 'General', 'invoicing' );
379
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
380
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
381
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
378
+    $tabs['general']  = __('General', 'invoicing');
379
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
380
+    $tabs['taxes']    = __('Taxes', 'invoicing');
381
+	$tabs['emails'] = __('Emails', 'invoicing');
382 382
 
383
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
384
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
383
+	if (count(getpaid_get_integration_settings()) > 0) {
384
+		$tabs['integrations'] = __('Integrations', 'invoicing');
385 385
 	}
386 386
 
387
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
388
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
389
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
387
+    $tabs['privacy']  = __('Privacy', 'invoicing');
388
+    $tabs['misc']     = __('Misc', 'invoicing');
389
+    $tabs['tools']    = __('Tools', 'invoicing');
390 390
 
391
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
391
+    return apply_filters('wpinv_settings_tabs', $tabs);
392 392
 }
393 393
 
394
-function wpinv_get_settings_tab_sections( $tab = false ) {
394
+function wpinv_get_settings_tab_sections($tab = false) {
395 395
     $tabs     = false;
396 396
     $sections = wpinv_get_registered_settings_sections();
397 397
 
398
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
399
-        $tabs = $sections[ $tab ];
398
+    if ($tab && !empty($sections[$tab])) {
399
+        $tabs = $sections[$tab];
400 400
     }
401 401
 
402 402
     return $tabs;
@@ -405,91 +405,91 @@  discard block
 block discarded – undo
405 405
 function wpinv_get_registered_settings_sections() {
406 406
     static $sections = false;
407 407
 
408
-    if ( false !== $sections ) {
408
+    if (false !== $sections) {
409 409
         return $sections;
410 410
     }
411 411
 
412 412
     $sections = array(
413
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
414
-            'main' => __( 'General Settings', 'invoicing' ),
415
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
416
-            'labels' => __( 'Label Texts', 'invoicing' ),
417
-        ) ),
418
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
419
-            'main' => __( 'Gateway Settings', 'invoicing' ),
420
-        ) ),
421
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
422
-            'main'  => __( 'Tax Settings', 'invoicing' ),
423
-			'rates' => __( 'Tax Rates', 'invoicing' ),
424
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
425
-        ) ),
426
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
427
-            'main' => __( 'Email Settings', 'invoicing' ),
428
-		) ),
429
-
430
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
431
-
432
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
433
-            'main' => __( 'Privacy policy', 'invoicing' ),
434
-        ) ),
435
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
436
-            'main' => __( 'Miscellaneous', 'invoicing' ),
437
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
438
-        ) ),
439
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
440
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
441
-        ) ),
413
+        'general' => apply_filters('wpinv_settings_sections_general', array(
414
+            'main' => __('General Settings', 'invoicing'),
415
+            'currency_section' => __('Currency Settings', 'invoicing'),
416
+            'labels' => __('Label Texts', 'invoicing'),
417
+        )),
418
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
419
+            'main' => __('Gateway Settings', 'invoicing'),
420
+        )),
421
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
422
+            'main'  => __('Tax Settings', 'invoicing'),
423
+			'rates' => __('Tax Rates', 'invoicing'),
424
+			'vat'   => __('EU VAT Settings', 'invoicing')
425
+        )),
426
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
427
+            'main' => __('Email Settings', 'invoicing'),
428
+		)),
429
+
430
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
431
+
432
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
433
+            'main' => __('Privacy policy', 'invoicing'),
434
+        )),
435
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
436
+            'main' => __('Miscellaneous', 'invoicing'),
437
+            'custom-css' => __('Custom CSS', 'invoicing'),
438
+        )),
439
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
440
+            'main' => __('Diagnostic Tools', 'invoicing'),
441
+        )),
442 442
     );
443 443
 
444
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
444
+    $sections = apply_filters('wpinv_settings_sections', $sections);
445 445
 
446 446
     return $sections;
447 447
 }
448 448
 
449
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
449
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
450 450
 	$pages_options = array();
451 451
 
452
-	if( $default_label !== NULL && $default_label !== false ) {
453
-		$pages_options = array( '' => $default_label ); // Blank option
452
+	if ($default_label !== NULL && $default_label !== false) {
453
+		$pages_options = array('' => $default_label); // Blank option
454 454
 	}
455 455
 
456 456
 	$pages = get_pages();
457
-	if ( $pages ) {
458
-		foreach ( $pages as $page ) {
457
+	if ($pages) {
458
+		foreach ($pages as $page) {
459 459
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
460
-            $pages_options[ $page->ID ] = $title;
460
+            $pages_options[$page->ID] = $title;
461 461
 		}
462 462
 	}
463 463
 
464 464
 	return $pages_options;
465 465
 }
466 466
 
467
-function wpinv_header_callback( $args ) {
468
-	if ( !empty( $args['desc'] ) ) {
467
+function wpinv_header_callback($args) {
468
+	if (!empty($args['desc'])) {
469 469
         echo $args['desc'];
470 470
     }
471 471
 }
472 472
 
473
-function wpinv_hidden_callback( $args ) {
473
+function wpinv_hidden_callback($args) {
474 474
 	global $wpinv_options;
475 475
 
476
-	if ( isset( $args['set_value'] ) ) {
476
+	if (isset($args['set_value'])) {
477 477
 		$value = $args['set_value'];
478
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
479
-		$value = $wpinv_options[ $args['id'] ];
478
+	} elseif (isset($wpinv_options[$args['id']])) {
479
+		$value = $wpinv_options[$args['id']];
480 480
 	} else {
481
-		$value = isset( $args['std'] ) ? $args['std'] : '';
481
+		$value = isset($args['std']) ? $args['std'] : '';
482 482
 	}
483 483
 
484
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
484
+	if (isset($args['faux']) && true === $args['faux']) {
485 485
 		$args['readonly'] = true;
486
-		$value = isset( $args['std'] ) ? $args['std'] : '';
486
+		$value = isset($args['std']) ? $args['std'] : '';
487 487
 		$name  = '';
488 488
 	} else {
489
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
489
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
490 490
 	}
491 491
 
492
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
492
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
493 493
     
494 494
 	echo $html;
495 495
 }
@@ -497,61 +497,61 @@  discard block
 block discarded – undo
497 497
 /**
498 498
  * Displays a checkbox settings callback.
499 499
  */
500
-function wpinv_checkbox_callback( $args ) {
500
+function wpinv_checkbox_callback($args) {
501 501
 
502
-	$std = isset( $args['std'] ) ? $args['std'] : '';
503
-	$std = wpinv_get_option( $args['id'], $std );
504
-	$id  = esc_attr( $args['id'] );
502
+	$std = isset($args['std']) ? $args['std'] : '';
503
+	$std = wpinv_get_option($args['id'], $std);
504
+	$id  = esc_attr($args['id']);
505 505
 
506
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
506
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
507 507
 	?>
508 508
 		<fieldset>
509 509
 			<label>
510
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
511
-				<?php echo wp_kses_post( $args['desc'] ); ?>
510
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
511
+				<?php echo wp_kses_post($args['desc']); ?>
512 512
 			</label>
513 513
 		</fieldset>
514 514
 	<?php
515 515
 }
516 516
 
517
-function wpinv_multicheck_callback( $args ) {
517
+function wpinv_multicheck_callback($args) {
518 518
 	
519 519
 	global $wpinv_options;
520 520
 
521
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
522
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
521
+	$sanitize_id = wpinv_sanitize_key($args['id']);
522
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
523 523
 
524
-	if ( ! empty( $args['options'] ) ) {
524
+	if (!empty($args['options'])) {
525 525
 
526
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
527
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
526
+		$std     = isset($args['std']) ? $args['std'] : array();
527
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
528 528
 
529 529
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
530
-        foreach( $args['options'] as $key => $option ):
531
-			$sanitize_key = wpinv_sanitize_key( $key );
532
-			if ( in_array( $sanitize_key, $value ) ) { 
530
+        foreach ($args['options'] as $key => $option):
531
+			$sanitize_key = wpinv_sanitize_key($key);
532
+			if (in_array($sanitize_key, $value)) { 
533 533
 				$enabled = $sanitize_key;
534 534
 			} else { 
535 535
 				$enabled = NULL; 
536 536
 			}
537
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
538
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
537
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
538
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
539 539
 		endforeach;
540 540
 		echo '</div>';
541 541
 		echo '<p class="description">' . $args['desc'] . '</p>';
542 542
 	}
543 543
 }
544 544
 
545
-function wpinv_payment_icons_callback( $args ) {
545
+function wpinv_payment_icons_callback($args) {
546 546
 	global $wpinv_options;
547 547
     
548
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
548
+    $sanitize_id = wpinv_sanitize_key($args['id']);
549 549
 
550
-	if ( ! empty( $args['options'] ) ) {
551
-		foreach( $args['options'] as $key => $option ) {
552
-            $sanitize_key = wpinv_sanitize_key( $key );
550
+	if (!empty($args['options'])) {
551
+		foreach ($args['options'] as $key => $option) {
552
+            $sanitize_key = wpinv_sanitize_key($key);
553 553
             
554
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
554
+			if (isset($wpinv_options[$args['id']][$key])) {
555 555
 				$enabled = $option;
556 556
 			} else {
557 557
 				$enabled = NULL;
@@ -559,67 +559,67 @@  discard block
 block discarded – undo
559 559
 
560 560
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
561 561
 
562
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
562
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
563 563
 
564
-				if ( wpinv_string_is_image_url( $key ) ) {
565
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
564
+				if (wpinv_string_is_image_url($key)) {
565
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
566 566
 				} else {
567
-					$card = strtolower( str_replace( ' ', '', $option ) );
567
+					$card = strtolower(str_replace(' ', '', $option));
568 568
 
569
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
570
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
569
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
570
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
571 571
 					} else {
572
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
572
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
573 573
 						$content_dir = WP_CONTENT_DIR;
574 574
 
575
-						if ( function_exists( 'wp_normalize_path' ) ) {
575
+						if (function_exists('wp_normalize_path')) {
576 576
 							// Replaces backslashes with forward slashes for Windows systems
577
-							$image = wp_normalize_path( $image );
578
-							$content_dir = wp_normalize_path( $content_dir );
577
+							$image = wp_normalize_path($image);
578
+							$content_dir = wp_normalize_path($content_dir);
579 579
 						}
580 580
 
581
-						$image = str_replace( $content_dir, content_url(), $image );
581
+						$image = str_replace($content_dir, content_url(), $image);
582 582
 					}
583 583
 
584
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
584
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
585 585
 				}
586 586
 			echo $option . '</label>';
587 587
 		}
588
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
588
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
589 589
 	}
590 590
 }
591 591
 
592 592
 /**
593 593
  * Displays a radio settings field.
594 594
  */
595
-function wpinv_radio_callback( $args ) {
595
+function wpinv_radio_callback($args) {
596 596
 
597
-	$std = isset( $args['std'] ) ? $args['std'] : '';
598
-	$std = wpinv_get_option( $args['id'], $std );
597
+	$std = isset($args['std']) ? $args['std'] : '';
598
+	$std = wpinv_get_option($args['id'], $std);
599 599
 	?>
600 600
 		<fieldset>
601
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
602
-				<?php foreach( $args['options'] as $key => $option ) : ?>
601
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
602
+				<?php foreach ($args['options'] as $key => $option) : ?>
603 603
 					<li>
604 604
 						<label>
605
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
606
-							<?php echo wp_kses_post( $option ); ?>
605
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
606
+							<?php echo wp_kses_post($option); ?>
607 607
 						</label>
608 608
 					</li>
609 609
 				<?php endforeach; ?>
610 610
 			</ul>
611 611
 		</fieldset>
612 612
 	<?php
613
-	getpaid_settings_description_callback( $args );
613
+	getpaid_settings_description_callback($args);
614 614
 }
615 615
 
616 616
 /**
617 617
  * Displays a description if available.
618 618
  */
619
-function getpaid_settings_description_callback( $args ) {
619
+function getpaid_settings_description_callback($args) {
620 620
 
621
-	if ( ! empty( $args['desc'] ) ) {
622
-		$description = wp_kses_post( $args['desc'] );
621
+	if (!empty($args['desc'])) {
622
+		$description = wp_kses_post($args['desc']);
623 623
 		echo "<p class='description'>$description</p>";
624 624
 	}
625 625
 
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	</tr>
636 636
 	<tr class="bsui">
637 637
     	<td colspan="2" class="p-0">
638
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
638
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
639 639
 
640 640
 	<?php
641 641
 }
@@ -643,22 +643,22 @@  discard block
 block discarded – undo
643 643
 function wpinv_gateway_select_callback($args) {
644 644
 	global $wpinv_options;
645 645
     
646
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
647
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
646
+    $sanitize_id = wpinv_sanitize_key($args['id']);
647
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
648 648
 
649
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
649
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
650 650
 
651
-	foreach ( $args['options'] as $key => $option ) :
652
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
653
-            $selected = selected( $key, $args['selected'], false );
651
+	foreach ($args['options'] as $key => $option) :
652
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
653
+            $selected = selected($key, $args['selected'], false);
654 654
         } else {
655
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
655
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
656 656
         }
657
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
657
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
658 658
 	endforeach;
659 659
 
660 660
 	echo '</select>';
661
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
661
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
662 662
 }
663 663
 
664 664
 /**
@@ -667,28 +667,28 @@  discard block
 block discarded – undo
667 667
  * @param array $args
668 668
  * @return string
669 669
  */
670
-function wpinv_settings_attrs_helper( $args ) {
670
+function wpinv_settings_attrs_helper($args) {
671 671
 
672
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
673
-	$id           = esc_attr( $args['id'] );
674
-	$placeholder  = esc_attr( $args['placeholder'] );
672
+	$value        = isset($args['std']) ? $args['std'] : '';
673
+	$id           = esc_attr($args['id']);
674
+	$placeholder  = esc_attr($args['placeholder']);
675 675
 
676
-	if ( ! empty( $args['faux'] ) ) {
676
+	if (!empty($args['faux'])) {
677 677
 		$args['readonly'] = true;
678 678
 		$name             = '';
679 679
 	} else {
680
-		$value  = wpinv_get_option( $args['id'], $value );
680
+		$value  = wpinv_get_option($args['id'], $value);
681 681
 		$name   = "wpinv_settings[$id]";
682 682
 	}
683 683
 
684
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
685
-	$class    = esc_attr( $args['class'] );
686
-	$style    = esc_attr( $args['style'] );
687
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
684
+	$value    = is_scalar($value) ? esc_attr($value) : '';
685
+	$class    = esc_attr($args['class']);
686
+	$style    = esc_attr($args['style']);
687
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
688 688
 
689 689
 	$onchange = '';
690
-    if ( ! empty( $args['onchange'] ) ) {
691
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
690
+    if (!empty($args['onchange'])) {
691
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
692 692
 	}
693 693
 
694 694
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 /**
698 698
  * Displays a text input settings callback.
699 699
  */
700
-function wpinv_text_callback( $args ) {
700
+function wpinv_text_callback($args) {
701 701
 
702
-	$desc = wp_kses_post( $args['desc'] );
703
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
704
-	$attr = wpinv_settings_attrs_helper( $args );
702
+	$desc = wp_kses_post($args['desc']);
703
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
704
+	$attr = wpinv_settings_attrs_helper($args);
705 705
 
706 706
 	?>
707 707
 		<label style="width: 100%;">
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 /**
716 716
  * Displays a number input settings callback.
717 717
  */
718
-function wpinv_number_callback( $args ) {
718
+function wpinv_number_callback($args) {
719 719
 
720
-	$desc = wp_kses_post( $args['desc'] );
721
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
722
-	$attr = wpinv_settings_attrs_helper( $args );
723
-	$max  = intval( $args['max'] );
724
-	$min  = intval( $args['min'] );
725
-	$step = floatval( $args['step'] );
720
+	$desc = wp_kses_post($args['desc']);
721
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
722
+	$attr = wpinv_settings_attrs_helper($args);
723
+	$max  = intval($args['max']);
724
+	$min  = intval($args['min']);
725
+	$step = floatval($args['step']);
726 726
 
727 727
 	?>
728 728
 		<label style="width: 100%;">
@@ -733,47 +733,47 @@  discard block
 block discarded – undo
733 733
 
734 734
 }
735 735
 
736
-function wpinv_textarea_callback( $args ) {
736
+function wpinv_textarea_callback($args) {
737 737
 	global $wpinv_options;
738 738
     
739
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
739
+    $sanitize_id = wpinv_sanitize_key($args['id']);
740 740
 
741
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
742
-		$value = $wpinv_options[ $args['id'] ];
741
+	if (isset($wpinv_options[$args['id']])) {
742
+		$value = $wpinv_options[$args['id']];
743 743
 	} else {
744
-		$value = isset( $args['std'] ) ? $args['std'] : '';
744
+		$value = isset($args['std']) ? $args['std'] : '';
745 745
 	}
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
-	$html = '<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
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750
+	$html = '<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
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
752 752
 
753 753
 	echo $html;
754 754
 }
755 755
 
756
-function wpinv_password_callback( $args ) {
756
+function wpinv_password_callback($args) {
757 757
 	global $wpinv_options;
758 758
     
759
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
759
+    $sanitize_id = wpinv_sanitize_key($args['id']);
760 760
 
761
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
762
-		$value = $wpinv_options[ $args['id'] ];
761
+	if (isset($wpinv_options[$args['id']])) {
762
+		$value = $wpinv_options[$args['id']];
763 763
 	} else {
764
-		$value = isset( $args['std'] ) ? $args['std'] : '';
764
+		$value = isset($args['std']) ? $args['std'] : '';
765 765
 	}
766 766
 
767
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
768
-	$html = '<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 ) . '"/>';
769
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
767
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
768
+	$html = '<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) . '"/>';
769
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
770 770
 
771 771
 	echo $html;
772 772
 }
773 773
 
774 774
 function wpinv_missing_callback($args) {
775 775
 	printf(
776
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
776
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
777 777
 		'<strong>' . $args['id'] . '</strong>'
778 778
 	);
779 779
 }
@@ -781,20 +781,20 @@  discard block
 block discarded – undo
781 781
 /**
782 782
  * Displays a number input settings callback.
783 783
  */
784
-function wpinv_select_callback( $args ) {
784
+function wpinv_select_callback($args) {
785 785
 
786
-	$desc   = wp_kses_post( $args['desc'] );
787
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
788
-	$attr   = wpinv_settings_attrs_helper( $args );
789
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
790
-	$value  = wpinv_get_option( $args['id'], $value );
786
+	$desc   = wp_kses_post($args['desc']);
787
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
788
+	$attr   = wpinv_settings_attrs_helper($args);
789
+	$value  = isset($args['std']) ? $args['std'] : '';
790
+	$value  = wpinv_get_option($args['id'], $value);
791 791
 
792 792
 	?>
793 793
 		<label style="width: 100%;">
794 794
 			<select <?php echo $attr; ?>>
795
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
796
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( is_array( $value ) ? in_array( "$option", $value, true ) : "$option" === $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
797
-				<?php endforeach;?>
795
+				<?php foreach ($args['options'] as $option => $name) : ?>
796
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected(is_array($value) ? in_array("$option", $value, true) : "$option" === $value); ?>><?php echo wpinv_clean($name); ?></option>
797
+				<?php endforeach; ?>
798 798
 			</select>
799 799
 			<?php echo $desc; ?>
800 800
 		</label>
@@ -802,95 +802,95 @@  discard block
 block discarded – undo
802 802
 
803 803
 }
804 804
 
805
-function wpinv_color_select_callback( $args ) {
805
+function wpinv_color_select_callback($args) {
806 806
 	global $wpinv_options;
807 807
     
808
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
808
+    $sanitize_id = wpinv_sanitize_key($args['id']);
809 809
 
810
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
811
-		$value = $wpinv_options[ $args['id'] ];
810
+	if (isset($wpinv_options[$args['id']])) {
811
+		$value = $wpinv_options[$args['id']];
812 812
 	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
813
+		$value = isset($args['std']) ? $args['std'] : '';
814 814
 	}
815 815
 
816
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
816
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
817 817
 
818
-	foreach ( $args['options'] as $option => $color ) {
819
-		$selected = selected( $option, $value, false );
820
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
818
+	foreach ($args['options'] as $option => $color) {
819
+		$selected = selected($option, $value, false);
820
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
821 821
 	}
822 822
 
823 823
 	$html .= '</select>';
824
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
824
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
825 825
 
826 826
 	echo $html;
827 827
 }
828 828
 
829
-function wpinv_rich_editor_callback( $args ) {
829
+function wpinv_rich_editor_callback($args) {
830 830
 	global $wpinv_options, $wp_version;
831 831
     
832
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
832
+    $sanitize_id = wpinv_sanitize_key($args['id']);
833 833
 
834
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
835
-		$value = $wpinv_options[ $args['id'] ];
834
+	if (isset($wpinv_options[$args['id']])) {
835
+		$value = $wpinv_options[$args['id']];
836 836
 
837
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
838
-			$value = isset( $args['std'] ) ? $args['std'] : '';
837
+		if (empty($args['allow_blank']) && empty($value)) {
838
+			$value = isset($args['std']) ? $args['std'] : '';
839 839
 		}
840 840
 	} else {
841
-		$value = isset( $args['std'] ) ? $args['std'] : '';
841
+		$value = isset($args['std']) ? $args['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
 	$html = '<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
 		ob_start();
849
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
849
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
850 850
 		$html .= ob_get_clean();
851 851
 	} else {
852
-		$html .= '<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>';
852
+		$html .= '<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>';
853 853
 	}
854 854
 
855
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
855
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
856 856
 
857 857
 	echo $html;
858 858
 }
859 859
 
860
-function wpinv_upload_callback( $args ) {
860
+function wpinv_upload_callback($args) {
861 861
 	global $wpinv_options;
862 862
     
863
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
863
+    $sanitize_id = wpinv_sanitize_key($args['id']);
864 864
 
865
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
865
+	if (isset($wpinv_options[$args['id']])) {
866 866
 		$value = $wpinv_options[$args['id']];
867 867
 	} else {
868 868
 		$value = isset($args['std']) ? $args['std'] : '';
869 869
 	}
870 870
 
871
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
872
-	$html = '<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 ) ) . '"/>';
873
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
874
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
871
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
872
+	$html = '<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)) . '"/>';
873
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
874
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
875 875
 
876 876
 	echo $html;
877 877
 }
878 878
 
879
-function wpinv_color_callback( $args ) {
879
+function wpinv_color_callback($args) {
880 880
 	global $wpinv_options;
881 881
     
882
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
882
+    $sanitize_id = wpinv_sanitize_key($args['id']);
883 883
 
884
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
885
-		$value = $wpinv_options[ $args['id'] ];
884
+	if (isset($wpinv_options[$args['id']])) {
885
+		$value = $wpinv_options[$args['id']];
886 886
 	} else {
887
-		$value = isset( $args['std'] ) ? $args['std'] : '';
887
+		$value = isset($args['std']) ? $args['std'] : '';
888 888
 	}
889 889
 
890
-	$default = isset( $args['std'] ) ? $args['std'] : '';
890
+	$default = isset($args['std']) ? $args['std'] : '';
891 891
 
892
-	$html = '<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( $default ) . '" />';
893
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+	$html = '<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($default) . '" />';
893
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
894 894
 
895 895
 	echo $html;
896 896
 }
@@ -898,9 +898,9 @@  discard block
 block discarded – undo
898 898
 function wpinv_country_states_callback($args) {
899 899
 	global $wpinv_options;
900 900
     
901
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
901
+    $sanitize_id = wpinv_sanitize_key($args['id']);
902 902
 
903
-	if ( isset( $args['placeholder'] ) ) {
903
+	if (isset($args['placeholder'])) {
904 904
 		$placeholder = $args['placeholder'];
905 905
 	} else {
906 906
 		$placeholder = '';
@@ -908,16 +908,16 @@  discard block
 block discarded – undo
908 908
 
909 909
 	$states = wpinv_get_country_states();
910 910
 
911
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
912
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
913 913
 
914
-	foreach ( $states as $option => $name ) {
915
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
916
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
914
+	foreach ($states as $option => $name) {
915
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
916
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
917 917
 	}
918 918
 
919 919
 	$html .= '</select>';
920
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
920
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
921 921
 
922 922
 	echo $html;
923 923
 }
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 	</tr>
933 933
 	<tr class="bsui">
934 934
     	<td colspan="2" class="p-0">
935
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
935
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
936 936
 
937 937
 	<?php
938 938
 
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
 /**
942 942
  * Displays a tax rate' edit row.
943 943
  */
944
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
944
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
945 945
 	ob_start();
946 946
 
947
-	$key                      = sanitize_key( $key );
948
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
949
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
947
+	$key                      = sanitize_key($key);
948
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
949
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
950 950
 
951
-	if ( $echo ) {
951
+	if ($echo) {
952 952
 		echo ob_get_clean();
953 953
 	} else {
954 954
 		return ob_get_clean(); 
@@ -961,153 +961,153 @@  discard block
 block discarded – undo
961 961
     ob_start(); ?>
962 962
     </td><tr>
963 963
     <td colspan="2" class="wpinv_tools_tdbox">
964
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
965
-    <?php do_action( 'wpinv_tools_before' ); ?>
964
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
965
+    <?php do_action('wpinv_tools_before'); ?>
966 966
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
967 967
         <thead>
968 968
             <tr>
969
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
970
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
971
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
969
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
970
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
971
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
972 972
             </tr>
973 973
         </thead>
974 974
 
975 975
         <tbody>
976 976
 			<tr>
977
-                <td><?php _e( 'Check Pages', 'invoicing' );?></td>
977
+                <td><?php _e('Check Pages', 'invoicing'); ?></td>
978 978
                 <td>
979
-                    <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
979
+                    <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
980 980
                 </td>
981 981
                 <td>
982 982
 					<a href="<?php
983 983
 						echo esc_url(
984 984
 							wp_nonce_url(
985
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
985
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
986 986
 								'getpaid-nonce',
987 987
 								'getpaid-nonce'
988 988
 							)
989 989
 						);
990
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
990
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
991 991
                 </td>
992 992
             </tr>
993 993
 			<tr>
994
-                <td><?php _e( 'Create Database Tables', 'invoicing' );?></td>
994
+                <td><?php _e('Create Database Tables', 'invoicing'); ?></td>
995 995
                 <td>
996
-                    <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
996
+                    <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
997 997
                 </td>
998 998
                 <td>
999 999
 					<a href="<?php
1000 1000
 						echo esc_url(
1001 1001
 							wp_nonce_url(
1002
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1002
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
1003 1003
 								'getpaid-nonce',
1004 1004
 								'getpaid-nonce'
1005 1005
 							)
1006 1006
 						);
1007
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1007
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1008 1008
                 </td>
1009 1009
             </tr>
1010 1010
 			<tr>
1011
-                <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td>
1011
+                <td><?php _e('Migrate old invoices', 'invoicing'); ?></td>
1012 1012
                 <td>
1013
-                    <small><?php _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
+                    <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
1014 1014
                 </td>
1015 1015
                 <td>
1016 1016
 					<a href="<?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
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
1024
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1025 1025
                 </td>
1026 1026
             </tr>
1027 1027
 
1028 1028
 			<tr>
1029
-                <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td>
1029
+                <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td>
1030 1030
                 <td>
1031
-                    <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1031
+                    <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1032 1032
                 </td>
1033 1033
                 <td>
1034 1034
 					<a href="<?php
1035 1035
 						echo esc_url(
1036 1036
 							wp_nonce_url(
1037
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1037
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1038 1038
 								'getpaid-nonce',
1039 1039
 								'getpaid-nonce'
1040 1040
 							)
1041 1041
 						);
1042
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1042
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1043 1043
                 </td>
1044 1044
             </tr>
1045 1045
 
1046
-			<?php do_action( 'wpinv_tools_row' ); ?>
1046
+			<?php do_action('wpinv_tools_row'); ?>
1047 1047
         </tbody>
1048 1048
     </table>
1049
-    <?php do_action( 'wpinv_tools_after' ); ?>
1049
+    <?php do_action('wpinv_tools_after'); ?>
1050 1050
     <?php
1051 1051
     echo ob_get_clean();
1052 1052
 }
1053 1053
 
1054 1054
 
1055
-function wpinv_descriptive_text_callback( $args ) {
1056
-	echo wp_kses_post( $args['desc'] );
1055
+function wpinv_descriptive_text_callback($args) {
1056
+	echo wp_kses_post($args['desc']);
1057 1057
 }
1058 1058
 
1059
-function wpinv_raw_html_callback( $args ) {
1059
+function wpinv_raw_html_callback($args) {
1060 1060
 	echo $args['desc'];
1061 1061
 }
1062 1062
 
1063
-function wpinv_hook_callback( $args ) {
1064
-	do_action( 'wpinv_' . $args['id'], $args );
1063
+function wpinv_hook_callback($args) {
1064
+	do_action('wpinv_' . $args['id'], $args);
1065 1065
 }
1066 1066
 
1067 1067
 function wpinv_set_settings_cap() {
1068 1068
 	return wpinv_get_capability();
1069 1069
 }
1070
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1070
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1071 1071
 
1072
-function wpinv_settings_sanitize_input( $value, $key ) {
1072
+function wpinv_settings_sanitize_input($value, $key) {
1073 1073
 
1074
-    if ( $key == 'tax_rate' ) {
1075
-        $value = wpinv_sanitize_amount( $value );
1074
+    if ($key == 'tax_rate') {
1075
+        $value = wpinv_sanitize_amount($value);
1076 1076
         $value = $value >= 100 ? 99 : $value;
1077 1077
     }
1078 1078
 
1079 1079
     return $value;
1080 1080
 }
1081
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1081
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1082 1082
 
1083
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1084
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1085
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1083
+function wpinv_on_update_settings($old_value, $value, $option) {
1084
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1085
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1086 1086
     
1087
-    if ( $old != $new ) {
1088
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1087
+    if ($old != $new) {
1088
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1089 1089
     }
1090 1090
 }
1091
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1092
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1093
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1094
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1095
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1096
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1097
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1098
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1099
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1100
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1101
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1102
-
1103
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1091
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1092
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1093
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1094
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1095
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1096
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1097
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1098
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1099
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1100
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1101
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1102
+
1103
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1104 1104
     ?>
1105 1105
     <div class="wpinv-email-wc-row ">
1106 1106
         <div class="wpinv-email-wc-td">
1107
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1107
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1108 1108
             <p class="wpinv-email-wc-description">
1109 1109
                 <?php
1110
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1110
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1111 1111
                     <strong>{site_title} :</strong> Site Title<br>
1112 1112
                     <strong>{name} :</strong> Customer\'s full name<br>
1113 1113
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1122 1122
                     <strong>{date} :</strong> Today\'s date.<br>
1123 1123
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1124
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1124
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1125 1125
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1126 1126
                 ?>
1127 1127
             </p>
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +415 added lines, -415 removed lines patch added patch discarded remove patch
@@ -14,77 +14,77 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66 66
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
71
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
72
-		do_action( 'getpaid_init_admin_hooks', $this );
67
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
71
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
72
+        do_action( 'getpaid_init_admin_hooks', $this );
73 73
 
74 74
     }
75 75
 
76 76
     /**
77
-	 * Register admin scripts
78
-	 *
79
-	 */
80
-	public function enqeue_scripts() {
77
+     * Register admin scripts
78
+     *
79
+     */
80
+    public function enqeue_scripts() {
81 81
         global $current_screen, $pagenow;
82 82
 
83
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
84
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
83
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
84
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
85 85
 
86 86
         if ( ! empty( $current_screen->post_type ) ) {
87
-			$page = $current_screen->post_type;
87
+            $page = $current_screen->post_type;
88 88
         }
89 89
 
90 90
         // General styles.
@@ -105,54 +105,54 @@  discard block
 block discarded – undo
105 105
         }
106 106
 
107 107
         // Payment form scripts.
108
-		if ( 'wpi_payment_form' == $page && $editing ) {
108
+        if ( 'wpi_payment_form' == $page && $editing ) {
109 109
             $this->load_payment_form_scripts();
110 110
         }
111 111
 
112
-		if ( $page == 'wpinv-subscriptions' ) {
113
-			wp_enqueue_script( 'postbox' );
114
-		}
112
+        if ( $page == 'wpinv-subscriptions' ) {
113
+            wp_enqueue_script( 'postbox' );
114
+        }
115 115
 
116 116
     }
117 117
 
118 118
     /**
119
-	 * Returns admin js translations.
120
-	 *
121
-	 */
122
-	protected function get_admin_i18() {
119
+     * Returns admin js translations.
120
+     *
121
+     */
122
+    protected function get_admin_i18() {
123 123
         global $post;
124 124
 
125
-		$date_range = array(
126
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
127
-		);
125
+        $date_range = array(
126
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
127
+        );
128 128
 
129
-		if ( $date_range['period'] == 'custom' ) {
129
+        if ( $date_range['period'] == 'custom' ) {
130 130
 			
131
-			if ( isset( $_GET['from'] ) ) {
132
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
133
-			}
131
+            if ( isset( $_GET['from'] ) ) {
132
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
133
+            }
134 134
 
135
-			if ( isset( $_GET['to'] ) ) {
136
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
137
-			}
135
+            if ( isset( $_GET['to'] ) ) {
136
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
137
+            }
138 138
 
139
-		}
139
+        }
140 140
 
141 141
         $i18n = array(
142 142
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
143 143
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
144
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
145
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
146
-			'rest_root'                 => esc_url_raw( rest_url() ),
147
-			'date_range'                => $date_range,
144
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
145
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
146
+            'rest_root'                 => esc_url_raw( rest_url() ),
147
+            'date_range'                => $date_range,
148 148
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
149 149
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
150 150
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
151 151
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
152 152
             'tax'                       => wpinv_tax_amount(),
153 153
             'discount'                  => 0,
154
-			'currency_symbol'           => wpinv_currency_symbol(),
155
-			'currency'                  => wpinv_get_currency(),
154
+            'currency_symbol'           => wpinv_currency_symbol(),
155
+            'currency'                  => wpinv_get_currency(),
156 156
             'currency_pos'              => wpinv_currency_position(),
157 157
             'thousand_sep'              => wpinv_thousands_separator(),
158 158
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -172,116 +172,116 @@  discard block
 block discarded – undo
172 172
             'item_description'          => __( 'Item Description', 'invoicing' ),
173 173
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
174 174
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
175
-			'searching'                 => __( 'Searching', 'invoicing' ),
176
-			'loading'                   => __( 'Loading...', 'invoicing' ),
175
+            'searching'                 => __( 'Searching', 'invoicing' ),
176
+            'loading'                   => __( 'Loading...', 'invoicing' ),
177 177
         );
178 178
 
179
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
179
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
180 180
 
181
-			$invoice              = new WPInv_Invoice( $post );
182
-			$i18n['save_invoice'] = sprintf(
183
-				__( 'Save %s', 'invoicing' ),
184
-				ucfirst( $invoice->get_invoice_quote_type() )
185
-			);
181
+            $invoice              = new WPInv_Invoice( $post );
182
+            $i18n['save_invoice'] = sprintf(
183
+                __( 'Save %s', 'invoicing' ),
184
+                ucfirst( $invoice->get_invoice_quote_type() )
185
+            );
186 186
 
187
-			$i18n['invoice_description'] = sprintf(
188
-				__( '%s Description', 'invoicing' ),
189
-				ucfirst( $invoice->get_invoice_quote_type() )
190
-			);
187
+            $i18n['invoice_description'] = sprintf(
188
+                __( '%s Description', 'invoicing' ),
189
+                ucfirst( $invoice->get_invoice_quote_type() )
190
+            );
191 191
 
192
-		}
193
-		return $i18n;
194
-	}
192
+        }
193
+        return $i18n;
194
+    }
195 195
 
196
-	/**
197
-	 * Change the admin footer text on GetPaid admin pages.
198
-	 *
199
-	 * @since  2.0.0
200
-	 * @param  string $footer_text
201
-	 * @return string
202
-	 */
203
-	public function admin_footer_text( $footer_text ) {
204
-		global $current_screen;
196
+    /**
197
+     * Change the admin footer text on GetPaid admin pages.
198
+     *
199
+     * @since  2.0.0
200
+     * @param  string $footer_text
201
+     * @return string
202
+     */
203
+    public function admin_footer_text( $footer_text ) {
204
+        global $current_screen;
205 205
 
206
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
206
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
207 207
 
208 208
         if ( ! empty( $current_screen->post_type ) ) {
209
-			$page = $current_screen->post_type;
209
+            $page = $current_screen->post_type;
210 210
         }
211 211
 
212 212
         // General styles.
213 213
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
214 214
 
215
-			// Change the footer text
216
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
217
-
218
-				$rating_url  = esc_url(
219
-					wp_nonce_url(
220
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
221
-						'getpaid-nonce',
222
-						'getpaid-nonce'
223
-						)
224
-				);
225
-
226
-				$footer_text = sprintf(
227
-					/* translators: %s: five stars */
228
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
229
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
230
-				);
231
-
232
-			} else {
233
-
234
-				$footer_text = sprintf(
235
-					/* translators: %s: GetPaid */
236
-					__( 'Thank you for using %s!', 'invoicing' ),
237
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
238
-				);
239
-
240
-			}
241
-
242
-		}
243
-
244
-		return $footer_text;
245
-	}
246
-
247
-	/**
248
-	 * Redirects to wp.org to rate the plugin.
249
-	 *
250
-	 * @since  2.0.0
251
-	 */
252
-	public function redirect_to_wordpress_rating_page() {
253
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
254
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
255
-		exit;
256
-	}
215
+            // Change the footer text
216
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
217
+
218
+                $rating_url  = esc_url(
219
+                    wp_nonce_url(
220
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
221
+                        'getpaid-nonce',
222
+                        'getpaid-nonce'
223
+                        )
224
+                );
225
+
226
+                $footer_text = sprintf(
227
+                    /* translators: %s: five stars */
228
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
229
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
230
+                );
231
+
232
+            } else {
233
+
234
+                $footer_text = sprintf(
235
+                    /* translators: %s: GetPaid */
236
+                    __( 'Thank you for using %s!', 'invoicing' ),
237
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
238
+                );
239
+
240
+            }
241
+
242
+        }
243
+
244
+        return $footer_text;
245
+    }
257 246
 
258 247
     /**
259
-	 * Loads payment form js.
260
-	 *
261
-	 */
262
-	protected function load_payment_form_scripts() {
248
+     * Redirects to wp.org to rate the plugin.
249
+     *
250
+     * @since  2.0.0
251
+     */
252
+    public function redirect_to_wordpress_rating_page() {
253
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
254
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
255
+        exit;
256
+    }
257
+
258
+    /**
259
+     * Loads payment form js.
260
+     *
261
+     */
262
+    protected function load_payment_form_scripts() {
263 263
         global $post;
264 264
 
265 265
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
266
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
267
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
266
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
267
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
268 268
 
269
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
270
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
269
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
270
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
271 271
 
272
-		wp_localize_script(
272
+        wp_localize_script(
273 273
             'wpinv-admin-payment-form-script',
274 274
             'wpinvPaymentFormAdmin',
275 275
             array(
276
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
277
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
278
-				'currency'      => wpinv_currency_symbol(),
279
-				'position'      => wpinv_currency_position(),
280
-				'decimals'      => (int) wpinv_decimals(),
281
-				'thousands_sep' => wpinv_thousands_separator(),
282
-				'decimals_sep'  => wpinv_decimal_separator(),
283
-				'form_items'    => gepaid_get_form_items( $post->ID ),
284
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
276
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
277
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
278
+                'currency'      => wpinv_currency_symbol(),
279
+                'position'      => wpinv_currency_position(),
280
+                'decimals'      => (int) wpinv_decimals(),
281
+                'thousands_sep' => wpinv_thousands_separator(),
282
+                'decimals_sep'  => wpinv_decimal_separator(),
283
+                'form_items'    => gepaid_get_form_items( $post->ID ),
284
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
285 285
             )
286 286
         );
287 287
 
@@ -290,20 +290,20 @@  discard block
 block discarded – undo
290 290
     }
291 291
 
292 292
     /**
293
-	 * Add our classes to admin pages.
293
+     * Add our classes to admin pages.
294 294
      *
295 295
      * @param string $classes
296 296
      * @return string
297
-	 *
298
-	 */
297
+     *
298
+     */
299 299
     public function admin_body_class( $classes ) {
300
-		global $pagenow, $post, $current_screen;
300
+        global $pagenow, $post, $current_screen;
301 301
 
302 302
 
303 303
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
304 304
 
305 305
         if ( ! empty( $current_screen->post_type ) ) {
306
-			$page = $current_screen->post_type;
306
+            $page = $current_screen->post_type;
307 307
         }
308 308
 
309 309
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -312,59 +312,59 @@  discard block
 block discarded – undo
312 312
 
313 313
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
314 314
             $classes .= ' wpinv-cpt wpinv';
315
-		}
315
+        }
316 316
 		
317
-		if ( getpaid_is_invoice_post_type( $page ) ) {
317
+        if ( getpaid_is_invoice_post_type( $page ) ) {
318 318
             $classes .= ' getpaid-is-invoice-cpt';
319 319
         }
320 320
 
321
-		return $classes;
321
+        return $classes;
322 322
     }
323 323
 
324 324
     /**
325
-	 * Maybe show the AyeCode Connect Notice.
326
-	 */
327
-	public function init_ayecode_connect_helper(){
325
+     * Maybe show the AyeCode Connect Notice.
326
+     */
327
+    public function init_ayecode_connect_helper(){
328 328
 
329 329
         new AyeCode_Connect_Helper(
330 330
             array(
331
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
332
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
333
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
334
-				'connect_button'    => __("Connect Site","invoicing"),
335
-				'connecting_button'    => __("Connecting...","invoicing"),
336
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
337
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
331
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
332
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
333
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
334
+                'connect_button'    => __("Connect Site","invoicing"),
335
+                'connecting_button'    => __("Connecting...","invoicing"),
336
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
337
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
338 338
             ),
339 339
             array( 'wpi-addons' )
340 340
         );
341 341
 
342 342
     }
343 343
 
344
-	/**
345
-	 * Redirect users to settings on activation.
346
-	 *
347
-	 * @return void
348
-	 */
349
-	public function activation_redirect() {
344
+    /**
345
+     * Redirect users to settings on activation.
346
+     *
347
+     * @return void
348
+     */
349
+    public function activation_redirect() {
350 350
 
351
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
351
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
352 352
 
353
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
354
-			return;
355
-		}
353
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
354
+            return;
355
+        }
356 356
 
357
-		// Bail if activating from network, or bulk
358
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
359
-			return;
360
-		}
357
+        // Bail if activating from network, or bulk
358
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
359
+            return;
360
+        }
361 361
 
362
-	    update_option( 'wpinv_redirected_to_settings', 1 );
362
+        update_option( 'wpinv_redirected_to_settings', 1 );
363 363
 
364 364
         wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
365 365
         exit;
366 366
 
367
-	}
367
+    }
368 368
 
369 369
     /**
370 370
      * Fires an admin action after verifying that a user can fire them.
@@ -378,304 +378,304 @@  discard block
 block discarded – undo
378 378
 
379 379
     }
380 380
 
381
-	/**
381
+    /**
382 382
      * Sends a payment reminder to a customer.
383
-	 * 
384
-	 * @param array $args
383
+     * 
384
+     * @param array $args
385 385
      */
386 386
     public function send_customer_invoice( $args ) {
387
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
387
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
388 388
 
389
-		if ( $sent ) {
390
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
391
-		} else {
392
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
393
-		}
389
+        if ( $sent ) {
390
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
391
+        } else {
392
+            $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
393
+        }
394 394
 
395
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
396
-		exit;
397
-	}
395
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
396
+        exit;
397
+    }
398 398
 
399
-	/**
399
+    /**
400 400
      * Sends a payment reminder to a customer.
401
-	 * 
402
-	 * @param array $args
401
+     * 
402
+     * @param array $args
403 403
      */
404 404
     public function send_customer_payment_reminder( $args ) {
405
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
405
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
406 406
 
407
-		if ( $sent ) {
408
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
409
-		} else {
410
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
411
-		}
407
+        if ( $sent ) {
408
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
409
+        } else {
410
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
411
+        }
412 412
 
413
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
414
-		exit;
415
-	}
413
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
414
+        exit;
415
+    }
416 416
 
417
-	/**
417
+    /**
418 418
      * Resets tax rates.
419
-	 * 
419
+     * 
420 420
      */
421 421
     public function admin_reset_tax_rates() {
422 422
 
423
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
424
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
425
-		exit;
423
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
424
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
425
+        exit;
426 426
 
427
-	}
427
+    }
428 428
 
429
-	/**
429
+    /**
430 430
      * Resets admin pages.
431
-	 * 
431
+     * 
432 432
      */
433 433
     public function admin_create_missing_pages() {
434
-		$installer = new GetPaid_Installer();
435
-		$installer->create_pages();
436
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
437
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
438
-		exit;
439
-	}
440
-
441
-	/**
434
+        $installer = new GetPaid_Installer();
435
+        $installer->create_pages();
436
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
437
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
438
+        exit;
439
+    }
440
+
441
+    /**
442 442
      * Creates an missing admin tables.
443
-	 * 
443
+     * 
444 444
      */
445 445
     public function admin_create_missing_tables() {
446
-		global $wpdb;
447
-		$installer = new GetPaid_Installer();
446
+        global $wpdb;
447
+        $installer = new GetPaid_Installer();
448 448
 
449
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
450
-			$installer->create_subscriptions_table();
449
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
450
+            $installer->create_subscriptions_table();
451 451
 
452
-			if ( $wpdb->last_error !== '' ) {
453
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
454
-			}
455
-		}
452
+            if ( $wpdb->last_error !== '' ) {
453
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
454
+            }
455
+        }
456 456
 
457
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
458
-			$installer->create_invoices_table();
457
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
458
+            $installer->create_invoices_table();
459 459
 
460
-			if ( $wpdb->last_error !== '' ) {
461
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
462
-			}
463
-		}
460
+            if ( $wpdb->last_error !== '' ) {
461
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
462
+            }
463
+        }
464 464
 
465
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
466
-			$installer->create_invoice_items_table();
465
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
466
+            $installer->create_invoice_items_table();
467 467
 
468
-			if ( $wpdb->last_error !== '' ) {
469
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
470
-			}
471
-		}
468
+            if ( $wpdb->last_error !== '' ) {
469
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
470
+            }
471
+        }
472 472
 
473
-		if ( ! $this->has_notices() ) {
474
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
475
-		}
473
+        if ( ! $this->has_notices() ) {
474
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
475
+        }
476 476
 
477
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
478
-		exit;
479
-	}
477
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
478
+        exit;
479
+    }
480 480
 
481
-	/**
481
+    /**
482 482
      * Migrates old invoices to the new database tables.
483
-	 * 
483
+     * 
484 484
      */
485 485
     public function admin_migrate_old_invoices() {
486 486
 
487
-		// Migrate the invoices.
488
-		$installer = new GetPaid_Installer();
489
-		$installer->migrate_old_invoices();
487
+        // Migrate the invoices.
488
+        $installer = new GetPaid_Installer();
489
+        $installer->migrate_old_invoices();
490 490
 
491
-		// Show an admin message.
492
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
491
+        // Show an admin message.
492
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
493 493
 
494
-		// Redirect the admin.
495
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
496
-		exit;
494
+        // Redirect the admin.
495
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
496
+        exit;
497 497
 
498
-	}
498
+    }
499 499
 
500
-	/**
500
+    /**
501 501
      * Recalculates discounts.
502
-	 * 
502
+     * 
503 503
      */
504 504
     public function admin_recalculate_discounts() {
505
-		global $wpdb;
505
+        global $wpdb;
506 506
 
507
-		// Fetch all invoices that have discount codes.
508
-		$table    = $wpdb->prefix . 'getpaid_invoices';
509
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
507
+        // Fetch all invoices that have discount codes.
508
+        $table    = $wpdb->prefix . 'getpaid_invoices';
509
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
510 510
 
511
-		foreach ( $invoices as $invoice ) {
511
+        foreach ( $invoices as $invoice ) {
512 512
 
513
-			$invoice = new WPInv_Invoice( $invoice );
513
+            $invoice = new WPInv_Invoice( $invoice );
514 514
 
515
-			if ( ! $invoice->exists() ) {
516
-				continue;
517
-			}
515
+            if ( ! $invoice->exists() ) {
516
+                continue;
517
+            }
518 518
 
519
-			// Abort if the discount does not exist or does not apply here.
520
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
521
-			if ( ! $discount->exists() ) {
522
-				continue;
523
-			}
519
+            // Abort if the discount does not exist or does not apply here.
520
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
521
+            if ( ! $discount->exists() ) {
522
+                continue;
523
+            }
524 524
 
525
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
526
-			$invoice->recalculate_total();
525
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
526
+            $invoice->recalculate_total();
527 527
 
528
-			if ( $invoice->get_total_discount() > 0 ) {
529
-				$invoice->save();
530
-			}
528
+            if ( $invoice->get_total_discount() > 0 ) {
529
+                $invoice->save();
530
+            }
531 531
 
532
-		}
532
+        }
533 533
 
534
-		// Show an admin message.
535
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
534
+        // Show an admin message.
535
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
536 536
 
537
-		// Redirect the admin.
538
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
539
-		exit;
537
+        // Redirect the admin.
538
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
539
+        exit;
540 540
 
541
-	}
541
+    }
542 542
 
543 543
     /**
544
-	 * Returns an array of admin notices.
545
-	 *
546
-	 * @since       1.0.19
544
+     * Returns an array of admin notices.
545
+     *
546
+     * @since       1.0.19
547 547
      * @return array
548
-	 */
549
-	public function get_notices() {
550
-		$notices = get_option( 'wpinv_admin_notices' );
548
+     */
549
+    public function get_notices() {
550
+        $notices = get_option( 'wpinv_admin_notices' );
551 551
         return is_array( $notices ) ? $notices : array();
552
-	}
552
+    }
553 553
 
554
-	/**
555
-	 * Checks if we have any admin notices.
556
-	 *
557
-	 * @since       2.0.4
554
+    /**
555
+     * Checks if we have any admin notices.
556
+     *
557
+     * @since       2.0.4
558 558
      * @return array
559
-	 */
560
-	public function has_notices() {
561
-		return count( $this->get_notices() ) > 0;
562
-	}
563
-
564
-	/**
565
-	 * Clears all admin notices
566
-	 *
567
-	 * @access      public
568
-	 * @since       1.0.19
569
-	 */
570
-	public function clear_notices() {
571
-		delete_option( 'wpinv_admin_notices' );
572
-	}
573
-
574
-	/**
575
-	 * Saves a new admin notice
576
-	 *
577
-	 * @access      public
578
-	 * @since       1.0.19
579
-	 */
580
-	public function save_notice( $type, $message ) {
581
-		$notices = $this->get_notices();
582
-
583
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
584
-			$notices[ $type ] = array();
585
-		}
586
-
587
-		$notices[ $type ][] = $message;
588
-
589
-		update_option( 'wpinv_admin_notices', $notices );
590
-	}
591
-
592
-	/**
593
-	 * Displays a success notice
594
-	 *
595
-	 * @param       string $msg The message to qeue.
596
-	 * @access      public
597
-	 * @since       1.0.19
598
-	 */
599
-	public function show_success( $msg ) {
600
-		$this->save_notice( 'success', $msg );
601
-	}
602
-
603
-	/**
604
-	 * Displays a error notice
605
-	 *
606
-	 * @access      public
607
-	 * @param       string $msg The message to qeue.
608
-	 * @since       1.0.19
609
-	 */
610
-	public function show_error( $msg ) {
611
-		$this->save_notice( 'error', $msg );
612
-	}
613
-
614
-	/**
615
-	 * Displays a warning notice
616
-	 *
617
-	 * @access      public
618
-	 * @param       string $msg The message to qeue.
619
-	 * @since       1.0.19
620
-	 */
621
-	public function show_warning( $msg ) {
622
-		$this->save_notice( 'warning', $msg );
623
-	}
624
-
625
-	/**
626
-	 * Displays a info notice
627
-	 *
628
-	 * @access      public
629
-	 * @param       string $msg The message to qeue.
630
-	 * @since       1.0.19
631
-	 */
632
-	public function show_info( $msg ) {
633
-		$this->save_notice( 'info', $msg );
634
-	}
635
-
636
-	/**
637
-	 * Show notices
638
-	 *
639
-	 * @access      public
640
-	 * @since       1.0.19
641
-	 */
642
-	public function show_notices() {
559
+     */
560
+    public function has_notices() {
561
+        return count( $this->get_notices() ) > 0;
562
+    }
563
+
564
+    /**
565
+     * Clears all admin notices
566
+     *
567
+     * @access      public
568
+     * @since       1.0.19
569
+     */
570
+    public function clear_notices() {
571
+        delete_option( 'wpinv_admin_notices' );
572
+    }
573
+
574
+    /**
575
+     * Saves a new admin notice
576
+     *
577
+     * @access      public
578
+     * @since       1.0.19
579
+     */
580
+    public function save_notice( $type, $message ) {
581
+        $notices = $this->get_notices();
582
+
583
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
584
+            $notices[ $type ] = array();
585
+        }
586
+
587
+        $notices[ $type ][] = $message;
588
+
589
+        update_option( 'wpinv_admin_notices', $notices );
590
+    }
591
+
592
+    /**
593
+     * Displays a success notice
594
+     *
595
+     * @param       string $msg The message to qeue.
596
+     * @access      public
597
+     * @since       1.0.19
598
+     */
599
+    public function show_success( $msg ) {
600
+        $this->save_notice( 'success', $msg );
601
+    }
602
+
603
+    /**
604
+     * Displays a error notice
605
+     *
606
+     * @access      public
607
+     * @param       string $msg The message to qeue.
608
+     * @since       1.0.19
609
+     */
610
+    public function show_error( $msg ) {
611
+        $this->save_notice( 'error', $msg );
612
+    }
613
+
614
+    /**
615
+     * Displays a warning notice
616
+     *
617
+     * @access      public
618
+     * @param       string $msg The message to qeue.
619
+     * @since       1.0.19
620
+     */
621
+    public function show_warning( $msg ) {
622
+        $this->save_notice( 'warning', $msg );
623
+    }
624
+
625
+    /**
626
+     * Displays a info notice
627
+     *
628
+     * @access      public
629
+     * @param       string $msg The message to qeue.
630
+     * @since       1.0.19
631
+     */
632
+    public function show_info( $msg ) {
633
+        $this->save_notice( 'info', $msg );
634
+    }
635
+
636
+    /**
637
+     * Show notices
638
+     *
639
+     * @access      public
640
+     * @since       1.0.19
641
+     */
642
+    public function show_notices() {
643 643
 
644 644
         $notices = $this->get_notices();
645 645
         $this->clear_notices();
646 646
 
647
-		foreach ( $notices as $type => $messages ) {
647
+        foreach ( $notices as $type => $messages ) {
648 648
 
649
-			if ( ! is_array( $messages ) ) {
650
-				continue;
651
-			}
649
+            if ( ! is_array( $messages ) ) {
650
+                continue;
651
+            }
652 652
 
653 653
             $type  = sanitize_key( $type );
654
-			foreach ( $messages as $message ) {
654
+            foreach ( $messages as $message ) {
655 655
                 $message = wp_kses_post( $message );
656
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
656
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
657
+            }
658
+
659
+        }
660
+
661
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
662
+
663
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
664
+                $url     = esc_url(
665
+                    wp_nonce_url(
666
+                        add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
667
+                        'getpaid-nonce',
668
+                        'getpaid-nonce'
669
+                    )
670
+                );
671
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
672
+                $message2 = __( 'Generate Pages', 'invoicing' );
673
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
674
+                break;
657 675
             }
658 676
 
659 677
         }
660 678
 
661
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
662
-
663
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
664
-				$url     = esc_url(
665
-					wp_nonce_url(
666
-						add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
667
-						'getpaid-nonce',
668
-						'getpaid-nonce'
669
-					)
670
-				);
671
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
672
-				$message2 = __( 'Generate Pages', 'invoicing' );
673
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
674
-				break;
675
-			}
676
-
677
-		}
678
-
679
-	}
679
+    }
680 680
 
681 681
 }
Please login to merge, or discard this patch.
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  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
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,22 +54,22 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
71
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
72
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
65
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
66
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
67
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
68
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
69
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
70
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
71
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
72
+		do_action('getpaid_init_admin_hooks', $this);
73 73
 
74 74
     }
75 75
 
@@ -80,37 +80,37 @@  discard block
 block discarded – undo
80 80
 	public function enqeue_scripts() {
81 81
         global $current_screen, $pagenow;
82 82
 
83
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
83
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
84 84
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
85 85
 
86
-        if ( ! empty( $current_screen->post_type ) ) {
86
+        if (!empty($current_screen->post_type)) {
87 87
 			$page = $current_screen->post_type;
88 88
         }
89 89
 
90 90
         // General styles.
91
-        if ( false !== stripos( $page, 'wpi' ) ) {
91
+        if (false !== stripos($page, 'wpi')) {
92 92
 
93 93
             // Styles.
94
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
95
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
96
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
94
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
95
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
96
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
97 97
 
98 98
             // Scripts.
99
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
99
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
100 100
 
101
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
102
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker' ),  $version );
103
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
101
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
102
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker'), $version);
103
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
104 104
 
105 105
         }
106 106
 
107 107
         // Payment form scripts.
108
-		if ( 'wpi_payment_form' == $page && $editing ) {
108
+		if ('wpi_payment_form' == $page && $editing) {
109 109
             $this->load_payment_form_scripts();
110 110
         }
111 111
 
112
-		if ( $page == 'wpinv-subscriptions' ) {
113
-			wp_enqueue_script( 'postbox' );
112
+		if ($page == 'wpinv-subscriptions') {
113
+			wp_enqueue_script('postbox');
114 114
 		}
115 115
 
116 116
     }
@@ -123,32 +123,32 @@  discard block
 block discarded – undo
123 123
         global $post;
124 124
 
125 125
 		$date_range = array(
126
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
126
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
127 127
 		);
128 128
 
129
-		if ( $date_range['period'] == 'custom' ) {
129
+		if ($date_range['period'] == 'custom') {
130 130
 			
131
-			if ( isset( $_GET['from'] ) ) {
132
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
131
+			if (isset($_GET['from'])) {
132
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
133 133
 			}
134 134
 
135
-			if ( isset( $_GET['to'] ) ) {
136
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
135
+			if (isset($_GET['to'])) {
136
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
137 137
 			}
138 138
 
139 139
 		}
140 140
 
141 141
         $i18n = array(
142
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
143
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
144
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
145
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
146
-			'rest_root'                 => esc_url_raw( rest_url() ),
142
+            'ajax_url'                  => admin_url('admin-ajax.php'),
143
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
144
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
145
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
146
+			'rest_root'                 => esc_url_raw(rest_url()),
147 147
 			'date_range'                => $date_range,
148
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
149
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
150
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
151
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
148
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
149
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
150
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
151
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
152 152
             'tax'                       => wpinv_tax_amount(),
153 153
             'discount'                  => 0,
154 154
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -157,36 +157,36 @@  discard block
 block discarded – undo
157 157
             'thousand_sep'              => wpinv_thousands_separator(),
158 158
             'decimal_sep'               => wpinv_decimal_separator(),
159 159
             'decimals'                  => wpinv_decimals(),
160
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
161
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
162
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
163
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
164
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
165
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
166
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
167
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
168
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
169
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
170
-            'action_edit'               => __( 'Edit', 'invoicing' ),
171
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
172
-            'item_description'          => __( 'Item Description', 'invoicing' ),
173
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
174
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
175
-			'searching'                 => __( 'Searching', 'invoicing' ),
176
-			'loading'                   => __( 'Loading...', 'invoicing' ),
160
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
161
+            'status_publish'            => wpinv_status_nicename('publish'),
162
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
163
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
164
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
165
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
166
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
167
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
168
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
169
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
170
+            'action_edit'               => __('Edit', 'invoicing'),
171
+            'action_cancel'             => __('Cancel', 'invoicing'),
172
+            'item_description'          => __('Item Description', 'invoicing'),
173
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
174
+            'discount_description'      => __('Discount Description', 'invoicing'),
175
+			'searching'                 => __('Searching', 'invoicing'),
176
+			'loading'                   => __('Loading...', 'invoicing'),
177 177
         );
178 178
 
179
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
179
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
180 180
 
181
-			$invoice              = new WPInv_Invoice( $post );
181
+			$invoice              = new WPInv_Invoice($post);
182 182
 			$i18n['save_invoice'] = sprintf(
183
-				__( 'Save %s', 'invoicing' ),
184
-				ucfirst( $invoice->get_invoice_quote_type() )
183
+				__('Save %s', 'invoicing'),
184
+				ucfirst($invoice->get_invoice_quote_type())
185 185
 			);
186 186
 
187 187
 			$i18n['invoice_description'] = sprintf(
188
-				__( '%s Description', 'invoicing' ),
189
-				ucfirst( $invoice->get_invoice_quote_type() )
188
+				__('%s Description', 'invoicing'),
189
+				ucfirst($invoice->get_invoice_quote_type())
190 190
 			);
191 191
 
192 192
 		}
@@ -200,24 +200,24 @@  discard block
 block discarded – undo
200 200
 	 * @param  string $footer_text
201 201
 	 * @return string
202 202
 	 */
203
-	public function admin_footer_text( $footer_text ) {
203
+	public function admin_footer_text($footer_text) {
204 204
 		global $current_screen;
205 205
 
206
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
206
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
207 207
 
208
-        if ( ! empty( $current_screen->post_type ) ) {
208
+        if (!empty($current_screen->post_type)) {
209 209
 			$page = $current_screen->post_type;
210 210
         }
211 211
 
212 212
         // General styles.
213
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
213
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
214 214
 
215 215
 			// Change the footer text
216
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
216
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
217 217
 
218
-				$rating_url  = esc_url(
218
+				$rating_url = esc_url(
219 219
 					wp_nonce_url(
220
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
220
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
221 221
 						'getpaid-nonce',
222 222
 						'getpaid-nonce'
223 223
 						)
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 				$footer_text = sprintf(
227 227
 					/* translators: %s: five stars */
228
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
228
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
229 229
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
230 230
 				);
231 231
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 				$footer_text = sprintf(
235 235
 					/* translators: %s: GetPaid */
236
-					__( 'Thank you for using %s!', 'invoicing' ),
236
+					__('Thank you for using %s!', 'invoicing'),
237 237
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
238 238
 				);
239 239
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
 	 * @since  2.0.0
251 251
 	 */
252 252
 	public function redirect_to_wordpress_rating_page() {
253
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
254
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
253
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
254
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
255 255
 		exit;
256 256
 	}
257 257
 
@@ -262,30 +262,30 @@  discard block
 block discarded – undo
262 262
 	protected function load_payment_form_scripts() {
263 263
         global $post;
264 264
 
265
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
266
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
267
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
265
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
266
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
267
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
268 268
 
269
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
270
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
269
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
270
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
271 271
 
272 272
 		wp_localize_script(
273 273
             'wpinv-admin-payment-form-script',
274 274
             'wpinvPaymentFormAdmin',
275 275
             array(
276
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
277
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
276
+				'elements'      => wpinv_get_data('payment-form-elements'),
277
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
278 278
 				'currency'      => wpinv_currency_symbol(),
279 279
 				'position'      => wpinv_currency_position(),
280 280
 				'decimals'      => (int) wpinv_decimals(),
281 281
 				'thousands_sep' => wpinv_thousands_separator(),
282 282
 				'decimals_sep'  => wpinv_decimal_separator(),
283
-				'form_items'    => gepaid_get_form_items( $post->ID ),
283
+				'form_items'    => gepaid_get_form_items($post->ID),
284 284
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
285 285
             )
286 286
         );
287 287
 
288
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
288
+        wp_enqueue_script('wpinv-admin-payment-form-script');
289 289
 
290 290
     }
291 291
 
@@ -296,25 +296,25 @@  discard block
 block discarded – undo
296 296
      * @return string
297 297
 	 *
298 298
 	 */
299
-    public function admin_body_class( $classes ) {
299
+    public function admin_body_class($classes) {
300 300
 		global $pagenow, $post, $current_screen;
301 301
 
302 302
 
303
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
303
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
304 304
 
305
-        if ( ! empty( $current_screen->post_type ) ) {
305
+        if (!empty($current_screen->post_type)) {
306 306
 			$page = $current_screen->post_type;
307 307
         }
308 308
 
309
-        if ( false !== stripos( $page, 'wpi' ) ) {
310
-            $classes .= ' wpi-' . sanitize_key( $page );
309
+        if (false !== stripos($page, 'wpi')) {
310
+            $classes .= ' wpi-' . sanitize_key($page);
311 311
         }
312 312
 
313
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
313
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
314 314
             $classes .= ' wpinv-cpt wpinv';
315 315
 		}
316 316
 		
317
-		if ( getpaid_is_invoice_post_type( $page ) ) {
317
+		if (getpaid_is_invoice_post_type($page)) {
318 318
             $classes .= ' getpaid-is-invoice-cpt';
319 319
         }
320 320
 
@@ -324,19 +324,19 @@  discard block
 block discarded – undo
324 324
     /**
325 325
 	 * Maybe show the AyeCode Connect Notice.
326 326
 	 */
327
-	public function init_ayecode_connect_helper(){
327
+	public function init_ayecode_connect_helper() {
328 328
 
329 329
         new AyeCode_Connect_Helper(
330 330
             array(
331
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
332
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
333
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
334
-				'connect_button'    => __("Connect Site","invoicing"),
335
-				'connecting_button'    => __("Connecting...","invoicing"),
336
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
337
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
331
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
332
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
333
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
334
+				'connect_button'    => __("Connect Site", "invoicing"),
335
+				'connecting_button'    => __("Connecting...", "invoicing"),
336
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
337
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
338 338
             ),
339
-            array( 'wpi-addons' )
339
+            array('wpi-addons')
340 340
         );
341 341
 
342 342
     }
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
 	 */
349 349
 	public function activation_redirect() {
350 350
 
351
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
351
+		$redirected = get_option('wpinv_redirected_to_settings');
352 352
 
353
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
353
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
354 354
 			return;
355 355
 		}
356 356
 
357 357
 		// Bail if activating from network, or bulk
358
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
358
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
359 359
 			return;
360 360
 		}
361 361
 
362
-	    update_option( 'wpinv_redirected_to_settings', 1 );
362
+	    update_option('wpinv_redirected_to_settings', 1);
363 363
 
364
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
364
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
365 365
         exit;
366 366
 
367 367
 	}
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
      */
372 372
     public function maybe_do_admin_action() {
373 373
 
374
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
375
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
376
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
374
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
375
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
376
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
377 377
         }
378 378
 
379 379
     }
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 	 * 
384 384
 	 * @param array $args
385 385
      */
386
-    public function send_customer_invoice( $args ) {
387
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
386
+    public function send_customer_invoice($args) {
387
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
388 388
 
389
-		if ( $sent ) {
390
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
389
+		if ($sent) {
390
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
391 391
 		} else {
392
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
392
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
393 393
 		}
394 394
 
395
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
395
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
396 396
 		exit;
397 397
 	}
398 398
 
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 	 * 
402 402
 	 * @param array $args
403 403
      */
404
-    public function send_customer_payment_reminder( $args ) {
405
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
404
+    public function send_customer_payment_reminder($args) {
405
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
406 406
 
407
-		if ( $sent ) {
408
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
407
+		if ($sent) {
408
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
409 409
 		} else {
410
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
410
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
411 411
 		}
412 412
 
413
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
413
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
414 414
 		exit;
415 415
 	}
416 416
 
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
      */
421 421
     public function admin_reset_tax_rates() {
422 422
 
423
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
424
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
423
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
424
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
425 425
 		exit;
426 426
 
427 427
 	}
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
     public function admin_create_missing_pages() {
434 434
 		$installer = new GetPaid_Installer();
435 435
 		$installer->create_pages();
436
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
437
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
436
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
437
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
438 438
 		exit;
439 439
 	}
440 440
 
@@ -446,35 +446,35 @@  discard block
 block discarded – undo
446 446
 		global $wpdb;
447 447
 		$installer = new GetPaid_Installer();
448 448
 
449
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
449
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
450 450
 			$installer->create_subscriptions_table();
451 451
 
452
-			if ( $wpdb->last_error !== '' ) {
453
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
452
+			if ($wpdb->last_error !== '') {
453
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
454 454
 			}
455 455
 		}
456 456
 
457
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
457
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
458 458
 			$installer->create_invoices_table();
459 459
 
460
-			if ( $wpdb->last_error !== '' ) {
461
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
460
+			if ($wpdb->last_error !== '') {
461
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
462 462
 			}
463 463
 		}
464 464
 
465
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
465
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
466 466
 			$installer->create_invoice_items_table();
467 467
 
468
-			if ( $wpdb->last_error !== '' ) {
469
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
468
+			if ($wpdb->last_error !== '') {
469
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
470 470
 			}
471 471
 		}
472 472
 
473
-		if ( ! $this->has_notices() ) {
474
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
473
+		if (!$this->has_notices()) {
474
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
475 475
 		}
476 476
 
477
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
477
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
478 478
 		exit;
479 479
 	}
480 480
 
@@ -489,10 +489,10 @@  discard block
 block discarded – undo
489 489
 		$installer->migrate_old_invoices();
490 490
 
491 491
 		// Show an admin message.
492
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
492
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
493 493
 
494 494
 		// Redirect the admin.
495
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
495
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
496 496
 		exit;
497 497
 
498 498
 	}
@@ -506,36 +506,36 @@  discard block
 block discarded – undo
506 506
 
507 507
 		// Fetch all invoices that have discount codes.
508 508
 		$table    = $wpdb->prefix . 'getpaid_invoices';
509
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
509
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
510 510
 
511
-		foreach ( $invoices as $invoice ) {
511
+		foreach ($invoices as $invoice) {
512 512
 
513
-			$invoice = new WPInv_Invoice( $invoice );
513
+			$invoice = new WPInv_Invoice($invoice);
514 514
 
515
-			if ( ! $invoice->exists() ) {
515
+			if (!$invoice->exists()) {
516 516
 				continue;
517 517
 			}
518 518
 
519 519
 			// Abort if the discount does not exist or does not apply here.
520
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
521
-			if ( ! $discount->exists() ) {
520
+			$discount = new WPInv_Discount($invoice->get_discount_code());
521
+			if (!$discount->exists()) {
522 522
 				continue;
523 523
 			}
524 524
 
525
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
525
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
526 526
 			$invoice->recalculate_total();
527 527
 
528
-			if ( $invoice->get_total_discount() > 0 ) {
528
+			if ($invoice->get_total_discount() > 0) {
529 529
 				$invoice->save();
530 530
 			}
531 531
 
532 532
 		}
533 533
 
534 534
 		// Show an admin message.
535
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
535
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
536 536
 
537 537
 		// Redirect the admin.
538
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
538
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
539 539
 		exit;
540 540
 
541 541
 	}
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
      * @return array
548 548
 	 */
549 549
 	public function get_notices() {
550
-		$notices = get_option( 'wpinv_admin_notices' );
551
-        return is_array( $notices ) ? $notices : array();
550
+		$notices = get_option('wpinv_admin_notices');
551
+        return is_array($notices) ? $notices : array();
552 552
 	}
553 553
 
554 554
 	/**
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
      * @return array
559 559
 	 */
560 560
 	public function has_notices() {
561
-		return count( $this->get_notices() ) > 0;
561
+		return count($this->get_notices()) > 0;
562 562
 	}
563 563
 
564 564
 	/**
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	 * @since       1.0.19
569 569
 	 */
570 570
 	public function clear_notices() {
571
-		delete_option( 'wpinv_admin_notices' );
571
+		delete_option('wpinv_admin_notices');
572 572
 	}
573 573
 
574 574
 	/**
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
 	 * @access      public
578 578
 	 * @since       1.0.19
579 579
 	 */
580
-	public function save_notice( $type, $message ) {
580
+	public function save_notice($type, $message) {
581 581
 		$notices = $this->get_notices();
582 582
 
583
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
584
-			$notices[ $type ] = array();
583
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
584
+			$notices[$type] = array();
585 585
 		}
586 586
 
587
-		$notices[ $type ][] = $message;
587
+		$notices[$type][] = $message;
588 588
 
589
-		update_option( 'wpinv_admin_notices', $notices );
589
+		update_option('wpinv_admin_notices', $notices);
590 590
 	}
591 591
 
592 592
 	/**
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
 	 * @access      public
597 597
 	 * @since       1.0.19
598 598
 	 */
599
-	public function show_success( $msg ) {
600
-		$this->save_notice( 'success', $msg );
599
+	public function show_success($msg) {
600
+		$this->save_notice('success', $msg);
601 601
 	}
602 602
 
603 603
 	/**
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 	 * @param       string $msg The message to qeue.
608 608
 	 * @since       1.0.19
609 609
 	 */
610
-	public function show_error( $msg ) {
611
-		$this->save_notice( 'error', $msg );
610
+	public function show_error($msg) {
611
+		$this->save_notice('error', $msg);
612 612
 	}
613 613
 
614 614
 	/**
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
 	 * @param       string $msg The message to qeue.
619 619
 	 * @since       1.0.19
620 620
 	 */
621
-	public function show_warning( $msg ) {
622
-		$this->save_notice( 'warning', $msg );
621
+	public function show_warning($msg) {
622
+		$this->save_notice('warning', $msg);
623 623
 	}
624 624
 
625 625
 	/**
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
 	 * @param       string $msg The message to qeue.
630 630
 	 * @since       1.0.19
631 631
 	 */
632
-	public function show_info( $msg ) {
633
-		$this->save_notice( 'info', $msg );
632
+	public function show_info($msg) {
633
+		$this->save_notice('info', $msg);
634 634
 	}
635 635
 
636 636
 	/**
@@ -644,32 +644,32 @@  discard block
 block discarded – undo
644 644
         $notices = $this->get_notices();
645 645
         $this->clear_notices();
646 646
 
647
-		foreach ( $notices as $type => $messages ) {
647
+		foreach ($notices as $type => $messages) {
648 648
 
649
-			if ( ! is_array( $messages ) ) {
649
+			if (!is_array($messages)) {
650 650
 				continue;
651 651
 			}
652 652
 
653
-            $type  = sanitize_key( $type );
654
-			foreach ( $messages as $message ) {
655
-                $message = wp_kses_post( $message );
653
+            $type = sanitize_key($type);
654
+			foreach ($messages as $message) {
655
+                $message = wp_kses_post($message);
656 656
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
657 657
             }
658 658
 
659 659
         }
660 660
 
661
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
661
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
662 662
 
663
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
664
-				$url     = esc_url(
663
+			if (!is_numeric(wpinv_get_option($page, false))) {
664
+				$url = esc_url(
665 665
 					wp_nonce_url(
666
-						add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
666
+						add_query_arg('getpaid-admin-action', 'create_missing_pages'),
667 667
 						'getpaid-nonce',
668 668
 						'getpaid-nonce'
669 669
 					)
670 670
 				);
671
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
672
-				$message2 = __( 'Generate Pages', 'invoicing' );
671
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
672
+				$message2 = __('Generate Pages', 'invoicing');
673 673
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
674 674
 				break;
675 675
 			}
Please login to merge, or discard this patch.