Passed
Push — master ( 1599c5...2383b4 )
by Brian
11:02
created
includes/admin/register-settings.php 2 patches
Indentation   +338 added lines, -338 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   = esc_attr( $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   = esc_attr( $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(
@@ -425,333 +425,333 @@  discard block
 block discarded – undo
425 425
 }
426 426
 
427 427
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
428
-	$pages_options = array();
428
+    $pages_options = array();
429 429
 
430
-	if( $default_label !== NULL && $default_label !== false ) {
431
-		$pages_options = array( '' => $default_label ); // Blank option
432
-	}
430
+    if( $default_label !== NULL && $default_label !== false ) {
431
+        $pages_options = array( '' => $default_label ); // Blank option
432
+    }
433 433
 
434
-	$pages = get_pages();
435
-	if ( $pages ) {
436
-		foreach ( $pages as $page ) {
437
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
434
+    $pages = get_pages();
435
+    if ( $pages ) {
436
+        foreach ( $pages as $page ) {
437
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
438 438
             $pages_options[ $page->ID ] = $title;
439
-		}
440
-	}
439
+        }
440
+    }
441 441
 
442
-	return $pages_options;
442
+    return $pages_options;
443 443
 }
444 444
 
445 445
 function wpinv_header_callback( $args ) {
446
-	if ( !empty( $args['desc'] ) ) {
446
+    if ( !empty( $args['desc'] ) ) {
447 447
         echo $args['desc'];
448 448
     }
449 449
 }
450 450
 
451 451
 function wpinv_hidden_callback( $args ) {
452
-	global $wpinv_options;
453
-
454
-	if ( isset( $args['set_value'] ) ) {
455
-		$value = $args['set_value'];
456
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
457
-		$value = $wpinv_options[ $args['id'] ];
458
-	} else {
459
-		$value = isset( $args['std'] ) ? $args['std'] : '';
460
-	}
461
-
462
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
463
-		$args['readonly'] = true;
464
-		$value = isset( $args['std'] ) ? $args['std'] : '';
465
-		$name  = '';
466
-	} else {
467
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
468
-	}
469
-
470
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
452
+    global $wpinv_options;
453
+
454
+    if ( isset( $args['set_value'] ) ) {
455
+        $value = $args['set_value'];
456
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
457
+        $value = $wpinv_options[ $args['id'] ];
458
+    } else {
459
+        $value = isset( $args['std'] ) ? $args['std'] : '';
460
+    }
461
+
462
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
463
+        $args['readonly'] = true;
464
+        $value = isset( $args['std'] ) ? $args['std'] : '';
465
+        $name  = '';
466
+    } else {
467
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
468
+    }
469
+
470
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
471 471
     
472
-	echo $html;
472
+    echo $html;
473 473
 }
474 474
 
475 475
 function wpinv_checkbox_callback( $args ) {
476
-	global $wpinv_options;
476
+    global $wpinv_options;
477 477
     
478 478
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
479 479
 
480
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
481
-		$name = '';
482
-	} else {
483
-		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
484
-	}
480
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
481
+        $name = '';
482
+    } else {
483
+        $name = 'name="wpinv_settings[' . $sanitize_id . ']"';
484
+    }
485 485
 
486
-	$std     = isset( $args['std'] ) ? $args['std'] : 0;
487
-	$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
488
-	$checked = checked( empty( $value ), false, false );
486
+    $std     = isset( $args['std'] ) ? $args['std'] : 0;
487
+    $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
488
+    $checked = checked( empty( $value ), false, false );
489 489
 
490
-	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
491
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
490
+    $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
491
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
492 492
 
493
-	echo $html;
493
+    echo $html;
494 494
 }
495 495
 
496 496
 function wpinv_multicheck_callback( $args ) {
497
-	global $wpinv_options;
497
+    global $wpinv_options;
498 498
 
499
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
500
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
499
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
500
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
501 501
 
502
-	if ( ! empty( $args['options'] ) ) {
502
+    if ( ! empty( $args['options'] ) ) {
503 503
 
504
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
505
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
504
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
505
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
506 506
 
507
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
507
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
508 508
         foreach( $args['options'] as $key => $option ):
509
-			$sanitize_key = wpinv_sanitize_key( $key );
510
-			if ( in_array( $sanitize_key, $value ) ) { 
511
-				$enabled = $sanitize_key;
512
-			} else { 
513
-				$enabled = NULL; 
514
-			}
515
-			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;';
516
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
517
-		endforeach;
518
-		echo '</div>';
519
-		echo '<p class="description">' . $args['desc'] . '</p>';
520
-	}
509
+            $sanitize_key = wpinv_sanitize_key( $key );
510
+            if ( in_array( $sanitize_key, $value ) ) { 
511
+                $enabled = $sanitize_key;
512
+            } else { 
513
+                $enabled = NULL; 
514
+            }
515
+            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;';
516
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
517
+        endforeach;
518
+        echo '</div>';
519
+        echo '<p class="description">' . $args['desc'] . '</p>';
520
+    }
521 521
 }
522 522
 
523 523
 function wpinv_payment_icons_callback( $args ) {
524
-	global $wpinv_options;
524
+    global $wpinv_options;
525 525
     
526 526
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
527 527
 
528
-	if ( ! empty( $args['options'] ) ) {
529
-		foreach( $args['options'] as $key => $option ) {
528
+    if ( ! empty( $args['options'] ) ) {
529
+        foreach( $args['options'] as $key => $option ) {
530 530
             $sanitize_key = wpinv_sanitize_key( $key );
531 531
             
532
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
533
-				$enabled = $option;
534
-			} else {
535
-				$enabled = NULL;
536
-			}
537
-
538
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
539
-
540
-				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;';
541
-
542
-				if ( wpinv_string_is_image_url( $key ) ) {
543
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
544
-				} else {
545
-					$card = strtolower( str_replace( ' ', '', $option ) );
546
-
547
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
548
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
549
-					} else {
550
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
551
-						$content_dir = WP_CONTENT_DIR;
552
-
553
-						if ( function_exists( 'wp_normalize_path' ) ) {
554
-							// Replaces backslashes with forward slashes for Windows systems
555
-							$image = wp_normalize_path( $image );
556
-							$content_dir = wp_normalize_path( $content_dir );
557
-						}
558
-
559
-						$image = str_replace( $content_dir, content_url(), $image );
560
-					}
561
-
562
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
-				}
564
-			echo $option . '</label>';
565
-		}
566
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
567
-	}
532
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
533
+                $enabled = $option;
534
+            } else {
535
+                $enabled = NULL;
536
+            }
537
+
538
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
539
+
540
+                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;';
541
+
542
+                if ( wpinv_string_is_image_url( $key ) ) {
543
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
544
+                } else {
545
+                    $card = strtolower( str_replace( ' ', '', $option ) );
546
+
547
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
548
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
549
+                    } else {
550
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
551
+                        $content_dir = WP_CONTENT_DIR;
552
+
553
+                        if ( function_exists( 'wp_normalize_path' ) ) {
554
+                            // Replaces backslashes with forward slashes for Windows systems
555
+                            $image = wp_normalize_path( $image );
556
+                            $content_dir = wp_normalize_path( $content_dir );
557
+                        }
558
+
559
+                        $image = str_replace( $content_dir, content_url(), $image );
560
+                    }
561
+
562
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563
+                }
564
+            echo $option . '</label>';
565
+        }
566
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
567
+    }
568 568
 }
569 569
 
570 570
 function wpinv_radio_callback( $args ) {
571
-	global $wpinv_options;
571
+    global $wpinv_options;
572 572
     
573 573
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
574 574
     
575 575
     foreach ( $args['options'] as $key => $option ) :
576
-		$sanitize_key = wpinv_sanitize_key( $key );
576
+        $sanitize_key = wpinv_sanitize_key( $key );
577 577
         
578 578
         $checked = false;
579 579
 
580
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
581
-			$checked = true;
582
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
583
-			$checked = true;
580
+        if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
581
+            $checked = true;
582
+        elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
583
+            $checked = true;
584 584
 
585
-		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
586
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
587
-	endforeach;
585
+        echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
586
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
587
+    endforeach;
588 588
 
589
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
589
+    echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
590 590
 }
