Passed
Push — master ( 862b0e...047a35 )
by Stiofan
17:04
created
includes/wpinv-helper-functions.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
  */
98 98
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
99 99
 
100
-	$invoice_statuses = array(
101
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
100
+    $invoice_statuses = array(
101
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
102 102
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
103 103
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
104
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
105
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
106
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
104
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
105
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
106
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
107 107
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
108 108
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
109 109
     );
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         $invoice = $invoice->get_post_type();
121 121
     }
122 122
 
123
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
123
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
124 124
 }
125 125
 
126 126
 /**
@@ -238,25 +238,25 @@  discard block
 block discarded – undo
238 238
  * @return string
239 239
  */
240 240
 function getpaid_get_price_format() {
241
-	$currency_pos = wpinv_currency_position();
242
-	$format       = '%1$s%2$s';
243
-
244
-	switch ( $currency_pos ) {
245
-		case 'left':
246
-			$format = '%1$s%2$s';
247
-			break;
248
-		case 'right':
249
-			$format = '%2$s%1$s';
250
-			break;
251
-		case 'left_space':
252
-			$format = '%1$s %2$s';
253
-			break;
254
-		case 'right_space':
255
-			$format = '%2$s %1$s';
256
-			break;
257
-	}
258
-
259
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
241
+    $currency_pos = wpinv_currency_position();
242
+    $format       = '%1$s%2$s';
243
+
244
+    switch ( $currency_pos ) {
245
+        case 'left':
246
+            $format = '%1$s%2$s';
247
+            break;
248
+        case 'right':
249
+            $format = '%2$s%1$s';
250
+            break;
251
+        case 'left_space':
252
+            $format = '%1$s %2$s';
253
+            break;
254
+        case 'right_space':
255
+            $format = '%2$s %1$s';
256
+            break;
257
+    }
258
+
259
+    return apply_filters( 'getpaid_price_format', $format, $currency_pos );
260 260
 }
261 261
 
262 262
 /**
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
  * @param mixed  $value Value.
360 360
  */
361 361
 function getpaid_maybe_define_constant( $name, $value ) {
362
-	if ( ! defined( $name ) ) {
363
-		define( $name, $value );
364
-	}
362
+    if ( ! defined( $name ) ) {
363
+        define( $name, $value );
364
+    }
365 365
 }
366 366
 
367 367
 function wpinv_get_php_arg_separator_output() {
368
-	return ini_get( 'arg_separator.output' );
368
+    return ini_get( 'arg_separator.output' );
369 369
 }
370 370
 
371 371
 function wpinv_rgb_from_hex( $color ) {
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
         $list = array();
717 717
     }
718 718
 
719
-	if ( ! is_array( $list ) ) {
720
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
721
-	}
719
+    if ( ! is_array( $list ) ) {
720
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
721
+    }
722 722
 
723
-	return $list;
723
+    return $list;
724 724
 }
725 725
 
726 726
 /**
@@ -740,9 +740,9 @@  discard block
 block discarded – undo
740 740
     }
741 741
 
742 742
     $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
743
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
743
+    wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
744 744
 
745
-	return $data;
745
+    return $data;
746 746
 }
747 747
 
748 748
 /**
@@ -771,17 +771,17 @@  discard block
 block discarded – undo
771 771
  */
