Passed
Push — master ( 760759...814197 )
by Brian
04:26
created
includes/wpinv-address-functions.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+    $country = wpinv_get_option( 'default_country', 'UK' );
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+    return apply_filters( 'wpinv_default_country', $country );
19 19
 }
20 20
 
21 21
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function wpinv_sanitize_country( $country ) {
38 38
 
39
-	// Enure the country is specified
39
+    // Enure the country is specified
40 40
     if ( empty( $country ) ) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+    $state = wpinv_get_option( 'default_state', '' );
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+    return apply_filters( 'wpinv_default_state', $state );
72 72
 }
73 73
 
74 74
 function wpinv_state_name( $state_code = '', $country_code = '' ) {
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
 
306 306
     $country = wpinv_sanitize_country( $country );
307 307
     
308
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
309
-		if ( false !== array_search( $country, $countries, true ) ) {
310
-			return $continent_code;
311
-		}
312
-	}
308
+    foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
309
+        if ( false !== array_search( $country, $countries, true ) ) {
310
+            return $continent_code;
311
+        }
312
+    }
313 313
 
314 314
     return '';
315 315
     
@@ -601,33 +601,33 @@  discard block
 block discarded – undo
601 601
 }
602 602
 
603 603
 function wpinv_get_states_field() {
604
-	if( empty( $_POST['country'] ) ) {
605
-		$_POST['country'] = wpinv_get_default_country();
606
-	}
607
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
604
+    if( empty( $_POST['country'] ) ) {
605
+        $_POST['country'] = wpinv_get_default_country();
606
+    }
607
+    $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
608 608
 
609
-	if( !empty( $states ) ) {
610
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
609
+    if( !empty( $states ) ) {
610
+        $sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
611 611
 
612 612
         $class  = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : '';
613 613
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
614 614
 
615 615
         $args  = array(
616
-			'name'    => $sanitized_field_name,
617
-			'id'      => $sanitized_field_name,
618
-			'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
619
-			'options' => array_merge( array( '' => '' ), $states ),
620
-			'show_option_all'  => false,
621
-			'show_option_none' => false
622
-		);
623
-
624
-		$response = wpinv_html_select( $args );
625
-
626
-	} else {
627
-		$response = 'nostates';
628
-	}
616
+            'name'    => $sanitized_field_name,
617
+            'id'      => $sanitized_field_name,
618
+            'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
619
+            'options' => array_merge( array( '' => '' ), $states ),
620
+            'show_option_all'  => false,
621
+            'show_option_none' => false
622
+        );
623
+
624
+        $response = wpinv_html_select( $args );
625
+
626
+    } else {
627
+        $response = 'nostates';
628
+    }
629 629
 
630
-	return $response;
630
+    return $response;
631 631
 }
632 632
 
633 633
 function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
@@ -645,46 +645,46 @@  discard block
 block discarded – undo
645 645
  */
646 646
 function wpinv_get_address_formats() {
647 647
 
648
-		return apply_filters( 'wpinv_localisation_address_formats',
649
-			array(
650
-				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
651
-				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
652
-				'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
653
-				'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
-				'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}  {{zip}}\n{{country}}",
655
-				'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
656
-				'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
657
-				'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
658
-				'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
-				'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
-				'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
-				'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
662
-				'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
663
-				'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
664
-				'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
665
-				'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
666
-				'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
667
-				'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
668
-				'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
669
-				'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
670
-				'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
671
-				'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
672
-				'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
-				'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
674
-				'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
-				'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
-				'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
-				'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
-				'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
679
-				'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
-				'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
681
-				'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
682
-				'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
683
-				'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
684
-				'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
685
-				'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
686
-			)
687
-		);
648
+        return apply_filters( 'wpinv_localisation_address_formats',
649
+            array(
650
+                'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
651
+                'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
652
+                'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
653
+                'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
+                'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}  {{zip}}\n{{country}}",
655
+                'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
656
+                'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
657
+                'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
658
+                'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
+                'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
+                'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
+                'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
662
+                'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
663
+                'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
664
+                'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
665
+                'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
666
+                'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
667
+                'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
668
+                'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
669
+                'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
670
+                'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
671
+                'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
672
+                'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
+                'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
674
+                'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
+                'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
+                'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
+                'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
+                'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
679
+                'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
+                'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
681
+                'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
682
+                'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
683
+                'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
684
+                'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
685
+                'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
686
+            )
687
+        );
688 688
 }
689 689
 
690 690
 /**
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
     }
702 702
 
703 703
     // Get all formats.
704
-	$formats = wpinv_get_address_formats();
704
+    $formats = wpinv_get_address_formats();
705 705
 
706
-	// Get format for the specified country.
707
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
706
+    // Get format for the specified country.
707
+    $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
708 708
     
709 709
     /**
710
-	 * Filters the address format to use on Invoices.
710
+     * Filters the address format to use on Invoices.
711 711
      * 
712 712
      * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed.
713
-	 *
714
-	 * @since 1.0.13
715
-	 *
716
-	 * @param string $format  The address format to use.
713
+     *
714
+     * @since 1.0.13
715
+     *
716
+     * @param string $format  The address format to use.
717 717
      * @param string $country The country who's address format is being retrieved.
718
-	 */
718
+     */
719 719
     return apply_filters( 'wpinv_get_full_address_format', $format, $country );
720 720
 }
721 721
 
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
         'country'           => '',
737 737
         'zip'               => '',
738 738
         'first_name'        => '',
739
-		'last_name'         => '',
740
-		'company'           => '',
739
+        'last_name'         => '',
740
+        'company'           => '',
741 741
     );
742 742
 
743 743
     $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
     $args['country_code']= $country;
759 759
 
760 760
     /**
761
-	 * Filters the address format replacements to use on Invoices.
761
+     * Filters the address format replacements to use on Invoices.
762 762
      * 
763
-	 *
764
-	 * @since 1.0.13
765
-	 *
766
-	 * @param array $replacements  The address replacements to use.
763
+     *
764
+     * @since 1.0.13
765
+     *
766
+     * @param array $replacements  The address replacements to use.
767 767
      * @param array $billing_details  The billing details to use.
768
-	 */
768
+     */
769 769
     $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
770 770
 
771 771
     $return = array();
@@ -788,5 +788,5 @@  discard block
 block discarded – undo
788 788
  * @return string
789 789
  */
790 790
 function wpinv_trim_formatted_address_line( $line ) {
791
-	return trim( $line, ', ' );
791
+    return trim( $line, ', ' );
792 792
 }
793 793
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+	$country = wpinv_get_option('default_country', 'UK');
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+	return apply_filters('wpinv_default_country', $country);
19 19
 }
20 20
 
21 21
 /**
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string
25 25
  */
26
-function getpaid_get_ip_country( $ip_address = '' ) {
27
-    $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true );
26
+function getpaid_get_ip_country($ip_address = '') {
27
+    $country = GetPaid_Geolocation::geolocate_ip($ip_address, true);
28 28
     return $country['country'];
29 29
 }
30 30
 
@@ -34,59 +34,59 @@  discard block
 block discarded – undo
34 34
  * @param string $country The country code to sanitize
35 35
  * @return array
36 36
  */