591 591
 
592 592
 function wpinv_gateways_callback( $args ) {
593
-	global $wpinv_options;
593
+    global $wpinv_options;
594 594
     
595 595
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
596 596
 
597
-	foreach ( $args['options'] as $key => $option ) :
598
-		$sanitize_key = wpinv_sanitize_key( $key );
597
+    foreach ( $args['options'] as $key => $option ) :
598
+        $sanitize_key = wpinv_sanitize_key( $key );
599 599
         
600 600
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
601
-			$enabled = '1';
602
-		else
603
-			$enabled = null;
601
+            $enabled = '1';
602
+        else
603
+            $enabled = null;
604 604
 
605
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
606
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
607
-	endforeach;
605
+        echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
606
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
607
+    endforeach;
608 608
 }
609 609
 
610 610
 function wpinv_gateway_select_callback($args) {
611
-	global $wpinv_options;
611
+    global $wpinv_options;
612 612
     
613 613
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
614 614
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
615 615
 
616
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
616
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
617 617
 
618
-	foreach ( $args['options'] as $key => $option ) :
619
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
618
+    foreach ( $args['options'] as $key => $option ) :
619
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
620 620
             $selected = selected( $key, $args['selected'], false );
621 621
         } else {
622 622
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
623 623
         }
624
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
625
-	endforeach;
624
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
625
+    endforeach;
626 626
 
627
-	echo '</select>';
628
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
627
+    echo '</select>';
628
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
629 629
 }
630 630
 
631 631
 function wpinv_text_callback( $args ) {
632
-	global $wpinv_options;
632
+    global $wpinv_options;
633 633
     
634 634
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
635 635
 
636
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
637
-		$value = $wpinv_options[ $args['id'] ];
638
-	} else {
639
-		$value = isset( $args['std'] ) ? $args['std'] : '';
640
-	}
641
-
642
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
643
-		$args['readonly'] = true;
644
-		$value = isset( $args['std'] ) ? $args['std'] : '';
645
-		$name  = '';
646
-	} else {
647
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
648
-	}
649
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
650
-
651
-	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
652
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
653
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
654
-	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
655
-
656
-	echo $html;
636
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
637
+        $value = $wpinv_options[ $args['id'] ];
638
+    } else {
639
+        $value = isset( $args['std'] ) ? $args['std'] : '';
640
+    }
641
+
642
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
643
+        $args['readonly'] = true;
644
+        $value = isset( $args['std'] ) ? $args['std'] : '';
645
+        $name  = '';
646
+    } else {
647
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
648
+    }
649
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
650
+
651
+    $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
652
+    $size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
653
+    $html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
654
+    $html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
655
+
656
+    echo $html;
657 657
 }
658 658
 
659 659
 function wpinv_number_callback( $args ) {
660
-	global $wpinv_options;
660
+    global $wpinv_options;
661 661
     
662 662
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
663 663
 
664
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
665
-		$value = $wpinv_options[ $args['id'] ];
666
-	} else {
667
-		$value = isset( $args['std'] ) ? $args['std'] : '';
668
-	}
669
-
670
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
671
-		$args['readonly'] = true;
672
-		$value = isset( $args['std'] ) ? $args['std'] : '';
673
-		$name  = '';
674
-	} else {
675
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
676
-	}
677
-
678
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
679
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
680
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
681
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
682
-
683
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
684
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
685
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
686
-
687
-	echo $html;
664
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
665
+        $value = $wpinv_options[ $args['id'] ];
666
+    } else {
667
+        $value = isset( $args['std'] ) ? $args['std'] : '';
668
+    }
669
+
670
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
671
+        $args['readonly'] = true;
672
+        $value = isset( $args['std'] ) ? $args['std'] : '';
673
+        $name  = '';
674
+    } else {
675
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
676
+    }
677
+
678
+    $max  = isset( $args['max'] ) ? $args['max'] : 999999;
679
+    $min  = isset( $args['min'] ) ? $args['min'] : 0;
680
+    $step = isset( $args['step'] ) ? $args['step'] : 1;
681
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
682
+
683
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
684
+    $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
685
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
686
+
687
+    echo $html;
688 688
 }
689 689
 
690 690
 function wpinv_textarea_callback( $args ) {
691
-	global $wpinv_options;
691
+    global $wpinv_options;
692 692
     
693 693
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
694 694
 
695
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
696
-		$value = $wpinv_options[ $args['id'] ];
697
-	} else {
698
-		$value = isset( $args['std'] ) ? $args['std'] : '';
699
-	}
695
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
696
+        $value = $wpinv_options[ $args['id'] ];
697
+    } else {
698
+        $value = isset( $args['std'] ) ? $args['std'] : '';
699
+    }
700 700
     
701 701
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
702 702
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
703 703
 
704
-	$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>';
705
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
704
+    $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>';
705
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
706 706
 
707
-	echo $html;
707
+    echo $html;
708 708
 }
709 709
 
710 710
 function wpinv_password_callback( $args ) {
711
-	global $wpinv_options;
711
+    global $wpinv_options;
712 712
     
713 713
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
714 714
 
715
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
716
-		$value = $wpinv_options[ $args['id'] ];
717
-	} else {
718
-		$value = isset( $args['std'] ) ? $args['std'] : '';
719
-	}
715
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
716
+        $value = $wpinv_options[ $args['id'] ];
717
+    } else {
718
+        $value = isset( $args['std'] ) ? $args['std'] : '';
719
+    }
720 720
 
721
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
722
-	$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 ) . '"/>';
723
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
721
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
722
+    $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 ) . '"/>';
723
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
724 724
 
725
-	echo $html;
725
+    echo $html;
726 726
 }
727 727
 
728 728
 function wpinv_missing_callback($args) {
729
-	printf(
730
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
731
-		'<strong>' . $args['id'] . '</strong>'
732
-	);
729
+    printf(
730
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
731
+        '<strong>' . $args['id'] . '</strong>'
732
+    );
733 733
 }
734 734
 
735 735
 function wpinv_select_callback($args) {
736
-	global $wpinv_options;
736
+    global $wpinv_options;
737 737
     
738 738
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
739 739
 
740
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
741
-		$value = $wpinv_options[ $args['id'] ];
742
-	} else {
743
-		$value = isset( $args['std'] ) ? $args['std'] : '';
744
-	}
740
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
741
+        $value = $wpinv_options[ $args['id'] ];
742
+    } else {
743
+        $value = isset( $args['std'] ) ? $args['std'] : '';
744
+    }
745 745
     
746 746
     if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
747 747
         $value = $args['selected'];
748 748
     }
749 749
 
750
-	if ( isset( $args['placeholder'] ) ) {
751
-		$placeholder = $args['placeholder'];
752
-	} else {
753
-		$placeholder = '';
754
-	}
750
+    if ( isset( $args['placeholder'] ) ) {
751
+        $placeholder = $args['placeholder'];
752
+    } else {
753
+        $placeholder = '';
754
+    }
755 755
     
756 756
     if( !empty( $args['onchange'] ) ) {
757 757
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
@@ -761,143 +761,143 @@  discard block
 block discarded – undo
761 761
 
762 762
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
763 763
 
764
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
764
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
765 765
 
766
-	foreach ( $args['options'] as $option => $name ) {
767
-		$selected = selected( $option, $value, false );
768
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
769
-	}
766
+    foreach ( $args['options'] as $option => $name ) {
767
+        $selected = selected( $option, $value, false );
768
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
769
+    }
770 770
 
771
-	$html .= '</select>';
772
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
771
+    $html .= '</select>';
772
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
773 773
 
774
-	echo $html;
774
+    echo $html;
775 775
 }
776 776
 