772 772
 function wpinv_clean( $var ) {
773 773
 
774
-	if ( is_array( $var ) ) {
775
-		return array_map( 'wpinv_clean', $var );
774
+    if ( is_array( $var ) ) {
775
+        return array_map( 'wpinv_clean', $var );
776 776
     }
777 777
 
778 778
     if ( is_object( $var ) ) {
779
-		$object_vars = get_object_vars( $var );
780
-		foreach ( $object_vars as $property_name => $property_value ) {
781
-			$var->$property_name = wpinv_clean( $property_value );
779
+        $object_vars = get_object_vars( $var );
780
+        foreach ( $object_vars as $property_name => $property_value ) {
781
+            $var->$property_name = wpinv_clean( $property_value );
782 782
         }
783 783
         return $var;
784
-	}
784
+    }
785 785
     
786 786
     return is_string( $var ) ? sanitize_text_field( $var ) : $var;
787 787
 }
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
  */
795 795
 function getpaid_convert_price_string_to_options( $str ) {
796 796
 
797
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
797
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
798 798
     $options     = array();
799 799
 
800 800
     foreach ( $raw_options as $option ) {
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
  * @return string
873 873
  */
874 874
 function getpaid_date_format() {
875
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
875
+    return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
876 876
 }
877 877
 
878 878
 /**
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
  * @return string
882 882
  */
883 883
 function getpaid_time_format() {
884
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
884
+    return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
885 885
 }
886 886
 
887 887
 /**
@@ -894,15 +894,15 @@  discard block
 block discarded – undo
894 894
 function getpaid_limit_length( $string, $limit ) {
895 895
     $str_limit = $limit - 3;
896 896
 
897
-	if ( function_exists( 'mb_strimwidth' ) ) {
898
-		if ( mb_strlen( $string ) > $limit ) {
899
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
900
-		}
901
-	} else {
902
-		if ( strlen( $string ) > $limit ) {
903
-			$string = substr( $string, 0, $str_limit ) . '...';
904
-		}
905
-	}
897
+    if ( function_exists( 'mb_strimwidth' ) ) {
898
+        if ( mb_strlen( $string ) > $limit ) {
899
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
900
+        }
901
+    } else {
902
+        if ( strlen( $string ) > $limit ) {
903
+            $string = substr( $string, 0, $str_limit ) . '...';
904
+        }
905
+    }
906 906
     return $string;
907 907
 
908 908
 }
Please login to merge, or discard this patch.
Spacing   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
  * 
57 57
  * @param string $amount The amount to sanitize.
58 58
  */
59
-function wpinv_sanitize_amount( $amount ) {
59
+function wpinv_sanitize_amount($amount) {
60 60
 
61
-    if ( is_numeric( $amount ) ) {
62
-        return floatval( $amount );
61
+    if (is_numeric($amount)) {
62
+        return floatval($amount);
63 63
     }
64 64
 
65 65
     // Separate the decimals and thousands.
66
-    $amount    = explode( wpinv_decimal_separator(), $amount );
66
+    $amount    = explode(wpinv_decimal_separator(), $amount);
67 67
 
68 68
     // Remove thousands.
69
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
69
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
70 70
 
71 71
     // Convert back to string.
72
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
72
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
73 73
 
74 74
     // Cast the remaining to a float.
75
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
75
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
76 76
 
77 77
 }
78 78
 
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
  * @param float $amount
83 83
  * @param float|string|int|null $decimals
84 84
  */
85
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
85
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
86 86
 
87
-    if ( $decimals === null ) {
87
+    if ($decimals === null) {
88 88
         $decimals = wpinv_decimals();
89 89
     }
90 90
 
91
-    if ( $use_sprintf ) {
92
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
91
+    if ($use_sprintf) {
92
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
93 93
     } else {
94
-        $amount = round( (float) $amount, absint( $decimals ) );
94
+        $amount = round((float) $amount, absint($decimals));
95 95
     }
96 96
 
97
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
97
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
98 98
 }
99 99
 
100 100
 /**
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
107 107
  * @return array
108 108
  */
109
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
109
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
110 110
 
111 111
 	$invoice_statuses = array(
112
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
113
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
114
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
115
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
116
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
117
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
118
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
119
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
112
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
113
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
114
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
115
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
116
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
117
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
118
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
119
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
120 120
     );
121 121
 
122
-    if ( $draft ) {
123
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
122
+    if ($draft) {
123
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
124 124
     }
125 125
 
126
-    if ( $trashed ) {
127
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
126
+    if ($trashed) {
127
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
128 128
     }
129 129
 
130
-    if ( $invoice instanceof WPInv_Invoice ) {
130
+    if ($invoice instanceof WPInv_Invoice) {
131 131
         $invoice = $invoice->get_post_type();
132 132
     }
133 133
 
134
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
134
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
135 135
 }
136 136
 
137 137
 /**
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
  * @param string $status The raw status
141 141
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
142 142
  */
143
-function wpinv_status_nicename( $status, $invoice = false ) {
144
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
145
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : $status;
143
+function wpinv_status_nicename($status, $invoice = false) {
144
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
145
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
146 146
 
147
-    return sanitize_text_field( $status );
147
+    return sanitize_text_field($status);
148 148
 }
149 149
 
150 150
 /**
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
  * 
153 153
  * @param string $current
154 154
  */
155
-function wpinv_get_currency( $current = '' ) {
155
+function wpinv_get_currency($current = '') {
156 156
 
157
-    if ( empty( $current ) ) {
158
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
157
+    if (empty($current)) {
158
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
159 159
     }
160 160
 
161
-    return trim( strtoupper( $current ) );
161
+    return trim(strtoupper($current));
162 162
 }
163 163
 
164 164
 /**
@@ -166,25 +166,25 @@  discard block
 block discarded – undo
166 166
  * 
167 167
  * @param string|null $currency The currency code. Defaults to the default currency.
168 168
  */
169
-function wpinv_currency_symbol( $currency = null ) {
169
+function wpinv_currency_symbol($currency = null) {
170 170
 
171 171
     // Prepare the currency.
172
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
172
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
173 173
 
174 174
     // Fetch all symbols.
175 175
     $symbols = wpinv_get_currency_symbols();
176 176
 
177 177
     // Fetch this currencies symbol.
178
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
178
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
179 179
 
180 180
     // Filter the symbol.
181
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
181
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
182 182
 }
183 183
 
184 184
 function wpinv_currency_position() {
185
-    $position = wpinv_get_option( 'currency_position', 'left' );
185
+    $position = wpinv_get_option('currency_position', 'left');
186 186
     
187
-    return apply_filters( 'wpinv_currency_position', $position );
187
+    return apply_filters('wpinv_currency_position', $position);
188 188
 }
189 189
 
190 190
 /**
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
  * 
193 193
  * @param $string|null $current
194 194
  */
195
-function wpinv_thousands_separator( $current = null ) {
195
+function wpinv_thousands_separator($current = null) {
196 196
 
197
-    if ( null == $current ) {
198
-        $current = wpinv_get_option( 'thousands_separator', ',' );
197
+    if (null == $current) {
198
+        $current = wpinv_get_option('thousands_separator', ',');
199 199
     }
200 200
 
201
-    return trim( $current );
201
+    return trim($current);
202 202
 }
203 203
 
204 204
 /**
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
  * 
207 207
  * @param $string|null $current
208 208
  */
209
-function wpinv_decimal_separator( $current = null ) {
209
+function wpinv_decimal_separator($current = null) {
210 210
 
211
-    if ( null == $current ) {
212
-        $current = wpinv_get_option( 'decimal_separator', '.' );
211
+    if (null == $current) {
212
+        $current = wpinv_get_option('decimal_separator', '.');
213 213
     }
214 214
     
215
-    return trim( $current );
215
+    return trim($current);
216 216
 }
217 217
 
218 218
 /**
@@ -220,27 +220,27 @@  discard block
 block discarded – undo
220 220
  * 
221 221
  * @param $string|null $current
222 222
  */
223
-function wpinv_decimals( $current = null ) {
223
+function wpinv_decimals($current = null) {
224 224
 
225
-    if ( null == $current ) {
226
-        $current = wpinv_get_option( 'decimals', 2 );
225
+    if (null == $current) {
226
+        $current = wpinv_get_option('decimals', 2);
227 227
     }
228 228
     
229
-    return absint( $current );
229
+    return absint($current);
230 230
 }
231 231
 
232 232
 /**
233 233
  * Retrieves a list of all supported currencies.
234 234
  */
235 235
 function wpinv_get_currencies() {
236
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
236
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
237 237
 }
238 238
 
239 239
 /**
240 240
  * Retrieves a list of all currency symbols.
241 241
  */
242 242
 function wpinv_get_currency_symbols() {
243
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
243
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
244 244
 }
245 245
 
246 246
 /**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	$currency_pos = wpinv_currency_position();
253 253
 	$format       = '%1$s%2$s';
254 254
 
255
-	switch ( $currency_pos ) {
255
+	switch ($currency_pos) {
256 256
 		case 'left':
257 257
 			$format = '%1$s%2$s';
258 258
 			break;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 			break;
268 268
 	}
269 269
 
270
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
270
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
271 271
 }
272 272
 
273 273
 /**
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
  * @param  string $currency Currency.
278 278
  * @return string
279 279
  */
280
-function wpinv_price( $amount = 0, $currency = '' ) {
280
+function wpinv_price($amount = 0, $currency = '') {
281 281
 
282 282
     // Backwards compatibility.
283
-    $amount             = wpinv_sanitize_amount( $amount );
283
+    $amount             = wpinv_sanitize_amount($amount);
284 284
 
285 285
     // Prepare variables.
286
-    $currency           = wpinv_get_currency( $currency );
286
+    $currency           = wpinv_get_currency($currency);
287 287
     $amount             = (float) $amount;
288 288
     $unformatted_amount = $amount;
289 289
     $negative           = $amount < 0;
290
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
291
-    $amount             = wpinv_format_amount( $amount );
290
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
291
+    $amount             = wpinv_format_amount($amount);
292 292
 
293 293
     // Format the amount.
294 294
     $format             = getpaid_get_price_format();
295
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
295
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
296 296
 
297 297
     // Filter the formatting.
298
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
298
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
299 299
 }
300 300
 
301 301
 /**
@@ -306,25 +306,25 @@  discard block
 block discarded – undo
306 306
  * @param  bool     $calculate Whether or not to apply separators.
307 307
  * @return string
308 308
  */
309
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
309
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
310 310
     $thousands_sep = wpinv_thousands_separator();
311 311
     $decimal_sep   = wpinv_decimal_separator();
312
-    $decimals      = wpinv_decimals( $decimals );
313
-    $amount        = wpinv_sanitize_amount( $amount );
312
+    $decimals      = wpinv_decimals($decimals);
313
+    $amount        = wpinv_sanitize_amount($amount);
314 314
 
315
-    if ( $calculate ) {
315
+    if ($calculate) {
316 316
         return $amount;
317 317
     }
318 318
 
319 319
     // Fomart the amount.
320
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
320
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
321 321
 }
322 322
 
323
-function wpinv_sanitize_key( $key ) {
323
+function wpinv_sanitize_key($key) {
324 324
     $raw_key = $key;
325
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
325
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
326 326
 
327
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
327
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
328 328
 }
329 329
 
330 330
 /**
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
  * 
333 333
  * @param $str the file whose extension should be retrieved.
334 334
  */
335
-function wpinv_get_file_extension( $str ) {
336
-    $filetype = wp_check_filetype( $str );
335
+function wpinv_get_file_extension($str) {
336
+    $filetype = wp_check_filetype($str);
337 337
     return $filetype['ext'];
338 338
 }
339 339
 
@@ -342,16 +342,16 @@  discard block
 block discarded – undo
342 342
  * 
343 343
  * @param string $string
344 344
  */
345
-function wpinv_string_is_image_url( $string ) {
346
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
347
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
345
+function wpinv_string_is_image_url($string) {
346
+    $extension = strtolower(wpinv_get_file_extension($string));
347
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
348 348
 }
349 349
 
350 350
 /**
351 351
  * Returns the current URL.
352 352
  */
353 353
 function wpinv_get_current_page_url() {
354
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
354
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
355 355
 }
356 356
 
357 357
 /**
@@ -361,46 +361,46 @@  discard block
 block discarded – undo
361 361
  * @param string $name  Constant name.
362 362
  * @param mixed  $value Value.
363 363
  */
364
-function getpaid_maybe_define_constant( $name, $value ) {
365
-	if ( ! defined( $name ) ) {
366
-		define( $name, $value );
364
+function getpaid_maybe_define_constant($name, $value) {
365
+	if (!defined($name)) {
366
+		define($name, $value);
367 367
 	}
368 368
 }
369 369
 
370 370
 function wpinv_get_php_arg_separator_output() {
371
-	return ini_get( 'arg_separator.output' );
371
+	return ini_get('arg_separator.output');
372 372
 }
373 373
 
374
-function wpinv_rgb_from_hex( $color ) {
375
-    $color = str_replace( '#', '', $color );
374
+function wpinv_rgb_from_hex($color) {
375
+    $color = str_replace('#', '', $color);
376 376
 
377 377
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
378
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
379
-    if ( empty( $color ) ) {
378
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
379
+    if (empty($color)) {
380 380
         return NULL;
381 381
     }
382 382
 
383
-    $color = str_split( $color );
383
+    $color = str_split($color);
384 384
 
385 385
     $rgb      = array();
386
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
387
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
388
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
386
+    $rgb['R'] = hexdec($color[0] . $color[1]);
387
+    $rgb['G'] = hexdec($color[2] . $color[3]);
388
+    $rgb['B'] = hexdec($color[4] . $color[5]);
389 389
 
390 390
     return $rgb;
391 391
 }
392 392
 
393
-function wpinv_hex_darker( $color, $factor = 30 ) {
394
-    $base  = wpinv_rgb_from_hex( $color );
393
+function wpinv_hex_darker($color, $factor = 30) {
394
+    $base  = wpinv_rgb_from_hex($color);
395 395
     $color = '#';
396 396
 
397
-    foreach ( $base as $k => $v ) {
397
+    foreach ($base as $k => $v) {
398 398
         $amount      = $v / 100;
399
-        $amount      = round( $amount * $factor );
399
+        $amount      = round($amount * $factor);
400 400
         $new_decimal = $v - $amount;
401 401
 
402
-        $new_hex_component = dechex( $new_decimal );
403
-        if ( strlen( $new_hex_component ) < 2 ) {
402
+        $new_hex_component = dechex($new_decimal);
403
+        if (strlen($new_hex_component) < 2) {
404 404
             $new_hex_component = "0" . $new_hex_component;
405 405
         }
406 406
         $color .= $new_hex_component;
@@ -409,18 +409,18 @@  discard block
 block discarded – undo
409 409
     return $color;
410 410
 }
411 411
 
412
-function wpinv_hex_lighter( $color, $factor = 30 ) {
413
-    $base  = wpinv_rgb_from_hex( $color );
412
+function wpinv_hex_lighter($color, $factor = 30) {
413
+    $base  = wpinv_rgb_from_hex($color);
414 414
     $color = '#';
415 415
 
416
-    foreach ( $base as $k => $v ) {
416
+    foreach ($base as $k => $v) {
417 417
         $amount      = 255 - $v;
418 418
         $amount      = $amount / 100;
419
-        $amount      = round( $amount * $factor );
419
+        $amount      = round($amount * $factor);
420 420
         $new_decimal = $v + $amount;
421 421
 
422
-        $new_hex_component = dechex( $new_decimal );
423
-        if ( strlen( $new_hex_component ) < 2 ) {
422
+        $new_hex_component = dechex($new_decimal);
423
+        if (strlen($new_hex_component) < 2) {
424 424
             $new_hex_component = "0" . $new_hex_component;
425 425
         }
426 426
         $color .= $new_hex_component;
@@ -429,22 +429,22 @@  discard block
 block discarded – undo
429 429
     return $color;
430 430
 }
431 431
 
432
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
433
-    $hex = str_replace( '#', '', $color );
432
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
433
+    $hex = str_replace('#', '', $color);
434 434
 
435
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
436
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
437
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
435
+    $c_r = hexdec(substr($hex, 0, 2));
436
+    $c_g = hexdec(substr($hex, 2, 2));
437
+    $c_b = hexdec(substr($hex, 4, 2));
438 438
 
439
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
439
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
440 440
 
441 441
     return $brightness > 155 ? $dark : $light;
442 442
 }
443 443
 
444
-function wpinv_format_hex( $hex ) {
445
-    $hex = trim( str_replace( '#', '', $hex ) );
444
+function wpinv_format_hex($hex) {
445
+    $hex = trim(str_replace('#', '', $hex));
446 446
 
447
-    if ( strlen( $hex ) == 3 ) {
447
+    if (strlen($hex) == 3) {
448 448
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
449 449
     }
450 450
 
@@ -464,12 +464,12 @@  discard block
 block discarded – undo
464 464
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
465 465
  * @return string
466 466
  */
467
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
468
-    if ( function_exists( 'mb_strimwidth' ) ) {
469
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
467
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
468
+    if (function_exists('mb_strimwidth')) {
469
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
470 470
     }
471 471
     
472
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
472
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
473 473
 }
474 474
 
475 475
 /**
@@ -481,28 +481,28 @@  discard block
 block discarded – undo
481 481
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
482 482
  * @return int Returns the number of characters in string.
483 483
  */
484
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
485
-    if ( function_exists( 'mb_strlen' ) ) {
486
-        return mb_strlen( $str, $encoding );
484
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
485
+    if (function_exists('mb_strlen')) {
486
+        return mb_strlen($str, $encoding);
487 487
     }
488 488
         
489
-    return strlen( $str );
489
+    return strlen($str);
490 490
 }
491 491
 
492
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
493
-    if ( function_exists( 'mb_strtolower' ) ) {
494
-        return mb_strtolower( $str, $encoding );
492
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
493
+    if (function_exists('mb_strtolower')) {
494
+        return mb_strtolower($str, $encoding);
495 495
     }
496 496
     
497
-    return strtolower( $str );
497
+    return strtolower($str);
498 498
 }
499 499
 
500
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
501
-    if ( function_exists( 'mb_strtoupper' ) ) {
502
-        return mb_strtoupper( $str, $encoding );
500
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
501
+    if (function_exists('mb_strtoupper')) {
502
+        return mb_strtoupper($str, $encoding);
503 503
     }
504 504
     
505
-    return strtoupper( $str );
505
+    return strtoupper($str);
506 506
 }
507 507
 
508 508
 /**
@@ -516,12 +516,12 @@  discard block
 block discarded – undo
516 516
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
517 517
  * @return int Returns the position of the first occurrence of search in the string.
518 518
  */
519
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
520
-    if ( function_exists( 'mb_strpos' ) ) {
521
-        return mb_strpos( $str, $find, $offset, $encoding );
519
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
520
+    if (function_exists('mb_strpos')) {
521
+        return mb_strpos($str, $find, $offset, $encoding);
522 522
     }
523 523
         
524
-    return strpos( $str, $find, $offset );
524
+    return strpos($str, $find, $offset);
525 525
 }
526 526
 
527 527
 /**
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
536 536
  * @return int Returns the position of the last occurrence of search.
537 537
  */
538
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
539
-    if ( function_exists( 'mb_strrpos' ) ) {
540
-        return mb_strrpos( $str, $find, $offset, $encoding );
538
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
539
+    if (function_exists('mb_strrpos')) {
540
+        return mb_strrpos($str, $find, $offset, $encoding);
541 541
     }
542 542
         
543
-    return strrpos( $str, $find, $offset );
543
+    return strrpos($str, $find, $offset);
544 544
 }
545 545
 
546 546
 /**
@@ -555,16 +555,16 @@  discard block
 block discarded – undo
555 555
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
556 556
  * @return string
557 557
  */
558
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
559
-    if ( function_exists( 'mb_substr' ) ) {
560
-        if ( $length === null ) {
561
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
558
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
559
+    if (function_exists('mb_substr')) {
560
+        if ($length === null) {
561
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
562 562
         } else {
563
-            return mb_substr( $str, $start, $length, $encoding );
563
+            return mb_substr($str, $start, $length, $encoding);
564 564
         }
565 565
     }
566 566
         
567
-    return substr( $str, $start, $length );
567
+    return substr($str, $start, $length);
568 568
 }
569 569
 
570 570
 /**
@@ -576,48 +576,48 @@  discard block
 block discarded – undo
576 576
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
577 577
  * @return string The width of string.
578 578
  */
579
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
580
-    if ( function_exists( 'mb_strwidth' ) ) {
581
-        return mb_strwidth( $str, $encoding );
579
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
580
+    if (function_exists('mb_strwidth')) {
581
+        return mb_strwidth($str, $encoding);
582 582
     }
583 583
     
584
-    return wpinv_utf8_strlen( $str, $encoding );
584
+    return wpinv_utf8_strlen($str, $encoding);
585 585
 }
586 586
 
587
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
588
-    if ( function_exists( 'mb_strlen' ) ) {
589
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
587
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
588
+    if (function_exists('mb_strlen')) {
589
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
590 590
         $str_end = "";
591 591
         
592
-        if ( $lower_str_end ) {
593
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
592
+        if ($lower_str_end) {
593
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
594 594
         } else {
595
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
595
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
596 596
         }
597 597
 
598 598
         return $first_letter . $str_end;
599 599
     }
600 600
     
601
-    return ucfirst( $str );
601
+    return ucfirst($str);
602 602
 }
603 603
 
604
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
605
-    if ( function_exists( 'mb_convert_case' ) ) {
606
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
604
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
605
+    if (function_exists('mb_convert_case')) {
606
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
607 607
     }
608 608
     
609
-    return ucwords( $str );
609
+    return ucwords($str);
610 610
 }
611 611
 
612
-function wpinv_period_in_days( $period, $unit ) {
613
-    $period = absint( $period );
612
+function wpinv_period_in_days($period, $unit) {
613
+    $period = absint($period);
614 614
     
615
-    if ( $period > 0 ) {
616
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
615
+    if ($period > 0) {
616
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
617 617
             $period = $period * 7;
618
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
618
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
619 619
             $period = $period * 30;
620
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
620
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
621 621
             $period = $period * 365;
622 622
         }
623 623
     }
@@ -625,14 +625,14 @@  discard block
 block discarded – undo
625 625
     return $period;
626 626
 }
627 627
 
628
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
629
-    if ( function_exists( 'cal_days_in_month' ) ) {
630
-        return cal_days_in_month( $calendar, $month, $year );
628
+function wpinv_cal_days_in_month($calendar, $month, $year) {
629
+    if (function_exists('cal_days_in_month')) {
630
+        return cal_days_in_month($calendar, $month, $year);
631 631
     }
632 632
 
633 633
     // Fallback in case the calendar extension is not loaded in PHP
634 634
     // Only supports Gregorian calendar
635
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
635
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
636 636
 }
637 637
 
638 638
 /**
@@ -643,12 +643,12 @@  discard block
 block discarded – undo
643 643
  *
644 644
  * @return string
645 645
  */
646
-function wpi_help_tip( $tip, $allow_html = false ) {
646
+function wpi_help_tip($tip, $allow_html = false) {
647 647
 
648
-    if ( $allow_html ) {
649
-        $tip = wpi_sanitize_tooltip( $tip );
648
+    if ($allow_html) {
649
+        $tip = wpi_sanitize_tooltip($tip);
650 650
     } else {
651
-        $tip = esc_attr( $tip );
651
+        $tip = esc_attr($tip);
652 652
     }
653 653
 
654 654
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
  * @param string $var
663 663
  * @return string
664 664
  */
665
-function wpi_sanitize_tooltip( $var ) {
666
-    return wp_kses( html_entity_decode( $var ), array(
665
+function wpi_sanitize_tooltip($var) {
666
+    return wp_kses(html_entity_decode($var), array(
667 667
         'br'     => array(),
668 668
         'em'     => array(),
669 669
         'strong' => array(),
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         'li'     => array(),
675 675
         'ol'     => array(),
676 676
         'p'      => array(),
677
-    ) );
677
+    ));
678 678
 }
679 679
 
680 680
 /**
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
  */
685 685
 function wpinv_get_screen_ids() {
686 686
 
687
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
687
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
688 688
 
689 689
     $screen_ids = array(
690 690
         'toplevel_page_' . $screen_id,
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
         'getpaid_page_wpinv-customers',
706 706
     );
707 707
 
708
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
708
+    return apply_filters('wpinv_screen_ids', $screen_ids);
709 709
 }
710 710
 
711 711
 /**
@@ -716,14 +716,14 @@  discard block
 block discarded – undo
716 716
  * @param array|string $list List of values.
717 717
  * @return array Sanitized array of values.
718 718
  */
719
-function wpinv_parse_list( $list ) {
719
+function wpinv_parse_list($list) {
720 720
 
721
-    if ( empty( $list ) ) {
721
+    if (empty($list)) {
722 722
         $list = array();
723 723
     }
724 724
 
725
-	if ( ! is_array( $list ) ) {
726
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
725
+	if (!is_array($list)) {
726
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
727 727
 	}
728 728
 
729 729
 	return $list;
@@ -737,16 +737,16 @@  discard block
 block discarded – undo
737 737
  * @param string $key Type of data to fetch.
738 738
  * @return mixed Fetched data.
739 739
  */
740
-function wpinv_get_data( $key ) {
740
+function wpinv_get_data($key) {
741 741
 
742 742
     // Try fetching it from the cache.
743
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
744
-    if( $data ) {
743
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
744
+    if ($data) {
745 745
         return $data;
746 746
     }
747 747
 
748
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
749
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
748
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
749
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
750 750
 
751 751
 	return $data;
752 752
 }
@@ -760,10 +760,10 @@  discard block
 block discarded – undo
760 760
  * @param bool $first_empty Whether or not the first item in the list should be empty
761 761
  * @return mixed Fetched data.
762 762
  */
763
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
763
+function wpinv_maybe_add_empty_option($options, $first_empty) {
764 764
 
765
-    if ( ! empty( $options ) && $first_empty ) {
766
-        return array_merge( array( '' => '' ), $options );
765
+    if (!empty($options) && $first_empty) {
766
+        return array_merge(array('' => ''), $options);
767 767
     }
768 768
     return $options;
769 769
 
@@ -775,21 +775,21 @@  discard block
 block discarded – undo
775 775
  * @param mixed $var Data to sanitize.
776 776
  * @return string|array
777 777
  */
778
-function wpinv_clean( $var ) {
778
+function wpinv_clean($var) {
779 779
 
780
-	if ( is_array( $var ) ) {
781
-		return array_map( 'wpinv_clean', $var );
780
+	if (is_array($var)) {
781
+		return array_map('wpinv_clean', $var);
782 782
     }
783 783
 
784
-    if ( is_object( $var ) ) {
785
-		$object_vars = get_object_vars( $var );
786
-		foreach ( $object_vars as $property_name => $property_value ) {
787
-			$var->$property_name = wpinv_clean( $property_value );
784
+    if (is_object($var)) {
785
+		$object_vars = get_object_vars($var);
786
+		foreach ($object_vars as $property_name => $property_value) {
787
+			$var->$property_name = wpinv_clean($property_value);
788 788
         }
789 789
         return $var;
790 790
 	}
791 791
     
792
-    return is_string( $var ) ? sanitize_text_field( $var ) : $var;
792
+    return is_string($var) ? sanitize_text_field($var) : $var;
793 793
 }
794 794
 
795 795
 /**
@@ -798,43 +798,43 @@  discard block
 block discarded – undo
798 798
  * @param string $str Data to convert.
799 799
  * @return string|array
800 800
  */
801
-function getpaid_convert_price_string_to_options( $str ) {
801
+function getpaid_convert_price_string_to_options($str) {
802 802
 
803
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
804
-    $options     = array();
803
+	$raw_options = array_map('trim', explode(',', $str));
804
+    $options = array();
805 805
 
806
-    foreach ( $raw_options as $option ) {
806
+    foreach ($raw_options as $option) {
807 807
 
808
-        if ( '' == $option ) {
808
+        if ('' == $option) {
809 809
             continue;
810 810
         }
811 811
 
812
-        $option = array_map( 'trim', explode( '|', $option ) );
812
+        $option = array_map('trim', explode('|', $option));
813 813
 
814 814
         $price = null;
815 815
         $label = null;
816 816
 
817
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
818
-            $label  = $option[0];
817
+        if (isset($option[0]) && '' != $option[0]) {
818
+            $label = $option[0];
819 819
         }
820 820
 
821
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
821
+        if (isset($option[1]) && '' != $option[1]) {
822 822
             $price = $option[1];
823 823
         }
824 824
 
825
-        if ( ! isset( $price ) ) {
825
+        if (!isset($price)) {
826 826
             $price = $label;
827 827
         }
828 828
 
829
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
829
+        if (!isset($price) || !is_numeric($price)) {
830 830
             continue;
831 831
         }
832 832
 
833
-        if ( ! isset( $label ) ) {
833
+        if (!isset($label)) {
834 834
             $label = $price;
835 835
         }
836 836
 
837
-        $options[ $price ] = $label;
837
+        $options[$price] = $label;
838 838
     }
839 839
 
840 840
     return $options;
@@ -843,27 +843,27 @@  discard block
 block discarded – undo
843 843
 /**
844 844
  * Returns the help tip.
845 845
  */
846
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
847
-    $additional_classes = sanitize_html_class( $additional_classes );
848
-    $tip                = esc_attr__( $tip );
846
+function getpaid_get_help_tip($tip, $additional_classes = '') {
847
+    $additional_classes = sanitize_html_class($additional_classes);
848
+    $tip                = esc_attr__($tip);
849 849
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
850 850
 }
851 851
 
852 852
 /**
853 853
  * Formats a date
854 854
  */
855
-function getpaid_format_date( $date, $with_time = false ) {
855
+function getpaid_format_date($date, $with_time = false) {
856 856
 
857
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
857
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
858 858
         return '';
859 859
     }
860 860
 
861 861
     $format = getpaid_date_format();
862 862
 
863
-    if ( $with_time ) {
863
+    if ($with_time) {
864 864
         $format .= ' ' . getpaid_time_format();
865 865
     }
866
-    return date_i18n( $format, strtotime( $date ) );
866
+    return date_i18n($format, strtotime($date));
867 867
 
868 868
 }
869 869
 
@@ -872,9 +872,9 @@  discard block
 block discarded – undo
872 872
  *
873 873
  * @return string
874 874
  */
875
-function getpaid_format_date_value( $date, $default = "&mdash;", $with_time = false ) {
876
-    $date = getpaid_format_date( $date, $with_time );
877
-    return empty( $date ) ? $default : $date;
875
+function getpaid_format_date_value($date, $default = "&mdash;", $with_time = false) {
876
+    $date = getpaid_format_date($date, $with_time);
877
+    return empty($date) ? $default : $date;
878 878
 }
879 879
 
880 880
 /**
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
  * @return string
884 884
  */
885 885
 function getpaid_date_format() {
886
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
886
+	return apply_filters('getpaid_date_format', get_option('date_format'));
887 887
 }
888 888
 
889 889
 /**
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
  * @return string
893 893
  */
894 894
 function getpaid_time_format() {
895
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
895
+	return apply_filters('getpaid_time_format', get_option('time_format'));
896 896
 }
897 897
 
898 898
 /**
@@ -902,16 +902,16 @@  discard block
 block discarded – undo
902 902
  * @param  integer $limit Limit size in characters.
903 903
  * @return string
904 904
  */
905
-function getpaid_limit_length( $string, $limit ) {
905
+function getpaid_limit_length($string, $limit) {
906 906
     $str_limit = $limit - 3;
907 907
 
908
-	if ( function_exists( 'mb_strimwidth' ) ) {
909
-		if ( mb_strlen( $string ) > $limit ) {
910
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
908
+	if (function_exists('mb_strimwidth')) {
909
+		if (mb_strlen($string) > $limit) {
910
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
911 911
 		}
912 912
 	} else {
913
-		if ( strlen( $string ) > $limit ) {
914
-			$string = substr( $string, 0, $str_limit ) . '...';
913
+		if (strlen($string) > $limit) {
914
+			$string = substr($string, 0, $str_limit) . '...';
915 915
 		}
916 916
 	}
917 917
     return $string;
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
  * @since 1.0.19
926 926
  */
927 927
 function getpaid_api() {
928
-    return getpaid()->get( 'api' );
928
+    return getpaid()->get('api');
929 929
 }
930 930
 
931 931
 /**
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
  * @since 1.0.19
936 936
  */
937 937
 function getpaid_post_types() {
938
-    return getpaid()->get( 'post_types' );
938
+    return getpaid()->get('post_types');
939 939
 }
940 940
 
941 941
 /**
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
  * @since 1.0.19
946 946
  */
947 947
 function getpaid_session() {
948
-    return getpaid()->get( 'session' );
948
+    return getpaid()->get('session');
949 949
 }
950 950
 
951 951
 /**
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
  * @since 1.0.19
956 956
  */
957 957
 function getpaid_notes() {
958
-    return getpaid()->get( 'notes' );
958
+    return getpaid()->get('notes');
959 959
 }
960 960
 
961 961
 /**
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
  * @return GetPaid_Admin
965 965
  */
966 966
 function getpaid_admin() {
967
-    return getpaid()->get( 'admin' );
967
+    return getpaid()->get('admin');
968 968
 }
969 969
 
970 970
 /**
@@ -974,8 +974,8 @@  discard block
 block discarded – undo
974 974
  * @param string $base the base url
975 975
  * @return string
976 976
  */
977
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
978
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
977
+function getpaid_get_authenticated_action_url($action, $base = false) {
978
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
979 979
 }
980 980
 
981 981
 /**
@@ -983,11 +983,11 @@  discard block
 block discarded – undo
983 983
  *
984 984
  * @return string
985 985
  */
986
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
986
+function getpaid_get_post_type_label($post_type, $plural = true) {
987 987
 
988
-    $post_type = get_post_type_object( $post_type );
988
+    $post_type = get_post_type_object($post_type);
989 989
 
990
-    if ( ! is_object( $post_type ) ) {
990
+    if (!is_object($post_type)) {
991 991
         return null;
992 992
     }
993 993
 
@@ -1000,18 +1000,18 @@  discard block
 block discarded – undo
1000 1000
  *
1001 1001
  * @return mixed|null
1002 1002
  */
1003
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1003
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1004 1004
 
1005
-    if ( ! is_array( $array ) ) {
1005
+    if (!is_array($array)) {
1006 1006
         return null;
1007 1007
     }
1008 1008
 
1009
-    if ( ! empty( $secondary_key ) ) {
1010
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1011
-        return getpaid_get_array_field( $array, $key );
1009
+    if (!empty($secondary_key)) {
1010
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1011
+        return getpaid_get_array_field($array, $key);
1012 1012
     }
1013 1013
 
1014
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1014
+    return isset($array[$key]) ? $array[$key] : null;
1015 1015
 
1016 1016
 }
1017 1017
 
@@ -1020,12 +1020,12 @@  discard block
 block discarded – undo
1020 1020
  *
1021 1021
  * @return array
1022 1022
  */
1023
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1023
+function getpaid_array_merge_if_empty($args, $defaults) {
1024 1024
 
1025
-    foreach ( $defaults as $key => $value ) {
1025
+    foreach ($defaults as $key => $value) {
1026 1026
 
1027
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1028
-            $args[ $key ] = $value;
1027
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1028
+            $args[$key] = $value;
1029 1029
         }
1030 1030
 
1031 1031
     }
Please login to merge, or discard this patch.
includes/reports/class-getpaid-invoice-exporter.php 2 patches
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -12,194 +12,194 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Invoice_Exporter extends GetPaid_Graph_Downloader {
14 14
 
15
-	/**
16
-	 * Retrieves invoices query args.
17
-	 * 
18
-	 * @param string $post_type post type to retrieve.
19
-	 * @param array $args Args to search for.
20
-	 * @return array
21
-	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
23
-
24
-		$query_args = array(
25
-			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
27
-			'posts_per_page'         => -1,
28
-			'no_found_rows'          => true,
29
-			'update_post_term_cache' => false,
30
-			'fields'                 => 'ids',
31
-		);
32
-
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
35
-		}
36
-
37
-		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
40
-		}
41
-
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
44
-		}
45
-
46
-		if ( ! empty( $date_query ) ) {
47
-			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
49
-		}
50
-
51
-		return $query_args;
52
-	}
53
-
54
-	/**
55
-	 * Retrieves invoices.
56
-	 * 
57
-	 * @param array $query_args WP_Query args.
58
-	 * @return WPInv_Invoice[]
59
-	 */
60
-	public function get_invoices( $query_args ) {
61
-
62
-		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
64
-
65
-		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
67
-
68
-	}
69
-
70
-	/**
71
-	 * Handles the actual download.
72
-	 *
73
-	 */
74
-	public function export( $post_type, $args ) {
75
-
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
77
-		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
80
-
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} else if( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
85
-		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
87
-		}
88
-
89
-		fclose( $stream );
90
-		exit;
91
-	}
92
-
93
-	/**
94
-	 * Prepares a single invoice for download.
95
-	 *
96
-	 * @param WPInv_Invoice $invoice The invoice to prepare..
97
-	 * @param array $fields The fields to stream.
98
-	 * @since       1.0.19
99
-	 * @return array
100
-	 */
101
-	public function prepare_row( $invoice, $fields ) {
102
-
103
-		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
-
106
-		foreach ( $fields as $field ) {
107
-
108
-			$value  = '';
109
-			$method = "get_$field";
110
-
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
113
-			}
114
-
115
-			if ( in_array( $field, $amount_fields ) ) {
116
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
117
-			}
118
-
119
-			$prepared[ $field ] = wpinv_clean( $value );
120
-
121
-		}
122
-
123
-		return $prepared;
124
-	}
125
-
126
-	/**
127
-	 * Retrieves export fields.
128
-	 *
129
-	 * @param string $post_type
130
-	 * @since       1.0.19
131
-	 * @return array
132
-	 */
133
-	public function get_export_fields( $post_type ) {
134
-
135
-		$fields = array(
136
-			'id',
137
-			'parent_id',
138
-			'status',
139
-			'date_created',
140
-			'date_modified',
141
-			'date_due',
142
-			'date_completed',
143
-			'number',
144
-			'key',
145
-			'description',
146
-			'post_type',
147
-			'mode',
148
-			'customer_id',
149
-			'customer_first_name',
150
-			'customer_last_name',
151
-			'customer_phone',
152
-			'customer_email',
153
-			'customer_country',
154
-			'customer_city',
155
-			'customer_state',
156
-			'customer_zip',
157
-			'customer_company',
158
-			'customer_vat_number',
159
-			'customer_address',
160
-			'subtotal',
161
-			'total_discount',
162
-			'total_tax',
163
-			'total_fees',
164
-			'fees',
165
-			'discounts',
166
-			'taxes',
167
-			'cart_details',
168
-			'item_ids',
169
-			'payment_form',
170
-			'discount_code',
171
-			'gateway',
172
-			'transaction_id',
173
-			'currency',
174
-			'disable_taxes',
175
-			'subscription_id',
176
-			'remote_subscription_id',
177
-			'is_viewed',
178
-			'email_cc',
179
-			'template',
180
-			'created_via'
181
-    	);
182
-
183
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
184
-	}
185
-
186
-	/**
187
-	 * Retrieves amount fields.
188
-	 *
189
-	 * @param string $post_type
190
-	 * @since       1.0.19
191
-	 * @return array
192
-	 */
193
-	public function get_amount_fields( $post_type ) {
194
-
195
-		$fields = array(
196
-			'subtotal',
197
-			'total_discount',
198
-			'total_tax',
199
-			'total_fees'
200
-    	);
201
-
202
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
203
-	}
15
+    /**
16
+     * Retrieves invoices query args.
17
+     * 
18
+     * @param string $post_type post type to retrieve.
19
+     * @param array $args Args to search for.
20
+     * @return array
21
+     */
22
+    public function get_invoice_query_args( $post_type, $args ) {
23
+
24
+        $query_args = array(
25
+            'post_type'              => $post_type,
26
+            'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
27
+            'posts_per_page'         => -1,
28
+            'no_found_rows'          => true,
29
+            'update_post_term_cache' => false,
30
+            'fields'                 => 'ids',
31
+        );
32
+
33
+        if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
+            $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
35
+        }
36
+
37
+        $date_query = array();
38
+        if ( ! empty( $args['to_date'] ) ) {
39
+            $date_query['before'] = wpinv_clean( $args['to_date'] );
40
+        }
41
+
42
+        if ( ! empty( $args['from_date'] ) ) {
43
+            $date_query['after'] = wpinv_clean( $args['from_date'] );
44
+        }
45
+
46
+        if ( ! empty( $date_query ) ) {
47
+            $date_query['inclusive']  = true;
48
+            $query_args['date_query'] = array( $date_query );
49
+        }
50
+
51
+        return $query_args;
52
+    }
53
+
54
+    /**
55
+     * Retrieves invoices.
56
+     * 
57
+     * @param array $query_args WP_Query args.
58
+     * @return WPInv_Invoice[]
59
+     */
60
+    public function get_invoices( $query_args ) {
61
+
62
+        // Get invoices.
63
+        $invoices = new WP_Query( $query_args );
64
+
65
+        // Prepare the results.
66
+        return array_map( 'wpinv_get_invoice', $invoices->posts );
67
+
68
+    }
69
+
70
+    /**
71
+     * Handles the actual download.
72
+     *
73
+     */
74
+    public function export( $post_type, $args ) {
75
+
76
+        $invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
77
+        $stream    = $this->prepare_output();
78
+        $headers   = $this->get_export_fields( $post_type );
79
+        $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
80
+
81
+        if ( 'csv' == $file_type ) {
82
+            $this->download_csv( $invoices, $stream, $headers );
83
+        } else if( 'xml' == $file_type ) {
84
+            $this->download_xml( $invoices, $stream, $headers );
85
+        } else {
86
+            $this->download_json( $invoices, $stream, $headers );
87
+        }
88
+
89
+        fclose( $stream );
90
+        exit;
91
+    }
92
+
93
+    /**
94
+     * Prepares a single invoice for download.
95
+     *
96
+     * @param WPInv_Invoice $invoice The invoice to prepare..
97
+     * @param array $fields The fields to stream.
98
+     * @since       1.0.19
99
+     * @return array
100
+     */
101
+    public function prepare_row( $invoice, $fields ) {
102
+
103
+        $prepared      = array();
104
+        $amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
+
106
+        foreach ( $fields as $field ) {
107
+
108
+            $value  = '';
109
+            $method = "get_$field";
110
+
111
+            if ( method_exists( $invoice, $method ) ) {
112
+                $value  = $invoice->$method();
113
+            }
114
+
115
+            if ( in_array( $field, $amount_fields ) ) {
116
+                $value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
117
+            }
118
+
119
+            $prepared[ $field ] = wpinv_clean( $value );
120
+
121
+        }
122
+
123
+        return $prepared;
124
+    }
125
+
126
+    /**
127
+     * Retrieves export fields.
128
+     *
129
+     * @param string $post_type
130
+     * @since       1.0.19
131
+     * @return array
132
+     */
133
+    public function get_export_fields( $post_type ) {
134
+
135
+        $fields = array(
136
+            'id',
137
+            'parent_id',
138
+            'status',
139
+            'date_created',
140
+            'date_modified',
141
+            'date_due',
142
+            'date_completed',
143
+            'number',
144
+            'key',
145
+            'description',
146
+            'post_type',
147
+            'mode',
148
+            'customer_id',
149
+            'customer_first_name',
150
+            'customer_last_name',
151
+            'customer_phone',
152
+            'customer_email',
153
+            'customer_country',
154
+            'customer_city',
155
+            'customer_state',
156
+            'customer_zip',
157
+            'customer_company',
158
+            'customer_vat_number',
159
+            'customer_address',
160
+            'subtotal',
161
+            'total_discount',
162
+            'total_tax',
163
+            'total_fees',
164
+            'fees',
165
+            'discounts',
166
+            'taxes',
167
+            'cart_details',
168
+            'item_ids',
169
+            'payment_form',
170
+            'discount_code',
171
+            'gateway',
172
+            'transaction_id',
173
+            'currency',
174
+            'disable_taxes',
175
+            'subscription_id',
176
+            'remote_subscription_id',
177
+            'is_viewed',
178
+            'email_cc',
179
+            'template',
180
+            'created_via'
181
+        );
182
+
183
+        return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
184
+    }
185
+
186
+    /**
187
+     * Retrieves amount fields.
188
+     *
189
+     * @param string $post_type
190
+     * @since       1.0.19
191
+     * @return array
192
+     */
193
+    public function get_amount_fields( $post_type ) {
194
+
195
+        $fields = array(
196
+            'subtotal',
197
+            'total_discount',
198
+            'total_tax',
199
+            'total_fees'
200
+        );
201
+
202
+        return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
203
+    }
204 204
 
205 205
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Invoice_Exporter Class.
@@ -19,33 +19,33 @@  discard block
 block discarded – undo
19 19
 	 * @param array $args Args to search for.
20 20
 	 * @return array
21 21
 	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
22
+	public function get_invoice_query_args($post_type, $args) {
23 23
 
24 24
 		$query_args = array(
25 25
 			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
26
+			'post_status'            => array_keys(wpinv_get_invoice_statuses(true, false, $post_type)),
27 27
 			'posts_per_page'         => -1,
28 28
 			'no_found_rows'          => true,
29 29
 			'update_post_term_cache' => false,
30 30
 			'fields'                 => 'ids',
31 31
 		);
32 32
 
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
33
+		if (!empty($args['status']) && in_array($args['status'], $query_args['post_status'], true)) {
34
+			$query_args['post_status'] = wpinv_clean(wpinv_parse_list($args['status']));
35 35
 		}
36 36
 
37 37
 		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
38
+		if (!empty($args['to_date'])) {
39
+			$date_query['before'] = wpinv_clean($args['to_date']);
40 40
 		}
41 41
 
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
42
+		if (!empty($args['from_date'])) {
43
+			$date_query['after'] = wpinv_clean($args['from_date']);
44 44
 		}
45 45
 
46
-		if ( ! empty( $date_query ) ) {
46
+		if (!empty($date_query)) {
47 47
 			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
48
+			$query_args['date_query'] = array($date_query);
49 49
 		}
50 50
 
51 51
 		return $query_args;
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @param array $query_args WP_Query args.
58 58
 	 * @return WPInv_Invoice[]
59 59
 	 */
60
-	public function get_invoices( $query_args ) {
60
+	public function get_invoices($query_args) {
61 61
 
62 62
 		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
63
+		$invoices = new WP_Query($query_args);
64 64
 
65 65
 		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
66
+		return array_map('wpinv_get_invoice', $invoices->posts);
67 67
 
68 68
 	}
69 69
 
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 	 * Handles the actual download.
72 72
 	 *
73 73
 	 */
74
-	public function export( $post_type, $args ) {
74
+	public function export($post_type, $args) {
75 75
 
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
76
+		$invoices  = $this->get_invoices($this->get_invoice_query_args($post_type, $args));
77 77
 		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
78
+		$headers   = $this->get_export_fields($post_type);
79
+		$file_type = $this->prepare_file_type(strtolower(getpaid_get_post_type_label($post_type)));
80 80
 
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} else if( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
81
+		if ('csv' == $file_type) {
82
+			$this->download_csv($invoices, $stream, $headers);
83
+		} else if ('xml' == $file_type) {
84
+			$this->download_xml($invoices, $stream, $headers);
85 85
 		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
86
+			$this->download_json($invoices, $stream, $headers);
87 87
 		}
88 88
 
89
-		fclose( $stream );
89
+		fclose($stream);
90 90
 		exit;
91 91
 	}
92 92
 
@@ -98,25 +98,25 @@  discard block
 block discarded – undo
98 98
 	 * @since       1.0.19
99 99
 	 * @return array
100 100
 	 */
101
-	public function prepare_row( $invoice, $fields ) {
101
+	public function prepare_row($invoice, $fields) {
102 102
 
103 103
 		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
104
+		$amount_fields = $this->get_amount_fields($invoice->get_post_type());
105 105
 
106
-		foreach ( $fields as $field ) {
106
+		foreach ($fields as $field) {
107 107
 
108 108
 			$value  = '';
109 109
 			$method = "get_$field";
110 110
 
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
111
+			if (method_exists($invoice, $method)) {
112
+				$value = $invoice->$method();
113 113
 			}
114 114
 
115
-			if ( in_array( $field, $amount_fields ) ) {
116
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
115
+			if (in_array($field, $amount_fields)) {
116
+				$value = wpinv_round_amount(wpinv_sanitize_amount($value));
117 117
 			}
118 118
 
119
-			$prepared[ $field ] = wpinv_clean( $value );
119
+			$prepared[$field] = wpinv_clean($value);
120 120
 
121 121
 		}
122 122
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @since       1.0.19
131 131
 	 * @return array
132 132
 	 */
133
-	public function get_export_fields( $post_type ) {
133
+	public function get_export_fields($post_type) {
134 134
 
135 135
 		$fields = array(
136 136
 			'id',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 			'created_via'
181 181
     	);
182 182
 
183
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
183
+		return apply_filters('getpaid_invoice_exporter_get_fields', $fields, $post_type);
184 184
 	}
185 185
 
186 186
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @since       1.0.19
191 191
 	 * @return array
192 192
 	 */
193
-	public function get_amount_fields( $post_type ) {
193
+	public function get_amount_fields($post_type) {
194 194
 
195 195
 		$fields = array(
196 196
 			'subtotal',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			'total_fees'
200 200
     	);
201 201
 
202
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
202
+		return apply_filters('getpaid_invoice_exporter_get_amount_fields', $fields, $post_type);
203 203
 	}
204 204
 
205 205
 }
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rates-edit.php 1 patch
Spacing   +20 added lines, -20 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
 $tax_rates  = GetPaid_Tax::get_all_tax_rates();
10 10
 $dummy_rate = array(
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
     'global'       => true,
14 14
     'rate'         => wpinv_get_default_tax_rate(),
15 15
     'reduced_rate' => 5,
16
-    'name'         => __( 'VAT', 'invoicing' ),
16
+    'name'         => __('VAT', 'invoicing'),
17 17
 );
18 18
 
19 19
 $reset_url = esc_url(
20 20
     wp_nonce_url(
21
-        add_query_arg( 'getpaid-admin-action', 'reset_tax_rates' ),
21
+        add_query_arg('getpaid-admin-action', 'reset_tax_rates'),
22 22
         'getpaid-nonce',
23 23
         'getpaid-nonce'
24 24
     )
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
 ?>
28 28
 <div class="table-responsive">
29 29
     <table id="wpinv_tax_rates" class="widefat fixed table">
30
-        <caption><?php echo esc_html_e( 'Enter tax rates for specific regions.', 'invoicing' ); ?></caption>
30
+        <caption><?php echo esc_html_e('Enter tax rates for specific regions.', 'invoicing'); ?></caption>
31 31
 
32 32
         <thead>
33 33
             <tr class="table-light">
34 34
 
35 35
                 <th scope="col" class="border-bottom border-top">
36
-                    <?php _e( 'Country', 'invoicing' ); ?>
37
-                    <?php echo getpaid_get_help_tip( __( 'Optionally limit this tax rate to a specific country.', 'invoicing' ), 'position-static' ); ?>
36
+                    <?php _e('Country', 'invoicing'); ?>
37
+                    <?php echo getpaid_get_help_tip(__('Optionally limit this tax rate to a specific country.', 'invoicing'), 'position-static'); ?>
38 38
                 </th>
39 39
 
40 40
                 <th scope="col" class="border-bottom border-top">
41
-                    <?php _e( 'State', 'invoicing' ); ?>
42
-                    <?php echo getpaid_get_help_tip( __( 'Separate state codes using a comma or leave blank to apply country wide.', 'invoicing' ), 'position-static' ); ?>
41
+                    <?php _e('State', 'invoicing'); ?>
42
+                    <?php echo getpaid_get_help_tip(__('Separate state codes using a comma or leave blank to apply country wide.', 'invoicing'), 'position-static'); ?>
43 43
                 </th>
44 44
 
45 45
                 <th scope="col" class="border-bottom border-top">
46
-                    <?php _e( 'Standard Rate %', 'invoicing' ); ?>
47
-                    <?php echo getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing' ), 'position-static' ); ?>
46
+                    <?php _e('Standard Rate %', 'invoicing'); ?>
47
+                    <?php echo getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Standard rate" tax class.', 'invoicing'), 'position-static'); ?>
48 48
                 </th>
49 49
 
50 50
                 <th scope="col" class="border-bottom border-top">
51
-                    <?php _e( 'Reduced Rate %', 'invoicing' ); ?>
52
-                    <?php echo getpaid_get_help_tip( __( 'The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing' ), 'position-static' ); ?>
51
+                    <?php _e('Reduced Rate %', 'invoicing'); ?>
52
+                    <?php echo getpaid_get_help_tip(__('The tax rate (percentage) to charge on items that use the "Reduced rate" tax class.', 'invoicing'), 'position-static'); ?>
53 53
                 </th>
54 54
 
55 55
                 <th scope="col" class="border-bottom border-top">
56
-                    <?php _e( 'Tax Name', 'invoicing' ); ?>
57
-                    <?php echo getpaid_get_help_tip( __( 'The name of this tax, e.g VAT.', 'invoicing' ), 'position-static' ); ?>
56
+                    <?php _e('Tax Name', 'invoicing'); ?>
57
+                    <?php echo getpaid_get_help_tip(__('The name of this tax, e.g VAT.', 'invoicing'), 'position-static'); ?>
58 58
                 </th>
59 59
 
60 60
                 <th scope="col" class="border-bottom border-top" style="width:32px">&nbsp;</th>
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
         </thead>
64 64
 
65 65
         <tbody>
66
-            <?php array_walk( $tax_rates, 'wpinv_tax_rate_callback' ); ?>
66
+            <?php array_walk($tax_rates, 'wpinv_tax_rate_callback'); ?>
67 67
         </tbody>
68 68
 
69 69
         <tfoot>
70 70
             <tr class="table-light">
71 71
                 <td colspan="6" class="border-top">
72 72
 
73
-                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e( 'Add Tax Rate', 'invoicing' ); ?>">
74
-                        <span><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span>
73
+                    <button type="button" class="button button-secondary wpinv_add_tax_rate" aria-label="<?php esc_attr_e('Add Tax Rate', 'invoicing'); ?>">
74
+                        <span><?php _e('Add Tax Rate', 'invoicing'); ?></span>
75 75
                     </button>
76 76
 
77
-                    <a href="<?php echo $reset_url; ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e( 'Reset Tax Rates', 'invoicing' ); ?>">
78
-                        <span><?php _e( 'Reset Tax Rates', 'invoicing' ); ?></span>
77
+                    <a href="<?php echo $reset_url; ?>" class="button button-secondary wpinv_reset_tax_rates" aria-label="<?php esc_attr_e('Reset Tax Rates', 'invoicing'); ?>">
78
+                        <span><?php _e('Reset Tax Rates', 'invoicing'); ?></span>
79 79
                     </a>
80 80
                 </td>
81 81
             </tr>
@@ -84,6 +84,6 @@  discard block
 block discarded – undo
84 84
 </div>
85 85
 
86 86
 <script type="text/html" id="tmpl-wpinv-tax-rate-row">
87
-    <?php echo wpinv_tax_rate_callback( $dummy_rate, 0, false ); ?>
87
+    <?php echo wpinv_tax_rate_callback($dummy_rate, 0, false); ?>
88 88
 </script>
89 89
 
Please login to merge, or discard this patch.
includes/admin/views/html-tax-rate-edit.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @var array $tax_rate
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 ?>
12 12
 
@@ -18,54 +18,54 @@  discard block
 block discarded – undo
18 18
             $country = aui()->select(
19 19
                 array(
20 20
                     'options'     => array_merge(
21
-                        array( '' => __( 'All Countries', 'invoicing' ) ),
21
+                        array('' => __('All Countries', 'invoicing')),
22 22
                         wpinv_get_country_list()
23 23
                     ),
24 24
                     'name'        => "tax_rates[$key][country]",
25
-                    'id'          => uniqid( 'tax_rate_country' ),
26
-                    'value'       => sanitize_text_field( $tax_rate['country'] ),
27
-                    'label'       => __( 'Country', 'invoicing' ),
25
+                    'id'          => uniqid('tax_rate_country'),
26
+                    'value'       => sanitize_text_field($tax_rate['country']),
27
+                    'label'       => __('Country', 'invoicing'),
28 28
                     'class'       => 'wpinv_country',
29 29
                     'no_wrap'     => true,
30 30
                 )
31 31
             );
32 32
 
33
-            echo str_replace( 'custom-select', '', $country );
33
+            echo str_replace('custom-select', '', $country);
34 34
         ?>
35 35
     </td>
36 36
 
37 37
     <td class="wpinv_tax_state">
38 38
 
39 39
         <label class="w-100">
40
-            <span class="screen-reader-text"><?php _e( 'States', 'invoicing' ); ?></span>
41
-            <input type="text" placeholder="<?php esc_attr_e( 'Apply to whole country', 'invoicing' ); ?>" name="tax_rates[<?php echo $key ?>][state]" value="<?php echo empty( $tax_rate['global'] ) ? sanitize_text_field( $tax_rate['state'] ) : ''; ?>"/>
40
+            <span class="screen-reader-text"><?php _e('States', 'invoicing'); ?></span>
41
+            <input type="text" placeholder="<?php esc_attr_e('Apply to whole country', 'invoicing'); ?>" name="tax_rates[<?php echo $key ?>][state]" value="<?php echo empty($tax_rate['global']) ? sanitize_text_field($tax_rate['state']) : ''; ?>"/>
42 42
         </label>
43 43
 
44 44
     </td>
45 45
 
46 46
     <td class="wpinv_standard_rate">
47 47
         <label class="w-100">
48
-            <span class="screen-reader-text"><?php _e( 'Standard Rate', 'invoicing' ); ?></span>
49
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['rate'] ); ?>"/>
48
+            <span class="screen-reader-text"><?php _e('Standard Rate', 'invoicing'); ?></span>
49
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['rate']); ?>"/>
50 50
         </label>
51 51
     </td>
52 52
 
53 53
     <td class="wpinv_reduced_rate">
54 54
         <label class="w-100">
55
-            <span class="screen-reader-text"><?php _e( 'Reduced Rate', 'invoicing' ); ?></span>
56
-            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount( $tax_rate['reduced_rate'] ); ?>"/>
55
+            <span class="screen-reader-text"><?php _e('Reduced Rate', 'invoicing'); ?></span>
56
+            <input type="number" step="any" min="0" max="99" name="tax_rates[<?php echo $key ?>][reduced_rate]" value="<?php echo wpinv_sanitize_amount($tax_rate['reduced_rate']); ?>"/>
57 57
         </label>
58 58
     </td>
59 59
 
60 60
     <td class="wpinv_tax_name">
61 61
         <label class="w-100">
62
-            <span class="screen-reader-text"><?php _e( 'Tax Name', 'invoicing' ); ?></span>
63
-            <input type="text" name="tax_rates[<?php echo $key ?>][name]" value="<?php echo sanitize_text_field( $tax_rate['name'] ); ?>"/>
62
+            <span class="screen-reader-text"><?php _e('Tax Name', 'invoicing'); ?></span>
63
+            <input type="text" name="tax_rates[<?php echo $key ?>][name]" value="<?php echo sanitize_text_field($tax_rate['name']); ?>"/>
64 64
         </label>
65 65
     </td>
66 66
 
67 67
     <td class="wpinv_tax_remove">
68
-        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>">
68
+        <button type="button" class="close wpinv_remove_tax_rate" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>">
69 69
             <span aria-hidden="true">&times;</span>
70 70
         </button>
71 71
     </td>
Please login to merge, or discard this patch.
includes/data/tax-rates.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 return array(
14 14
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
         'global'       => true,
19 19
         'rate'         => 20,
20 20
         'reduced_rate' => 13,
21
-        'name'         => __( 'VAT', 'invoicing' ),
21
+        'name'         => __('VAT', 'invoicing'),
22 22
     ),
23 23
 
24 24
     array(
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         'global'       => true,
28 28
         'rate'         => 21,
29 29
         'reduced_rate' => 12,
30
-        'name'         => __( 'VAT', 'invoicing' ),
30
+        'name'         => __('VAT', 'invoicing'),
31 31
     ),
32 32
 
33 33
     array(
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         'global'       => true,
37 37
         'rate'         => 20,
38 38
         'reduced_rate' => 9,
39
-        'name'         => __( 'VAT', 'invoicing' ),
39
+        'name'         => __('VAT', 'invoicing'),
40 40
     ),
41 41
 
42 42
     array(
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         'global'       => true,
46 46
         'rate'         => 19,
47 47
         'reduced_rate' => 9,
48
-        'name'         => __( 'VAT', 'invoicing' ),
48
+        'name'         => __('VAT', 'invoicing'),
49 49
     ),
50 50
 
51 51
     array(
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         'global'       => true,
55 55
         'rate'         => 21,
56 56
         'reduced_rate' => 15,
57
-        'name'         => __( 'VAT', 'invoicing' ),
57
+        'name'         => __('VAT', 'invoicing'),
58 58
     ),
59 59
 
60 60
     array(
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         'global'       => true,
64 64
         'rate'         => 25,
65 65
         'reduced_rate' => 25,
66
-        'name'         => __( 'VAT', 'invoicing' ),
66
+        'name'         => __('VAT', 'invoicing'),
67 67
     ),
68 68
 
69 69
     array(
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         'global'       => true,
73 73
         'rate'         => 16,
74 74
         'reduced_rate' => 5,
75
-        'name'         => __( 'VAT', 'invoicing' ),
75
+        'name'         => __('VAT', 'invoicing'),
76 76
     ),
77 77
 
78 78
     array(
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         'global'       => true,
82 82
         'rate'         => 20,
83 83
         'reduced_rate' => 9,
84
-        'name'         => __( 'VAT', 'invoicing' ),
84
+        'name'         => __('VAT', 'invoicing'),
85 85
     ),
86 86
 
87 87
     array(
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         'global'       => true,
91 91
         'rate'         => 24,
92 92
         'reduced_rate' => 13,
93
-        'name'         => __( 'VAT', 'invoicing' ),
93
+        'name'         => __('VAT', 'invoicing'),
94 94
     ),
95 95
 
96 96
     array(
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         'global'       => true,
100 100
         'rate'         => 21,
101 101
         'reduced_rate' => 10,
102
-        'name'         => __( 'VAT', 'invoicing' ),
102
+        'name'         => __('VAT', 'invoicing'),
103 103
     ),
104 104
 
105 105
     array(
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
         'global'       => true,
109 109
         'rate'         => 24,
110 110
         'reduced_rate' => 14,
111
-        'name'         => __( 'VAT', 'invoicing' ),
111
+        'name'         => __('VAT', 'invoicing'),
112 112
     ),
113 113
 
114 114
     array(
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         'global'       => true,
118 118
         'rate'         => 20,
119 119
         'reduced_rate' => 10,
120
-        'name'         => __( 'VAT', 'invoicing' ),
120
+        'name'         => __('VAT', 'invoicing'),
121 121
     ),
122 122
 
123 123
     array(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         'global'       => true,
127 127
         'rate'         => 25,
128 128
         'reduced_rate' => 13,
129
-        'name'         => __( 'VAT', 'invoicing' ),
129
+        'name'         => __('VAT', 'invoicing'),
130 130
     ),
131 131
 
132 132
     array(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         'global'       => true,
136 136
         'rate'         => 25,
137 137
         'reduced_rate' => 13,
138
-        'name'         => __( 'VAT', 'invoicing' ),
138
+        'name'         => __('VAT', 'invoicing'),
139 139
     ),
140 140
 
141 141
     array(
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         'global'       => true,
145 145
         'rate'         => 22,
146 146
         'reduced_rate' => 10,
147
-        'name'         => __( 'VAT', 'invoicing' ),
147
+        'name'         => __('VAT', 'invoicing'),
148 148
     ),
149 149
 
150 150
     array(
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         'global'       => true,
154 154
         'rate'         => 21,
155 155
         'reduced_rate' => 12,
156
-        'name'         => __( 'VAT', 'invoicing' ),
156
+        'name'         => __('VAT', 'invoicing'),
157 157
     ),
158 158
 
159 159
     array(
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         'global'       => true,
163 163
         'rate'         => 21,
164 164
         'reduced_rate' => 9,
165
-        'name'         => __( 'VAT', 'invoicing' ),
165
+        'name'         => __('VAT', 'invoicing'),
166 166
     ),
167 167
 
168 168
     array(
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         'global'       => true,
172 172
         'rate'         => 17,
173 173
         'reduced_rate' => 14,
174
-        'name'         => __( 'VAT', 'invoicing' ),
174
+        'name'         => __('VAT', 'invoicing'),
175 175
     ),
176 176
 
177 177
     array(
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
         'global'       => true,
181 181
         'rate'         => 27,
182 182
         'reduced_rate' => 18,
183
-        'name'         => __( 'VAT', 'invoicing' ),
183
+        'name'         => __('VAT', 'invoicing'),
184 184
     ),
185 185
 
186 186
     array(
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
         'global'       => true,
190 190
         'rate'         => 21,
191 191
         'reduced_rate' => 13.5,
192
-        'name'         => __( 'VAT', 'invoicing' ),
192
+        'name'         => __('VAT', 'invoicing'),
193 193
     ),
194 194
 
195 195
     array(
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         'global'       => true,
199 199
         'rate'         => 18,
200 200
         'reduced_rate' => 7,
201
-        'name'         => __( 'VAT', 'invoicing' ),
201
+        'name'         => __('VAT', 'invoicing'),
202 202
     ),
203 203
 
204 204
     array(
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         'global'       => true,
208 208
         'rate'         => 21,
209 209
         'reduced_rate' => 9,
210
-        'name'         => __( 'VAT', 'invoicing' ),
210
+        'name'         => __('VAT', 'invoicing'),
211 211
     ),
212 212
 
213 213
     array(
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         'global'       => true,
217 217
         'rate'         => 23,
218 218
         'reduced_rate' => 8,
219
-        'name'         => __( 'VAT', 'invoicing' ),
219
+        'name'         => __('VAT', 'invoicing'),
220 220
     ),
221 221
 
222 222
     array(
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         'global'       => true,
226 226
         'rate'         => 23,
227 227
         'reduced_rate' => 13,
228
-        'name'         => __( 'VAT', 'invoicing' ),
228
+        'name'         => __('VAT', 'invoicing'),
229 229
     ),
230 230
 
231 231
     array(
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
         'global'       => true,
235 235
         'rate'         => 19,
236 236
         'reduced_rate' => 9,
237
-        'name'         => __( 'VAT', 'invoicing' ),
237
+        'name'         => __('VAT', 'invoicing'),
238 238
     ),
239 239
 
240 240
     array(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         'global'       => true,
244 244
         'rate'         => 22,
245 245
         'reduced_rate' => 9.5,
246
-        'name'         => __( 'VAT', 'invoicing' ),
246
+        'name'         => __('VAT', 'invoicing'),
247 247
     ),
248 248
 
249 249
     array(
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         'global'       => true,
253 253
         'rate'         => 20,
254 254
         'reduced_rate' => 10,
255
-        'name'         => __( 'VAT', 'invoicing' ),
255
+        'name'         => __('VAT', 'invoicing'),
256 256
     ),
257 257
 
258 258
     array(
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         'global'       => true,
262 262
         'rate'         => 25,
263 263
         'reduced_rate' => 12,
264
-        'name'         => __( 'VAT', 'invoicing' ),
264
+        'name'         => __('VAT', 'invoicing'),
265 265
     ),
266 266
 
267 267
     array(
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         'global'       => true,
271 271
         'rate'         => 20,
272 272
         'reduced_rate' => 5,
273
-        'name'         => __( 'VAT', 'invoicing' ),
273
+        'name'         => __('VAT', 'invoicing'),
274 274
     )
275 275
 
276 276
 );
Please login to merge, or discard this patch.
includes/class-getpaid-tax.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -13,168 +13,168 @@
 block discarded – undo
13 13
  */
14 14
 class GetPaid_Tax {
15 15
 
16
-	/**
17
-	 * Calculates tax for a line item.
18
-	 *
19
-	 * @param  float   $price              The price to calc tax on.
20
-	 * @param  array   $rates              The rates to apply.
21
-	 * @param  boolean $price_includes_tax Whether the passed price has taxes included.
22
-	 * @return array                       Array of tax name => tax amount.
23
-	 */
24
-	public static function calc_tax( $price, $rates, $price_includes_tax = false ) {
25
-
26
-		if ( $price_includes_tax ) {
27
-			$taxes = self::calc_inclusive_tax( $price, $rates );
28
-		} else {
29
-			$taxes = self::calc_exclusive_tax( $price, $rates );
30
-		}
31
-
32
-		return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax );
33
-
34
-	}
35
-
36
-	/**
37
-	 * Calc tax from inclusive price.
38
-	 *
39
-	 * @param  float $price Price to calculate tax for.
40
-	 * @param  array $rates Array of tax rates.
41
-	 * @return array
42
-	 */
43
-	public static function calc_inclusive_tax( $price, $rates ) {
44
-		$taxes     = array();
45
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
46
-
47
-		// Add tax rates.
48
-		$tax_rate  = 1 + ( array_sum( $tax_rates ) / 100 );
49
-
50
-		foreach ( $tax_rates as $name => $rate ) {
51
-			$the_rate       = ( $rate / 100 ) / $tax_rate;
52
-			$net_price      = $price - ( $the_rate * $price );
53
-			$tax_amount     = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price );
54
-			$taxes[ $name ] = $tax_amount;
55
-		}
56
-
57
-		// Round all taxes to precision (4DP) before passing them back.
58
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
59
-
60
-		return $taxes;
61
-	}
62
-
63
-	/**
64
-	 * Calc tax from exclusive price.
65
-	 *
66
-	 * @param  float $price Price to calculate tax for.
67
-	 * @param  array $rates Array of tax rates.
68
-	 * @return array
69
-	 */
70
-	public static function calc_exclusive_tax( $price, $rates ) {
71
-		$taxes     = array();
72
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
73
-
74
-		foreach ( $tax_rates as $name => $rate ) {
75
-
76
-			$tax_amount     = $price * ( $rate / 100 );
77
-			$taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price );
78
-
79
-		}
80
-
81
-		// Round all taxes to precision (4DP) before passing them back.
82
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
83
-
84
-		return $taxes;
85
-	}
86
-
87
-	/**
88
-	 * Get's an array of all tax rates.
89
-	 *
90
-	 * @return array
91
-	 */
92
-	public static function get_all_tax_rates() {
93
-
94
-		$rates = get_option( 'wpinv_tax_rates', array() );
95
-
96
-		return apply_filters(
97
-			'getpaid_get_all_tax_rates',
98
-			array_filter( wpinv_parse_list( $rates ) )
99
-		);
100
-
101
-	}
102
-
103
-	/**
104
-	 * Get's an array of default tax rates.
105
-	 *
106
-	 * @return array
107
-	 */
108
-	public static function get_default_tax_rates() {
109
-
110
-		return apply_filters(
111
-			'getpaid_get_default_tax_rates',
112
-			array(
113
-				array(
114
-					'country'   => wpinv_get_default_country(),
115
-					'state'     => wpinv_get_default_state(),
116
-					'global'    => true,
117
-					'rate'      => wpinv_get_default_tax_rate(),
118
-					'name'      => __( 'Base Tax', 'invoicing' ),
119
-				)
120
-			)
121
-		);
122
-
123
-	}
124
-
125
-	/**
126
-	 * Get's an array of tax rates for a given address.
127
-	 *
128
-	 * @param string $country
129
-	 * @param string $state
130
-	 * @return array
131
-	 */
132
-	public static function get_address_tax_rates( $country, $state ) {
133
-
134
-		$all_tax_rates  = self::get_all_tax_rates();
135
-		$matching_rates = array_merge(
136
-			wp_list_filter( $all_tax_rates, array( 'country' => $country ) ),
137
-			wp_list_filter( $all_tax_rates, array( 'country' => '' ) )
138
-		);
139
-
140
-		foreach ( $matching_rates as $i => $rate ) {
141
-
142
-			$states = array_filter( wpinv_clean( explode( ',', $rate['state'] ) ) );
143
-			if ( empty( $rate['global'] ) && ! in_array( $state, $states ) ) {
144
-				unset( $matching_rates[ $i ] );
145
-			}
146
-
147
-		}
148
-
149
-		return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state );
150
-
151
-	}
152
-
153
-	/**
154
-	 * Sums a set of taxes to form a single total. Result is rounded to precision.
155
-	 *
156
-	 * @param  array $taxes Array of taxes.
157
-	 * @return float
158
-	 */
159
-	public static function get_tax_total( $taxes ) {
160
-		return self::round( array_sum( $taxes ) );
161
-	}
162
-
163
-	/**
164
-	 * Round to precision.
165
-	 *
166
-	 * Filter example: to return rounding to .5 cents you'd use:
167
-	 *
168
-	 * function euro_5cent_rounding( $in ) {
169
-	 *      return round( $in / 5, 2 ) * 5;
170
-	 * }
171
-	 * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' );
172
-	 *
173
-	 * @param float|int $in Value to round.
174
-	 * @return float
175
-	 */
176
-	public static function round( $in ) {
177
-		return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in );
178
-	}
16
+    /**
17
+     * Calculates tax for a line item.
18
+     *
19
+     * @param  float   $price              The price to calc tax on.
20
+     * @param  array   $rates              The rates to apply.
21
+     * @param  boolean $price_includes_tax Whether the passed price has taxes included.
22
+     * @return array                       Array of tax name => tax amount.
23
+     */
24
+    public static function calc_tax( $price, $rates, $price_includes_tax = false ) {
25
+
26
+        if ( $price_includes_tax ) {
27
+            $taxes = self::calc_inclusive_tax( $price, $rates );
28
+        } else {
29
+            $taxes = self::calc_exclusive_tax( $price, $rates );
30
+        }
31
+
32
+        return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax );
33
+
34
+    }
35
+
36
+    /**
37
+     * Calc tax from inclusive price.
38
+     *
39
+     * @param  float $price Price to calculate tax for.
40
+     * @param  array $rates Array of tax rates.
41
+     * @return array
42
+     */
43
+    public static function calc_inclusive_tax( $price, $rates ) {
44
+        $taxes     = array();
45
+        $tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
46
+
47
+        // Add tax rates.
48
+        $tax_rate  = 1 + ( array_sum( $tax_rates ) / 100 );
49
+
50
+        foreach ( $tax_rates as $name => $rate ) {
51
+            $the_rate       = ( $rate / 100 ) / $tax_rate;
52
+            $net_price      = $price - ( $the_rate * $price );
53
+            $tax_amount     = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price );
54
+            $taxes[ $name ] = $tax_amount;
55
+        }
56
+
57
+        // Round all taxes to precision (4DP) before passing them back.
58
+        $taxes = array_map( array( __CLASS__, 'round' ), $taxes );
59
+
60
+        return $taxes;
61
+    }
62
+
63
+    /**
64
+     * Calc tax from exclusive price.
65
+     *
66
+     * @param  float $price Price to calculate tax for.
67
+     * @param  array $rates Array of tax rates.
68
+     * @return array
69
+     */
70
+    public static function calc_exclusive_tax( $price, $rates ) {
71
+        $taxes     = array();
72
+        $tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
73
+
74
+        foreach ( $tax_rates as $name => $rate ) {
75
+
76
+            $tax_amount     = $price * ( $rate / 100 );
77
+            $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price );
78
+
79
+        }
80
+
81
+        // Round all taxes to precision (4DP) before passing them back.
82
+        $taxes = array_map( array( __CLASS__, 'round' ), $taxes );
83
+
84
+        return $taxes;
85
+    }
86
+
87
+    /**
88
+     * Get's an array of all tax rates.
89
+     *
90
+     * @return array
91
+     */
92
+    public static function get_all_tax_rates() {
93
+
94
+        $rates = get_option( 'wpinv_tax_rates', array() );
95
+
96
+        return apply_filters(
97
+            'getpaid_get_all_tax_rates',
98
+            array_filter( wpinv_parse_list( $rates ) )
99
+        );
100
+
101
+    }
102
+
103
+    /**
104
+     * Get's an array of default tax rates.
105
+     *
106
+     * @return array
107
+     */
108
+    public static function get_default_tax_rates() {
109
+
110
+        return apply_filters(
111
+            'getpaid_get_default_tax_rates',
112
+            array(
113
+                array(
114
+                    'country'   => wpinv_get_default_country(),
115
+                    'state'     => wpinv_get_default_state(),
116
+                    'global'    => true,
117
+                    'rate'      => wpinv_get_default_tax_rate(),
118
+                    'name'      => __( 'Base Tax', 'invoicing' ),
119
+                )
120
+            )
121
+        );
122
+
123
+    }
124
+
125
+    /**
126
+     * Get's an array of tax rates for a given address.
127
+     *
128
+     * @param string $country
129
+     * @param string $state
130
+     * @return array
131
+     */
132
+    public static function get_address_tax_rates( $country, $state ) {
133
+
134
+        $all_tax_rates  = self::get_all_tax_rates();
135
+        $matching_rates = array_merge(
136
+            wp_list_filter( $all_tax_rates, array( 'country' => $country ) ),
137
+            wp_list_filter( $all_tax_rates, array( 'country' => '' ) )
138
+        );
139
+
140
+        foreach ( $matching_rates as $i => $rate ) {
141
+
142
+            $states = array_filter( wpinv_clean( explode( ',', $rate['state'] ) ) );
143
+            if ( empty( $rate['global'] ) && ! in_array( $state, $states ) ) {
144
+                unset( $matching_rates[ $i ] );
145
+            }
146
+
147
+        }
148
+
149
+        return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state );
150
+
151
+    }
152
+
153
+    /**
154
+     * Sums a set of taxes to form a single total. Result is rounded to precision.
155
+     *
156
+     * @param  array $taxes Array of taxes.
157
+     * @return float
158
+     */
159
+    public static function get_tax_total( $taxes ) {
160
+        return self::round( array_sum( $taxes ) );
161
+    }
162
+
163
+    /**
164
+     * Round to precision.
165
+     *
166
+     * Filter example: to return rounding to .5 cents you'd use:
167
+     *
168
+     * function euro_5cent_rounding( $in ) {
169
+     *      return round( $in / 5, 2 ) * 5;
170
+     * }
171
+     * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' );
172
+     *
173
+     * @param float|int $in Value to round.
174
+     * @return float
175
+     */
176
+    public static function round( $in ) {
177
+        return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in );
178
+    }
179 179
 
180 180
 }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Class GetPaid_Tax
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
 	 * @param  boolean $price_includes_tax Whether the passed price has taxes included.
22 22
 	 * @return array                       Array of tax name => tax amount.
23 23
 	 */
24
-	public static function calc_tax( $price, $rates, $price_includes_tax = false ) {
24
+	public static function calc_tax($price, $rates, $price_includes_tax = false) {
25 25
 
26
-		if ( $price_includes_tax ) {
27
-			$taxes = self::calc_inclusive_tax( $price, $rates );
26
+		if ($price_includes_tax) {
27
+			$taxes = self::calc_inclusive_tax($price, $rates);
28 28
 		} else {
29
-			$taxes = self::calc_exclusive_tax( $price, $rates );
29
+			$taxes = self::calc_exclusive_tax($price, $rates);
30 30
 		}
31 31
 
32
-		return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax );
32
+		return apply_filters('getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax);
33 33
 
34 34
 	}
35 35
 
@@ -40,22 +40,22 @@  discard block
 block discarded – undo
40 40
 	 * @param  array $rates Array of tax rates.
41 41
 	 * @return array
42 42
 	 */
43
-	public static function calc_inclusive_tax( $price, $rates ) {
43
+	public static function calc_inclusive_tax($price, $rates) {
44 44
 		$taxes     = array();
45
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
45
+		$tax_rates = wp_list_pluck($rates, 'rate', 'name');
46 46
 
47 47
 		// Add tax rates.
48
-		$tax_rate  = 1 + ( array_sum( $tax_rates ) / 100 );
48
+		$tax_rate  = 1 + (array_sum($tax_rates) / 100);
49 49
 
50
-		foreach ( $tax_rates as $name => $rate ) {
51
-			$the_rate       = ( $rate / 100 ) / $tax_rate;
52
-			$net_price      = $price - ( $the_rate * $price );
53
-			$tax_amount     = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price );
54
-			$taxes[ $name ] = $tax_amount;
50
+		foreach ($tax_rates as $name => $rate) {
51
+			$the_rate       = ($rate / 100) / $tax_rate;
52
+			$net_price      = $price - ($the_rate * $price);
53
+			$tax_amount     = apply_filters('getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price);
54
+			$taxes[$name] = $tax_amount;
55 55
 		}
56 56
 
57 57
 		// Round all taxes to precision (4DP) before passing them back.
58
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
58
+		$taxes = array_map(array(__CLASS__, 'round'), $taxes);
59 59
 
60 60
 		return $taxes;
61 61
 	}
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
 	 * @param  array $rates Array of tax rates.
68 68
 	 * @return array
69 69
 	 */
70
-	public static function calc_exclusive_tax( $price, $rates ) {
70
+	public static function calc_exclusive_tax($price, $rates) {
71 71
 		$taxes     = array();
72
-		$tax_rates = wp_list_pluck( $rates, 'rate', 'name' );
72
+		$tax_rates = wp_list_pluck($rates, 'rate', 'name');
73 73
 
74
-		foreach ( $tax_rates as $name => $rate ) {
74
+		foreach ($tax_rates as $name => $rate) {
75 75
 
76
-			$tax_amount     = $price * ( $rate / 100 );
77
-			$taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price );
76
+			$tax_amount     = $price * ($rate / 100);
77
+			$taxes[$name] = apply_filters('getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price);
78 78
 
79 79
 		}
80 80
 
81 81
 		// Round all taxes to precision (4DP) before passing them back.
82
-		$taxes = array_map( array( __CLASS__, 'round' ), $taxes );
82
+		$taxes = array_map(array(__CLASS__, 'round'), $taxes);
83 83
 
84 84
 		return $taxes;
85 85
 	}
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public static function get_all_tax_rates() {
93 93
 
94
-		$rates = get_option( 'wpinv_tax_rates', array() );
94
+		$rates = get_option('wpinv_tax_rates', array());
95 95
 
96 96
 		return apply_filters(
97 97
 			'getpaid_get_all_tax_rates',
98
-			array_filter( wpinv_parse_list( $rates ) )
98
+			array_filter(wpinv_parse_list($rates))
99 99
 		);
100 100
 
101 101
 	}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 					'state'     => wpinv_get_default_state(),
116 116
 					'global'    => true,
117 117
 					'rate'      => wpinv_get_default_tax_rate(),
118
-					'name'      => __( 'Base Tax', 'invoicing' ),
118
+					'name'      => __('Base Tax', 'invoicing'),
119 119
 				)
120 120
 			)
121 121
 		);
@@ -129,24 +129,24 @@  discard block
 block discarded – undo
129 129
 	 * @param string $state
130 130
 	 * @return array
131 131
 	 */
132
-	public static function get_address_tax_rates( $country, $state ) {
132
+	public static function get_address_tax_rates($country, $state) {
133 133
 
134 134
 		$all_tax_rates  = self::get_all_tax_rates();
135 135
 		$matching_rates = array_merge(
136
-			wp_list_filter( $all_tax_rates, array( 'country' => $country ) ),
137
-			wp_list_filter( $all_tax_rates, array( 'country' => '' ) )
136
+			wp_list_filter($all_tax_rates, array('country' => $country)),
137
+			wp_list_filter($all_tax_rates, array('country' => ''))
138 138
 		);
139 139
 
140
-		foreach ( $matching_rates as $i => $rate ) {
140
+		foreach ($matching_rates as $i => $rate) {
141 141
 
142
-			$states = array_filter( wpinv_clean( explode( ',', $rate['state'] ) ) );
143
-			if ( empty( $rate['global'] ) && ! in_array( $state, $states ) ) {
144
-				unset( $matching_rates[ $i ] );
142
+			$states = array_filter(wpinv_clean(explode(',', $rate['state'])));
143
+			if (empty($rate['global']) && !in_array($state, $states)) {
144
+				unset($matching_rates[$i]);
145 145
 			}
146 146
 
147 147
 		}
148 148
 
149
-		return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state );
149
+		return apply_filters('getpaid_get_address_tax_rates', $matching_rates, $country, $state);
150 150
 
151 151
 	}
152 152
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	 * @param  array $taxes Array of taxes.
157 157
 	 * @return float
158 158
 	 */
159
-	public static function get_tax_total( $taxes ) {
160
-		return self::round( array_sum( $taxes ) );
159
+	public static function get_tax_total($taxes) {
160
+		return self::round(array_sum($taxes));
161 161
 	}
162 162
 
163 163
 	/**
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @param float|int $in Value to round.
174 174
 	 * @return float
175 175
 	 */
176
-	public static function round( $in ) {
177
-		return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in );
176
+	public static function round($in) {
177
+		return apply_filters('getpaid_tax_round', round($in, 4), $in);
178 178
 	}
179 179
 
180 180
 }
Please login to merge, or discard this patch.
includes/class-wpinv-subscriptions-db.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The Subscriptions DB Class
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
             'transaction_id'    => '',
73 73
             'parent_payment_id' => 0,
74 74
             'product_id'        => 0,
75
-            'created'           => date( 'Y-m-d H:i:s' ),
76
-            'expiration'        => date( 'Y-m-d H:i:s' ),
75
+            'created'           => date('Y-m-d H:i:s'),
76
+            'expiration'        => date('Y-m-d H:i:s'),
77 77
             'trial_period'      => '',
78 78
             'status'            => '',
79 79
             'profile_id'        => '',
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
      * @access  public
87 87
      * @since   1.0.0
88 88
      */
89
-    public function get_subscriptions( $args = array() ) {
90
-        return getpaid_get_subscriptions( $args );
89
+    public function get_subscriptions($args = array()) {
90
+        return getpaid_get_subscriptions($args);
91 91
     }
92 92
 
93 93
     /**
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
      * @access  public
97 97
      * @since   1.0.0
98 98
      */
99
-    public function count( $args = array() ) {
100
-        return getpaid_get_subscriptions( $args, 'count' );
99
+    public function count($args = array()) {
100
+        return getpaid_get_subscriptions($args, 'count');
101 101
     }
102 102
 
103 103
     /**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function create_table() {
110 110
 
111
-        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
111
+        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
112 112
 
113 113
         $sql = "CREATE TABLE " . $this->table_name . " (
114 114
         id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
         KEY customer_and_status ( customer_id, status)
134 134
         ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
135 135
 
136
-        dbDelta( $sql );
136
+        dbDelta($sql);
137 137
 
138
-        update_option( $this->table_name . '_db_version', $this->version );
138
+        update_option($this->table_name . '_db_version', $this->version);
139 139
     }
140 140
 
141 141
 }
142 142
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-vat.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_VAT {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-	 * Output the VAT rules settings.
50
-	 *
51
-	 * @param WPInv_Item $item
52
-	 */
49
+     * Output the VAT rules settings.
50
+     *
51
+     * @param WPInv_Item $item
52
+     */
53 53
     public static function output_vat_rules( $item ) {
54 54
         ?>
55 55
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
     }
88 88
 
89 89
     /**
90
-	 * Output the VAT class settings.
91
-	 *
92
-	 * @param WPInv_Item $item
93
-	 */
90
+     * Output the VAT class settings.
91
+     *
92
+     * @param WPInv_Item $item
93
+     */
94 94
     public static function output_vat_classes( $item ) {
95 95
         ?>
96 96
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,26 +21,26 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         echo "<div class='bsui' style='max-width: 600px;padding-top: 10px;'>";
30 30
 
31
-        do_action( 'wpinv_item_before_vat_metabox', $item );
31
+        do_action('wpinv_item_before_vat_metabox', $item);
32 32
 
33 33
         // Output the vat rules settings.
34
-        do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item );
35
-        self::output_vat_rules( $item );
36
-        do_action( 'wpinv_item_vat_metabox_vat_rules', $item );
34
+        do_action('wpinv_item_vat_metabox_before_vat_rules', $item);
35
+        self::output_vat_rules($item);
36
+        do_action('wpinv_item_vat_metabox_vat_rules', $item);
37 37
 
38 38
         // Output vat class settings.
39
-        do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item );
40
-        self::output_vat_classes( $item );
41
-        do_action( 'wpinv_item_vat_metabox_vat_class', $item );
39
+        do_action('wpinv_item_vat_metabox_before_vat_rules', $item);
40
+        self::output_vat_classes($item);
41
+        do_action('wpinv_item_vat_metabox_vat_class', $item);
42 42
 
43
-        do_action( 'wpinv_item_vat_metabox', $item );
43
+        do_action('wpinv_item_vat_metabox', $item);
44 44
 
45 45
         echo '</div>';
46 46
     }
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param WPInv_Item $item
52 52
 	 */
53
-    public static function output_vat_rules( $item ) {
53
+    public static function output_vat_rules($item) {
54 54
         ?>
55 55
 
56 56
             <div class="wpinv_vat_rules">
57 57
 
58 58
                 <div class="form-group row">
59 59
                     <label for="wpinv_vat_rules" class="col-sm-3 col-form-label">
60
-                        <?php _e( 'Tax Rule', 'invoicing' );?>
60
+                        <?php _e('Tax Rule', 'invoicing'); ?>
61 61
                     </label>
62 62
                     <div class="col-sm-8">
63 63
                         <?php
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
                                 array(
66 66
                                     'id'               => 'wpinv_vat_rules',
67 67
                                     'name'             => 'wpinv_vat_rules',
68
-                                    'placeholder'      => __( 'Select tax rule', 'invoicing' ),
69
-                                    'value'            => $item->get_vat_rule( 'edit' ),
68
+                                    'placeholder'      => __('Select tax rule', 'invoicing'),
69
+                                    'value'            => $item->get_vat_rule('edit'),
70 70
                                     'select2'          => true,
71 71
                                     'data-allow-clear' => 'false',
72 72
                                     'no_wrap'          => true,
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param WPInv_Item $item
90 90
 	 */
91
-    public static function output_vat_classes( $item ) {
91
+    public static function output_vat_classes($item) {
92 92
         ?>
93 93
 
94 94
             <div class="wpinv_vat_classes">
95 95
 
96 96
                 <div class="form-group row">
97 97
                     <label for="wpinv_vat_class" class="col-sm-3 col-form-label">
98
-                        <?php _e( 'Tax Class', 'invoicing' );?>
98
+                        <?php _e('Tax Class', 'invoicing'); ?>
99 99
                     </label>
100 100
                     <div class="col-sm-8">
101 101
                         <?php
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
                                 array(
104 104
                                     'id'               => 'wpinv_vat_class',
105 105
                                     'name'             => 'wpinv_vat_class',
106
-                                    'placeholder'      => __( 'Select tax class', 'invoicing' ),
107
-                                    'value'            => $item->get_vat_class( 'edit' ),
106
+                                    'placeholder'      => __('Select tax class', 'invoicing'),
107
+                                    'value'            => $item->get_vat_class('edit'),
108 108
                                     'select2'          => true,
109 109
                                     'data-allow-clear' => 'false',
110 110
                                     'no_wrap'          => true,
Please login to merge, or discard this patch.
templates/invoice/company-address.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Prepare the company name.
13
-$company_name = wpinv_get_option( 'vat_company_name' );
13
+$company_name = wpinv_get_option('vat_company_name');
14 14
 
15
-if ( empty( $company_name ) ) {
15
+if (empty($company_name)) {
16 16
     $company_name = wpinv_get_business_name();
17 17
 }
18 18
 
@@ -22,30 +22,30 @@  discard block
 block discarded – undo
22 22
         <div class="row">
23 23
 
24 24
             <div class="invoice-company-address-label col-2">
25
-                <strong><?php _e( 'From:', 'invoicing' ) ?></strong>
25
+                <strong><?php _e('From:', 'invoicing') ?></strong>
26 26
             </div>
27 27
 
28 28
             <div class="invoice-company-address-value col-10">
29 29
 
30
-                <?php do_action( 'getpaid_company_address_top' ); ?>
30
+                <?php do_action('getpaid_company_address_top'); ?>
31 31
 
32 32
                 <div class="name">
33
-                    <a target="_blank" class="text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
34
-                        <?php echo esc_html( wpinv_get_business_name() ); ?>
33
+                    <a target="_blank" class="text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
34
+                        <?php echo esc_html(wpinv_get_business_name()); ?>
35 35
                     </a>
36 36
                 </div>
37 37
 
38
-                <?php if ( $address = wpinv_get_business_address() ) { ?>
39
-                    <?php echo $address;?>
38
+                <?php if ($address = wpinv_get_business_address()) { ?>
39
+                    <?php echo $address; ?>
40 40
                 <?php } ?>
41 41
 
42
-                <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
42
+                <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
43 43
                     <div class="email_from">
44
-                        <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?>
44
+                        <?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?>
45 45
                     </div>
46 46
                 <?php } ?>
47 47
 
48
-                <?php do_action( 'getpaid_company_address_bottom' ); ?>
48
+                <?php do_action('getpaid_company_address_bottom'); ?>
49 49
 
50 50
             </div>
51 51
 
Please login to merge, or discard this patch.