37
-function wpinv_sanitize_country( $country ) {
37
+function wpinv_sanitize_country($country) {
38 38
 
39 39
 	// Enure the country is specified
40
-    if ( empty( $country ) ) {
40
+    if (empty($country)) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
43
-    return trim( wpinv_utf8_strtoupper( $country ) );
43
+    return trim(wpinv_utf8_strtoupper($country));
44 44
 
45 45
 }
46 46
 
47
-function wpinv_is_base_country( $country ) {
47
+function wpinv_is_base_country($country) {
48 48
     $base_country = wpinv_get_default_country();
49 49
     
50
-    if ( $base_country === 'UK' ) {
50
+    if ($base_country === 'UK') {
51 51
         $base_country = 'GB';
52 52
     }
53
-    if ( $country == 'UK' ) {
53
+    if ($country == 'UK') {
54 54
         $country = 'GB';
55 55
     }
56 56
 
57
-    return ( $country && $country === $base_country ) ? true : false;
57
+    return ($country && $country === $base_country) ? true : false;
58 58
 }
59 59
 
60
-function wpinv_country_name( $country_code = '' ) { 
60
+function wpinv_country_name($country_code = '') { 
61 61
     $countries = wpinv_get_country_list();
62 62
     $country_code = $country_code == 'UK' ? 'GB' : $country_code;
63
-    $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code;
63
+    $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code;
64 64
 
65
-    return apply_filters( 'wpinv_country_name', $country, $country_code );
65
+    return apply_filters('wpinv_country_name', $country, $country_code);
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+	$state = wpinv_get_option('default_state', '');
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+	return apply_filters('wpinv_default_state', $state);
72 72
 }
73 73
 
74
-function wpinv_state_name( $state_code = '', $country_code = '' ) {
74
+function wpinv_state_name($state_code = '', $country_code = '') {
75 75
     $state = $state_code;
76 76
     
77
-    if ( !empty( $country_code ) ) {
78
-        $states = wpinv_get_country_states( $country_code );
77
+    if (!empty($country_code)) {
78
+        $states = wpinv_get_country_states($country_code);
79 79
         
80
-        $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state;
80
+        $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state;
81 81
     }
82 82
 
83
-    return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code );
83
+    return apply_filters('wpinv_state_name', $state, $state_code, $country_code);
84 84
 }
85 85
 
86 86
 function wpinv_store_address() {
87
-    $address = wpinv_get_option( 'store_address', '' );
87
+    $address = wpinv_get_option('store_address', '');
88 88
 
89
-    return apply_filters( 'wpinv_store_address', $address );
89
+    return apply_filters('wpinv_store_address', $address);
90 90
 }
91 91
 
92 92
 /**
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  *
95 95
  * @param WPInv_Invoice $invoice
96 96
  */
97
-function getpaid_maybe_add_default_address( &$invoice ) {
97
+function getpaid_maybe_add_default_address(&$invoice) {
98 98
 
99 99
     $user_id = $invoice->get_user_id();
100 100
 
101 101
     // Abort if the invoice belongs to no one.
102
-    if ( empty( $user_id ) ) {
102
+    if (empty($user_id)) {
103 103
         return;
104 104
     }
105 105
 
106 106
     // Fill in defaults whenever necessary.
107
-    foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) {
107
+    foreach (wpinv_get_user_address($user_id) as $key => $value) {
108 108
 
109
-        if ( is_callable( $invoice, "get_$key" ) ) {
110
-            $current = call_user_func( array( $invoice, "get_$key" ) );
109
+        if (is_callable($invoice, "get_$key")) {
110
+            $current = call_user_func(array($invoice, "get_$key"));
111 111
 
112
-            if ( empty( $current ) ) {
112
+            if (empty($current)) {
113 113
                 $method = "set_$key";
114
-                $invoice->$method( $value );
114
+                $invoice->$method($value);
115 115
             }
116 116
 
117 117
         }
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
     $address_fields = apply_filters(
131 131
         'getpaid_user_address_fields',
132 132
         array(
133
-            'first_name' => __( 'First Name', 'invoicing' ),
134
-            'last_name'  => __( 'Last Name', 'invoicing' ),
135
-            'address'    => __( 'Address', 'invoicing' ),
136
-            'city'       => __( 'City', 'invoicing' ),
137
-            'country'    => __( 'Country', 'invoicing' ),
138
-            'state'      => __( 'State', 'invoicing' ),
139
-            'zip'        => __( 'Zip/Postal Code', 'invoicing' ),
140
-            'phone'      => __( 'Phone Number', 'invoicing' ),
141
-            'company'    => __( 'Company', 'invoicing' ),
142
-            'vat_number' => __( 'VAT Number', 'invoicing' ),
133
+            'first_name' => __('First Name', 'invoicing'),
134
+            'last_name'  => __('Last Name', 'invoicing'),
135
+            'address'    => __('Address', 'invoicing'),
136
+            'city'       => __('City', 'invoicing'),
137
+            'country'    => __('Country', 'invoicing'),
138
+            'state'      => __('State', 'invoicing'),
139
+            'zip'        => __('Zip/Postal Code', 'invoicing'),
140
+            'phone'      => __('Phone Number', 'invoicing'),
141
+            'company'    => __('Company', 'invoicing'),
142
+            'vat_number' => __('VAT Number', 'invoicing'),
143 143
         )
144 144
     );
145 145
 
146
-    if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) {
147
-        unset( $address_fields['vat_number'] );
146
+    if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) {
147
+        unset($address_fields['vat_number']);
148 148
     }
149 149
 
150 150
     return $address_fields;
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
  * 
156 156
  * @return bool
157 157
  */
158
-function getpaid_is_address_field_whitelisted( $key ) {
159
-    return array_key_exists( $key, getpaid_user_address_fields() );
158
+function getpaid_is_address_field_whitelisted($key) {
159
+    return array_key_exists($key, getpaid_user_address_fields());
160 160
 }
161 161
 
162 162
 /**
@@ -166,24 +166,24 @@  discard block
 block discarded – undo
166 166
  *
167 167
  * @param WPInv_Invoice $invoice
168 168
  */
169
-function getpaid_save_invoice_user_address( $invoice ) {
169
+function getpaid_save_invoice_user_address($invoice) {
170 170
 
171 171
     // Retrieve the invoice.
172
-    $invoice = wpinv_get_invoice( $invoice );
172
+    $invoice = wpinv_get_invoice($invoice);
173 173
 
174 174
     // Abort if it does not exist.
175
-    if ( empty( $invoice ) || $invoice->is_renewal() ) {
175
+    if (empty($invoice) || $invoice->is_renewal()) {
176 176
         return;
177 177
     }
178 178
 
179
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
179
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
180 180
 
181
-        if ( is_callable( array( $invoice, "get_$field" ) ) ) {
182
-            $value = call_user_func( array( $invoice, "get_$field" ) );
181
+        if (is_callable(array($invoice, "get_$field"))) {
182
+            $value = call_user_func(array($invoice, "get_$field"));
183 183
 
184 184
             // Only save if it is not empty.
185
-            if ( ! empty( $value ) ) {
186
-                update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value );
185
+            if (!empty($value)) {
186
+                update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value);
187 187
             }
188 188
 
189 189
         }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
 }
194
-add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' );
194
+add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address');
195 195
 
196 196
 /**
197 197
  * Retrieves a saved user address.
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
  * @param bool $with_default Whether or not we should use the default country and state.
201 201
  * @return array
202 202
  */
203
-function wpinv_get_user_address( $user_id = 0, $with_default = true ) {
203
+function wpinv_get_user_address($user_id = 0, $with_default = true) {
204 204
 
205 205
     // Prepare the user id.
206
-    $user_id   = empty( $user_id ) ? get_current_user_id() : $user_id;
207
-    $user_info = get_userdata( $user_id );
206
+    $user_id   = empty($user_id) ? get_current_user_id() : $user_id;
207
+    $user_info = get_userdata($user_id);
208 208
 
209 209
     // Abort if non exists.
210
-    if ( empty( $user_info ) ) {
210
+    if (empty($user_info)) {
211 211
         return array();
212 212
     }
213 213
 
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
         'email'   => $user_info->user_email,
218 218
     );
219 219
 
220
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
221
-        $address[$field] = getpaid_get_user_address_field( $user_id, $field );
220
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
221
+        $address[$field] = getpaid_get_user_address_field($user_id, $field);
222 222
     }
223 223
 
224
-    if ( ! $with_default ) {
224
+    if (!$with_default) {
225 225
         return $address;
226 226
     }
227 227
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         'country'    => wpinv_get_default_country(),
233 233
     );
234 234
 
235
-    return getpaid_array_merge_if_empty( $address, $defaults );
235
+    return getpaid_array_merge_if_empty($address, $defaults);
236 236
 
237 237
 }
238 238
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
  * @param string $field The field to use.
244 244
  * @return string|null
245 245
  */
246
-function getpaid_get_user_address_field( $user_id, $field ) {
246
+function getpaid_get_user_address_field($user_id, $field) {
247 247
 
248 248
     $prefixes = array(
249 249
         '_wpinv_',
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
         ''
252 252
     );
253 253
 
254
-    foreach ( $prefixes as $prefix ) {
254
+    foreach ($prefixes as $prefix) {
255 255
 
256 256
         // Meta table.
257
-        $value = get_user_meta( $user_id, $prefix . $field, true );
257
+        $value = get_user_meta($user_id, $prefix . $field, true);
258 258
         
259 259
         // UWP table.
260
-        $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
260
+        $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
261 261
 
262
-        if ( ! empty( $value ) ) {
262
+        if (!empty($value)) {
263 263
             return $value;
264 264
         }
265 265
 
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
  * @param string $return What to return.
277 277
  * @return array
278 278
  */
279
-function wpinv_get_continents( $return = 'all' ) {
279
+function wpinv_get_continents($return = 'all') {
280 280
 
281
-    $continents = wpinv_get_data( 'continents' );
281
+    $continents = wpinv_get_data('continents');
282 282
 
283
-    switch( $return ) {
283
+    switch ($return) {
284 284
         case 'name' :
285
-            return wp_list_pluck( $continents, 'name' );
285
+            return wp_list_pluck($continents, 'name');
286 286
             break;
287 287
         case 'countries' :
288
-            return wp_list_pluck( $continents, 'countries' );
288
+            return wp_list_pluck($continents, 'countries');
289 289
             break;
290 290
         default :
291 291
             return $continents;
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
  * @param string $country Country code. If no code is specified, defaults to the default country.
302 302
  * @return string
303 303
  */
304
-function wpinv_get_continent_code_for_country( $country = false ) {
304
+function wpinv_get_continent_code_for_country($country = false) {
305 305
 
306
-    $country = wpinv_sanitize_country( $country );
306
+    $country = wpinv_sanitize_country($country);
307 307
     
308
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
309
-		if ( false !== array_search( $country, $countries, true ) ) {
308
+	foreach (wpinv_get_continents('countries') as $continent_code => $countries) {
309
+		if (false !== array_search($country, $countries, true)) {
310 310
 			return $continent_code;
311 311
 		}
312 312
 	}
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
  * @param string $country Country code. If no code is specified, defaults to the default country.
323 323
  * @return array
324 324
  */
325
-function wpinv_get_country_calling_code( $country = null) {
325
+function wpinv_get_country_calling_code($country = null) {
326 326
 
327
-    $country = wpinv_sanitize_country( $country );
328
-    $codes   = wpinv_get_data( 'phone-codes' );
329
-    $code    = isset( $codes[ $country ] ) ? $codes[ $country ] : '';
327
+    $country = wpinv_sanitize_country($country);
328
+    $codes   = wpinv_get_data('phone-codes');
329
+    $code    = isset($codes[$country]) ? $codes[$country] : '';
330 330
 
331
-    if ( is_array( $code ) ) {
331
+    if (is_array($code)) {
332 332
         return $code[0];
333 333
     }
334 334
     return $code;
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
  * @param bool $first_empty Whether or not the first item in the list should be empty
342 342
  * @return array
343 343
  */
344
-function wpinv_get_country_list( $first_empty = false ) {
345
-    return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty );
344
+function wpinv_get_country_list($first_empty = false) {
345
+    return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty);
346 346
 }
347 347
 
348 348
 /**
@@ -352,22 +352,22 @@  discard block
 block discarded – undo
352 352
  * @param bool $first_empty Whether or not the first item in the list should be empty
353 353
  * @return array
354 354
  */
355
-function wpinv_get_country_states( $country = null, $first_empty = false ) {
355
+function wpinv_get_country_states($country = null, $first_empty = false) {
356 356
     
357 357
     // Prepare the country.
358
-    $country = wpinv_sanitize_country( $country );
358
+    $country = wpinv_sanitize_country($country);
359 359
 
360 360
     // Fetch all states.
361
-    $all_states = wpinv_get_data( 'states' );
361
+    $all_states = wpinv_get_data('states');
362 362
 
363 363
     // Fetch the specified country's states.
364
-    $states     = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ;
365
-    $states     = apply_filters( "wpinv_{$country}_states", $states );
366
-    $states     = apply_filters( 'wpinv_country_states', $states, $country );
364
+    $states     = isset($all_states[$country]) ? $all_states[$country] : array();
365
+    $states     = apply_filters("wpinv_{$country}_states", $states);
366
+    $states     = apply_filters('wpinv_country_states', $states, $country);
367 367
 
368
-    asort( $states );
368
+    asort($states);
369 369
      
370
-    return wpinv_maybe_add_empty_option( $states, $first_empty );
370
+    return wpinv_maybe_add_empty_option($states, $first_empty);
371 371
 }
372 372
 
373 373
 /**
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
  * @return array
378 378
  */
379 379
 function wpinv_get_us_states_list() {
380
-    return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) );
380
+    return apply_filters('wpinv_usa_states', wpinv_get_country_states('US'));
381 381
 }
382 382
 
383 383
 /**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
  * @return array
388 388
  */
389 389
 function wpinv_get_canada_states_list() {
390
-    return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) );
390
+    return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA'));
391 391
 }
392 392
 
393 393
 /**
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
  * @return array
398 398
  */
399 399
 function wpinv_get_australia_states_list() {
400
-    return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) );
400
+    return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU'));
401 401
 }
402 402
 
403 403
 /**
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
  * @return array
408 408
  */
409 409
 function wpinv_get_bangladesh_states_list() {
410
-    return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) );
410
+    return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD'));
411 411
 }
412 412
 
413 413
 /**
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
  * @return array
418 418
  */
419 419
 function wpinv_get_brazil_states_list() {
420
-    return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) );
420
+    return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR'));
421 421
 }
422 422
 
423 423
 /**
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
  * @return array
428 428
  */
429 429
 function wpinv_get_bulgaria_states_list() {
430
-    return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) );
430
+    return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG'));
431 431
 }
432 432
 
433 433
 /**
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
  * @return array
438 438
  */
439 439
 function wpinv_get_hong_kong_states_list() {
440
-    return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) );
440
+    return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK'));
441 441
 }
442 442
 
443 443
 /**
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
  * @return array
448 448
  */
449 449
 function wpinv_get_hungary_states_list() {
450
-    return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) );
450
+    return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU'));
451 451
 }
452 452
 
453 453
 /**
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
  * @return array
458 458
  */
459 459
 function wpinv_get_japan_states_list() {
460
-    return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) );
460
+    return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP'));
461 461
 }
462 462
 
463 463
 /**
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
  * @return array
468 468
  */
469 469
 function wpinv_get_china_states_list() {
470
-    return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) );
470
+    return apply_filters('wpinv_china_states', wpinv_get_country_states('CN'));
471 471
 }
472 472
 
473 473
 /**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
  * @return array
478 478
  */
479 479
 function wpinv_get_new_zealand_states_list() {
480
-    return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) );
480
+    return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ'));
481 481
 }
482 482
 
483 483
 /**
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
  * @return array
488 488
  */
489 489
 function wpinv_get_peru_states_list() {
490
-    return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) );
490
+    return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE'));
491 491
 }
492 492
 
493 493
 /**
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
  * @return array
498 498
  */
499 499
 function wpinv_get_indonesia_states_list() {
500
-    return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) );
500
+    return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID'));
501 501
 }
502 502
 
503 503
 /**
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
  * @return array
508 508
  */
509 509
 function wpinv_get_india_states_list() {
510
-    return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) );
510
+    return apply_filters('wpinv_india_states', wpinv_get_country_states('IN'));
511 511
 }
512 512
 
513 513
 /**
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
  * @return array
518 518
  */
519 519
 function wpinv_get_iran_states_list() {
520
-    return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) );
520
+    return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR'));
521 521
 }
522 522
 
523 523
 /**
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
  * @return array
528 528
  */
529 529
 function wpinv_get_italy_states_list() {
530
-    return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) );
530
+    return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT'));
531 531
 }
532 532
 
533 533
 /**
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
  * @return array
538 538
  */
539 539
 function wpinv_get_malaysia_states_list() {
540
-    return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) );
540
+    return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY'));
541 541
 }
542 542
 
543 543
 /**
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
  * @return array
548 548
  */
549 549
 function wpinv_get_mexico_states_list() {
550
-    return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) );
550
+    return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX'));
551 551
 }
552 552
 
553 553
 /**
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
  * @return array
558 558
  */
559 559
 function wpinv_get_nepal_states_list() {
560
-    return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) );
560
+    return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP'));
561 561
 }
562 562
 
563 563
 /**
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
  * @return array
568 568
  */
569 569
 function wpinv_get_south_africa_states_list() {
570
-    return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) );
570
+    return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA'));
571 571
 }
572 572
 
573 573
 /**
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
  * @return array
578 578
  */
579 579
 function wpinv_get_thailand_states_list() {
580
-    return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) );
580
+    return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH'));
581 581
 }
582 582
 
583 583
 /**
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
  * @return array
588 588
  */
589 589
 function wpinv_get_turkey_states_list() {
590
-    return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) );
590
+    return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR'));
591 591
 }
592 592
 
593 593
 /**
@@ -597,31 +597,31 @@  discard block
 block discarded – undo
597 597
  * @return array
598 598
  */
599 599
 function wpinv_get_spain_states_list() {
600
-    return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) );
600
+    return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES'));
601 601
 }
602 602
 