777 777
 function wpinv_color_select_callback( $args ) {
778
-	global $wpinv_options;
778
+    global $wpinv_options;
779 779
     
780 780
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
781 781
 
782
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
783
-		$value = $wpinv_options[ $args['id'] ];
784
-	} else {
785
-		$value = isset( $args['std'] ) ? $args['std'] : '';
786
-	}
782
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
783
+        $value = $wpinv_options[ $args['id'] ];
784
+    } else {
785
+        $value = isset( $args['std'] ) ? $args['std'] : '';
786
+    }
787 787
 
788
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
788
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
789 789
 
790
-	foreach ( $args['options'] as $option => $color ) {
791
-		$selected = selected( $option, $value, false );
792
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
793
-	}
790
+    foreach ( $args['options'] as $option => $color ) {
791
+        $selected = selected( $option, $value, false );
792
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
793
+    }
794 794
 
795
-	$html .= '</select>';
796
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
795
+    $html .= '</select>';
796
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
797 797
 
798
-	echo $html;
798
+    echo $html;
799 799
 }
800 800
 
801 801
 function wpinv_rich_editor_callback( $args ) {
802
-	global $wpinv_options, $wp_version;
802
+    global $wpinv_options, $wp_version;
803 803
     
804 804
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
805 805
 
806
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
807
-		$value = $wpinv_options[ $args['id'] ];
806
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
807
+        $value = $wpinv_options[ $args['id'] ];
808 808
 
809
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
810
-			$value = isset( $args['std'] ) ? $args['std'] : '';
811
-		}
812
-	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
814
-	}
809
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
810
+            $value = isset( $args['std'] ) ? $args['std'] : '';
811
+        }
812
+    } else {
813
+        $value = isset( $args['std'] ) ? $args['std'] : '';
814
+    }
815 815
 
816
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
816
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
817 817
 
818
-	$html = '<div class="getpaid-settings-editor-input">';
819
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
820
-		ob_start();
821
-		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 ) );
822
-		$html .= ob_get_clean();
823
-	} else {
824
-		$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>';
825
-	}
818
+    $html = '<div class="getpaid-settings-editor-input">';
819
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
820
+        ob_start();
821
+        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 ) );
822
+        $html .= ob_get_clean();
823
+    } else {
824
+        $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>';
825
+    }
826 826
 
827
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
827
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
828 828
 
829
-	echo $html;
829
+    echo $html;
830 830
 }
831 831
 
832 832
 function wpinv_upload_callback( $args ) {
833
-	global $wpinv_options;
833
+    global $wpinv_options;
834 834
     
835 835
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
836 836
 
837
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
838
-		$value = $wpinv_options[$args['id']];
839
-	} else {
840
-		$value = isset($args['std']) ? $args['std'] : '';
841
-	}
837
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
838
+        $value = $wpinv_options[$args['id']];
839
+    } else {
840
+        $value = isset($args['std']) ? $args['std'] : '';
841
+    }
842 842
 
843
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
844
-	$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 ) ) . '"/>';
845
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
846
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
843
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
844
+    $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 ) ) . '"/>';
845
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
846
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
847 847
 
848
-	echo $html;
848
+    echo $html;
849 849
 }
850 850
 
851 851
 function wpinv_color_callback( $args ) {
852
-	global $wpinv_options;
852
+    global $wpinv_options;
853 853
     
854 854
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
855 855
 
856
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
857
-		$value = $wpinv_options[ $args['id'] ];
858
-	} else {
859
-		$value = isset( $args['std'] ) ? $args['std'] : '';
860
-	}
856
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
857
+        $value = $wpinv_options[ $args['id'] ];
858
+    } else {
859
+        $value = isset( $args['std'] ) ? $args['std'] : '';
860
+    }
861 861
 
862
-	$default = isset( $args['std'] ) ? $args['std'] : '';
862
+    $default = isset( $args['std'] ) ? $args['std'] : '';
863 863
 
864
-	$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 ) . '" />';
865
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
864
+    $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 ) . '" />';
865
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
866 866
 
867
-	echo $html;
867
+    echo $html;
868 868
 }
869 869
 
870 870
 function wpinv_country_states_callback($args) {
871
-	global $wpinv_options;
871
+    global $wpinv_options;
872 872
     
873 873
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
874 874
 
875
-	if ( isset( $args['placeholder'] ) ) {
876
-		$placeholder = $args['placeholder'];
877
-	} else {
878
-		$placeholder = '';
879
-	}
875
+    if ( isset( $args['placeholder'] ) ) {
876
+        $placeholder = $args['placeholder'];
877
+    } else {
878
+        $placeholder = '';
879
+    }
880 880
 
881
-	$states = wpinv_get_country_states();
881
+    $states = wpinv_get_country_states();
882 882
 
883
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
883
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
885 885
 
886
-	foreach ( $states as $option => $name ) {
887
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
888
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
889
-	}
886
+    foreach ( $states as $option => $name ) {
887
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
888
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
889
+    }
890 890
 
891
-	$html .= '</select>';
892
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
891
+    $html .= '</select>';
892
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
893 893
 
894
-	echo $html;
894
+    echo $html;
895 895
 }
896 896
 
897 897
 function wpinv_tax_rates_callback($args) {
898
-	global $wpinv_options;
899
-	$rates = wpinv_get_tax_rates();
900
-	ob_start(); ?>
898
+    global $wpinv_options;
899
+    $rates = wpinv_get_tax_rates();
900
+    ob_start(); ?>
901 901
     </td><tr>
902 902
     <td colspan="2" class="wpinv_tax_tdbox">
903 903
 	<p><?php echo $args['desc']; ?></p>
@@ -921,40 +921,40 @@  discard block
 block discarded – undo
921 921
 			<tr>
922 922
 				<td class="wpinv_tax_country">
923 923
 					<?php
924
-					echo wpinv_html_select( array(
925
-						'options'          => wpinv_get_country_list( true ),
926
-						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
924
+                    echo wpinv_html_select( array(
925
+                        'options'          => wpinv_get_country_list( true ),
926
+                        'name'             => 'tax_rates[' . $sanitized_key . '][country]',
927 927
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
928
-						'selected'         => $rate['country'],
929
-						'show_option_all'  => false,
930
-						'show_option_none' => false,
931
-						'class'            => 'wpinv-tax-country wpi_select2',
932
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
933
-					) );
934
-					?>
928
+                        'selected'         => $rate['country'],
929
+                        'show_option_all'  => false,
930
+                        'show_option_none' => false,
931
+                        'class'            => 'wpinv-tax-country wpi_select2',
932
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
933
+                    ) );
934
+                    ?>
935 935
 				</td>
936 936
 				<td class="wpinv_tax_state">
937 937
 					<?php
938
-					$states = wpinv_get_country_states( $rate['country'] );
939
-					if( !empty( $states ) ) {
940
-						echo wpinv_html_select( array(
941
-							'options'          => array_merge( array( '' => '' ), $states ),
942
-							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
938
+                    $states = wpinv_get_country_states( $rate['country'] );
939
+                    if( !empty( $states ) ) {
940
+                        echo wpinv_html_select( array(
941
+                            'options'          => array_merge( array( '' => '' ), $states ),
942
+                            'name'             => 'tax_rates[' . $sanitized_key . '][state]',
943 943
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
944
-							'selected'         => $rate['state'],
945
-							'show_option_all'  => false,
946
-							'show_option_none' => false,
944
+                            'selected'         => $rate['state'],
945
+                            'show_option_all'  => false,
946
+                            'show_option_none' => false,
947 947
                             'class'            => 'wpi_select2',
948
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
949
-						) );
950
-					} else {
951
-						echo wpinv_html_text( array(
952
-							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
953
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
948
+                            'placeholder'      => __( 'Choose a state', 'invoicing' )
949
+                        ) );
950
+                    } else {
951
+                        echo wpinv_html_text( array(
952
+                            'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
953
+                            'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
954 954
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
955
-						) );
956
-					}
957
-					?>
955
+                        ) );
956
+                    }
957
+                    ?>
958 958
 				</td>
959 959
 				<td class="wpinv_tax_global">
960 960
 					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
@@ -969,19 +969,19 @@  discard block
 block discarded – undo
969 969
 			<tr>
970 970
 				<td class="wpinv_tax_country">
971 971
 					<?php
972
-					echo wpinv_html_select( array(
973
-						'options'          => wpinv_get_country_list( true ),
974
-						'name'             => 'tax_rates[0][country]',
975
-						'show_option_all'  => false,
976
-						'show_option_none' => false,
977
-						'class'            => 'wpinv-tax-country wpi_select2',
978
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
979
-					) ); ?>
972
+                    echo wpinv_html_select( array(
973
+                        'options'          => wpinv_get_country_list( true ),
974
+                        'name'             => 'tax_rates[0][country]',
975
+                        'show_option_all'  => false,
976
+                        'show_option_none' => false,
977
+                        'class'            => 'wpinv-tax-country wpi_select2',
978
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
979
+                    ) ); ?>
980 980
 				</td>
981 981
 				<td class="wpinv_tax_state">
982 982
 					<?php echo wpinv_html_text( array(
983
-						'name' => 'tax_rates[0][state]'
984
-					) ); ?>
983
+                        'name' => 'tax_rates[0][state]'
984
+                    ) ); ?>
985 985
 				</td>
