@@ -6,7 +6,7 @@ discard block |
||
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 |
||
20 | 20 | */ |
21 | 21 | function wpinv_get_ip() { |
22 | 22 | |
23 | - if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { |
|
24 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); |
|
23 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { |
|
24 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 |
29 | 29 | // Make sure we always only send through the first IP in the list which should always be the client IP. |
30 | - return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); |
|
30 | + return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])))))); |
|
31 | 31 | } |
32 | 32 | |
33 | - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
34 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
33 | + if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|
34 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
38 | - return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
37 | + if (isset($_SERVER['REMOTE_ADDR'])) { |
|
38 | + return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | |
44 | 44 | function wpinv_get_user_agent() { |
45 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
46 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
45 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
46 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
47 | 47 | } else { |
48 | 48 | $user_agent = ''; |
49 | 49 | } |
50 | 50 | |
51 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
51 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * @param string $amount The amount to sanitize. |
58 | 58 | * @return float |
59 | 59 | */ |
60 | -function getpaid_standardize_amount( $amount ) { |
|
60 | +function getpaid_standardize_amount($amount) { |
|
61 | 61 | |
62 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
63 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
64 | - if ( is_numeric( $amount ) ) { |
|
65 | - return floatval( $amount ); |
|
62 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
63 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
64 | + if (is_numeric($amount)) { |
|
65 | + return floatval($amount); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // Cast the remaining to a float. |
69 | - return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) ); |
|
69 | + return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount)); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param string $amount The amount to sanitize. |
77 | 77 | */ |
78 | -function getpaid_unstandardize_amount( $amount ) { |
|
79 | - return str_replace( '.', wpinv_decimal_separator(), $amount ); |
|
78 | +function getpaid_unstandardize_amount($amount) { |
|
79 | + return str_replace('.', wpinv_decimal_separator(), $amount); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param string $amount The amount to sanitize. |
86 | 86 | */ |
87 | -function wpinv_sanitize_amount( $amount ) { |
|
87 | +function wpinv_sanitize_amount($amount) { |
|
88 | 88 | |
89 | - if ( is_numeric( $amount ) ) { |
|
90 | - return floatval( $amount ); |
|
89 | + if (is_numeric($amount)) { |
|
90 | + return floatval($amount); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Separate the decimals and thousands. |
94 | - $amount = explode( wpinv_decimal_separator(), $amount ); |
|
94 | + $amount = explode(wpinv_decimal_separator(), $amount); |
|
95 | 95 | |
96 | 96 | // Remove thousands. |
97 | - $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] ); |
|
97 | + $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]); |
|
98 | 98 | |
99 | 99 | // Convert back to string. |
100 | - $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
100 | + $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
101 | 101 | |
102 | 102 | // Cast the remaining to a float. |
103 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
103 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | * @param float $amount |
111 | 111 | * @param float|string|int|null $decimals |
112 | 112 | */ |
113 | -function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) { |
|
113 | +function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) { |
|
114 | 114 | |
115 | - if ( $decimals === null ) { |
|
115 | + if ($decimals === null) { |
|
116 | 116 | $decimals = wpinv_decimals(); |
117 | 117 | } |
118 | 118 | |
119 | - if ( $use_sprintf ) { |
|
120 | - $amount = sprintf( "%.{$decimals}f", (float) $amount ); |
|
119 | + if ($use_sprintf) { |
|
120 | + $amount = sprintf("%.{$decimals}f", (float) $amount); |
|
121 | 121 | } else { |
122 | - $amount = round( (float) $amount, absint( $decimals ) ); |
|
122 | + $amount = round((float) $amount, absint($decimals)); |
|
123 | 123 | } |
124 | 124 | |
125 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
125 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -134,32 +134,32 @@ discard block |
||
134 | 134 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
135 | 135 | * @return array |
136 | 136 | */ |
137 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
137 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
138 | 138 | |
139 | 139 | $invoice_statuses = array( |
140 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
141 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
142 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
143 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
144 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
145 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
146 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
147 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
140 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
141 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
142 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
143 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
144 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
145 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
146 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
147 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - if ( $draft ) { |
|
151 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
150 | + if ($draft) { |
|
151 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
152 | 152 | } |
153 | 153 | |
154 | - if ( $trashed ) { |
|
155 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
154 | + if ($trashed) { |
|
155 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
158 | + if ($invoice instanceof WPInv_Invoice) { |
|
159 | 159 | $invoice = $invoice->get_post_type(); |
160 | 160 | } |
161 | 161 | |
162 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
162 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @param string $status The raw status |
169 | 169 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
170 | 170 | */ |
171 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
172 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
173 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : $status; |
|
171 | +function wpinv_status_nicename($status, $invoice = false) { |
|
172 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
173 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
174 | 174 | |
175 | - return sanitize_text_field( $status ); |
|
175 | + return sanitize_text_field($status); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param string $current |
182 | 182 | */ |
183 | -function wpinv_get_currency( $current = '' ) { |
|
183 | +function wpinv_get_currency($current = '') { |
|
184 | 184 | |
185 | - if ( empty( $current ) ) { |
|
186 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
185 | + if (empty($current)) { |
|
186 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
187 | 187 | } |
188 | 188 | |
189 | - return trim( strtoupper( $current ) ); |
|
189 | + return trim(strtoupper($current)); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -194,25 +194,25 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @param string|null $currency The currency code. Defaults to the default currency. |
196 | 196 | */ |
197 | -function wpinv_currency_symbol( $currency = null ) { |
|
197 | +function wpinv_currency_symbol($currency = null) { |
|
198 | 198 | |
199 | 199 | // Prepare the currency. |
200 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
200 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
201 | 201 | |
202 | 202 | // Fetch all symbols. |
203 | 203 | $symbols = wpinv_get_currency_symbols(); |
204 | 204 | |
205 | 205 | // Fetch this currencies symbol. |
206 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
206 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
207 | 207 | |
208 | 208 | // Filter the symbol. |
209 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
209 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_currency_position() { |
213 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
213 | + $position = wpinv_get_option('currency_position', 'left'); |
|
214 | 214 | |
215 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
215 | + return apply_filters('wpinv_currency_position', $position); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param $string|null $current |
222 | 222 | */ |
223 | -function wpinv_thousands_separator( $current = null ) { |
|
223 | +function wpinv_thousands_separator($current = null) { |
|
224 | 224 | |
225 | - if ( null == $current ) { |
|
226 | - $current = wpinv_get_option( 'thousands_separator', ',' ); |
|
225 | + if (null == $current) { |
|
226 | + $current = wpinv_get_option('thousands_separator', ','); |
|
227 | 227 | } |
228 | 228 | |
229 | - return trim( $current ); |
|
229 | + return trim($current); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @param $string|null $current |
236 | 236 | */ |
237 | -function wpinv_decimal_separator( $current = null ) { |
|
237 | +function wpinv_decimal_separator($current = null) { |
|
238 | 238 | |
239 | - if ( null == $current ) { |
|
240 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
239 | + if (null == $current) { |
|
240 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
241 | 241 | } |
242 | 242 | |
243 | - return trim( $current ); |
|
243 | + return trim($current); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -248,27 +248,27 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @param $string|null $current |
250 | 250 | */ |
251 | -function wpinv_decimals( $current = null ) { |
|
251 | +function wpinv_decimals($current = null) { |
|
252 | 252 | |
253 | - if ( null == $current ) { |
|
254 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
253 | + if (null == $current) { |
|
254 | + $current = wpinv_get_option('decimals', 2); |
|
255 | 255 | } |
256 | 256 | |
257 | - return absint( $current ); |
|
257 | + return absint($current); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Retrieves a list of all supported currencies. |
262 | 262 | */ |
263 | 263 | function wpinv_get_currencies() { |
264 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
264 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Retrieves a list of all currency symbols. |
269 | 269 | */ |
270 | 270 | function wpinv_get_currency_symbols() { |
271 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
271 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $currency_pos = wpinv_currency_position(); |
281 | 281 | $format = '%1$s%2$s'; |
282 | 282 | |
283 | - switch ( $currency_pos ) { |
|
283 | + switch ($currency_pos) { |
|
284 | 284 | case 'left': |
285 | 285 | $format = '%1$s%2$s'; |
286 | 286 | break; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | break; |
296 | 296 | } |
297 | 297 | |
298 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
298 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -305,25 +305,25 @@ discard block |
||
305 | 305 | * @param string $currency Currency. |
306 | 306 | * @return string |
307 | 307 | */ |
308 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
308 | +function wpinv_price($amount = 0, $currency = '') { |
|
309 | 309 | |
310 | 310 | // Backwards compatibility. |
311 | - $amount = wpinv_sanitize_amount( $amount ); |
|
311 | + $amount = wpinv_sanitize_amount($amount); |
|
312 | 312 | |
313 | 313 | // Prepare variables. |
314 | - $currency = wpinv_get_currency( $currency ); |
|
314 | + $currency = wpinv_get_currency($currency); |
|
315 | 315 | $amount = (float) $amount; |
316 | 316 | $unformatted_amount = $amount; |
317 | 317 | $negative = $amount < 0; |
318 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
319 | - $amount = wpinv_format_amount( $amount ); |
|
318 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
319 | + $amount = wpinv_format_amount($amount); |
|
320 | 320 | |
321 | 321 | // Format the amount. |
322 | 322 | $format = getpaid_get_price_format(); |
323 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
323 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
324 | 324 | |
325 | 325 | // Filter the formatting. |
326 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
326 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -334,25 +334,25 @@ discard block |
||
334 | 334 | * @param bool $calculate Whether or not to apply separators. |
335 | 335 | * @return string |
336 | 336 | */ |
337 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
337 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
338 | 338 | $thousands_sep = wpinv_thousands_separator(); |
339 | 339 | $decimal_sep = wpinv_decimal_separator(); |
340 | - $decimals = wpinv_decimals( $decimals ); |
|
341 | - $amount = wpinv_sanitize_amount( $amount ); |
|
340 | + $decimals = wpinv_decimals($decimals); |
|
341 | + $amount = wpinv_sanitize_amount($amount); |
|
342 | 342 | |
343 | - if ( $calculate ) { |
|
343 | + if ($calculate) { |
|
344 | 344 | return $amount; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Fomart the amount. |
348 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
348 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
349 | 349 | } |
350 | 350 | |
351 | -function wpinv_sanitize_key( $key ) { |
|
351 | +function wpinv_sanitize_key($key) { |
|
352 | 352 | $raw_key = $key; |
353 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
353 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
354 | 354 | |
355 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
355 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @param $str the file whose extension should be retrieved. |
362 | 362 | */ |
363 | -function wpinv_get_file_extension( $str ) { |
|
364 | - $filetype = wp_check_filetype( $str ); |
|
363 | +function wpinv_get_file_extension($str) { |
|
364 | + $filetype = wp_check_filetype($str); |
|
365 | 365 | return $filetype['ext']; |
366 | 366 | } |
367 | 367 | |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param string $string |
372 | 372 | */ |
373 | -function wpinv_string_is_image_url( $string ) { |
|
374 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
375 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
373 | +function wpinv_string_is_image_url($string) { |
|
374 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
375 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Returns the current URL. |
380 | 380 | */ |
381 | 381 | function wpinv_get_current_page_url() { |
382 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
382 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -389,46 +389,46 @@ discard block |
||
389 | 389 | * @param string $name Constant name. |
390 | 390 | * @param mixed $value Value. |
391 | 391 | */ |
392 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
393 | - if ( ! defined( $name ) ) { |
|
394 | - define( $name, $value ); |
|
392 | +function getpaid_maybe_define_constant($name, $value) { |
|
393 | + if (!defined($name)) { |
|
394 | + define($name, $value); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
398 | 398 | function wpinv_get_php_arg_separator_output() { |
399 | - return ini_get( 'arg_separator.output' ); |
|
399 | + return ini_get('arg_separator.output'); |
|
400 | 400 | } |
401 | 401 | |
402 | -function wpinv_rgb_from_hex( $color ) { |
|
403 | - $color = str_replace( '#', '', $color ); |
|
402 | +function wpinv_rgb_from_hex($color) { |
|
403 | + $color = str_replace('#', '', $color); |
|
404 | 404 | |
405 | 405 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
406 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
407 | - if ( empty( $color ) ) { |
|
406 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
407 | + if (empty($color)) { |
|
408 | 408 | return NULL; |
409 | 409 | } |
410 | 410 | |
411 | - $color = str_split( $color ); |
|
411 | + $color = str_split($color); |
|
412 | 412 | |
413 | 413 | $rgb = array(); |
414 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
415 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
416 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
414 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
415 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
416 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
417 | 417 | |
418 | 418 | return $rgb; |
419 | 419 | } |
420 | 420 | |
421 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
422 | - $base = wpinv_rgb_from_hex( $color ); |
|
421 | +function wpinv_hex_darker($color, $factor = 30) { |
|
422 | + $base = wpinv_rgb_from_hex($color); |
|
423 | 423 | $color = '#'; |
424 | 424 | |
425 | - foreach ( $base as $k => $v ) { |
|
425 | + foreach ($base as $k => $v) { |
|
426 | 426 | $amount = $v / 100; |
427 | - $amount = round( $amount * $factor ); |
|
427 | + $amount = round($amount * $factor); |
|
428 | 428 | $new_decimal = $v - $amount; |
429 | 429 | |
430 | - $new_hex_component = dechex( $new_decimal ); |
|
431 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
430 | + $new_hex_component = dechex($new_decimal); |
|
431 | + if (strlen($new_hex_component) < 2) { |
|
432 | 432 | $new_hex_component = "0" . $new_hex_component; |
433 | 433 | } |
434 | 434 | $color .= $new_hex_component; |
@@ -437,18 +437,18 @@ discard block |
||
437 | 437 | return $color; |
438 | 438 | } |
439 | 439 | |
440 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
441 | - $base = wpinv_rgb_from_hex( $color ); |
|
440 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
441 | + $base = wpinv_rgb_from_hex($color); |
|
442 | 442 | $color = '#'; |
443 | 443 | |
444 | - foreach ( $base as $k => $v ) { |
|
444 | + foreach ($base as $k => $v) { |
|
445 | 445 | $amount = 255 - $v; |
446 | 446 | $amount = $amount / 100; |
447 | - $amount = round( $amount * $factor ); |
|
447 | + $amount = round($amount * $factor); |
|
448 | 448 | $new_decimal = $v + $amount; |
449 | 449 | |
450 | - $new_hex_component = dechex( $new_decimal ); |
|
451 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
450 | + $new_hex_component = dechex($new_decimal); |
|
451 | + if (strlen($new_hex_component) < 2) { |
|
452 | 452 | $new_hex_component = "0" . $new_hex_component; |
453 | 453 | } |
454 | 454 | $color .= $new_hex_component; |
@@ -457,22 +457,22 @@ discard block |
||
457 | 457 | return $color; |
458 | 458 | } |
459 | 459 | |
460 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
461 | - $hex = str_replace( '#', '', $color ); |
|
460 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
461 | + $hex = str_replace('#', '', $color); |
|
462 | 462 | |
463 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
464 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
465 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
463 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
464 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
465 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
466 | 466 | |
467 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
467 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
468 | 468 | |
469 | 469 | return $brightness > 155 ? $dark : $light; |
470 | 470 | } |
471 | 471 | |
472 | -function wpinv_format_hex( $hex ) { |
|
473 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
472 | +function wpinv_format_hex($hex) { |
|
473 | + $hex = trim(str_replace('#', '', $hex)); |
|
474 | 474 | |
475 | - if ( strlen( $hex ) == 3 ) { |
|
475 | + if (strlen($hex) == 3) { |
|
476 | 476 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
477 | 477 | } |
478 | 478 | |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
493 | 493 | * @return string |
494 | 494 | */ |
495 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
496 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
497 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
495 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
496 | + if (function_exists('mb_strimwidth')) { |
|
497 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
498 | 498 | } |
499 | 499 | |
500 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
500 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -509,28 +509,28 @@ discard block |
||
509 | 509 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
510 | 510 | * @return int Returns the number of characters in string. |
511 | 511 | */ |
512 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
513 | - if ( function_exists( 'mb_strlen' ) ) { |
|
514 | - return mb_strlen( $str, $encoding ); |
|
512 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
513 | + if (function_exists('mb_strlen')) { |
|
514 | + return mb_strlen($str, $encoding); |
|
515 | 515 | } |
516 | 516 | |
517 | - return strlen( $str ); |
|
517 | + return strlen($str); |
|
518 | 518 | } |
519 | 519 | |
520 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
521 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
522 | - return mb_strtolower( $str, $encoding ); |
|
520 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
521 | + if (function_exists('mb_strtolower')) { |
|
522 | + return mb_strtolower($str, $encoding); |
|
523 | 523 | } |
524 | 524 | |
525 | - return strtolower( $str ); |
|
525 | + return strtolower($str); |
|
526 | 526 | } |
527 | 527 | |
528 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
529 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
530 | - return mb_strtoupper( $str, $encoding ); |
|
528 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
529 | + if (function_exists('mb_strtoupper')) { |
|
530 | + return mb_strtoupper($str, $encoding); |
|
531 | 531 | } |
532 | 532 | |
533 | - return strtoupper( $str ); |
|
533 | + return strtoupper($str); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
545 | 545 | * @return int Returns the position of the first occurrence of search in the string. |
546 | 546 | */ |
547 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
548 | - if ( function_exists( 'mb_strpos' ) ) { |
|
549 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
547 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
548 | + if (function_exists('mb_strpos')) { |
|
549 | + return mb_strpos($str, $find, $offset, $encoding); |
|
550 | 550 | } |
551 | 551 | |
552 | - return strpos( $str, $find, $offset ); |
|
552 | + return strpos($str, $find, $offset); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -563,12 +563,12 @@ discard block |
||
563 | 563 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
564 | 564 | * @return int Returns the position of the last occurrence of search. |
565 | 565 | */ |
566 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
567 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
568 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
566 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
567 | + if (function_exists('mb_strrpos')) { |
|
568 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
569 | 569 | } |
570 | 570 | |
571 | - return strrpos( $str, $find, $offset ); |
|
571 | + return strrpos($str, $find, $offset); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
584 | 584 | * @return string |
585 | 585 | */ |
586 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
587 | - if ( function_exists( 'mb_substr' ) ) { |
|
588 | - if ( $length === null ) { |
|
589 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
586 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
587 | + if (function_exists('mb_substr')) { |
|
588 | + if ($length === null) { |
|
589 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
590 | 590 | } else { |
591 | - return mb_substr( $str, $start, $length, $encoding ); |
|
591 | + return mb_substr($str, $start, $length, $encoding); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | - return substr( $str, $start, $length ); |
|
595 | + return substr($str, $start, $length); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -604,48 +604,48 @@ discard block |
||
604 | 604 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
605 | 605 | * @return string The width of string. |
606 | 606 | */ |
607 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
608 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
609 | - return mb_strwidth( $str, $encoding ); |
|
607 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
608 | + if (function_exists('mb_strwidth')) { |
|
609 | + return mb_strwidth($str, $encoding); |
|
610 | 610 | } |
611 | 611 | |
612 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
612 | + return wpinv_utf8_strlen($str, $encoding); |
|
613 | 613 | } |
614 | 614 | |
615 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
616 | - if ( function_exists( 'mb_strlen' ) ) { |
|
617 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
615 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
616 | + if (function_exists('mb_strlen')) { |
|
617 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
618 | 618 | $str_end = ""; |
619 | 619 | |
620 | - if ( $lower_str_end ) { |
|
621 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
620 | + if ($lower_str_end) { |
|
621 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
622 | 622 | } else { |
623 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
623 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | return $first_letter . $str_end; |
627 | 627 | } |
628 | 628 | |
629 | - return ucfirst( $str ); |
|
629 | + return ucfirst($str); |
|
630 | 630 | } |
631 | 631 | |
632 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
633 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
634 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
632 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
633 | + if (function_exists('mb_convert_case')) { |
|
634 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
635 | 635 | } |
636 | 636 | |
637 | - return ucwords( $str ); |
|
637 | + return ucwords($str); |
|
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_period_in_days( $period, $unit ) { |
|
641 | - $period = absint( $period ); |
|
640 | +function wpinv_period_in_days($period, $unit) { |
|
641 | + $period = absint($period); |
|
642 | 642 | |
643 | - if ( $period > 0 ) { |
|
644 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
643 | + if ($period > 0) { |
|
644 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
645 | 645 | $period = $period * 7; |
646 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
646 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
647 | 647 | $period = $period * 30; |
648 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
648 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
649 | 649 | $period = $period * 365; |
650 | 650 | } |
651 | 651 | } |
@@ -653,14 +653,14 @@ discard block |
||
653 | 653 | return $period; |
654 | 654 | } |
655 | 655 | |
656 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
657 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
658 | - return cal_days_in_month( $calendar, $month, $year ); |
|
656 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
657 | + if (function_exists('cal_days_in_month')) { |
|
658 | + return cal_days_in_month($calendar, $month, $year); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | // Fallback in case the calendar extension is not loaded in PHP |
662 | 662 | // Only supports Gregorian calendar |
663 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
663 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -671,15 +671,15 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @return string |
673 | 673 | */ |
674 | -function wpi_help_tip( $tip, $allow_html = false, $is_vue = false ) { |
|
674 | +function wpi_help_tip($tip, $allow_html = false, $is_vue = false) { |
|
675 | 675 | |
676 | - if ( $allow_html ) { |
|
677 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
676 | + if ($allow_html) { |
|
677 | + $tip = wpi_sanitize_tooltip($tip); |
|
678 | 678 | } else { |
679 | - $tip = esc_attr( $tip ); |
|
679 | + $tip = esc_attr($tip); |
|
680 | 680 | } |
681 | 681 | |
682 | - if ( $is_vue ) { |
|
682 | + if ($is_vue) { |
|
683 | 683 | return '<span class="dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
684 | 684 | } |
685 | 685 | |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | * @param string $var |
695 | 695 | * @return string |
696 | 696 | */ |
697 | -function wpi_sanitize_tooltip( $var ) { |
|
698 | - return wp_kses( html_entity_decode( $var ), array( |
|
697 | +function wpi_sanitize_tooltip($var) { |
|
698 | + return wp_kses(html_entity_decode($var), array( |
|
699 | 699 | 'br' => array(), |
700 | 700 | 'em' => array(), |
701 | 701 | 'strong' => array(), |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | 'li' => array(), |
707 | 707 | 'ol' => array(), |
708 | 708 | 'p' => array(), |
709 | - ) ); |
|
709 | + )); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | /** |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | */ |
717 | 717 | function wpinv_get_screen_ids() { |
718 | 718 | |
719 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
719 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
720 | 720 | |
721 | 721 | $screen_ids = array( |
722 | 722 | 'toplevel_page_' . $screen_id, |
@@ -735,10 +735,10 @@ discard block |
||
735 | 735 | 'getpaid_page_wpinv-reports', |
736 | 736 | 'getpaid_page_wpi-addons', |
737 | 737 | 'getpaid_page_wpinv-customers', |
738 | - 'gp-setup',// setup wizard |
|
738 | + 'gp-setup', // setup wizard |
|
739 | 739 | ); |
740 | 740 | |
741 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
741 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
@@ -749,14 +749,14 @@ discard block |
||
749 | 749 | * @param array|string $list List of values. |
750 | 750 | * @return array Sanitized array of values. |
751 | 751 | */ |
752 | -function wpinv_parse_list( $list ) { |
|
752 | +function wpinv_parse_list($list) { |
|
753 | 753 | |
754 | - if ( empty( $list ) ) { |
|
754 | + if (empty($list)) { |
|
755 | 755 | $list = array(); |
756 | 756 | } |
757 | 757 | |
758 | - if ( ! is_array( $list ) ) { |
|
759 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
758 | + if (!is_array($list)) { |
|
759 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | return $list; |
@@ -770,16 +770,16 @@ discard block |
||
770 | 770 | * @param string $key Type of data to fetch. |
771 | 771 | * @return mixed Fetched data. |
772 | 772 | */ |
773 | -function wpinv_get_data( $key ) { |
|
773 | +function wpinv_get_data($key) { |
|
774 | 774 | |
775 | 775 | // Try fetching it from the cache. |
776 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
777 | - if( $data ) { |
|
776 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
777 | + if ($data) { |
|
778 | 778 | return $data; |
779 | 779 | } |
780 | 780 | |
781 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
782 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
781 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
782 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
783 | 783 | |
784 | 784 | return $data; |
785 | 785 | } |
@@ -793,10 +793,10 @@ discard block |
||
793 | 793 | * @param bool $first_empty Whether or not the first item in the list should be empty |
794 | 794 | * @return mixed Fetched data. |
795 | 795 | */ |
796 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
796 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
797 | 797 | |
798 | - if ( ! empty( $options ) && $first_empty ) { |
|
799 | - return array_merge( array( '' => '' ), $options ); |
|
798 | + if (!empty($options) && $first_empty) { |
|
799 | + return array_merge(array('' => ''), $options); |
|
800 | 800 | } |
801 | 801 | return $options; |
802 | 802 | |
@@ -808,21 +808,21 @@ discard block |
||
808 | 808 | * @param mixed $var Data to sanitize. |
809 | 809 | * @return string|array |
810 | 810 | */ |
811 | -function wpinv_clean( $var ) { |
|
811 | +function wpinv_clean($var) { |
|
812 | 812 | |
813 | - if ( is_array( $var ) ) { |
|
814 | - return array_map( 'wpinv_clean', $var ); |
|
813 | + if (is_array($var)) { |
|
814 | + return array_map('wpinv_clean', $var); |
|
815 | 815 | } |
816 | 816 | |
817 | - if ( is_object( $var ) ) { |
|
818 | - $object_vars = get_object_vars( $var ); |
|
819 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
820 | - $var->$property_name = wpinv_clean( $property_value ); |
|
817 | + if (is_object($var)) { |
|
818 | + $object_vars = get_object_vars($var); |
|
819 | + foreach ($object_vars as $property_name => $property_value) { |
|
820 | + $var->$property_name = wpinv_clean($property_value); |
|
821 | 821 | } |
822 | 822 | return $var; |
823 | 823 | } |
824 | 824 | |
825 | - return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var; |
|
825 | + return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var; |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -831,43 +831,43 @@ discard block |
||
831 | 831 | * @param string $str Data to convert. |
832 | 832 | * @return string|array |
833 | 833 | */ |
834 | -function getpaid_convert_price_string_to_options( $str ) { |
|
834 | +function getpaid_convert_price_string_to_options($str) { |
|
835 | 835 | |
836 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
837 | - $options = array(); |
|
836 | + $raw_options = array_map('trim', explode(',', $str)); |
|
837 | + $options = array(); |
|
838 | 838 | |
839 | - foreach ( $raw_options as $option ) { |
|
839 | + foreach ($raw_options as $option) { |
|
840 | 840 | |
841 | - if ( '' == $option ) { |
|
841 | + if ('' == $option) { |
|
842 | 842 | continue; |
843 | 843 | } |
844 | 844 | |
845 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
845 | + $option = array_map('trim', explode('|', $option)); |
|
846 | 846 | |
847 | 847 | $price = null; |
848 | 848 | $label = null; |
849 | 849 | |
850 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
851 | - $label = $option[0]; |
|
850 | + if (isset($option[0]) && '' != $option[0]) { |
|
851 | + $label = $option[0]; |
|
852 | 852 | } |
853 | 853 | |
854 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
854 | + if (isset($option[1]) && '' != $option[1]) { |
|
855 | 855 | $price = $option[1]; |
856 | 856 | } |
857 | 857 | |
858 | - if ( ! isset( $price ) ) { |
|
858 | + if (!isset($price)) { |
|
859 | 859 | $price = $label; |
860 | 860 | } |
861 | 861 | |
862 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
862 | + if (!isset($price) || !is_numeric($price)) { |
|
863 | 863 | continue; |
864 | 864 | } |
865 | 865 | |
866 | - if ( ! isset( $label ) ) { |
|
866 | + if (!isset($label)) { |
|
867 | 867 | $label = $price; |
868 | 868 | } |
869 | 869 | |
870 | - $options[ "$label|$price" ] = $label; |
|
870 | + $options["$label|$price"] = $label; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | return $options; |
@@ -876,27 +876,27 @@ discard block |
||
876 | 876 | /** |
877 | 877 | * Returns the help tip. |
878 | 878 | */ |
879 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
880 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
881 | - $tip = esc_attr__( $tip ); |
|
879 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
880 | + $additional_classes = sanitize_html_class($additional_classes); |
|
881 | + $tip = esc_attr__($tip); |
|
882 | 882 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
886 | 886 | * Formats a date |
887 | 887 | */ |
888 | -function getpaid_format_date( $date, $with_time = false ) { |
|
888 | +function getpaid_format_date($date, $with_time = false) { |
|
889 | 889 | |
890 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
890 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
891 | 891 | return ''; |
892 | 892 | } |
893 | 893 | |
894 | 894 | $format = getpaid_date_format(); |
895 | 895 | |
896 | - if ( $with_time ) { |
|
896 | + if ($with_time) { |
|
897 | 897 | $format .= ' ' . getpaid_time_format(); |
898 | 898 | } |
899 | - return date_i18n( $format, strtotime( $date ) ); |
|
899 | + return date_i18n($format, strtotime($date)); |
|
900 | 900 | |
901 | 901 | } |
902 | 902 | |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | * |
906 | 906 | * @return string |
907 | 907 | */ |
908 | -function getpaid_format_date_value( $date, $default = "—", $with_time = false ) { |
|
909 | - $date = getpaid_format_date( $date, $with_time ); |
|
910 | - return empty( $date ) ? $default : $date; |
|
908 | +function getpaid_format_date_value($date, $default = "—", $with_time = false) { |
|
909 | + $date = getpaid_format_date($date, $with_time); |
|
910 | + return empty($date) ? $default : $date; |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | * @return string |
917 | 917 | */ |
918 | 918 | function getpaid_date_format() { |
919 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
919 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | /** |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * @return string |
926 | 926 | */ |
927 | 927 | function getpaid_time_format() { |
928 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
928 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
@@ -935,16 +935,16 @@ discard block |
||
935 | 935 | * @param integer $limit Limit size in characters. |
936 | 936 | * @return string |
937 | 937 | */ |
938 | -function getpaid_limit_length( $string, $limit ) { |
|
938 | +function getpaid_limit_length($string, $limit) { |
|
939 | 939 | $str_limit = $limit - 3; |
940 | 940 | |
941 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
942 | - if ( mb_strlen( $string ) > $limit ) { |
|
943 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
941 | + if (function_exists('mb_strimwidth')) { |
|
942 | + if (mb_strlen($string) > $limit) { |
|
943 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
944 | 944 | } |
945 | 945 | } else { |
946 | - if ( strlen( $string ) > $limit ) { |
|
947 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
946 | + if (strlen($string) > $limit) { |
|
947 | + $string = substr($string, 0, $str_limit) . '...'; |
|
948 | 948 | } |
949 | 949 | } |
950 | 950 | return $string; |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | * @since 1.0.19 |
959 | 959 | */ |
960 | 960 | function getpaid_api() { |
961 | - return getpaid()->get( 'api' ); |
|
961 | + return getpaid()->get('api'); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | * @since 1.0.19 |
969 | 969 | */ |
970 | 970 | function getpaid_post_types() { |
971 | - return getpaid()->get( 'post_types' ); |
|
971 | + return getpaid()->get('post_types'); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | /** |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | * @since 1.0.19 |
979 | 979 | */ |
980 | 980 | function getpaid_session() { |
981 | - return getpaid()->get( 'session' ); |
|
981 | + return getpaid()->get('session'); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | /** |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | * @since 1.0.19 |
989 | 989 | */ |
990 | 990 | function getpaid_notes() { |
991 | - return getpaid()->get( 'notes' ); |
|
991 | + return getpaid()->get('notes'); |
|
992 | 992 | } |
993 | 993 | |
994 | 994 | /** |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | * @return GetPaid_Admin |
998 | 998 | */ |
999 | 999 | function getpaid_admin() { |
1000 | - return getpaid()->get( 'admin' ); |
|
1000 | + return getpaid()->get('admin'); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | /** |
@@ -1007,8 +1007,8 @@ discard block |
||
1007 | 1007 | * @param string $base the base url |
1008 | 1008 | * @return string |
1009 | 1009 | */ |
1010 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
1011 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
1010 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
1011 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return string |
1018 | 1018 | */ |
1019 | -function getpaid_get_post_type_label( $post_type, $plural = true ) { |
|
1019 | +function getpaid_get_post_type_label($post_type, $plural = true) { |
|
1020 | 1020 | |
1021 | - $post_type = get_post_type_object( $post_type ); |
|
1021 | + $post_type = get_post_type_object($post_type); |
|
1022 | 1022 | |
1023 | - if ( ! is_object( $post_type ) ) { |
|
1023 | + if (!is_object($post_type)) { |
|
1024 | 1024 | return null; |
1025 | 1025 | } |
1026 | 1026 | |
@@ -1033,18 +1033,18 @@ discard block |
||
1033 | 1033 | * |
1034 | 1034 | * @return mixed|null |
1035 | 1035 | */ |
1036 | -function getpaid_get_array_field( $array, $key, $secondary_key = null ) { |
|
1036 | +function getpaid_get_array_field($array, $key, $secondary_key = null) { |
|
1037 | 1037 | |
1038 | - if ( ! is_array( $array ) ) { |
|
1038 | + if (!is_array($array)) { |
|
1039 | 1039 | return null; |
1040 | 1040 | } |
1041 | 1041 | |
1042 | - if ( ! empty( $secondary_key ) ) { |
|
1043 | - $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array(); |
|
1044 | - return getpaid_get_array_field( $array, $key ); |
|
1042 | + if (!empty($secondary_key)) { |
|
1043 | + $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array(); |
|
1044 | + return getpaid_get_array_field($array, $key); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | - return isset( $array[ $key ] ) ? $array[ $key ] : null; |
|
1047 | + return isset($array[$key]) ? $array[$key] : null; |
|
1048 | 1048 | |
1049 | 1049 | } |
1050 | 1050 | |
@@ -1053,12 +1053,12 @@ discard block |
||
1053 | 1053 | * |
1054 | 1054 | * @return array |
1055 | 1055 | */ |
1056 | -function getpaid_array_merge_if_empty( $args, $defaults ) { |
|
1056 | +function getpaid_array_merge_if_empty($args, $defaults) { |
|
1057 | 1057 | |
1058 | - foreach ( $defaults as $key => $value ) { |
|
1058 | + foreach ($defaults as $key => $value) { |
|
1059 | 1059 | |
1060 | - if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) { |
|
1061 | - $args[ $key ] = $value; |
|
1060 | + if (array_key_exists($key, $args) && empty($args[$key])) { |
|
1061 | + $args[$key] = $value; |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | } |
@@ -1076,12 +1076,12 @@ discard block |
||
1076 | 1076 | |
1077 | 1077 | $types = get_allowed_mime_types(); |
1078 | 1078 | |
1079 | - if ( isset( $types['htm|html'] ) ) { |
|
1080 | - unset( $types['htm|html'] ); |
|
1079 | + if (isset($types['htm|html'])) { |
|
1080 | + unset($types['htm|html']); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | - if ( isset( $types['js'] ) ) { |
|
1084 | - unset( $types['js'] ); |
|
1083 | + if (isset($types['js'])) { |
|
1084 | + unset($types['js']); |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | return $types; |
@@ -1089,34 +1089,34 @@ discard block |
||
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | |
1092 | -function getpaid_user_delete_invoice( $data ) { |
|
1092 | +function getpaid_user_delete_invoice($data) { |
|
1093 | 1093 | |
1094 | 1094 | // Ensure there is an invoice to delete. |
1095 | - if ( empty( $data['invoice_id'] ) ) { |
|
1095 | + if (empty($data['invoice_id'])) { |
|
1096 | 1096 | return; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - $invoice = new WPInv_Invoice( (int) $data['invoice_id'] ); |
|
1099 | + $invoice = new WPInv_Invoice((int) $data['invoice_id']); |
|
1100 | 1100 | |
1101 | 1101 | // Ensure that it exists and that it belongs to the current user. |
1102 | - if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) { |
|
1103 | - wpinv_set_error( 'invalid_invoice', __( 'You do not have permission to delete this invoice', 'invoicing' ) ); |
|
1102 | + if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) { |
|
1103 | + wpinv_set_error('invalid_invoice', __('You do not have permission to delete this invoice', 'invoicing')); |
|
1104 | 1104 | |
1105 | 1105 | // Can it be deleted? |
1106 | - } else if ( ! $invoice->needs_payment() ) { |
|
1107 | - wpinv_set_error( 'cannot_delete', __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ) ); |
|
1106 | + } else if (!$invoice->needs_payment()) { |
|
1107 | + wpinv_set_error('cannot_delete', __('This invoice cannot be deleted as it has already been paid.', 'invoicing')); |
|
1108 | 1108 | |
1109 | 1109 | // Delete it. |
1110 | 1110 | } else { |
1111 | 1111 | |
1112 | 1112 | $invoice->delete(); |
1113 | - wpinv_set_error( 'delete', __( 'The invoice has been deleted.', 'invoicing' ), 'info' ); |
|
1113 | + wpinv_set_error('delete', __('The invoice has been deleted.', 'invoicing'), 'info'); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | - $redirect = remove_query_arg( array( 'getpaid-action', 'getpaid-nonce', 'invoice_id' ) ); |
|
1116 | + $redirect = remove_query_arg(array('getpaid-action', 'getpaid-nonce', 'invoice_id')); |
|
1117 | 1117 | |
1118 | - wp_safe_redirect( $redirect ); |
|
1118 | + wp_safe_redirect($redirect); |
|
1119 | 1119 | exit; |
1120 | 1120 | |
1121 | 1121 | } |
1122 | -add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' ); |
|
1123 | 1122 | \ No newline at end of file |
1123 | +add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice'); |
|
1124 | 1124 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * The Subscription Class |
@@ -68,27 +68,27 @@ discard block |
||
68 | 68 | * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
69 | 69 | * @param bool $deprecated |
70 | 70 | */ |
71 | - function __construct( $subscription = 0, $deprecated = false ) { |
|
71 | + function __construct($subscription = 0, $deprecated = false) { |
|
72 | 72 | |
73 | - parent::__construct( $subscription ); |
|
73 | + parent::__construct($subscription); |
|
74 | 74 | |
75 | - if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | - $this->set_id( $subscription ); |
|
77 | - } elseif ( $subscription instanceof self ) { |
|
78 | - $this->set_id( $subscription->get_id() ); |
|
79 | - } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
80 | - $this->set_id( $subscription_id ); |
|
81 | - } elseif ( ! empty( $subscription->id ) ) { |
|
82 | - $this->set_id( $subscription->id ); |
|
75 | + if (!$deprecated && !empty($subscription) && is_numeric($subscription)) { |
|
76 | + $this->set_id($subscription); |
|
77 | + } elseif ($subscription instanceof self) { |
|
78 | + $this->set_id($subscription->get_id()); |
|
79 | + } elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) { |
|
80 | + $this->set_id($subscription_id); |
|
81 | + } elseif (!empty($subscription->id)) { |
|
82 | + $this->set_id($subscription->id); |
|
83 | 83 | } else { |
84 | - $this->set_object_read( true ); |
|
84 | + $this->set_object_read(true); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Load the datastore. |
88 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
88 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
89 | 89 | |
90 | - if ( $this->get_id() > 0 ) { |
|
91 | - $this->data_store->read( $this ); |
|
90 | + if ($this->get_id() > 0) { |
|
91 | + $this->data_store->read($this); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * @since 1.0.19 |
104 | 104 | * @return int |
105 | 105 | */ |
106 | - public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
106 | + public static function get_subscription_id_by_field($value, $field = 'profile_id') { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | 109 | // Trim the value. |
110 | - $value = trim( $value ); |
|
110 | + $value = trim($value); |
|
111 | 111 | |
112 | - if ( empty( $value ) ) { |
|
112 | + if (empty($value)) { |
|
113 | 113 | return 0; |
114 | 114 | } |
115 | 115 | |
116 | - if ( 'invoice_id' == $field ) { |
|
116 | + if ('invoice_id' == $field) { |
|
117 | 117 | $field = 'parent_payment_id'; |
118 | 118 | } |
119 | 119 | |
@@ -125,28 +125,28 @@ discard block |
||
125 | 125 | ); |
126 | 126 | |
127 | 127 | // Ensure a field has been passed. |
128 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
128 | + if (empty($field) || !in_array($field, $fields)) { |
|
129 | 129 | return 0; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Maybe retrieve from the cache. |
133 | - $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | - if ( ! empty( $subscription_id ) ) { |
|
133 | + $subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
134 | + if (!empty($subscription_id)) { |
|
135 | 135 | return $subscription_id; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Fetch from the db. |
139 | 139 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
140 | 140 | $subscription_id = (int) $wpdb->get_var( |
141 | - $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
141 | + $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
142 | 142 | ); |
143 | 143 | |
144 | - if ( empty( $subscription_id ) ) { |
|
144 | + if (empty($subscription_id)) { |
|
145 | 145 | return 0; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Update the cache with our data. |
149 | - wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
149 | + wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
150 | 150 | |
151 | 151 | return $subscription_id; |
152 | 152 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | * Clears the subscription's cache. |
156 | 156 | */ |
157 | 157 | public function clear_cache() { |
158 | - wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | - wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | - wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
158 | + wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids'); |
|
159 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
160 | + wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids'); |
|
161 | + wp_cache_delete($this->get_id(), 'getpaid_subscriptions'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Checks if a subscription key is set. |
166 | 166 | */ |
167 | - public function _isset( $key ) { |
|
168 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
167 | + public function _isset($key) { |
|
168 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /* |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param string $context View or edit context. |
191 | 191 | * @return int |
192 | 192 | */ |
193 | - public function get_customer_id( $context = 'view' ) { |
|
194 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
193 | + public function get_customer_id($context = 'view') { |
|
194 | + return (int) $this->get_prop('customer_id', $context); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $context View or edit context. |
202 | 202 | * @return WP_User|false WP_User object on success, false on failure. |
203 | 203 | */ |
204 | - public function get_customer( $context = 'view' ) { |
|
205 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
204 | + public function get_customer($context = 'view') { |
|
205 | + return get_userdata($this->get_customer_id($context)); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $context View or edit context. |
213 | 213 | * @return int |
214 | 214 | */ |
215 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
215 | + public function get_parent_invoice_id($context = 'view') { |
|
216 | + return (int) $this->get_prop('parent_payment_id', $context); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param string $context View or edit context. |
224 | 224 | * @return int |
225 | 225 | */ |
226 | - public function get_parent_payment_id( $context = 'view' ) { |
|
227 | - return $this->get_parent_invoice_id( $context ); |
|
226 | + public function get_parent_payment_id($context = 'view') { |
|
227 | + return $this->get_parent_invoice_id($context); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @since 1.0.0 |
234 | 234 | * @return int |
235 | 235 | */ |
236 | - public function get_original_payment_id( $context = 'view' ) { |
|
237 | - return $this->get_parent_invoice_id( $context ); |
|
236 | + public function get_original_payment_id($context = 'view') { |
|
237 | + return $this->get_parent_invoice_id($context); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @param string $context View or edit context. |
245 | 245 | * @return WPInv_Invoice |
246 | 246 | */ |
247 | - public function get_parent_invoice( $context = 'view' ) { |
|
248 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
247 | + public function get_parent_invoice($context = 'view') { |
|
248 | + return new WPInv_Invoice($this->get_parent_invoice_id($context)); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | * @param string $context View or edit context. |
256 | 256 | * @return WPInv_Invoice |
257 | 257 | */ |
258 | - public function get_parent_payment( $context = 'view' ) { |
|
259 | - return $this->get_parent_invoice( $context ); |
|
258 | + public function get_parent_payment($context = 'view') { |
|
259 | + return $this->get_parent_invoice($context); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param string $context View or edit context. |
267 | 267 | * @return int |
268 | 268 | */ |
269 | - public function get_product_id( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'product_id', $context ); |
|
269 | + public function get_product_id($context = 'view') { |
|
270 | + return (int) $this->get_prop('product_id', $context); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $context View or edit context. |
278 | 278 | * @return WPInv_Item |
279 | 279 | */ |
280 | - public function get_product( $context = 'view' ) { |
|
281 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
280 | + public function get_product($context = 'view') { |
|
281 | + return new WPInv_Item($this->get_product_id($context)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param string $context View or edit context. |
291 | 291 | * @return string |
292 | 292 | */ |
293 | - public function get_gateway( $context = 'view' ) { |
|
294 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
293 | + public function get_gateway($context = 'view') { |
|
294 | + return $this->get_parent_invoice($context)->get_gateway(); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | * @param string $context View or edit context. |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function get_period( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'period', $context ); |
|
304 | + public function get_period($context = 'view') { |
|
305 | + return $this->get_prop('period', $context); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param string $context View or edit context. |
313 | 313 | * @return int |
314 | 314 | */ |
315 | - public function get_frequency( $context = 'view' ) { |
|
316 | - return (int) $this->get_prop( 'frequency', $context ); |
|
315 | + public function get_frequency($context = 'view') { |
|
316 | + return (int) $this->get_prop('frequency', $context); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string $context View or edit context. |
324 | 324 | * @return float |
325 | 325 | */ |
326 | - public function get_initial_amount( $context = 'view' ) { |
|
327 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
326 | + public function get_initial_amount($context = 'view') { |
|
327 | + return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context)); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $context View or edit context. |
335 | 335 | * @return float |
336 | 336 | */ |
337 | - public function get_recurring_amount( $context = 'view' ) { |
|
338 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
337 | + public function get_recurring_amount($context = 'view') { |
|
338 | + return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context)); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $context View or edit context. |
346 | 346 | * @return int |
347 | 347 | */ |
348 | - public function get_bill_times( $context = 'view' ) { |
|
349 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
348 | + public function get_bill_times($context = 'view') { |
|
349 | + return (int) $this->get_prop('bill_times', $context); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | * @param string $context View or edit context. |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public function get_transaction_id( $context = 'view' ) { |
|
360 | - return $this->get_prop( 'transaction_id', $context ); |
|
359 | + public function get_transaction_id($context = 'view') { |
|
360 | + return $this->get_prop('transaction_id', $context); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param string $context View or edit context. |
368 | 368 | * @return string |
369 | 369 | */ |
370 | - public function get_created( $context = 'view' ) { |
|
371 | - return $this->get_prop( 'created', $context ); |
|
370 | + public function get_created($context = 'view') { |
|
371 | + return $this->get_prop('created', $context); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $context View or edit context. |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public function get_date_created( $context = 'view' ) { |
|
382 | - return $this->get_created( $context ); |
|
381 | + public function get_date_created($context = 'view') { |
|
382 | + return $this->get_created($context); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function get_time_created() { |
392 | 392 | $created = $this->get_date_created(); |
393 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
393 | + return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp')); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -400,11 +400,11 @@ discard block |
||
400 | 400 | * @param string $context View or edit context. |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - public function get_date_created_gmt( $context = 'view' ) { |
|
404 | - $date = $this->get_date_created( $context ); |
|
403 | + public function get_date_created_gmt($context = 'view') { |
|
404 | + $date = $this->get_date_created($context); |
|
405 | 405 | |
406 | - if ( $date ) { |
|
407 | - $date = get_gmt_from_date( $date ); |
|
406 | + if ($date) { |
|
407 | + $date = get_gmt_from_date($date); |
|
408 | 408 | } |
409 | 409 | return $date; |
410 | 410 | } |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param string $context View or edit context. |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - public function get_next_renewal_date( $context = 'view' ) { |
|
420 | - return $this->get_prop( 'expiration', $context ); |
|
419 | + public function get_next_renewal_date($context = 'view') { |
|
420 | + return $this->get_prop('expiration', $context); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param string $context View or edit context. |
428 | 428 | * @return string |
429 | 429 | */ |
430 | - public function get_expiration( $context = 'view' ) { |
|
431 | - return $this->get_next_renewal_date( $context ); |
|
430 | + public function get_expiration($context = 'view') { |
|
431 | + return $this->get_next_renewal_date($context); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | public function get_expiration_time() { |
441 | 441 | $expiration = $this->get_expiration(); |
442 | 442 | |
443 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | - return current_time( 'timestamp' ); |
|
443 | + if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) { |
|
444 | + return current_time('timestamp'); |
|
445 | 445 | } |
446 | 446 | |
447 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
447 | + $expiration = strtotime($expiration, current_time('timestamp')); |
|
448 | + return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | * @param string $context View or edit context. |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | - $date = $this->get_next_renewal_date( $context ); |
|
458 | + public function get_next_renewal_date_gmt($context = 'view') { |
|
459 | + $date = $this->get_next_renewal_date($context); |
|
460 | 460 | |
461 | - if ( $date ) { |
|
462 | - $date = get_gmt_from_date( $date ); |
|
461 | + if ($date) { |
|
462 | + $date = get_gmt_from_date($date); |
|
463 | 463 | } |
464 | 464 | return $date; |
465 | 465 | } |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * @param string $context View or edit context. |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function get_trial_period( $context = 'view' ) { |
|
475 | - return $this->get_prop( 'trial_period', $context ); |
|
474 | + public function get_trial_period($context = 'view') { |
|
475 | + return $this->get_prop('trial_period', $context); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param string $context View or edit context. |
483 | 483 | * @return string |
484 | 484 | */ |
485 | - public function get_status( $context = 'view' ) { |
|
486 | - return $this->get_prop( 'status', $context ); |
|
485 | + public function get_status($context = 'view') { |
|
486 | + return $this->get_prop('status', $context); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * @param string $context View or edit context. |
494 | 494 | * @return string |
495 | 495 | */ |
496 | - public function get_profile_id( $context = 'view' ) { |
|
497 | - return $this->get_prop( 'profile_id', $context ); |
|
496 | + public function get_profile_id($context = 'view') { |
|
497 | + return $this->get_prop('profile_id', $context); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /* |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @since 1.0.19 |
510 | 510 | * @param int $value The customer's id. |
511 | 511 | */ |
512 | - public function set_customer_id( $value ) { |
|
513 | - $this->set_prop( 'customer_id', (int) $value ); |
|
512 | + public function set_customer_id($value) { |
|
513 | + $this->set_prop('customer_id', (int) $value); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | * @since 1.0.19 |
520 | 520 | * @param int $value The parent invoice id. |
521 | 521 | */ |
522 | - public function set_parent_invoice_id( $value ) { |
|
523 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
522 | + public function set_parent_invoice_id($value) { |
|
523 | + $this->set_prop('parent_payment_id', (int) $value); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | * @since 1.0.19 |
530 | 530 | * @param int $value The parent invoice id. |
531 | 531 | */ |
532 | - public function set_parent_payment_id( $value ) { |
|
533 | - $this->set_parent_invoice_id( $value ); |
|
532 | + public function set_parent_payment_id($value) { |
|
533 | + $this->set_parent_invoice_id($value); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @since 1.0.19 |
540 | 540 | * @param int $value The parent invoice id. |
541 | 541 | */ |
542 | - public function set_original_payment_id( $value ) { |
|
543 | - $this->set_parent_invoice_id( $value ); |
|
542 | + public function set_original_payment_id($value) { |
|
543 | + $this->set_parent_invoice_id($value); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * @since 1.0.19 |
550 | 550 | * @param int $value The subscription product id. |
551 | 551 | */ |
552 | - public function set_product_id( $value ) { |
|
553 | - $this->set_prop( 'product_id', (int) $value ); |
|
552 | + public function set_product_id($value) { |
|
553 | + $this->set_prop('product_id', (int) $value); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | * @since 1.0.19 |
560 | 560 | * @param string $value The renewal period. |
561 | 561 | */ |
562 | - public function set_period( $value ) { |
|
563 | - $this->set_prop( 'period', $value ); |
|
562 | + public function set_period($value) { |
|
563 | + $this->set_prop('period', $value); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -569,9 +569,9 @@ discard block |
||
569 | 569 | * @since 1.0.19 |
570 | 570 | * @param int $value The subscription frequency. |
571 | 571 | */ |
572 | - public function set_frequency( $value ) { |
|
573 | - $value = empty( $value ) ? 1 : (int) $value; |
|
574 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
572 | + public function set_frequency($value) { |
|
573 | + $value = empty($value) ? 1 : (int) $value; |
|
574 | + $this->set_prop('frequency', absint($value)); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @since 1.0.19 |
581 | 581 | * @param float $value The initial subcription amount. |
582 | 582 | */ |
583 | - public function set_initial_amount( $value ) { |
|
584 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
583 | + public function set_initial_amount($value) { |
|
584 | + $this->set_prop('initial_amount', wpinv_sanitize_amount($value)); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @since 1.0.19 |
591 | 591 | * @param float $value The recurring subcription amount. |
592 | 592 | */ |
593 | - public function set_recurring_amount( $value ) { |
|
594 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
593 | + public function set_recurring_amount($value) { |
|
594 | + $this->set_prop('recurring_amount', wpinv_sanitize_amount($value)); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @since 1.0.19 |
601 | 601 | * @param int $value Bill times. |
602 | 602 | */ |
603 | - public function set_bill_times( $value ) { |
|
604 | - $this->set_prop( 'bill_times', (int) $value ); |
|
603 | + public function set_bill_times($value) { |
|
604 | + $this->set_prop('bill_times', (int) $value); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | * @since 1.0.19 |
611 | 611 | * @param string $value Bill times. |
612 | 612 | */ |
613 | - public function set_transaction_id( $value ) { |
|
614 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
613 | + public function set_transaction_id($value) { |
|
614 | + $this->set_prop('transaction_id', sanitize_text_field($value)); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -620,15 +620,15 @@ discard block |
||
620 | 620 | * @since 1.0.19 |
621 | 621 | * @param string $value strtotime compliant date. |
622 | 622 | */ |
623 | - public function set_created( $value ) { |
|
624 | - $date = strtotime( $value ); |
|
623 | + public function set_created($value) { |
|
624 | + $date = strtotime($value); |
|
625 | 625 | |
626 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
627 | - $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
626 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
627 | + $this->set_prop('created', date('Y-m-d H:i:s', $date)); |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | - $this->set_prop( 'created', '' ); |
|
631 | + $this->set_prop('created', ''); |
|
632 | 632 | |
633 | 633 | } |
634 | 634 | |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | * @since 1.0.19 |
639 | 639 | * @param string $value strtotime compliant date. |
640 | 640 | */ |
641 | - public function set_date_created( $value ) { |
|
642 | - $this->set_created( $value ); |
|
641 | + public function set_date_created($value) { |
|
642 | + $this->set_created($value); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -648,15 +648,15 @@ discard block |
||
648 | 648 | * @since 1.0.19 |
649 | 649 | * @param string $value strtotime compliant date. |
650 | 650 | */ |
651 | - public function set_next_renewal_date( $value ) { |
|
652 | - $date = strtotime( $value ); |
|
651 | + public function set_next_renewal_date($value) { |
|
652 | + $date = strtotime($value); |
|
653 | 653 | |
654 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
655 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
654 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
655 | + $this->set_prop('expiration', date('Y-m-d H:i:s', $date)); |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | - $this->set_prop( 'expiration', '' ); |
|
659 | + $this->set_prop('expiration', ''); |
|
660 | 660 | |
661 | 661 | } |
662 | 662 | |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | * @since 1.0.19 |
667 | 667 | * @param string $value strtotime compliant date. |
668 | 668 | */ |
669 | - public function set_expiration( $value ) { |
|
670 | - $this->set_next_renewal_date( $value ); |
|
669 | + public function set_expiration($value) { |
|
670 | + $this->set_next_renewal_date($value); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | * @since 1.0.19 |
677 | 677 | * @param string $value trial period e.g 1 year. |
678 | 678 | */ |
679 | - public function set_trial_period( $value ) { |
|
680 | - $this->set_prop( 'trial_period', $value ); |
|
679 | + public function set_trial_period($value) { |
|
680 | + $this->set_prop('trial_period', $value); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -686,23 +686,23 @@ discard block |
||
686 | 686 | * @since 1.0.19 |
687 | 687 | * @param string $new_status New subscription status. |
688 | 688 | */ |
689 | - public function set_status( $new_status ) { |
|
689 | + public function set_status($new_status) { |
|
690 | 690 | |
691 | 691 | // Abort if this is not a valid status; |
692 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
692 | + if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) { |
|
693 | 693 | return; |
694 | 694 | } |
695 | 695 | |
696 | 696 | |
697 | - $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status(); |
|
698 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
697 | + $old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status(); |
|
698 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
699 | 699 | $this->status_transition = array( |
700 | 700 | 'from' => $old_status, |
701 | 701 | 'to' => $new_status, |
702 | 702 | ); |
703 | 703 | } |
704 | 704 | |
705 | - $this->set_prop( 'status', $new_status ); |
|
705 | + $this->set_prop('status', $new_status); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | * @since 1.0.19 |
712 | 712 | * @param string $value the remote profile id. |
713 | 713 | */ |
714 | - public function set_profile_id( $value ) { |
|
715 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
714 | + public function set_profile_id($value) { |
|
715 | + $this->set_prop('profile_id', sanitize_text_field($value)); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /* |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @param string|array String or array of strings to check for. |
731 | 731 | * @return bool |
732 | 732 | */ |
733 | - public function has_status( $status ) { |
|
734 | - return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) ); |
|
733 | + public function has_status($status) { |
|
734 | + return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status))); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | */ |
742 | 742 | public function has_trial_period() { |
743 | 743 | $period = $this->get_trial_period(); |
744 | - return ! empty( $period ); |
|
744 | + return !empty($period); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | * @return bool |
751 | 751 | */ |
752 | 752 | public function is_active() { |
753 | - return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
753 | + return $this->has_status('active trialling') && !$this->is_expired(); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * @return bool |
760 | 760 | */ |
761 | 761 | public function is_expired() { |
762 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) ); |
|
762 | + return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('timestamp')); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | */ |
770 | 770 | public function is_last_renewal() { |
771 | 771 | $max_bills = $this->get_bill_times(); |
772 | - return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed(); |
|
772 | + return !empty($max_bills) && $max_bills <= $this->get_times_billed(); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /* |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | /** |
785 | 785 | * Backwards compatibilty. |
786 | 786 | */ |
787 | - public function create( $data = array() ) { |
|
787 | + public function create($data = array()) { |
|
788 | 788 | |
789 | 789 | // Set the properties. |
790 | - if ( is_array( $data ) ) { |
|
791 | - $this->set_props( $data ); |
|
790 | + if (is_array($data)) { |
|
791 | + $this->set_props($data); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | // Save the item. |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | /** |
800 | 800 | * Backwards compatibilty. |
801 | 801 | */ |
802 | - public function update( $args = array() ) { |
|
803 | - return $this->create( $args ); |
|
802 | + public function update($args = array()) { |
|
803 | + return $this->create($args); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -809,12 +809,12 @@ discard block |
||
809 | 809 | * @since 1.0.0 |
810 | 810 | * @return WP_Post[] |
811 | 811 | */ |
812 | - public function get_child_payments( $hide_pending = true ) { |
|
812 | + public function get_child_payments($hide_pending = true) { |
|
813 | 813 | |
814 | - $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' ); |
|
814 | + $statuses = array('publish', 'wpi-processing', 'wpi-renewal'); |
|
815 | 815 | |
816 | - if ( ! $hide_pending ) { |
|
817 | - $statuses = array_keys( wpinv_get_invoice_statuses() ); |
|
816 | + if (!$hide_pending) { |
|
817 | + $statuses = array_keys(wpinv_get_invoice_statuses()); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | return get_posts( |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | * @return int |
837 | 837 | */ |
838 | 838 | public function get_total_payments() { |
839 | - return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() ); |
|
839 | + return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id()); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | public function get_times_billed() { |
849 | 849 | $times_billed = $this->get_total_payments(); |
850 | 850 | |
851 | - if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) { |
|
851 | + if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) { |
|
852 | 852 | $times_billed--; |
853 | 853 | } |
854 | 854 | |
@@ -863,49 +863,49 @@ discard block |
||
863 | 863 | * @param WPInv_Invoice $invoice If adding an existing invoice. |
864 | 864 | * @return bool |
865 | 865 | */ |
866 | - public function add_payment( $args = array(), $invoice = false ) { |
|
866 | + public function add_payment($args = array(), $invoice = false) { |
|
867 | 867 | |
868 | 868 | // Process each payment once. |
869 | - if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) { |
|
869 | + if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) { |
|
870 | 870 | return false; |
871 | 871 | } |
872 | 872 | |
873 | 873 | // Are we creating a new invoice? |
874 | - if ( empty( $invoice ) ) { |
|
874 | + if (empty($invoice)) { |
|
875 | 875 | $invoice = $this->create_payment(); |
876 | 876 | |
877 | - if ( empty( $invoice ) ) { |
|
877 | + if (empty($invoice)) { |
|
878 | 878 | return false; |
879 | 879 | } |
880 | 880 | |
881 | 881 | } |
882 | 882 | |
883 | - $invoice->set_status( 'wpi-renewal' ); |
|
883 | + $invoice->set_status('wpi-renewal'); |
|
884 | 884 | |
885 | 885 | // Maybe set a transaction id. |
886 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
887 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
886 | + if (!empty($args['transaction_id'])) { |
|
887 | + $invoice->set_transaction_id($args['transaction_id']); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | // Set the completed date. |
891 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
891 | + $invoice->set_completed_date(current_time('mysql')); |
|
892 | 892 | |
893 | 893 | // And the gateway. |
894 | - if ( ! empty( $args['gateway'] ) ) { |
|
895 | - $invoice->set_gateway( $args['gateway'] ); |
|
894 | + if (!empty($args['gateway'])) { |
|
895 | + $invoice->set_gateway($args['gateway']); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | $invoice->save(); |
899 | 899 | |
900 | - if ( ! $invoice->exists() ) { |
|
900 | + if (!$invoice->exists()) { |
|
901 | 901 | return false; |
902 | 902 | } |
903 | 903 | |
904 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
905 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
906 | - do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
|
904 | + do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this); |
|
905 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
906 | + do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id()); |
|
907 | 907 | |
908 | - update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
|
908 | + update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id); |
|
909 | 909 | |
910 | 910 | return $invoice->get_id(); |
911 | 911 | } |
@@ -920,41 +920,41 @@ discard block |
||
920 | 920 | |
921 | 921 | $parent_invoice = $this->get_parent_payment(); |
922 | 922 | |
923 | - if ( ! $parent_invoice->exists() ) { |
|
923 | + if (!$parent_invoice->exists()) { |
|
924 | 924 | return false; |
925 | 925 | } |
926 | 926 | |
927 | 927 | // Duplicate the parent invoice. |
928 | - $invoice = getpaid_duplicate_invoice( $parent_invoice ); |
|
929 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
930 | - $invoice->set_subscription_id( $this->get_id() ); |
|
931 | - $invoice->set_remote_subscription_id( $this->get_profile_id() ); |
|
928 | + $invoice = getpaid_duplicate_invoice($parent_invoice); |
|
929 | + $invoice->set_parent_id($parent_invoice->get_id()); |
|
930 | + $invoice->set_subscription_id($this->get_id()); |
|
931 | + $invoice->set_remote_subscription_id($this->get_profile_id()); |
|
932 | 932 | |
933 | 933 | // Set invoice items. |
934 | - $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() ); |
|
935 | - $allowed_items = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] ); |
|
934 | + $subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id()); |
|
935 | + $allowed_items = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']); |
|
936 | 936 | $invoice_items = array(); |
937 | 937 | |
938 | - foreach ( $invoice->get_items() as $item ) { |
|
939 | - if ( in_array( $item->get_id(), $allowed_items ) ) { |
|
938 | + foreach ($invoice->get_items() as $item) { |
|
939 | + if (in_array($item->get_id(), $allowed_items)) { |
|
940 | 940 | $invoice_items[] = $item; |
941 | 941 | } |
942 | 942 | } |
943 | 943 | |
944 | - $invoice->set_items( $invoice_items ); |
|
944 | + $invoice->set_items($invoice_items); |
|
945 | 945 | |
946 | - if ( ! empty( $subscription_group['fees'] ) ) { |
|
947 | - $invoice->set_fees( $subscription_group['fees'] ); |
|
946 | + if (!empty($subscription_group['fees'])) { |
|
947 | + $invoice->set_fees($subscription_group['fees']); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | // Maybe recalculate discount (Pre-GetPaid Fix). |
951 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
952 | - if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) { |
|
953 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
951 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
952 | + if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) { |
|
953 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | $invoice->recalculate_total(); |
957 | - $invoice->set_status( 'wpi-pending' ); |
|
957 | + $invoice->set_status('wpi-pending'); |
|
958 | 958 | $invoice->save(); |
959 | 959 | |
960 | 960 | return $invoice->exists() ? $invoice : false; |
@@ -969,20 +969,20 @@ discard block |
||
969 | 969 | public function renew() { |
970 | 970 | |
971 | 971 | // Complete subscription if applicable |
972 | - if ( $this->is_last_renewal() ) { |
|
972 | + if ($this->is_last_renewal()) { |
|
973 | 973 | return $this->complete(); |
974 | 974 | } |
975 | 975 | |
976 | 976 | // Calculate new expiration |
977 | 977 | $frequency = $this->get_frequency(); |
978 | 978 | $period = $this->get_period(); |
979 | - $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
979 | + $new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time()); |
|
980 | 980 | |
981 | - $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
982 | - $this->set_status( 'active' ); |
|
981 | + $this->set_expiration(date('Y-m-d H:i:s', $new_expiration)); |
|
982 | + $this->set_status('active'); |
|
983 | 983 | $this->save(); |
984 | 984 | |
985 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
985 | + do_action('getpaid_subscription_renewed', $this); |
|
986 | 986 | |
987 | 987 | return $this->get_id(); |
988 | 988 | } |
@@ -998,11 +998,11 @@ discard block |
||
998 | 998 | public function complete() { |
999 | 999 | |
1000 | 1000 | // Only mark a subscription as complete if it's not already cancelled. |
1001 | - if ( $this->has_status( 'cancelled' ) ) { |
|
1001 | + if ($this->has_status('cancelled')) { |
|
1002 | 1002 | return false; |
1003 | 1003 | } |
1004 | 1004 | |
1005 | - $this->set_status( 'completed' ); |
|
1005 | + $this->set_status('completed'); |
|
1006 | 1006 | return $this->save(); |
1007 | 1007 | |
1008 | 1008 | } |
@@ -1014,14 +1014,14 @@ discard block |
||
1014 | 1014 | * @param bool $check_expiration |
1015 | 1015 | * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
1016 | 1016 | */ |
1017 | - public function expire( $check_expiration = false ) { |
|
1017 | + public function expire($check_expiration = false) { |
|
1018 | 1018 | |
1019 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1019 | + if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) { |
|
1020 | 1020 | // Do not mark as expired since real expiration date is in the future |
1021 | 1021 | return false; |
1022 | 1022 | } |
1023 | 1023 | |
1024 | - $this->set_status( 'expired' ); |
|
1024 | + $this->set_status('expired'); |
|
1025 | 1025 | return $this->save(); |
1026 | 1026 | |
1027 | 1027 | } |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | * @return int Subscription id. |
1034 | 1034 | */ |
1035 | 1035 | public function failing() { |
1036 | - $this->set_status( 'failing' ); |
|
1036 | + $this->set_status('failing'); |
|
1037 | 1037 | return $this->save(); |
1038 | 1038 | } |
1039 | 1039 | |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | * @return int Subscription id. |
1045 | 1045 | */ |
1046 | 1046 | public function cancel() { |
1047 | - $this->set_status( 'cancelled' ); |
|
1047 | + $this->set_status('cancelled'); |
|
1048 | 1048 | return $this->save(); |
1049 | 1049 | } |
1050 | 1050 | |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | * @return bool |
1056 | 1056 | */ |
1057 | 1057 | public function can_cancel() { |
1058 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1058 | + return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this); |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | /** |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | * @return array |
1067 | 1067 | */ |
1068 | 1068 | public function get_cancellable_statuses() { |
1069 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
1069 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | /** |
@@ -1076,8 +1076,8 @@ discard block |
||
1076 | 1076 | * @return string |
1077 | 1077 | */ |
1078 | 1078 | public function get_cancel_url() { |
1079 | - $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1080 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1079 | + $url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url()); |
|
1080 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | /** |
@@ -1088,10 +1088,10 @@ discard block |
||
1088 | 1088 | */ |
1089 | 1089 | public function get_view_url() { |
1090 | 1090 | |
1091 | - $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1092 | - $url = add_query_arg( 'subscription', $this->get_id(), $url ); |
|
1091 | + $url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
1092 | + $url = add_query_arg('subscription', $this->get_id(), $url); |
|
1093 | 1093 | |
1094 | - return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1094 | + return apply_filters('getpaid_get_subscription_view_url', $url, $this); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | /** |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | * @return bool |
1105 | 1105 | */ |
1106 | 1106 | public function can_renew() { |
1107 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1107 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | /** |
@@ -1114,8 +1114,8 @@ discard block |
||
1114 | 1114 | * @return string |
1115 | 1115 | */ |
1116 | 1116 | public function get_renew_url() { |
1117 | - $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' ); |
|
1118 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1117 | + $url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'getpaid-nonce'); |
|
1118 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | /** |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | * @return bool |
1126 | 1126 | */ |
1127 | 1127 | public function can_update() { |
1128 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1128 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | /** |
@@ -1135,8 +1135,8 @@ discard block |
||
1135 | 1135 | * @return string |
1136 | 1136 | */ |
1137 | 1137 | public function get_update_url() { |
1138 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1139 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1138 | + $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id())); |
|
1139 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | /** |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | * @return string |
1147 | 1147 | */ |
1148 | 1148 | public function get_status_label() { |
1149 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1149 | + return getpaid_get_subscription_status_label($this->get_status()); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | /** |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | public function get_status_class() { |
1159 | 1159 | $statuses = getpaid_get_subscription_status_classes(); |
1160 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
1160 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1168,9 +1168,9 @@ discard block |
||
1168 | 1168 | */ |
1169 | 1169 | public function get_status_label_html() { |
1170 | 1170 | |
1171 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1172 | - $class = esc_attr( $this->get_status_class() ); |
|
1173 | - $status = sanitize_html_class( $this->get_status() ); |
|
1171 | + $status_label = sanitize_text_field($this->get_status_label()); |
|
1172 | + $class = esc_attr($this->get_status_class()); |
|
1173 | + $status = sanitize_html_class($this->get_status()); |
|
1174 | 1174 | |
1175 | 1175 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
1176 | 1176 | } |
@@ -1182,9 +1182,9 @@ discard block |
||
1182 | 1182 | * @param string $txn_id The transaction ID from the merchant processor |
1183 | 1183 | * @return bool |
1184 | 1184 | */ |
1185 | - public function payment_exists( $txn_id = '' ) { |
|
1186 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1187 | - return ! empty( $invoice_id ); |
|
1185 | + public function payment_exists($txn_id = '') { |
|
1186 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id'); |
|
1187 | + return !empty($invoice_id); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | /** |
@@ -1196,35 +1196,35 @@ discard block |
||
1196 | 1196 | // Reset status transition variable. |
1197 | 1197 | $this->status_transition = false; |
1198 | 1198 | |
1199 | - if ( $status_transition ) { |
|
1199 | + if ($status_transition) { |
|
1200 | 1200 | try { |
1201 | 1201 | |
1202 | 1202 | // Fire a hook for the status change. |
1203 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1204 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1203 | + do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
1204 | + do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition); |
|
1205 | 1205 | |
1206 | - if ( ! empty( $status_transition['from'] ) ) { |
|
1206 | + if (!empty($status_transition['from'])) { |
|
1207 | 1207 | |
1208 | 1208 | /* translators: 1: old subscription status 2: new subscription status */ |
1209 | - $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1209 | + $transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1210 | 1210 | |
1211 | 1211 | // Note the transition occurred. |
1212 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1212 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1213 | 1213 | |
1214 | 1214 | // Fire another hook. |
1215 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1216 | - do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1215 | + do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
1216 | + do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
1217 | 1217 | |
1218 | 1218 | } else { |
1219 | 1219 | /* translators: %s: new invoice status */ |
1220 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1220 | + $transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1221 | 1221 | |
1222 | 1222 | // Note the transition occurred. |
1223 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1223 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1224 | 1224 | |
1225 | 1225 | } |
1226 | - } catch ( Exception $e ) { |
|
1227 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1226 | + } catch (Exception $e) { |
|
1227 | + $this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
1228 | 1228 | } |
1229 | 1229 | } |
1230 | 1230 | |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | */ |
1251 | 1251 | public function activate() { |
1252 | 1252 | $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
1253 | - $this->set_status( $status ); |
|
1253 | + $this->set_status($status); |
|
1254 | 1254 | return $this->save(); |
1255 | 1255 | } |
1256 | 1256 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves an item by it's ID. |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | * @param int the item ID to retrieve. |
15 | 15 | * @return WPInv_Item|false |
16 | 16 | */ |
17 | -function wpinv_get_item_by_id( $id ) { |
|
18 | - $item = wpinv_get_item( $id ); |
|
19 | - return empty( $item ) || $id != $item->get_id() ? false : $item; |
|
17 | +function wpinv_get_item_by_id($id) { |
|
18 | + $item = wpinv_get_item($id); |
|
19 | + return empty($item) || $id != $item->get_id() ? false : $item; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return WPInv_Item|false |
26 | 26 | */ |
27 | -function wpinv_get_item_by( $field = '', $value = '', $type = '' ) { |
|
27 | +function wpinv_get_item_by($field = '', $value = '', $type = '') { |
|
28 | 28 | |
29 | - if ( 'id' == strtolower( $field ) ) { |
|
30 | - return wpinv_get_item_by_id( $field ); |
|
29 | + if ('id' == strtolower($field)) { |
|
30 | + return wpinv_get_item_by_id($field); |
|
31 | 31 | } |
32 | 32 | |
33 | - $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type ); |
|
34 | - return empty( $id ) ? false : wpinv_get_item( $id ); |
|
33 | + $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type); |
|
34 | + return empty($id) ? false : wpinv_get_item($id); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | * @param int|WPInv_Item the item to retrieve. |
42 | 42 | * @return WPInv_Item|false |
43 | 43 | */ |
44 | -function wpinv_get_item( $item = 0 ) { |
|
44 | +function wpinv_get_item($item = 0) { |
|
45 | 45 | |
46 | - if ( empty( $item ) ) { |
|
46 | + if (empty($item)) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | |
50 | - $item = new WPInv_Item( $item ); |
|
50 | + $item = new WPInv_Item($item); |
|
51 | 51 | return $item->exists() ? $item : false; |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | -function wpinv_get_all_items( $args = array() ) { |
|
55 | +function wpinv_get_all_items($args = array()) { |
|
56 | 56 | |
57 | - $args = wp_parse_args( $args, array( |
|
58 | - 'status' => array( 'publish' ), |
|
59 | - 'limit' => get_option( 'posts_per_page' ), |
|
57 | + $args = wp_parse_args($args, array( |
|
58 | + 'status' => array('publish'), |
|
59 | + 'limit' => get_option('posts_per_page'), |
|
60 | 60 | 'page' => 1, |
61 | 61 | 'exclude' => array(), |
62 | 62 | 'orderby' => 'date', |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'meta_query' => array(), |
66 | 66 | 'return' => 'objects', |
67 | 67 | 'paginate' => false, |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | $wp_query_args = array( |
71 | 71 | 'post_type' => 'wpi_item', |
@@ -75,26 +75,26 @@ discard block |
||
75 | 75 | 'fields' => 'ids', |
76 | 76 | 'orderby' => $args['orderby'], |
77 | 77 | 'order' => $args['order'], |
78 | - 'paged' => absint( $args['page'] ), |
|
78 | + 'paged' => absint($args['page']), |
|
79 | 79 | ); |
80 | 80 | |
81 | - if ( ! empty( $args['exclude'] ) ) { |
|
82 | - $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] ); |
|
81 | + if (!empty($args['exclude'])) { |
|
82 | + $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']); |
|
83 | 83 | } |
84 | 84 | |
85 | - if ( ! $args['paginate' ] ) { |
|
85 | + if (!$args['paginate']) { |
|
86 | 86 | $wp_query_args['no_found_rows'] = true; |
87 | 87 | } |
88 | 88 | |
89 | - if ( ! empty( $args['search'] ) ) { |
|
89 | + if (!empty($args['search'])) { |
|
90 | 90 | $wp_query_args['s'] = $args['search']; |
91 | 91 | } |
92 | 92 | |
93 | - if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) { |
|
94 | - $types = wpinv_parse_list( $args['type'] ); |
|
93 | + if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) { |
|
94 | + $types = wpinv_parse_list($args['type']); |
|
95 | 95 | $wp_query_args['meta_query'][] = array( |
96 | 96 | 'key' => '_wpinv_type', |
97 | - 'value' => implode( ',', $types ), |
|
97 | + 'value' => implode(',', $types), |
|
98 | 98 | 'compare' => 'IN', |
99 | 99 | ); |
100 | 100 | } |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args); |
103 | 103 | |
104 | 104 | // Get results. |
105 | - $items = new WP_Query( $wp_query_args ); |
|
105 | + $items = new WP_Query($wp_query_args); |
|
106 | 106 | |
107 | - if ( 'objects' === $args['return'] ) { |
|
108 | - $return = array_map( 'wpinv_get_item_by_id', $items->posts ); |
|
109 | - } elseif ( 'self' === $args['return'] ) { |
|
107 | + if ('objects' === $args['return']) { |
|
108 | + $return = array_map('wpinv_get_item_by_id', $items->posts); |
|
109 | + } elseif ('self' === $args['return']) { |
|
110 | 110 | return $items; |
111 | 111 | } else { |
112 | 112 | $return = $items->posts; |
113 | 113 | } |
114 | 114 | |
115 | - if ( $args['paginate' ] ) { |
|
115 | + if ($args['paginate']) { |
|
116 | 116 | return (object) array( |
117 | 117 | 'items' => $return, |
118 | 118 | 'total' => $items->found_posts, |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | |
125 | 125 | } |
126 | 126 | |
127 | -function wpinv_is_free_item( $item_id = 0 ) { |
|
128 | - if( empty( $item_id ) ) { |
|
127 | +function wpinv_is_free_item($item_id = 0) { |
|
128 | + if (empty($item_id)) { |
|
129 | 129 | return false; |
130 | 130 | } |
131 | 131 | |
132 | - $item = new WPInv_Item( $item_id ); |
|
132 | + $item = new WPInv_Item($item_id); |
|
133 | 133 | |
134 | 134 | return $item->is_free(); |
135 | 135 | } |
@@ -139,21 +139,21 @@ discard block |
||
139 | 139 | * |
140 | 140 | * @param WP_Post|WPInv_Item|Int $item The item to check for. |
141 | 141 | */ |
142 | -function wpinv_item_is_editable( $item = 0 ) { |
|
142 | +function wpinv_item_is_editable($item = 0) { |
|
143 | 143 | |
144 | 144 | // Fetch the item. |
145 | - $item = new WPInv_Item( $item ); |
|
145 | + $item = new WPInv_Item($item); |
|
146 | 146 | |
147 | 147 | // Check if it is editable. |
148 | 148 | return $item->is_editable(); |
149 | 149 | } |
150 | 150 | |
151 | -function wpinv_get_item_price( $item_id = 0 ) { |
|
152 | - if( empty( $item_id ) ) { |
|
151 | +function wpinv_get_item_price($item_id = 0) { |
|
152 | + if (empty($item_id)) { |
|
153 | 153 | return false; |
154 | 154 | } |
155 | 155 | |
156 | - $item = new WPInv_Item( $item_id ); |
|
156 | + $item = new WPInv_Item($item_id); |
|
157 | 157 | |
158 | 158 | return $item->get_price(); |
159 | 159 | } |
@@ -163,96 +163,96 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param WPInv_Item|int $item |
165 | 165 | */ |
166 | -function wpinv_is_recurring_item( $item = 0 ) { |
|
167 | - $item = new WPInv_Item( $item ); |
|
166 | +function wpinv_is_recurring_item($item = 0) { |
|
167 | + $item = new WPInv_Item($item); |
|
168 | 168 | return $item->is_recurring(); |
169 | 169 | } |
170 | 170 | |
171 | -function wpinv_item_price( $item_id = 0 ) { |
|
172 | - if( empty( $item_id ) ) { |
|
171 | +function wpinv_item_price($item_id = 0) { |
|
172 | + if (empty($item_id)) { |
|
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | |
176 | - $price = wpinv_get_item_price( $item_id ); |
|
177 | - $price = wpinv_price( $price ); |
|
176 | + $price = wpinv_get_item_price($item_id); |
|
177 | + $price = wpinv_price($price); |
|
178 | 178 | |
179 | - return apply_filters( 'wpinv_item_price', $price, $item_id ); |
|
179 | + return apply_filters('wpinv_item_price', $price, $item_id); |
|
180 | 180 | } |
181 | 181 | |
182 | -function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) { |
|
183 | - if ( is_null( $amount_override ) ) { |
|
184 | - $original_price = get_post_meta( $item_id, '_wpinv_price', true ); |
|
182 | +function wpinv_get_item_final_price($item_id = 0, $amount_override = null) { |
|
183 | + if (is_null($amount_override)) { |
|
184 | + $original_price = get_post_meta($item_id, '_wpinv_price', true); |
|
185 | 185 | } else { |
186 | 186 | $original_price = $amount_override; |
187 | 187 | } |
188 | 188 | |
189 | 189 | $price = $original_price; |
190 | 190 | |
191 | - return apply_filters( 'wpinv_get_item_final_price', $price, $item_id ); |
|
191 | + return apply_filters('wpinv_get_item_final_price', $price, $item_id); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_item_custom_singular_name( $item_id ) { |
|
195 | - if( empty( $item_id ) ) { |
|
194 | +function wpinv_item_custom_singular_name($item_id) { |
|
195 | + if (empty($item_id)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
199 | - $item = new WPInv_Item( $item_id ); |
|
199 | + $item = new WPInv_Item($item_id); |
|
200 | 200 | |
201 | 201 | return $item->get_custom_singular_name(); |
202 | 202 | } |
203 | 203 | |
204 | 204 | function wpinv_get_item_types() { |
205 | 205 | $item_types = array( |
206 | - 'custom' => __( 'Standard', 'invoicing' ), |
|
207 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
206 | + 'custom' => __('Standard', 'invoicing'), |
|
207 | + 'fee' => __('Fee', 'invoicing'), |
|
208 | 208 | ); |
209 | - return apply_filters( 'wpinv_get_item_types', $item_types ); |
|
209 | + return apply_filters('wpinv_get_item_types', $item_types); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_item_types() { |
213 | 213 | $item_types = wpinv_get_item_types(); |
214 | 214 | |
215 | - return ( !empty( $item_types ) ? array_keys( $item_types ) : array() ); |
|
215 | + return (!empty($item_types) ? array_keys($item_types) : array()); |
|
216 | 216 | } |
217 | 217 | |
218 | -function wpinv_get_item_type( $item_id ) { |
|
219 | - if( empty( $item_id ) ) { |
|
218 | +function wpinv_get_item_type($item_id) { |
|
219 | + if (empty($item_id)) { |
|
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | - $item = new WPInv_Item( $item_id ); |
|
223 | + $item = new WPInv_Item($item_id); |
|
224 | 224 | |
225 | 225 | return $item->get_type(); |
226 | 226 | } |
227 | 227 | |
228 | -function wpinv_item_type( $item_id ) { |
|
228 | +function wpinv_item_type($item_id) { |
|
229 | 229 | $item_types = wpinv_get_item_types(); |
230 | 230 | |
231 | - $item_type = wpinv_get_item_type( $item_id ); |
|
231 | + $item_type = wpinv_get_item_type($item_id); |
|
232 | 232 | |
233 | - if ( empty( $item_type ) ) { |
|
233 | + if (empty($item_type)) { |
|
234 | 234 | $item_type = '-'; |
235 | 235 | } |
236 | 236 | |
237 | - $item_type = isset( $item_types[$item_type] ) ? $item_types[$item_type] : __( $item_type, 'invoicing' ); |
|
237 | + $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing'); |
|
238 | 238 | |
239 | - return apply_filters( 'wpinv_item_type', $item_type, $item_id ); |
|
239 | + return apply_filters('wpinv_item_type', $item_type, $item_id); |
|
240 | 240 | } |
241 | 241 | |
242 | -function wpinv_get_random_item( $post_ids = true ) { |
|
243 | - wpinv_get_random_items( 1, $post_ids ); |
|
242 | +function wpinv_get_random_item($post_ids = true) { |
|
243 | + wpinv_get_random_items(1, $post_ids); |
|
244 | 244 | } |
245 | 245 | |
246 | -function wpinv_get_random_items( $num = 3, $post_ids = true ) { |
|
247 | - if ( $post_ids ) { |
|
248 | - $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids' ); |
|
246 | +function wpinv_get_random_items($num = 3, $post_ids = true) { |
|
247 | + if ($post_ids) { |
|
248 | + $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids'); |
|
249 | 249 | } else { |
250 | - $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num ); |
|
250 | + $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num); |
|
251 | 251 | } |
252 | 252 | |
253 | - $args = apply_filters( 'wpinv_get_random_items', $args ); |
|
253 | + $args = apply_filters('wpinv_get_random_items', $args); |
|
254 | 254 | |
255 | - return get_posts( $args ); |
|
255 | + return get_posts($args); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | * @param WPInv_Item|int $item |
262 | 262 | * @param bool $html |
263 | 263 | */ |
264 | -function wpinv_get_item_suffix( $item, $html = true ) { |
|
264 | +function wpinv_get_item_suffix($item, $html = true) { |
|
265 | 265 | |
266 | - $item = new WPInv_Item( $item ); |
|
267 | - $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : ''; |
|
268 | - $suffix = $html ? $suffix : strip_tags( $suffix ); |
|
266 | + $item = new WPInv_Item($item); |
|
267 | + $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : ''; |
|
268 | + $suffix = $html ? $suffix : strip_tags($suffix); |
|
269 | 269 | |
270 | - return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html ); |
|
270 | + return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | * @param WPInv_Item|int $item |
277 | 277 | * @param bool $force_delete |
278 | 278 | */ |
279 | -function wpinv_remove_item( $item = 0, $force_delete = false ) { |
|
280 | - $item = new WPInv_Item( $item ); |
|
281 | - $item->delete( $force_delete ); |
|
279 | +function wpinv_remove_item($item = 0, $force_delete = false) { |
|
280 | + $item = new WPInv_Item($item); |
|
281 | + $item->delete($force_delete); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -317,45 +317,45 @@ discard block |
||
317 | 317 | * @param bool $wp_error whether or not to return a WP_Error on failure. |
318 | 318 | * @return bool|WP_Error|WPInv_Item |
319 | 319 | */ |
320 | -function wpinv_create_item( $args = array(), $wp_error = false ) { |
|
320 | +function wpinv_create_item($args = array(), $wp_error = false) { |
|
321 | 321 | |
322 | 322 | // Prepare the item. |
323 | - if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) { |
|
324 | - $type = empty( $args['type'] ) ? 'custom' : $args['type']; |
|
325 | - $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type ); |
|
323 | + if (!empty($args['custom_id']) && empty($args['ID'])) { |
|
324 | + $type = empty($args['type']) ? 'custom' : $args['type']; |
|
325 | + $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type); |
|
326 | 326 | |
327 | - if ( ! empty( $item ) ) { |
|
327 | + if (!empty($item)) { |
|
328 | 328 | $args['ID'] = $item->get_id(); |
329 | 329 | } |
330 | 330 | |
331 | 331 | } |
332 | 332 | |
333 | 333 | // Do we have an item? |
334 | - if ( ! empty( $args['ID'] ) ) { |
|
335 | - $item = new WPInv_Item( $args['ID'] ); |
|
334 | + if (!empty($args['ID'])) { |
|
335 | + $item = new WPInv_Item($args['ID']); |
|
336 | 336 | } else { |
337 | 337 | $item = new WPInv_Item(); |
338 | 338 | } |
339 | 339 | |
340 | 340 | // Do we have an error? |
341 | - if ( ! empty( $item->last_error ) ) { |
|
342 | - return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false; |
|
341 | + if (!empty($item->last_error)) { |
|
342 | + return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | // Update item props. |
346 | - $item->set_props( $args ); |
|
346 | + $item->set_props($args); |
|
347 | 347 | |
348 | 348 | // Save the item. |
349 | 349 | $item->save(); |
350 | 350 | |
351 | 351 | // Do we have an error? |
352 | - if ( ! empty( $item->last_error ) ) { |
|
353 | - return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false; |
|
352 | + if (!empty($item->last_error)) { |
|
353 | + return $wp_error ? new WP_Error('not_saved', $item->last_error) : false; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | // Was the item saved? |
357 | - if ( ! $item->get_id() ) { |
|
358 | - return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false; |
|
357 | + if (!$item->get_id()) { |
|
358 | + return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false; |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $item; |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @see wpinv_create_item() |
369 | 369 | */ |
370 | -function wpinv_update_item( $args = array(), $wp_error = false ) { |
|
371 | - return wpinv_create_item( $args, $wp_error ); |
|
370 | +function wpinv_update_item($args = array(), $wp_error = false) { |
|
371 | + return wpinv_create_item($args, $wp_error); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
375 | 375 | * Sanitizes a recurring period |
376 | 376 | */ |
377 | -function getpaid_sanitize_recurring_period( $period, $full = false ) { |
|
377 | +function getpaid_sanitize_recurring_period($period, $full = false) { |
|
378 | 378 | |
379 | 379 | $periods = array( |
380 | 380 | 'D' => 'day', |
@@ -383,16 +383,16 @@ discard block |
||
383 | 383 | 'Y' => 'year', |
384 | 384 | ); |
385 | 385 | |
386 | - if ( ! isset( $periods[ $period ] ) ) { |
|
386 | + if (!isset($periods[$period])) { |
|
387 | 387 | $period = 'D'; |
388 | 388 | } |
389 | 389 | |
390 | - return $full ? $periods[ $period ] : $period; |
|
390 | + return $full ? $periods[$period] : $period; |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | |
394 | -function wpinv_item_max_buyable_quantity( $item_id ) { |
|
395 | - return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id ); |
|
394 | +function wpinv_item_max_buyable_quantity($item_id) { |
|
395 | + return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -400,46 +400,46 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @param WPInv_Item|GetPaid_Form_Item $item |
402 | 402 | */ |
403 | -function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) { |
|
403 | +function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) { |
|
404 | 404 | |
405 | 405 | // Abort if it is not recurring. |
406 | - if ( ! $item->is_recurring() ) { |
|
406 | + if (!$item->is_recurring()) { |
|
407 | 407 | return ''; |
408 | 408 | } |
409 | 409 | |
410 | - $initial_price = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price; |
|
411 | - $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price; |
|
412 | - $period = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ); |
|
410 | + $initial_price = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price; |
|
411 | + $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price; |
|
412 | + $period = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), ''); |
|
413 | 413 | $initial_class = 'getpaid-item-initial-price'; |
414 | 414 | $recurring_class = 'getpaid-item-recurring-price'; |
415 | 415 | $bill_times = $item->get_recurring_limit(); |
416 | 416 | |
417 | - if ( ! empty( $bill_times ) ) { |
|
417 | + if (!empty($bill_times)) { |
|
418 | 418 | $bill_times = $item->get_recurring_interval() * $bill_times; |
419 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
419 | + $bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times); |
|
420 | 420 | } |
421 | 421 | |
422 | - if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
|
423 | - $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
|
424 | - $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency ); |
|
422 | + if ($item instanceof GetPaid_Form_Item && false === $_initial_price) { |
|
423 | + $initial_price = wpinv_price($item->get_sub_total(), $currency); |
|
424 | + $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency); |
|
425 | 425 | } |
426 | 426 | |
427 | - if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) { |
|
428 | - return __( 'Free forever', 'invoicing' ); |
|
427 | + if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) { |
|
428 | + return __('Free forever', 'invoicing'); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | // For free trial items. |
432 | - if ( $item->has_free_trial() ) { |
|
433 | - $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() ); |
|
432 | + if ($item->has_free_trial()) { |
|
433 | + $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval()); |
|
434 | 434 | |
435 | - if ( wpinv_price( 0, $currency ) == $initial_price ) { |
|
435 | + if (wpinv_price(0, $currency) == $initial_price) { |
|
436 | 436 | |
437 | - if ( empty( $bill_times ) ) { |
|
437 | + if (empty($bill_times)) { |
|
438 | 438 | |
439 | 439 | return sprintf( |
440 | 440 | |
441 | 441 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period |
442 | - _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ), |
|
442 | + _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'), |
|
443 | 443 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
444 | 444 | "<span class='$recurring_class'>$recurring_price</span>", |
445 | 445 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | return sprintf( |
452 | 452 | |
453 | 453 | // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times |
454 | - _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ), |
|
454 | + _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'), |
|
455 | 455 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
456 | 456 | "<span class='$recurring_class'>$recurring_price</span>", |
457 | 457 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -461,12 +461,12 @@ discard block |
||
461 | 461 | |
462 | 462 | } |
463 | 463 | |
464 | - if ( empty( $bill_times ) ) { |
|
464 | + if (empty($bill_times)) { |
|
465 | 465 | |
466 | 466 | return sprintf( |
467 | 467 | |
468 | 468 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period |
469 | - _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ), |
|
469 | + _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'), |
|
470 | 470 | "<span class='$initial_class'>$initial_price</span>", |
471 | 471 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
472 | 472 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | return sprintf( |
480 | 480 | |
481 | 481 | // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times |
482 | - _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ), |
|
482 | + _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'), |
|
483 | 483 | "<span class='$initial_class'>$initial_price</span>", |
484 | 484 | "<span class='getpaid-item-trial-period'>$trial_period</span>", |
485 | 485 | "<span class='$recurring_class'>$recurring_price</span>", |
@@ -490,14 +490,14 @@ discard block |
||
490 | 490 | |
491 | 491 | } |
492 | 492 | |
493 | - if ( $initial_price == $recurring_price ) { |
|
493 | + if ($initial_price == $recurring_price) { |
|
494 | 494 | |
495 | - if ( empty( $bill_times ) ) { |
|
495 | + if (empty($bill_times)) { |
|
496 | 496 | |
497 | 497 | return sprintf( |
498 | 498 | |
499 | 499 | // translators: $1: is the recurring price, $2: is the susbcription period |
500 | - _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ), |
|
500 | + _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'), |
|
501 | 501 | "<span class='$recurring_class'>$recurring_price</span>", |
502 | 502 | "<span class='getpaid-item-recurring-period'>$period</span>" |
503 | 503 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | return sprintf( |
509 | 509 | |
510 | 510 | // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times |
511 | - _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ), |
|
511 | + _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'), |
|
512 | 512 | "<span class='$recurring_class'>$recurring_price</span>", |
513 | 513 | "<span class='getpaid-item-recurring-period'>$period</span>", |
514 | 514 | "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>" |
@@ -517,14 +517,14 @@ discard block |
||
517 | 517 | |
518 | 518 | } |
519 | 519 | |
520 | - if ( $initial_price == wpinv_price( 0, $currency ) ) { |
|
520 | + if ($initial_price == wpinv_price(0, $currency)) { |
|
521 | 521 | |
522 | - if ( empty( $bill_times ) ) { |
|
522 | + if (empty($bill_times)) { |
|
523 | 523 | |
524 | 524 | return sprintf( |
525 | 525 | |
526 | 526 | // translators: $1: is the recurring period, $2: is the recurring price |
527 | - _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ), |
|
527 | + _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'), |
|
528 | 528 | "<span class='getpaid-item-recurring-period'>$period</span>", |
529 | 529 | "<span class='$recurring_class'>$recurring_price</span>" |
530 | 530 | |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | return sprintf( |
536 | 536 | |
537 | 537 | // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times |
538 | - _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ), |
|
538 | + _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'), |
|
539 | 539 | "<span class='getpaid-item-recurring-period'>$period</span>", |
540 | 540 | "<span class='$recurring_class'>$recurring_price</span>", |
541 | 541 | "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>" |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | |
545 | 545 | } |
546 | 546 | |
547 | - if ( empty( $bill_times ) ) { |
|
547 | + if (empty($bill_times)) { |
|
548 | 548 | |
549 | 549 | return sprintf( |
550 | 550 | |
551 | 551 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period |
552 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ), |
|
552 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'), |
|
553 | 553 | "<span class='$initial_class'>$initial_price</span>", |
554 | 554 | "<span class='$recurring_class'>$recurring_price</span>", |
555 | 555 | "<span class='getpaid-item-recurring-period'>$period</span>" |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | return sprintf( |
562 | 562 | |
563 | 563 | // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times |
564 | - _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ), |
|
564 | + _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'), |
|
565 | 565 | "<span class='$initial_class'>$initial_price</span>", |
566 | 566 | "<span class='$recurring_class'>$recurring_price</span>", |
567 | 567 | "<span class='getpaid-item-recurring-period'>$period</span>", |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Invoice class. |
@@ -145,40 +145,40 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
147 | 147 | */ |
148 | - public function __construct( $invoice = 0 ) { |
|
148 | + public function __construct($invoice = 0) { |
|
149 | 149 | |
150 | - parent::__construct( $invoice ); |
|
150 | + parent::__construct($invoice); |
|
151 | 151 | |
152 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
153 | - $this->set_id( (int) $invoice ); |
|
154 | - } elseif ( $invoice instanceof self ) { |
|
155 | - $this->set_id( $invoice->get_id() ); |
|
156 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
157 | - $this->set_id( $invoice->ID ); |
|
158 | - } elseif ( is_array( $invoice ) ) { |
|
159 | - $this->set_props( $invoice ); |
|
152 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) { |
|
153 | + $this->set_id((int) $invoice); |
|
154 | + } elseif ($invoice instanceof self) { |
|
155 | + $this->set_id($invoice->get_id()); |
|
156 | + } elseif (!empty($invoice->ID)) { |
|
157 | + $this->set_id($invoice->ID); |
|
158 | + } elseif (is_array($invoice)) { |
|
159 | + $this->set_props($invoice); |
|
160 | 160 | |
161 | - if ( isset( $invoice['ID'] ) ) { |
|
162 | - $this->set_id( $invoice['ID'] ); |
|
161 | + if (isset($invoice['ID'])) { |
|
162 | + $this->set_id($invoice['ID']); |
|
163 | 163 | } |
164 | 164 | |
165 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
166 | - $this->set_id( $invoice_id ); |
|
167 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
168 | - $this->set_id( $invoice_id ); |
|
169 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
170 | - $this->set_id( $invoice_id ); |
|
165 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
166 | + $this->set_id($invoice_id); |
|
167 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
168 | + $this->set_id($invoice_id); |
|
169 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
170 | + $this->set_id($invoice_id); |
|
171 | 171 | } else { |
172 | - $this->set_object_read( true ); |
|
172 | + $this->set_object_read(true); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | // Load the datastore. |
176 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
176 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
177 | 177 | |
178 | - if ( $this->get_id() > 0 ) { |
|
179 | - $this->post = get_post( $this->get_id() ); |
|
178 | + if ($this->get_id() > 0) { |
|
179 | + $this->post = get_post($this->get_id()); |
|
180 | 180 | $this->ID = $this->get_id(); |
181 | - $this->data_store->read( $this ); |
|
181 | + $this->data_store->read($this); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | } |
@@ -193,38 +193,38 @@ discard block |
||
193 | 193 | * @since 1.0.15 |
194 | 194 | * @return int |
195 | 195 | */ |
196 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
196 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
197 | 197 | global $wpdb; |
198 | 198 | |
199 | 199 | // Trim the value. |
200 | - $value = trim( $value ); |
|
200 | + $value = trim($value); |
|
201 | 201 | |
202 | - if ( empty( $value ) ) { |
|
202 | + if (empty($value)) { |
|
203 | 203 | return 0; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Valid fields. |
207 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
207 | + $fields = array('key', 'number', 'transaction_id'); |
|
208 | 208 | |
209 | 209 | // Ensure a field has been passed. |
210 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
210 | + if (empty($field) || !in_array($field, $fields)) { |
|
211 | 211 | return 0; |
212 | 212 | } |
213 | 213 | |
214 | 214 | // Maybe retrieve from the cache. |
215 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
216 | - if ( false !== $invoice_id ) { |
|
215 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
216 | + if (false !== $invoice_id) { |
|
217 | 217 | return $invoice_id; |
218 | 218 | } |
219 | 219 | |
220 | 220 | // Fetch from the db. |
221 | 221 | $table = $wpdb->prefix . 'getpaid_invoices'; |
222 | 222 | $invoice_id = (int) $wpdb->get_var( |
223 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
223 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
224 | 224 | ); |
225 | 225 | |
226 | 226 | // Update the cache with our data |
227 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
227 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
228 | 228 | |
229 | 229 | return $invoice_id; |
230 | 230 | } |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | /** |
233 | 233 | * Checks if an invoice key is set. |
234 | 234 | */ |
235 | - public function _isset( $key ) { |
|
236 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
235 | + public function _isset($key) { |
|
236 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /* |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | * @param string $context View or edit context. |
259 | 259 | * @return int |
260 | 260 | */ |
261 | - public function get_parent_id( $context = 'view' ) { |
|
262 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
261 | + public function get_parent_id($context = 'view') { |
|
262 | + return (int) $this->get_prop('parent_id', $context); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @return WPInv_Invoice |
270 | 270 | */ |
271 | 271 | public function get_parent_payment() { |
272 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
272 | + return new WPInv_Invoice($this->get_parent_id()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $context View or edit context. |
290 | 290 | * @return string |
291 | 291 | */ |
292 | - public function get_status( $context = 'view' ) { |
|
293 | - return $this->get_prop( 'status', $context ); |
|
292 | + public function get_status($context = 'view') { |
|
293 | + return $this->get_prop('status', $context); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @return array |
301 | 301 | */ |
302 | 302 | public function get_all_statuses() { |
303 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
303 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -312,9 +312,9 @@ discard block |
||
312 | 312 | public function get_status_nicename() { |
313 | 313 | $statuses = $this->get_all_statuses(); |
314 | 314 | |
315 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
315 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
316 | 316 | |
317 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
317 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public function get_status_class() { |
327 | 327 | $statuses = getpaid_get_invoice_status_classes(); |
328 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
328 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | */ |
337 | 337 | public function get_status_label_html() { |
338 | 338 | |
339 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
340 | - $status = sanitize_html_class( $this->get_status() ); |
|
341 | - $class = esc_attr( $this->get_status_class() ); |
|
339 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
340 | + $status = sanitize_html_class($this->get_status()); |
|
341 | + $class = esc_attr($this->get_status_class()); |
|
342 | 342 | |
343 | 343 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
344 | 344 | } |
@@ -350,23 +350,23 @@ discard block |
||
350 | 350 | * @param string $context View or edit context. |
351 | 351 | * @return string |
352 | 352 | */ |
353 | - public function get_version( $context = 'view' ) { |
|
354 | - return $this->get_prop( 'version', $context ); |
|
353 | + public function get_version($context = 'view') { |
|
354 | + return $this->get_prop('version', $context); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
358 | 358 | * @deprecated |
359 | 359 | */ |
360 | - public function get_invoice_date( $format = true ) { |
|
361 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
362 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
363 | - $formatted = getpaid_format_date( $date ); |
|
360 | + public function get_invoice_date($format = true) { |
|
361 | + $date = getpaid_format_date($this->get_date_completed()); |
|
362 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
363 | + $formatted = getpaid_format_date($date); |
|
364 | 364 | |
365 | - if ( $format ) { |
|
365 | + if ($format) { |
|
366 | 366 | return $formatted; |
367 | 367 | } |
368 | 368 | |
369 | - return empty( $formatted ) ? '' : $date; |
|
369 | + return empty($formatted) ? '' : $date; |
|
370 | 370 | |
371 | 371 | } |
372 | 372 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | * @param string $context View or edit context. |
378 | 378 | * @return string |
379 | 379 | */ |
380 | - public function get_date_created( $context = 'view' ) { |
|
381 | - return $this->get_prop( 'date_created', $context ); |
|
380 | + public function get_date_created($context = 'view') { |
|
381 | + return $this->get_prop('date_created', $context); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * @param string $context View or edit context. |
389 | 389 | * @return string |
390 | 390 | */ |
391 | - public function get_created_date( $context = 'view' ) { |
|
392 | - return $this->get_date_created( $context ); |
|
391 | + public function get_created_date($context = 'view') { |
|
392 | + return $this->get_date_created($context); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | * @param string $context View or edit context. |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public function get_date_created_gmt( $context = 'view' ) { |
|
403 | - $date = $this->get_date_created( $context ); |
|
402 | + public function get_date_created_gmt($context = 'view') { |
|
403 | + $date = $this->get_date_created($context); |
|
404 | 404 | |
405 | - if ( $date ) { |
|
406 | - $date = get_gmt_from_date( $date ); |
|
405 | + if ($date) { |
|
406 | + $date = get_gmt_from_date($date); |
|
407 | 407 | } |
408 | 408 | return $date; |
409 | 409 | } |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $context View or edit context. |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - public function get_date_modified( $context = 'view' ) { |
|
419 | - return $this->get_prop( 'date_modified', $context ); |
|
418 | + public function get_date_modified($context = 'view') { |
|
419 | + return $this->get_prop('date_modified', $context); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * @param string $context View or edit context. |
427 | 427 | * @return string |
428 | 428 | */ |
429 | - public function get_modified_date( $context = 'view' ) { |
|
430 | - return $this->get_date_modified( $context ); |
|
429 | + public function get_modified_date($context = 'view') { |
|
430 | + return $this->get_date_modified($context); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -437,11 +437,11 @@ discard block |
||
437 | 437 | * @param string $context View or edit context. |
438 | 438 | * @return string |
439 | 439 | */ |
440 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
441 | - $date = $this->get_date_modified( $context ); |
|
440 | + public function get_date_modified_gmt($context = 'view') { |
|
441 | + $date = $this->get_date_modified($context); |
|
442 | 442 | |
443 | - if ( $date ) { |
|
444 | - $date = get_gmt_from_date( $date ); |
|
443 | + if ($date) { |
|
444 | + $date = get_gmt_from_date($date); |
|
445 | 445 | } |
446 | 446 | return $date; |
447 | 447 | } |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * @param string $context View or edit context. |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public function get_due_date( $context = 'view' ) { |
|
457 | - return $this->get_prop( 'due_date', $context ); |
|
456 | + public function get_due_date($context = 'view') { |
|
457 | + return $this->get_prop('due_date', $context); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | * @param string $context View or edit context. |
465 | 465 | * @return string |
466 | 466 | */ |
467 | - public function get_date_due( $context = 'view' ) { |
|
468 | - return $this->get_due_date( $context ); |
|
467 | + public function get_date_due($context = 'view') { |
|
468 | + return $this->get_due_date($context); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -475,11 +475,11 @@ discard block |
||
475 | 475 | * @param string $context View or edit context. |
476 | 476 | * @return string |
477 | 477 | */ |
478 | - public function get_due_date_gmt( $context = 'view' ) { |
|
479 | - $date = $this->get_due_date( $context ); |
|
478 | + public function get_due_date_gmt($context = 'view') { |
|
479 | + $date = $this->get_due_date($context); |
|
480 | 480 | |
481 | - if ( $date ) { |
|
482 | - $date = get_gmt_from_date( $date ); |
|
481 | + if ($date) { |
|
482 | + $date = get_gmt_from_date($date); |
|
483 | 483 | } |
484 | 484 | return $date; |
485 | 485 | } |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | * @param string $context View or edit context. |
492 | 492 | * @return string |
493 | 493 | */ |
494 | - public function get_gmt_date_due( $context = 'view' ) { |
|
495 | - return $this->get_due_date_gmt( $context ); |
|
494 | + public function get_gmt_date_due($context = 'view') { |
|
495 | + return $this->get_due_date_gmt($context); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | /** |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * @param string $context View or edit context. |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public function get_completed_date( $context = 'view' ) { |
|
506 | - return $this->get_prop( 'completed_date', $context ); |
|
505 | + public function get_completed_date($context = 'view') { |
|
506 | + return $this->get_prop('completed_date', $context); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -513,8 +513,8 @@ discard block |
||
513 | 513 | * @param string $context View or edit context. |
514 | 514 | * @return string |
515 | 515 | */ |
516 | - public function get_date_completed( $context = 'view' ) { |
|
517 | - return $this->get_completed_date( $context ); |
|
516 | + public function get_date_completed($context = 'view') { |
|
517 | + return $this->get_completed_date($context); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | /** |
@@ -524,11 +524,11 @@ discard block |
||
524 | 524 | * @param string $context View or edit context. |
525 | 525 | * @return string |
526 | 526 | */ |
527 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
528 | - $date = $this->get_completed_date( $context ); |
|
527 | + public function get_completed_date_gmt($context = 'view') { |
|
528 | + $date = $this->get_completed_date($context); |
|
529 | 529 | |
530 | - if ( $date ) { |
|
531 | - $date = get_gmt_from_date( $date ); |
|
530 | + if ($date) { |
|
531 | + $date = get_gmt_from_date($date); |
|
532 | 532 | } |
533 | 533 | return $date; |
534 | 534 | } |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | * @param string $context View or edit context. |
541 | 541 | * @return string |
542 | 542 | */ |
543 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
544 | - return $this->get_completed_date_gmt( $context ); |
|
543 | + public function get_gmt_completed_date($context = 'view') { |
|
544 | + return $this->get_completed_date_gmt($context); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -551,12 +551,12 @@ discard block |
||
551 | 551 | * @param string $context View or edit context. |
552 | 552 | * @return string |
553 | 553 | */ |
554 | - public function get_number( $context = 'view' ) { |
|
555 | - $number = $this->get_prop( 'number', $context ); |
|
554 | + public function get_number($context = 'view') { |
|
555 | + $number = $this->get_prop('number', $context); |
|
556 | 556 | |
557 | - if ( empty( $number ) ) { |
|
557 | + if (empty($number)) { |
|
558 | 558 | $number = $this->generate_number(); |
559 | - $this->set_number( $this->generate_number() ); |
|
559 | + $this->set_number($this->generate_number()); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | return $number; |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | public function maybe_set_number() { |
571 | 571 | $number = $this->get_number(); |
572 | 572 | |
573 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
574 | - $this->set_number( $this->generate_number() ); |
|
573 | + if (empty($number) || $this->get_id() == $number) { |
|
574 | + $this->set_number($this->generate_number()); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | } |
@@ -583,8 +583,8 @@ discard block |
||
583 | 583 | * @param string $context View or edit context. |
584 | 584 | * @return string |
585 | 585 | */ |
586 | - public function get_key( $context = 'view' ) { |
|
587 | - return $this->get_prop( 'key', $context ); |
|
586 | + public function get_key($context = 'view') { |
|
587 | + return $this->get_prop('key', $context); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | /** |
@@ -595,9 +595,9 @@ discard block |
||
595 | 595 | public function maybe_set_key() { |
596 | 596 | $key = $this->get_key(); |
597 | 597 | |
598 | - if ( empty( $key ) ) { |
|
599 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
600 | - $this->set_key( $key ); |
|
598 | + if (empty($key)) { |
|
599 | + $key = $this->generate_key($this->get_type() . '_'); |
|
600 | + $this->set_key($key); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | } |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | * @param string $context View or edit context. |
610 | 610 | * @return string |
611 | 611 | */ |
612 | - public function get_type( $context = 'view' ) { |
|
613 | - return $this->get_prop( 'type', $context ); |
|
612 | + public function get_type($context = 'view') { |
|
613 | + return $this->get_prop('type', $context); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * @return string |
621 | 621 | */ |
622 | 622 | public function get_invoice_quote_type() { |
623 | - return getpaid_get_post_type_label( $this->get_post_type(), false ); |
|
623 | + return getpaid_get_post_type_label($this->get_post_type(), false); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | * @param string $context View or edit context. |
631 | 631 | * @return string |
632 | 632 | */ |
633 | - public function get_label( $context = 'view' ) { |
|
634 | - return getpaid_get_post_type_label( $this->get_post_type( $context ), false ); |
|
633 | + public function get_label($context = 'view') { |
|
634 | + return getpaid_get_post_type_label($this->get_post_type($context), false); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -641,8 +641,8 @@ discard block |
||
641 | 641 | * @param string $context View or edit context. |
642 | 642 | * @return string |
643 | 643 | */ |
644 | - public function get_post_type( $context = 'view' ) { |
|
645 | - return $this->get_prop( 'post_type', $context ); |
|
644 | + public function get_post_type($context = 'view') { |
|
645 | + return $this->get_prop('post_type', $context); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | /** |
@@ -652,8 +652,8 @@ discard block |
||
652 | 652 | * @param string $context View or edit context. |
653 | 653 | * @return string |
654 | 654 | */ |
655 | - public function get_mode( $context = 'view' ) { |
|
656 | - return $this->get_prop( 'mode', $context ); |
|
655 | + public function get_mode($context = 'view') { |
|
656 | + return $this->get_prop('mode', $context); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | /** |
@@ -663,13 +663,13 @@ discard block |
||
663 | 663 | * @param string $context View or edit context. |
664 | 664 | * @return string |
665 | 665 | */ |
666 | - public function get_path( $context = 'view' ) { |
|
667 | - $path = $this->get_prop( 'path', $context ); |
|
666 | + public function get_path($context = 'view') { |
|
667 | + $path = $this->get_prop('path', $context); |
|
668 | 668 | $prefix = $this->get_type(); |
669 | 669 | |
670 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
671 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
672 | - $this->set_path( $path ); |
|
670 | + if (0 !== strpos($path, $prefix)) { |
|
671 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
672 | + $this->set_path($path); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | return $path; |
@@ -682,8 +682,8 @@ discard block |
||
682 | 682 | * @param string $context View or edit context. |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - public function get_name( $context = 'view' ) { |
|
686 | - return $this->get_prop( 'title', $context ); |
|
685 | + public function get_name($context = 'view') { |
|
686 | + return $this->get_prop('title', $context); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | * @param string $context View or edit context. |
694 | 694 | * @return string |
695 | 695 | */ |
696 | - public function get_title( $context = 'view' ) { |
|
697 | - return $this->get_name( $context ); |
|
696 | + public function get_title($context = 'view') { |
|
697 | + return $this->get_name($context); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | * @param string $context View or edit context. |
705 | 705 | * @return string |
706 | 706 | */ |
707 | - public function get_description( $context = 'view' ) { |
|
708 | - return $this->get_prop( 'description', $context ); |
|
707 | + public function get_description($context = 'view') { |
|
708 | + return $this->get_prop('description', $context); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -715,8 +715,8 @@ discard block |
||
715 | 715 | * @param string $context View or edit context. |
716 | 716 | * @return string |
717 | 717 | */ |
718 | - public function get_excerpt( $context = 'view' ) { |
|
719 | - return $this->get_description( $context ); |
|
718 | + public function get_excerpt($context = 'view') { |
|
719 | + return $this->get_description($context); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | /** |
@@ -726,8 +726,8 @@ discard block |
||
726 | 726 | * @param string $context View or edit context. |
727 | 727 | * @return string |
728 | 728 | */ |
729 | - public function get_summary( $context = 'view' ) { |
|
730 | - return $this->get_description( $context ); |
|
729 | + public function get_summary($context = 'view') { |
|
730 | + return $this->get_description($context); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | /** |
@@ -737,26 +737,26 @@ discard block |
||
737 | 737 | * @param string $context View or edit context. |
738 | 738 | * @return array |
739 | 739 | */ |
740 | - public function get_user_info( $context = 'view' ) { |
|
740 | + public function get_user_info($context = 'view') { |
|
741 | 741 | |
742 | 742 | $user_info = array( |
743 | - 'user_id' => $this->get_user_id( $context ), |
|
744 | - 'email' => $this->get_email( $context ), |
|
745 | - 'first_name' => $this->get_first_name( $context ), |
|
746 | - 'last_name' => $this->get_last_name( $context ), |
|
747 | - 'address' => $this->get_address( $context ), |
|
748 | - 'phone' => $this->get_phone( $context ), |
|
749 | - 'city' => $this->get_city( $context ), |
|
750 | - 'country' => $this->get_country( $context ), |
|
751 | - 'state' => $this->get_state( $context ), |
|
752 | - 'zip' => $this->get_zip( $context ), |
|
753 | - 'company' => $this->get_company( $context ), |
|
754 | - 'company_id' => $this->get_company_id( $context ), |
|
755 | - 'vat_number' => $this->get_vat_number( $context ), |
|
756 | - 'discount' => $this->get_discount_code( $context ), |
|
743 | + 'user_id' => $this->get_user_id($context), |
|
744 | + 'email' => $this->get_email($context), |
|
745 | + 'first_name' => $this->get_first_name($context), |
|
746 | + 'last_name' => $this->get_last_name($context), |
|
747 | + 'address' => $this->get_address($context), |
|
748 | + 'phone' => $this->get_phone($context), |
|
749 | + 'city' => $this->get_city($context), |
|
750 | + 'country' => $this->get_country($context), |
|
751 | + 'state' => $this->get_state($context), |
|
752 | + 'zip' => $this->get_zip($context), |
|
753 | + 'company' => $this->get_company($context), |
|
754 | + 'company_id' => $this->get_company_id($context), |
|
755 | + 'vat_number' => $this->get_vat_number($context), |
|
756 | + 'discount' => $this->get_discount_code($context), |
|
757 | 757 | ); |
758 | 758 | |
759 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
759 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
760 | 760 | |
761 | 761 | } |
762 | 762 | |
@@ -767,8 +767,8 @@ discard block |
||
767 | 767 | * @param string $context View or edit context. |
768 | 768 | * @return int |
769 | 769 | */ |
770 | - public function get_author( $context = 'view' ) { |
|
771 | - return (int) $this->get_prop( 'author', $context ); |
|
770 | + public function get_author($context = 'view') { |
|
771 | + return (int) $this->get_prop('author', $context); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | /** |
@@ -778,8 +778,8 @@ discard block |
||
778 | 778 | * @param string $context View or edit context. |
779 | 779 | * @return int |
780 | 780 | */ |
781 | - public function get_user_id( $context = 'view' ) { |
|
782 | - return $this->get_author( $context ); |
|
781 | + public function get_user_id($context = 'view') { |
|
782 | + return $this->get_author($context); |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | /** |
@@ -789,8 +789,8 @@ discard block |
||
789 | 789 | * @param string $context View or edit context. |
790 | 790 | * @return int |
791 | 791 | */ |
792 | - public function get_customer_id( $context = 'view' ) { |
|
793 | - return $this->get_author( $context ); |
|
792 | + public function get_customer_id($context = 'view') { |
|
793 | + return $this->get_author($context); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | * @param string $context View or edit context. |
801 | 801 | * @return string |
802 | 802 | */ |
803 | - public function get_ip( $context = 'view' ) { |
|
804 | - return $this->get_prop( 'user_ip', $context ); |
|
803 | + public function get_ip($context = 'view') { |
|
804 | + return $this->get_prop('user_ip', $context); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | * @param string $context View or edit context. |
812 | 812 | * @return string |
813 | 813 | */ |
814 | - public function get_user_ip( $context = 'view' ) { |
|
815 | - return $this->get_ip( $context ); |
|
814 | + public function get_user_ip($context = 'view') { |
|
815 | + return $this->get_ip($context); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | /** |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | * @param string $context View or edit context. |
823 | 823 | * @return string |
824 | 824 | */ |
825 | - public function get_customer_ip( $context = 'view' ) { |
|
826 | - return $this->get_ip( $context ); |
|
825 | + public function get_customer_ip($context = 'view') { |
|
826 | + return $this->get_ip($context); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
@@ -833,8 +833,8 @@ discard block |
||
833 | 833 | * @param string $context View or edit context. |
834 | 834 | * @return string |
835 | 835 | */ |
836 | - public function get_first_name( $context = 'view' ) { |
|
837 | - return $this->get_prop( 'first_name', $context ); |
|
836 | + public function get_first_name($context = 'view') { |
|
837 | + return $this->get_prop('first_name', $context); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
@@ -844,8 +844,8 @@ discard block |
||
844 | 844 | * @param string $context View or edit context. |
845 | 845 | * @return string |
846 | 846 | */ |
847 | - public function get_user_first_name( $context = 'view' ) { |
|
848 | - return $this->get_first_name( $context ); |
|
847 | + public function get_user_first_name($context = 'view') { |
|
848 | + return $this->get_first_name($context); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | /** |
@@ -855,8 +855,8 @@ discard block |
||
855 | 855 | * @param string $context View or edit context. |
856 | 856 | * @return string |
857 | 857 | */ |
858 | - public function get_customer_first_name( $context = 'view' ) { |
|
859 | - return $this->get_first_name( $context ); |
|
858 | + public function get_customer_first_name($context = 'view') { |
|
859 | + return $this->get_first_name($context); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | /** |
@@ -866,8 +866,8 @@ discard block |
||
866 | 866 | * @param string $context View or edit context. |
867 | 867 | * @return string |
868 | 868 | */ |
869 | - public function get_last_name( $context = 'view' ) { |
|
870 | - return $this->get_prop( 'last_name', $context ); |
|
869 | + public function get_last_name($context = 'view') { |
|
870 | + return $this->get_prop('last_name', $context); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
@@ -877,8 +877,8 @@ discard block |
||
877 | 877 | * @param string $context View or edit context. |
878 | 878 | * @return string |
879 | 879 | */ |
880 | - public function get_user_last_name( $context = 'view' ) { |
|
881 | - return $this->get_last_name( $context ); |
|
880 | + public function get_user_last_name($context = 'view') { |
|
881 | + return $this->get_last_name($context); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
@@ -888,8 +888,8 @@ discard block |
||
888 | 888 | * @param string $context View or edit context. |
889 | 889 | * @return string |
890 | 890 | */ |
891 | - public function get_customer_last_name( $context = 'view' ) { |
|
892 | - return $this->get_last_name( $context ); |
|
891 | + public function get_customer_last_name($context = 'view') { |
|
892 | + return $this->get_last_name($context); |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | /** |
@@ -899,22 +899,22 @@ discard block |
||
899 | 899 | * @param string $context View or edit context. |
900 | 900 | * @return string |
901 | 901 | */ |
902 | - public function get_full_name( $context = 'view' ) { |
|
903 | - $name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
902 | + public function get_full_name($context = 'view') { |
|
903 | + $name = trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
904 | 904 | |
905 | - if ( ! $name ) { |
|
906 | - $user = get_userdata( $this->get_author( $context ) ); |
|
905 | + if (!$name) { |
|
906 | + $user = get_userdata($this->get_author($context)); |
|
907 | 907 | |
908 | - if ( $user ) { |
|
908 | + if ($user) { |
|
909 | 909 | $name = $user->display_name; |
910 | 910 | } |
911 | 911 | } |
912 | 912 | |
913 | - if ( ! $name ) { |
|
914 | - $name = $this->get_email( $context ); |
|
913 | + if (!$name) { |
|
914 | + $name = $this->get_email($context); |
|
915 | 915 | } |
916 | 916 | |
917 | - return apply_filters( 'wpinv_invoice_user_full_name', $name, $this ); |
|
917 | + return apply_filters('wpinv_invoice_user_full_name', $name, $this); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | /** |
@@ -924,8 +924,8 @@ discard block |
||
924 | 924 | * @param string $context View or edit context. |
925 | 925 | * @return string |
926 | 926 | */ |
927 | - public function get_user_full_name( $context = 'view' ) { |
|
928 | - return $this->get_full_name( $context ); |
|
927 | + public function get_user_full_name($context = 'view') { |
|
928 | + return $this->get_full_name($context); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
@@ -935,8 +935,8 @@ discard block |
||
935 | 935 | * @param string $context View or edit context. |
936 | 936 | * @return string |
937 | 937 | */ |
938 | - public function get_customer_full_name( $context = 'view' ) { |
|
939 | - return $this->get_full_name( $context ); |
|
938 | + public function get_customer_full_name($context = 'view') { |
|
939 | + return $this->get_full_name($context); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | * @param string $context View or edit context. |
947 | 947 | * @return string |
948 | 948 | */ |
949 | - public function get_phone( $context = 'view' ) { |
|
950 | - return $this->get_prop( 'phone', $context ); |
|
949 | + public function get_phone($context = 'view') { |
|
950 | + return $this->get_prop('phone', $context); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | /** |
@@ -957,8 +957,8 @@ discard block |
||
957 | 957 | * @param string $context View or edit context. |
958 | 958 | * @return string |
959 | 959 | */ |
960 | - public function get_phone_number( $context = 'view' ) { |
|
961 | - return $this->get_phone( $context ); |
|
960 | + public function get_phone_number($context = 'view') { |
|
961 | + return $this->get_phone($context); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -968,8 +968,8 @@ discard block |
||
968 | 968 | * @param string $context View or edit context. |
969 | 969 | * @return string |
970 | 970 | */ |
971 | - public function get_user_phone( $context = 'view' ) { |
|
972 | - return $this->get_phone( $context ); |
|
971 | + public function get_user_phone($context = 'view') { |
|
972 | + return $this->get_phone($context); |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | /** |
@@ -979,8 +979,8 @@ discard block |
||
979 | 979 | * @param string $context View or edit context. |
980 | 980 | * @return string |
981 | 981 | */ |
982 | - public function get_customer_phone( $context = 'view' ) { |
|
983 | - return $this->get_phone( $context ); |
|
982 | + public function get_customer_phone($context = 'view') { |
|
983 | + return $this->get_phone($context); |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | /** |
@@ -990,8 +990,8 @@ discard block |
||
990 | 990 | * @param string $context View or edit context. |
991 | 991 | * @return string |
992 | 992 | */ |
993 | - public function get_email( $context = 'view' ) { |
|
994 | - return $this->get_prop( 'email', $context ); |
|
993 | + public function get_email($context = 'view') { |
|
994 | + return $this->get_prop('email', $context); |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | /** |
@@ -1001,8 +1001,8 @@ discard block |
||
1001 | 1001 | * @param string $context View or edit context. |
1002 | 1002 | * @return string |
1003 | 1003 | */ |
1004 | - public function get_email_address( $context = 'view' ) { |
|
1005 | - return $this->get_email( $context ); |
|
1004 | + public function get_email_address($context = 'view') { |
|
1005 | + return $this->get_email($context); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | /** |
@@ -1012,8 +1012,8 @@ discard block |
||
1012 | 1012 | * @param string $context View or edit context. |
1013 | 1013 | * @return string |
1014 | 1014 | */ |
1015 | - public function get_user_email( $context = 'view' ) { |
|
1016 | - return $this->get_email( $context ); |
|
1015 | + public function get_user_email($context = 'view') { |
|
1016 | + return $this->get_email($context); |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | /** |
@@ -1023,8 +1023,8 @@ discard block |
||
1023 | 1023 | * @param string $context View or edit context. |
1024 | 1024 | * @return string |
1025 | 1025 | */ |
1026 | - public function get_customer_email( $context = 'view' ) { |
|
1027 | - return $this->get_email( $context ); |
|
1026 | + public function get_customer_email($context = 'view') { |
|
1027 | + return $this->get_email($context); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | /** |
@@ -1034,9 +1034,9 @@ discard block |
||
1034 | 1034 | * @param string $context View or edit context. |
1035 | 1035 | * @return string |
1036 | 1036 | */ |
1037 | - public function get_country( $context = 'view' ) { |
|
1038 | - $country = $this->get_prop( 'country', $context ); |
|
1039 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
1037 | + public function get_country($context = 'view') { |
|
1038 | + $country = $this->get_prop('country', $context); |
|
1039 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | /** |
@@ -1046,8 +1046,8 @@ discard block |
||
1046 | 1046 | * @param string $context View or edit context. |
1047 | 1047 | * @return string |
1048 | 1048 | */ |
1049 | - public function get_user_country( $context = 'view' ) { |
|
1050 | - return $this->get_country( $context ); |
|
1049 | + public function get_user_country($context = 'view') { |
|
1050 | + return $this->get_country($context); |
|
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | /** |
@@ -1057,8 +1057,8 @@ discard block |
||
1057 | 1057 | * @param string $context View or edit context. |
1058 | 1058 | * @return string |
1059 | 1059 | */ |
1060 | - public function get_customer_country( $context = 'view' ) { |
|
1061 | - return $this->get_country( $context ); |
|
1060 | + public function get_customer_country($context = 'view') { |
|
1061 | + return $this->get_country($context); |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | /** |
@@ -1068,9 +1068,9 @@ discard block |
||
1068 | 1068 | * @param string $context View or edit context. |
1069 | 1069 | * @return string |
1070 | 1070 | */ |
1071 | - public function get_state( $context = 'view' ) { |
|
1072 | - $state = $this->get_prop( 'state', $context ); |
|
1073 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1071 | + public function get_state($context = 'view') { |
|
1072 | + $state = $this->get_prop('state', $context); |
|
1073 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | /** |
@@ -1080,8 +1080,8 @@ discard block |
||
1080 | 1080 | * @param string $context View or edit context. |
1081 | 1081 | * @return string |
1082 | 1082 | */ |
1083 | - public function get_user_state( $context = 'view' ) { |
|
1084 | - return $this->get_state( $context ); |
|
1083 | + public function get_user_state($context = 'view') { |
|
1084 | + return $this->get_state($context); |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | /** |
@@ -1091,8 +1091,8 @@ discard block |
||
1091 | 1091 | * @param string $context View or edit context. |
1092 | 1092 | * @return string |
1093 | 1093 | */ |
1094 | - public function get_customer_state( $context = 'view' ) { |
|
1095 | - return $this->get_state( $context ); |
|
1094 | + public function get_customer_state($context = 'view') { |
|
1095 | + return $this->get_state($context); |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | /** |
@@ -1102,8 +1102,8 @@ discard block |
||
1102 | 1102 | * @param string $context View or edit context. |
1103 | 1103 | * @return string |
1104 | 1104 | */ |
1105 | - public function get_city( $context = 'view' ) { |
|
1106 | - return $this->get_prop( 'city', $context ); |
|
1105 | + public function get_city($context = 'view') { |
|
1106 | + return $this->get_prop('city', $context); |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | /** |
@@ -1113,8 +1113,8 @@ discard block |
||
1113 | 1113 | * @param string $context View or edit context. |
1114 | 1114 | * @return string |
1115 | 1115 | */ |
1116 | - public function get_user_city( $context = 'view' ) { |
|
1117 | - return $this->get_city( $context ); |
|
1116 | + public function get_user_city($context = 'view') { |
|
1117 | + return $this->get_city($context); |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | /** |
@@ -1124,8 +1124,8 @@ discard block |
||
1124 | 1124 | * @param string $context View or edit context. |
1125 | 1125 | * @return string |
1126 | 1126 | */ |
1127 | - public function get_customer_city( $context = 'view' ) { |
|
1128 | - return $this->get_city( $context ); |
|
1127 | + public function get_customer_city($context = 'view') { |
|
1128 | + return $this->get_city($context); |
|
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | /** |
@@ -1135,8 +1135,8 @@ discard block |
||
1135 | 1135 | * @param string $context View or edit context. |
1136 | 1136 | * @return string |
1137 | 1137 | */ |
1138 | - public function get_zip( $context = 'view' ) { |
|
1139 | - return $this->get_prop( 'zip', $context ); |
|
1138 | + public function get_zip($context = 'view') { |
|
1139 | + return $this->get_prop('zip', $context); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | /** |
@@ -1146,8 +1146,8 @@ discard block |
||
1146 | 1146 | * @param string $context View or edit context. |
1147 | 1147 | * @return string |
1148 | 1148 | */ |
1149 | - public function get_user_zip( $context = 'view' ) { |
|
1150 | - return $this->get_zip( $context ); |
|
1149 | + public function get_user_zip($context = 'view') { |
|
1150 | + return $this->get_zip($context); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1157,8 +1157,8 @@ discard block |
||
1157 | 1157 | * @param string $context View or edit context. |
1158 | 1158 | * @return string |
1159 | 1159 | */ |
1160 | - public function get_customer_zip( $context = 'view' ) { |
|
1161 | - return $this->get_zip( $context ); |
|
1160 | + public function get_customer_zip($context = 'view') { |
|
1161 | + return $this->get_zip($context); |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | /** |
@@ -1168,8 +1168,8 @@ discard block |
||
1168 | 1168 | * @param string $context View or edit context. |
1169 | 1169 | * @return string |
1170 | 1170 | */ |
1171 | - public function get_company( $context = 'view' ) { |
|
1172 | - return $this->get_prop( 'company', $context ); |
|
1171 | + public function get_company($context = 'view') { |
|
1172 | + return $this->get_prop('company', $context); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | /** |
@@ -1179,8 +1179,8 @@ discard block |
||
1179 | 1179 | * @param string $context View or edit context. |
1180 | 1180 | * @return string |
1181 | 1181 | */ |
1182 | - public function get_user_company( $context = 'view' ) { |
|
1183 | - return $this->get_company( $context ); |
|
1182 | + public function get_user_company($context = 'view') { |
|
1183 | + return $this->get_company($context); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | /** |
@@ -1190,8 +1190,8 @@ discard block |
||
1190 | 1190 | * @param string $context View or edit context. |
1191 | 1191 | * @return string |
1192 | 1192 | */ |
1193 | - public function get_customer_company( $context = 'view' ) { |
|
1194 | - return $this->get_company( $context ); |
|
1193 | + public function get_customer_company($context = 'view') { |
|
1194 | + return $this->get_company($context); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | /** |
@@ -1201,8 +1201,8 @@ discard block |
||
1201 | 1201 | * @param string $context View or edit context. |
1202 | 1202 | * @return string |
1203 | 1203 | */ |
1204 | - public function get_company_id( $context = 'view' ) { |
|
1205 | - return $this->get_prop( 'company_id', $context ); |
|
1204 | + public function get_company_id($context = 'view') { |
|
1205 | + return $this->get_prop('company_id', $context); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | /** |
@@ -1212,8 +1212,8 @@ discard block |
||
1212 | 1212 | * @param string $context View or edit context. |
1213 | 1213 | * @return string |
1214 | 1214 | */ |
1215 | - public function get_vat_number( $context = 'view' ) { |
|
1216 | - return $this->get_prop( 'vat_number', $context ); |
|
1215 | + public function get_vat_number($context = 'view') { |
|
1216 | + return $this->get_prop('vat_number', $context); |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | /** |
@@ -1223,8 +1223,8 @@ discard block |
||
1223 | 1223 | * @param string $context View or edit context. |
1224 | 1224 | * @return string |
1225 | 1225 | */ |
1226 | - public function get_user_vat_number( $context = 'view' ) { |
|
1227 | - return $this->get_vat_number( $context ); |
|
1226 | + public function get_user_vat_number($context = 'view') { |
|
1227 | + return $this->get_vat_number($context); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | /** |
@@ -1234,8 +1234,8 @@ discard block |
||
1234 | 1234 | * @param string $context View or edit context. |
1235 | 1235 | * @return string |
1236 | 1236 | */ |
1237 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1238 | - return $this->get_vat_number( $context ); |
|
1237 | + public function get_customer_vat_number($context = 'view') { |
|
1238 | + return $this->get_vat_number($context); |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | /** |
@@ -1245,8 +1245,8 @@ discard block |
||
1245 | 1245 | * @param string $context View or edit context. |
1246 | 1246 | * @return string |
1247 | 1247 | */ |
1248 | - public function get_vat_rate( $context = 'view' ) { |
|
1249 | - return $this->get_prop( 'vat_rate', $context ); |
|
1248 | + public function get_vat_rate($context = 'view') { |
|
1249 | + return $this->get_prop('vat_rate', $context); |
|
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | /** |
@@ -1256,8 +1256,8 @@ discard block |
||
1256 | 1256 | * @param string $context View or edit context. |
1257 | 1257 | * @return string |
1258 | 1258 | */ |
1259 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1260 | - return $this->get_vat_rate( $context ); |
|
1259 | + public function get_user_vat_rate($context = 'view') { |
|
1260 | + return $this->get_vat_rate($context); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | /** |
@@ -1267,8 +1267,8 @@ discard block |
||
1267 | 1267 | * @param string $context View or edit context. |
1268 | 1268 | * @return string |
1269 | 1269 | */ |
1270 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1271 | - return $this->get_vat_rate( $context ); |
|
1270 | + public function get_customer_vat_rate($context = 'view') { |
|
1271 | + return $this->get_vat_rate($context); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | /** |
@@ -1278,8 +1278,8 @@ discard block |
||
1278 | 1278 | * @param string $context View or edit context. |
1279 | 1279 | * @return string |
1280 | 1280 | */ |
1281 | - public function get_address( $context = 'view' ) { |
|
1282 | - return $this->get_prop( 'address', $context ); |
|
1281 | + public function get_address($context = 'view') { |
|
1282 | + return $this->get_prop('address', $context); |
|
1283 | 1283 | } |
1284 | 1284 | |
1285 | 1285 | /** |
@@ -1289,8 +1289,8 @@ discard block |
||
1289 | 1289 | * @param string $context View or edit context. |
1290 | 1290 | * @return string |
1291 | 1291 | */ |
1292 | - public function get_user_address( $context = 'view' ) { |
|
1293 | - return $this->get_address( $context ); |
|
1292 | + public function get_user_address($context = 'view') { |
|
1293 | + return $this->get_address($context); |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | /** |
@@ -1300,8 +1300,8 @@ discard block |
||
1300 | 1300 | * @param string $context View or edit context. |
1301 | 1301 | * @return string |
1302 | 1302 | */ |
1303 | - public function get_customer_address( $context = 'view' ) { |
|
1304 | - return $this->get_address( $context ); |
|
1303 | + public function get_customer_address($context = 'view') { |
|
1304 | + return $this->get_address($context); |
|
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | /** |
@@ -1311,8 +1311,8 @@ discard block |
||
1311 | 1311 | * @param string $context View or edit context. |
1312 | 1312 | * @return bool |
1313 | 1313 | */ |
1314 | - public function get_is_viewed( $context = 'view' ) { |
|
1315 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1314 | + public function get_is_viewed($context = 'view') { |
|
1315 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | /** |
@@ -1322,8 +1322,8 @@ discard block |
||
1322 | 1322 | * @param string $context View or edit context. |
1323 | 1323 | * @return bool |
1324 | 1324 | */ |
1325 | - public function get_email_cc( $context = 'view' ) { |
|
1326 | - return $this->get_prop( 'email_cc', $context ); |
|
1325 | + public function get_email_cc($context = 'view') { |
|
1326 | + return $this->get_prop('email_cc', $context); |
|
1327 | 1327 | } |
1328 | 1328 | |
1329 | 1329 | /** |
@@ -1333,8 +1333,8 @@ discard block |
||
1333 | 1333 | * @param string $context View or edit context. |
1334 | 1334 | * @return bool |
1335 | 1335 | */ |
1336 | - public function get_template( $context = 'view' ) { |
|
1337 | - return $this->get_prop( 'template', $context ); |
|
1336 | + public function get_template($context = 'view') { |
|
1337 | + return $this->get_prop('template', $context); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | /** |
@@ -1344,8 +1344,8 @@ discard block |
||
1344 | 1344 | * @param string $context View or edit context. |
1345 | 1345 | * @return bool |
1346 | 1346 | */ |
1347 | - public function get_created_via( $context = 'view' ) { |
|
1348 | - return $this->get_prop( 'created_via', $context ); |
|
1347 | + public function get_created_via($context = 'view') { |
|
1348 | + return $this->get_prop('created_via', $context); |
|
1349 | 1349 | } |
1350 | 1350 | |
1351 | 1351 | /** |
@@ -1355,8 +1355,8 @@ discard block |
||
1355 | 1355 | * @param string $context View or edit context. |
1356 | 1356 | * @return bool |
1357 | 1357 | */ |
1358 | - public function get_address_confirmed( $context = 'view' ) { |
|
1359 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1358 | + public function get_address_confirmed($context = 'view') { |
|
1359 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | /** |
@@ -1366,8 +1366,8 @@ discard block |
||
1366 | 1366 | * @param string $context View or edit context. |
1367 | 1367 | * @return bool |
1368 | 1368 | */ |
1369 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1370 | - return $this->get_address_confirmed( $context ); |
|
1369 | + public function get_user_address_confirmed($context = 'view') { |
|
1370 | + return $this->get_address_confirmed($context); |
|
1371 | 1371 | } |
1372 | 1372 | |
1373 | 1373 | /** |
@@ -1377,8 +1377,8 @@ discard block |
||
1377 | 1377 | * @param string $context View or edit context. |
1378 | 1378 | * @return bool |
1379 | 1379 | */ |
1380 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1381 | - return $this->get_address_confirmed( $context ); |
|
1380 | + public function get_customer_address_confirmed($context = 'view') { |
|
1381 | + return $this->get_address_confirmed($context); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | /** |
@@ -1389,8 +1389,8 @@ discard block |
||
1389 | 1389 | */ |
1390 | 1390 | public function get_shipping_address() { |
1391 | 1391 | |
1392 | - $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true ); |
|
1393 | - return is_array( $shipping_address ) ? $shipping_address : false; |
|
1392 | + $shipping_address = get_post_meta($this->get_id(), 'shipping_address', true); |
|
1393 | + return is_array($shipping_address) ? $shipping_address : false; |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | /** |
@@ -1407,17 +1407,17 @@ discard block |
||
1407 | 1407 | * @param string $context View or edit context. |
1408 | 1408 | * @return float |
1409 | 1409 | */ |
1410 | - public function get_shipping( $context = 'view' ) { |
|
1410 | + public function get_shipping($context = 'view') { |
|
1411 | 1411 | |
1412 | - if ( $context = 'view' ) { |
|
1413 | - return floatval( $this->get_prop( 'shipping', $context ) ); |
|
1412 | + if ($context = 'view') { |
|
1413 | + return floatval($this->get_prop('shipping', $context)); |
|
1414 | 1414 | } |
1415 | 1415 | |
1416 | - return $this->get_prop( 'shipping', $context ); |
|
1416 | + return $this->get_prop('shipping', $context); |
|
1417 | 1417 | } |
1418 | 1418 | |
1419 | 1419 | public function has_shipping() { |
1420 | - return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' ); |
|
1420 | + return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && null !== $this->get_prop('shipping', 'edit'); |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | /** |
@@ -1427,12 +1427,12 @@ discard block |
||
1427 | 1427 | * @param string $context View or edit context. |
1428 | 1428 | * @return float |
1429 | 1429 | */ |
1430 | - public function get_subtotal( $context = 'view' ) { |
|
1431 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1430 | + public function get_subtotal($context = 'view') { |
|
1431 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1432 | 1432 | |
1433 | 1433 | // Backwards compatibility. |
1434 | - if ( is_bool( $context ) && $context ) { |
|
1435 | - return wpinv_price( $subtotal, $this->get_currency() ); |
|
1434 | + if (is_bool($context) && $context) { |
|
1435 | + return wpinv_price($subtotal, $this->get_currency()); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | 1438 | return $subtotal; |
@@ -1445,8 +1445,8 @@ discard block |
||
1445 | 1445 | * @param string $context View or edit context. |
1446 | 1446 | * @return float |
1447 | 1447 | */ |
1448 | - public function get_total_discount( $context = 'view' ) { |
|
1449 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
1448 | + public function get_total_discount($context = 'view') { |
|
1449 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context))); |
|
1450 | 1450 | } |
1451 | 1451 | |
1452 | 1452 | /** |
@@ -1456,18 +1456,18 @@ discard block |
||
1456 | 1456 | * @param string $context View or edit context. |
1457 | 1457 | * @return float |
1458 | 1458 | */ |
1459 | - public function get_total_tax( $context = 'view' ) { |
|
1460 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
1459 | + public function get_total_tax($context = 'view') { |
|
1460 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context))); |
|
1461 | 1461 | } |
1462 | 1462 | |
1463 | 1463 | /** |
1464 | 1464 | * @deprecated |
1465 | 1465 | */ |
1466 | - public function get_final_tax( $currency = false ) { |
|
1466 | + public function get_final_tax($currency = false) { |
|
1467 | 1467 | $tax = $this->get_total_tax(); |
1468 | 1468 | |
1469 | - if ( $currency ) { |
|
1470 | - return wpinv_price( $tax, $this->get_currency() ); |
|
1469 | + if ($currency) { |
|
1470 | + return wpinv_price($tax, $this->get_currency()); |
|
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | return $tax; |
@@ -1480,8 +1480,8 @@ discard block |
||
1480 | 1480 | * @param string $context View or edit context. |
1481 | 1481 | * @return float |
1482 | 1482 | */ |
1483 | - public function get_total_fees( $context = 'view' ) { |
|
1484 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
1483 | + public function get_total_fees($context = 'view') { |
|
1484 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context))); |
|
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | /** |
@@ -1491,8 +1491,8 @@ discard block |
||
1491 | 1491 | * @param string $context View or edit context. |
1492 | 1492 | * @return float |
1493 | 1493 | */ |
1494 | - public function get_fees_total( $context = 'view' ) { |
|
1495 | - return $this->get_total_fees( $context ); |
|
1494 | + public function get_fees_total($context = 'view') { |
|
1495 | + return $this->get_total_fees($context); |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | /** |
@@ -1501,14 +1501,14 @@ discard block |
||
1501 | 1501 | * @since 1.0.19 |
1502 | 1502 | * @return float |
1503 | 1503 | */ |
1504 | - public function get_total( $context = 'view' ) { |
|
1505 | - $total = $this->get_prop( 'total', $context ); |
|
1504 | + public function get_total($context = 'view') { |
|
1505 | + $total = $this->get_prop('total', $context); |
|
1506 | 1506 | |
1507 | - if ( $this->has_shipping() && $context == 'view' ) { |
|
1508 | - $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context ); |
|
1507 | + if ($this->has_shipping() && $context == 'view') { |
|
1508 | + $total = $this->get_prop('total', $context) + $this->get_shipping($context); |
|
1509 | 1509 | } |
1510 | 1510 | |
1511 | - return wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1511 | + return wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1512 | 1512 | } |
1513 | 1513 | |
1514 | 1514 | /** |
@@ -1520,20 +1520,20 @@ discard block |
||
1520 | 1520 | public function get_non_recurring_total() { |
1521 | 1521 | |
1522 | 1522 | $subtotal = 0; |
1523 | - foreach ( $this->get_items() as $item ) { |
|
1524 | - if ( ! $item->is_recurring() ) { |
|
1523 | + foreach ($this->get_items() as $item) { |
|
1524 | + if (!$item->is_recurring()) { |
|
1525 | 1525 | $subtotal += $item->get_sub_total(); |
1526 | 1526 | } |
1527 | 1527 | } |
1528 | 1528 | |
1529 | - foreach ( $this->get_fees() as $fee ) { |
|
1530 | - if ( empty( $fee['recurring_fee'] ) ) { |
|
1531 | - $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
1529 | + foreach ($this->get_fees() as $fee) { |
|
1530 | + if (empty($fee['recurring_fee'])) { |
|
1531 | + $subtotal += wpinv_sanitize_amount($fee['initial_fee']); |
|
1532 | 1532 | } |
1533 | 1533 | } |
1534 | 1534 | |
1535 | - $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
1536 | - return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this ); |
|
1535 | + $subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal)); |
|
1536 | + return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this); |
|
1537 | 1537 | |
1538 | 1538 | } |
1539 | 1539 | |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | */ |
1557 | 1557 | public function get_initial_total() { |
1558 | 1558 | |
1559 | - if ( empty( $this->totals ) ) { |
|
1559 | + if (empty($this->totals)) { |
|
1560 | 1560 | $this->recalculate_total(); |
1561 | 1561 | } |
1562 | 1562 | |
@@ -1566,12 +1566,12 @@ discard block |
||
1566 | 1566 | $subtotal = $this->totals['subtotal']['initial']; |
1567 | 1567 | $total = $tax + $fee - $discount + $subtotal; |
1568 | 1568 | |
1569 | - if ( 0 > $total ) { |
|
1569 | + if (0 > $total) { |
|
1570 | 1570 | $total = 0; |
1571 | 1571 | } |
1572 | 1572 | |
1573 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1574 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1573 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1574 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | /** |
@@ -1583,7 +1583,7 @@ discard block |
||
1583 | 1583 | */ |
1584 | 1584 | public function get_recurring_total() { |
1585 | 1585 | |
1586 | - if ( empty( $this->totals ) ) { |
|
1586 | + if (empty($this->totals)) { |
|
1587 | 1587 | $this->recalculate_total(); |
1588 | 1588 | } |
1589 | 1589 | |
@@ -1593,12 +1593,12 @@ discard block |
||
1593 | 1593 | $subtotal = $this->totals['subtotal']['recurring']; |
1594 | 1594 | $total = $tax + $fee - $discount + $subtotal; |
1595 | 1595 | |
1596 | - if ( 0 > $total ) { |
|
1596 | + if (0 > $total) { |
|
1597 | 1597 | $total = 0; |
1598 | 1598 | } |
1599 | 1599 | |
1600 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1601 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1600 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1601 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | 1604 | /** |
@@ -1609,10 +1609,10 @@ discard block |
||
1609 | 1609 | * @param string $currency Whether to include the currency. |
1610 | 1610 | * @return float|string |
1611 | 1611 | */ |
1612 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1612 | + public function get_recurring_details($field = '', $currency = false) { |
|
1613 | 1613 | |
1614 | 1614 | // Maybe recalculate totals. |
1615 | - if ( empty( $this->totals ) ) { |
|
1615 | + if (empty($this->totals)) { |
|
1616 | 1616 | $this->recalculate_total(); |
1617 | 1617 | } |
1618 | 1618 | |
@@ -1632,8 +1632,8 @@ discard block |
||
1632 | 1632 | $currency |
1633 | 1633 | ); |
1634 | 1634 | |
1635 | - if ( isset( $data[$field] ) ) { |
|
1636 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1635 | + if (isset($data[$field])) { |
|
1636 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1637 | 1637 | } |
1638 | 1638 | |
1639 | 1639 | return $data; |
@@ -1646,8 +1646,8 @@ discard block |
||
1646 | 1646 | * @param string $context View or edit context. |
1647 | 1647 | * @return array |
1648 | 1648 | */ |
1649 | - public function get_fees( $context = 'view' ) { |
|
1650 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1649 | + public function get_fees($context = 'view') { |
|
1650 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1651 | 1651 | } |
1652 | 1652 | |
1653 | 1653 | /** |
@@ -1657,8 +1657,8 @@ discard block |
||
1657 | 1657 | * @param string $context View or edit context. |
1658 | 1658 | * @return array |
1659 | 1659 | */ |
1660 | - public function get_discounts( $context = 'view' ) { |
|
1661 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1660 | + public function get_discounts($context = 'view') { |
|
1661 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1662 | 1662 | } |
1663 | 1663 | |
1664 | 1664 | /** |
@@ -1668,8 +1668,8 @@ discard block |
||
1668 | 1668 | * @param string $context View or edit context. |
1669 | 1669 | * @return array |
1670 | 1670 | */ |
1671 | - public function get_taxes( $context = 'view' ) { |
|
1672 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1671 | + public function get_taxes($context = 'view') { |
|
1672 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | /** |
@@ -1679,8 +1679,8 @@ discard block |
||
1679 | 1679 | * @param string $context View or edit context. |
1680 | 1680 | * @return GetPaid_Form_Item[] |
1681 | 1681 | */ |
1682 | - public function get_items( $context = 'view' ) { |
|
1683 | - return $this->get_prop( 'items', $context ); |
|
1682 | + public function get_items($context = 'view') { |
|
1683 | + return $this->get_prop('items', $context); |
|
1684 | 1684 | } |
1685 | 1685 | |
1686 | 1686 | /** |
@@ -1690,7 +1690,7 @@ discard block |
||
1690 | 1690 | * @return string |
1691 | 1691 | */ |
1692 | 1692 | public function get_item_ids() { |
1693 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
1693 | + return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id')); |
|
1694 | 1694 | } |
1695 | 1695 | |
1696 | 1696 | /** |
@@ -1700,8 +1700,8 @@ discard block |
||
1700 | 1700 | * @param string $context View or edit context. |
1701 | 1701 | * @return int |
1702 | 1702 | */ |
1703 | - public function get_payment_form( $context = 'view' ) { |
|
1704 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1703 | + public function get_payment_form($context = 'view') { |
|
1704 | + return intval($this->get_prop('payment_form', $context)); |
|
1705 | 1705 | } |
1706 | 1706 | |
1707 | 1707 | /** |
@@ -1711,8 +1711,8 @@ discard block |
||
1711 | 1711 | * @param string $context View or edit context. |
1712 | 1712 | * @return string |
1713 | 1713 | */ |
1714 | - public function get_submission_id( $context = 'view' ) { |
|
1715 | - return $this->get_prop( 'submission_id', $context ); |
|
1714 | + public function get_submission_id($context = 'view') { |
|
1715 | + return $this->get_prop('submission_id', $context); |
|
1716 | 1716 | } |
1717 | 1717 | |
1718 | 1718 | /** |
@@ -1722,8 +1722,8 @@ discard block |
||
1722 | 1722 | * @param string $context View or edit context. |
1723 | 1723 | * @return string |
1724 | 1724 | */ |
1725 | - public function get_discount_code( $context = 'view' ) { |
|
1726 | - return $this->get_prop( 'discount_code', $context ); |
|
1725 | + public function get_discount_code($context = 'view') { |
|
1726 | + return $this->get_prop('discount_code', $context); |
|
1727 | 1727 | } |
1728 | 1728 | |
1729 | 1729 | /** |
@@ -1733,8 +1733,8 @@ discard block |
||
1733 | 1733 | * @param string $context View or edit context. |
1734 | 1734 | * @return string |
1735 | 1735 | */ |
1736 | - public function get_gateway( $context = 'view' ) { |
|
1737 | - return $this->get_prop( 'gateway', $context ); |
|
1736 | + public function get_gateway($context = 'view') { |
|
1737 | + return $this->get_prop('gateway', $context); |
|
1738 | 1738 | } |
1739 | 1739 | |
1740 | 1740 | /** |
@@ -1744,8 +1744,8 @@ discard block |
||
1744 | 1744 | * @return string |
1745 | 1745 | */ |
1746 | 1746 | public function get_gateway_title() { |
1747 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1748 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1747 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1748 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | /** |
@@ -1755,8 +1755,8 @@ discard block |
||
1755 | 1755 | * @param string $context View or edit context. |
1756 | 1756 | * @return string |
1757 | 1757 | */ |
1758 | - public function get_transaction_id( $context = 'view' ) { |
|
1759 | - return $this->get_prop( 'transaction_id', $context ); |
|
1758 | + public function get_transaction_id($context = 'view') { |
|
1759 | + return $this->get_prop('transaction_id', $context); |
|
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | /** |
@@ -1766,9 +1766,9 @@ discard block |
||
1766 | 1766 | * @param string $context View or edit context. |
1767 | 1767 | * @return string |
1768 | 1768 | */ |
1769 | - public function get_currency( $context = 'view' ) { |
|
1770 | - $currency = $this->get_prop( 'currency', $context ); |
|
1771 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1769 | + public function get_currency($context = 'view') { |
|
1770 | + $currency = $this->get_prop('currency', $context); |
|
1771 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1772 | 1772 | } |
1773 | 1773 | |
1774 | 1774 | /** |
@@ -1778,8 +1778,8 @@ discard block |
||
1778 | 1778 | * @param string $context View or edit context. |
1779 | 1779 | * @return bool |
1780 | 1780 | */ |
1781 | - public function get_disable_taxes( $context = 'view' ) { |
|
1782 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1781 | + public function get_disable_taxes($context = 'view') { |
|
1782 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1783 | 1783 | } |
1784 | 1784 | |
1785 | 1785 | /** |
@@ -1789,8 +1789,8 @@ discard block |
||
1789 | 1789 | * @param string $context View or edit context. |
1790 | 1790 | * @return int |
1791 | 1791 | */ |
1792 | - public function get_subscription_id( $context = 'view' ) { |
|
1793 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1792 | + public function get_subscription_id($context = 'view') { |
|
1793 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1794 | 1794 | } |
1795 | 1795 | |
1796 | 1796 | /** |
@@ -1800,12 +1800,12 @@ discard block |
||
1800 | 1800 | * @param string $context View or edit context. |
1801 | 1801 | * @return int |
1802 | 1802 | */ |
1803 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1804 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1803 | + public function get_remote_subscription_id($context = 'view') { |
|
1804 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1805 | 1805 | |
1806 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1806 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1807 | 1807 | $parent = $this->get_parent(); |
1808 | - return $parent->get_remote_subscription_id( $context ); |
|
1808 | + return $parent->get_remote_subscription_id($context); |
|
1809 | 1809 | } |
1810 | 1810 | |
1811 | 1811 | return $subscription_id; |
@@ -1818,20 +1818,20 @@ discard block |
||
1818 | 1818 | * @param string $context View or edit context. |
1819 | 1819 | * @return array |
1820 | 1820 | */ |
1821 | - public function get_payment_meta( $context = 'view' ) { |
|
1821 | + public function get_payment_meta($context = 'view') { |
|
1822 | 1822 | |
1823 | 1823 | return array( |
1824 | - 'price' => $this->get_total( $context ), |
|
1825 | - 'date' => $this->get_date_created( $context ), |
|
1826 | - 'user_email' => $this->get_email( $context ), |
|
1827 | - 'invoice_key' => $this->get_key( $context ), |
|
1828 | - 'currency' => $this->get_currency( $context ), |
|
1829 | - 'items' => $this->get_items( $context ), |
|
1830 | - 'user_info' => $this->get_user_info( $context ), |
|
1824 | + 'price' => $this->get_total($context), |
|
1825 | + 'date' => $this->get_date_created($context), |
|
1826 | + 'user_email' => $this->get_email($context), |
|
1827 | + 'invoice_key' => $this->get_key($context), |
|
1828 | + 'currency' => $this->get_currency($context), |
|
1829 | + 'items' => $this->get_items($context), |
|
1830 | + 'user_info' => $this->get_user_info($context), |
|
1831 | 1831 | 'cart_details' => $this->get_cart_details(), |
1832 | - 'status' => $this->get_status( $context ), |
|
1833 | - 'fees' => $this->get_fees( $context ), |
|
1834 | - 'taxes' => $this->get_taxes( $context ), |
|
1832 | + 'status' => $this->get_status($context), |
|
1833 | + 'fees' => $this->get_fees($context), |
|
1834 | + 'taxes' => $this->get_taxes($context), |
|
1835 | 1835 | ); |
1836 | 1836 | |
1837 | 1837 | } |
@@ -1846,9 +1846,9 @@ discard block |
||
1846 | 1846 | $items = $this->get_items(); |
1847 | 1847 | $cart_details = array(); |
1848 | 1848 | |
1849 | - foreach ( $items as $item ) { |
|
1849 | + foreach ($items as $item) { |
|
1850 | 1850 | $item->invoice_id = $this->get_id(); |
1851 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1851 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1852 | 1852 | } |
1853 | 1853 | |
1854 | 1854 | return $cart_details; |
@@ -1859,11 +1859,11 @@ discard block |
||
1859 | 1859 | * |
1860 | 1860 | * @return null|GetPaid_Form_Item|int |
1861 | 1861 | */ |
1862 | - public function get_recurring( $object = false ) { |
|
1862 | + public function get_recurring($object = false) { |
|
1863 | 1863 | |
1864 | 1864 | // Are we returning an object? |
1865 | - if ( $object ) { |
|
1866 | - return $this->get_item( $this->recurring_item ); |
|
1865 | + if ($object) { |
|
1866 | + return $this->get_item($this->recurring_item); |
|
1867 | 1867 | } |
1868 | 1868 | |
1869 | 1869 | return $this->recurring_item; |
@@ -1878,15 +1878,15 @@ discard block |
||
1878 | 1878 | public function get_subscription_name() { |
1879 | 1879 | |
1880 | 1880 | // Retrieve the recurring name |
1881 | - $item = $this->get_recurring( true ); |
|
1881 | + $item = $this->get_recurring(true); |
|
1882 | 1882 | |
1883 | 1883 | // Abort if it does not exist. |
1884 | - if ( empty( $item ) ) { |
|
1884 | + if (empty($item)) { |
|
1885 | 1885 | return ''; |
1886 | 1886 | } |
1887 | 1887 | |
1888 | 1888 | // Return the item name. |
1889 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1889 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1890 | 1890 | } |
1891 | 1891 | |
1892 | 1892 | /** |
@@ -1896,9 +1896,9 @@ discard block |
||
1896 | 1896 | * @return string |
1897 | 1897 | */ |
1898 | 1898 | public function get_view_url() { |
1899 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1900 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1901 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1899 | + $invoice_url = get_permalink($this->get_id()); |
|
1900 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1901 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1902 | 1902 | } |
1903 | 1903 | |
1904 | 1904 | /** |
@@ -1907,25 +1907,25 @@ discard block |
||
1907 | 1907 | * @since 1.0.19 |
1908 | 1908 | * @return string |
1909 | 1909 | */ |
1910 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1910 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1911 | 1911 | |
1912 | 1912 | // Retrieve the checkout url. |
1913 | 1913 | $pay_url = wpinv_get_checkout_uri(); |
1914 | 1914 | |
1915 | 1915 | // Maybe force ssl. |
1916 | - if ( is_ssl() ) { |
|
1917 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1916 | + if (is_ssl()) { |
|
1917 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1918 | 1918 | } |
1919 | 1919 | |
1920 | 1920 | // Add the invoice key. |
1921 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1921 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1922 | 1922 | |
1923 | 1923 | // (Maybe?) add a secret |
1924 | - if ( $secret ) { |
|
1925 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1924 | + if ($secret) { |
|
1925 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1926 | 1926 | } |
1927 | 1927 | |
1928 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1928 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1929 | 1929 | } |
1930 | 1930 | |
1931 | 1931 | /** |
@@ -1940,14 +1940,14 @@ discard block |
||
1940 | 1940 | $receipt_url = wpinv_get_success_page_uri(); |
1941 | 1941 | |
1942 | 1942 | // Maybe force ssl. |
1943 | - if ( is_ssl() ) { |
|
1944 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1943 | + if (is_ssl()) { |
|
1944 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1945 | 1945 | } |
1946 | 1946 | |
1947 | 1947 | // Add the invoice key. |
1948 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1948 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1949 | 1949 | |
1950 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1950 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1951 | 1951 | } |
1952 | 1952 | |
1953 | 1953 | /** |
@@ -1957,7 +1957,7 @@ discard block |
||
1957 | 1957 | * @return string |
1958 | 1958 | */ |
1959 | 1959 | public function get_transaction_url() { |
1960 | - return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this ); |
|
1960 | + return apply_filters('getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this); |
|
1961 | 1961 | } |
1962 | 1962 | |
1963 | 1963 | /** |
@@ -1970,7 +1970,7 @@ discard block |
||
1970 | 1970 | |
1971 | 1971 | $type = $this->get_type(); |
1972 | 1972 | $status = "wpi-$type-pending"; |
1973 | - return str_replace( '-invoice', '', $status ); |
|
1973 | + return str_replace('-invoice', '', $status); |
|
1974 | 1974 | |
1975 | 1975 | } |
1976 | 1976 | |
@@ -1984,8 +1984,8 @@ discard block |
||
1984 | 1984 | * @param string $context View or edit context. |
1985 | 1985 | * @return mixed Value of the given invoice property (if set). |
1986 | 1986 | */ |
1987 | - public function get( $key, $context = 'view' ) { |
|
1988 | - return $this->get_prop( $key, $context ); |
|
1987 | + public function get($key, $context = 'view') { |
|
1988 | + return $this->get_prop($key, $context); |
|
1989 | 1989 | } |
1990 | 1990 | |
1991 | 1991 | /* |
@@ -2008,11 +2008,11 @@ discard block |
||
2008 | 2008 | * @param mixed $value new value. |
2009 | 2009 | * @return mixed Value of the given invoice property (if set). |
2010 | 2010 | */ |
2011 | - public function set( $key, $value ) { |
|
2011 | + public function set($key, $value) { |
|
2012 | 2012 | |
2013 | 2013 | $setter = "set_$key"; |
2014 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
2015 | - $this->{$setter}( $value ); |
|
2014 | + if (is_callable(array($this, $setter))) { |
|
2015 | + $this->{$setter}($value); |
|
2016 | 2016 | } |
2017 | 2017 | |
2018 | 2018 | } |
@@ -2026,45 +2026,45 @@ discard block |
||
2026 | 2026 | * @param bool $manual_update Is this a manual status change?. |
2027 | 2027 | * @return array details of change. |
2028 | 2028 | */ |
2029 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
2029 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
2030 | 2030 | $old_status = $this->get_status(); |
2031 | 2031 | |
2032 | 2032 | $statuses = $this->get_all_statuses(); |
2033 | 2033 | |
2034 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
2035 | - unset( $statuses[ 'draft' ] ); |
|
2034 | + if (isset($statuses['draft'])) { |
|
2035 | + unset($statuses['draft']); |
|
2036 | 2036 | } |
2037 | 2037 | |
2038 | - $this->set_prop( 'status', $new_status ); |
|
2038 | + $this->set_prop('status', $new_status); |
|
2039 | 2039 | |
2040 | 2040 | // If setting the status, ensure it's set to a valid status. |
2041 | - if ( true === $this->object_read ) { |
|
2041 | + if (true === $this->object_read) { |
|
2042 | 2042 | |
2043 | 2043 | // Only allow valid new status. |
2044 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
2044 | + if (!array_key_exists($new_status, $statuses)) { |
|
2045 | 2045 | $new_status = $this->get_default_status(); |
2046 | 2046 | } |
2047 | 2047 | |
2048 | 2048 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
2049 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
2049 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
2050 | 2050 | $old_status = $this->get_default_status(); |
2051 | 2051 | } |
2052 | 2052 | |
2053 | 2053 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
2054 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
2054 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
2055 | 2055 | $old_status = 'wpi-pending'; |
2056 | 2056 | } |
2057 | 2057 | |
2058 | - if ( $old_status !== $new_status ) { |
|
2058 | + if ($old_status !== $new_status) { |
|
2059 | 2059 | $this->status_transition = array( |
2060 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
2060 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
2061 | 2061 | 'to' => $new_status, |
2062 | 2062 | 'note' => $note, |
2063 | 2063 | 'manual' => (bool) $manual_update, |
2064 | 2064 | ); |
2065 | 2065 | |
2066 | - if ( $manual_update ) { |
|
2067 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
2066 | + if ($manual_update) { |
|
2067 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
2068 | 2068 | } |
2069 | 2069 | |
2070 | 2070 | $this->maybe_set_date_paid(); |
@@ -2089,8 +2089,8 @@ discard block |
||
2089 | 2089 | */ |
2090 | 2090 | public function maybe_set_date_paid() { |
2091 | 2091 | |
2092 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
2093 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
2092 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
2093 | + $this->set_date_completed(current_time('mysql')); |
|
2094 | 2094 | } |
2095 | 2095 | } |
2096 | 2096 | |
@@ -2099,11 +2099,11 @@ discard block |
||
2099 | 2099 | * |
2100 | 2100 | * @since 1.0.19 |
2101 | 2101 | */ |
2102 | - public function set_parent_id( $value ) { |
|
2103 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
2102 | + public function set_parent_id($value) { |
|
2103 | + if ($value && ($value === $this->get_id())) { |
|
2104 | 2104 | return; |
2105 | 2105 | } |
2106 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
2106 | + $this->set_prop('parent_id', absint($value)); |
|
2107 | 2107 | } |
2108 | 2108 | |
2109 | 2109 | /** |
@@ -2111,8 +2111,8 @@ discard block |
||
2111 | 2111 | * |
2112 | 2112 | * @since 1.0.19 |
2113 | 2113 | */ |
2114 | - public function set_version( $value ) { |
|
2115 | - $this->set_prop( 'version', $value ); |
|
2114 | + public function set_version($value) { |
|
2115 | + $this->set_prop('version', $value); |
|
2116 | 2116 | } |
2117 | 2117 | |
2118 | 2118 | /** |
@@ -2122,15 +2122,15 @@ discard block |
||
2122 | 2122 | * @param string $value Value to set. |
2123 | 2123 | * @return bool Whether or not the date was set. |
2124 | 2124 | */ |
2125 | - public function set_date_created( $value ) { |
|
2126 | - $date = strtotime( $value ); |
|
2125 | + public function set_date_created($value) { |
|
2126 | + $date = strtotime($value); |
|
2127 | 2127 | |
2128 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2129 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
2128 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2129 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
2130 | 2130 | return true; |
2131 | 2131 | } |
2132 | 2132 | |
2133 | - $this->set_prop( 'date_created', '' ); |
|
2133 | + $this->set_prop('date_created', ''); |
|
2134 | 2134 | return false; |
2135 | 2135 | |
2136 | 2136 | } |
@@ -2142,15 +2142,15 @@ discard block |
||
2142 | 2142 | * @param string $value Value to set. |
2143 | 2143 | * @return bool Whether or not the date was set. |
2144 | 2144 | */ |
2145 | - public function set_due_date( $value ) { |
|
2146 | - $date = strtotime( $value ); |
|
2145 | + public function set_due_date($value) { |
|
2146 | + $date = strtotime($value); |
|
2147 | 2147 | |
2148 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2149 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2148 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2149 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
2150 | 2150 | return true; |
2151 | 2151 | } |
2152 | 2152 | |
2153 | - $this->set_prop( 'due_date', '' ); |
|
2153 | + $this->set_prop('due_date', ''); |
|
2154 | 2154 | return false; |
2155 | 2155 | |
2156 | 2156 | } |
@@ -2161,8 +2161,8 @@ discard block |
||
2161 | 2161 | * @since 1.0.19 |
2162 | 2162 | * @param string $value New name. |
2163 | 2163 | */ |
2164 | - public function set_date_due( $value ) { |
|
2165 | - $this->set_due_date( $value ); |
|
2164 | + public function set_date_due($value) { |
|
2165 | + $this->set_due_date($value); |
|
2166 | 2166 | } |
2167 | 2167 | |
2168 | 2168 | /** |
@@ -2172,15 +2172,15 @@ discard block |
||
2172 | 2172 | * @param string $value Value to set. |
2173 | 2173 | * @return bool Whether or not the date was set. |
2174 | 2174 | */ |
2175 | - public function set_completed_date( $value ) { |
|
2176 | - $date = strtotime( $value ); |
|
2175 | + public function set_completed_date($value) { |
|
2176 | + $date = strtotime($value); |
|
2177 | 2177 | |
2178 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2179 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2178 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2179 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2180 | 2180 | return true; |
2181 | 2181 | } |
2182 | 2182 | |
2183 | - $this->set_prop( 'completed_date', '' ); |
|
2183 | + $this->set_prop('completed_date', ''); |
|
2184 | 2184 | return false; |
2185 | 2185 | |
2186 | 2186 | } |
@@ -2191,8 +2191,8 @@ discard block |
||
2191 | 2191 | * @since 1.0.19 |
2192 | 2192 | * @param string $value New name. |
2193 | 2193 | */ |
2194 | - public function set_date_completed( $value ) { |
|
2195 | - $this->set_completed_date( $value ); |
|
2194 | + public function set_date_completed($value) { |
|
2195 | + $this->set_completed_date($value); |
|
2196 | 2196 | } |
2197 | 2197 | |
2198 | 2198 | /** |
@@ -2202,15 +2202,15 @@ discard block |
||
2202 | 2202 | * @param string $value Value to set. |
2203 | 2203 | * @return bool Whether or not the date was set. |
2204 | 2204 | */ |
2205 | - public function set_date_modified( $value ) { |
|
2206 | - $date = strtotime( $value ); |
|
2205 | + public function set_date_modified($value) { |
|
2206 | + $date = strtotime($value); |
|
2207 | 2207 | |
2208 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2209 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2208 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2209 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2210 | 2210 | return true; |
2211 | 2211 | } |
2212 | 2212 | |
2213 | - $this->set_prop( 'date_modified', '' ); |
|
2213 | + $this->set_prop('date_modified', ''); |
|
2214 | 2214 | return false; |
2215 | 2215 | |
2216 | 2216 | } |
@@ -2221,9 +2221,9 @@ discard block |
||
2221 | 2221 | * @since 1.0.19 |
2222 | 2222 | * @param string $value New number. |
2223 | 2223 | */ |
2224 | - public function set_number( $value ) { |
|
2225 | - $number = sanitize_text_field( $value ); |
|
2226 | - $this->set_prop( 'number', $number ); |
|
2224 | + public function set_number($value) { |
|
2225 | + $number = sanitize_text_field($value); |
|
2226 | + $this->set_prop('number', $number); |
|
2227 | 2227 | } |
2228 | 2228 | |
2229 | 2229 | /** |
@@ -2232,9 +2232,9 @@ discard block |
||
2232 | 2232 | * @since 1.0.19 |
2233 | 2233 | * @param string $value Type. |
2234 | 2234 | */ |
2235 | - public function set_type( $value ) { |
|
2236 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2237 | - $this->set_prop( 'type', $type ); |
|
2235 | + public function set_type($value) { |
|
2236 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2237 | + $this->set_prop('type', $type); |
|
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | /** |
@@ -2243,10 +2243,10 @@ discard block |
||
2243 | 2243 | * @since 1.0.19 |
2244 | 2244 | * @param string $value Post type. |
2245 | 2245 | */ |
2246 | - public function set_post_type( $value ) { |
|
2247 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2248 | - $this->set_type( $value ); |
|
2249 | - $this->set_prop( 'post_type', $value ); |
|
2246 | + public function set_post_type($value) { |
|
2247 | + if (getpaid_is_invoice_post_type($value)) { |
|
2248 | + $this->set_type($value); |
|
2249 | + $this->set_prop('post_type', $value); |
|
2250 | 2250 | } |
2251 | 2251 | } |
2252 | 2252 | |
@@ -2256,9 +2256,9 @@ discard block |
||
2256 | 2256 | * @since 1.0.19 |
2257 | 2257 | * @param string $value New key. |
2258 | 2258 | */ |
2259 | - public function set_key( $value ) { |
|
2260 | - $key = sanitize_text_field( $value ); |
|
2261 | - $this->set_prop( 'key', $key ); |
|
2259 | + public function set_key($value) { |
|
2260 | + $key = sanitize_text_field($value); |
|
2261 | + $this->set_prop('key', $key); |
|
2262 | 2262 | } |
2263 | 2263 | |
2264 | 2264 | /** |
@@ -2267,9 +2267,9 @@ discard block |
||
2267 | 2267 | * @since 1.0.19 |
2268 | 2268 | * @param string $value mode. |
2269 | 2269 | */ |
2270 | - public function set_mode( $value ) { |
|
2271 | - if ( in_array( $value, array( 'live', 'test' ) ) ) { |
|
2272 | - $this->set_prop( 'mode', $value ); |
|
2270 | + public function set_mode($value) { |
|
2271 | + if (in_array($value, array('live', 'test'))) { |
|
2272 | + $this->set_prop('mode', $value); |
|
2273 | 2273 | } |
2274 | 2274 | } |
2275 | 2275 | |
@@ -2279,8 +2279,8 @@ discard block |
||
2279 | 2279 | * @since 1.0.19 |
2280 | 2280 | * @param string $value path. |
2281 | 2281 | */ |
2282 | - public function set_path( $value ) { |
|
2283 | - $this->set_prop( 'path', $value ); |
|
2282 | + public function set_path($value) { |
|
2283 | + $this->set_prop('path', $value); |
|
2284 | 2284 | } |
2285 | 2285 | |
2286 | 2286 | /** |
@@ -2289,9 +2289,9 @@ discard block |
||
2289 | 2289 | * @since 1.0.19 |
2290 | 2290 | * @param string $value New name. |
2291 | 2291 | */ |
2292 | - public function set_name( $value ) { |
|
2293 | - $name = sanitize_text_field( $value ); |
|
2294 | - $this->set_prop( 'name', $name ); |
|
2292 | + public function set_name($value) { |
|
2293 | + $name = sanitize_text_field($value); |
|
2294 | + $this->set_prop('name', $name); |
|
2295 | 2295 | } |
2296 | 2296 | |
2297 | 2297 | /** |
@@ -2300,8 +2300,8 @@ discard block |
||
2300 | 2300 | * @since 1.0.19 |
2301 | 2301 | * @param string $value New name. |
2302 | 2302 | */ |
2303 | - public function set_title( $value ) { |
|
2304 | - $this->set_name( $value ); |
|
2303 | + public function set_title($value) { |
|
2304 | + $this->set_name($value); |
|
2305 | 2305 | } |
2306 | 2306 | |
2307 | 2307 | /** |
@@ -2310,9 +2310,9 @@ discard block |
||
2310 | 2310 | * @since 1.0.19 |
2311 | 2311 | * @param string $value New description. |
2312 | 2312 | */ |
2313 | - public function set_description( $value ) { |
|
2314 | - $description = wp_kses_post( $value ); |
|
2315 | - $this->set_prop( 'description', $description ); |
|
2313 | + public function set_description($value) { |
|
2314 | + $description = wp_kses_post($value); |
|
2315 | + $this->set_prop('description', $description); |
|
2316 | 2316 | } |
2317 | 2317 | |
2318 | 2318 | /** |
@@ -2321,8 +2321,8 @@ discard block |
||
2321 | 2321 | * @since 1.0.19 |
2322 | 2322 | * @param string $value New description. |
2323 | 2323 | */ |
2324 | - public function set_excerpt( $value ) { |
|
2325 | - $this->set_description( $value ); |
|
2324 | + public function set_excerpt($value) { |
|
2325 | + $this->set_description($value); |
|
2326 | 2326 | } |
2327 | 2327 | |
2328 | 2328 | /** |
@@ -2331,8 +2331,8 @@ discard block |
||
2331 | 2331 | * @since 1.0.19 |
2332 | 2332 | * @param string $value New description. |
2333 | 2333 | */ |
2334 | - public function set_summary( $value ) { |
|
2335 | - $this->set_description( $value ); |
|
2334 | + public function set_summary($value) { |
|
2335 | + $this->set_description($value); |
|
2336 | 2336 | } |
2337 | 2337 | |
2338 | 2338 | /** |
@@ -2341,12 +2341,12 @@ discard block |
||
2341 | 2341 | * @since 1.0.19 |
2342 | 2342 | * @param int $value New author. |
2343 | 2343 | */ |
2344 | - public function set_author( $value ) { |
|
2345 | - $user = get_user_by( 'id', (int) $value ); |
|
2344 | + public function set_author($value) { |
|
2345 | + $user = get_user_by('id', (int) $value); |
|
2346 | 2346 | |
2347 | - if ( $user && $user->ID ) { |
|
2348 | - $this->set_prop( 'author', $user->ID ); |
|
2349 | - $this->set_prop( 'email', $user->user_email ); |
|
2347 | + if ($user && $user->ID) { |
|
2348 | + $this->set_prop('author', $user->ID); |
|
2349 | + $this->set_prop('email', $user->user_email); |
|
2350 | 2350 | } |
2351 | 2351 | |
2352 | 2352 | } |
@@ -2357,8 +2357,8 @@ discard block |
||
2357 | 2357 | * @since 1.0.19 |
2358 | 2358 | * @param int $value New user id. |
2359 | 2359 | */ |
2360 | - public function set_user_id( $value ) { |
|
2361 | - $this->set_author( $value ); |
|
2360 | + public function set_user_id($value) { |
|
2361 | + $this->set_author($value); |
|
2362 | 2362 | } |
2363 | 2363 | |
2364 | 2364 | /** |
@@ -2367,8 +2367,8 @@ discard block |
||
2367 | 2367 | * @since 1.0.19 |
2368 | 2368 | * @param int $value New user id. |
2369 | 2369 | */ |
2370 | - public function set_customer_id( $value ) { |
|
2371 | - $this->set_author( $value ); |
|
2370 | + public function set_customer_id($value) { |
|
2371 | + $this->set_author($value); |
|
2372 | 2372 | } |
2373 | 2373 | |
2374 | 2374 | /** |
@@ -2377,8 +2377,8 @@ discard block |
||
2377 | 2377 | * @since 1.0.19 |
2378 | 2378 | * @param string $value ip address. |
2379 | 2379 | */ |
2380 | - public function set_ip( $value ) { |
|
2381 | - $this->set_prop( 'ip', $value ); |
|
2380 | + public function set_ip($value) { |
|
2381 | + $this->set_prop('ip', $value); |
|
2382 | 2382 | } |
2383 | 2383 | |
2384 | 2384 | /** |
@@ -2387,8 +2387,8 @@ discard block |
||
2387 | 2387 | * @since 1.0.19 |
2388 | 2388 | * @param string $value ip address. |
2389 | 2389 | */ |
2390 | - public function set_user_ip( $value ) { |
|
2391 | - $this->set_ip( $value ); |
|
2390 | + public function set_user_ip($value) { |
|
2391 | + $this->set_ip($value); |
|
2392 | 2392 | } |
2393 | 2393 | |
2394 | 2394 | /** |
@@ -2397,8 +2397,8 @@ discard block |
||
2397 | 2397 | * @since 1.0.19 |
2398 | 2398 | * @param string $value first name. |
2399 | 2399 | */ |
2400 | - public function set_first_name( $value ) { |
|
2401 | - $this->set_prop( 'first_name', $value ); |
|
2400 | + public function set_first_name($value) { |
|
2401 | + $this->set_prop('first_name', $value); |
|
2402 | 2402 | } |
2403 | 2403 | |
2404 | 2404 | /** |
@@ -2407,8 +2407,8 @@ discard block |
||
2407 | 2407 | * @since 1.0.19 |
2408 | 2408 | * @param string $value first name. |
2409 | 2409 | */ |
2410 | - public function set_user_first_name( $value ) { |
|
2411 | - $this->set_first_name( $value ); |
|
2410 | + public function set_user_first_name($value) { |
|
2411 | + $this->set_first_name($value); |
|
2412 | 2412 | } |
2413 | 2413 | |
2414 | 2414 | /** |
@@ -2417,8 +2417,8 @@ discard block |
||
2417 | 2417 | * @since 1.0.19 |
2418 | 2418 | * @param string $value first name. |
2419 | 2419 | */ |
2420 | - public function set_customer_first_name( $value ) { |
|
2421 | - $this->set_first_name( $value ); |
|
2420 | + public function set_customer_first_name($value) { |
|
2421 | + $this->set_first_name($value); |
|
2422 | 2422 | } |
2423 | 2423 | |
2424 | 2424 | /** |
@@ -2427,8 +2427,8 @@ discard block |
||
2427 | 2427 | * @since 1.0.19 |
2428 | 2428 | * @param string $value last name. |
2429 | 2429 | */ |
2430 | - public function set_last_name( $value ) { |
|
2431 | - $this->set_prop( 'last_name', $value ); |
|
2430 | + public function set_last_name($value) { |
|
2431 | + $this->set_prop('last_name', $value); |
|
2432 | 2432 | } |
2433 | 2433 | |
2434 | 2434 | /** |
@@ -2437,8 +2437,8 @@ discard block |
||
2437 | 2437 | * @since 1.0.19 |
2438 | 2438 | * @param string $value last name. |
2439 | 2439 | */ |
2440 | - public function set_user_last_name( $value ) { |
|
2441 | - $this->set_last_name( $value ); |
|
2440 | + public function set_user_last_name($value) { |
|
2441 | + $this->set_last_name($value); |
|
2442 | 2442 | } |
2443 | 2443 | |
2444 | 2444 | /** |
@@ -2447,8 +2447,8 @@ discard block |
||
2447 | 2447 | * @since 1.0.19 |
2448 | 2448 | * @param string $value last name. |
2449 | 2449 | */ |
2450 | - public function set_customer_last_name( $value ) { |
|
2451 | - $this->set_last_name( $value ); |
|
2450 | + public function set_customer_last_name($value) { |
|
2451 | + $this->set_last_name($value); |
|
2452 | 2452 | } |
2453 | 2453 | |
2454 | 2454 | /** |
@@ -2457,8 +2457,8 @@ discard block |
||
2457 | 2457 | * @since 1.0.19 |
2458 | 2458 | * @param string $value phone. |
2459 | 2459 | */ |
2460 | - public function set_phone( $value ) { |
|
2461 | - $this->set_prop( 'phone', $value ); |
|
2460 | + public function set_phone($value) { |
|
2461 | + $this->set_prop('phone', $value); |
|
2462 | 2462 | } |
2463 | 2463 | |
2464 | 2464 | /** |
@@ -2467,8 +2467,8 @@ discard block |
||
2467 | 2467 | * @since 1.0.19 |
2468 | 2468 | * @param string $value phone. |
2469 | 2469 | */ |
2470 | - public function set_user_phone( $value ) { |
|
2471 | - $this->set_phone( $value ); |
|
2470 | + public function set_user_phone($value) { |
|
2471 | + $this->set_phone($value); |
|
2472 | 2472 | } |
2473 | 2473 | |
2474 | 2474 | /** |
@@ -2477,8 +2477,8 @@ discard block |
||
2477 | 2477 | * @since 1.0.19 |
2478 | 2478 | * @param string $value phone. |
2479 | 2479 | */ |
2480 | - public function set_customer_phone( $value ) { |
|
2481 | - $this->set_phone( $value ); |
|
2480 | + public function set_customer_phone($value) { |
|
2481 | + $this->set_phone($value); |
|
2482 | 2482 | } |
2483 | 2483 | |
2484 | 2484 | /** |
@@ -2487,8 +2487,8 @@ discard block |
||
2487 | 2487 | * @since 1.0.19 |
2488 | 2488 | * @param string $value phone. |
2489 | 2489 | */ |
2490 | - public function set_phone_number( $value ) { |
|
2491 | - $this->set_phone( $value ); |
|
2490 | + public function set_phone_number($value) { |
|
2491 | + $this->set_phone($value); |
|
2492 | 2492 | } |
2493 | 2493 | |
2494 | 2494 | /** |
@@ -2497,8 +2497,8 @@ discard block |
||
2497 | 2497 | * @since 1.0.19 |
2498 | 2498 | * @param string $value email address. |
2499 | 2499 | */ |
2500 | - public function set_email( $value ) { |
|
2501 | - $this->set_prop( 'email', $value ); |
|
2500 | + public function set_email($value) { |
|
2501 | + $this->set_prop('email', $value); |
|
2502 | 2502 | } |
2503 | 2503 | |
2504 | 2504 | /** |
@@ -2507,8 +2507,8 @@ discard block |
||
2507 | 2507 | * @since 1.0.19 |
2508 | 2508 | * @param string $value email address. |
2509 | 2509 | */ |
2510 | - public function set_user_email( $value ) { |
|
2511 | - $this->set_email( $value ); |
|
2510 | + public function set_user_email($value) { |
|
2511 | + $this->set_email($value); |
|
2512 | 2512 | } |
2513 | 2513 | |
2514 | 2514 | /** |
@@ -2517,8 +2517,8 @@ discard block |
||
2517 | 2517 | * @since 1.0.19 |
2518 | 2518 | * @param string $value email address. |
2519 | 2519 | */ |
2520 | - public function set_email_address( $value ) { |
|
2521 | - $this->set_email( $value ); |
|
2520 | + public function set_email_address($value) { |
|
2521 | + $this->set_email($value); |
|
2522 | 2522 | } |
2523 | 2523 | |
2524 | 2524 | /** |
@@ -2527,8 +2527,8 @@ discard block |
||
2527 | 2527 | * @since 1.0.19 |
2528 | 2528 | * @param string $value email address. |
2529 | 2529 | */ |
2530 | - public function set_customer_email( $value ) { |
|
2531 | - $this->set_email( $value ); |
|
2530 | + public function set_customer_email($value) { |
|
2531 | + $this->set_email($value); |
|
2532 | 2532 | } |
2533 | 2533 | |
2534 | 2534 | /** |
@@ -2537,8 +2537,8 @@ discard block |
||
2537 | 2537 | * @since 1.0.19 |
2538 | 2538 | * @param string $value country. |
2539 | 2539 | */ |
2540 | - public function set_country( $value ) { |
|
2541 | - $this->set_prop( 'country', $value ); |
|
2540 | + public function set_country($value) { |
|
2541 | + $this->set_prop('country', $value); |
|
2542 | 2542 | } |
2543 | 2543 | |
2544 | 2544 | /** |
@@ -2547,8 +2547,8 @@ discard block |
||
2547 | 2547 | * @since 1.0.19 |
2548 | 2548 | * @param string $value country. |
2549 | 2549 | */ |
2550 | - public function set_user_country( $value ) { |
|
2551 | - $this->set_country( $value ); |
|
2550 | + public function set_user_country($value) { |
|
2551 | + $this->set_country($value); |
|
2552 | 2552 | } |
2553 | 2553 | |
2554 | 2554 | /** |
@@ -2557,8 +2557,8 @@ discard block |
||
2557 | 2557 | * @since 1.0.19 |
2558 | 2558 | * @param string $value country. |
2559 | 2559 | */ |
2560 | - public function set_customer_country( $value ) { |
|
2561 | - $this->set_country( $value ); |
|
2560 | + public function set_customer_country($value) { |
|
2561 | + $this->set_country($value); |
|
2562 | 2562 | } |
2563 | 2563 | |
2564 | 2564 | /** |
@@ -2567,8 +2567,8 @@ discard block |
||
2567 | 2567 | * @since 1.0.19 |
2568 | 2568 | * @param string $value state. |
2569 | 2569 | */ |
2570 | - public function set_state( $value ) { |
|
2571 | - $this->set_prop( 'state', $value ); |
|
2570 | + public function set_state($value) { |
|
2571 | + $this->set_prop('state', $value); |
|
2572 | 2572 | } |
2573 | 2573 | |
2574 | 2574 | /** |
@@ -2577,8 +2577,8 @@ discard block |
||
2577 | 2577 | * @since 1.0.19 |
2578 | 2578 | * @param string $value state. |
2579 | 2579 | */ |
2580 | - public function set_user_state( $value ) { |
|
2581 | - $this->set_state( $value ); |
|
2580 | + public function set_user_state($value) { |
|
2581 | + $this->set_state($value); |
|
2582 | 2582 | } |
2583 | 2583 | |
2584 | 2584 | /** |
@@ -2587,8 +2587,8 @@ discard block |
||
2587 | 2587 | * @since 1.0.19 |
2588 | 2588 | * @param string $value state. |
2589 | 2589 | */ |
2590 | - public function set_customer_state( $value ) { |
|
2591 | - $this->set_state( $value ); |
|
2590 | + public function set_customer_state($value) { |
|
2591 | + $this->set_state($value); |
|
2592 | 2592 | } |
2593 | 2593 | |
2594 | 2594 | /** |
@@ -2597,8 +2597,8 @@ discard block |
||
2597 | 2597 | * @since 1.0.19 |
2598 | 2598 | * @param string $value city. |
2599 | 2599 | */ |
2600 | - public function set_city( $value ) { |
|
2601 | - $this->set_prop( 'city', $value ); |
|
2600 | + public function set_city($value) { |
|
2601 | + $this->set_prop('city', $value); |
|
2602 | 2602 | } |
2603 | 2603 | |
2604 | 2604 | /** |
@@ -2607,8 +2607,8 @@ discard block |
||
2607 | 2607 | * @since 1.0.19 |
2608 | 2608 | * @param string $value city. |
2609 | 2609 | */ |
2610 | - public function set_user_city( $value ) { |
|
2611 | - $this->set_city( $value ); |
|
2610 | + public function set_user_city($value) { |
|
2611 | + $this->set_city($value); |
|
2612 | 2612 | } |
2613 | 2613 | |
2614 | 2614 | /** |
@@ -2617,8 +2617,8 @@ discard block |
||
2617 | 2617 | * @since 1.0.19 |
2618 | 2618 | * @param string $value city. |
2619 | 2619 | */ |
2620 | - public function set_customer_city( $value ) { |
|
2621 | - $this->set_city( $value ); |
|
2620 | + public function set_customer_city($value) { |
|
2621 | + $this->set_city($value); |
|
2622 | 2622 | } |
2623 | 2623 | |
2624 | 2624 | /** |
@@ -2627,8 +2627,8 @@ discard block |
||
2627 | 2627 | * @since 1.0.19 |
2628 | 2628 | * @param string $value zip. |
2629 | 2629 | */ |
2630 | - public function set_zip( $value ) { |
|
2631 | - $this->set_prop( 'zip', $value ); |
|
2630 | + public function set_zip($value) { |
|
2631 | + $this->set_prop('zip', $value); |
|
2632 | 2632 | } |
2633 | 2633 | |
2634 | 2634 | /** |
@@ -2637,8 +2637,8 @@ discard block |
||
2637 | 2637 | * @since 1.0.19 |
2638 | 2638 | * @param string $value zip. |
2639 | 2639 | */ |
2640 | - public function set_user_zip( $value ) { |
|
2641 | - $this->set_zip( $value ); |
|
2640 | + public function set_user_zip($value) { |
|
2641 | + $this->set_zip($value); |
|
2642 | 2642 | } |
2643 | 2643 | |
2644 | 2644 | /** |
@@ -2647,8 +2647,8 @@ discard block |
||
2647 | 2647 | * @since 1.0.19 |
2648 | 2648 | * @param string $value zip. |
2649 | 2649 | */ |
2650 | - public function set_customer_zip( $value ) { |
|
2651 | - $this->set_zip( $value ); |
|
2650 | + public function set_customer_zip($value) { |
|
2651 | + $this->set_zip($value); |
|
2652 | 2652 | } |
2653 | 2653 | |
2654 | 2654 | /** |
@@ -2657,8 +2657,8 @@ discard block |
||
2657 | 2657 | * @since 1.0.19 |
2658 | 2658 | * @param string $value company. |
2659 | 2659 | */ |
2660 | - public function set_company( $value ) { |
|
2661 | - $this->set_prop( 'company', $value ); |
|
2660 | + public function set_company($value) { |
|
2661 | + $this->set_prop('company', $value); |
|
2662 | 2662 | } |
2663 | 2663 | |
2664 | 2664 | /** |
@@ -2667,8 +2667,8 @@ discard block |
||
2667 | 2667 | * @since 1.0.19 |
2668 | 2668 | * @param string $value company. |
2669 | 2669 | */ |
2670 | - public function set_user_company( $value ) { |
|
2671 | - $this->set_company( $value ); |
|
2670 | + public function set_user_company($value) { |
|
2671 | + $this->set_company($value); |
|
2672 | 2672 | } |
2673 | 2673 | |
2674 | 2674 | /** |
@@ -2677,8 +2677,8 @@ discard block |
||
2677 | 2677 | * @since 1.0.19 |
2678 | 2678 | * @param string $value company. |
2679 | 2679 | */ |
2680 | - public function set_customer_company( $value ) { |
|
2681 | - $this->set_company( $value ); |
|
2680 | + public function set_customer_company($value) { |
|
2681 | + $this->set_company($value); |
|
2682 | 2682 | } |
2683 | 2683 | |
2684 | 2684 | /** |
@@ -2687,8 +2687,8 @@ discard block |
||
2687 | 2687 | * @since 1.0.19 |
2688 | 2688 | * @param string $value company id. |
2689 | 2689 | */ |
2690 | - public function set_company_id( $value ) { |
|
2691 | - $this->set_prop( 'company_id', $value ); |
|
2690 | + public function set_company_id($value) { |
|
2691 | + $this->set_prop('company_id', $value); |
|
2692 | 2692 | } |
2693 | 2693 | |
2694 | 2694 | /** |
@@ -2697,8 +2697,8 @@ discard block |
||
2697 | 2697 | * @since 1.0.19 |
2698 | 2698 | * @param string $value var number. |
2699 | 2699 | */ |
2700 | - public function set_vat_number( $value ) { |
|
2701 | - $this->set_prop( 'vat_number', $value ); |
|
2700 | + public function set_vat_number($value) { |
|
2701 | + $this->set_prop('vat_number', $value); |
|
2702 | 2702 | } |
2703 | 2703 | |
2704 | 2704 | /** |
@@ -2707,8 +2707,8 @@ discard block |
||
2707 | 2707 | * @since 1.0.19 |
2708 | 2708 | * @param string $value var number. |
2709 | 2709 | */ |
2710 | - public function set_user_vat_number( $value ) { |
|
2711 | - $this->set_vat_number( $value ); |
|
2710 | + public function set_user_vat_number($value) { |
|
2711 | + $this->set_vat_number($value); |
|
2712 | 2712 | } |
2713 | 2713 | |
2714 | 2714 | /** |
@@ -2717,8 +2717,8 @@ discard block |
||
2717 | 2717 | * @since 1.0.19 |
2718 | 2718 | * @param string $value var number. |
2719 | 2719 | */ |
2720 | - public function set_customer_vat_number( $value ) { |
|
2721 | - $this->set_vat_number( $value ); |
|
2720 | + public function set_customer_vat_number($value) { |
|
2721 | + $this->set_vat_number($value); |
|
2722 | 2722 | } |
2723 | 2723 | |
2724 | 2724 | /** |
@@ -2727,8 +2727,8 @@ discard block |
||
2727 | 2727 | * @since 1.0.19 |
2728 | 2728 | * @param string $value var rate. |
2729 | 2729 | */ |
2730 | - public function set_vat_rate( $value ) { |
|
2731 | - $this->set_prop( 'vat_rate', $value ); |
|
2730 | + public function set_vat_rate($value) { |
|
2731 | + $this->set_prop('vat_rate', $value); |
|
2732 | 2732 | } |
2733 | 2733 | |
2734 | 2734 | /** |
@@ -2737,8 +2737,8 @@ discard block |
||
2737 | 2737 | * @since 1.0.19 |
2738 | 2738 | * @param string $value var number. |
2739 | 2739 | */ |
2740 | - public function set_user_vat_rate( $value ) { |
|
2741 | - $this->set_vat_rate( $value ); |
|
2740 | + public function set_user_vat_rate($value) { |
|
2741 | + $this->set_vat_rate($value); |
|
2742 | 2742 | } |
2743 | 2743 | |
2744 | 2744 | /** |
@@ -2747,8 +2747,8 @@ discard block |
||
2747 | 2747 | * @since 1.0.19 |
2748 | 2748 | * @param string $value var number. |
2749 | 2749 | */ |
2750 | - public function set_customer_vat_rate( $value ) { |
|
2751 | - $this->set_vat_rate( $value ); |
|
2750 | + public function set_customer_vat_rate($value) { |
|
2751 | + $this->set_vat_rate($value); |
|
2752 | 2752 | } |
2753 | 2753 | |
2754 | 2754 | /** |
@@ -2757,8 +2757,8 @@ discard block |
||
2757 | 2757 | * @since 1.0.19 |
2758 | 2758 | * @param string $value address. |
2759 | 2759 | */ |
2760 | - public function set_address( $value ) { |
|
2761 | - $this->set_prop( 'address', $value ); |
|
2760 | + public function set_address($value) { |
|
2761 | + $this->set_prop('address', $value); |
|
2762 | 2762 | } |
2763 | 2763 | |
2764 | 2764 | /** |
@@ -2767,8 +2767,8 @@ discard block |
||
2767 | 2767 | * @since 1.0.19 |
2768 | 2768 | * @param string $value address. |
2769 | 2769 | */ |
2770 | - public function set_user_address( $value ) { |
|
2771 | - $this->set_address( $value ); |
|
2770 | + public function set_user_address($value) { |
|
2771 | + $this->set_address($value); |
|
2772 | 2772 | } |
2773 | 2773 | |
2774 | 2774 | /** |
@@ -2777,8 +2777,8 @@ discard block |
||
2777 | 2777 | * @since 1.0.19 |
2778 | 2778 | * @param string $value address. |
2779 | 2779 | */ |
2780 | - public function set_customer_address( $value ) { |
|
2781 | - $this->set_address( $value ); |
|
2780 | + public function set_customer_address($value) { |
|
2781 | + $this->set_address($value); |
|
2782 | 2782 | } |
2783 | 2783 | |
2784 | 2784 | /** |
@@ -2787,8 +2787,8 @@ discard block |
||
2787 | 2787 | * @since 1.0.19 |
2788 | 2788 | * @param int|bool $value confirmed. |
2789 | 2789 | */ |
2790 | - public function set_is_viewed( $value ) { |
|
2791 | - $this->set_prop( 'is_viewed', $value ); |
|
2790 | + public function set_is_viewed($value) { |
|
2791 | + $this->set_prop('is_viewed', $value); |
|
2792 | 2792 | } |
2793 | 2793 | |
2794 | 2794 | /** |
@@ -2797,8 +2797,8 @@ discard block |
||
2797 | 2797 | * @since 1.0.19 |
2798 | 2798 | * @param string $value email recipients. |
2799 | 2799 | */ |
2800 | - public function set_email_cc( $value ) { |
|
2801 | - $this->set_prop( 'email_cc', $value ); |
|
2800 | + public function set_email_cc($value) { |
|
2801 | + $this->set_prop('email_cc', $value); |
|
2802 | 2802 | } |
2803 | 2803 | |
2804 | 2804 | /** |
@@ -2807,9 +2807,9 @@ discard block |
||
2807 | 2807 | * @since 1.0.19 |
2808 | 2808 | * @param string $value template. |
2809 | 2809 | */ |
2810 | - public function set_template( $value ) { |
|
2811 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2812 | - $this->set_prop( 'template', $value ); |
|
2810 | + public function set_template($value) { |
|
2811 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2812 | + $this->set_prop('template', $value); |
|
2813 | 2813 | } |
2814 | 2814 | } |
2815 | 2815 | |
@@ -2820,8 +2820,8 @@ discard block |
||
2820 | 2820 | * @param string $value source. |
2821 | 2821 | * @deprecated |
2822 | 2822 | */ |
2823 | - public function created_via( $value ) { |
|
2824 | - $this->set_created_via( sanitize_text_field( $value ) ); |
|
2823 | + public function created_via($value) { |
|
2824 | + $this->set_created_via(sanitize_text_field($value)); |
|
2825 | 2825 | } |
2826 | 2826 | |
2827 | 2827 | /** |
@@ -2830,8 +2830,8 @@ discard block |
||
2830 | 2830 | * @since 1.0.19 |
2831 | 2831 | * @param string $value source. |
2832 | 2832 | */ |
2833 | - public function set_created_via( $value ) { |
|
2834 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
2833 | + public function set_created_via($value) { |
|
2834 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
2835 | 2835 | } |
2836 | 2836 | |
2837 | 2837 | /** |
@@ -2840,8 +2840,8 @@ discard block |
||
2840 | 2840 | * @since 1.0.19 |
2841 | 2841 | * @param int|bool $value confirmed. |
2842 | 2842 | */ |
2843 | - public function set_address_confirmed( $value ) { |
|
2844 | - $this->set_prop( 'address_confirmed', $value ); |
|
2843 | + public function set_address_confirmed($value) { |
|
2844 | + $this->set_prop('address_confirmed', $value); |
|
2845 | 2845 | } |
2846 | 2846 | |
2847 | 2847 | /** |
@@ -2850,8 +2850,8 @@ discard block |
||
2850 | 2850 | * @since 1.0.19 |
2851 | 2851 | * @param int|bool $value confirmed. |
2852 | 2852 | */ |
2853 | - public function set_user_address_confirmed( $value ) { |
|
2854 | - $this->set_address_confirmed( $value ); |
|
2853 | + public function set_user_address_confirmed($value) { |
|
2854 | + $this->set_address_confirmed($value); |
|
2855 | 2855 | } |
2856 | 2856 | |
2857 | 2857 | /** |
@@ -2860,8 +2860,8 @@ discard block |
||
2860 | 2860 | * @since 1.0.19 |
2861 | 2861 | * @param int|bool $value confirmed. |
2862 | 2862 | */ |
2863 | - public function set_customer_address_confirmed( $value ) { |
|
2864 | - $this->set_address_confirmed( $value ); |
|
2863 | + public function set_customer_address_confirmed($value) { |
|
2864 | + $this->set_address_confirmed($value); |
|
2865 | 2865 | } |
2866 | 2866 | |
2867 | 2867 | /** |
@@ -2870,13 +2870,13 @@ discard block |
||
2870 | 2870 | * @since 1.0.19 |
2871 | 2871 | * @param float $value shipping amount. |
2872 | 2872 | */ |
2873 | - public function set_shipping( $value ) { |
|
2873 | + public function set_shipping($value) { |
|
2874 | 2874 | |
2875 | - if ( ! is_numeric( $value ) ) { |
|
2876 | - return $this->set_prop( 'shipping', null ); |
|
2875 | + if (!is_numeric($value)) { |
|
2876 | + return $this->set_prop('shipping', null); |
|
2877 | 2877 | } |
2878 | 2878 | |
2879 | - $this->set_prop( 'shipping', max( 0, floatval( $value ) ) ); |
|
2879 | + $this->set_prop('shipping', max(0, floatval($value))); |
|
2880 | 2880 | } |
2881 | 2881 | |
2882 | 2882 | /** |
@@ -2885,8 +2885,8 @@ discard block |
||
2885 | 2885 | * @since 1.0.19 |
2886 | 2886 | * @param float $value sub total. |
2887 | 2887 | */ |
2888 | - public function set_subtotal( $value ) { |
|
2889 | - $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
2888 | + public function set_subtotal($value) { |
|
2889 | + $this->set_prop('subtotal', max(0, $value)); |
|
2890 | 2890 | } |
2891 | 2891 | |
2892 | 2892 | /** |
@@ -2895,8 +2895,8 @@ discard block |
||
2895 | 2895 | * @since 1.0.19 |
2896 | 2896 | * @param float $value sub total. |
2897 | 2897 | */ |
2898 | - public function set_total( $value ) { |
|
2899 | - $this->set_prop( 'total', max( 0, $value ) ); |
|
2898 | + public function set_total($value) { |
|
2899 | + $this->set_prop('total', max(0, $value)); |
|
2900 | 2900 | } |
2901 | 2901 | |
2902 | 2902 | /** |
@@ -2905,8 +2905,8 @@ discard block |
||
2905 | 2905 | * @since 1.0.19 |
2906 | 2906 | * @param float $value discount total. |
2907 | 2907 | */ |
2908 | - public function set_total_discount( $value ) { |
|
2909 | - $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
2908 | + public function set_total_discount($value) { |
|
2909 | + $this->set_prop('total_discount', max(0, $value)); |
|
2910 | 2910 | } |
2911 | 2911 | |
2912 | 2912 | /** |
@@ -2915,8 +2915,8 @@ discard block |
||
2915 | 2915 | * @since 1.0.19 |
2916 | 2916 | * @param float $value discount total. |
2917 | 2917 | */ |
2918 | - public function set_discount( $value ) { |
|
2919 | - $this->set_total_discount( $value ); |
|
2918 | + public function set_discount($value) { |
|
2919 | + $this->set_total_discount($value); |
|
2920 | 2920 | } |
2921 | 2921 | |
2922 | 2922 | /** |
@@ -2925,8 +2925,8 @@ discard block |
||
2925 | 2925 | * @since 1.0.19 |
2926 | 2926 | * @param float $value tax total. |
2927 | 2927 | */ |
2928 | - public function set_total_tax( $value ) { |
|
2929 | - $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
2928 | + public function set_total_tax($value) { |
|
2929 | + $this->set_prop('total_tax', max(0, $value)); |
|
2930 | 2930 | } |
2931 | 2931 | |
2932 | 2932 | /** |
@@ -2935,8 +2935,8 @@ discard block |
||
2935 | 2935 | * @since 1.0.19 |
2936 | 2936 | * @param float $value tax total. |
2937 | 2937 | */ |
2938 | - public function set_tax_total( $value ) { |
|
2939 | - $this->set_total_tax( $value ); |
|
2938 | + public function set_tax_total($value) { |
|
2939 | + $this->set_total_tax($value); |
|
2940 | 2940 | } |
2941 | 2941 | |
2942 | 2942 | /** |
@@ -2945,8 +2945,8 @@ discard block |
||
2945 | 2945 | * @since 1.0.19 |
2946 | 2946 | * @param float $value fees total. |
2947 | 2947 | */ |
2948 | - public function set_total_fees( $value ) { |
|
2949 | - $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
2948 | + public function set_total_fees($value) { |
|
2949 | + $this->set_prop('total_fees', max(0, $value)); |
|
2950 | 2950 | } |
2951 | 2951 | |
2952 | 2952 | /** |
@@ -2955,8 +2955,8 @@ discard block |
||
2955 | 2955 | * @since 1.0.19 |
2956 | 2956 | * @param float $value fees total. |
2957 | 2957 | */ |
2958 | - public function set_fees_total( $value ) { |
|
2959 | - $this->set_total_fees( $value ); |
|
2958 | + public function set_fees_total($value) { |
|
2959 | + $this->set_total_fees($value); |
|
2960 | 2960 | } |
2961 | 2961 | |
2962 | 2962 | /** |
@@ -2965,13 +2965,13 @@ discard block |
||
2965 | 2965 | * @since 1.0.19 |
2966 | 2966 | * @param array $value fees. |
2967 | 2967 | */ |
2968 | - public function set_fees( $value ) { |
|
2968 | + public function set_fees($value) { |
|
2969 | 2969 | |
2970 | - if ( ! is_array( $value ) ) { |
|
2970 | + if (!is_array($value)) { |
|
2971 | 2971 | $value = array(); |
2972 | 2972 | } |
2973 | 2973 | |
2974 | - $this->set_prop( 'fees', $value ); |
|
2974 | + $this->set_prop('fees', $value); |
|
2975 | 2975 | |
2976 | 2976 | } |
2977 | 2977 | |
@@ -2981,13 +2981,13 @@ discard block |
||
2981 | 2981 | * @since 1.0.19 |
2982 | 2982 | * @param array $value taxes. |
2983 | 2983 | */ |
2984 | - public function set_taxes( $value ) { |
|
2984 | + public function set_taxes($value) { |
|
2985 | 2985 | |
2986 | - if ( ! is_array( $value ) ) { |
|
2986 | + if (!is_array($value)) { |
|
2987 | 2987 | $value = array(); |
2988 | 2988 | } |
2989 | 2989 | |
2990 | - $this->set_prop( 'taxes', $value ); |
|
2990 | + $this->set_prop('taxes', $value); |
|
2991 | 2991 | |
2992 | 2992 | } |
2993 | 2993 | |
@@ -2997,13 +2997,13 @@ discard block |
||
2997 | 2997 | * @since 1.0.19 |
2998 | 2998 | * @param array $value discounts. |
2999 | 2999 | */ |
3000 | - public function set_discounts( $value ) { |
|
3000 | + public function set_discounts($value) { |
|
3001 | 3001 | |
3002 | - if ( ! is_array( $value ) ) { |
|
3002 | + if (!is_array($value)) { |
|
3003 | 3003 | $value = array(); |
3004 | 3004 | } |
3005 | 3005 | |
3006 | - $this->set_prop( 'discounts', $value ); |
|
3006 | + $this->set_prop('discounts', $value); |
|
3007 | 3007 | } |
3008 | 3008 | |
3009 | 3009 | /** |
@@ -3012,19 +3012,19 @@ discard block |
||
3012 | 3012 | * @since 1.0.19 |
3013 | 3013 | * @param GetPaid_Form_Item[] $value items. |
3014 | 3014 | */ |
3015 | - public function set_items( $value ) { |
|
3015 | + public function set_items($value) { |
|
3016 | 3016 | |
3017 | 3017 | // Remove existing items. |
3018 | - $this->set_prop( 'items', array() ); |
|
3018 | + $this->set_prop('items', array()); |
|
3019 | 3019 | $this->recurring_item = null; |
3020 | 3020 | |
3021 | 3021 | // Ensure that we have an array. |
3022 | - if ( ! is_array( $value ) ) { |
|
3022 | + if (!is_array($value)) { |
|
3023 | 3023 | return; |
3024 | 3024 | } |
3025 | 3025 | |
3026 | - foreach ( $value as $item ) { |
|
3027 | - $this->add_item( $item ); |
|
3026 | + foreach ($value as $item) { |
|
3027 | + $this->add_item($item); |
|
3028 | 3028 | } |
3029 | 3029 | |
3030 | 3030 | } |
@@ -3035,8 +3035,8 @@ discard block |
||
3035 | 3035 | * @since 1.0.19 |
3036 | 3036 | * @param int $value payment form. |
3037 | 3037 | */ |
3038 | - public function set_payment_form( $value ) { |
|
3039 | - $this->set_prop( 'payment_form', $value ); |
|
3038 | + public function set_payment_form($value) { |
|
3039 | + $this->set_prop('payment_form', $value); |
|
3040 | 3040 | } |
3041 | 3041 | |
3042 | 3042 | /** |
@@ -3045,8 +3045,8 @@ discard block |
||
3045 | 3045 | * @since 1.0.19 |
3046 | 3046 | * @param string $value submission id. |
3047 | 3047 | */ |
3048 | - public function set_submission_id( $value ) { |
|
3049 | - $this->set_prop( 'submission_id', $value ); |
|
3048 | + public function set_submission_id($value) { |
|
3049 | + $this->set_prop('submission_id', $value); |
|
3050 | 3050 | } |
3051 | 3051 | |
3052 | 3052 | /** |
@@ -3055,8 +3055,8 @@ discard block |
||
3055 | 3055 | * @since 1.0.19 |
3056 | 3056 | * @param string $value discount code. |
3057 | 3057 | */ |
3058 | - public function set_discount_code( $value ) { |
|
3059 | - $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
3058 | + public function set_discount_code($value) { |
|
3059 | + $this->set_prop('discount_code', sanitize_text_field($value)); |
|
3060 | 3060 | } |
3061 | 3061 | |
3062 | 3062 | /** |
@@ -3065,8 +3065,8 @@ discard block |
||
3065 | 3065 | * @since 1.0.19 |
3066 | 3066 | * @param string $value gateway. |
3067 | 3067 | */ |
3068 | - public function set_gateway( $value ) { |
|
3069 | - $this->set_prop( 'gateway', $value ); |
|
3068 | + public function set_gateway($value) { |
|
3069 | + $this->set_prop('gateway', $value); |
|
3070 | 3070 | } |
3071 | 3071 | |
3072 | 3072 | /** |
@@ -3075,9 +3075,9 @@ discard block |
||
3075 | 3075 | * @since 1.0.19 |
3076 | 3076 | * @param string $value transaction id. |
3077 | 3077 | */ |
3078 | - public function set_transaction_id( $value ) { |
|
3079 | - if ( ! empty( $value ) ) { |
|
3080 | - $this->set_prop( 'transaction_id', $value ); |
|
3078 | + public function set_transaction_id($value) { |
|
3079 | + if (!empty($value)) { |
|
3080 | + $this->set_prop('transaction_id', $value); |
|
3081 | 3081 | } |
3082 | 3082 | } |
3083 | 3083 | |
@@ -3087,8 +3087,8 @@ discard block |
||
3087 | 3087 | * @since 1.0.19 |
3088 | 3088 | * @param string $value currency id. |
3089 | 3089 | */ |
3090 | - public function set_currency( $value ) { |
|
3091 | - $this->set_prop( 'currency', $value ); |
|
3090 | + public function set_currency($value) { |
|
3091 | + $this->set_prop('currency', $value); |
|
3092 | 3092 | } |
3093 | 3093 | |
3094 | 3094 | /** |
@@ -3097,8 +3097,8 @@ discard block |
||
3097 | 3097 | * @since 1.0.19 |
3098 | 3098 | * @param bool $value value. |
3099 | 3099 | */ |
3100 | - public function set_disable_taxes( $value ) { |
|
3101 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
3100 | + public function set_disable_taxes($value) { |
|
3101 | + $this->set_prop('disable_taxes', (bool) $value); |
|
3102 | 3102 | } |
3103 | 3103 | |
3104 | 3104 | /** |
@@ -3107,8 +3107,8 @@ discard block |
||
3107 | 3107 | * @since 1.0.19 |
3108 | 3108 | * @param string $value subscription id. |
3109 | 3109 | */ |
3110 | - public function set_subscription_id( $value ) { |
|
3111 | - $this->set_prop( 'subscription_id', $value ); |
|
3110 | + public function set_subscription_id($value) { |
|
3111 | + $this->set_prop('subscription_id', $value); |
|
3112 | 3112 | } |
3113 | 3113 | |
3114 | 3114 | /** |
@@ -3117,8 +3117,8 @@ discard block |
||
3117 | 3117 | * @since 1.0.19 |
3118 | 3118 | * @param string $value subscription id. |
3119 | 3119 | */ |
3120 | - public function set_remote_subscription_id( $value ) { |
|
3121 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
3120 | + public function set_remote_subscription_id($value) { |
|
3121 | + $this->set_prop('remote_subscription_id', $value); |
|
3122 | 3122 | } |
3123 | 3123 | |
3124 | 3124 | /* |
@@ -3135,28 +3135,28 @@ discard block |
||
3135 | 3135 | */ |
3136 | 3136 | public function is_parent() { |
3137 | 3137 | $parent = $this->get_parent_id(); |
3138 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
3138 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
3139 | 3139 | } |
3140 | 3140 | |
3141 | 3141 | /** |
3142 | 3142 | * Checks if this is a renewal invoice. |
3143 | 3143 | */ |
3144 | 3144 | public function is_renewal() { |
3145 | - return $this->is_recurring() && ! $this->is_parent(); |
|
3145 | + return $this->is_recurring() && !$this->is_parent(); |
|
3146 | 3146 | } |
3147 | 3147 | |
3148 | 3148 | /** |
3149 | 3149 | * Checks if this is a recurring invoice. |
3150 | 3150 | */ |
3151 | 3151 | public function is_recurring() { |
3152 | - return ! empty( $this->recurring_item ); |
|
3152 | + return !empty($this->recurring_item); |
|
3153 | 3153 | } |
3154 | 3154 | |
3155 | 3155 | /** |
3156 | 3156 | * Checks if this is a taxable invoice. |
3157 | 3157 | */ |
3158 | 3158 | public function is_taxable() { |
3159 | - return ! $this->get_disable_taxes(); |
|
3159 | + return !$this->get_disable_taxes(); |
|
3160 | 3160 | } |
3161 | 3161 | |
3162 | 3162 | /** |
@@ -3170,45 +3170,45 @@ discard block |
||
3170 | 3170 | * Checks to see if the invoice requires payment. |
3171 | 3171 | */ |
3172 | 3172 | public function is_free() { |
3173 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
3173 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
3174 | 3174 | |
3175 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
3175 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
3176 | 3176 | $is_free = false; |
3177 | 3177 | } |
3178 | 3178 | |
3179 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
3179 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
3180 | 3180 | } |
3181 | 3181 | |
3182 | 3182 | /** |
3183 | 3183 | * Checks if the invoice is paid. |
3184 | 3184 | */ |
3185 | 3185 | public function is_paid() { |
3186 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
3187 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
3186 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
3187 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
3188 | 3188 | } |
3189 | 3189 | |
3190 | 3190 | /** |
3191 | 3191 | * Checks if the invoice needs payment. |
3192 | 3192 | */ |
3193 | 3193 | public function needs_payment() { |
3194 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
3195 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
3194 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
3195 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
3196 | 3196 | } |
3197 | 3197 | |
3198 | 3198 | /** |
3199 | 3199 | * Checks if the invoice is refunded. |
3200 | 3200 | */ |
3201 | 3201 | public function is_refunded() { |
3202 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
3203 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
3202 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
3203 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
3204 | 3204 | } |
3205 | 3205 | |
3206 | 3206 | /** |
3207 | 3207 | * Checks if the invoice is held. |
3208 | 3208 | */ |
3209 | 3209 | public function is_held() { |
3210 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3211 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
3210 | + $is_held = $this->has_status('wpi-onhold'); |
|
3211 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3212 | 3212 | } |
3213 | 3213 | |
3214 | 3214 | /** |
@@ -3216,30 +3216,30 @@ discard block |
||
3216 | 3216 | */ |
3217 | 3217 | public function is_due() { |
3218 | 3218 | $due_date = $this->get_due_date(); |
3219 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3219 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3220 | 3220 | } |
3221 | 3221 | |
3222 | 3222 | /** |
3223 | 3223 | * Checks if the invoice is draft. |
3224 | 3224 | */ |
3225 | 3225 | public function is_draft() { |
3226 | - return $this->has_status( 'draft, auto-draft' ); |
|
3226 | + return $this->has_status('draft, auto-draft'); |
|
3227 | 3227 | } |
3228 | 3228 | |
3229 | 3229 | /** |
3230 | 3230 | * Checks if the invoice has a given status. |
3231 | 3231 | */ |
3232 | - public function has_status( $status ) { |
|
3233 | - $status = wpinv_parse_list( $status ); |
|
3234 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3232 | + public function has_status($status) { |
|
3233 | + $status = wpinv_parse_list($status); |
|
3234 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3235 | 3235 | } |
3236 | 3236 | |
3237 | 3237 | /** |
3238 | 3238 | * Checks if the invoice is of a given type. |
3239 | 3239 | */ |
3240 | - public function is_type( $type ) { |
|
3241 | - $type = wpinv_parse_list( $type ); |
|
3242 | - return in_array( $this->get_type(), $type ); |
|
3240 | + public function is_type($type) { |
|
3241 | + $type = wpinv_parse_list($type); |
|
3242 | + return in_array($this->get_type(), $type); |
|
3243 | 3243 | } |
3244 | 3244 | |
3245 | 3245 | /** |
@@ -3271,8 +3271,8 @@ discard block |
||
3271 | 3271 | * |
3272 | 3272 | */ |
3273 | 3273 | public function is_initial_free() { |
3274 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3275 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3274 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3275 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3276 | 3276 | } |
3277 | 3277 | |
3278 | 3278 | /** |
@@ -3282,11 +3282,11 @@ discard block |
||
3282 | 3282 | public function item_has_free_trial() { |
3283 | 3283 | |
3284 | 3284 | // Ensure we have a recurring item. |
3285 | - if ( ! $this->is_recurring() ) { |
|
3285 | + if (!$this->is_recurring()) { |
|
3286 | 3286 | return false; |
3287 | 3287 | } |
3288 | 3288 | |
3289 | - $item = $this->get_recurring( true ); |
|
3289 | + $item = $this->get_recurring(true); |
|
3290 | 3290 | return $item->has_free_trial(); |
3291 | 3291 | } |
3292 | 3292 | |
@@ -3294,7 +3294,7 @@ discard block |
||
3294 | 3294 | * Check if the free trial is a result of a discount. |
3295 | 3295 | */ |
3296 | 3296 | public function is_free_trial_from_discount() { |
3297 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3297 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3298 | 3298 | } |
3299 | 3299 | |
3300 | 3300 | /** |
@@ -3302,12 +3302,12 @@ discard block |
||
3302 | 3302 | */ |
3303 | 3303 | public function discount_first_payment_only() { |
3304 | 3304 | |
3305 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
3306 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
3305 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
3306 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
3307 | 3307 | return true; |
3308 | 3308 | } |
3309 | 3309 | |
3310 | - return ! $discount->get_is_recurring(); |
|
3310 | + return !$discount->get_is_recurring(); |
|
3311 | 3311 | } |
3312 | 3312 | |
3313 | 3313 | /* |
@@ -3325,23 +3325,23 @@ discard block |
||
3325 | 3325 | * @param GetPaid_Form_Item|array $item |
3326 | 3326 | * @return WP_Error|Bool |
3327 | 3327 | */ |
3328 | - public function add_item( $item ) { |
|
3328 | + public function add_item($item) { |
|
3329 | 3329 | |
3330 | - if ( is_array( $item ) ) { |
|
3331 | - $item = $this->process_array_item( $item ); |
|
3330 | + if (is_array($item)) { |
|
3331 | + $item = $this->process_array_item($item); |
|
3332 | 3332 | } |
3333 | 3333 | |
3334 | - if ( is_numeric( $item ) ) { |
|
3335 | - $item = new GetPaid_Form_Item( $item ); |
|
3334 | + if (is_numeric($item)) { |
|
3335 | + $item = new GetPaid_Form_Item($item); |
|
3336 | 3336 | } |
3337 | 3337 | |
3338 | 3338 | // Make sure that it is available for purchase. |
3339 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3340 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3339 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3340 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3341 | 3341 | } |
3342 | 3342 | |
3343 | 3343 | // Do we have a recurring item? |
3344 | - if ( $item->is_recurring() ) { |
|
3344 | + if ($item->is_recurring()) { |
|
3345 | 3345 | $this->recurring_item = $item->get_id(); |
3346 | 3346 | } |
3347 | 3347 | |
@@ -3349,9 +3349,9 @@ discard block |
||
3349 | 3349 | $item->invoice_id = (int) $this->get_id(); |
3350 | 3350 | |
3351 | 3351 | // Remove duplicates. |
3352 | - $this->remove_item( $item->get_id() ); |
|
3352 | + $this->remove_item($item->get_id()); |
|
3353 | 3353 | |
3354 | - if ( 0 == $item->get_quantity() ) { |
|
3354 | + if (0 == $item->get_quantity()) { |
|
3355 | 3355 | return; |
3356 | 3356 | } |
3357 | 3357 | |
@@ -3361,7 +3361,7 @@ discard block |
||
3361 | 3361 | // Add new item. |
3362 | 3362 | $items[] = $item; |
3363 | 3363 | |
3364 | - $this->set_prop( 'items', $items ); |
|
3364 | + $this->set_prop('items', $items); |
|
3365 | 3365 | |
3366 | 3366 | return true; |
3367 | 3367 | } |
@@ -3372,26 +3372,26 @@ discard block |
||
3372 | 3372 | * @since 1.0.19 |
3373 | 3373 | * @return GetPaid_Form_Item |
3374 | 3374 | */ |
3375 | - protected function process_array_item( $array ) { |
|
3375 | + protected function process_array_item($array) { |
|
3376 | 3376 | |
3377 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3378 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3377 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3378 | + $item = new GetPaid_Form_Item($item_id); |
|
3379 | 3379 | |
3380 | 3380 | // Set item data. |
3381 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
3382 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3381 | + foreach (array('name', 'price', 'description') as $key) { |
|
3382 | + if (isset($array["item_$key"])) { |
|
3383 | 3383 | $method = "set_$key"; |
3384 | - $item->$method( $array[ "item_$key" ] ); |
|
3384 | + $item->$method($array["item_$key"]); |
|
3385 | 3385 | } |
3386 | 3386 | } |
3387 | 3387 | |
3388 | - if ( isset( $array['quantity'] ) ) { |
|
3389 | - $item->set_quantity( $array['quantity'] ); |
|
3388 | + if (isset($array['quantity'])) { |
|
3389 | + $item->set_quantity($array['quantity']); |
|
3390 | 3390 | } |
3391 | 3391 | |
3392 | 3392 | // Set item meta. |
3393 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3394 | - $item->set_item_meta( $array['meta'] ); |
|
3393 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3394 | + $item->set_item_meta($array['meta']); |
|
3395 | 3395 | } |
3396 | 3396 | |
3397 | 3397 | return $item; |
@@ -3404,10 +3404,10 @@ discard block |
||
3404 | 3404 | * @since 1.0.19 |
3405 | 3405 | * @return GetPaid_Form_Item|null |
3406 | 3406 | */ |
3407 | - public function get_item( $item_id ) { |
|
3407 | + public function get_item($item_id) { |
|
3408 | 3408 | |
3409 | - foreach ( $this->get_items() as $item ) { |
|
3410 | - if ( (int) $item_id == $item->get_id() ) { |
|
3409 | + foreach ($this->get_items() as $item) { |
|
3410 | + if ((int) $item_id == $item->get_id()) { |
|
3411 | 3411 | return $item; |
3412 | 3412 | } |
3413 | 3413 | } |
@@ -3420,16 +3420,16 @@ discard block |
||
3420 | 3420 | * |
3421 | 3421 | * @since 1.0.19 |
3422 | 3422 | */ |
3423 | - public function remove_item( $item_id ) { |
|
3423 | + public function remove_item($item_id) { |
|
3424 | 3424 | $items = $this->get_items(); |
3425 | 3425 | $item_id = (int) $item_id; |
3426 | 3426 | |
3427 | - foreach ( $items as $index => $item ) { |
|
3428 | - if ( (int) $item_id == $item->get_id() ) { |
|
3429 | - unset( $items[ $index ] ); |
|
3430 | - $this->set_prop( 'items', $items ); |
|
3427 | + foreach ($items as $index => $item) { |
|
3428 | + if ((int) $item_id == $item->get_id()) { |
|
3429 | + unset($items[$index]); |
|
3430 | + $this->set_prop('items', $items); |
|
3431 | 3431 | |
3432 | - if ( $item_id == $this->recurring_item ) { |
|
3432 | + if ($item_id == $this->recurring_item) { |
|
3433 | 3433 | $this->recurring_item = null; |
3434 | 3434 | } |
3435 | 3435 | |
@@ -3444,11 +3444,11 @@ discard block |
||
3444 | 3444 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3445 | 3445 | * @since 1.0.19 |
3446 | 3446 | */ |
3447 | - public function add_fee( $fee ) { |
|
3447 | + public function add_fee($fee) { |
|
3448 | 3448 | |
3449 | 3449 | $fees = $this->get_fees(); |
3450 | - $fees[ $fee['name'] ] = $fee; |
|
3451 | - $this->set_prop( 'fees', $fees ); |
|
3450 | + $fees[$fee['name']] = $fee; |
|
3451 | + $this->set_prop('fees', $fees); |
|
3452 | 3452 | |
3453 | 3453 | } |
3454 | 3454 | |
@@ -3457,9 +3457,9 @@ discard block |
||
3457 | 3457 | * |
3458 | 3458 | * @since 1.0.19 |
3459 | 3459 | */ |
3460 | - public function get_fee( $fee ) { |
|
3460 | + public function get_fee($fee) { |
|
3461 | 3461 | $fees = $this->get_fees(); |
3462 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3462 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3463 | 3463 | } |
3464 | 3464 | |
3465 | 3465 | /** |
@@ -3467,11 +3467,11 @@ discard block |
||
3467 | 3467 | * |
3468 | 3468 | * @since 1.0.19 |
3469 | 3469 | */ |
3470 | - public function remove_fee( $fee ) { |
|
3470 | + public function remove_fee($fee) { |
|
3471 | 3471 | $fees = $this->get_fees(); |
3472 | - if ( isset( $fees[ $fee ] ) ) { |
|
3473 | - unset( $fees[ $fee ] ); |
|
3474 | - $this->set_prop( 'fees', $fees ); |
|
3472 | + if (isset($fees[$fee])) { |
|
3473 | + unset($fees[$fee]); |
|
3474 | + $this->set_prop('fees', $fees); |
|
3475 | 3475 | } |
3476 | 3476 | } |
3477 | 3477 | |
@@ -3481,11 +3481,11 @@ discard block |
||
3481 | 3481 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
3482 | 3482 | * @since 1.0.19 |
3483 | 3483 | */ |
3484 | - public function add_discount( $discount ) { |
|
3484 | + public function add_discount($discount) { |
|
3485 | 3485 | |
3486 | 3486 | $discounts = $this->get_discounts(); |
3487 | - $discounts[ $discount['name'] ] = $discount; |
|
3488 | - $this->set_prop( 'discounts', $discounts ); |
|
3487 | + $discounts[$discount['name']] = $discount; |
|
3488 | + $this->set_prop('discounts', $discounts); |
|
3489 | 3489 | |
3490 | 3490 | } |
3491 | 3491 | |
@@ -3495,15 +3495,15 @@ discard block |
||
3495 | 3495 | * @since 1.0.19 |
3496 | 3496 | * @return float |
3497 | 3497 | */ |
3498 | - public function get_discount( $discount = false ) { |
|
3498 | + public function get_discount($discount = false) { |
|
3499 | 3499 | |
3500 | 3500 | // Backwards compatibilty. |
3501 | - if ( empty( $discount ) ) { |
|
3501 | + if (empty($discount)) { |
|
3502 | 3502 | return $this->get_total_discount(); |
3503 | 3503 | } |
3504 | 3504 | |
3505 | 3505 | $discounts = $this->get_discounts(); |
3506 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3506 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3507 | 3507 | } |
3508 | 3508 | |
3509 | 3509 | /** |
@@ -3511,15 +3511,15 @@ discard block |
||
3511 | 3511 | * |
3512 | 3512 | * @since 1.0.19 |
3513 | 3513 | */ |
3514 | - public function remove_discount( $discount ) { |
|
3514 | + public function remove_discount($discount) { |
|
3515 | 3515 | $discounts = $this->get_discounts(); |
3516 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3517 | - unset( $discounts[ $discount ] ); |
|
3518 | - $this->set_prop( 'discounts', $discounts ); |
|
3516 | + if (isset($discounts[$discount])) { |
|
3517 | + unset($discounts[$discount]); |
|
3518 | + $this->set_prop('discounts', $discounts); |
|
3519 | 3519 | } |
3520 | 3520 | |
3521 | - if ( 'discount_code' == $discount ) { |
|
3522 | - foreach ( $this->get_items() as $item ) { |
|
3521 | + if ('discount_code' == $discount) { |
|
3522 | + foreach ($this->get_items() as $item) { |
|
3523 | 3523 | $item->item_discount = 0; |
3524 | 3524 | $item->recurring_item_discount = 0; |
3525 | 3525 | } |
@@ -3532,12 +3532,12 @@ discard block |
||
3532 | 3532 | * |
3533 | 3533 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
3534 | 3534 | */ |
3535 | - public function add_tax( $tax ) { |
|
3536 | - if ( $this->is_taxable() ) { |
|
3535 | + public function add_tax($tax) { |
|
3536 | + if ($this->is_taxable()) { |
|
3537 | 3537 | |
3538 | - $taxes = $this->get_taxes(); |
|
3539 | - $taxes[ $tax['name'] ] = $tax; |
|
3540 | - $this->set_prop( 'taxes', $tax ); |
|
3538 | + $taxes = $this->get_taxes(); |
|
3539 | + $taxes[$tax['name']] = $tax; |
|
3540 | + $this->set_prop('taxes', $tax); |
|
3541 | 3541 | |
3542 | 3542 | } |
3543 | 3543 | } |
@@ -3547,15 +3547,15 @@ discard block |
||
3547 | 3547 | * |
3548 | 3548 | * @since 1.0.19 |
3549 | 3549 | */ |
3550 | - public function get_tax( $tax = null ) { |
|
3550 | + public function get_tax($tax = null) { |
|
3551 | 3551 | |
3552 | 3552 | // Backwards compatility. |
3553 | - if ( empty( $tax ) ) { |
|
3553 | + if (empty($tax)) { |
|
3554 | 3554 | return $this->get_total_tax(); |
3555 | 3555 | } |
3556 | 3556 | |
3557 | 3557 | $taxes = $this->get_taxes(); |
3558 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3558 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3559 | 3559 | } |
3560 | 3560 | |
3561 | 3561 | /** |
@@ -3563,11 +3563,11 @@ discard block |
||
3563 | 3563 | * |
3564 | 3564 | * @since 1.0.19 |
3565 | 3565 | */ |
3566 | - public function remove_tax( $tax ) { |
|
3566 | + public function remove_tax($tax) { |
|
3567 | 3567 | $taxes = $this->get_taxes(); |
3568 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3569 | - unset( $taxes[ $tax ] ); |
|
3570 | - $this->set_prop( 'taxes', $taxes ); |
|
3568 | + if (isset($taxes[$tax])) { |
|
3569 | + unset($taxes[$tax]); |
|
3570 | + $this->set_prop('taxes', $taxes); |
|
3571 | 3571 | } |
3572 | 3572 | } |
3573 | 3573 | |
@@ -3578,22 +3578,22 @@ discard block |
||
3578 | 3578 | * @return float The recalculated subtotal |
3579 | 3579 | */ |
3580 | 3580 | public function recalculate_subtotal() { |
3581 | - $items = $this->get_items(); |
|
3581 | + $items = $this->get_items(); |
|
3582 | 3582 | $subtotal = 0; |
3583 | 3583 | $recurring = 0; |
3584 | 3584 | |
3585 | - foreach ( $items as $item ) { |
|
3586 | - $subtotal += $item->get_sub_total( 'edit' ); |
|
3587 | - $recurring += $item->get_recurring_sub_total( 'edit' ); |
|
3585 | + foreach ($items as $item) { |
|
3586 | + $subtotal += $item->get_sub_total('edit'); |
|
3587 | + $recurring += $item->get_recurring_sub_total('edit'); |
|
3588 | 3588 | } |
3589 | 3589 | |
3590 | - if ( wpinv_prices_include_tax() ) { |
|
3591 | - $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
3592 | - $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
3590 | + if (wpinv_prices_include_tax()) { |
|
3591 | + $subtotal = max(0, $subtotal - $this->totals['tax']['initial']); |
|
3592 | + $recurring = max(0, $recurring - $this->totals['tax']['recurring']); |
|
3593 | 3593 | } |
3594 | 3594 | |
3595 | 3595 | $current = $this->is_renewal() ? $recurring : $subtotal; |
3596 | - $this->set_subtotal( $current ); |
|
3596 | + $this->set_subtotal($current); |
|
3597 | 3597 | |
3598 | 3598 | $this->totals['subtotal'] = array( |
3599 | 3599 | 'initial' => $subtotal, |
@@ -3614,14 +3614,14 @@ discard block |
||
3614 | 3614 | $discount = 0; |
3615 | 3615 | $recurring = 0; |
3616 | 3616 | |
3617 | - foreach ( $discounts as $data ) { |
|
3618 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
3619 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
3617 | + foreach ($discounts as $data) { |
|
3618 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
3619 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
3620 | 3620 | } |
3621 | 3621 | |
3622 | 3622 | $current = $this->is_renewal() ? $recurring : $discount; |
3623 | 3623 | |
3624 | - $this->set_total_discount( $current ); |
|
3624 | + $this->set_total_discount($current); |
|
3625 | 3625 | |
3626 | 3626 | $this->totals['discount'] = array( |
3627 | 3627 | 'initial' => $discount, |
@@ -3642,13 +3642,13 @@ discard block |
||
3642 | 3642 | |
3643 | 3643 | // Maybe disable taxes. |
3644 | 3644 | $vat_number = $this->get_vat_number(); |
3645 | - $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
3645 | + $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number); |
|
3646 | 3646 | |
3647 | - if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
3647 | + if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
3648 | 3648 | $skip_tax = false; |
3649 | 3649 | } |
3650 | 3650 | |
3651 | - if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
3651 | + if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) { |
|
3652 | 3652 | |
3653 | 3653 | $this->totals['tax'] = array( |
3654 | 3654 | 'initial' => 0, |
@@ -3657,38 +3657,38 @@ discard block |
||
3657 | 3657 | |
3658 | 3658 | $this->tax_rate = 0; |
3659 | 3659 | |
3660 | - $this->set_taxes( array() ); |
|
3660 | + $this->set_taxes(array()); |
|
3661 | 3661 | $current = 0; |
3662 | 3662 | } else { |
3663 | 3663 | |
3664 | 3664 | $item_taxes = array(); |
3665 | 3665 | |
3666 | - foreach ( $this->get_items() as $item ) { |
|
3667 | - $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
3668 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
3669 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
3670 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
3671 | - foreach ( $taxes as $name => $amount ) { |
|
3672 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
3673 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
3674 | - |
|
3675 | - if ( ! isset( $item_taxes[ $name ] ) ) { |
|
3676 | - $item_taxes[ $name ] = $tax; |
|
3666 | + foreach ($this->get_items() as $item) { |
|
3667 | + $rates = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state()); |
|
3668 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
3669 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
3670 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
3671 | + foreach ($taxes as $name => $amount) { |
|
3672 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
3673 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
3674 | + |
|
3675 | + if (!isset($item_taxes[$name])) { |
|
3676 | + $item_taxes[$name] = $tax; |
|
3677 | 3677 | continue; |
3678 | 3678 | } |
3679 | 3679 | |
3680 | - $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
3681 | - $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
3680 | + $item_taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
3681 | + $item_taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
3682 | 3682 | |
3683 | 3683 | } |
3684 | 3684 | |
3685 | 3685 | } |
3686 | 3686 | |
3687 | - $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
3688 | - $this->set_taxes( $item_taxes ); |
|
3687 | + $item_taxes = array_replace($this->get_taxes(), $item_taxes); |
|
3688 | + $this->set_taxes($item_taxes); |
|
3689 | 3689 | |
3690 | - $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
3691 | - $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
3690 | + $initial_tax = array_sum(wp_list_pluck($item_taxes, 'initial_tax')); |
|
3691 | + $recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax')); |
|
3692 | 3692 | |
3693 | 3693 | $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
3694 | 3694 | |
@@ -3699,7 +3699,7 @@ discard block |
||
3699 | 3699 | |
3700 | 3700 | } |
3701 | 3701 | |
3702 | - $this->set_total_tax( $current ); |
|
3702 | + $this->set_total_tax($current); |
|
3703 | 3703 | |
3704 | 3704 | return $current; |
3705 | 3705 | |
@@ -3716,20 +3716,20 @@ discard block |
||
3716 | 3716 | $fee = 0; |
3717 | 3717 | $recurring = 0; |
3718 | 3718 | |
3719 | - foreach ( $fees as $data ) { |
|
3720 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
3721 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
3719 | + foreach ($fees as $data) { |
|
3720 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
3721 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
3722 | 3722 | } |
3723 | 3723 | |
3724 | 3724 | $current = $this->is_renewal() ? $recurring : $fee; |
3725 | - $this->set_total_fees( $current ); |
|
3725 | + $this->set_total_fees($current); |
|
3726 | 3726 | |
3727 | 3727 | $this->totals['fee'] = array( |
3728 | 3728 | 'initial' => $fee, |
3729 | 3729 | 'recurring' => $recurring, |
3730 | 3730 | ); |
3731 | 3731 | |
3732 | - $this->set_total_fees( $fee ); |
|
3732 | + $this->set_total_fees($fee); |
|
3733 | 3733 | return $current; |
3734 | 3734 | } |
3735 | 3735 | |
@@ -3744,7 +3744,7 @@ discard block |
||
3744 | 3744 | $this->recalculate_total_discount(); |
3745 | 3745 | $this->recalculate_total_tax(); |
3746 | 3746 | $this->recalculate_subtotal(); |
3747 | - $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) ); |
|
3747 | + $this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit')); |
|
3748 | 3748 | return $this->get_total(); |
3749 | 3749 | } |
3750 | 3750 | |
@@ -3753,7 +3753,7 @@ discard block |
||
3753 | 3753 | */ |
3754 | 3754 | public function recalculate_totals() { |
3755 | 3755 | $this->recalculate_total(); |
3756 | - $this->save( true ); |
|
3756 | + $this->save(true); |
|
3757 | 3757 | return $this; |
3758 | 3758 | } |
3759 | 3759 | |
@@ -3771,8 +3771,8 @@ discard block |
||
3771 | 3771 | * @return int|false The new note's ID on success, false on failure. |
3772 | 3772 | * |
3773 | 3773 | */ |
3774 | - public function add_system_note( $note ) { |
|
3775 | - return $this->add_note( $note, false, false, true ); |
|
3774 | + public function add_system_note($note) { |
|
3775 | + return $this->add_note($note, false, false, true); |
|
3776 | 3776 | } |
3777 | 3777 | |
3778 | 3778 | /** |
@@ -3782,10 +3782,10 @@ discard block |
||
3782 | 3782 | * @return int|false The new note's ID on success, false on failure. |
3783 | 3783 | * |
3784 | 3784 | */ |
3785 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3785 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3786 | 3786 | |
3787 | 3787 | // Bail if no note specified or this invoice is not yet saved. |
3788 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3788 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3789 | 3789 | return false; |
3790 | 3790 | } |
3791 | 3791 | |
@@ -3793,23 +3793,23 @@ discard block |
||
3793 | 3793 | $author_email = '[email protected]'; |
3794 | 3794 | |
3795 | 3795 | // If this is an admin comment or it has been added by the user. |
3796 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3797 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3796 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3797 | + $user = get_user_by('id', get_current_user_id()); |
|
3798 | 3798 | $author = $user->display_name; |
3799 | 3799 | $author_email = $user->user_email; |
3800 | 3800 | } |
3801 | 3801 | |
3802 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3802 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3803 | 3803 | |
3804 | 3804 | } |
3805 | 3805 | |
3806 | 3806 | /** |
3807 | 3807 | * Generates a unique key for the invoice. |
3808 | 3808 | */ |
3809 | - public function generate_key( $string = '' ) { |
|
3810 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3809 | + public function generate_key($string = '') { |
|
3810 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3811 | 3811 | return strtolower( |
3812 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3812 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3813 | 3813 | ); |
3814 | 3814 | } |
3815 | 3815 | |
@@ -3819,11 +3819,11 @@ discard block |
||
3819 | 3819 | public function generate_number() { |
3820 | 3820 | $number = $this->get_id(); |
3821 | 3821 | |
3822 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3823 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3822 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3823 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3824 | 3824 | } |
3825 | 3825 | |
3826 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3826 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3827 | 3827 | |
3828 | 3828 | } |
3829 | 3829 | |
@@ -3836,55 +3836,55 @@ discard block |
||
3836 | 3836 | // Reset status transition variable. |
3837 | 3837 | $this->status_transition = false; |
3838 | 3838 | |
3839 | - if ( $status_transition ) { |
|
3839 | + if ($status_transition) { |
|
3840 | 3840 | try { |
3841 | 3841 | |
3842 | 3842 | // Fire a hook for the status change. |
3843 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3843 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3844 | 3844 | |
3845 | 3845 | // @deprecated this is deprecated and will be removed in the future. |
3846 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3846 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3847 | 3847 | |
3848 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3848 | + if (!empty($status_transition['from'])) { |
|
3849 | 3849 | |
3850 | 3850 | /* translators: 1: old invoice status 2: new invoice status */ |
3851 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3851 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
3852 | 3852 | |
3853 | 3853 | // Fire another hook. |
3854 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3855 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3854 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3855 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3856 | 3856 | |
3857 | 3857 | // @deprecated this is deprecated and will be removed in the future. |
3858 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3858 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3859 | 3859 | |
3860 | 3860 | // Note the transition occurred. |
3861 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
3861 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
3862 | 3862 | |
3863 | 3863 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3864 | 3864 | if ( |
3865 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3866 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3865 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3866 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3867 | 3867 | ) { |
3868 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3868 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3869 | 3869 | } |
3870 | 3870 | |
3871 | 3871 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3872 | 3872 | if ( |
3873 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3874 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3873 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3874 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3875 | 3875 | ) { |
3876 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3876 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3877 | 3877 | } |
3878 | 3878 | } else { |
3879 | 3879 | /* translators: %s: new invoice status */ |
3880 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3880 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
3881 | 3881 | |
3882 | 3882 | // Note the transition occurred. |
3883 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3883 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3884 | 3884 | |
3885 | 3885 | } |
3886 | - } catch ( Exception $e ) { |
|
3887 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3886 | + } catch (Exception $e) { |
|
3887 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3888 | 3888 | } |
3889 | 3889 | } |
3890 | 3890 | } |
@@ -3892,13 +3892,13 @@ discard block |
||
3892 | 3892 | /** |
3893 | 3893 | * Updates an invoice status. |
3894 | 3894 | */ |
3895 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3895 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3896 | 3896 | |
3897 | 3897 | // Fires before updating a status. |
3898 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3898 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3899 | 3899 | |
3900 | 3900 | // Update the status. |
3901 | - $this->set_status( $new_status, $note, $manual ); |
|
3901 | + $this->set_status($new_status, $note, $manual); |
|
3902 | 3902 | |
3903 | 3903 | // Save the order. |
3904 | 3904 | return $this->save(); |
@@ -3909,18 +3909,18 @@ discard block |
||
3909 | 3909 | * @deprecated |
3910 | 3910 | */ |
3911 | 3911 | public function refresh_item_ids() { |
3912 | - $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) ); |
|
3913 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3912 | + $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id'))); |
|
3913 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3914 | 3914 | } |
3915 | 3915 | |
3916 | 3916 | /** |
3917 | 3917 | * @deprecated |
3918 | 3918 | */ |
3919 | - public function update_items( $temp = false ) { |
|
3919 | + public function update_items($temp = false) { |
|
3920 | 3920 | |
3921 | - $this->set_items( $this->get_items() ); |
|
3921 | + $this->set_items($this->get_items()); |
|
3922 | 3922 | |
3923 | - if ( ! $temp ) { |
|
3923 | + if (!$temp) { |
|
3924 | 3924 | $this->save(); |
3925 | 3925 | } |
3926 | 3926 | |
@@ -3934,11 +3934,11 @@ discard block |
||
3934 | 3934 | |
3935 | 3935 | $discount_code = $this->get_discount_code(); |
3936 | 3936 | |
3937 | - if ( empty( $discount_code ) ) { |
|
3937 | + if (empty($discount_code)) { |
|
3938 | 3938 | return false; |
3939 | 3939 | } |
3940 | 3940 | |
3941 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3941 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3942 | 3942 | |
3943 | 3943 | // Ensure it is active. |
3944 | 3944 | return $discount->exists(); |
@@ -3949,7 +3949,7 @@ discard block |
||
3949 | 3949 | * Refunds an invoice. |
3950 | 3950 | */ |
3951 | 3951 | public function refund() { |
3952 | - $this->set_status( 'wpi-refunded' ); |
|
3952 | + $this->set_status('wpi-refunded'); |
|
3953 | 3953 | $this->save(); |
3954 | 3954 | } |
3955 | 3955 | |
@@ -3958,53 +3958,53 @@ discard block |
||
3958 | 3958 | * |
3959 | 3959 | * @param string $transaction_id |
3960 | 3960 | */ |
3961 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3961 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3962 | 3962 | |
3963 | 3963 | // Set the transaction id. |
3964 | - if ( empty( $transaction_id ) ) { |
|
3964 | + if (empty($transaction_id)) { |
|
3965 | 3965 | $transaction_id = $this->generate_key('trans_'); |
3966 | 3966 | } |
3967 | 3967 | |
3968 | - if ( ! $this->get_transaction_id() ) { |
|
3969 | - $this->set_transaction_id( $transaction_id ); |
|
3968 | + if (!$this->get_transaction_id()) { |
|
3969 | + $this->set_transaction_id($transaction_id); |
|
3970 | 3970 | } |
3971 | 3971 | |
3972 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3972 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3973 | 3973 | return $this->save(); |
3974 | 3974 | } |
3975 | 3975 | |
3976 | 3976 | // Set the completed date. |
3977 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3977 | + $this->set_date_completed(current_time('mysql')); |
|
3978 | 3978 | |
3979 | 3979 | // Set the new status. |
3980 | - $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
3981 | - if ( $this->is_renewal() || ! $this->is_parent() ) { |
|
3980 | + $gateway = sanitize_text_field($this->get_gateway_title()); |
|
3981 | + if ($this->is_renewal() || !$this->is_parent()) { |
|
3982 | 3982 | |
3983 | - $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
3984 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
3983 | + $_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway); |
|
3984 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
3985 | 3985 | |
3986 | - if ( 'none' == $this->get_gateway() ) { |
|
3986 | + if ('none' == $this->get_gateway()) { |
|
3987 | 3987 | $_note = $note; |
3988 | 3988 | } |
3989 | 3989 | |
3990 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3990 | + $this->set_status('wpi-renewal', $_note); |
|
3991 | 3991 | |
3992 | 3992 | } else { |
3993 | 3993 | |
3994 | - $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
3995 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
3994 | + $_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway); |
|
3995 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
3996 | 3996 | |
3997 | - if ( 'none' == $this->get_gateway() ) { |
|
3997 | + if ('none' == $this->get_gateway()) { |
|
3998 | 3998 | $_note = $note; |
3999 | 3999 | } |
4000 | 4000 | |
4001 | - $this->set_status( 'publish', $_note ); |
|
4001 | + $this->set_status('publish', $_note); |
|
4002 | 4002 | |
4003 | 4003 | } |
4004 | 4004 | |
4005 | 4005 | // Set checkout mode. |
4006 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
4007 | - $this->set_mode( $mode ); |
|
4006 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
4007 | + $this->set_mode($mode); |
|
4008 | 4008 | |
4009 | 4009 | // Save the invoice. |
4010 | 4010 | $this->save(); |
@@ -4029,9 +4029,9 @@ discard block |
||
4029 | 4029 | * Clears the subscription's cache. |
4030 | 4030 | */ |
4031 | 4031 | public function clear_cache() { |
4032 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
4033 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
4034 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
4032 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
4033 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
4034 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
4035 | 4035 | } |
4036 | 4036 | |
4037 | 4037 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 2.0.0 |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * GetPaid REST reports controller class. |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @see register_rest_route() |
48 | 48 | */ |
49 | - public function register_namespace_routes( $namespace ) { |
|
49 | + public function register_namespace_routes($namespace) { |
|
50 | 50 | |
51 | 51 | // Get sales report. |
52 | 52 | register_rest_route( |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | array( |
56 | 56 | array( |
57 | 57 | 'methods' => WP_REST_Server::READABLE, |
58 | - 'callback' => array( $this, 'get_items' ), |
|
59 | - 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
58 | + 'callback' => array($this, 'get_items'), |
|
59 | + 'permission_callback' => array($this, 'get_items_permissions_check'), |
|
60 | 60 | 'args' => $this->get_collection_params(), |
61 | 61 | ), |
62 | - 'schema' => array( $this, 'get_public_item_schema' ), |
|
62 | + 'schema' => array($this, 'get_public_item_schema'), |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | * @param WP_REST_Request $request Full data about the request. |
73 | 73 | * @return WP_Error|boolean |
74 | 74 | */ |
75 | - public function get_items_permissions_check( $request ) { |
|
75 | + public function get_items_permissions_check($request) { |
|
76 | 76 | |
77 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
78 | - return new WP_Error( 'rest_cannot_view', __( 'Sorry, you cannot list resources.', 'invoicing' ), array( 'status' => rest_authorization_required_code() ) ); |
|
77 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
78 | + return new WP_Error('rest_cannot_view', __('Sorry, you cannot list resources.', 'invoicing'), array('status' => rest_authorization_required_code())); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | return true; |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * @param WP_REST_Request $request |
88 | 88 | * @return array|WP_Error |
89 | 89 | */ |
90 | - public function get_items( $request ) { |
|
90 | + public function get_items($request) { |
|
91 | 91 | $data = array(); |
92 | - $item = $this->prepare_item_for_response( null, $request ); |
|
93 | - $data[] = $this->prepare_response_for_collection( $item ); |
|
92 | + $item = $this->prepare_item_for_response(null, $request); |
|
93 | + $data[] = $this->prepare_response_for_collection($item); |
|
94 | 94 | |
95 | - return rest_ensure_response( $data ); |
|
95 | + return rest_ensure_response($data); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -102,166 +102,166 @@ discard block |
||
102 | 102 | * @param WP_REST_Request $request Request object. |
103 | 103 | * @return WP_REST_Response $response Response data. |
104 | 104 | */ |
105 | - public function prepare_item_for_response( $_, $request ) { |
|
105 | + public function prepare_item_for_response($_, $request) { |
|
106 | 106 | |
107 | 107 | // Set report range. |
108 | - $this->report_range = $this->get_date_range( $request ); |
|
108 | + $this->report_range = $this->get_date_range($request); |
|
109 | 109 | |
110 | 110 | $report_data = $this->get_report_data(); |
111 | 111 | $period_totals = array(); |
112 | 112 | |
113 | 113 | // Setup period totals by ensuring each period in the interval has data. |
114 | - $start_date = strtotime( $this->report_range['after'] ) + DAY_IN_SECONDS; |
|
114 | + $start_date = strtotime($this->report_range['after']) + DAY_IN_SECONDS; |
|
115 | 115 | |
116 | - if ( 'month' === $this->groupby ) { |
|
117 | - $start_date = strtotime( date( 'Y-m-01', $start_date ) ); |
|
116 | + if ('month' === $this->groupby) { |
|
117 | + $start_date = strtotime(date('Y-m-01', $start_date)); |
|
118 | 118 | } |
119 | 119 | |
120 | - for ( $i = 0; $i < $this->interval; $i++ ) { |
|
120 | + for ($i = 0; $i < $this->interval; $i++) { |
|
121 | 121 | |
122 | - switch ( $this->groupby ) { |
|
122 | + switch ($this->groupby) { |
|
123 | 123 | case 'day' : |
124 | - $time = date( 'Y-m-d', strtotime( "+{$i} DAY", $start_date ) ); |
|
124 | + $time = date('Y-m-d', strtotime("+{$i} DAY", $start_date)); |
|
125 | 125 | break; |
126 | 126 | default : |
127 | - $time = date( 'Y-m', strtotime( "+{$i} MONTH", $start_date ) ); |
|
127 | + $time = date('Y-m', strtotime("+{$i} MONTH", $start_date)); |
|
128 | 128 | break; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // Set the defaults for each period. |
132 | - $period_totals[ $time ] = array( |
|
132 | + $period_totals[$time] = array( |
|
133 | 133 | 'invoices' => 0, |
134 | 134 | 'items' => 0, |
135 | 135 | 'refunded_items' => 0, |
136 | - 'refunded_tax' => wpinv_round_amount( 0.00 ), |
|
137 | - 'subtotal' => wpinv_round_amount( 0.00 ), |
|
138 | - 'refunded_subtotal' => wpinv_round_amount( 0.00 ), |
|
139 | - 'refunded_fees' => wpinv_round_amount( 0.00 ), |
|
140 | - 'discount' => wpinv_round_amount( 0.00 ), |
|
136 | + 'refunded_tax' => wpinv_round_amount(0.00), |
|
137 | + 'subtotal' => wpinv_round_amount(0.00), |
|
138 | + 'refunded_subtotal' => wpinv_round_amount(0.00), |
|
139 | + 'refunded_fees' => wpinv_round_amount(0.00), |
|
140 | + 'discount' => wpinv_round_amount(0.00), |
|
141 | 141 | ); |
142 | 142 | |
143 | - foreach( array_keys( wpinv_get_report_graphs() ) as $key ) { |
|
144 | - if ( ! isset( $period_totals[ $time ][ $key ] ) ) { |
|
145 | - $period_totals[ $time ][ $key ] = wpinv_round_amount( 0.00 ); |
|
143 | + foreach (array_keys(wpinv_get_report_graphs()) as $key) { |
|
144 | + if (!isset($period_totals[$time][$key])) { |
|
145 | + $period_totals[$time][$key] = wpinv_round_amount(0.00); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | 149 | } |
150 | 150 | |
151 | 151 | // add total sales, total invoice count, total tax for each period |
152 | - $date_format = ( 'day' === $this->groupby ) ? 'Y-m-d' : 'Y-m'; |
|
153 | - foreach ( $report_data->invoices as $invoice ) { |
|
154 | - $time = date( $date_format, strtotime( $invoice->post_date ) ); |
|
152 | + $date_format = ('day' === $this->groupby) ? 'Y-m-d' : 'Y-m'; |
|
153 | + foreach ($report_data->invoices as $invoice) { |
|
154 | + $time = date($date_format, strtotime($invoice->post_date)); |
|
155 | 155 | |
156 | - if ( ! isset( $period_totals[ $time ] ) ) { |
|
156 | + if (!isset($period_totals[$time])) { |
|
157 | 157 | continue; |
158 | 158 | } |
159 | 159 | |
160 | - $period_totals[ $time ]['sales'] = wpinv_round_amount( $invoice->total_sales ); |
|
161 | - $period_totals[ $time ]['tax'] = wpinv_round_amount( $invoice->total_tax ); |
|
162 | - $period_totals[ $time ]['subtotal'] = wpinv_round_amount( $invoice->subtotal ); |
|
163 | - $period_totals[ $time ]['fees'] = wpinv_round_amount( $invoice->total_fees ); |
|
160 | + $period_totals[$time]['sales'] = wpinv_round_amount($invoice->total_sales); |
|
161 | + $period_totals[$time]['tax'] = wpinv_round_amount($invoice->total_tax); |
|
162 | + $period_totals[$time]['subtotal'] = wpinv_round_amount($invoice->subtotal); |
|
163 | + $period_totals[$time]['fees'] = wpinv_round_amount($invoice->total_fees); |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | - foreach ( $report_data->refunds as $invoice ) { |
|
168 | - $time = date( $date_format, strtotime( $invoice->post_date ) ); |
|
167 | + foreach ($report_data->refunds as $invoice) { |
|
168 | + $time = date($date_format, strtotime($invoice->post_date)); |
|
169 | 169 | |
170 | - if ( ! isset( $period_totals[ $time ] ) ) { |
|
170 | + if (!isset($period_totals[$time])) { |
|
171 | 171 | continue; |
172 | 172 | } |
173 | 173 | |
174 | - $period_totals[ $time ]['refunds'] = wpinv_round_amount( $invoice->total_sales ); |
|
175 | - $period_totals[ $time ]['refunded_tax'] = wpinv_round_amount( $invoice->total_tax ); |
|
176 | - $period_totals[ $time ]['refunded_subtotal'] = wpinv_round_amount( $invoice->subtotal ); |
|
177 | - $period_totals[ $time ]['refunded_fees'] = wpinv_round_amount( $invoice->total_fees ); |
|
174 | + $period_totals[$time]['refunds'] = wpinv_round_amount($invoice->total_sales); |
|
175 | + $period_totals[$time]['refunded_tax'] = wpinv_round_amount($invoice->total_tax); |
|
176 | + $period_totals[$time]['refunded_subtotal'] = wpinv_round_amount($invoice->subtotal); |
|
177 | + $period_totals[$time]['refunded_fees'] = wpinv_round_amount($invoice->total_fees); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
181 | - foreach ( $report_data->invoice_counts as $invoice ) { |
|
182 | - $time = date( $date_format, strtotime( $invoice->post_date ) ); |
|
181 | + foreach ($report_data->invoice_counts as $invoice) { |
|
182 | + $time = date($date_format, strtotime($invoice->post_date)); |
|
183 | 183 | |
184 | - if ( isset( $period_totals[ $time ] ) ) { |
|
185 | - $period_totals[ $time ]['invoices'] = (int) $invoice->count; |
|
184 | + if (isset($period_totals[$time])) { |
|
185 | + $period_totals[$time]['invoices'] = (int) $invoice->count; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | 190 | // Add total invoice items for each period. |
191 | - foreach ( $report_data->invoice_items as $invoice_item ) { |
|
192 | - $time = ( 'day' === $this->groupby ) ? date( 'Y-m-d', strtotime( $invoice_item->post_date ) ) : date( 'Y-m', strtotime( $invoice_item->post_date ) ); |
|
191 | + foreach ($report_data->invoice_items as $invoice_item) { |
|
192 | + $time = ('day' === $this->groupby) ? date('Y-m-d', strtotime($invoice_item->post_date)) : date('Y-m', strtotime($invoice_item->post_date)); |
|
193 | 193 | |
194 | - if ( isset( $period_totals[ $time ] ) ) { |
|
195 | - $period_totals[ $time ]['items'] = (int) $invoice_item->invoice_item_count; |
|
194 | + if (isset($period_totals[$time])) { |
|
195 | + $period_totals[$time]['items'] = (int) $invoice_item->invoice_item_count; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | } |
199 | 199 | |
200 | 200 | // Add total discount for each period. |
201 | - foreach ( $report_data->coupons as $discount ) { |
|
202 | - $time = ( 'day' === $this->groupby ) ? date( 'Y-m-d', strtotime( $discount->post_date ) ) : date( 'Y-m', strtotime( $discount->post_date ) ); |
|
201 | + foreach ($report_data->coupons as $discount) { |
|
202 | + $time = ('day' === $this->groupby) ? date('Y-m-d', strtotime($discount->post_date)) : date('Y-m', strtotime($discount->post_date)); |
|
203 | 203 | |
204 | - if ( isset( $period_totals[ $time ] ) ) { |
|
205 | - $period_totals[ $time ]['discount'] = wpinv_round_amount( $discount->discount_amount ); |
|
204 | + if (isset($period_totals[$time])) { |
|
205 | + $period_totals[$time]['discount'] = wpinv_round_amount($discount->discount_amount); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | } |
209 | 209 | |
210 | 210 | // Extra fields. |
211 | - foreach( array_keys( wpinv_get_report_graphs() ) as $key ) { |
|
211 | + foreach (array_keys(wpinv_get_report_graphs()) as $key) { |
|
212 | 212 | |
213 | 213 | // Abort unprepared. |
214 | - if ( ! isset( $report_data->$key ) ) { |
|
214 | + if (!isset($report_data->$key)) { |
|
215 | 215 | continue; |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Abort defaults. |
219 | - if ( in_array( $key, array( 'sales', 'refunds', 'tax', 'fees', 'discount', 'invoices', 'items' ) ) ) { |
|
219 | + if (in_array($key, array('sales', 'refunds', 'tax', 'fees', 'discount', 'invoices', 'items'))) { |
|
220 | 220 | continue; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // Set values. |
224 | - foreach ( $report_data->$key as $item ) { |
|
225 | - $time = ( 'day' === $this->groupby ) ? date( 'Y-m-d', strtotime( $item->date ) ) : date( 'Y-m', strtotime( $item->date ) ); |
|
224 | + foreach ($report_data->$key as $item) { |
|
225 | + $time = ('day' === $this->groupby) ? date('Y-m-d', strtotime($item->date)) : date('Y-m', strtotime($item->date)); |
|
226 | 226 | |
227 | - if ( isset( $period_totals[ $time ] ) ) { |
|
228 | - $period_totals[ $time ][ $key ] = wpinv_round_amount( $item->val ); |
|
227 | + if (isset($period_totals[$time])) { |
|
228 | + $period_totals[$time][$key] = wpinv_round_amount($item->val); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - unset( $report_data->$key ); |
|
232 | + unset($report_data->$key); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | $report_data->totals = $period_totals; |
236 | 236 | $report_data->grouped_by = $this->groupby; |
237 | - $report_data->interval = max( $this->interval, 1 ); |
|
237 | + $report_data->interval = max($this->interval, 1); |
|
238 | 238 | $report_data->currency = wpinv_get_currency(); |
239 | 239 | $report_data->currency_symbol = wpinv_currency_symbol(); |
240 | 240 | $report_data->currency_position = wpinv_currency_position(); |
241 | 241 | $report_data->decimal_places = wpinv_decimals(); |
242 | 242 | $report_data->thousands_sep = wpinv_thousands_separator(); |
243 | 243 | $report_data->decimals_sep = wpinv_decimal_separator(); |
244 | - $report_data->start_date = date( 'Y-m-d', strtotime( $this->report_range['after'] ) + DAY_IN_SECONDS ); |
|
245 | - $report_data->end_date = date( 'Y-m-d', strtotime( $this->report_range['before'] ) - DAY_IN_SECONDS ); |
|
246 | - $report_data->start_date_locale = getpaid_format_date( date( 'Y-m-d', strtotime( $this->report_range['after'] ) + DAY_IN_SECONDS ) ); |
|
247 | - $report_data->end_date_locale = getpaid_format_date( date( 'Y-m-d', strtotime( $this->report_range['before'] ) - DAY_IN_SECONDS ) ); |
|
244 | + $report_data->start_date = date('Y-m-d', strtotime($this->report_range['after']) + DAY_IN_SECONDS); |
|
245 | + $report_data->end_date = date('Y-m-d', strtotime($this->report_range['before']) - DAY_IN_SECONDS); |
|
246 | + $report_data->start_date_locale = getpaid_format_date(date('Y-m-d', strtotime($this->report_range['after']) + DAY_IN_SECONDS)); |
|
247 | + $report_data->end_date_locale = getpaid_format_date(date('Y-m-d', strtotime($this->report_range['before']) - DAY_IN_SECONDS)); |
|
248 | 248 | $report_data->decimals_sep = wpinv_decimal_separator(); |
249 | 249 | |
250 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
250 | + $context = !empty($request['context']) ? $request['context'] : 'view'; |
|
251 | 251 | $data = $report_data; |
252 | - unset( $data->invoice_counts, $data->invoices, $data->coupons, $data->refunds, $data->invoice_items ); |
|
253 | - $data = $this->add_additional_fields_to_object( (array) $data, $request ); |
|
254 | - $data = $this->filter_response_by_context( $data, $context ); |
|
252 | + unset($data->invoice_counts, $data->invoices, $data->coupons, $data->refunds, $data->invoice_items); |
|
253 | + $data = $this->add_additional_fields_to_object((array) $data, $request); |
|
254 | + $data = $this->filter_response_by_context($data, $context); |
|
255 | 255 | |
256 | 256 | // Wrap the data in a response object. |
257 | - $response = rest_ensure_response( $data ); |
|
258 | - $response->add_links( array( |
|
257 | + $response = rest_ensure_response($data); |
|
258 | + $response->add_links(array( |
|
259 | 259 | 'about' => array( |
260 | - 'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ), |
|
260 | + 'href' => rest_url(sprintf('%s/reports', $this->namespace)), |
|
261 | 261 | ), |
262 | - ) ); |
|
262 | + )); |
|
263 | 263 | |
264 | - return apply_filters( 'getpaid_rest_prepare_report_sales', $response, $report_data, $request ); |
|
264 | + return apply_filters('getpaid_rest_prepare_report_sales', $response, $report_data, $request); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @return stdClass |
271 | 271 | */ |
272 | 272 | public function get_report_data() { |
273 | - if ( empty( $this->report_data ) ) { |
|
273 | + if (empty($this->report_data)) { |
|
274 | 274 | $this->query_report_data(); |
275 | 275 | } |
276 | 276 | return $this->report_data; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | // Prepare reports. |
285 | 285 | $this->report_data = (object) array( |
286 | - 'invoice_counts' => $this->query_invoice_counts(),//count, post_date |
|
286 | + 'invoice_counts' => $this->query_invoice_counts(), //count, post_date |
|
287 | 287 | 'coupons' => $this->query_coupon_counts(), // discount_amount, post_date |
288 | 288 | 'invoice_items' => $this->query_item_counts(), // invoice_item_count, post_date |
289 | 289 | 'refunded_items' => $this->count_refunded_items(), // invoice_item_count, post_date |
@@ -293,32 +293,32 @@ discard block |
||
293 | 293 | ); |
294 | 294 | |
295 | 295 | // Calculated totals. |
296 | - $this->report_data->total_tax = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->invoices, 'total_tax' ) ) ); |
|
297 | - $this->report_data->total_sales = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->invoices, 'total_sales' ) ) ); |
|
298 | - $this->report_data->total_discount = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->invoices, 'total_discount' ) ) ); |
|
299 | - $this->report_data->total_fees = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->invoices, 'total_fees' ) ) ); |
|
300 | - $this->report_data->subtotal = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->invoices, 'subtotal' ) ) ); |
|
301 | - $this->report_data->net_sales = wpinv_round_amount( $this->report_data->total_sales - max( 0, $this->report_data->total_tax ) ); |
|
302 | - $this->report_data->total_refunded_tax = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->refunds, 'total_tax' ) ) ); |
|
303 | - $this->report_data->total_refunds = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->refunds, 'total_sales' ) ) ); |
|
304 | - $this->report_data->refunded_discount = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->refunds, 'total_discount' ) ) ); |
|
305 | - $this->report_data->refunded_fees = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->refunds, 'total_fees' ) ) ); |
|
306 | - $this->report_data->refunded_subtotal = wpinv_round_amount( array_sum( wp_list_pluck( $this->report_data->refunds, 'subtotal' ) ) ); |
|
307 | - $this->report_data->net_refunds = wpinv_round_amount( $this->report_data->total_refunds + max( 0, $this->report_data->total_refunded_tax ) ); |
|
296 | + $this->report_data->total_tax = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->invoices, 'total_tax'))); |
|
297 | + $this->report_data->total_sales = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->invoices, 'total_sales'))); |
|
298 | + $this->report_data->total_discount = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->invoices, 'total_discount'))); |
|
299 | + $this->report_data->total_fees = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->invoices, 'total_fees'))); |
|
300 | + $this->report_data->subtotal = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->invoices, 'subtotal'))); |
|
301 | + $this->report_data->net_sales = wpinv_round_amount($this->report_data->total_sales - max(0, $this->report_data->total_tax)); |
|
302 | + $this->report_data->total_refunded_tax = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->refunds, 'total_tax'))); |
|
303 | + $this->report_data->total_refunds = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->refunds, 'total_sales'))); |
|
304 | + $this->report_data->refunded_discount = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->refunds, 'total_discount'))); |
|
305 | + $this->report_data->refunded_fees = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->refunds, 'total_fees'))); |
|
306 | + $this->report_data->refunded_subtotal = wpinv_round_amount(array_sum(wp_list_pluck($this->report_data->refunds, 'subtotal'))); |
|
307 | + $this->report_data->net_refunds = wpinv_round_amount($this->report_data->total_refunds + max(0, $this->report_data->total_refunded_tax)); |
|
308 | 308 | |
309 | 309 | |
310 | 310 | // Calculate average based on net. |
311 | - $this->report_data->average_sales = wpinv_round_amount( $this->report_data->net_sales / max( $this->interval, 1 ), 2 ); |
|
312 | - $this->report_data->average_total_sales = wpinv_round_amount( $this->report_data->total_sales / max( $this->interval, 1 ), 2 ); |
|
311 | + $this->report_data->average_sales = wpinv_round_amount($this->report_data->net_sales / max($this->interval, 1), 2); |
|
312 | + $this->report_data->average_total_sales = wpinv_round_amount($this->report_data->total_sales / max($this->interval, 1), 2); |
|
313 | 313 | |
314 | 314 | // Total invoices in this period, even if refunded. |
315 | - $this->report_data->total_invoices = absint( array_sum( wp_list_pluck( $this->report_data->invoice_counts, 'count' ) ) ); |
|
315 | + $this->report_data->total_invoices = absint(array_sum(wp_list_pluck($this->report_data->invoice_counts, 'count'))); |
|
316 | 316 | |
317 | 317 | // Items invoiced in this period, even if refunded. |
318 | - $this->report_data->total_items = absint( array_sum( wp_list_pluck( $this->report_data->invoice_items, 'invoice_item_count' ) ) ); |
|
318 | + $this->report_data->total_items = absint(array_sum(wp_list_pluck($this->report_data->invoice_items, 'invoice_item_count'))); |
|
319 | 319 | |
320 | 320 | // 3rd party filtering of report data |
321 | - $this->report_data = apply_filters( 'getpaid_rest_api_filter_report_data', $this->report_data, $this ); |
|
321 | + $this->report_data = apply_filters('getpaid_rest_api_filter_report_data', $this->report_data, $this); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | 'name' => 'post_date', |
344 | 344 | ), |
345 | 345 | ), |
346 | - 'group_by' => $this->get_group_by_sql( 'posts.post_date' ), |
|
346 | + 'group_by' => $this->get_group_by_sql('posts.post_date'), |
|
347 | 347 | 'order_by' => 'post_date ASC', |
348 | 348 | 'query_type' => 'get_results', |
349 | 349 | 'filter_range' => $this->report_range, |
350 | - 'invoice_status' => array( 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-renewal' ), |
|
350 | + 'invoice_status' => array('publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-renewal'), |
|
351 | 351 | ) |
352 | 352 | ); |
353 | 353 | |
@@ -374,11 +374,11 @@ discard block |
||
374 | 374 | 'name' => 'post_date', |
375 | 375 | ), |
376 | 376 | ), |
377 | - 'group_by' => $this->get_group_by_sql( 'posts.post_date' ), |
|
377 | + 'group_by' => $this->get_group_by_sql('posts.post_date'), |
|
378 | 378 | 'order_by' => 'post_date ASC', |
379 | 379 | 'query_type' => 'get_results', |
380 | 380 | 'filter_range' => $this->report_range, |
381 | - 'invoice_status' => array( 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-renewal' ), |
|
381 | + 'invoice_status' => array('publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-renewal'), |
|
382 | 382 | ) |
383 | 383 | ); |
384 | 384 | |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | 'name' => 'post_date', |
406 | 406 | ), |
407 | 407 | ), |
408 | - 'group_by' => $this->get_group_by_sql( 'posts.post_date' ), |
|
408 | + 'group_by' => $this->get_group_by_sql('posts.post_date'), |
|
409 | 409 | 'order_by' => 'post_date ASC', |
410 | 410 | 'query_type' => 'get_results', |
411 | 411 | 'filter_range' => $this->report_range, |
412 | - 'invoice_status' => array( 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-renewal' ), |
|
412 | + 'invoice_status' => array('publish', 'wpi-processing', 'wpi-onhold', 'wpi-refunded', 'wpi-renewal'), |
|
413 | 413 | ) |
414 | 414 | ); |
415 | 415 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | ), |
434 | 434 | 'query_type' => 'get_var', |
435 | 435 | 'filter_range' => $this->report_range, |
436 | - 'invoice_status' => array( 'wpi-refunded' ), |
|
436 | + 'invoice_status' => array('wpi-refunded'), |
|
437 | 437 | ) |
438 | 438 | ); |
439 | 439 | |
@@ -480,11 +480,11 @@ discard block |
||
480 | 480 | 'name' => 'post_date', |
481 | 481 | ), |
482 | 482 | ), |
483 | - 'group_by' => $this->get_group_by_sql( 'posts.post_date' ), |
|
483 | + 'group_by' => $this->get_group_by_sql('posts.post_date'), |
|
484 | 484 | 'order_by' => 'post_date ASC', |
485 | 485 | 'query_type' => 'get_results', |
486 | 486 | 'filter_range' => $this->report_range, |
487 | - 'invoice_status' => array( 'publish', 'wpi-processing', 'wpi-onhold', 'wpi-renewal' ), |
|
487 | + 'invoice_status' => array('publish', 'wpi-processing', 'wpi-onhold', 'wpi-renewal'), |
|
488 | 488 | ) |
489 | 489 | ); |
490 | 490 | |
@@ -531,11 +531,11 @@ discard block |
||
531 | 531 | 'name' => 'post_date', |
532 | 532 | ), |
533 | 533 | ), |
534 | - 'group_by' => $this->get_group_by_sql( 'posts.post_date' ), |
|
534 | + 'group_by' => $this->get_group_by_sql('posts.post_date'), |
|
535 | 535 | 'order_by' => 'post_date ASC', |
536 | 536 | 'query_type' => 'get_results', |
537 | 537 | 'filter_range' => $this->report_range, |
538 | - 'invoice_status' => array( 'wpi-refunded' ), |
|
538 | + 'invoice_status' => array('wpi-refunded'), |
|
539 | 539 | ) |
540 | 540 | ); |
541 | 541 | |
@@ -554,154 +554,154 @@ discard block |
||
554 | 554 | 'type' => 'object', |
555 | 555 | 'properties' => array( |
556 | 556 | 'total_sales' => array( |
557 | - 'description' => __( 'Gross sales in the period.', 'invoicing' ), |
|
557 | + 'description' => __('Gross sales in the period.', 'invoicing'), |
|
558 | 558 | 'type' => 'string', |
559 | - 'context' => array( 'view' ), |
|
559 | + 'context' => array('view'), |
|
560 | 560 | 'readonly' => true, |
561 | 561 | ), |
562 | 562 | 'net_sales' => array( |
563 | - 'description' => __( 'Net sales in the period.', 'invoicing' ), |
|
563 | + 'description' => __('Net sales in the period.', 'invoicing'), |
|
564 | 564 | 'type' => 'string', |
565 | - 'context' => array( 'view' ), |
|
565 | + 'context' => array('view'), |
|
566 | 566 | 'readonly' => true, |
567 | 567 | ), |
568 | 568 | 'average_sales' => array( |
569 | - 'description' => __( 'Average net daily sales.', 'invoicing' ), |
|
569 | + 'description' => __('Average net daily sales.', 'invoicing'), |
|
570 | 570 | 'type' => 'string', |
571 | - 'context' => array( 'view' ), |
|
571 | + 'context' => array('view'), |
|
572 | 572 | 'readonly' => true, |
573 | 573 | ), |
574 | 574 | 'average_total_sales' => array( |
575 | - 'description' => __( 'Average gross daily sales.', 'invoicing' ), |
|
575 | + 'description' => __('Average gross daily sales.', 'invoicing'), |
|
576 | 576 | 'type' => 'string', |
577 | - 'context' => array( 'view' ), |
|
577 | + 'context' => array('view'), |
|
578 | 578 | 'readonly' => true, |
579 | 579 | ), |
580 | 580 | 'total_invoices' => array( |
581 | - 'description' => __( 'Number of paid invoices.', 'invoicing' ), |
|
581 | + 'description' => __('Number of paid invoices.', 'invoicing'), |
|
582 | 582 | 'type' => 'integer', |
583 | - 'context' => array( 'view' ), |
|
583 | + 'context' => array('view'), |
|
584 | 584 | 'readonly' => true, |
585 | 585 | ), |
586 | 586 | 'total_items' => array( |
587 | - 'description' => __( 'Number of items purchased.', 'invoicing' ), |
|
587 | + 'description' => __('Number of items purchased.', 'invoicing'), |
|
588 | 588 | 'type' => 'integer', |
589 | - 'context' => array( 'view' ), |
|
589 | + 'context' => array('view'), |
|
590 | 590 | 'readonly' => true, |
591 | 591 | ), |
592 | 592 | 'refunded_items' => array( |
593 | - 'description' => __( 'Number of items refunded.', 'invoicing' ), |
|
593 | + 'description' => __('Number of items refunded.', 'invoicing'), |
|
594 | 594 | 'type' => 'integer', |
595 | - 'context' => array( 'view' ), |
|
595 | + 'context' => array('view'), |
|
596 | 596 | 'readonly' => true, |
597 | 597 | ), |
598 | 598 | 'total_tax' => array( |
599 | - 'description' => __( 'Total charged for taxes.', 'invoicing' ), |
|
599 | + 'description' => __('Total charged for taxes.', 'invoicing'), |
|
600 | 600 | 'type' => 'string', |
601 | - 'context' => array( 'view' ), |
|
601 | + 'context' => array('view'), |
|
602 | 602 | 'readonly' => true, |
603 | 603 | ), |
604 | 604 | 'total_refunded_tax' => array( |
605 | - 'description' => __( 'Total refunded for taxes.', 'invoicing' ), |
|
605 | + 'description' => __('Total refunded for taxes.', 'invoicing'), |
|
606 | 606 | 'type' => 'string', |
607 | - 'context' => array( 'view' ), |
|
607 | + 'context' => array('view'), |
|
608 | 608 | 'readonly' => true, |
609 | 609 | ), |
610 | 610 | 'total_fees' => array( |
611 | - 'description' => __( 'Total fees charged.', 'invoicing' ), |
|
611 | + 'description' => __('Total fees charged.', 'invoicing'), |
|
612 | 612 | 'type' => 'string', |
613 | - 'context' => array( 'view' ), |
|
613 | + 'context' => array('view'), |
|
614 | 614 | 'readonly' => true, |
615 | 615 | ), |
616 | 616 | 'total_refunds' => array( |
617 | - 'description' => __( 'Total of refunded invoices.', 'invoicing' ), |
|
617 | + 'description' => __('Total of refunded invoices.', 'invoicing'), |
|
618 | 618 | 'type' => 'integer', |
619 | - 'context' => array( 'view' ), |
|
619 | + 'context' => array('view'), |
|
620 | 620 | 'readonly' => true, |
621 | 621 | ), |
622 | 622 | 'net_refunds' => array( |
623 | - 'description' => __( 'Net of refunded invoices.', 'invoicing' ), |
|
623 | + 'description' => __('Net of refunded invoices.', 'invoicing'), |
|
624 | 624 | 'type' => 'integer', |
625 | - 'context' => array( 'view' ), |
|
625 | + 'context' => array('view'), |
|
626 | 626 | 'readonly' => true, |
627 | 627 | ), |
628 | 628 | 'total_discount' => array( |
629 | - 'description' => __( 'Total of discounts used.', 'invoicing' ), |
|
629 | + 'description' => __('Total of discounts used.', 'invoicing'), |
|
630 | 630 | 'type' => 'integer', |
631 | - 'context' => array( 'view' ), |
|
631 | + 'context' => array('view'), |
|
632 | 632 | 'readonly' => true, |
633 | 633 | ), |
634 | 634 | 'totals' => array( |
635 | - 'description' => __( 'Totals.', 'invoicing' ), |
|
635 | + 'description' => __('Totals.', 'invoicing'), |
|
636 | 636 | 'type' => 'array', |
637 | 637 | 'items' => array( |
638 | 638 | 'type' => 'array', |
639 | 639 | ), |
640 | - 'context' => array( 'view' ), |
|
640 | + 'context' => array('view'), |
|
641 | 641 | 'readonly' => true, |
642 | 642 | ), |
643 | 643 | 'interval' => array( |
644 | - 'description' => __( 'Number of months/days in the report period.', 'invoicing' ), |
|
644 | + 'description' => __('Number of months/days in the report period.', 'invoicing'), |
|
645 | 645 | 'type' => 'integer', |
646 | - 'context' => array( 'view' ), |
|
646 | + 'context' => array('view'), |
|
647 | 647 | 'readonly' => true, |
648 | 648 | ), |
649 | 649 | 'previous_range' => array( |
650 | - 'description' => __( 'The previous report period.', 'invoicing' ), |
|
650 | + 'description' => __('The previous report period.', 'invoicing'), |
|
651 | 651 | 'type' => 'array', |
652 | 652 | 'items' => array( |
653 | 653 | 'type' => 'string', |
654 | 654 | ), |
655 | - 'context' => array( 'view' ), |
|
655 | + 'context' => array('view'), |
|
656 | 656 | 'readonly' => true, |
657 | 657 | ), |
658 | 658 | 'grouped_by' => array( |
659 | - 'description' => __( 'The period used to group the totals.', 'invoicing' ), |
|
659 | + 'description' => __('The period used to group the totals.', 'invoicing'), |
|
660 | 660 | 'type' => 'string', |
661 | - 'context' => array( 'view' ), |
|
662 | - 'enum' => array( 'day', 'month' ), |
|
661 | + 'context' => array('view'), |
|
662 | + 'enum' => array('day', 'month'), |
|
663 | 663 | 'readonly' => true, |
664 | 664 | ), |
665 | 665 | 'currency' => array( |
666 | - 'description' => __( 'The default store currency.', 'invoicing' ), |
|
666 | + 'description' => __('The default store currency.', 'invoicing'), |
|
667 | 667 | 'type' => 'string', |
668 | - 'context' => array( 'view' ), |
|
668 | + 'context' => array('view'), |
|
669 | 669 | 'readonly' => true, |
670 | 670 | ), |
671 | 671 | 'currency_symbol' => array( |
672 | - 'description' => __( 'The default store currency symbol.', 'invoicing' ), |
|
672 | + 'description' => __('The default store currency symbol.', 'invoicing'), |
|
673 | 673 | 'type' => 'string', |
674 | - 'context' => array( 'view' ), |
|
674 | + 'context' => array('view'), |
|
675 | 675 | 'readonly' => true, |
676 | 676 | ), |
677 | 677 | 'currency_position' => array( |
678 | - 'description' => __( 'The default store currency position.', 'invoicing' ), |
|
678 | + 'description' => __('The default store currency position.', 'invoicing'), |
|
679 | 679 | 'type' => 'string', |
680 | - 'context' => array( 'view' ), |
|
680 | + 'context' => array('view'), |
|
681 | 681 | 'readonly' => true, |
682 | 682 | ), |
683 | 683 | 'decimal_places' => array( |
684 | - 'description' => __( 'The default store decimal places.', 'invoicing' ), |
|
684 | + 'description' => __('The default store decimal places.', 'invoicing'), |
|
685 | 685 | 'type' => 'string', |
686 | - 'context' => array( 'view' ), |
|
686 | + 'context' => array('view'), |
|
687 | 687 | 'readonly' => true, |
688 | 688 | ), |
689 | 689 | 'thousands_sep' => array( |
690 | - 'description' => __( 'The default store thousands separator.', 'invoicing' ), |
|
690 | + 'description' => __('The default store thousands separator.', 'invoicing'), |
|
691 | 691 | 'type' => 'string', |
692 | - 'context' => array( 'view' ), |
|
692 | + 'context' => array('view'), |
|
693 | 693 | 'readonly' => true, |
694 | 694 | ), |
695 | 695 | 'decimals_sep' => array( |
696 | - 'description' => __( 'The default store decimals separator.', 'invoicing' ), |
|
696 | + 'description' => __('The default store decimals separator.', 'invoicing'), |
|
697 | 697 | 'type' => 'string', |
698 | - 'context' => array( 'view' ), |
|
698 | + 'context' => array('view'), |
|
699 | 699 | 'readonly' => true, |
700 | 700 | ), |
701 | 701 | ), |
702 | 702 | ); |
703 | 703 | |
704 | - return $this->add_additional_fields_schema( $schema ); |
|
704 | + return $this->add_additional_fields_schema($schema); |
|
705 | 705 | |
706 | 706 | } |
707 | 707 |
@@ -7,40 +7,40 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( !$is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( !$is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,139 +49,139 @@ discard block |
||
49 | 49 | * @param string $post_type The post type or invoice type. |
50 | 50 | * @return string The history page URL. |
51 | 51 | */ |
52 | -function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) { |
|
53 | - $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) ); |
|
54 | - $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | - $page_id = absint( $page_id ); |
|
56 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
52 | +function wpinv_get_history_page_uri($post_type = 'wpi_invoice') { |
|
53 | + $post_type = sanitize_key(str_replace('wpi_', '', $post_type)); |
|
54 | + $page_id = wpinv_get_option("{$post_type}_history_page", 0); |
|
55 | + $page_id = absint($page_id); |
|
56 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_success_page() { |
60 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
60 | + $is_success_page = wpinv_get_option('success_page', false); |
|
61 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
63 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_invoice_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_is_subscriptions_history_page() { |
73 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
74 | - $ret = $ret ? is_page( $ret ) : false; |
|
75 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
73 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
74 | + $ret = $ret ? is_page($ret) : false; |
|
75 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Redirects a user the success page. |
80 | 80 | */ |
81 | -function wpinv_send_to_success_page( $args = array() ) { |
|
81 | +function wpinv_send_to_success_page($args = array()) { |
|
82 | 82 | |
83 | 83 | $redirect = add_query_arg( |
84 | - wp_parse_args( $args ), |
|
84 | + wp_parse_args($args), |
|
85 | 85 | wpinv_get_success_page_uri() |
86 | 86 | ); |
87 | 87 | |
88 | - $redirect = apply_filters( 'wpinv_send_to_success_page_url', $redirect, $args ); |
|
88 | + $redirect = apply_filters('wpinv_send_to_success_page_url', $redirect, $args); |
|
89 | 89 | |
90 | - wp_redirect( $redirect ); |
|
90 | + wp_redirect($redirect); |
|
91 | 91 | exit; |
92 | 92 | } |
93 | 93 | |
94 | -function wpinv_send_to_failed_page( $args = null ) { |
|
94 | +function wpinv_send_to_failed_page($args = null) { |
|
95 | 95 | $redirect = wpinv_get_failed_transaction_uri(); |
96 | 96 | |
97 | - if ( !empty( $args ) ) { |
|
97 | + if (!empty($args)) { |
|
98 | 98 | // Check for backward compatibility |
99 | - if ( is_string( $args ) ) |
|
100 | - $args = str_replace( '?', '', $args ); |
|
99 | + if (is_string($args)) |
|
100 | + $args = str_replace('?', '', $args); |
|
101 | 101 | |
102 | - $args = wp_parse_args( $args ); |
|
102 | + $args = wp_parse_args($args); |
|
103 | 103 | |
104 | - $redirect = add_query_arg( $args, $redirect ); |
|
104 | + $redirect = add_query_arg($args, $redirect); |
|
105 | 105 | } |
106 | 106 | |
107 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
107 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
108 | 108 | |
109 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
110 | - wp_redirect( $redirect ); |
|
109 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
110 | + wp_redirect($redirect); |
|
111 | 111 | exit; |
112 | 112 | } |
113 | 113 | |
114 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
115 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
116 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
114 | +function wpinv_get_checkout_uri($args = array()) { |
|
115 | + $uri = wpinv_get_option('checkout_page', false); |
|
116 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
117 | 117 | |
118 | - if ( !empty( $args ) ) { |
|
118 | + if (!empty($args)) { |
|
119 | 119 | // Check for backward compatibility |
120 | - if ( is_string( $args ) ) |
|
121 | - $args = str_replace( '?', '', $args ); |
|
120 | + if (is_string($args)) |
|
121 | + $args = str_replace('?', '', $args); |
|
122 | 122 | |
123 | - $args = wp_parse_args( $args ); |
|
123 | + $args = wp_parse_args($args); |
|
124 | 124 | |
125 | - $uri = add_query_arg( $args, $uri ); |
|
125 | + $uri = add_query_arg($args, $uri); |
|
126 | 126 | } |
127 | 127 | |
128 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
128 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
129 | 129 | |
130 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
130 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
131 | 131 | |
132 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
133 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
132 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
133 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
134 | 134 | } |
135 | 135 | |
136 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
136 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
140 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
141 | - $success_page = get_permalink( $success_page ); |
|
139 | +function wpinv_get_success_page_url($query_string = null) { |
|
140 | + $success_page = wpinv_get_option('success_page', 0); |
|
141 | + $success_page = get_permalink($success_page); |
|
142 | 142 | |
143 | - if ( $query_string ) |
|
143 | + if ($query_string) |
|
144 | 144 | $success_page .= $query_string; |
145 | 145 | |
146 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
146 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
147 | 147 | } |
148 | 148 | |
149 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
150 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
151 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
149 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
150 | + $uri = wpinv_get_option('failure_page', ''); |
|
151 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
152 | 152 | |
153 | - if ( $extras ) |
|
153 | + if ($extras) |
|
154 | 154 | $uri .= $extras; |
155 | 155 | |
156 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
156 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | function wpinv_is_failed_transaction_page() { |
160 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
161 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
160 | + $ret = wpinv_get_option('failure_page', false); |
|
161 | + $ret = isset($ret) ? is_page($ret) : false; |
|
162 | 162 | |
163 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
163 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
164 | 164 | } |
165 | 165 | |
166 | -function wpinv_transaction_query( $type = 'start' ) { |
|
166 | +function wpinv_transaction_query($type = 'start') { |
|
167 | 167 | global $wpdb; |
168 | 168 | |
169 | 169 | $wpdb->hide_errors(); |
170 | 170 | |
171 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
172 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
171 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
172 | + define('WPINV_USE_TRANSACTIONS', true); |
|
173 | 173 | } |
174 | 174 | |
175 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
176 | - switch ( $type ) { |
|
175 | + if (WPINV_USE_TRANSACTIONS) { |
|
176 | + switch ($type) { |
|
177 | 177 | case 'commit' : |
178 | - $wpdb->query( 'COMMIT' ); |
|
178 | + $wpdb->query('COMMIT'); |
|
179 | 179 | break; |
180 | 180 | case 'rollback' : |
181 | - $wpdb->query( 'ROLLBACK' ); |
|
181 | + $wpdb->query('ROLLBACK'); |
|
182 | 182 | break; |
183 | 183 | default : |
184 | - $wpdb->query( 'START TRANSACTION' ); |
|
184 | + $wpdb->query('START TRANSACTION'); |
|
185 | 185 | break; |
186 | 186 | } |
187 | 187 | } |
@@ -190,146 +190,146 @@ discard block |
||
190 | 190 | function wpinv_get_prefix() { |
191 | 191 | $invoice_prefix = 'INV-'; |
192 | 192 | |
193 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
193 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | function wpinv_get_business_logo() { |
197 | - $business_logo = wpinv_get_option( 'logo' ); |
|
198 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
197 | + $business_logo = wpinv_get_option('logo'); |
|
198 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | function wpinv_get_business_name() { |
202 | - $name = wpinv_get_option( 'store_name', wpinv_get_blogname() ); |
|
202 | + $name = wpinv_get_option('store_name', wpinv_get_blogname()); |
|
203 | 203 | |
204 | - if ( empty( $name ) ) { |
|
204 | + if (empty($name)) { |
|
205 | 205 | $name = wpinv_get_blogname(); |
206 | 206 | } |
207 | 207 | |
208 | - return apply_filters( 'wpinv_get_business_name', $name ); |
|
208 | + return apply_filters('wpinv_get_business_name', $name); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | function wpinv_get_blogname() { |
212 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
212 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | function wpinv_get_admin_email() { |
216 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
217 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
216 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
217 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | function wpinv_get_business_website() { |
221 | - $business_website = home_url( '/' ); |
|
222 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
221 | + $business_website = home_url('/'); |
|
222 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
223 | 223 | } |
224 | 224 | |
225 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
225 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
226 | 226 | $terms_text = ''; |
227 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
227 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | function wpinv_get_business_footer() { |
231 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
232 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
233 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
231 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
232 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
233 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | function wpinv_checkout_required_fields() { |
237 | 237 | $required_fields = array(); |
238 | 238 | |
239 | 239 | // Let payment gateways and other extensions determine if address fields should be required |
240 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
240 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
241 | 241 | |
242 | - if ( $require_billing_details ) { |
|
243 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
242 | + if ($require_billing_details) { |
|
243 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
244 | 244 | $required_fields['first_name'] = array( |
245 | 245 | 'error_id' => 'invalid_first_name', |
246 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
246 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
247 | 247 | ); |
248 | 248 | } |
249 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
249 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
250 | 250 | $required_fields['address'] = array( |
251 | 251 | 'error_id' => 'invalid_address', |
252 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
252 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
253 | 253 | ); |
254 | 254 | } |
255 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
255 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
256 | 256 | $required_fields['city'] = array( |
257 | 257 | 'error_id' => 'invalid_city', |
258 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
258 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
259 | 259 | ); |
260 | 260 | } |
261 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
261 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
262 | 262 | $required_fields['state'] = array( |
263 | 263 | 'error_id' => 'invalid_state', |
264 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
264 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
265 | 265 | ); |
266 | 266 | } |
267 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
267 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
268 | 268 | $required_fields['country'] = array( |
269 | 269 | 'error_id' => 'invalid_country', |
270 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
270 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
271 | 271 | ); |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
275 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | function wpinv_is_ssl_enforced() { |
279 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
280 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
279 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
280 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | function wpinv_schedule_event_twicedaily() { |
284 | 284 | wpinv_email_payment_reminders(); |
285 | 285 | } |
286 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
286 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
287 | 287 | |
288 | 288 | function wpinv_require_login_to_checkout() { |
289 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
290 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
289 | + $return = wpinv_get_option('login_to_checkout', false); |
|
290 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
291 | 291 | } |
292 | 292 | |
293 | -function wpinv_sequential_number_active( $type = '' ) { |
|
294 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
295 | - if ( null !== $check ) { |
|
293 | +function wpinv_sequential_number_active($type = '') { |
|
294 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
295 | + if (null !== $check) { |
|
296 | 296 | return $check; |
297 | 297 | } |
298 | 298 | |
299 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
299 | + return wpinv_get_option('sequential_invoice_number'); |
|
300 | 300 | } |
301 | 301 | |
302 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
302 | +function wpinv_switch_to_locale($locale = NULL) { |
|
303 | 303 | global $invoicing, $wpi_switch_locale; |
304 | 304 | |
305 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
306 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
305 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
306 | + $locale = empty($locale) ? get_locale() : $locale; |
|
307 | 307 | |
308 | - switch_to_locale( $locale ); |
|
308 | + switch_to_locale($locale); |
|
309 | 309 | |
310 | 310 | $wpi_switch_locale = $locale; |
311 | 311 | |
312 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
312 | + add_filter('plugin_locale', 'get_locale'); |
|
313 | 313 | |
314 | 314 | $invoicing->load_textdomain(); |
315 | 315 | |
316 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
316 | + do_action('wpinv_switch_to_locale', $locale); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | 320 | function wpinv_restore_locale() { |
321 | 321 | global $invoicing, $wpi_switch_locale; |
322 | 322 | |
323 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
323 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
324 | 324 | restore_previous_locale(); |
325 | 325 | |
326 | 326 | $wpi_switch_locale = NULL; |
327 | 327 | |
328 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
328 | + remove_filter('plugin_locale', 'get_locale'); |
|
329 | 329 | |
330 | 330 | $invoicing->load_textdomain(); |
331 | 331 | |
332 | - do_action( 'wpinv_restore_locale' ); |
|
332 | + do_action('wpinv_restore_locale'); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
@@ -337,26 +337,26 @@ discard block |
||
337 | 337 | * Returns the default form's id. |
338 | 338 | */ |
339 | 339 | function wpinv_get_default_payment_form() { |
340 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
340 | + $form = get_option('wpinv_default_payment_form'); |
|
341 | 341 | |
342 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
342 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
343 | 343 | $form = wp_insert_post( |
344 | 344 | array( |
345 | 345 | 'post_type' => 'wpi_payment_form', |
346 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
346 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
347 | 347 | 'post_status' => 'publish', |
348 | 348 | 'meta_input' => array( |
349 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
349 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
350 | 350 | 'wpinv_form_items' => array(), |
351 | 351 | ) |
352 | 352 | ) |
353 | 353 | ); |
354 | 354 | |
355 | - update_option( 'wpinv_default_payment_form', $form ); |
|
355 | + update_option('wpinv_default_payment_form', $form); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | // WPML support. |
359 | - $form = apply_filters( 'wpml_object_id', $form, 'wpi_payment_form', TRUE ); |
|
359 | + $form = apply_filters('wpml_object_id', $form, 'wpi_payment_form', TRUE); |
|
360 | 360 | return $form; |
361 | 361 | } |
362 | 362 | |
@@ -365,19 +365,19 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @param int $payment_form |
367 | 367 | */ |
368 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
368 | +function getpaid_get_payment_form_elements($payment_form) { |
|
369 | 369 | |
370 | - if ( empty( $payment_form ) ) { |
|
371 | - return wpinv_get_data( 'sample-payment-form' ); |
|
370 | + if (empty($payment_form)) { |
|
371 | + return wpinv_get_data('sample-payment-form'); |
|
372 | 372 | } |
373 | 373 | |
374 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
374 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
375 | 375 | |
376 | - if ( is_array( $form_elements ) ) { |
|
376 | + if (is_array($form_elements)) { |
|
377 | 377 | return $form_elements; |
378 | 378 | } |
379 | 379 | |
380 | - return wpinv_get_data( 'sample-payment-form' ); |
|
380 | + return wpinv_get_data('sample-payment-form'); |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | |
@@ -386,42 +386,42 @@ discard block |
||
386 | 386 | * |
387 | 387 | * @param int $payment_form |
388 | 388 | */ |
389 | -function gepaid_get_form_items( $id ) { |
|
390 | - $form = new GetPaid_Payment_Form( $id ); |
|
389 | +function gepaid_get_form_items($id) { |
|
390 | + $form = new GetPaid_Payment_Form($id); |
|
391 | 391 | |
392 | 392 | // Is this a default form? |
393 | - if ( $form->is_default() ) { |
|
393 | + if ($form->is_default()) { |
|
394 | 394 | return array(); |
395 | 395 | } |
396 | 396 | |
397 | - return $form->get_items( 'view', 'arrays' ); |
|
397 | + return $form->get_items('view', 'arrays'); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
401 | 401 | * Trims each line in a paragraph. |
402 | 402 | * |
403 | 403 | */ |
404 | -function gepaid_trim_lines( $content ) { |
|
405 | - return implode( "\n", array_map( 'trim', explode( "\n", $content ) ) ); |
|
404 | +function gepaid_trim_lines($content) { |
|
405 | + return implode("\n", array_map('trim', explode("\n", $content))); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
409 | -function wpinv_add_elementor_widget_categories( $elements_manager ) { |
|
409 | +function wpinv_add_elementor_widget_categories($elements_manager) { |
|
410 | 410 | $elements_manager->add_category( |
411 | 411 | 'getpaid', |
412 | 412 | [ |
413 | - 'title' => esc_html__( 'GetPaid', 'invoicing' ), |
|
413 | + 'title' => esc_html__('GetPaid', 'invoicing'), |
|
414 | 414 | 'icon' => 'fa fa-plug', |
415 | 415 | ] |
416 | 416 | ); |
417 | 417 | } |
418 | -add_filter( 'elementor/elements/categories_registered', 'wpinv_add_elementor_widget_categories' ); |
|
418 | +add_filter('elementor/elements/categories_registered', 'wpinv_add_elementor_widget_categories'); |
|
419 | 419 | |
420 | -function wpinv_alter_elementor_widget_config( $config ){ |
|
420 | +function wpinv_alter_elementor_widget_config($config) { |
|
421 | 421 | |
422 | - if ( ! empty( $config['initial_document']['widgets'] ) ) { |
|
423 | - foreach( $config['initial_document']['widgets'] as $key => $widget){ |
|
424 | - if(substr( $key, 0, 16 ) === "wp-widget-wpinv_" || $key === "wp-widget-getpaid"){ |
|
422 | + if (!empty($config['initial_document']['widgets'])) { |
|
423 | + foreach ($config['initial_document']['widgets'] as $key => $widget) { |
|
424 | + if (substr($key, 0, 16) === "wp-widget-wpinv_" || $key === "wp-widget-getpaid") { |
|
425 | 425 | $config['initial_document']['widgets'][$key]['categories'][] = 'getpaid'; |
426 | 426 | $config['initial_document']['widgets'][$key]['hide_on_search'] = false; |
427 | 427 | $config['initial_document']['widgets'][$key]['icon'] = 'eicon-globe'; //@todo if no icons use on page then font-awesome is not loaded, wif we can fifure out how to force load we can use icons. <i class="fas fa-globe-americas"></i><i class="fa-solid fa-earth-americas"></i> |
@@ -431,20 +431,20 @@ discard block |
||
431 | 431 | |
432 | 432 | return $config; |
433 | 433 | } |
434 | -add_filter( 'elementor/editor/localize_settings', 'wpinv_alter_elementor_widget_config' ); |
|
434 | +add_filter('elementor/editor/localize_settings', 'wpinv_alter_elementor_widget_config'); |
|
435 | 435 | |
436 | 436 | function wpinv_get_report_graphs() { |
437 | 437 | |
438 | 438 | return apply_filters( |
439 | 439 | 'getpaid_report_graphs', |
440 | 440 | array( |
441 | - 'sales' => __( 'Earnings', 'invoicing' ), |
|
442 | - 'refunds' => __( 'Refunds', 'invoicing' ), |
|
443 | - 'tax' => __( 'Taxes', 'invoicing' ), |
|
444 | - 'fees' => __( 'Fees', 'invoicing' ), |
|
445 | - 'discount' => __( 'Discounts', 'invoicing' ), |
|
446 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
447 | - 'items' => __( 'Purchased Items', 'invoicing' ), |
|
441 | + 'sales' => __('Earnings', 'invoicing'), |
|
442 | + 'refunds' => __('Refunds', 'invoicing'), |
|
443 | + 'tax' => __('Taxes', 'invoicing'), |
|
444 | + 'fees' => __('Fees', 'invoicing'), |
|
445 | + 'discount' => __('Discounts', 'invoicing'), |
|
446 | + 'invoices' => __('Invoices', 'invoicing'), |
|
447 | + 'items' => __('Purchased Items', 'invoicing'), |
|
448 | 448 | ) |
449 | 449 | ); |
450 | 450 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports_Abstract_Report Class. |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | public function get_range() { |
33 | 33 | $valid_ranges = $this->get_periods(); |
34 | 34 | |
35 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
36 | - return sanitize_key( $_GET['date_range'] ); |
|
35 | + if (isset($_GET['date_range']) && array_key_exists($_GET['date_range'], $valid_ranges)) { |
|
36 | + return sanitize_key($_GET['date_range']); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return '7_days'; |
@@ -47,34 +47,34 @@ discard block |
||
47 | 47 | public function get_periods() { |
48 | 48 | |
49 | 49 | $periods = array( |
50 | - 'today' => __( 'Today', 'invoicing' ), |
|
51 | - 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
52 | - '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
53 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
54 | - '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
55 | - '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
56 | - '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
57 | - '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
50 | + 'today' => __('Today', 'invoicing'), |
|
51 | + 'yesterday' => __('Yesterday', 'invoicing'), |
|
52 | + '7_days' => __('Last 7 days', 'invoicing'), |
|
53 | + '30_days' => __('Last 30 days', 'invoicing'), |
|
54 | + '60_days' => __('Last 60 days', 'invoicing'), |
|
55 | + '90_days' => __('Last 90 days', 'invoicing'), |
|
56 | + '180_days' => __('Last 180 days', 'invoicing'), |
|
57 | + '360_days' => __('Last 360 days', 'invoicing'), |
|
58 | 58 | ); |
59 | 59 | |
60 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
60 | + return apply_filters('getpaid_earning_periods', $periods); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Retrieves the current range's sql. |
65 | 65 | * |
66 | 66 | */ |
67 | - public function get_range_sql( $range, $date = 'CAST(meta.completed_date AS DATE)', $datetime = 'meta.comlpeted_date' ) { |
|
67 | + public function get_range_sql($range, $date = 'CAST(meta.completed_date AS DATE)', $datetime = 'meta.comlpeted_date') { |
|
68 | 68 | |
69 | 69 | // Prepare durations. |
70 | - $today = current_time( 'Y-m-d' ); |
|
71 | - $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
72 | - $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
73 | - $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
74 | - $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
75 | - $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
76 | - $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
77 | - $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
70 | + $today = current_time('Y-m-d'); |
|
71 | + $yesterday = date('Y-m-d', strtotime('-1 day', current_time('timestamp'))); |
|
72 | + $seven_days_ago = date('Y-m-d', strtotime('-7 days', current_time('timestamp'))); |
|
73 | + $thirty_days_ago = date('Y-m-d', strtotime('-30 days', current_time('timestamp'))); |
|
74 | + $ninety_days_ago = date('Y-m-d', strtotime('-90 days', current_time('timestamp'))); |
|
75 | + $sixty_days_ago = date('Y-m-d', strtotime('-60 days', current_time('timestamp'))); |
|
76 | + $one_eighty_days_ago = date('Y-m-d', strtotime('-180 days', current_time('timestamp'))); |
|
77 | + $three_sixty_days_ago = date('Y-m-d', strtotime('-360 days', current_time('timestamp'))); |
|
78 | 78 | |
79 | 79 | $ranges = array( |
80 | 80 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | |
121 | 121 | ); |
122 | 122 | |
123 | - $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
124 | - return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
123 | + $sql = isset($ranges[$range]) ? $ranges[$range] : $ranges['7_days']; |
|
124 | + return apply_filters('getpaid_earning_graphs_get_range_sql', $sql, $range); |
|
125 | 125 | |
126 | 126 | } |
127 | 127 | |
@@ -132,30 +132,30 @@ discard block |
||
132 | 132 | public function get_hours_in_a_day() { |
133 | 133 | |
134 | 134 | return array( |
135 | - '12AM' => __( '12 AM', 'invoicing'), |
|
136 | - '1AM' => __( '1 AM', 'invoicing'), |
|
137 | - '2AM' => __( '2 AM', 'invoicing'), |
|
138 | - '3AM' => __( '3 AM', 'invoicing'), |
|
139 | - '4AM' => __( '4 AM', 'invoicing'), |
|
140 | - '5AM' => __( '5 AM', 'invoicing'), |
|
141 | - '6AM' => __( '6 AM', 'invoicing'), |
|
142 | - '7AM' => __( '7 AM', 'invoicing'), |
|
143 | - '8AM' => __( '8 AM', 'invoicing'), |
|
144 | - '9AM' => __( '9 AM', 'invoicing'), |
|
145 | - '10AM' => __( '10 AM', 'invoicing'), |
|
146 | - '11AM' => __( '11 AM', 'invoicing'), |
|
147 | - '12pm' => __( '12 PM', 'invoicing'), |
|
148 | - '1PM' => __( '1 PM', 'invoicing'), |
|
149 | - '2PM' => __( '2 PM', 'invoicing'), |
|
150 | - '3PM' => __( '3 PM', 'invoicing'), |
|
151 | - '4PM' => __( '4 PM', 'invoicing'), |
|
152 | - '5PM' => __( '5 PM', 'invoicing'), |
|
153 | - '6PM' => __( '6 PM', 'invoicing'), |
|
154 | - '7PM' => __( '7 PM', 'invoicing'), |
|
155 | - '8PM' => __( '8 PM', 'invoicing'), |
|
156 | - '9PM' => __( '9 PM', 'invoicing'), |
|
157 | - '10PM' => __( '10 PM', 'invoicing'), |
|
158 | - '11PM' => __( '11 PM', 'invoicing'), |
|
135 | + '12AM' => __('12 AM', 'invoicing'), |
|
136 | + '1AM' => __('1 AM', 'invoicing'), |
|
137 | + '2AM' => __('2 AM', 'invoicing'), |
|
138 | + '3AM' => __('3 AM', 'invoicing'), |
|
139 | + '4AM' => __('4 AM', 'invoicing'), |
|
140 | + '5AM' => __('5 AM', 'invoicing'), |
|
141 | + '6AM' => __('6 AM', 'invoicing'), |
|
142 | + '7AM' => __('7 AM', 'invoicing'), |
|
143 | + '8AM' => __('8 AM', 'invoicing'), |
|
144 | + '9AM' => __('9 AM', 'invoicing'), |
|
145 | + '10AM' => __('10 AM', 'invoicing'), |
|
146 | + '11AM' => __('11 AM', 'invoicing'), |
|
147 | + '12pm' => __('12 PM', 'invoicing'), |
|
148 | + '1PM' => __('1 PM', 'invoicing'), |
|
149 | + '2PM' => __('2 PM', 'invoicing'), |
|
150 | + '3PM' => __('3 PM', 'invoicing'), |
|
151 | + '4PM' => __('4 PM', 'invoicing'), |
|
152 | + '5PM' => __('5 PM', 'invoicing'), |
|
153 | + '6PM' => __('6 PM', 'invoicing'), |
|
154 | + '7PM' => __('7 PM', 'invoicing'), |
|
155 | + '8PM' => __('8 PM', 'invoicing'), |
|
156 | + '9PM' => __('9 PM', 'invoicing'), |
|
157 | + '10PM' => __('10 PM', 'invoicing'), |
|
158 | + '11PM' => __('11 PM', 'invoicing'), |
|
159 | 159 | ); |
160 | 160 | |
161 | 161 | } |
@@ -164,24 +164,24 @@ discard block |
||
164 | 164 | * Retrieves the days in a period |
165 | 165 | * |
166 | 166 | */ |
167 | - public function get_days_in_period( $days ) { |
|
167 | + public function get_days_in_period($days) { |
|
168 | 168 | |
169 | 169 | $return = array(); |
170 | 170 | $format = 'Y-m-d'; |
171 | 171 | |
172 | - if ( $days < 8 ) { |
|
172 | + if ($days < 8) { |
|
173 | 173 | $format = 'D'; |
174 | 174 | } |
175 | 175 | |
176 | - if ( $days < 32 ) { |
|
176 | + if ($days < 32) { |
|
177 | 177 | $format = 'M j'; |
178 | 178 | } |
179 | 179 | |
180 | - while ( $days > 0 ) { |
|
180 | + while ($days > 0) { |
|
181 | 181 | |
182 | - $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
183 | - $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
184 | - $return[ $key ] = $label; |
|
182 | + $key = date('Y-m-d', strtotime("-$days days", current_time('timestamp'))); |
|
183 | + $label = date_i18n($format, strtotime("-$days days", current_time('timestamp'))); |
|
184 | + $return[$key] = $label; |
|
185 | 185 | $days--; |
186 | 186 | |
187 | 187 | } |
@@ -193,15 +193,15 @@ discard block |
||
193 | 193 | * Retrieves the weeks in a period |
194 | 194 | * |
195 | 195 | */ |
196 | - public function get_weeks_in_period( $days ) { |
|
196 | + public function get_weeks_in_period($days) { |
|
197 | 197 | |
198 | 198 | $return = array(); |
199 | 199 | |
200 | - while ( $days > 0 ) { |
|
200 | + while ($days > 0) { |
|
201 | 201 | |
202 | - $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
203 | - $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
204 | - $return[ $key ] = $label; |
|
202 | + $key = date('W', strtotime("-$days days", current_time('timestamp'))); |
|
203 | + $label = date_i18n('Y-m-d', strtotime("-$days days", current_time('timestamp'))); |
|
204 | + $return[$key] = $label; |
|
205 | 205 | $days--; |
206 | 206 | |
207 | 207 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * GetPaid_Reports_Helper Class. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param array $args |
27 | 27 | * @return mixed depending on query_type |
28 | 28 | */ |
29 | - public static function get_invoice_report_data( $args = array() ) { |
|
29 | + public static function get_invoice_report_data($args = array()) { |
|
30 | 30 | global $wpdb; |
31 | 31 | |
32 | 32 | $default_args = array( |
@@ -37,94 +37,94 @@ discard block |
||
37 | 37 | 'order_by' => '', // What to order by. |
38 | 38 | 'limit' => '', // Results limit. |
39 | 39 | 'filter_range' => array(), // An array of before and after dates to limit results by. |
40 | - 'invoice_types' => array( 'wpi_invoice' ), // An array of post types to retrieve. |
|
41 | - 'invoice_status' => array( 'publish', 'wpi-processing', 'wpi-onhold' ), |
|
40 | + 'invoice_types' => array('wpi_invoice'), // An array of post types to retrieve. |
|
41 | + 'invoice_status' => array('publish', 'wpi-processing', 'wpi-onhold'), |
|
42 | 42 | 'parent_invoice_status' => false, // Optionally filter by parent invoice status. |
43 | 43 | ); |
44 | 44 | |
45 | - $args = apply_filters( 'getpaid_reports_get_invoice_report_data_args', $args ); |
|
46 | - $args = wp_parse_args( $args, $default_args ); |
|
45 | + $args = apply_filters('getpaid_reports_get_invoice_report_data_args', $args); |
|
46 | + $args = wp_parse_args($args, $default_args); |
|
47 | 47 | |
48 | - extract( $args ); |
|
48 | + extract($args); |
|
49 | 49 | |
50 | - if ( empty( $data ) ) { |
|
50 | + if (empty($data)) { |
|
51 | 51 | return ''; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $query = array(); |
55 | - $query['select'] = 'SELECT ' . implode( ',', self::prepare_invoice_data( $data ) ); |
|
55 | + $query['select'] = 'SELECT ' . implode(',', self::prepare_invoice_data($data)); |
|
56 | 56 | $query['from'] = "FROM {$wpdb->posts} AS posts"; |
57 | - $query['join'] = implode( ' ', self::prepare_invoice_joins( $data + $where, ! empty( $parent_invoice_status ) ) ); |
|
57 | + $query['join'] = implode(' ', self::prepare_invoice_joins($data + $where, !empty($parent_invoice_status))); |
|
58 | 58 | |
59 | 59 | $query['where'] = " |
60 | - WHERE posts.post_type IN ( '" . implode( "','", $invoice_types ) . "' ) |
|
60 | + WHERE posts.post_type IN ( '" . implode("','", $invoice_types) . "' ) |
|
61 | 61 | "; |
62 | 62 | |
63 | - if ( ! empty( $invoice_status ) ) { |
|
63 | + if (!empty($invoice_status)) { |
|
64 | 64 | $query['where'] .= " |
65 | - AND posts.post_status IN ( '" . implode( "','", $invoice_status ) . "' ) |
|
65 | + AND posts.post_status IN ( '" . implode("','", $invoice_status) . "' ) |
|
66 | 66 | "; |
67 | 67 | } |
68 | 68 | |
69 | - if ( ! empty( $parent_invoice_status ) ) { |
|
70 | - if ( ! empty( $invoice_status ) ) { |
|
71 | - $query['where'] .= " AND ( parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) OR parent.ID IS NULL ) "; |
|
69 | + if (!empty($parent_invoice_status)) { |
|
70 | + if (!empty($invoice_status)) { |
|
71 | + $query['where'] .= " AND ( parent.post_status IN ( '" . implode("','", $parent_invoice_status) . "' ) OR parent.ID IS NULL ) "; |
|
72 | 72 | } else { |
73 | - $query['where'] .= " AND parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) "; |
|
73 | + $query['where'] .= " AND parent.post_status IN ( '" . implode("','", $parent_invoice_status) . "' ) "; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - if ( ! empty( $filter_range['before'] ) ) { |
|
77 | + if (!empty($filter_range['before'])) { |
|
78 | 78 | $query['where'] .= " |
79 | - AND posts.post_date < '" . date( 'Y-m-d 23:59:59', strtotime( $filter_range['before'] ) ) . "' |
|
79 | + AND posts.post_date < '" . date('Y-m-d 23:59:59', strtotime($filter_range['before'])) . "' |
|
80 | 80 | "; |
81 | 81 | } |
82 | 82 | |
83 | - if ( ! empty( $filter_range['after'] ) ) { |
|
83 | + if (!empty($filter_range['after'])) { |
|
84 | 84 | $query['where'] .= " |
85 | - AND posts.post_date > '" . date( 'Y-m-d H:i:s', strtotime( $filter_range['after'] ) ) . "' |
|
85 | + AND posts.post_date > '" . date('Y-m-d H:i:s', strtotime($filter_range['after'])) . "' |
|
86 | 86 | "; |
87 | 87 | } |
88 | 88 | |
89 | - if ( ! empty( $where ) ) { |
|
89 | + if (!empty($where)) { |
|
90 | 90 | |
91 | - foreach ( $where as $value ) { |
|
91 | + foreach ($where as $value) { |
|
92 | 92 | |
93 | - if ( strtolower( $value['operator'] ) == 'in' || strtolower( $value['operator'] ) == 'not in' ) { |
|
93 | + if (strtolower($value['operator']) == 'in' || strtolower($value['operator']) == 'not in') { |
|
94 | 94 | |
95 | - if ( is_array( $value['value'] ) ) { |
|
96 | - $value['value'] = implode( "','", $value['value'] ); |
|
95 | + if (is_array($value['value'])) { |
|
96 | + $value['value'] = implode("','", $value['value']); |
|
97 | 97 | } |
98 | 98 | |
99 | - if ( ! empty( $value['value'] ) ) { |
|
99 | + if (!empty($value['value'])) { |
|
100 | 100 | $where_value = "{$value['operator']} ('{$value['value']}')"; |
101 | 101 | } |
102 | 102 | } else { |
103 | 103 | $where_value = "{$value['operator']} '{$value['value']}'"; |
104 | 104 | } |
105 | 105 | |
106 | - if ( ! empty( $where_value ) ) { |
|
106 | + if (!empty($where_value)) { |
|
107 | 107 | $query['where'] .= " AND {$value['key']} {$where_value}"; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | - if ( $group_by ) { |
|
112 | + if ($group_by) { |
|
113 | 113 | $query['group_by'] = "GROUP BY {$group_by}"; |
114 | 114 | } |
115 | 115 | |
116 | - if ( $order_by ) { |
|
116 | + if ($order_by) { |
|
117 | 117 | $query['order_by'] = "ORDER BY {$order_by}"; |
118 | 118 | } |
119 | 119 | |
120 | - if ( $limit ) { |
|
120 | + if ($limit) { |
|
121 | 121 | $query['limit'] = "LIMIT {$limit}"; |
122 | 122 | } |
123 | 123 | |
124 | - $query = apply_filters( 'getpaid_reports_get_invoice_report_query', $query, $data ); |
|
125 | - $query = implode( ' ', $query ); |
|
124 | + $query = apply_filters('getpaid_reports_get_invoice_report_query', $query, $data); |
|
125 | + $query = implode(' ', $query); |
|
126 | 126 | |
127 | - return self::execute( $query_type, $query ); |
|
127 | + return self::execute($query_type, $query); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -135,26 +135,26 @@ discard block |
||
135 | 135 | * @param array $data |
136 | 136 | * @return array |
137 | 137 | */ |
138 | - public static function prepare_invoice_data( $data ) { |
|
138 | + public static function prepare_invoice_data($data) { |
|
139 | 139 | |
140 | 140 | $prepared = array(); |
141 | 141 | |
142 | - foreach ( $data as $raw_key => $value ) { |
|
143 | - $key = sanitize_key( $raw_key ); |
|
142 | + foreach ($data as $raw_key => $value) { |
|
143 | + $key = sanitize_key($raw_key); |
|
144 | 144 | $distinct = ''; |
145 | 145 | |
146 | - if ( isset( $value['distinct'] ) ) { |
|
146 | + if (isset($value['distinct'])) { |
|
147 | 147 | $distinct = 'DISTINCT'; |
148 | 148 | } |
149 | 149 | |
150 | - $get_key = self::get_invoice_table_key( $key, $value['type'] ); |
|
150 | + $get_key = self::get_invoice_table_key($key, $value['type']); |
|
151 | 151 | |
152 | - if ( false === $get_key ) { |
|
152 | + if (false === $get_key) { |
|
153 | 153 | // Skip to the next foreach iteration else the query will be invalid. |
154 | 154 | continue; |
155 | 155 | } |
156 | 156 | |
157 | - if ( ! empty( $value['function'] ) ) { |
|
157 | + if (!empty($value['function'])) { |
|
158 | 158 | $get = "{$value['function']}({$distinct} {$get_key})"; |
159 | 159 | } else { |
160 | 160 | $get = "{$distinct} {$get_key}"; |
@@ -175,22 +175,22 @@ discard block |
||
175 | 175 | * @param bool $with_parent |
176 | 176 | * @return array |
177 | 177 | */ |
178 | - public static function prepare_invoice_joins( $data, $with_parent ) { |
|
178 | + public static function prepare_invoice_joins($data, $with_parent) { |
|
179 | 179 | global $wpdb; |
180 | 180 | |
181 | 181 | $prepared = array(); |
182 | 182 | |
183 | - foreach ( $data as $raw_key => $value ) { |
|
184 | - $join_type = isset( $value['join_type'] ) ? $value['join_type'] : 'INNER'; |
|
185 | - $type = isset( $value['type'] ) ? $value['type'] : false; |
|
186 | - $key = sanitize_key( $raw_key ); |
|
183 | + foreach ($data as $raw_key => $value) { |
|
184 | + $join_type = isset($value['join_type']) ? $value['join_type'] : 'INNER'; |
|
185 | + $type = isset($value['type']) ? $value['type'] : false; |
|
186 | + $key = sanitize_key($raw_key); |
|
187 | 187 | |
188 | - switch ( $type ) { |
|
188 | + switch ($type) { |
|
189 | 189 | case 'meta': |
190 | - $prepared[ "meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$raw_key}' )"; |
|
190 | + $prepared["meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$raw_key}' )"; |
|
191 | 191 | break; |
192 | 192 | case 'parent_meta': |
193 | - $prepared[ "parent_meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$raw_key}')"; |
|
193 | + $prepared["parent_meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$raw_key}')"; |
|
194 | 194 | break; |
195 | 195 | case 'invoice_data': |
196 | 196 | $prepared['invoices'] = "{$join_type} JOIN {$wpdb->prefix}getpaid_invoices AS invoices ON posts.ID = invoices.post_id"; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - if ( $with_parent ) { |
|
204 | + if ($with_parent) { |
|
205 | 205 | $prepared['parent'] = "LEFT JOIN {$wpdb->posts} AS parent ON posts.post_parent = parent.ID"; |
206 | 206 | } |
207 | 207 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param string $table |
218 | 218 | * @return string|false |
219 | 219 | */ |
220 | - public static function get_invoice_table_key( $key, $table ) { |
|
220 | + public static function get_invoice_table_key($key, $table) { |
|
221 | 221 | |
222 | 222 | $keys = array( |
223 | 223 | 'meta' => "meta_{$key}.meta_value", |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'invoice_item' => "invoice_items.{$key}", |
228 | 228 | ); |
229 | 229 | |
230 | - return isset( $keys[ $table ] ) ? $keys[ $table ] : false; |
|
230 | + return isset($keys[$table]) ? $keys[$table] : false; |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | |
@@ -239,16 +239,16 @@ discard block |
||
239 | 239 | * @param string $query |
240 | 240 | * @return mixed depending on query_type |
241 | 241 | */ |
242 | - public static function execute( $query_type, $query ) { |
|
242 | + public static function execute($query_type, $query) { |
|
243 | 243 | global $wpdb; |
244 | 244 | |
245 | - $query_hash = md5( $query_type . $query ); |
|
246 | - $result = self::get_cached_query( $query_hash ); |
|
247 | - if ( $result === false ) { |
|
245 | + $query_hash = md5($query_type . $query); |
|
246 | + $result = self::get_cached_query($query_hash); |
|
247 | + if ($result === false) { |
|
248 | 248 | self::enable_big_selects(); |
249 | 249 | |
250 | - $result = $wpdb->$query_type( $query ); |
|
251 | - self::set_cached_query( $query_hash, $result ); |
|
250 | + $result = $wpdb->$query_type($query); |
|
251 | + self::set_cached_query($query_hash, $result); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | return $result; |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | |
264 | 264 | global $wpdb; |
265 | 265 | |
266 | - if ( ! $big_selects ) { |
|
267 | - $wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' ); |
|
266 | + if (!$big_selects) { |
|
267 | + $wpdb->query('SET SESSION SQL_BIG_SELECTS=1'); |
|
268 | 268 | $big_selects = true; |
269 | 269 | } |
270 | 270 | } |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return mixed|false The cache contents on success, false on failure to retrieve contents. |
278 | 278 | */ |
279 | - protected static function get_cached_query( $query_hash ) { |
|
279 | + protected static function get_cached_query($query_hash) { |
|
280 | 280 | |
281 | 281 | return wp_cache_get( |
282 | 282 | $query_hash, |
283 | - strtolower( __CLASS__ ) |
|
283 | + strtolower(__CLASS__) |
|
284 | 284 | ); |
285 | 285 | |
286 | 286 | } |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | * @param string $query_hash The query hash. |
292 | 292 | * @param mixed $data The data to cache. |
293 | 293 | */ |
294 | - protected static function set_cached_query( $query_hash, $data ) { |
|
294 | + protected static function set_cached_query($query_hash, $data) { |
|
295 | 295 | |
296 | 296 | wp_cache_set( |
297 | 297 | $query_hash, |
298 | 298 | $data, |
299 | - strtolower( __CLASS__ ), |
|
299 | + strtolower(__CLASS__), |
|
300 | 300 | MINUTE_IN_SECONDS |
301 | 301 | ); |
302 | 302 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | 'block-keywords'=> "['invoicing','invoice']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'getpaid_invoice', |
25 | - 'name' => __( 'GetPaid > Single Invoice','invoicing' ), |
|
25 | + 'name' => __('GetPaid > Single Invoice', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'wpinv-invoice-class bsui', |
28 | - 'description' => esc_html__('Displays a single invoice.','invoicing'), |
|
28 | + 'description' => esc_html__('Displays a single invoice.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | 'title' => array( |
32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
32 | + 'title' => __('Widget title', 'invoicing'), |
|
33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
34 | 34 | 'type' => 'text', |
35 | 35 | 'desc_tip' => true, |
36 | 36 | 'default' => '', |
37 | 37 | 'advanced' => false |
38 | 38 | ), |
39 | 39 | 'id' => array( |
40 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
41 | - 'desc' => __( 'Enter the invoice ID', 'invoicing' ), |
|
40 | + 'title' => __('Invoice', 'invoicing'), |
|
41 | + 'desc' => __('Enter the invoice ID', 'invoicing'), |
|
42 | 42 | 'type' => 'text', |
43 | 43 | 'desc_tip' => true, |
44 | 44 | 'default' => '', |
45 | - 'placeholder' => __('1','invoicing'), |
|
45 | + 'placeholder' => __('1', 'invoicing'), |
|
46 | 46 | 'advanced' => false |
47 | 47 | ), |
48 | 48 | ) |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | |
53 | - parent::__construct( $options ); |
|
53 | + parent::__construct($options); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -62,30 +62,30 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return mixed|string|bool |
64 | 64 | */ |
65 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
65 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
66 | 66 | |
67 | 67 | // Is the shortcode set up correctly? |
68 | - if ( empty( $args['id'] ) ) { |
|
68 | + if (empty($args['id'])) { |
|
69 | 69 | return aui()->alert( |
70 | 70 | array( |
71 | 71 | 'type' => 'warning', |
72 | - 'content' => __( 'Missing invoice ID', 'invoicing' ), |
|
72 | + 'content' => __('Missing invoice ID', 'invoicing'), |
|
73 | 73 | ) |
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
77 | - $invoice = wpinv_get_invoice( (int) $args['id'] ); |
|
77 | + $invoice = wpinv_get_invoice((int) $args['id']); |
|
78 | 78 | |
79 | - if ( $invoice ) { |
|
79 | + if ($invoice) { |
|
80 | 80 | ob_start(); |
81 | - getpaid_invoice( $invoice ); |
|
81 | + getpaid_invoice($invoice); |
|
82 | 82 | return ob_get_clean(); |
83 | 83 | } |
84 | 84 | |
85 | 85 | return aui()->alert( |
86 | 86 | array( |
87 | 87 | 'type' => 'danger', |
88 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
88 | + 'content' => __('Invoice not found', 'invoicing'), |
|
89 | 89 | ) |
90 | 90 | ); |
91 | 91 |