603 603
 function wpinv_get_states_field() {
604
-	if( empty( $_POST['country'] ) ) {
604
+	if (empty($_POST['country'])) {
605 605
 		$_POST['country'] = wpinv_get_default_country();
606 606
 	}
607
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
607
+	$states = wpinv_get_country_states(sanitize_text_field($_POST['country']));
608 608
 
609
-	if( !empty( $states ) ) {
610
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
609
+	if (!empty($states)) {
610
+		$sanitized_field_name = sanitize_text_field($_POST['field_name']);
611 611
 
612
-        $class  = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : '';
612
+        $class  = isset($_POST['class']) ? esc_attr($_POST['class']) : '';
613 613
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
614 614
 
615
-        $args  = array(
615
+        $args = array(
616 616
 			'name'    => $sanitized_field_name,
617 617
 			'id'      => $sanitized_field_name,
618
-			'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
619
-			'options' => array_merge( array( '' => '' ), $states ),
618
+			'class'   => implode(' ', array_unique(explode(' ', $class))),
619
+			'options' => array_merge(array('' => ''), $states),
620 620
 			'show_option_all'  => false,
621 621
 			'show_option_none' => false
622 622
 		);
623 623
 
624
-		$response = wpinv_html_select( $args );
624
+		$response = wpinv_html_select($args);
625 625
 
626 626
 	} else {
627 627
 		$response = 'nostates';
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
 	return $response;
631 631
 }
632 632
 
633
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
634
-    $country = !empty( $country ) ? $country : wpinv_get_default_country();
633
+function wpinv_default_billing_country($country = '', $user_id = 0) {
634
+    $country = !empty($country) ? $country : wpinv_get_default_country();
635 635
     
636
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
636
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
637 637
 }
638 638
 
639 639
 /**
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
  */
646 646
 function wpinv_get_address_formats() {
647 647
 
648
-		return apply_filters( 'wpinv_localisation_address_formats',
648
+		return apply_filters('wpinv_localisation_address_formats',
649 649
 			array(
650 650
 				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
651 651
 				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
  * @see `wpinv_get_invoice_address_replacements`
695 695
  * @return string
696 696
  */
697
-function wpinv_get_full_address_format( $country = false) {
697
+function wpinv_get_full_address_format($country = false) {
698 698
 
699
-    if( empty( $country ) ) {
699
+    if (empty($country)) {
700 700
         $country = wpinv_get_default_country();
701 701
     }
702 702
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 	$formats = wpinv_get_address_formats();
705 705
 
706 706
 	// Get format for the specified country.
707
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
707
+	$format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default'];
708 708
     
709 709
     /**
710 710
 	 * Filters the address format to use on Invoices.
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 	 * @param string $format  The address format to use.
717 717
      * @param string $country The country who's address format is being retrieved.
718 718
 	 */
719
-    return apply_filters( 'wpinv_get_full_address_format', $format, $country );
719
+    return apply_filters('wpinv_get_full_address_format', $format, $country);
720 720
 }
721 721
 
722 722
 /**
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
  * @param array $billing_details customer's billing details
728 728
  * @return array
729 729
  */
730
-function wpinv_get_invoice_address_replacements( $billing_details ) {
730
+function wpinv_get_invoice_address_replacements($billing_details) {
731 731
 
732 732
     $default_args = array(
733 733
         'address'           => '',
@@ -740,22 +740,22 @@  discard block
 block discarded – undo
740 740
 		'company'           => '',
741 741
     );
742 742
 
743
-    $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
743
+    $args    = map_deep(wp_parse_args($billing_details, $default_args), 'trim');
744 744
     $state   = $args['state'];
745 745
     $country = $args['country'];
746 746
 
747 747
     // Handle full country name.
748
-    $full_country = empty( $country ) ? $country : wpinv_country_name( $country );
748
+    $full_country = empty($country) ? $country : wpinv_country_name($country);
749 749
 
750 750
     // Handle full state name.
751
-    $full_state   = ( $country && $state ) ?  wpinv_state_name( $state, $country ) : $state;
751
+    $full_state   = ($country && $state) ?  wpinv_state_name($state, $country) : $state;
752 752
 
753 753
     $args['postcode']    = $args['zip'];
754 754
     $args['name']        = $args['first_name'] . ' ' . $args['last_name'];
755 755
     $args['state']       = $full_state;
756 756
     $args['state_code']  = $state;
757 757
     $args['country']     = $full_country;
758
-    $args['country_code']= $country;
758
+    $args['country_code'] = $country;
759 759
 
760 760
     /**
761 761
 	 * Filters the address format replacements to use on Invoices.
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 	 * @param array $replacements  The address replacements to use.
767 767
      * @param array $billing_details  The billing details to use.
768 768
 	 */
769
-    $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
769
+    $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details);
770 770
 
771 771
     $return = array();
772 772
 
773
-    foreach( $replacements as $key => $value ) {
774
-        $value  = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : '';
773
+    foreach ($replacements as $key => $value) {
774
+        $value = is_scalar($value) ? trim(sanitize_text_field($value)) : '';
775 775
         $return['{{' . $key . '}}'] = $value;
776
-        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value );
776
+        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value);
777 777
     }
778 778
 
779 779
     return $return;
@@ -787,6 +787,6 @@  discard block
 block discarded – undo
787 787
  * @since 1.0.14
788 788
  * @return string
789 789
  */
790
-function wpinv_trim_formatted_address_line( $line ) {
791
-	return trim( $line, ', ' );
790
+function wpinv_trim_formatted_address_line($line) {
791
+	return trim($line, ', ');
792 792
 }
793 793
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/wizard-header.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 			<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
21 21
 			<?php
22 22
                 getpaid_admin()->enqeue_scripts();
23
-				wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
-				wp_print_styles( 'select2' );
23
+                wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
+                wp_print_styles( 'select2' );
25 25
                 wp_print_scripts( 'select2' );
26
-				wp_print_scripts( 'wpinv-admin-script' );
26
+                wp_print_scripts( 'wpinv-admin-script' );
27 27
                 do_action( 'admin_print_styles' );
28 28
                 do_action( 'admin_head' );
29
-			?>
29
+            ?>
30 30
 			<style>
31 31
 				body, p{
32 32
 					font-size: 16px;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 $aui_settings = AyeCode_UI_Settings::instance();
10 10
 $aui_settings->enqueue_scripts();
@@ -17,15 +17,15 @@  discard block
 block discarded – undo
17 17
 		<head>
18 18
 			<meta name="viewport" content="width=device-width"/>
19 19
 			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
20
-			<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
20
+			<title><?php esc_html_e('GetPaid &rsaquo; Setup Wizard', 'invoicing'); ?></title>
21 21
 			<?php
22 22
                 getpaid_admin()->enqeue_scripts();
23
-				wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
-				wp_print_styles( 'select2' );
25
-                wp_print_scripts( 'select2' );
26
-				wp_print_scripts( 'wpinv-admin-script' );
27
-                do_action( 'admin_print_styles' );
28
-                do_action( 'admin_head' );
23
+				wp_enqueue_style('font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0');
24
+				wp_print_styles('select2');
25
+                wp_print_scripts('select2');
26
+				wp_print_scripts('wpinv-admin-script');
27
+                do_action('admin_print_styles');
28
+                do_action('admin_head');
29 29
 			?>
30 30
 			<style>
31 31
 				body, p{
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
                     font-weight: 500;
38 38
                     margin-bottom: .1rem;
39 39
                 }
40
-				<?php echo $aui_settings::css_primary( '#009874', true ); ?>
40
+				<?php echo $aui_settings::css_primary('#009874', true); ?>
41 41
 			</style>
42 42
 		</head>
43 43
 
44 44
         <body class="gp-setup wp-core-ui bg-lightx mx-auto text-dark scrollbars-ios" style="background: #f3f6ff;">
45 45
 
46
-            <?php if ( isset( $_REQUEST['step'] ) ) : ?>
46
+            <?php if (isset($_REQUEST['step'])) : ?>
47 47
                 <ol class="gp-setup-steps mb-0 pb-4 mw-100 list-group list-group-horizontal text-center">
48
-                    <?php foreach ( $steps as $step => $data ) : ?>
48
+                    <?php foreach ($steps as $step => $data) : ?>
49 49
                         <li class="list-group-item flex-fill rounded-0 <?php
50 50
                             echo $step == $current ? 'active' : 'd-none d-md-block';
51
-                            echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? ' done' : '';
51
+                            echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? ' done' : '';
52 52
                         ?>">
53
-                            <i class="far fa-check-circle <?php echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? 'text-success' : '' ;?>"></i>
54
-                            <?php echo esc_html( $data['name'] ); ?>
53
+                            <i class="far fa-check-circle <?php echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? 'text-success' : ''; ?>"></i>
54
+                            <?php echo esc_html($data['name']); ?>
55 55
                         </li>
56 56
                     <?php endforeach; ?>
57 57
                 </ol>
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             <div class="text-center pb-3 mt-5">
63 63
                 <a class=" text-decoration-none" href="https://wpgetpaid.com/">
64 64
                     <span class="text-black-50">
65
-                        <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png';?>" />
65
+                        <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png'; ?>" />
66 66
                     </span>
67 67
                 </a>
68 68
             </div>
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,9 +55,12 @@
 block discarded – undo
55 55
                         </li>
56 56
                     <?php endforeach; ?>
57 57
                 </ol>
58
-            <?php else: ?>
58
+            <?php else {
59
+    : ?>
59 60
                 <div class='mb-3'>&nbsp;</div>
60
-            <?php endif; ?>
61
+            <?php endif;
62
+}
63
+?>
61 64
 
62 65
             <div class="text-center pb-3 mt-5">
63 66
                 <a class=" text-decoration-none" href="https://wpgetpaid.com/">
Please login to merge, or discard this patch.
includes/admin/views/wizard-plugins.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,30 +4,30 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 
11 11
 <div class="card shadow-sm my-5">'
12 12
 
13
-    <form method="post" class="text-center card-body" action="<?php echo esc_url( admin_url() ); ?>">
14
-		<?php getpaid_hidden_field( 'getpaid-admin-action', 'install_plugin' ); ?>
15
-		<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
16
-		<?php getpaid_hidden_field( 'redirect', $next_url ); ?>
13
+    <form method="post" class="text-center card-body" action="<?php echo esc_url(admin_url()); ?>">
14
+		<?php getpaid_hidden_field('getpaid-admin-action', 'install_plugin'); ?>
15
+		<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
16
+		<?php getpaid_hidden_field('redirect', $next_url); ?>
17 17
 		<div class="gd-wizard-recommend">
18 18
 
19
-			<h2 class="gd-settings-title h3"><?php _e( 'Recommended Plugins', 'invoicing' ); ?></h2>
20
-			<p><?php _e( 'Below are a few of our own plugins that may help you.', 'invoicing' ); ?></p>
19
+			<h2 class="gd-settings-title h3"><?php _e('Recommended Plugins', 'invoicing'); ?></h2>
20
+			<p><?php _e('Below are a few of our own plugins that may help you.', 'invoicing'); ?></p>
21 21
 
22 22
 			<ul class="list-group">
23
-				<?php foreach ( $recommended_plugins as $plugin ) : ?>
23
+				<?php foreach ($recommended_plugins as $plugin) : ?>
24 24
 				<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap text-left">
25
-					<span class="mr-auto"><?php echo esc_html( $plugin['name'] ); ?></span>
25
+					<span class="mr-auto"><?php echo esc_html($plugin['name']); ?></span>
26 26
 					<div class="custom-control custom-switch getpaid-install-plugin-siwtch-div mr-n2">
27
-						<input type="checkbox" name="plugins[<?php echo esc_attr( $plugin['slug'] ); ?>]" value="<?php echo esc_attr( $plugin['file'] ); ?>" class="custom-control-input"  <?php if( is_plugin_active( $plugin['slug'] ) ){echo "checked";} ?>>
27
+						<input type="checkbox" name="plugins[<?php echo esc_attr($plugin['slug']); ?>]" value="<?php echo esc_attr($plugin['file']); ?>" class="custom-control-input"  <?php if (is_plugin_active($plugin['slug'])) {echo "checked"; } ?>>
28 28
 						<label class="custom-control-label" for="ac-setting-updates"></label>
29 29
 					</div>
30
-					<small class="w-100"><?php echo esc_attr( $plugin['desc'] );?></small>
30
+					<small class="w-100"><?php echo esc_attr($plugin['desc']); ?></small>
31 31
 				</li>
32 32
 				<?php endforeach; ?>
33 33
 			</ul>
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 				<input
37 37
                 	type="submit"
38 38
                 	class="btn btn-primary button-next"
39
-				    value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
39
+				    value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/>
40 40
 			</p>
41 41
 
42 42
 		</div>
Please login to merge, or discard this patch.
includes/admin/views/wizard-settings.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,15 +4,15 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 
11 11
 <div class="card shadow-sm my-5">
12 12
 
13 13
     <form method="post" class="text-left card-body" action="options.php">
14
-        <?php settings_fields( 'wpinv_settings' ); ?>
15
-        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>">
14
+        <?php settings_fields('wpinv_settings'); ?>
15
+        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>">
16 16
 
17 17
         <table class="gp-setup-maps w-100 " cellspacing="0">
18 18
             <tbody>
@@ -20,28 +20,28 @@  discard block
 block discarded – undo
20 20
 
21 21
                     global $wp_settings_fields;
22 22
 
23
-                    if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) {
24
-                        $settings =  $wp_settings_fields[ $page ][ $section ];
23
+                    if (isset($wp_settings_fields[$page][$section])) {
24
+                        $settings = $wp_settings_fields[$page][$section];
25 25
 
26
-                        foreach ( $settings as $field ) {
26
+                        foreach ($settings as $field) {
27 27
 
28
-                            $name      = esc_attr( $field['id'] );
29
-                            $id        = sanitize_key( $name );
28
+                            $name      = esc_attr($field['id']);
29
+                            $id        = sanitize_key($name);
30 30
                             $class     = '';
31
-                            $value     = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
32
-                            $value     = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) );
33
-                            $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : '';
34
-                            $type      = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) );
35
-                            $label     = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : '';
36
-                            $options   = isset( $field['args']['options'] ) ? $field['args']['options'] : array();
31
+                            $value     = isset($field['args']['std']) ? $field['args']['std'] : '';
32
+                            $value     = wpinv_clean(wpinv_get_option($field['args']['id'], $value));
33
+                            $help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : '';
34
+                            $type      = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback']));
35
+                            $label     = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : '';
36
+                            $options   = isset($field['args']['options']) ? $field['args']['options'] : array();
37 37
                         
38
-                            if ( false !== strpos( $name, 'logo') ) {
38
+                            if (false !== strpos($name, 'logo')) {
39 39
                                 $type = 'hidden';
40 40
                             }
41 41
                         
42
-                            if ( 'country_states' == $type ) {
42
+                            if ('country_states' == $type) {
43 43
                         
44
-                                if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) {
44
+                                if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) {
45 45
                                     $type = 'text';
46 46
                                 } else {
47 47
                                     $type = 'select';
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
                                 $class = 'getpaid_js_field-state';
51 51
                             }
52 52
                         
53
-                            if ( 'wpinv_settings[default_country]' == $name ) {
53
+                            if ('wpinv_settings[default_country]' == $name) {
54 54
                                 $class = 'getpaid_js_field-country';
55 55
                             }
56 56
                         
57
-                            switch ( $type ) {
57
+                            switch ($type) {
58 58
                         
59 59
                                 case 'hidden':
60 60
                                     echo "<input type='hidden' id='$id' name='$name' value='$value' />";
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
                                             'type'       => $type,
67 67
                                             'id'         => $id,
68 68
                                             'name'       => $name,
69
-                                            'value'      => is_scalar( $value ) ? esc_attr( $value ) : '',
69
+                                            'value'      => is_scalar($value) ? esc_attr($value) : '',
70 70
                                             'required'   => false,
71 71
                                             'help_text'  => $help_text,
72 72
                                             'label'      => $label,
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                                         array(
83 83
                                             'id'              => $id,
84 84
                                             'name'            => $name,
85
-                                            'value'           => is_scalar( $value ) ? esc_textarea( $value ) : '',
85
+                                            'value'           => is_scalar($value) ? esc_textarea($value) : '',
86 86
                                             'required'        => false,
87 87
                                             'help_text'       => $help_text,
88 88
                                             'label'           => $label,
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
                                     );
95 95
                         
96 96
                                     // Bug fixed in AUI 0.1.51 for name stripping []
97
-                                    echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea );
97
+                                    echo str_replace(sanitize_html_class($name), esc_attr($name), $textarea);
98 98
                         
99 99
                                     break;
100 100
                                 case 'select':
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                                             'id'              =>  $id,
104 104
                                             'name'            =>  $name,
105 105
                                             'placeholder'     => '',
106
-                                            'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
106
+                                            'value'           => is_scalar($value) ? esc_attr($value) : '',
107 107
                                             'required'        => false,
108 108
                                             'help_text'       => $help_text,
109 109
                                             'label'           => $label,
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				<input
129 129
                     type="submit"
130 130
                     class="btn btn-primary button-next"
131
-				    value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
131
+				    value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/>
132 132
 			</p>
133 133
         </table>
134 134
     </form>
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@  discard block
 block discarded – undo
14 14
 class WPInv_Ajax {
15 15
 
16 16
     /**
17
-	 * Hook in ajax handlers.
18
-	 */
19
-	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
-		self::add_ajax_events();
17
+     * Hook in ajax handlers.
18
+     */
19
+    public static function init() {
20
+        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
+        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
+        self::add_ajax_events();
23 23
     }
24 24
 
25 25
     /**
26
-	 * Set GetPaid AJAX constant and headers.
27
-	 */
28
-	public static function define_ajax() {
29
-
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
-			}
36
-			$GLOBALS['wpdb']->hide_errors();
37
-		}
26
+     * Set GetPaid AJAX constant and headers.
27
+     */
28
+    public static function define_ajax() {
29
+
30
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
+            getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
+            getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
+            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
+                /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
+            }
36
+            $GLOBALS['wpdb']->hide_errors();
37
+        }
38 38
 
39 39
     }
40 40
     
41 41
     /**
42
-	 * Send headers for GetPaid Ajax Requests.
43
-	 *
44
-	 * @since 1.0.18
45
-	 */
46
-	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
48
-			send_origin_headers();
49
-			send_nosniff_header();
50
-			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
54
-		}
42
+     * Send headers for GetPaid Ajax Requests.
43
+     *
44
+     * @since 1.0.18
45
+     */
46
+    private static function wpinv_ajax_headers() {
47
+        if ( ! headers_sent() ) {
48
+            send_origin_headers();
49
+            send_nosniff_header();
50
+            nocache_headers();
51
+            header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
+            header( 'X-Robots-Tag: noindex' );
53
+            status_header( 200 );
54
+        }
55 55
     }
56 56
     
57 57
     /**
58
-	 * Check for GetPaid Ajax request and fire action.
59
-	 */
60
-	public static function do_wpinv_ajax() {
61
-		global $wp_query;
58
+     * Check for GetPaid Ajax request and fire action.
59
+     */
60
+    public static function do_wpinv_ajax() {
61
+        global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
-		}
63
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
+            $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
+        }
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+        $action = $wp_query->get( 'wpinv-ajax' );
68 68
 
69
-		if ( $action ) {
70
-			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
73
-			wp_die();
74
-		}
69
+        if ( $action ) {
70
+            self::wpinv_ajax_headers();
71
+            $action = sanitize_text_field( $action );
72
+            do_action( 'wpinv_ajax_' . $action );
73
+            wp_die();
74
+        }
75 75
 
76 76
     }
77 77
 
78 78
     /**
79
-	 * Hook in ajax methods.
80
-	 */
79
+     * Hook in ajax methods.
80
+     */
81 81
     public static function add_ajax_events() {
82 82
 
83 83
         // array( 'event' => is_frontend )
@@ -259,24 +259,24 @@  discard block
 block discarded – undo
259 259
         check_ajax_referer( 'getpaid_form_nonce' );
260 260
 
261 261
         // Is the request set up correctly?
262
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
263
-			echo aui()->alert(
264
-				array(
265
-					'type'    => 'warning',
266
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
267
-				)
262
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
263
+            echo aui()->alert(
264
+                array(
265
+                    'type'    => 'warning',
266
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
267
+                )
268 268
             );
269 269
             exit;
270 270
         }
271 271
 
272 272
         // Payment form or button?
273
-		if ( ! empty( $_GET['form'] ) ) {
273
+        if ( ! empty( $_GET['form'] ) ) {
274 274
             getpaid_display_payment_form( urldecode( $_GET['form'] ) );
275
-		} else if( ! empty( $_GET['invoice'] ) ) {
276
-		    getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
275
+        } else if( ! empty( $_GET['invoice'] ) ) {
276
+            getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
277 277
         } else {
278
-			$items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
279
-		    getpaid_display_item_payment_form( $items );
278
+            $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
279
+            getpaid_display_item_payment_form( $items );
280 280
         }
281 281
 
282 282
         exit;
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
         if ( is_wp_error( $error ) ) {
598 598
             $alert = $error->get_error_message();
599 599
             wp_send_json_success( compact( 'alert' ) );
600
-         }
600
+            }
601 601
 
602 602
         // Update totals.
603 603
         $invoice->recalculate_total();
Please login to merge, or discard this patch.
Spacing   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -105,36 +105,36 @@  discard block
 block discarded – undo
105 105
             'payment_form_refresh_prices' => true,
106 106
         );
107 107
 
108
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
109
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
110
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
108
+        foreach ($ajax_events as $ajax_event => $nopriv) {
109
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
110
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
111 111
 
112
-            if ( $nopriv ) {
113
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
114
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
115
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
112
+            if ($nopriv) {
113
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
114
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
115
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
116 116
             }
117 117
         }
118 118
     }
119 119
     
120 120
     public static function add_note() {
121
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
121
+        check_ajax_referer('add-invoice-note', '_nonce');
122 122
 
123
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
123
+        if (!wpinv_current_user_can_manage_invoicing()) {
124 124
             die(-1);
125 125
         }
126 126
 
127
-        $post_id   = absint( $_POST['post_id'] );
128
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
129
-        $note_type = sanitize_text_field( $_POST['note_type'] );
127
+        $post_id   = absint($_POST['post_id']);
128
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
129
+        $note_type = sanitize_text_field($_POST['note_type']);
130 130
 
131 131
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
132 132
 
133
-        if ( $post_id > 0 ) {
134
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
133
+        if ($post_id > 0) {
134
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
135 135
 
136
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
137
-                wpinv_get_invoice_note_line_item( $note_id );
136
+            if ($note_id > 0 && !is_wp_error($note_id)) {
137
+                wpinv_get_invoice_note_line_item($note_id);
138 138
             }
139 139
         }
140 140
 
@@ -142,16 +142,16 @@  discard block
 block discarded – undo
142 142
     }
143 143
 
144 144
     public static function delete_note() {
145
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
145
+        check_ajax_referer('delete-invoice-note', '_nonce');
146 146
 
147
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
147
+        if (!wpinv_current_user_can_manage_invoicing()) {
148 148
             die(-1);
149 149
         }
150 150
 
151
-        $note_id = (int)$_POST['note_id'];
151
+        $note_id = (int) $_POST['note_id'];
152 152
 
153
-        if ( $note_id > 0 ) {
154
-            wp_delete_comment( $note_id, true );
153
+        if ($note_id > 0) {
154
+            wp_delete_comment($note_id, true);
155 155
         }
156 156
 
157 157
         die();
@@ -169,34 +169,34 @@  discard block
 block discarded – undo
169 169
     public static function get_billing_details() {
170 170
 
171 171
         // Verify nonce.
172
-        check_ajax_referer( 'wpinv-nonce' );
172
+        check_ajax_referer('wpinv-nonce');
173 173
 
174 174
         // Can the user manage the plugin?
175
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
175
+        if (!wpinv_current_user_can_manage_invoicing()) {
176 176
             die(-1);
177 177
         }
178 178
 
179 179
         // Do we have a user id?
180 180
         $user_id = $_GET['user_id'];
181 181
 
182
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
182
+        if (empty($user_id) || !is_numeric($user_id)) {
183 183
             die(-1);
184 184
         }
185 185
 
186 186
         // Fetch the billing details.
187
-        $billing_details    = wpinv_get_user_address( $user_id );
188
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
187
+        $billing_details    = wpinv_get_user_address($user_id);
188
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
189 189
 
190 190
         // unset the user id and email.
191
-        $to_ignore = array( 'user_id', 'email' );
191
+        $to_ignore = array('user_id', 'email');
192 192
 
193
-        foreach ( $to_ignore as $key ) {
194
-            if ( isset( $billing_details[ $key ] ) ) {
195
-                unset( $billing_details[ $key ] );
193
+        foreach ($to_ignore as $key) {
194
+            if (isset($billing_details[$key])) {
195
+                unset($billing_details[$key]);
196 196
             }
197 197
         }
198 198
 
199
-        wp_send_json_success( $billing_details );
199
+        wp_send_json_success($billing_details);
200 200
 
201 201
     }
202 202
 
@@ -206,47 +206,47 @@  discard block
 block discarded – undo
206 206
     public static function check_new_user_email() {
207 207
 
208 208
         // Verify nonce.
209
-        check_ajax_referer( 'wpinv-nonce' );
209
+        check_ajax_referer('wpinv-nonce');
210 210
 
211 211
         // Can the user manage the plugin?
212
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
212
+        if (!wpinv_current_user_can_manage_invoicing()) {
213 213
             die(-1);
214 214
         }
215 215
 
216 216
         // We need an email address.
217
-        if ( empty( $_GET['email'] ) ) {
218
-            _e( "Provide the new user's email address", 'invoicing' );
217
+        if (empty($_GET['email'])) {
218
+            _e("Provide the new user's email address", 'invoicing');
219 219
             exit;
220 220
         }
221 221
 
222 222
         // Ensure the email is valid.
223
-        $email = sanitize_text_field( $_GET['email'] );
224
-        if ( ! is_email( $email ) ) {
225
-            _e( 'Invalid email address', 'invoicing' );
223
+        $email = sanitize_text_field($_GET['email']);
224
+        if (!is_email($email)) {
225
+            _e('Invalid email address', 'invoicing');
226 226
             exit;
227 227
         }
228 228
 
229 229
         // And it does not exist.
230
-        $id = email_exists( $email );
231
-        if ( $id ) {
232
-            wp_send_json_success( compact( 'id' ) );
230
+        $id = email_exists($email);
231
+        if ($id) {
232
+            wp_send_json_success(compact('id'));
233 233
         }
234 234
 
235
-        wp_send_json_success( true );
235
+        wp_send_json_success(true);
236 236
     }
237 237
     
238 238
     public static function run_tool() {
239
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
240
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
239
+        check_ajax_referer('wpinv-nonce', '_nonce');
240
+        if (!wpinv_current_user_can_manage_invoicing()) {
241 241
             die(-1);
242 242
         }
243 243
         
244
-        $tool = sanitize_text_field( $_POST['tool'] );
244
+        $tool = sanitize_text_field($_POST['tool']);
245 245
         
246
-        do_action( 'wpinv_run_tool' );
246
+        do_action('wpinv_run_tool');
247 247
         
248
-        if ( !empty( $tool ) ) {
249
-            do_action( 'wpinv_tool_' . $tool );
248
+        if (!empty($tool)) {
249
+            do_action('wpinv_tool_' . $tool);
250 250
         }
251 251
     }
252 252
 
@@ -256,27 +256,27 @@  discard block
 block discarded – undo
256 256
     public static function get_payment_form() {
257 257
 
258 258
         // Check nonce.
259
-        check_ajax_referer( 'getpaid_form_nonce' );
259
+        check_ajax_referer('getpaid_form_nonce');
260 260
 
261 261
         // Is the request set up correctly?
262
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
262
+		if (empty($_GET['form']) && empty($_GET['item'])) {
263 263
 			echo aui()->alert(
264 264
 				array(
265 265
 					'type'    => 'warning',
266
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
266
+					'content' => __('No payment form or item provided', 'invoicing'),
267 267
 				)
268 268
             );
269 269
             exit;
270 270
         }
271 271
 
272 272
         // Payment form or button?
273
-		if ( ! empty( $_GET['form'] ) ) {
274
-            getpaid_display_payment_form( urldecode( $_GET['form'] ) );
275
-		} else if( ! empty( $_GET['invoice'] ) ) {
276
-		    getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
273
+		if (!empty($_GET['form'])) {
274
+            getpaid_display_payment_form(urldecode($_GET['form']));
275
+		} else if (!empty($_GET['invoice'])) {
276
+		    getpaid_display_invoice_payment_form(urldecode($_GET['invoice']));
277 277
         } else {
278
-			$items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
279
-		    getpaid_display_item_payment_form( $items );
278
+			$items = getpaid_convert_items_to_array(urldecode($_GET['item']));
279
+		    getpaid_display_item_payment_form($items);
280 280
         }
281 281
 
282 282
         exit;
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
     public static function payment_form() {
292 292
 
293 293
         // Check nonce.
294
-        check_ajax_referer( 'getpaid_form_nonce' );
294
+        check_ajax_referer('getpaid_form_nonce');
295 295
 
296 296
         // ... form fields...
297
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
298
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
297
+        if (empty($_POST['getpaid_payment_form_submission'])) {
298
+            _e('Error: Reload the page and try again.', 'invoicing');
299 299
             exit;
300 300
         }
301 301
 
302 302
         // Process the payment form.
303
-        $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' );
304
-        $checkout       = new $checkout_class( new GetPaid_Payment_Form_Submission() );
303
+        $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout');
304
+        $checkout       = new $checkout_class(new GetPaid_Payment_Form_Submission());
305 305
         $checkout->process_checkout();
306 306
 
307 307
         exit;
@@ -314,55 +314,55 @@  discard block
 block discarded – undo
314 314
      */
315 315
     public static function get_payment_form_states_field() {
316 316
 
317
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
317
+        if (empty($_GET['country']) || empty($_GET['form'])) {
318 318
             exit;
319 319
         }
320 320
 
321
-        $elements = getpaid_get_payment_form_elements( $_GET['form'] );
321
+        $elements = getpaid_get_payment_form_elements($_GET['form']);
322 322
 
323
-        if ( empty( $elements ) ) {
323
+        if (empty($elements)) {
324 324
             exit;
325 325
         }
326 326
 
327 327
         $address_fields = array();
328
-        foreach ( $elements as $element ) {
329
-            if ( 'address' === $element['type'] ) {
328
+        foreach ($elements as $element) {
329
+            if ('address' === $element['type']) {
330 330
                 $address_fields = $element;
331 331
                 break;
332 332
             }
333 333
         }
334 334
 
335
-        if ( empty( $address_fields ) ) {
335
+        if (empty($address_fields)) {
336 336
             exit;
337 337
         }
338 338
 
339
-        foreach ( $address_fields['fields'] as $address_field ) {
339
+        foreach ($address_fields['fields'] as $address_field) {
340 340
 
341
-            if ( 'wpinv_state' == $address_field['name'] ) {
341
+            if ('wpinv_state' == $address_field['name']) {
342 342
 
343
-                $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
344
-                $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
345
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
346
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
347
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
348
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
343
+                $wrap_class  = getpaid_get_form_element_grid_class($address_field);
344
+                $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
345
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
346
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
347
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
348
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
349 349
 
350
-                if ( ! empty( $address_field['required'] ) ) {
350
+                if (!empty($address_field['required'])) {
351 351
                     $label .= "<span class='text-danger'> *</span>";
352 352
                 }
353 353
 
354
-                $html = getpaid_get_states_select_markup (
355
-                    sanitize_text_field( $_GET['country'] ),
354
+                $html = getpaid_get_states_select_markup(
355
+                    sanitize_text_field($_GET['country']),
356 356
                     $value,
357 357
                     $placeholder,
358 358
                     $label,
359 359
                     $description,
360
-                    ! empty( $address_field['required'] ),
360
+                    !empty($address_field['required']),
361 361
                     $wrap_class,
362
-                    wpinv_clean( $_GET['name'] )
362
+                    wpinv_clean($_GET['name'])
363 363
                 );
364 364
 
365
-                wp_send_json_success( $html );
365
+                wp_send_json_success($html);
366 366
                 exit;
367 367
 
368 368
             }
@@ -378,66 +378,66 @@  discard block
 block discarded – undo
378 378
     public static function recalculate_invoice_totals() {
379 379
 
380 380
         // Verify nonce.
381
-        check_ajax_referer( 'wpinv-nonce' );
381
+        check_ajax_referer('wpinv-nonce');
382 382
 
383
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
383
+        if (!wpinv_current_user_can_manage_invoicing()) {
384 384
             exit;
385 385
         }
386 386
 
387 387
         // We need an invoice.
388
-        if ( empty( $_POST['post_id'] ) ) {
388
+        if (empty($_POST['post_id'])) {
389 389
             exit;
390 390
         }
391 391
 
392 392
         // Fetch the invoice.
393
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
393
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
394 394
 
395 395
         // Ensure it exists.
396
-        if ( ! $invoice->get_id() ) {
396
+        if (!$invoice->get_id()) {
397 397
             exit;
398 398
         }
399 399
 
400 400
         // Maybe set the country, state, currency.
401
-        foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) {
402
-            if ( isset( $_POST[ $key ] ) ) {
401
+        foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) {
402
+            if (isset($_POST[$key])) {
403 403
                 $method = "set_$key";
404
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
404
+                $invoice->$method(sanitize_text_field($_POST[$key]));
405 405
             }
406 406
         }
407 407
 
408 408
         // Maybe disable taxes.
409
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
409
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
410 410
 
411 411
         // Discount code.
412
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
413
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
414
-            if ( $discount->exists() ) {
415
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
412
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
413
+            $discount = new WPInv_Discount($invoice->get_discount_code());
414
+            if ($discount->exists()) {
415
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
416 416
             } else {
417
-                $invoice->remove_discount( 'discount_code' );
417
+                $invoice->remove_discount('discount_code');
418 418
             }
419 419
         }
420 420
 
421 421
         // Recalculate totals.
422 422
         $invoice->recalculate_total();
423 423
 
424
-        $total        = wpinv_price( $invoice->get_total(), $invoice->get_currency() );
425
-        $suscriptions = getpaid_get_invoice_subscriptions( $invoice );
426
-        if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
427
-            $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() );
428
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
424
+        $total        = wpinv_price($invoice->get_total(), $invoice->get_currency());
425
+        $suscriptions = getpaid_get_invoice_subscriptions($invoice);
426
+        if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
427
+            $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency());
428
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
429 429
         }
430 430
 
431 431
         $totals = array(
432
-            'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
433
-            'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
434
-            'tax'      => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
432
+            'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
433
+            'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
434
+            'tax'      => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
435 435
             'total'    => $total,
436 436
         );
437 437
 
438
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
438
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
439 439
 
440
-        wp_send_json_success( compact( 'totals' ) );
440
+        wp_send_json_success(compact('totals'));
441 441
     }
442 442
 
443 443
     /**
@@ -446,33 +446,33 @@  discard block
 block discarded – undo
446 446
     public static function get_invoice_items() {
447 447
 
448 448
         // Verify nonce.
449
-        check_ajax_referer( 'wpinv-nonce' );
449
+        check_ajax_referer('wpinv-nonce');
450 450
 
451
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
451
+        if (!wpinv_current_user_can_manage_invoicing()) {
452 452
             exit;
453 453
         }
454 454
 
455 455
         // We need an invoice and items.
456
-        if ( empty( $_POST['post_id'] ) ) {
456
+        if (empty($_POST['post_id'])) {
457 457
             exit;
458 458
         }
459 459
 
460 460
         // Fetch the invoice.
461
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
461
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
462 462
 
463 463
         // Ensure it exists.
464
-        if ( ! $invoice->get_id() ) {
464
+        if (!$invoice->get_id()) {
465 465
             exit;
466 466
         }
467 467
 
468 468
         // Return an array of invoice items.
469 469
         $items = array();
470 470
 
471
-        foreach ( $invoice->get_items() as $item ) {
472
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency(), $invoice->is_renewal()  );
471
+        foreach ($invoice->get_items() as $item) {
472
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal());
473 473
         }
474 474
 
475
-        wp_send_json_success( compact( 'items' ) );
475
+        wp_send_json_success(compact('items'));
476 476
     }
477 477
 
478 478
     /**
@@ -481,50 +481,50 @@  discard block
 block discarded – undo
481 481
     public static function edit_invoice_item() {
482 482
 
483 483
         // Verify nonce.
484
-        check_ajax_referer( 'wpinv-nonce' );
484
+        check_ajax_referer('wpinv-nonce');
485 485
 
486
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
486
+        if (!wpinv_current_user_can_manage_invoicing()) {
487 487
             exit;
488 488
         }
489 489
 
490 490
         // We need an invoice and item details.
491
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
491
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
492 492
             exit;
493 493
         }
494 494
 
495 495
         // Fetch the invoice.
496
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
496
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
497 497
 
498 498
         // Ensure it exists and its not been paid for.
499
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
499
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
500 500
             exit;
501 501
         }
502 502
 
503 503
         // Format the data.
504
-        $data = wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) );
504
+        $data = wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field'));
505 505
 
506 506
         // Ensure that we have an item id.
507
-        if ( empty( $data['id'] ) ) {
507
+        if (empty($data['id'])) {
508 508
             exit;
509 509
         }
510 510
 
511 511
         // Abort if the invoice does not have the specified item.
512
-        $item = $invoice->get_item( (int) $data['id'] );
512
+        $item = $invoice->get_item((int) $data['id']);
513 513
 
514
-        if ( empty( $item ) ) {
514
+        if (empty($item)) {
515 515
             exit;
516 516
         }
517 517
 
518 518
         // Update the item.
519
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
520
-        $item->set_name( sanitize_text_field( $data['name'] ) );
521
-        $item->set_description( wp_kses_post( $data['description'] ) );
522
-        $item->set_quantity( floatval( $data['quantity'] ) );
519
+        $item->set_price(getpaid_standardize_amount($data['price']));
520
+        $item->set_name(sanitize_text_field($data['name']));
521
+        $item->set_description(wp_kses_post($data['description']));
522
+        $item->set_quantity(floatval($data['quantity']));
523 523
 
524 524
         // Add it to the invoice.
525
-        $error = $invoice->add_item( $item );
525
+        $error = $invoice->add_item($item);
526 526
         $alert = false;
527
-        if ( is_wp_error( $error ) ) {
527
+        if (is_wp_error($error)) {
528 528
             $alert = $error->get_error_message();
529 529
         }
530 530
 
@@ -537,11 +537,11 @@  discard block
 block discarded – undo
537 537
         // Return an array of invoice items.
538 538
         $items = array();
539 539
 
540
-        foreach ( $invoice->get_items() as $item ) {
541
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
540
+        foreach ($invoice->get_items() as $item) {
541
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
542 542
         }
543 543
 
544
-        wp_send_json_success( compact( 'items', 'alert' ) );
544
+        wp_send_json_success(compact('items', 'alert'));
545 545
     }
546 546
 
547 547
     /**
@@ -550,53 +550,53 @@  discard block
 block discarded – undo
550 550
     public static function create_invoice_item() {
551 551
 
552 552
         // Verify nonce.
553
-        check_ajax_referer( 'wpinv-nonce' );
553
+        check_ajax_referer('wpinv-nonce');
554 554
 
555
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
555
+        if (!wpinv_current_user_can_manage_invoicing()) {
556 556
             exit;
557 557
         }
558 558
 
559 559
         // We need an invoice and item details.
560
-        if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) {
560
+        if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) {
561 561
             exit;
562 562
         }
563 563
 
564 564
         // Fetch the invoice.
565
-        $invoice = new WPInv_Invoice( trim( $_POST['invoice_id'] ) );
565
+        $invoice = new WPInv_Invoice(trim($_POST['invoice_id']));
566 566
 
567 567
         // Ensure it exists and its not been paid for.
568
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
568
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
569 569
             exit;
570 570
         }
571 571
 
572 572
         // Format the data.
573
-        $data = wp_unslash( $_POST['_wpinv_quick'] );
573
+        $data = wp_unslash($_POST['_wpinv_quick']);
574 574
 
575 575
         $item = new WPInv_Item();
576
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
577
-        $item->set_name( sanitize_text_field( $data['name'] ) );
578
-        $item->set_description( wp_kses_post( $data['description'] ) );
579
-        $item->set_type( sanitize_text_field( $data['type'] ) );
580
-        $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) );
581
-        $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) );
582
-        $item->set_status( 'publish' );
576
+        $item->set_price(getpaid_standardize_amount($data['price']));
577
+        $item->set_name(sanitize_text_field($data['name']));
578
+        $item->set_description(wp_kses_post($data['description']));
579
+        $item->set_type(sanitize_text_field($data['type']));
580
+        $item->set_vat_rule(sanitize_text_field($data['vat_rule']));
581
+        $item->set_vat_class(sanitize_text_field($data['vat_class']));
582
+        $item->set_status('publish');
583 583
         $item->save();
584 584
 
585
-        if ( ! $item->exists() ) {
586
-            $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' );
587
-            wp_send_json_success( compact( 'alert' ) );
585
+        if (!$item->exists()) {
586
+            $alert = __('Could not create invoice item. Please try again.', 'invoicing');
587
+            wp_send_json_success(compact('alert'));
588 588
         }
589 589
 
590
-        $item = new GetPaid_Form_Item( $item->get_id() );
591
-        $item->set_quantity( floatval( $data['qty'] ) );
590
+        $item = new GetPaid_Form_Item($item->get_id());
591
+        $item->set_quantity(floatval($data['qty']));
592 592
 
593 593
         // Add it to the invoice.
594
-        $error = $invoice->add_item( $item );
594
+        $error = $invoice->add_item($item);
595 595
         $alert = false;
596 596
 
597
-        if ( is_wp_error( $error ) ) {
597
+        if (is_wp_error($error)) {
598 598
             $alert = $error->get_error_message();
599
-            wp_send_json_success( compact( 'alert' ) );
599
+            wp_send_json_success(compact('alert'));
600 600
          }
601 601
 
602 602
         // Update totals.
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
         $invoice->recalculate_total();
610 610
         $invoice->save();
611 611
         ob_start();
612
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
612
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
613 613
         $row = ob_get_clean();
614
-        wp_send_json_success( compact( 'row' ) );
614
+        wp_send_json_success(compact('row'));
615 615
     }
616 616
 
617 617
     /**
@@ -620,33 +620,33 @@  discard block
 block discarded – undo
620 620
     public static function remove_invoice_item() {
621 621
 
622 622
         // Verify nonce.
623
-        check_ajax_referer( 'wpinv-nonce' );
623
+        check_ajax_referer('wpinv-nonce');
624 624
 
625
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
625
+        if (!wpinv_current_user_can_manage_invoicing()) {
626 626
             exit;
627 627
         }
628 628
 
629 629
         // We need an invoice and an item.
630
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
630
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
631 631
             exit;
632 632
         }
633 633
 
634 634
         // Fetch the invoice.
635
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
635
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
636 636
 
637 637
         // Ensure it exists and its not been paid for.
638
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
638
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
639 639
             exit;
640 640
         }
641 641
 
642 642
         // Abort if the invoice does not have the specified item.
643
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
643
+        $item = $invoice->get_item((int) $_POST['item_id']);
644 644
 
645
-        if ( empty( $item ) ) {
645
+        if (empty($item)) {
646 646
             exit;
647 647
         }
648 648
 
649
-        $invoice->remove_item( (int) $_POST['item_id'] );
649
+        $invoice->remove_item((int) $_POST['item_id']);
650 650
 
651 651
         // Update totals.
652 652
         $invoice->recalculate_total();
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
         // Return an array of invoice items.
658 658
         $items = array();
659 659
 
660
-        foreach ( $invoice->get_items() as $item ) {
661
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
660
+        foreach ($invoice->get_items() as $item) {
661
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
662 662
         }
663 663
 
664
-        wp_send_json_success( compact( 'items' ) );
664
+        wp_send_json_success(compact('items'));
665 665
     }
666 666
 
667 667
     /**
@@ -670,69 +670,69 @@  discard block
 block discarded – undo
670 670
     public static function recalculate_full_prices() {
671 671
 
672 672
         // Verify nonce.
673
-        check_ajax_referer( 'wpinv-nonce' );
673
+        check_ajax_referer('wpinv-nonce');
674 674
 
675
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
675
+        if (!wpinv_current_user_can_manage_invoicing()) {
676 676
             exit;
677 677
         }
678 678
 
679 679
         // We need an invoice and item.
680
-        if ( empty( $_POST['post_id'] ) ) {
680
+        if (empty($_POST['post_id'])) {
681 681
             exit;
682 682
         }
683 683
 
684 684
         // Fetch the invoice.
685
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
685
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
686 686
         $alert   = false;
687 687
 
688 688
         // Ensure it exists and its not been paid for.
689
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
689
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
690 690
             exit;
691 691
         }
692 692
 
693
-        $invoice->set_items( array() );
693
+        $invoice->set_items(array());
694 694
 
695
-        if ( ! empty( $_POST['getpaid_items'] ) ) {
695
+        if (!empty($_POST['getpaid_items'])) {
696 696
 
697
-            foreach ( $_POST['getpaid_items'] as $item_id => $args ) {
698
-                $item = new GetPaid_Form_Item( $item_id );
697
+            foreach ($_POST['getpaid_items'] as $item_id => $args) {
698
+                $item = new GetPaid_Form_Item($item_id);
699 699
 
700
-                if ( $item->exists() ) {
701
-                    $item->set_price( getpaid_standardize_amount( $args['price'] ) );
702
-                    $item->set_quantity( floatval( $args['quantity'] ) );
703
-                    $item->set_name( sanitize_text_field( $args['name'] ) );
704
-                    $item->set_description( wp_kses_post( $args['description'] ) );
705
-                    $invoice->add_item( $item );
700
+                if ($item->exists()) {
701
+                    $item->set_price(getpaid_standardize_amount($args['price']));
702
+                    $item->set_quantity(floatval($args['quantity']));
703
+                    $item->set_name(sanitize_text_field($args['name']));
704
+                    $item->set_description(wp_kses_post($args['description']));
705
+                    $invoice->add_item($item);
706 706
                 }
707 707
             }
708 708
 
709 709
         }
710 710
 
711
-        $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) );
711
+        $invoice->set_disable_taxes(!empty($_POST['disable_taxes']));
712 712
 
713 713
         // Maybe set the country, state, currency.
714
-        foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) {
715
-            if ( isset( $_POST[ $key ] ) ) {
716
-                $_key   = str_replace( 'wpinv_', '', $key );
714
+        foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) {
715
+            if (isset($_POST[$key])) {
716
+                $_key   = str_replace('wpinv_', '', $key);
717 717
                 $method = "set_$_key";
718
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
718
+                $invoice->$method(sanitize_text_field($_POST[$key]));
719 719
             }
720 720
         }
721 721
 
722
-        $discount = new WPInv_Discount( $invoice->get_discount_code() );
723
-        if ( $discount->exists() ) {
724
-            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
722
+        $discount = new WPInv_Discount($invoice->get_discount_code());
723
+        if ($discount->exists()) {
724
+            $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
725 725
         } else {
726
-            $invoice->remove_discount( 'discount_code' );
726
+            $invoice->remove_discount('discount_code');
727 727
         }
728 728
 
729 729
         // Save the invoice.
730 730
         $invoice->recalculate_total();
731 731
         $invoice->save();
732 732
         ob_start();
733
-        GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice );
733
+        GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice);
734 734
         $table = ob_get_clean();
735
-        wp_send_json_success( compact( 'table' ) );
735
+        wp_send_json_success(compact('table'));
736 736
     }
737 737
 
738 738
     /**
@@ -741,42 +741,42 @@  discard block
 block discarded – undo
741 741
     public static function admin_add_invoice_item() {
742 742
 
743 743
         // Verify nonce.
744
-        check_ajax_referer( 'wpinv-nonce' );
744
+        check_ajax_referer('wpinv-nonce');
745 745
 
746
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
746
+        if (!wpinv_current_user_can_manage_invoicing()) {
747 747
             exit;
748 748
         }
749 749
 
750 750
         // We need an invoice and item.
751
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
751
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
752 752
             exit;
753 753
         }
754 754
 
755 755
         // Fetch the invoice.
756
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
756
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
757 757
         $alert   = false;
758 758
 
759 759
         // Ensure it exists and its not been paid for.
760
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
760
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
761 761
             exit;
762 762
         }
763 763
 
764 764
         // Add the item.
765
-        $item  = new GetPaid_Form_Item( (int) $_POST['item_id'] );
766
-        $error = $invoice->add_item( $item );
765
+        $item  = new GetPaid_Form_Item((int) $_POST['item_id']);
766
+        $error = $invoice->add_item($item);
767 767
 
768
-        if ( is_wp_error( $error ) ) {
768
+        if (is_wp_error($error)) {
769 769
             $alert = $error->get_error_message();
770
-            wp_send_json_success( compact( 'alert' ) );
770
+            wp_send_json_success(compact('alert'));
771 771
         }
772 772
 
773 773
         // Save the invoice.
774 774
         $invoice->recalculate_total();
775 775
         $invoice->save();
776 776
         ob_start();
777
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
777
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
778 778
         $row = ob_get_clean();
779
-        wp_send_json_success( compact( 'row' ) );
779
+        wp_send_json_success(compact('row'));
780 780
     }
781 781
 
782 782
     /**
@@ -785,39 +785,39 @@  discard block
 block discarded – undo
785 785
     public static function add_invoice_items() {
786 786
 
787 787
         // Verify nonce.
788
-        check_ajax_referer( 'wpinv-nonce' );
788
+        check_ajax_referer('wpinv-nonce');
789 789
 
790
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
790
+        if (!wpinv_current_user_can_manage_invoicing()) {
791 791
             exit;
792 792
         }
793 793
 
794 794
         // We need an invoice and items.
795
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
795
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
796 796
             exit;
797 797
         }
798 798
 
799 799
         // Fetch the invoice.
800
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
800
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
801 801
         $alert   = false;
802 802
 
803 803
         // Ensure it exists and its not been paid for.
804
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
804
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
805 805
             exit;
806 806
         }
807 807
 
808 808
         // Add the items.
809
-        foreach ( $_POST['items'] as $data ) {
809
+        foreach ($_POST['items'] as $data) {
810 810
 
811
-            $item = new GetPaid_Form_Item( $data[ 'id' ] );
811
+            $item = new GetPaid_Form_Item($data['id']);
812 812
 
813
-            if ( is_numeric( $data[ 'qty' ] ) && (float) $data[ 'qty' ] > 0 ) {
814
-                $item->set_quantity( $data[ 'qty' ] );
813
+            if (is_numeric($data['qty']) && (float) $data['qty'] > 0) {
814
+                $item->set_quantity($data['qty']);
815 815
             }
816 816
 
817
-            if ( $item->get_id() > 0 ) {
818
-                $error = $invoice->add_item( $item );
817
+            if ($item->get_id() > 0) {
818
+                $error = $invoice->add_item($item);
819 819
 
820
-                if ( is_wp_error( $error ) ) {
820
+                if (is_wp_error($error)) {
821 821
                     $alert = $error->get_error_message();
822 822
                 }
823 823
 
@@ -832,11 +832,11 @@  discard block
 block discarded – undo
832 832
         // Return an array of invoice items.
833 833
         $items = array();
834 834
 
835
-        foreach ( $invoice->get_items() as $item ) {
836
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
835
+        foreach ($invoice->get_items() as $item) {
836
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
837 837
         }
838 838
 
839
-        wp_send_json_success( compact( 'items', 'alert' ) );
839
+        wp_send_json_success(compact('items', 'alert'));
840 840
     }
841 841
 
842 842
     /**
@@ -845,15 +845,15 @@  discard block
 block discarded – undo
845 845
     public static function get_invoicing_items() {
846 846
 
847 847
         // Verify nonce.
848
-        check_ajax_referer( 'wpinv-nonce' );
848
+        check_ajax_referer('wpinv-nonce');
849 849
 
850
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
850
+        if (!wpinv_current_user_can_manage_invoicing()) {
851 851
             exit;
852 852
         }
853 853
 
854 854
         // We need a search term.
855
-        if ( empty( $_GET['search'] ) ) {
856
-            wp_send_json_success( array() );
855
+        if (empty($_GET['search'])) {
856
+            wp_send_json_success(array());
857 857
         }
858 858
 
859 859
         // Retrieve items.
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
             'orderby'        => 'title',
863 863
             'order'          => 'ASC',
864 864
             'posts_per_page' => -1,
865
-            'post_status'    => array( 'publish' ),
866
-            's'              => trim( $_GET['search'] ),
865
+            'post_status'    => array('publish'),
866
+            's'              => trim($_GET['search']),
867 867
             'meta_query'     => array(
868 868
                 array(
869 869
                     'key'       => '_wpinv_type',
@@ -873,21 +873,21 @@  discard block
 block discarded – undo
873 873
             )
874 874
         );
875 875
 
876
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
876
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
877 877
         $data  = array();
878 878
 
879
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) );
879
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id']));
880 880
 
881
-        foreach ( $items as $item ) {
882
-            $item      = new GetPaid_Form_Item( $item );
881
+        foreach ($items as $item) {
882
+            $item = new GetPaid_Form_Item($item);
883 883
             $data[] = array(
884 884
                 'id'        => (int) $item->get_id(),
885
-                'text'      => strip_tags( $item->get_name() ),
886
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
885
+                'text'      => strip_tags($item->get_name()),
886
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
887 887
             );
888 888
         }
889 889
 
890
-        wp_send_json_success( $data );
890
+        wp_send_json_success($data);
891 891
 
892 892
     }
893 893
 
@@ -897,37 +897,37 @@  discard block
 block discarded – undo
897 897
     public static function get_customers() {
898 898
 
899 899
         // Verify nonce.
900
-        check_ajax_referer( 'wpinv-nonce' );
900
+        check_ajax_referer('wpinv-nonce');
901 901
 
902
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
902
+        if (!wpinv_current_user_can_manage_invoicing()) {
903 903
             exit;
904 904
         }
905 905
 
906 906
         // We need a search term.
907
-        if ( empty( $_GET['search'] ) ) {
908
-            wp_send_json_success( array() );
907
+        if (empty($_GET['search'])) {
908
+            wp_send_json_success(array());
909 909
         }
910 910
 
911 911
         // Retrieve customers.
912 912
     
913 913
         $customer_args = array(
914
-            'fields'         => array( 'ID', 'user_email', 'display_name' ),
914
+            'fields'         => array('ID', 'user_email', 'display_name'),
915 915
             'orderby'        => 'display_name',
916
-            'search'         => '*' . sanitize_text_field( $_GET['search'] ) . '*',
917
-            'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
916
+            'search'         => '*' . sanitize_text_field($_GET['search']) . '*',
917
+            'search_columns' => array('user_login', 'user_email', 'display_name'),
918 918
         );
919 919
 
920
-        $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) );
920
+        $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args));
921 921
         $data      = array();
922 922
 
923
-        foreach ( $customers as $customer ) {
923
+        foreach ($customers as $customer) {
924 924
             $data[] = array(
925 925
                 'id'        => (int) $customer->ID,
926
-                'text'      => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ),
926
+                'text'      => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)),
927 927
             );
928 928
         }
929 929
 
930
-        wp_send_json_success( $data );
930
+        wp_send_json_success($data);
931 931
 
932 932
     }
933 933
 
@@ -937,28 +937,28 @@  discard block
 block discarded – undo
937 937
     public static function get_aui_states_field() {
938 938
 
939 939
         // Verify nonce.
940
-        check_ajax_referer( 'wpinv-nonce' );
940
+        check_ajax_referer('wpinv-nonce');
941 941
 
942 942
         // We need a country.
943
-        if ( empty( $_GET['country'] ) ) {
943
+        if (empty($_GET['country'])) {
944 944
             exit;
945 945
         }
946 946
 
947
-        $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) );
948
-        $state  = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state();
949
-        $name   = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state';
950
-        $class  = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm';
947
+        $states = wpinv_get_country_states(sanitize_text_field($_GET['country']));
948
+        $state  = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state();
949
+        $name   = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state';
950
+        $class  = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm';
951 951
 
952
-        if ( empty( $states ) ) {
952
+        if (empty($states)) {
953 953
 
954 954
             $html = aui()->input(
955 955
                 array(
956 956
                     'type'        => 'text',
957 957
                     'id'          => 'wpinv_state',
958 958
                     'name'        => $name,
959
-                    'label'       => __( 'State', 'invoicing' ),
959
+                    'label'       => __('State', 'invoicing'),
960 960
                     'label_type'  => 'vertical',
961
-                    'placeholder' => __( 'State', 'invoicing' ),
961
+                    'placeholder' => __('State', 'invoicing'),
962 962
                     'class'       => $class,
963 963
                     'value'       => $state,
964 964
                 )
@@ -970,9 +970,9 @@  discard block
 block discarded – undo
970 970
                 array(
971 971
                     'id'          => 'wpinv_state',
972 972
                     'name'        => $name,
973
-                    'label'       => __( 'State', 'invoicing' ),
973
+                    'label'       => __('State', 'invoicing'),
974 974
                     'label_type'  => 'vertical',
975
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
975
+                    'placeholder' => __('Select a state', 'invoicing'),
976 976
                     'class'       => $class,
977 977
                     'value'       => $state,
978 978
                     'options'     => $states,
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
         wp_send_json_success(
987 987
             array(
988 988
                 'html'   => $html,
989
-                'select' => ! empty ( $states )
989
+                'select' => !empty ($states)
990 990
             )
991 991
         );
992 992
 
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
     public static function payment_form_refresh_prices() {
1001 1001
 
1002 1002
         // Check nonce.
1003
-        check_ajax_referer( 'getpaid_form_nonce' );
1003
+        check_ajax_referer('getpaid_form_nonce');
1004 1004
 
1005 1005
         // ... form fields...
1006
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
1007
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
1006
+        if (empty($_POST['getpaid_payment_form_submission'])) {
1007
+            _e('Error: Reload the page and try again.', 'invoicing');
1008 1008
             exit;
1009 1009
         }
1010 1010
 
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
         $submission = new GetPaid_Payment_Form_Submission();
1013 1013
 
1014 1014
         // Do we have an error?
1015
-        if ( ! empty( $submission->last_error ) ) {
1015
+        if (!empty($submission->last_error)) {
1016 1016
             wp_send_json_error(
1017 1017
                 array(
1018 1018
                     'code'  => $submission->last_error_code,
@@ -1022,12 +1022,12 @@  discard block
 block discarded – undo
1022 1022
         }
1023 1023
 
1024 1024
         // Prepare the response.
1025
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
1025
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
1026 1026
 
1027 1027
         // Filter the response.
1028
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
1028
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
1029 1029
 
1030
-        wp_send_json_success( $response );
1030
+        wp_send_json_success($response);
1031 1031
     }
1032 1032
 
1033 1033
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
     }
320 320
 
321 321
     /**
322
-	 * Output the metabox.
323
-	 *
324
-	 * @param WP_Post $post
325
-	 */
322
+     * Output the metabox.
323
+     *
324
+     * @param WP_Post $post
325
+     */
326 326
     public static function output2( $post ) {
327 327
 
328 328
         // Prepare the invoice.
Please login to merge, or discard this patch.
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -16,82 +16,82 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Items {
18 18
 
19
-    public static function get_columns( $invoice ) {
19
+    public static function get_columns($invoice) {
20 20
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
21 21
         $columns            = array(
22
-            'id'     => __( 'ID', 'invoicing' ),
23
-            'title'  => __( 'Item', 'invoicing' ),
22
+            'id'     => __('ID', 'invoicing'),
23
+            'title'  => __('Item', 'invoicing'),
24 24
             'price'  => sprintf(
25 25
                 '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span>
26 26
                 <span class="getpaid-hide-if-hours hide-if-amount">%s</span>
27 27
                 <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>',
28
-                __( 'Amount', 'invoicing' ),
29
-                __( 'Price', 'invoicing' ),
30
-                __( 'Rate', 'invoicing' )
28
+                __('Amount', 'invoicing'),
29
+                __('Price', 'invoicing'),
30
+                __('Rate', 'invoicing')
31 31
             ),
32 32
             'qty'    => sprintf(
33 33
                 '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>',
34
-                __( 'Quantity', 'invoicing' ),
35
-                __( 'Hours', 'invoicing' )
34
+                __('Quantity', 'invoicing'),
35
+                __('Hours', 'invoicing')
36 36
             ),
37
-            'total'  => __( 'Total', 'invoicing' ),
38
-            'tax'    => __( 'Tax (%)', 'invoicing' ),
37
+            'total'  => __('Total', 'invoicing'),
38
+            'tax'    => __('Tax (%)', 'invoicing'),
39 39
             'action' => '',
40 40
         );
41 41
 
42
-        if ( ! $use_taxes ) {
43
-            unset( $columns['tax'] );
42
+        if (!$use_taxes) {
43
+            unset($columns['tax']);
44 44
         }
45 45
 
46 46
         return $columns;
47 47
     }
48 48
 
49
-    public static function output( $post, $invoice = false ) {
49
+    public static function output($post, $invoice = false) {
50 50
 
51
-        if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) {
52
-            return self::output2( $post );
51
+        if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) {
52
+            return self::output2($post);
53 53
         }
54 54
 
55
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
56
-        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id );
55
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
56
+        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id);
57 57
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
58
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
59
-        $columns            = self::get_columns( $invoice );
60
-        $cols               = count( $columns );
58
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
59
+        $columns            = self::get_columns($invoice);
60
+        $cols               = count($columns);
61 61
         $class              = '';
62 62
 
63
-        unset( $item_types['adv'] );
64
-        unset( $item_types['package'] );
63
+        unset($item_types['adv']);
64
+        unset($item_types['package']);
65 65
 
66
-        if ( $invoice->is_paid() ) {
66
+        if ($invoice->is_paid()) {
67 67
             $class .= ' wpinv-paid';
68 68
         }
69 69
 
70
-        if ( $invoice->is_refunded() ) {
70
+        if ($invoice->is_refunded()) {
71 71
             $class .= ' wpinv-refunded';
72 72
         }
73 73
 
74
-        if ( $invoice->is_recurring() ) {
74
+        if ($invoice->is_recurring()) {
75 75
             $class .= ' wpi-recurring';
76 76
         }
77 77
 
78 78
     ?>
79 79
 
80
-        <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>">
80
+        <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>">
81 81
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
82 82
 
83 83
                 <thead>
84 84
                     <tr>
85
-                        <?php foreach ( $columns as $key => $label ) : ?>
86
-                            <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th>
85
+                        <?php foreach ($columns as $key => $label) : ?>
86
+                            <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th>
87 87
                         <?php endforeach; ?>
88 88
                     </tr>
89 89
                 </thead>
90 90
 
91 91
                 <tbody class="wpinv-line-items">
92 92
                     <?php
93
-                        foreach ( $invoice->get_items() as $int => $item ) {
94
-                            self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
93
+                        foreach ($invoice->get_items() as $int => $item) {
94
+                            self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd');
95 95
                         }
96 96
                     ?>
97 97
                 </tbody>
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                                             <div class="wp-clearfix">
109 109
                                                 <label class="wpi-item-name">
110 110
                                                     <span class="input-text-wrap">
111
-                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
111
+                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
112 112
                                                     </span>
113 113
                                                 </label>
114 114
                                             </div>
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                                             <div class="wp-clearfix">
117 117
                                                 <label class="wpi-item-price">
118 118
                                                     <span class="input-text-wrap">
119
-                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
-                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
119
+                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
120
+                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
121 121
                                                     </span>
122 122
                                                 </label>
123 123
                                             </div>
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
                                             <div class="wp-clearfix">
126 126
                                                 <label class="wpi-item-name">
127 127
                                                     <span class="input-text-wrap">
128
-                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
128
+                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
129 129
                                                     </span>
130 130
                                                 </label>
131 131
                                             </div>
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                                             <div class="wp-clearfix">
134 134
                                                 <label class="wpi-item-type">
135 135
                                                     <span class="input-text-wrap">
136
-                                                        <?php echo wpinv_html_select( array(
136
+                                                        <?php echo wpinv_html_select(array(
137 137
                                                             'options'          => $item_types,
138 138
                                                             'name'             => '_wpinv_quick[type]',
139 139
                                                             'id'               => '_wpinv_quick_type',
@@ -141,19 +141,19 @@  discard block
 block discarded – undo
141 141
                                                             'show_option_all'  => false,
142 142
                                                             'show_option_none' => false,
143 143
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
144
-                                                        ) ); ?>
144
+                                                        )); ?>
145 145
                                                     </span>
146 146
                                                 </label>
147 147
                                             </div>
148 148
 
149
-                                            <?php if ( $use_taxes ) : ?>
149
+                                            <?php if ($use_taxes) : ?>
150 150
                                                 <div class="wp-clearfix">
151 151
                                                     <label class="wpi-vat-rule">
152 152
                                                         <span class="input-text-wrap">
153 153
                                                             <?php
154
-                                                                echo wpinv_html_select( array(
154
+                                                                echo wpinv_html_select(array(
155 155
                                                                     'options'          => array_merge(
156
-                                                                        array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
156
+                                                                        array('' => __('Select VAT Rule', 'invoicing')),
157 157
                                                                         getpaid_get_tax_rules()
158 158
                                                                     ),
159 159
                                                                     'name'             => '_wpinv_quick[vat_rule]',
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                                                                     'show_option_all'  => false,
162 162
                                                                     'show_option_none' => false,
163 163
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
164
-                                                                ) );
164
+                                                                ));
165 165
                                                             ?>
166 166
                                                         </span>
167 167
                                                     </label>
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
                                                     <label class="wpi-vat-class">
171 171
                                                         <span class="input-text-wrap">
172 172
                                                             <?php
173
-                                                                echo wpinv_html_select( array(
173
+                                                                echo wpinv_html_select(array(
174 174
                                                                     'options'          => array_merge(
175
-                                                                        array( '' => __( 'Select VAT Class', 'invoicing' ) ),
175
+                                                                        array('' => __('Select VAT Class', 'invoicing')),
176 176
                                                                         getpaid_get_tax_classes()
177 177
                                                                     ),
178 178
                                                                     'name'             => '_wpinv_quick[vat_class]',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
                                                                     'show_option_all'  => false,
181 181
                                                                     'show_option_none' => false,
182 182
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
183
-                                                                ) );
183
+                                                                ));
184 184
                                                             ?>
185 185
                                                         </span>
186 186
                                                     </label>
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
                         </td>
202 202
                     </tr>
203 203
                     <tr class="totals">
204
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
204
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
205 205
                         <td colspan="4">
206 206
                             <table cellspacing="0" cellpadding="0">
207 207
                                 <tr class="subtotal">
208
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
209
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td>
208
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
209
+                                    <td class="total"><?php echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td>
210 210
                                     <td class="action"></td>
211 211
                                 </tr>
212 212
                                 <tr class="discount">
213
-                                    <td class="name"><?php _e( 'Discount:', 'invoicing' ) ; ?></td>
214
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td>
213
+                                    <td class="name"><?php _e('Discount:', 'invoicing'); ?></td>
214
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td>
215 215
                                     <td class="action"></td>
216 216
                                 </tr>
217
-                                <?php if ( $use_taxes ) : ?>
217
+                                <?php if ($use_taxes) : ?>
218 218
                                 <tr class="tax">
219
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
220
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td>
219
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
220
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td>
221 221
                                     <td class="action"></td>
222 222
                                 </tr>
223 223
                                 <?php endif; ?>
224 224
                                 <tr class="total">
225
-                                    <td class="name"><?php _e( 'Total:', 'invoicing' );?></td>
226
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );?></td>
225
+                                    <td class="name"><?php _e('Total:', 'invoicing'); ?></td>
226
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total(), $invoice->get_currency()); ?></td>
227 227
                                     <td class="action"></td>
228 228
                                 </tr>
229 229
                             </table>
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             </table>
235 235
             <div class="wpinv-actions">
236 236
                 <?php
237
-                    if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
237
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
238 238
                         echo wpinv_item_dropdown(
239 239
                             array(
240 240
                                 'name'             => 'wpinv_invoice_item',
@@ -244,61 +244,61 @@  discard block
 block discarded – undo
244 244
                             )
245 245
                         );
246 246
 
247
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>';
248
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
249
-                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
247
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>';
248
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>';
249
+                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>';
250 250
 
251 251
                     }
252 252
                 ?>
253
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
253
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
254 254
             </div>
255 255
         </div>
256 256
         <?php
257 257
     }
258 258
 
259
-    public static function output_row( $columns, $item, $invoice, $class='even' ) {
259
+    public static function output_row($columns, $item, $invoice, $class = 'even') {
260 260
 
261 261
     ?>
262
-        <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>">
263
-            <?php foreach ( array_keys( $columns ) as $column ) : ?>
264
-                <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
262
+        <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>">
263
+            <?php foreach (array_keys($columns) as $column) : ?>
264
+                <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
265 265
                     <?php
266
-                        switch ( $column ) {
266
+                        switch ($column) {
267 267
                             case 'id':
268 268
                                 echo (int) $item->get_id();
269 269
                                 break;
270 270
                             case 'title':
271 271
                                 printf(
272 272
                                     '<a href="%s" target="_blank">%s</a>',
273
-                                    get_edit_post_link( $item->get_id() ),
274
-                                    esc_html( $item->get_raw_name() )
273
+                                    get_edit_post_link($item->get_id()),
274
+                                    esc_html($item->get_raw_name())
275 275
                                 );
276 276
 
277
-                                $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
278
-                                if ( $summary !== '' ) {
277
+                                $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice);
278
+                                if ($summary !== '') {
279 279
                                     printf(
280 280
                                         '<span class="meta">%s</span>',
281
-                                        wpautop( wp_kses_post( $summary ) )
281
+                                        wpautop(wp_kses_post($summary))
282 282
                                     );
283 283
                                 }
284 284
 
285 285
                                 printf(
286 286
                                     '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
287
-                                    esc_attr( $item->get_raw_name() ),
287
+                                    esc_attr($item->get_raw_name()),
288 288
                                     (int) $item->get_id()
289 289
                                 );
290 290
 
291 291
                                 printf(
292 292
                                     '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
293 293
                                     (int) $item->get_id(),
294
-                                    esc_attr( $item->get_description() )
294
+                                    esc_attr($item->get_description())
295 295
                                 );
296 296
 
297 297
                                 break;
298 298
                             case 'price':
299 299
                                 printf(
300 300
                                     '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
301
-                                    esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
301
+                                    esc_attr(getpaid_unstandardize_amount($item->get_price())),
302 302
                                     (int) $item->get_id()
303 303
                                 );
304 304
 
@@ -306,26 +306,26 @@  discard block
 block discarded – undo
306 306
                             case 'qty':
307 307
                                 printf(
308 308
                                     '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
309
-                                    floatval( $item->get_quantity() ),
309
+                                    floatval($item->get_quantity()),
310 310
                                     (int) $item->get_id()
311 311
                                 );
312 312
 
313 313
                                 break;
314 314
                             case 'total':
315
-                                echo wpinv_price( $item->get_sub_total(), $invoice->get_currency() );
315
+                                echo wpinv_price($item->get_sub_total(), $invoice->get_currency());
316 316
 
317 317
                                 break;
318 318
                             case 'tax':
319
-                                echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%';
319
+                                echo wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%';
320 320
 
321 321
                                 break;
322 322
                             case 'action':
323
-                                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
323
+                                if (!$invoice->is_paid() && !$invoice->is_refunded()) {
324 324
                                     echo '<i class="fa fa-trash wpinv-item-remove"></i>';
325 325
                                 }
326 326
                                 break;
327 327
                         }
328
-                        do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice );
328
+                        do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice);
329 329
                     ?>
330 330
                 </td>
331 331
             <?php endforeach; ?>
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @param WP_Post $post
340 340
 	 */
341
-    public static function output2( $post ) {
341
+    public static function output2($post) {
342 342
 
343 343
         // Prepare the invoice.
344
-        $invoice = new WPInv_Invoice( $post );
344
+        $invoice = new WPInv_Invoice($post);
345 345
 
346 346
         // Invoice items.
347 347
         $items = $invoice->get_items();
@@ -349,28 +349,28 @@  discard block
 block discarded – undo
349 349
         $totals = array(
350 350
 
351 351
             'subtotal'  => array(
352
-                'label' => __( 'Items Subtotal', 'invoicing' ),
353
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
352
+                'label' => __('Items Subtotal', 'invoicing'),
353
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
354 354
             ),
355 355
 
356 356
             'discount'  => array(
357
-                'label' => __( 'Total Discount', 'invoicing' ),
358
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
357
+                'label' => __('Total Discount', 'invoicing'),
358
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
359 359
             ),
360 360
 
361 361
             'tax'       => array(
362
-                'label' => __( 'Total Tax', 'invoicing' ),
363
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
362
+                'label' => __('Total Tax', 'invoicing'),
363
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
364 364
             ),
365 365
 
366 366
             'total'     => array(
367
-                'label' => __( 'Invoice Total', 'invoicing' ),
368
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
367
+                'label' => __('Invoice Total', 'invoicing'),
368
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
369 369
             )
370 370
         );
371 371
 
372
-        if ( ! wpinv_use_taxes() ) {
373
-            unset( $totals['tax'] );
372
+        if (!wpinv_use_taxes()) {
373
+            unset($totals['tax']);
374 374
         }
375 375
 
376 376
         $item_args = array(
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             'orderby'        => 'title',
379 379
             'order'          => 'ASC',
380 380
             'posts_per_page' => -1,
381
-            'post_status'    => array( 'publish' ),
381
+            'post_status'    => array('publish'),
382 382
             'meta_query'     => array(
383 383
                 array(
384 384
                     'key'       => '_wpinv_type',
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
             }
403 403
         </style>
404 404
 
405
-                <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
405
+                <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
406 406
 
407
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
408
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
407
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
408
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
409 409
 
410 410
                         <div class="row">
411 411
                             <div class="col-12 col-sm-6">
@@ -414,15 +414,15 @@  discard block
 block discarded – undo
414 414
                                         array(
415 415
                                             'id'          => 'wpinv_template',
416 416
                                             'name'        => 'wpinv_template',
417
-                                            'label'       => __( 'Template', 'invoicing' ),
417
+                                            'label'       => __('Template', 'invoicing'),
418 418
                                             'label_type'  => 'vertical',
419
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
419
+                                            'placeholder' => __('Choose a template', 'invoicing'),
420 420
                                             'class'       => 'form-control-sm',
421
-                                            'value'       => $invoice->get_template( 'edit' ),
421
+                                            'value'       => $invoice->get_template('edit'),
422 422
                                             'options'     => array(
423
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
424
-                                                'hours'    => __( 'Hours', 'invoicing' ),
425
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
423
+                                                'quantity' => __('Quantity', 'invoicing'),
424
+                                                'hours'    => __('Hours', 'invoicing'),
425
+                                                'amount'   => __('Amount Only', 'invoicing'),
426 426
                                             ),
427 427
                                             'data-allow-clear' => 'false',
428 428
                                             'select2'          => true,
@@ -438,11 +438,11 @@  discard block
 block discarded – undo
438 438
                                         array(
439 439
                                             'id'          => 'wpinv_currency',
440 440
                                             'name'        => 'wpinv_currency',
441
-                                            'label'       => __( 'Currency', 'invoicing' ),
441
+                                            'label'       => __('Currency', 'invoicing'),
442 442
                                             'label_type'  => 'vertical',
443
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
443
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
444 444
                                             'class'       => 'form-control-sm',
445
-                                            'value'       => $invoice->get_currency( 'edit' ),
445
+                                            'value'       => $invoice->get_currency('edit'),
446 446
                                             'required'    => false,
447 447
                                             'data-allow-clear' => 'false',
448 448
                                             'select2'          => true,
@@ -454,24 +454,24 @@  discard block
 block discarded – undo
454 454
                             </div>
455 455
                         </div>
456 456
 
457
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
457
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
458 458
                     <?php endif; ?>
459 459
 
460 460
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
461 461
                         <thead>
462 462
                             <tr>
463
-                                <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th>
463
+                                <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th>
464 464
                                 <th class="getpaid-quantity hide-if-amount text-right">
465
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
466
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
465
+                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
466
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
467 467
                                 </th>
468 468
                                 <th class="getpaid-price hide-if-amount text-right">
469
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span>
470
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span>
469
+                                    <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span>
470
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span>
471 471
                                 </th>
472 472
                                 <th class="getpaid-item-subtotal text-right">
473
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span>
474
-                                    <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span>
473
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span>
474
+                                    <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span>
475 475
                                 </th>
476 476
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
477 477
                             </tr>
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 		                <tbody class="getpaid_invoice_line_items">
480 480
                             <tr class="hide-if-has-items hide-if-not-editable">
481 481
                                 <td colspan="2" class="pt-4 pb-4">
482
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button>
483
-                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button>
482
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button>
483
+                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button>
484 484
                                 </td>
485 485
                                 <td class="hide-if-amount">&nbsp;</th>
486 486
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
                             <div class="col-12 col-sm-6 offset-sm-6">
513 513
                                 <table class="getpaid-invoice-totals text-right w-100">
514 514
                                     <tbody>
515
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
516
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
517
-                                                <td class="label"><?php echo sanitize_text_field( $data['label'] ) ?>:</td>
515
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
516
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
517
+                                                <td class="label"><?php echo sanitize_text_field($data['label']) ?>:</td>
518 518
                                                 <td width="1%"></td>
519
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td>
519
+                                                <td class="value"><?php echo wp_kses_post($data['value']) ?></td>
520 520
                                             </tr>
521 521
                                         <?php endforeach; ?>
522 522
                                     </tbody>
@@ -529,18 +529,18 @@  discard block
 block discarded – undo
529 529
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
530 530
                         <div class="row">
531 531
                             <div class="text-left col-12 col-sm-8">
532
-                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button>
533
-                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button>
534
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
532
+                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button>
533
+                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button>
534
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
535 535
                             </div>
536 536
                             <div class="text-right col-12 col-sm-4">
537
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button>
537
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button>
538 538
                             </div>
539 539
                         </div>
540 540
                     </div>
541 541
 
542 542
                     <div class="getpaid-invoice-item-actions hide-if-editable">
543
-                        <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
543
+                        <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p>
544 544
                     </div>
545 545
 
546 546
                     <!-- Add items to an invoice -->
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
                         <div class="modal-dialog modal-dialog-centered" role="document">
549 549
                             <div class="modal-content">
550 550
                                 <div class="modal-header">
551
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5>
552
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
551
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5>
552
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
553 553
                                         <span aria-hidden="true">&times;</span>
554 554
                                     </button>
555 555
                                 </div>
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
                                     <table class="widefat">
558 558
                                         <thead>
559 559
                                             <tr>
560
-                                                <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th>
560
+                                                <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th>
561 561
                                                 <th class="pr-0 text-right hide-if-amount">
562
-                                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
563
-                                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
562
+                                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
563
+                                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
564 564
                                                 </th>
565 565
                                             </tr>
566 566
                                         </thead>
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 								            <tr>
569 569
 									            <td class="pl-0 text-left">
570 570
                                                     <select class="regular-text getpaid-add-invoice-item-select">
571
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
572
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
573
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option>
571
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
572
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
573
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags($item->post_title); ?></option>
574 574
                                                         <?php endforeach; ?>
575 575
                                                     </select>
576 576
                                                 </td>
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 						            </table>
583 583
                                 </div>
584 584
                                 <div class="modal-footer">
585
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
586
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button>
585
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
586
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button>
587 587
                                 </div>
588 588
                             </div>
589 589
                         </div>
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
                         <div class="modal-dialog modal-dialog-centered" role="document">
595 595
                             <div class="modal-content">
596 596
                                 <div class="modal-header">
597
-                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e( "Create Item", 'invoicing' ); ?></h5>
598
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
597
+                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e("Create Item", 'invoicing'); ?></h5>
598
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
599 599
                                         <span aria-hidden="true">&times;</span>
600 600
                                     </button>
601 601
                                 </div>
@@ -603,27 +603,27 @@  discard block
 block discarded – undo
603 603
                                     <div class="getpaid-create-item-div">
604 604
                                         <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id">
605 605
                                         <label class="form-group w-100">
606
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
607
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
606
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
607
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
608 608
                                         </label>
609 609
                                         <label class="form-group w-100">
610
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
611
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
612
-                                            <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
610
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
611
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
612
+                                            <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
613 613
                                         </label>
614 614
                                         <label class="form-group w-100 hide-if-amount">
615
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
615
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
616 616
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
617 617
                                         </label>
618 618
                                         <label class="form-group w-100">
619
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
620
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
619
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
620
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
621 621
                                         </label>
622 622
                                     </div>
623 623
                                 </div>
624 624
                                 <div class="modal-footer">
625
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
626
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Create', 'invoicing' ); ?></button>
625
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
626
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Create', 'invoicing'); ?></button>
627 627
                                 </div>
628 628
                             </div>
629 629
                         </div>
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
                         <div class="modal-dialog modal-dialog-centered" role="document">
635 635
                             <div class="modal-content">
636 636
                                 <div class="modal-header">
637
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5>
638
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
637
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5>
638
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
639 639
                                         <span aria-hidden="true">&times;</span>
640 640
                                     </button>
641 641
                                 </div>
@@ -643,27 +643,27 @@  discard block
 block discarded – undo
643 643
                                     <div class="getpaid-edit-item-div">
644 644
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
645 645
                                         <label class="form-group w-100">
646
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
647
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
646
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
647
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
648 648
                                         </label>
649 649
                                         <label class="form-group w-100">
650
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
651
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
652
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
650
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
651
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
652
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
653 653
                                         </label>
654 654
                                         <label class="form-group w-100 hide-if-amount">
655
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
655
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
656 656
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
657 657
                                         </label>
658 658
                                         <label class="form-group w-100">
659
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
660
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
659
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
660
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
661 661
                                         </label>
662 662
                                     </div>
663 663
                                 </div>
664 664
                                 <div class="modal-footer">
665
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
666
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button>
665
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
666
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button>
667 667
                                 </div>
668 668
                             </div>
669 669
                         </div>
Please login to merge, or discard this patch.
includes/admin/views/wizard-thank-you.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -4,68 +4,68 @@
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 
11 11
 <div class="card shadow-sm my-5">
12 12
 	<div class="text-center card-body">
13
-		<h1 class="h3"><?php esc_html_e( 'Awesome, you are ready to Get Paid', 'invoicing' ); ?></h1>
13
+		<h1 class="h3"><?php esc_html_e('Awesome, you are ready to Get Paid', 'invoicing'); ?></h1>
14 14
 
15 15
 		<div class="geodirectory-message geodirectory-tracker">
16
-			<p><?php _e( 'Thank you for choosing GetPaid!', 'invoicing' ); ?> <i class="far fa-smile-beam"></i></p>
16
+			<p><?php _e('Thank you for choosing GetPaid!', 'invoicing'); ?> <i class="far fa-smile-beam"></i></p>
17 17
 		</div>
18 18
 
19 19
 		<div class="gp-setup-next-steps">
20 20
 			<div class="gp-setup-next-steps-first mb-4">
21 21
 				<div>
22
-					<h2 class="h3"><i class="fas fa-arrow-down"></i> <?php esc_html_e( 'Watch This', 'invoicing' ); ?> <i class="fas fa-arrow-down"></i></h2>
22
+					<h2 class="h3"><i class="fas fa-arrow-down"></i> <?php esc_html_e('Watch This', 'invoicing'); ?> <i class="fas fa-arrow-down"></i></h2>
23 23
 					<div class="embed-responsive embed-responsive-16by9 mb-4">
24 24
 						<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/TXZuPXHjt9E?rel=0" allowfullscreen></iframe>
25 25
 					</div>
26 26
 				</div>
27
-				<h2 class="h3"><?php esc_html_e( 'Next steps', 'invoicing' ); ?></h2>
27
+				<h2 class="h3"><?php esc_html_e('Next steps', 'invoicing'); ?></h2>
28 28
 
29 29
 				<div class="d-flex justify-content-between">
30 30
 					<a
31 31
 						class="btn btn-outline-primary btn-sm"
32
-						href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_item' ) ); ?>">
32
+						href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_item')); ?>">
33 33
 						<span class="h1 d-block"><i class="fas fa-box-open"></i></span>
34
-						<?php esc_html_e( 'Create Item', 'invoicing' ); ?>
34
+						<?php esc_html_e('Create Item', 'invoicing'); ?>
35 35
 					</a>
36 36
 					<a
37 37
 						class="btn btn-outline-primary btn-sm"
38
-						href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_payment_form' ) ); ?>">
38
+						href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_payment_form')); ?>">
39 39
 						<span class="h1 d-block"><i class="fas fa-align-justify"></i></span>
40
-						<?php esc_html_e( 'Create Payment Form', 'invoicing' ); ?>
40
+						<?php esc_html_e('Create Payment Form', 'invoicing'); ?>
41 41
 					</a>
42 42
 					<a
43 43
 						class="btn btn-outline-primary btn-sm"
44
-						href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_invoice' ) ); ?>">
44
+						href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_invoice')); ?>">
45 45
 						<span class="h1 d-block"><i class="fas fa-file-alt"></i></span>
46
-						<?php esc_html_e( 'Create Invoice', 'invoicing' ); ?>
46
+						<?php esc_html_e('Create Invoice', 'invoicing'); ?>
47 47
 					</a>
48 48
 				</div>
49 49
 
50 50
 
51 51
 
52
-						<h2 class="h3 mt-4"><?php _e( 'Learn more', 'invoicing' ); ?></h2>
52
+						<h2 class="h3 mt-4"><?php _e('Learn more', 'invoicing'); ?></h2>
53 53
 				<div class="gp-setup-next-steps-last mt-2 d-flex justify-content-between">
54 54
 						<a
55 55
 							class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/collection/114-getting-started?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=invoicingplugin"
56
-							target="_blank"><?php esc_html_e( 'Getting Started', 'invoicing' ); ?></a>
56
+							target="_blank"><?php esc_html_e('Getting Started', 'invoicing'); ?></a>
57 57
 						<a
58 58
 							class="btn btn-outline-primary btn-sm"
59 59
 							href="https://docs.wpgetpaid.com/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingplugin"
60
-							target="_blank"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a>
60
+							target="_blank"><?php esc_html_e('Documentation', 'invoicing'); ?></a>
61 61
 						<a
62 62
 							class="btn btn-outline-primary btn-sm"
63 63
 							href="https://wpgetpaid.com/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingyplugin"
64
-							target="_blank"><?php esc_html_e( 'Support', 'invoicing' ); ?></a>
64
+							target="_blank"><?php esc_html_e('Support', 'invoicing'); ?></a>
65 65
 						<a
66 66
 							class="btn btn-outline-primary btn-sm"
67 67
 							href="https://demos.ayecode.io/getpaid/?utm_source=setupwizard&utm_medium=product&utm_content=demos&utm_campaign=invoicingyplugin"
68
-							target="_blank"><?php esc_html_e( 'Demos', 'invoicing' ); ?></a>
68
+							target="_blank"><?php esc_html_e('Demos', 'invoicing'); ?></a>
69 69
 					</div>
70 70
 			</div>
71 71
 		</div>
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/plugin.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
  */
16 16
 
17 17
 if ( ! defined( 'ABSPATH' ) ) {
18
-	exit;
18
+    exit;
19 19
 }
20 20
 
21 21
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
22
-	// include the class if needed
23
-	include_once( dirname( __FILE__ ) . "/wp-deactivation-survey.php" );
22
+    // include the class if needed
23
+    include_once( dirname( __FILE__ ) . "/wp-deactivation-survey.php" );
24 24
 }
25 25
 
26 26
 
@@ -36,6 +36,6 @@  discard block
 block discarded – undo
36 36
 //});
37 37
 
38 38
 AyeCode_Deactivation_Survey::instance(array(
39
-	'slug'		=> 'ayecode-deactivation-survey-testing',
40
-	'version'	=> '1.0.0'
39
+    'slug'		=> 'ayecode-deactivation-survey-testing',
40
+    'version'	=> '1.0.0'
41 41
 ));
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
14 14
  * Tested up to: 5.8
15 15
  */
16 16
 
17
-if ( ! defined( 'ABSPATH' ) ) {
17
+if (!defined('ABSPATH')) {
18 18
 	exit;
19 19
 }
20 20
 
21
-if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
21
+if (!class_exists('AyeCode_Deactivation_Survey')) {
22 22
 	// include the class if needed
23
-	include_once( dirname( __FILE__ ) . "/wp-deactivation-survey.php" );
23
+	include_once(dirname(__FILE__) . "/wp-deactivation-survey.php");
24 24
 }
25 25
 
26 26
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/wp-deactivation-survey.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,102 +1,102 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
8 8
 
9
-	class AyeCode_Deactivation_Survey {
9
+    class AyeCode_Deactivation_Survey {
10 10
 
11
-		/**
12
-		 * AyeCode_Deactivation_Survey instance.
13
-		 *
14
-		 * @access private
15
-		 * @since  1.0.0
16
-		 * @var    AyeCode_Deactivation_Survey There can be only one!
17
-		 */
18
-		private static $instance = null;
11
+        /**
12
+         * AyeCode_Deactivation_Survey instance.
13
+         *
14
+         * @access private
15
+         * @since  1.0.0
16
+         * @var    AyeCode_Deactivation_Survey There can be only one!
17
+         */
18
+        private static $instance = null;
19 19
 
20
-		public static $plugins;
20
+        public static $plugins;
21 21
 
22
-		public $version = "1.0.3";
22
+        public $version = "1.0.3";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
-				self::$instance = new AyeCode_Deactivation_Survey;
27
-				self::$plugins = array();
24
+        public static function instance( $plugin = array() ) {
25
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
+                self::$instance = new AyeCode_Deactivation_Survey;
27
+                self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+                add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
32
-			}
31
+                do_action( 'ayecode_deactivation_survey_loaded' );
32
+            }
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
36
-			}
34
+            if(!empty($plugin)){
35
+                self::$plugins[] = (object)$plugin;
36
+            }
37 37
 
38
-			return self::$instance;
39
-		}
38
+            return self::$instance;
39
+        }
40 40
 
41
-		public function scripts() {
42
-			global $pagenow;
41
+        public function scripts() {
42
+            global $pagenow;
43 43
 
44
-			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
46
-				return;
47
-			}
44
+            // Bail if we are not on the plugins page
45
+            if ( $pagenow != "plugins.php" ) {
46
+                return;
47
+            }
48 48
 
49
-			// Enqueue scripts
50
-			add_thickbox();
51
-			wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
49
+            // Enqueue scripts
50
+            add_thickbox();
51
+            wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
52 52
 
53
-			/*
53
+            /*
54 54
 			 * Localized strings. Strings can be localised by plugins using this class.
55 55
 			 * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review.
56 56
 			 */
57
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
-				'quick_feedback'			=> 'Quick Feedback',
59
-				'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
-				'better_plugins_name'		=> 'Please tell us which plugin?',
61
-				'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
-				'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
-				'brief_description'			=> 'Please give us any feedback that could help us improve',
64
-				'cancel'					=> 'Cancel',
65
-				'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
-				'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
-				'please_wait'				=> 'Please wait',
68
-				'get_support'				=> 'Get Support',
69
-				'documentation'				=> 'Documentation',
70
-				'thank_you'					=> 'Thank you!',
71
-			));
72
-
73
-			// Plugins
74
-			$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
-
76
-			// Reasons
77
-			$defaultReasons = array(
78
-				'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
-				'plugin-broke-site'			=> 'The plugin broke my site',
80
-				'plugin-setup-difficult'	=> 'Too difficult to setup',
81
-				'no-longer-needed'			=> 'I don\'t need this plugin any more',
82
-				'found-better-plugin'		=> 'I found a better plugin',
83
-				'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
84
-				'other'						=> 'Other',
85
-			);
86
-
87
-			foreach($plugins as $plugin)
88
-			{
89
-				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
90
-				$plugin->url = home_url();
91
-				$plugin->activated = 0;
92
-			}
93
-
94
-			// Send plugin data
95
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
96
-
97
-		}
57
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
+                'quick_feedback'			=> 'Quick Feedback',
59
+                'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
+                'better_plugins_name'		=> 'Please tell us which plugin?',
61
+                'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
+                'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
+                'brief_description'			=> 'Please give us any feedback that could help us improve',
64
+                'cancel'					=> 'Cancel',
65
+                'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
+                'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
+                'please_wait'				=> 'Please wait',
68
+                'get_support'				=> 'Get Support',
69
+                'documentation'				=> 'Documentation',
70
+                'thank_you'					=> 'Thank you!',
71
+            ));
72
+
73
+            // Plugins
74
+            $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
+
76
+            // Reasons
77
+            $defaultReasons = array(
78
+                'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
+                'plugin-broke-site'			=> 'The plugin broke my site',
80
+                'plugin-setup-difficult'	=> 'Too difficult to setup',
81
+                'no-longer-needed'			=> 'I don\'t need this plugin any more',
82
+                'found-better-plugin'		=> 'I found a better plugin',
83
+                'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
84
+                'other'						=> 'Other',
85
+            );
86
+
87
+            foreach($plugins as $plugin)
88
+            {
89
+                $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
90
+                $plugin->url = home_url();
91
+                $plugin->activated = 0;
92
+            }
93
+
94
+            // Send plugin data
95
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
96
+
97
+        }
98 98
 		
99 99
 
100
-	}
100
+    }
101 101
 
102 102
 }
103 103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7
-if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
7
+if (!class_exists('AyeCode_Deactivation_Survey')) {
8 8
 
9 9
 	class AyeCode_Deactivation_Survey {
10 10
 
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
 
22 22
 		public $version = "1.0.3";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
24
+		public static function instance($plugin = array()) {
25
+			if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_Deactivation_Survey)) {
26 26
 				self::$instance = new AyeCode_Deactivation_Survey;
27 27
 				self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+				add_action('admin_enqueue_scripts', array(self::$instance, 'scripts'));
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
31
+				do_action('ayecode_deactivation_survey_loaded');
32 32
 			}
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
34
+			if (!empty($plugin)) {
35
+				self::$plugins[] = (object) $plugin;
36 36
 			}
37 37
 
38 38
 			return self::$instance;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			global $pagenow;
43 43
 
44 44
 			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
45
+			if ($pagenow != "plugins.php") {
46 46
 				return;
47 47
 			}
48 48
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 				'other'						=> 'Other',
85 85
 			);
86 86
 
87
-			foreach($plugins as $plugin)
87
+			foreach ($plugins as $plugin)
88 88
 			{
89 89
 				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
90 90
 				$plugin->url = home_url();
Please login to merge, or discard this patch.