986 986
 				<td class="wpinv_tax_global">
987 987
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
         <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
997 997
 	</table>
998 998
 	<?php
999
-	echo ob_get_clean();
999
+    echo ob_get_clean();
1000 1000
 }
1001 1001
 
1002 1002
 function wpinv_tools_callback($args) {
@@ -1024,15 +1024,15 @@  discard block
 block discarded – undo
1024 1024
 }
1025 1025
 
1026 1026
 function wpinv_descriptive_text_callback( $args ) {
1027
-	echo wp_kses_post( $args['desc'] );
1027
+    echo wp_kses_post( $args['desc'] );
1028 1028
 }
1029 1029
 
1030 1030
 function wpinv_hook_callback( $args ) {
1031
-	do_action( 'wpinv_' . $args['id'], $args );
1031
+    do_action( 'wpinv_' . $args['id'], $args );
1032 1032
 }
1033 1033
 
1034 1034
 function wpinv_set_settings_cap() {
1035
-	return wpinv_get_capability();
1035
+    return wpinv_get_capability();
1036 1036
 }
1037 1037
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1038 1038
 
Please login to merge, or discard this patch.
Spacing   +396 added lines, -396 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,46 +190,46 @@  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   = esc_attr( $option['desc'] );
199
+	if (isset($option['desc']) && !empty($option['help-tip'])) {
200
+		$tip   = esc_attr($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']          : null,
215
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
214
+            'id'          => isset($option['id']) ? $option['id'] : null,
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']         : null,
222
-            'max'         => isset( $option['max'] )         ? $option['max']         : null,
223
-            'step'        => isset( $option['step'] )        ? $option['step']        : null,
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
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
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'] : null,
222
+            'max'         => isset($option['max']) ? $option['max'] : null,
223
+            'step'        => isset($option['step']) ? $option['step'] : null,
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
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
232
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
233 233
         )
234 234
     );
235 235
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @return array
242 242
  */
243 243
 function wpinv_get_registered_settings() {
244
-    return apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) );
244
+    return apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'));
245 245
 }
246 246
 
247 247
 /**
@@ -249,134 +249,134 @@  discard block
 block discarded – undo
249 249
  * 
250 250
  * @return array
251 251
  */
252
-function wpinv_settings_sanitize( $input = array() ) {
252
+function wpinv_settings_sanitize($input = array()) {
253 253
 
254 254
     $wpinv_options = wpinv_get_options();
255 255
 
256
-    if ( empty( wp_get_raw_referer() ) ) {
256
+    if (empty(wp_get_raw_referer())) {
257 257
         return $input;
258 258
     }
259 259
 
260
-    wp_parse_str( wp_get_raw_referer(), $referrer );
260
+    wp_parse_str(wp_get_raw_referer(), $referrer);
261 261
 
262 262
     $settings = wpinv_get_registered_settings();
263
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
264
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
263
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
264
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
265 265
 
266 266
     $input = $input ? $input : array();
267
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
268
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
267
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
268
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
269 269
 
270 270
     // Loop through each setting being saved and pass it through a sanitization filter
271
-    foreach ( $input as $key => $value ) {
271
+    foreach ($input as $key => $value) {
272 272
 
273 273
         // Get the setting type (checkbox, select, etc)
274
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
274
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
275 275
 
276
-        if ( $type ) {
276
+        if ($type) {
277 277
             // Field type specific filter
278
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
278
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
279 279
         }
280 280
 
281 281
         // General filter
282
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
282
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
283 283
     }
284 284
 
285 285
     // Loop through the whitelist and unset any that are empty for the tab being saved
286
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
287
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
286
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
287
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
288 288
 
289
-    $found_settings = array_merge( $main_settings, $section_settings );
289
+    $found_settings = array_merge($main_settings, $section_settings);
290 290
 
291
-    if ( ! empty( $found_settings ) ) {
292
-        foreach ( $found_settings as $key => $value ) {
291
+    if (!empty($found_settings)) {
292
+        foreach ($found_settings as $key => $value) {
293 293
 
294 294
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
295
-            if ( is_numeric( $key ) ) {
295
+            if (is_numeric($key)) {
296 296
                 $key = $value['id'];
297 297
             }
298 298
 
299
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
300
-                unset( $wpinv_options[ $key ] );
299
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
300
+                unset($wpinv_options[$key]);
301 301
             }
302 302
         }
303 303
     }
304 304
 
305 305
     // Merge our new settings with the existing
306
-    $output = array_merge( $wpinv_options, $input );
306
+    $output = array_merge($wpinv_options, $input);
307 307
 
308
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
308
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
309 309
 
310 310
     return $output;
311 311
 }
312 312
 
313
-function wpinv_settings_sanitize_misc_accounting( $input ) {
313
+function wpinv_settings_sanitize_misc_accounting($input) {
314 314
 
315
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
315
+    if (!wpinv_current_user_can_manage_invoicing()) {
316 316
         return $input;
317 317
     }
318 318
 
319
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
319
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
320 320
         // Shows an admin notice about upgrading previous order numbers
321
-        getpaid_session()->set( 'upgrade_sequential', '1' );
321
+        getpaid_session()->set('upgrade_sequential', '1');
322 322
     }
323 323
 
324 324
     return $input;
325 325
 }
326
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
326
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
327 327
 
328
-function wpinv_settings_sanitize_tax_rates( $input ) {
329
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
328
+function wpinv_settings_sanitize_tax_rates($input) {
329
+    if (!wpinv_current_user_can_manage_invoicing()) {
330 330
         return $input;
331 331
     }
332 332
 
333
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
333
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
334 334
 
335 335
     $tax_rates = array();
336 336
 
337
-    if ( !empty( $new_rates ) ) {
338
-        foreach ( $new_rates as $rate ) {
339
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
337
+    if (!empty($new_rates)) {
338
+        foreach ($new_rates as $rate) {
339
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
340 340
                 continue;
341 341
             }
342 342
             
343
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
343
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
344 344
             
345 345
             $tax_rates[] = $rate;
346 346
         }
347 347
     }
348 348
 
349
-    update_option( 'wpinv_tax_rates', $tax_rates );
349
+    update_option('wpinv_tax_rates', $tax_rates);
350 350
 
351 351
     return $input;
352 352
 }
353
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
353
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
354 354
 
355
-function wpinv_sanitize_text_field( $input ) {
356
-    return trim( $input );
355
+function wpinv_sanitize_text_field($input) {
356
+    return trim($input);
357 357
 }
358
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
358
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
359 359
 
360 360
 function wpinv_get_settings_tabs() {
361 361
     $tabs             = array();
362
-    $tabs['general']  = __( 'General', 'invoicing' );
363
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
364
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
365
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
366
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
367
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
368
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
369
-
370
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
362
+    $tabs['general']  = __('General', 'invoicing');
363
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
364
+    $tabs['taxes']    = __('Taxes', 'invoicing');
365
+    $tabs['emails']   = __('Emails', 'invoicing');
366
+    $tabs['privacy']  = __('Privacy', 'invoicing');
367
+    $tabs['misc']     = __('Misc', 'invoicing');
368
+    $tabs['tools']    = __('Tools', 'invoicing');
369
+
370
+    return apply_filters('wpinv_settings_tabs', $tabs);
371 371
 }
372 372
 
373
-function wpinv_get_settings_tab_sections( $tab = false ) {
373
+function wpinv_get_settings_tab_sections($tab = false) {
374 374
     $tabs     = false;
375 375
     $sections = wpinv_get_registered_settings_sections();
376 376
 
377
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
378
-        $tabs = $sections[ $tab ];
379
-    } else if ( $tab ) {
377
+    if ($tab && !empty($sections[$tab])) {
378
+        $tabs = $sections[$tab];
379
+    } else if ($tab) {
380 380
         $tabs = false;
381 381
     }
382 382
 
@@ -386,150 +386,150 @@  discard block
 block discarded – undo
386 386
 function wpinv_get_registered_settings_sections() {
387 387
     static $sections = false;
388 388
 
389
-    if ( false !== $sections ) {
389
+    if (false !== $sections) {
390 390
         return $sections;
391 391
     }
392 392
 
393 393
     $sections = array(
394
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
395
-            'main' => __( 'General Settings', 'invoicing' ),
396
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
397
-            'labels' => __( 'Label Texts', 'invoicing' ),
398
-        ) ),
399
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
400
-            'main' => __( 'Gateway Settings', 'invoicing' ),
401
-        ) ),
402
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
403
-            'main' => __( 'Tax Settings', 'invoicing' ),
404
-            'rates' => __( 'Tax Rates', 'invoicing' ),
405
-        ) ),
406
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
407
-            'main' => __( 'Email Settings', 'invoicing' ),
408
-        ) ),
409
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
410
-            'main' => __( 'Privacy policy', 'invoicing' ),
411
-        ) ),
412
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
413
-            'main' => __( 'Miscellaneous', 'invoicing' ),
414
-            'fields' => __( 'Fields Settings', 'invoicing' ),
415
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
416
-        ) ),
417
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
418
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
419
-        ) ),
394
+        'general' => apply_filters('wpinv_settings_sections_general', array(
395
+            'main' => __('General Settings', 'invoicing'),
396
+            'currency_section' => __('Currency Settings', 'invoicing'),
397
+            'labels' => __('Label Texts', 'invoicing'),
398
+        )),
399
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
400
+            'main' => __('Gateway Settings', 'invoicing'),
401
+        )),
402
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
403
+            'main' => __('Tax Settings', 'invoicing'),
404
+            'rates' => __('Tax Rates', 'invoicing'),
405
+        )),
406
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
407
+            'main' => __('Email Settings', 'invoicing'),
408
+        )),
409
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
410
+            'main' => __('Privacy policy', 'invoicing'),
411
+        )),
412
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
413
+            'main' => __('Miscellaneous', 'invoicing'),
414
+            'fields' => __('Fields Settings', 'invoicing'),
415
+            'custom-css' => __('Custom CSS', 'invoicing'),
416
+        )),
417
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
418
+            'main' => __('Diagnostic Tools', 'invoicing'),
419
+        )),
420 420
     );
421 421
 
422
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
422
+    $sections = apply_filters('wpinv_settings_sections', $sections);
423 423
 
424 424
     return $sections;
425 425
 }
426 426
 
427
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
427
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
428 428
 	$pages_options = array();
429 429
 
430
-	if( $default_label !== NULL && $default_label !== false ) {
431
-		$pages_options = array( '' => $default_label ); // Blank option
430
+	if ($default_label !== NULL && $default_label !== false) {
431
+		$pages_options = array('' => $default_label); // Blank option
432 432
 	}
433 433
 
434 434
 	$pages = get_pages();
435
-	if ( $pages ) {
436
-		foreach ( $pages as $page ) {
435
+	if ($pages) {
436
+		foreach ($pages as $page) {
437 437
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
438
-            $pages_options[ $page->ID ] = $title;
438
+            $pages_options[$page->ID] = $title;
439 439
 		}
440 440
 	}
441 441
 
442 442
 	return $pages_options;
443 443
 }
444 444
 
445
-function wpinv_header_callback( $args ) {
446
-	if ( !empty( $args['desc'] ) ) {
445
+function wpinv_header_callback($args) {
446
+	if (!empty($args['desc'])) {
447 447
         echo $args['desc'];
448 448
     }
449 449
 }
450 450
 
451
-function wpinv_hidden_callback( $args ) {
451
+function wpinv_hidden_callback($args) {
452 452
 	global $wpinv_options;
453 453
 
454
-	if ( isset( $args['set_value'] ) ) {
454
+	if (isset($args['set_value'])) {
455 455
 		$value = $args['set_value'];
456
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
457
-		$value = $wpinv_options[ $args['id'] ];
456
+	} elseif (isset($wpinv_options[$args['id']])) {
457
+		$value = $wpinv_options[$args['id']];
458 458
 	} else {
459
-		$value = isset( $args['std'] ) ? $args['std'] : '';
459
+		$value = isset($args['std']) ? $args['std'] : '';
460 460
 	}
461 461
 
462
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
462
+	if (isset($args['faux']) && true === $args['faux']) {
463 463
 		$args['readonly'] = true;
464
-		$value = isset( $args['std'] ) ? $args['std'] : '';
464
+		$value = isset($args['std']) ? $args['std'] : '';
465 465
 		$name  = '';
466 466
 	} else {
467
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
467
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
468 468
 	}
469 469
 
470
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
470
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
471 471
     
472 472
 	echo $html;
473 473
 }
474 474
 
475
-function wpinv_checkbox_callback( $args ) {
475
+function wpinv_checkbox_callback($args) {
476 476
 	global $wpinv_options;
477 477
     
478
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
478
+    $sanitize_id = wpinv_sanitize_key($args['id']);
479 479
 
480
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
480
+	if (isset($args['faux']) && true === $args['faux']) {
481 481
 		$name = '';
482 482
 	} else {
483 483
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
484 484
 	}
485 485
 
486
-	$std     = isset( $args['std'] ) ? $args['std'] : 0;
487
-	$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
488
-	$checked = checked( empty( $value ), false, false );
486
+	$std     = isset($args['std']) ? $args['std'] : 0;
487
+	$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
488
+	$checked = checked(empty($value), false, false);
489 489
 
490 490
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
491
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
491
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
492 492
 
493 493
 	echo $html;
494 494
 }
495 495
 
496
-function wpinv_multicheck_callback( $args ) {
496
+function wpinv_multicheck_callback($args) {
497 497
 	global $wpinv_options;
498 498
 
499
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
500
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
499
+	$sanitize_id = wpinv_sanitize_key($args['id']);
500
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
501 501
 
502
-	if ( ! empty( $args['options'] ) ) {
502
+	if (!empty($args['options'])) {
503 503
 
504
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
505
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
504
+		$std     = isset($args['std']) ? $args['std'] : array();
505
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
506 506
 
507 507
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
508
-        foreach( $args['options'] as $key => $option ):
509
-			$sanitize_key = wpinv_sanitize_key( $key );
510
-			if ( in_array( $sanitize_key, $value ) ) { 
508
+        foreach ($args['options'] as $key => $option):
509
+			$sanitize_key = wpinv_sanitize_key($key);
510
+			if (in_array($sanitize_key, $value)) { 
511 511
 				$enabled = $sanitize_key;
512 512
 			} else { 
513 513
 				$enabled = NULL; 
514 514
 			}
515
-			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;';
516
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
515
+			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;';
516
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
517 517
 		endforeach;
518 518
 		echo '</div>';
519 519
 		echo '<p class="description">' . $args['desc'] . '</p>';
520 520
 	}
521 521
 }
522 522
 
523
-function wpinv_payment_icons_callback( $args ) {
523
+function wpinv_payment_icons_callback($args) {
524 524
 	global $wpinv_options;
525 525
     
526
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
526
+    $sanitize_id = wpinv_sanitize_key($args['id']);
527 527
 
528
-	if ( ! empty( $args['options'] ) ) {
529
-		foreach( $args['options'] as $key => $option ) {
530
-            $sanitize_key = wpinv_sanitize_key( $key );
528
+	if (!empty($args['options'])) {
529
+		foreach ($args['options'] as $key => $option) {
530
+            $sanitize_key = wpinv_sanitize_key($key);
531 531
             
532
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
532
+			if (isset($wpinv_options[$args['id']][$key])) {
533 533
 				$enabled = $option;
534 534
 			} else {
535 535
 				$enabled = NULL;
@@ -537,197 +537,197 @@  discard block
 block discarded – undo
537 537
 
538 538
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
539 539
 
540
-				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;';
540
+				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;';
541 541
 
542
-				if ( wpinv_string_is_image_url( $key ) ) {
543
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
542
+				if (wpinv_string_is_image_url($key)) {
543
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
544 544
 				} else {
545
-					$card = strtolower( str_replace( ' ', '', $option ) );
545
+					$card = strtolower(str_replace(' ', '', $option));
546 546
 
547
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
548
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
547
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
548
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
549 549
 					} else {
550
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
550
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
551 551
 						$content_dir = WP_CONTENT_DIR;
552 552
 
553
-						if ( function_exists( 'wp_normalize_path' ) ) {
553
+						if (function_exists('wp_normalize_path')) {
554 554
 							// Replaces backslashes with forward slashes for Windows systems
555
-							$image = wp_normalize_path( $image );
556
-							$content_dir = wp_normalize_path( $content_dir );
555
+							$image = wp_normalize_path($image);
556
+							$content_dir = wp_normalize_path($content_dir);
557 557
 						}
558 558
 
559
-						$image = str_replace( $content_dir, content_url(), $image );
559
+						$image = str_replace($content_dir, content_url(), $image);
560 560
 					}
561 561
 
562
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
562
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
563 563
 				}
564 564
 			echo $option . '</label>';
565 565
 		}
566
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
566
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
567 567
 	}
568 568
 }
569 569
 
570
-function wpinv_radio_callback( $args ) {
570
+function wpinv_radio_callback($args) {
571 571
 	global $wpinv_options;
572 572
     
573
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
573
+    $sanitize_id = wpinv_sanitize_key($args['id']);
574 574
     
575
-    foreach ( $args['options'] as $key => $option ) :
576
-		$sanitize_key = wpinv_sanitize_key( $key );
575
+    foreach ($args['options'] as $key => $option) :
576
+		$sanitize_key = wpinv_sanitize_key($key);
577 577
         
578 578
         $checked = false;
579 579
 
580
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
580
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
581 581
 			$checked = true;
582
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
582
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
583 583
 			$checked = true;
584 584
 
585 585
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
586
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
586
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
587 587
 	endforeach;
588 588
 
589
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
589
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
590 590
 }
591 591
 
592
-function wpinv_gateways_callback( $args ) {
592
+function wpinv_gateways_callback($args) {
593 593
 	global $wpinv_options;
594 594
     
595
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
595
+    $sanitize_id = wpinv_sanitize_key($args['id']);
596 596
 
597
-	foreach ( $args['options'] as $key => $option ) :
598
-		$sanitize_key = wpinv_sanitize_key( $key );
597
+	foreach ($args['options'] as $key => $option) :
598
+		$sanitize_key = wpinv_sanitize_key($key);
599 599
         
600
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
600
+        if (isset($wpinv_options['gateways'][$key]))
601 601
 			$enabled = '1';
602 602
 		else
603 603
 			$enabled = null;
604 604
 
605
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
606
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
605
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
606
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
607 607
 	endforeach;
608 608
 }
609 609
 
610 610
 function wpinv_gateway_select_callback($args) {
611 611
 	global $wpinv_options;
612 612
     
613
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
614
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
613
+    $sanitize_id = wpinv_sanitize_key($args['id']);
614
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
615 615
 
616
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
616
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
617 617
 
618
-	foreach ( $args['options'] as $key => $option ) :
619
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
620
-            $selected = selected( $key, $args['selected'], false );
618
+	foreach ($args['options'] as $key => $option) :
619
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
620
+            $selected = selected($key, $args['selected'], false);
621 621
         } else {
622
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
622
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
623 623
         }
624
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
624
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
625 625
 	endforeach;
626 626
 
627 627
 	echo '</select>';
628
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
628
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
629 629
 }
630 630
 
631
-function wpinv_text_callback( $args ) {
631
+function wpinv_text_callback($args) {
632 632
 	global $wpinv_options;
633 633
     
634
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
634
+    $sanitize_id = wpinv_sanitize_key($args['id']);
635 635
 
636
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
637
-		$value = $wpinv_options[ $args['id'] ];
636
+	if (isset($wpinv_options[$args['id']])) {
637
+		$value = $wpinv_options[$args['id']];
638 638
 	} else {
639
-		$value = isset( $args['std'] ) ? $args['std'] : '';
639
+		$value = isset($args['std']) ? $args['std'] : '';
640 640
 	}
641 641
 
642
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
642
+	if (isset($args['faux']) && true === $args['faux']) {
643 643
 		$args['readonly'] = true;
644
-		$value = isset( $args['std'] ) ? $args['std'] : '';
644
+		$value = isset($args['std']) ? $args['std'] : '';
645 645
 		$name  = '';
646 646
 	} else {
647
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
647
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
648 648
 	}
649
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
649
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
650 650
 
651 651
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
652
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
653
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
654
-	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
652
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
653
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
654
+	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
655 655
 
656 656
 	echo $html;
657 657
 }
658 658
 
659
-function wpinv_number_callback( $args ) {
659
+function wpinv_number_callback($args) {
660 660
 	global $wpinv_options;
661 661
     
662
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
662
+    $sanitize_id = wpinv_sanitize_key($args['id']);
663 663
 
664
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
665
-		$value = $wpinv_options[ $args['id'] ];
664
+	if (isset($wpinv_options[$args['id']])) {
665
+		$value = $wpinv_options[$args['id']];
666 666
 	} else {
667
-		$value = isset( $args['std'] ) ? $args['std'] : '';
667
+		$value = isset($args['std']) ? $args['std'] : '';
668 668
 	}
669 669
 
670
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
670
+	if (isset($args['faux']) && true === $args['faux']) {
671 671
 		$args['readonly'] = true;
672
-		$value = isset( $args['std'] ) ? $args['std'] : '';
672
+		$value = isset($args['std']) ? $args['std'] : '';
673 673
 		$name  = '';
674 674
 	} else {
675
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
675
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
676 676
 	}
677 677
 
678
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
679
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
680
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
681
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
678
+	$max  = isset($args['max']) ? $args['max'] : 999999;
679
+	$min  = isset($args['min']) ? $args['min'] : 0;
680
+	$step = isset($args['step']) ? $args['step'] : 1;
681
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
682 682
 
683
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
684
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
685
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
683
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
684
+	$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>';
685
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
686 686
 
687 687
 	echo $html;
688 688
 }
689 689
 
690
-function wpinv_textarea_callback( $args ) {
690
+function wpinv_textarea_callback($args) {
691 691
 	global $wpinv_options;
692 692
     
693
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
693
+    $sanitize_id = wpinv_sanitize_key($args['id']);
694 694
 
695
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
696
-		$value = $wpinv_options[ $args['id'] ];
695
+	if (isset($wpinv_options[$args['id']])) {
696
+		$value = $wpinv_options[$args['id']];
697 697
 	} else {
698
-		$value = isset( $args['std'] ) ? $args['std'] : '';
698
+		$value = isset($args['std']) ? $args['std'] : '';
699 699
 	}
700 700
     
701
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
702
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
701
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
702
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
703 703
 
704
-	$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>';
705
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
704
+	$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>';
705
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
706 706
 
707 707
 	echo $html;
708 708
 }
709 709
 
710
-function wpinv_password_callback( $args ) {
710
+function wpinv_password_callback($args) {
711 711
 	global $wpinv_options;
712 712
     
713
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
713
+    $sanitize_id = wpinv_sanitize_key($args['id']);
714 714
 
715
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
716
-		$value = $wpinv_options[ $args['id'] ];
715
+	if (isset($wpinv_options[$args['id']])) {
716
+		$value = $wpinv_options[$args['id']];
717 717
 	} else {
718
-		$value = isset( $args['std'] ) ? $args['std'] : '';
718
+		$value = isset($args['std']) ? $args['std'] : '';
719 719
 	}
720 720
 
721
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
722
-	$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 ) . '"/>';
723
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
721
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
722
+	$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) . '"/>';
723
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
724 724
 
725 725
 	echo $html;
726 726
 }
727 727
 
728 728
 function wpinv_missing_callback($args) {
729 729
 	printf(
730
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
730
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
731 731
 		'<strong>' . $args['id'] . '</strong>'
732 732
 	);
733 733
 }
@@ -735,134 +735,134 @@  discard block
 block discarded – undo
735 735
 function wpinv_select_callback($args) {
736 736
 	global $wpinv_options;
737 737
     
738
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
738
+    $sanitize_id = wpinv_sanitize_key($args['id']);
739 739
 
740
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
741
-		$value = $wpinv_options[ $args['id'] ];
740
+	if (isset($wpinv_options[$args['id']])) {
741
+		$value = $wpinv_options[$args['id']];
742 742
 	} else {
743
-		$value = isset( $args['std'] ) ? $args['std'] : '';
743
+		$value = isset($args['std']) ? $args['std'] : '';
744 744
 	}
745 745
     
746
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
746
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
747 747
         $value = $args['selected'];
748 748
     }
749 749
 
750
-	if ( isset( $args['placeholder'] ) ) {
750
+	if (isset($args['placeholder'])) {
751 751
 		$placeholder = $args['placeholder'];
752 752
 	} else {
753 753
 		$placeholder = '';
754 754
 	}
755 755
     
756
-    if( !empty( $args['onchange'] ) ) {
757
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
756
+    if (!empty($args['onchange'])) {
757
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
758 758
     } else {
759 759
         $onchange = '';
760 760
     }
761 761
 
762
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
762
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
763 763
 
764
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
764
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '"  name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
765 765
 
766
-	foreach ( $args['options'] as $option => $name ) {
767
-		$selected = selected( $option, $value, false );
768
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
766
+	foreach ($args['options'] as $option => $name) {
767
+		$selected = selected($option, $value, false);
768
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
769 769
 	}
770 770
 
771 771
 	$html .= '</select>';
772
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
772
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
773 773
 
774 774
 	echo $html;
775 775
 }
776 776
 
777
-function wpinv_color_select_callback( $args ) {
777
+function wpinv_color_select_callback($args) {
778 778
 	global $wpinv_options;
779 779
     
780
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
780
+    $sanitize_id = wpinv_sanitize_key($args['id']);
781 781
 
782
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
783
-		$value = $wpinv_options[ $args['id'] ];
782
+	if (isset($wpinv_options[$args['id']])) {
783
+		$value = $wpinv_options[$args['id']];
784 784
 	} else {
785
-		$value = isset( $args['std'] ) ? $args['std'] : '';
785
+		$value = isset($args['std']) ? $args['std'] : '';
786 786
 	}
787 787
 
788
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
788
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
789 789
 
790
-	foreach ( $args['options'] as $option => $color ) {
791
-		$selected = selected( $option, $value, false );
792
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
790
+	foreach ($args['options'] as $option => $color) {
791
+		$selected = selected($option, $value, false);
792
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
793 793
 	}
794 794
 
795 795
 	$html .= '</select>';
796
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
796
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
797 797
 
798 798
 	echo $html;
799 799
 }
800 800
 
801
-function wpinv_rich_editor_callback( $args ) {
801
+function wpinv_rich_editor_callback($args) {
802 802
 	global $wpinv_options, $wp_version;
803 803
     
804
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
804
+    $sanitize_id = wpinv_sanitize_key($args['id']);
805 805
 
806
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
807
-		$value = $wpinv_options[ $args['id'] ];
806
+	if (isset($wpinv_options[$args['id']])) {
807
+		$value = $wpinv_options[$args['id']];
808 808
 
809
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
810
-			$value = isset( $args['std'] ) ? $args['std'] : '';
809
+		if (empty($args['allow_blank']) && empty($value)) {
810
+			$value = isset($args['std']) ? $args['std'] : '';
811 811
 		}
812 812
 	} else {
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
813
+		$value = isset($args['std']) ? $args['std'] : '';
814 814
 	}
815 815
 
816
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
816
+	$rows = isset($args['size']) ? $args['size'] : 20;
817 817
 
818 818
 	$html = '<div class="getpaid-settings-editor-input">';
819
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
819
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
820 820
 		ob_start();
821
-		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 ) );
821
+		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));
822 822
 		$html .= ob_get_clean();
823 823
 	} else {
824
-		$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>';
824
+		$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>';
825 825
 	}
826 826
 
827
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
827
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
828 828
 
829 829
 	echo $html;
830 830
 }
831 831
 
832
-function wpinv_upload_callback( $args ) {
832
+function wpinv_upload_callback($args) {
833 833
 	global $wpinv_options;
834 834
     
835
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
835
+    $sanitize_id = wpinv_sanitize_key($args['id']);
836 836
 
837
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
837
+	if (isset($wpinv_options[$args['id']])) {
838 838
 		$value = $wpinv_options[$args['id']];
839 839
 	} else {
840 840
 		$value = isset($args['std']) ? $args['std'] : '';
841 841
 	}
842 842
 
843
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
844
-	$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 ) ) . '"/>';
845
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
846
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
843
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
844
+	$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)) . '"/>';
845
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
846
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
847 847
 
848 848
 	echo $html;
849 849
 }
850 850
 
851
-function wpinv_color_callback( $args ) {
851
+function wpinv_color_callback($args) {
852 852
 	global $wpinv_options;
853 853
     
854
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
854
+    $sanitize_id = wpinv_sanitize_key($args['id']);
855 855
 
856
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
857
-		$value = $wpinv_options[ $args['id'] ];
856
+	if (isset($wpinv_options[$args['id']])) {
857
+		$value = $wpinv_options[$args['id']];
858 858
 	} else {
859
-		$value = isset( $args['std'] ) ? $args['std'] : '';
859
+		$value = isset($args['std']) ? $args['std'] : '';
860 860
 	}
861 861
 
862
-	$default = isset( $args['std'] ) ? $args['std'] : '';
862
+	$default = isset($args['std']) ? $args['std'] : '';
863 863
 
864
-	$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 ) . '" />';
865
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
864
+	$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) . '" />';
865
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
866 866
 
867 867
 	echo $html;
868 868
 }
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
 function wpinv_country_states_callback($args) {
871 871
 	global $wpinv_options;
872 872
     
873
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
873
+    $sanitize_id = wpinv_sanitize_key($args['id']);
874 874
 
875
-	if ( isset( $args['placeholder'] ) ) {
875
+	if (isset($args['placeholder'])) {
876 876
 		$placeholder = $args['placeholder'];
877 877
 	} else {
878 878
 		$placeholder = '';
@@ -880,16 +880,16 @@  discard block
 block discarded – undo
880 880
 
881 881
 	$states = wpinv_get_country_states();
882 882
 
883
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
883
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
885 885
 
886
-	foreach ( $states as $option => $name ) {
887
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
888
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
886
+	foreach ($states as $option => $name) {
887
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
888
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
889 889
 	}
890 890
 
891 891
 	$html .= '</select>';
892
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
893 893
 
894 894
 	echo $html;
895 895
 }
@@ -904,96 +904,96 @@  discard block
 block discarded – undo
904 904
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
905 905
 		<thead>
906 906
 			<tr>
907
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
908
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
909
-                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
910
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
911
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
912
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
907
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
908
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
909
+                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
910
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
911
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
912
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
913 913
 			</tr>
914 914
 		</thead>
915 915
         <tbody>
916
-		<?php if( !empty( $rates ) ) : ?>
917
-			<?php foreach( $rates as $key => $rate ) : ?>
916
+		<?php if (!empty($rates)) : ?>
917
+			<?php foreach ($rates as $key => $rate) : ?>
918 918
             <?php 
919
-            $sanitized_key = wpinv_sanitize_key( $key );
919
+            $sanitized_key = wpinv_sanitize_key($key);
920 920
             ?>
921 921
 			<tr>
922 922
 				<td class="wpinv_tax_country">
923 923
 					<?php
924
-					echo wpinv_html_select( array(
925
-						'options'          => wpinv_get_country_list( true ),
924
+					echo wpinv_html_select(array(
925
+						'options'          => wpinv_get_country_list(true),
926 926
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
927 927
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
928 928
 						'selected'         => $rate['country'],
929 929
 						'show_option_all'  => false,
930 930
 						'show_option_none' => false,
931 931
 						'class'            => 'wpinv-tax-country wpi_select2',
932
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
933
-					) );
932
+						'placeholder'      => __('Choose a country', 'invoicing')
933
+					));
934 934
 					?>
935 935
 				</td>
936 936
 				<td class="wpinv_tax_state">
937 937
 					<?php
938
-					$states = wpinv_get_country_states( $rate['country'] );
939
-					if( !empty( $states ) ) {
940
-						echo wpinv_html_select( array(
941
-							'options'          => array_merge( array( '' => '' ), $states ),
938
+					$states = wpinv_get_country_states($rate['country']);
939
+					if (!empty($states)) {
940
+						echo wpinv_html_select(array(
941
+							'options'          => array_merge(array('' => ''), $states),
942 942
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
943 943
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
944 944
 							'selected'         => $rate['state'],
945 945
 							'show_option_all'  => false,
946 946
 							'show_option_none' => false,
947 947
                             'class'            => 'wpi_select2',
948
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
949
-						) );
948
+							'placeholder'      => __('Choose a state', 'invoicing')
949
+						));
950 950
 					} else {
951
-						echo wpinv_html_text( array(
951
+						echo wpinv_html_text(array(
952 952
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
953
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
953
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
954 954
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
955
-						) );
955
+						));
956 956
 					}
957 957
 					?>
958 958
 				</td>
959 959
 				<td class="wpinv_tax_global">
960
-					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
961
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
960
+					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/>
961
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
962 962
 				</td>
963
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
964
-                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td>
965
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
963
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td>
964
+                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td>
965
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
966 966
 			</tr>
967 967
 			<?php endforeach; ?>
968 968
 		<?php else : ?>
969 969
 			<tr>
970 970
 				<td class="wpinv_tax_country">
971 971
 					<?php
972
-					echo wpinv_html_select( array(
973
-						'options'          => wpinv_get_country_list( true ),
972
+					echo wpinv_html_select(array(
973
+						'options'          => wpinv_get_country_list(true),
974 974
 						'name'             => 'tax_rates[0][country]',
975 975
 						'show_option_all'  => false,
976 976
 						'show_option_none' => false,
977 977
 						'class'            => 'wpinv-tax-country wpi_select2',
978
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
979
-					) ); ?>
978
+						'placeholder'      => __('Choose a country', 'invoicing')
979
+					)); ?>
980 980
 				</td>
981 981
 				<td class="wpinv_tax_state">
982
-					<?php echo wpinv_html_text( array(
982
+					<?php echo wpinv_html_text(array(
983 983
 						'name' => 'tax_rates[0][state]'
984
-					) ); ?>
984
+					)); ?>
985 985
 				</td>
986 986
 				<td class="wpinv_tax_global">
987 987
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
988
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
988
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
989 989
 				</td>
990
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td>
990
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float) wpinv_get_option('tax_rate', 0); ?>"/></td>
991 991
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
992
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
992
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
993 993
 			</tr>
994 994
 		<?php endif; ?>
995 995
         </tbody>
996
-        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
996
+        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot>
997 997
 	</table>
998 998
 	<?php
999 999
 	echo ob_get_clean();
@@ -1004,76 +1004,76 @@  discard block
 block discarded – undo
1004 1004
     ob_start(); ?>
1005 1005
     </td><tr>
1006 1006
     <td colspan="2" class="wpinv_tools_tdbox">
1007
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1008
-    <?php do_action( 'wpinv_tools_before' ); ?>
1007
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1008
+    <?php do_action('wpinv_tools_before'); ?>
1009 1009
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1010 1010
         <thead>
1011 1011
             <tr>
1012
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1013
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1014
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1012
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1013
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1014
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1015 1015
             </tr>
1016 1016
         </thead>
1017
-            <?php do_action( 'wpinv_tools_row' ); ?>
1017
+            <?php do_action('wpinv_tools_row'); ?>
1018 1018
         <tbody>
1019 1019
         </tbody>
1020 1020
     </table>
1021
-    <?php do_action( 'wpinv_tools_after' ); ?>
1021
+    <?php do_action('wpinv_tools_after'); ?>
1022 1022
     <?php
1023 1023
     echo ob_get_clean();
1024 1024
 }
1025 1025
 
1026
-function wpinv_descriptive_text_callback( $args ) {
1027
-	echo wp_kses_post( $args['desc'] );
1026
+function wpinv_descriptive_text_callback($args) {
1027
+	echo wp_kses_post($args['desc']);
1028 1028
 }
1029 1029
 
1030
-function wpinv_hook_callback( $args ) {
1031
-	do_action( 'wpinv_' . $args['id'], $args );
1030
+function wpinv_hook_callback($args) {
1031
+	do_action('wpinv_' . $args['id'], $args);
1032 1032
 }
1033 1033
 
1034 1034
 function wpinv_set_settings_cap() {
1035 1035
 	return wpinv_get_capability();
1036 1036
 }
1037
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1037
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1038 1038
 
1039
-function wpinv_settings_sanitize_input( $value, $key ) {
1040
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1041
-        $value = wpinv_sanitize_amount( $value, 4 );
1039
+function wpinv_settings_sanitize_input($value, $key) {
1040
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1041
+        $value = wpinv_sanitize_amount($value, 4);
1042 1042
         $value = $value >= 100 ? 99 : $value;
1043 1043
     }
1044 1044
         
1045 1045
     return $value;
1046 1046
 }
1047
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1047
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1048 1048
 
1049
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1050
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1051
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1049
+function wpinv_on_update_settings($old_value, $value, $option) {
1050
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1051
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1052 1052
     
1053
-    if ( $old != $new ) {
1054
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1053
+    if ($old != $new) {
1054
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1055 1055
     }
1056 1056
 }
1057
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1058
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1059
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1060
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1061
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1062
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1063
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1064
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1065
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1066
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1067
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1068
-
1069
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1057
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1058
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1059
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1060
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1061
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1062
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1063
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1064
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1065
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1066
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1067
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1068
+
1069
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1070 1070
     ?>
1071 1071
     <div class="wpinv-email-wc-row ">
1072 1072
         <div class="wpinv-email-wc-td">
1073
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1073
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1074 1074
             <p class="wpinv-email-wc-description">
1075 1075
                 <?php
1076
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1076
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1077 1077
                     <strong>{site_title} :</strong> Site Title<br>
1078 1078
                     <strong>{name} :</strong> Customer\'s full name<br>
1079 1079
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1088 1088
                     <strong>{date} :</strong> Today\'s date.<br>
1089 1089
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1090
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1090
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1091 1091
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1092 1092
                 ?>
1093 1093
             </p>
Please login to merge, or discard this patch.