@@ -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. |
@@ -133,40 +133,40 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
135 | 135 | */ |
136 | - public function __construct( $invoice = false ) { |
|
136 | + public function __construct($invoice = false) { |
|
137 | 137 | |
138 | - parent::__construct( $invoice ); |
|
138 | + parent::__construct($invoice); |
|
139 | 139 | |
140 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
141 | - $this->set_id( $invoice ); |
|
142 | - } elseif ( $invoice instanceof self ) { |
|
143 | - $this->set_id( $invoice->get_id() ); |
|
144 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
145 | - $this->set_id( $invoice->ID ); |
|
146 | - } elseif ( is_array( $invoice ) ) { |
|
147 | - $this->set_props( $invoice ); |
|
140 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
141 | + $this->set_id($invoice); |
|
142 | + } elseif ($invoice instanceof self) { |
|
143 | + $this->set_id($invoice->get_id()); |
|
144 | + } elseif (!empty($invoice->ID)) { |
|
145 | + $this->set_id($invoice->ID); |
|
146 | + } elseif (is_array($invoice)) { |
|
147 | + $this->set_props($invoice); |
|
148 | 148 | |
149 | - if ( isset( $invoice['ID'] ) ) { |
|
150 | - $this->set_id( $invoice['ID'] ); |
|
149 | + if (isset($invoice['ID'])) { |
|
150 | + $this->set_id($invoice['ID']); |
|
151 | 151 | } |
152 | 152 | |
153 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
154 | - $this->set_id( $invoice_id ); |
|
155 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
156 | - $this->set_id( $invoice_id ); |
|
157 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
158 | - $this->set_id( $invoice_id ); |
|
159 | - }else { |
|
160 | - $this->set_object_read( true ); |
|
153 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
154 | + $this->set_id($invoice_id); |
|
155 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
156 | + $this->set_id($invoice_id); |
|
157 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
158 | + $this->set_id($invoice_id); |
|
159 | + } else { |
|
160 | + $this->set_object_read(true); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // Load the datastore. |
164 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
164 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
165 | 165 | |
166 | - if ( $this->get_id() > 0 ) { |
|
167 | - $this->post = get_post( $this->get_id() ); |
|
166 | + if ($this->get_id() > 0) { |
|
167 | + $this->post = get_post($this->get_id()); |
|
168 | 168 | $this->ID = $this->get_id(); |
169 | - $this->data_store->read( $this ); |
|
169 | + $this->data_store->read($this); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | } |
@@ -181,38 +181,38 @@ discard block |
||
181 | 181 | * @since 1.0.15 |
182 | 182 | * @return int |
183 | 183 | */ |
184 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
184 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
185 | 185 | global $wpdb; |
186 | 186 | |
187 | 187 | // Trim the value. |
188 | - $value = trim( $value ); |
|
188 | + $value = trim($value); |
|
189 | 189 | |
190 | - if ( empty( $value ) ) { |
|
190 | + if (empty($value)) { |
|
191 | 191 | return 0; |
192 | 192 | } |
193 | 193 | |
194 | 194 | // Valid fields. |
195 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
195 | + $fields = array('key', 'number', 'transaction_id'); |
|
196 | 196 | |
197 | 197 | // Ensure a field has been passed. |
198 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
198 | + if (empty($field) || !in_array($field, $fields)) { |
|
199 | 199 | return 0; |
200 | 200 | } |
201 | 201 | |
202 | 202 | // Maybe retrieve from the cache. |
203 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
204 | - if ( false !== $invoice_id ) { |
|
203 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
204 | + if (false !== $invoice_id) { |
|
205 | 205 | return $invoice_id; |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Fetch from the db. |
209 | 209 | $table = $wpdb->prefix . 'getpaid_invoices'; |
210 | 210 | $invoice_id = (int) $wpdb->get_var( |
211 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
211 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
212 | 212 | ); |
213 | 213 | |
214 | 214 | // Update the cache with our data |
215 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
215 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
216 | 216 | |
217 | 217 | return $invoice_id; |
218 | 218 | } |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | /** |
221 | 221 | * Checks if an invoice key is set. |
222 | 222 | */ |
223 | - public function _isset( $key ) { |
|
224 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
223 | + public function _isset($key) { |
|
224 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /* |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | * @param string $context View or edit context. |
247 | 247 | * @return int |
248 | 248 | */ |
249 | - public function get_parent_id( $context = 'view' ) { |
|
250 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
249 | + public function get_parent_id($context = 'view') { |
|
250 | + return (int) $this->get_prop('parent_id', $context); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return WPInv_Invoice |
258 | 258 | */ |
259 | 259 | public function get_parent_payment() { |
260 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
260 | + return new WPInv_Invoice($this->get_parent_id()); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $context View or edit context. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - public function get_status( $context = 'view' ) { |
|
281 | - return $this->get_prop( 'status', $context ); |
|
280 | + public function get_status($context = 'view') { |
|
281 | + return $this->get_prop('status', $context); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function get_all_statuses() { |
291 | 291 | |
292 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
292 | + $statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
293 | 293 | |
294 | 294 | // For backwards compatibility. |
295 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
295 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
296 | 296 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
297 | 297 | } |
298 | 298 | |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | public function get_status_nicename() { |
309 | 309 | $statuses = $this->get_all_statuses(); |
310 | 310 | |
311 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
311 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
312 | 312 | |
313 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
313 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | */ |
322 | 322 | public function get_status_label_html() { |
323 | 323 | |
324 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
325 | - $status = sanitize_html_class( $this->get_status() ); |
|
324 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
325 | + $status = sanitize_html_class($this->get_status()); |
|
326 | 326 | |
327 | 327 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
328 | 328 | } |
@@ -334,27 +334,27 @@ discard block |
||
334 | 334 | * @param string $context View or edit context. |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public function get_version( $context = 'view' ) { |
|
338 | - return $this->get_prop( 'version', $context ); |
|
337 | + public function get_version($context = 'view') { |
|
338 | + return $this->get_prop('version', $context); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | 342 | * @deprecated |
343 | 343 | */ |
344 | - public function get_invoice_date( $formatted = true ) { |
|
344 | + public function get_invoice_date($formatted = true) { |
|
345 | 345 | $date_completed = $this->get_date_completed(); |
346 | 346 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
347 | 347 | |
348 | - if ( $invoice_date == '' ) { |
|
348 | + if ($invoice_date == '') { |
|
349 | 349 | $date_created = $this->get_date_created(); |
350 | 350 | $invoice_date = $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
351 | 351 | } |
352 | 352 | |
353 | - if ( $formatted && $invoice_date ) { |
|
354 | - $invoice_date = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) ); |
|
353 | + if ($formatted && $invoice_date) { |
|
354 | + $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date)); |
|
355 | 355 | } |
356 | 356 | |
357 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this ); |
|
357 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -364,8 +364,8 @@ discard block |
||
364 | 364 | * @param string $context View or edit context. |
365 | 365 | * @return string |
366 | 366 | */ |
367 | - public function get_date_created( $context = 'view' ) { |
|
368 | - return $this->get_prop( 'date_created', $context ); |
|
367 | + public function get_date_created($context = 'view') { |
|
368 | + return $this->get_prop('date_created', $context); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | * @param string $context View or edit context. |
376 | 376 | * @return string |
377 | 377 | */ |
378 | - public function get_created_date( $context = 'view' ) { |
|
379 | - return $this->get_date_created( $context ); |
|
378 | + public function get_created_date($context = 'view') { |
|
379 | + return $this->get_date_created($context); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
@@ -386,11 +386,11 @@ discard block |
||
386 | 386 | * @param string $context View or edit context. |
387 | 387 | * @return string |
388 | 388 | */ |
389 | - public function get_date_created_gmt( $context = 'view' ) { |
|
390 | - $date = $this->get_date_created( $context ); |
|
389 | + public function get_date_created_gmt($context = 'view') { |
|
390 | + $date = $this->get_date_created($context); |
|
391 | 391 | |
392 | - if ( $date ) { |
|
393 | - $date = get_gmt_from_date( $date ); |
|
392 | + if ($date) { |
|
393 | + $date = get_gmt_from_date($date); |
|
394 | 394 | } |
395 | 395 | return $date; |
396 | 396 | } |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | * @param string $context View or edit context. |
403 | 403 | * @return string |
404 | 404 | */ |
405 | - public function get_date_modified( $context = 'view' ) { |
|
406 | - return $this->get_prop( 'date_modified', $context ); |
|
405 | + public function get_date_modified($context = 'view') { |
|
406 | + return $this->get_prop('date_modified', $context); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | * @param string $context View or edit context. |
414 | 414 | * @return string |
415 | 415 | */ |
416 | - public function get_modified_date( $context = 'view' ) { |
|
417 | - return $this->get_date_modified( $context ); |
|
416 | + public function get_modified_date($context = 'view') { |
|
417 | + return $this->get_date_modified($context); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -424,11 +424,11 @@ discard block |
||
424 | 424 | * @param string $context View or edit context. |
425 | 425 | * @return string |
426 | 426 | */ |
427 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
428 | - $date = $this->get_date_modified( $context ); |
|
427 | + public function get_date_modified_gmt($context = 'view') { |
|
428 | + $date = $this->get_date_modified($context); |
|
429 | 429 | |
430 | - if ( $date ) { |
|
431 | - $date = get_gmt_from_date( $date ); |
|
430 | + if ($date) { |
|
431 | + $date = get_gmt_from_date($date); |
|
432 | 432 | } |
433 | 433 | return $date; |
434 | 434 | } |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @param string $context View or edit context. |
441 | 441 | * @return string |
442 | 442 | */ |
443 | - public function get_due_date( $context = 'view' ) { |
|
444 | - return $this->get_prop( 'due_date', $context ); |
|
443 | + public function get_due_date($context = 'view') { |
|
444 | + return $this->get_prop('due_date', $context); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | * @param string $context View or edit context. |
452 | 452 | * @return string |
453 | 453 | */ |
454 | - public function get_date_due( $context = 'view' ) { |
|
455 | - return $this->get_due_date( $context ); |
|
454 | + public function get_date_due($context = 'view') { |
|
455 | + return $this->get_due_date($context); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -462,11 +462,11 @@ discard block |
||
462 | 462 | * @param string $context View or edit context. |
463 | 463 | * @return string |
464 | 464 | */ |
465 | - public function get_due_date_gmt( $context = 'view' ) { |
|
466 | - $date = $this->get_due_date( $context ); |
|
465 | + public function get_due_date_gmt($context = 'view') { |
|
466 | + $date = $this->get_due_date($context); |
|
467 | 467 | |
468 | - if ( $date ) { |
|
469 | - $date = get_gmt_from_date( $date ); |
|
468 | + if ($date) { |
|
469 | + $date = get_gmt_from_date($date); |
|
470 | 470 | } |
471 | 471 | return $date; |
472 | 472 | } |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $context View or edit context. |
479 | 479 | * @return string |
480 | 480 | */ |
481 | - public function get_gmt_date_due( $context = 'view' ) { |
|
482 | - return $this->get_due_date_gmt( $context ); |
|
481 | + public function get_gmt_date_due($context = 'view') { |
|
482 | + return $this->get_due_date_gmt($context); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | * @param string $context View or edit context. |
490 | 490 | * @return string |
491 | 491 | */ |
492 | - public function get_completed_date( $context = 'view' ) { |
|
493 | - return $this->get_prop( 'completed_date', $context ); |
|
492 | + public function get_completed_date($context = 'view') { |
|
493 | + return $this->get_prop('completed_date', $context); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | * @param string $context View or edit context. |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public function get_date_completed( $context = 'view' ) { |
|
504 | - return $this->get_completed_date( $context ); |
|
503 | + public function get_date_completed($context = 'view') { |
|
504 | + return $this->get_completed_date($context); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -511,11 +511,11 @@ discard block |
||
511 | 511 | * @param string $context View or edit context. |
512 | 512 | * @return string |
513 | 513 | */ |
514 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
515 | - $date = $this->get_completed_date( $context ); |
|
514 | + public function get_completed_date_gmt($context = 'view') { |
|
515 | + $date = $this->get_completed_date($context); |
|
516 | 516 | |
517 | - if ( $date ) { |
|
518 | - $date = get_gmt_from_date( $date ); |
|
517 | + if ($date) { |
|
518 | + $date = get_gmt_from_date($date); |
|
519 | 519 | } |
520 | 520 | return $date; |
521 | 521 | } |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | * @param string $context View or edit context. |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
531 | - return $this->get_completed_date_gmt( $context ); |
|
530 | + public function get_gmt_completed_date($context = 'view') { |
|
531 | + return $this->get_completed_date_gmt($context); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | /** |
@@ -538,12 +538,12 @@ discard block |
||
538 | 538 | * @param string $context View or edit context. |
539 | 539 | * @return string |
540 | 540 | */ |
541 | - public function get_number( $context = 'view' ) { |
|
542 | - $number = $this->get_prop( 'number', $context ); |
|
541 | + public function get_number($context = 'view') { |
|
542 | + $number = $this->get_prop('number', $context); |
|
543 | 543 | |
544 | - if ( empty( $number ) ) { |
|
544 | + if (empty($number)) { |
|
545 | 545 | $number = $this->generate_number(); |
546 | - $this->set_number( $number ); |
|
546 | + $this->set_number($number); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | return $number; |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | * @param string $context View or edit context. |
557 | 557 | * @return string |
558 | 558 | */ |
559 | - public function get_key( $context = 'view' ) { |
|
560 | - $key = $this->get_prop( 'key', $context ); |
|
559 | + public function get_key($context = 'view') { |
|
560 | + $key = $this->get_prop('key', $context); |
|
561 | 561 | |
562 | - if ( empty( $key ) ) { |
|
563 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
564 | - $this->set_key( $key ); |
|
562 | + if (empty($key)) { |
|
563 | + $key = $this->generate_key($this->get_type() . '_'); |
|
564 | + $this->set_key($key); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | return $key; |
@@ -574,23 +574,23 @@ discard block |
||
574 | 574 | * @param string $context View or edit context. |
575 | 575 | * @return string |
576 | 576 | */ |
577 | - public function get_type( $context = 'view' ) { |
|
578 | - return $this->get_prop( 'type', $context ); |
|
577 | + public function get_type($context = 'view') { |
|
578 | + return $this->get_prop('type', $context); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
582 | 582 | * @deprecated |
583 | 583 | */ |
584 | - public function get_invoice_quote_type( $post_id ) { |
|
585 | - if ( empty( $post_id ) ) { |
|
584 | + public function get_invoice_quote_type($post_id) { |
|
585 | + if (empty($post_id)) { |
|
586 | 586 | return ''; |
587 | 587 | } |
588 | 588 | |
589 | - $type = get_post_type( $post_id ); |
|
589 | + $type = get_post_type($post_id); |
|
590 | 590 | |
591 | - if ( 'wpi_invoice' === $type ) { |
|
591 | + if ('wpi_invoice' === $type) { |
|
592 | 592 | $post_type = __('Invoice', 'invoicing'); |
593 | - } else{ |
|
593 | + } else { |
|
594 | 594 | $post_type = __('Quote', 'invoicing'); |
595 | 595 | } |
596 | 596 | |
@@ -604,8 +604,8 @@ discard block |
||
604 | 604 | * @param string $context View or edit context. |
605 | 605 | * @return string |
606 | 606 | */ |
607 | - public function get_post_type( $context = 'view' ) { |
|
608 | - return $this->get_prop( 'post_type', $context ); |
|
607 | + public function get_post_type($context = 'view') { |
|
608 | + return $this->get_prop('post_type', $context); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
@@ -615,8 +615,8 @@ discard block |
||
615 | 615 | * @param string $context View or edit context. |
616 | 616 | * @return string |
617 | 617 | */ |
618 | - public function get_mode( $context = 'view' ) { |
|
619 | - return $this->get_prop( 'mode', $context ); |
|
618 | + public function get_mode($context = 'view') { |
|
619 | + return $this->get_prop('mode', $context); |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -626,12 +626,12 @@ discard block |
||
626 | 626 | * @param string $context View or edit context. |
627 | 627 | * @return string |
628 | 628 | */ |
629 | - public function get_path( $context = 'view' ) { |
|
630 | - $path = $this->get_prop( 'path', $context ); |
|
629 | + public function get_path($context = 'view') { |
|
630 | + $path = $this->get_prop('path', $context); |
|
631 | 631 | |
632 | - if ( empty( $path ) ) { |
|
633 | - $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type ); |
|
634 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
632 | + if (empty($path)) { |
|
633 | + $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type); |
|
634 | + $path = sanitize_title($prefix . $this->get_id()); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | return $path; |
@@ -644,8 +644,8 @@ discard block |
||
644 | 644 | * @param string $context View or edit context. |
645 | 645 | * @return string |
646 | 646 | */ |
647 | - public function get_name( $context = 'view' ) { |
|
648 | - return $this->get_prop( 'title', $context ); |
|
647 | + public function get_name($context = 'view') { |
|
648 | + return $this->get_prop('title', $context); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | * @param string $context View or edit context. |
656 | 656 | * @return string |
657 | 657 | */ |
658 | - public function get_title( $context = 'view' ) { |
|
659 | - return $this->get_name( $context ); |
|
658 | + public function get_title($context = 'view') { |
|
659 | + return $this->get_name($context); |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | /** |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | * @param string $context View or edit context. |
667 | 667 | * @return string |
668 | 668 | */ |
669 | - public function get_description( $context = 'view' ) { |
|
670 | - return $this->get_prop( 'description', $context ); |
|
669 | + public function get_description($context = 'view') { |
|
670 | + return $this->get_prop('description', $context); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | * @param string $context View or edit context. |
678 | 678 | * @return string |
679 | 679 | */ |
680 | - public function get_excerpt( $context = 'view' ) { |
|
681 | - return $this->get_description( $context ); |
|
680 | + public function get_excerpt($context = 'view') { |
|
681 | + return $this->get_description($context); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -688,8 +688,8 @@ discard block |
||
688 | 688 | * @param string $context View or edit context. |
689 | 689 | * @return string |
690 | 690 | */ |
691 | - public function get_summary( $context = 'view' ) { |
|
692 | - return $this->get_description( $context ); |
|
691 | + public function get_summary($context = 'view') { |
|
692 | + return $this->get_description($context); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | /** |
@@ -699,25 +699,25 @@ discard block |
||
699 | 699 | * @param string $context View or edit context. |
700 | 700 | * @return array |
701 | 701 | */ |
702 | - public function get_user_info( $context = 'view' ) { |
|
702 | + public function get_user_info($context = 'view') { |
|
703 | 703 | |
704 | 704 | $user_info = array( |
705 | - 'user_id' => $this->get_user_id( $context ), |
|
706 | - 'email' => $this->get_email( $context ), |
|
707 | - 'first_name' => $this->get_first_name( $context ), |
|
708 | - 'last_name' => $this->get_last_name( $context ), |
|
709 | - 'address' => $this->get_address( $context ), |
|
710 | - 'phone' => $this->get_phone( $context ), |
|
711 | - 'city' => $this->get_city( $context ), |
|
712 | - 'country' => $this->get_country( $context ), |
|
713 | - 'state' => $this->get_state( $context ), |
|
714 | - 'zip' => $this->get_zip( $context ), |
|
715 | - 'company' => $this->get_company( $context ), |
|
716 | - 'vat_number' => $this->get_vat_number( $context ), |
|
717 | - 'discount' => $this->get_discount_code( $context ), |
|
705 | + 'user_id' => $this->get_user_id($context), |
|
706 | + 'email' => $this->get_email($context), |
|
707 | + 'first_name' => $this->get_first_name($context), |
|
708 | + 'last_name' => $this->get_last_name($context), |
|
709 | + 'address' => $this->get_address($context), |
|
710 | + 'phone' => $this->get_phone($context), |
|
711 | + 'city' => $this->get_city($context), |
|
712 | + 'country' => $this->get_country($context), |
|
713 | + 'state' => $this->get_state($context), |
|
714 | + 'zip' => $this->get_zip($context), |
|
715 | + 'company' => $this->get_company($context), |
|
716 | + 'vat_number' => $this->get_vat_number($context), |
|
717 | + 'discount' => $this->get_discount_code($context), |
|
718 | 718 | ); |
719 | 719 | |
720 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
720 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
721 | 721 | |
722 | 722 | } |
723 | 723 | |
@@ -728,8 +728,8 @@ discard block |
||
728 | 728 | * @param string $context View or edit context. |
729 | 729 | * @return int |
730 | 730 | */ |
731 | - public function get_author( $context = 'view' ) { |
|
732 | - return (int) $this->get_prop( 'author', $context ); |
|
731 | + public function get_author($context = 'view') { |
|
732 | + return (int) $this->get_prop('author', $context); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -739,8 +739,8 @@ discard block |
||
739 | 739 | * @param string $context View or edit context. |
740 | 740 | * @return int |
741 | 741 | */ |
742 | - public function get_user_id( $context = 'view' ) { |
|
743 | - return $this->get_author( $context ); |
|
742 | + public function get_user_id($context = 'view') { |
|
743 | + return $this->get_author($context); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
@@ -750,8 +750,8 @@ discard block |
||
750 | 750 | * @param string $context View or edit context. |
751 | 751 | * @return int |
752 | 752 | */ |
753 | - public function get_customer_id( $context = 'view' ) { |
|
754 | - return $this->get_author( $context ); |
|
753 | + public function get_customer_id($context = 'view') { |
|
754 | + return $this->get_author($context); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -761,8 +761,8 @@ discard block |
||
761 | 761 | * @param string $context View or edit context. |
762 | 762 | * @return string |
763 | 763 | */ |
764 | - public function get_ip( $context = 'view' ) { |
|
765 | - return $this->get_prop( 'user_ip', $context ); |
|
764 | + public function get_ip($context = 'view') { |
|
765 | + return $this->get_prop('user_ip', $context); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -772,8 +772,8 @@ discard block |
||
772 | 772 | * @param string $context View or edit context. |
773 | 773 | * @return string |
774 | 774 | */ |
775 | - public function get_user_ip( $context = 'view' ) { |
|
776 | - return $this->get_ip( $context ); |
|
775 | + public function get_user_ip($context = 'view') { |
|
776 | + return $this->get_ip($context); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | * @param string $context View or edit context. |
784 | 784 | * @return string |
785 | 785 | */ |
786 | - public function get_customer_ip( $context = 'view' ) { |
|
787 | - return $this->get_ip( $context ); |
|
786 | + public function get_customer_ip($context = 'view') { |
|
787 | + return $this->get_ip($context); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | /** |
@@ -794,8 +794,8 @@ discard block |
||
794 | 794 | * @param string $context View or edit context. |
795 | 795 | * @return string |
796 | 796 | */ |
797 | - public function get_first_name( $context = 'view' ) { |
|
798 | - return $this->get_prop( 'first_name', $context ); |
|
797 | + public function get_first_name($context = 'view') { |
|
798 | + return $this->get_prop('first_name', $context); |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
@@ -805,8 +805,8 @@ discard block |
||
805 | 805 | * @param string $context View or edit context. |
806 | 806 | * @return int |
807 | 807 | */ |
808 | - public function get_user_first_name( $context = 'view' ) { |
|
809 | - return $this->get_first_name( $context ); |
|
808 | + public function get_user_first_name($context = 'view') { |
|
809 | + return $this->get_first_name($context); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -816,8 +816,8 @@ discard block |
||
816 | 816 | * @param string $context View or edit context. |
817 | 817 | * @return int |
818 | 818 | */ |
819 | - public function get_customer_first_name( $context = 'view' ) { |
|
820 | - return $this->get_first_name( $context ); |
|
819 | + public function get_customer_first_name($context = 'view') { |
|
820 | + return $this->get_first_name($context); |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | /** |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | * @param string $context View or edit context. |
828 | 828 | * @return string |
829 | 829 | */ |
830 | - public function get_last_name( $context = 'view' ) { |
|
831 | - return $this->get_prop( 'last_name', $context ); |
|
830 | + public function get_last_name($context = 'view') { |
|
831 | + return $this->get_prop('last_name', $context); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | /** |
@@ -838,8 +838,8 @@ discard block |
||
838 | 838 | * @param string $context View or edit context. |
839 | 839 | * @return int |
840 | 840 | */ |
841 | - public function get_user_last_name( $context = 'view' ) { |
|
842 | - return $this->get_last_name( $context ); |
|
841 | + public function get_user_last_name($context = 'view') { |
|
842 | + return $this->get_last_name($context); |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | /** |
@@ -849,8 +849,8 @@ discard block |
||
849 | 849 | * @param string $context View or edit context. |
850 | 850 | * @return int |
851 | 851 | */ |
852 | - public function get_customer_last_name( $context = 'view' ) { |
|
853 | - return $this->get_last_name( $context ); |
|
852 | + public function get_customer_last_name($context = 'view') { |
|
853 | + return $this->get_last_name($context); |
|
854 | 854 | } |
855 | 855 | |
856 | 856 | /** |
@@ -860,8 +860,8 @@ discard block |
||
860 | 860 | * @param string $context View or edit context. |
861 | 861 | * @return string |
862 | 862 | */ |
863 | - public function get_full_name( $context = 'view' ) { |
|
864 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
863 | + public function get_full_name($context = 'view') { |
|
864 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | /** |
@@ -871,8 +871,8 @@ discard block |
||
871 | 871 | * @param string $context View or edit context. |
872 | 872 | * @return int |
873 | 873 | */ |
874 | - public function get_user_full_name( $context = 'view' ) { |
|
875 | - return $this->get_full_name( $context ); |
|
874 | + public function get_user_full_name($context = 'view') { |
|
875 | + return $this->get_full_name($context); |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
@@ -882,8 +882,8 @@ discard block |
||
882 | 882 | * @param string $context View or edit context. |
883 | 883 | * @return int |
884 | 884 | */ |
885 | - public function get_customer_full_name( $context = 'view' ) { |
|
886 | - return $this->get_full_name( $context ); |
|
885 | + public function get_customer_full_name($context = 'view') { |
|
886 | + return $this->get_full_name($context); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | /** |
@@ -893,8 +893,8 @@ discard block |
||
893 | 893 | * @param string $context View or edit context. |
894 | 894 | * @return string |
895 | 895 | */ |
896 | - public function get_phone( $context = 'view' ) { |
|
897 | - return $this->get_prop( 'phone', $context ); |
|
896 | + public function get_phone($context = 'view') { |
|
897 | + return $this->get_prop('phone', $context); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | /** |
@@ -904,8 +904,8 @@ discard block |
||
904 | 904 | * @param string $context View or edit context. |
905 | 905 | * @return int |
906 | 906 | */ |
907 | - public function get_phone_number( $context = 'view' ) { |
|
908 | - return $this->get_phone( $context ); |
|
907 | + public function get_phone_number($context = 'view') { |
|
908 | + return $this->get_phone($context); |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | /** |
@@ -915,8 +915,8 @@ discard block |
||
915 | 915 | * @param string $context View or edit context. |
916 | 916 | * @return int |
917 | 917 | */ |
918 | - public function get_user_phone( $context = 'view' ) { |
|
919 | - return $this->get_phone( $context ); |
|
918 | + public function get_user_phone($context = 'view') { |
|
919 | + return $this->get_phone($context); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | /** |
@@ -926,8 +926,8 @@ discard block |
||
926 | 926 | * @param string $context View or edit context. |
927 | 927 | * @return int |
928 | 928 | */ |
929 | - public function get_customer_phone( $context = 'view' ) { |
|
930 | - return $this->get_phone( $context ); |
|
929 | + public function get_customer_phone($context = 'view') { |
|
930 | + return $this->get_phone($context); |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | /** |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | * @param string $context View or edit context. |
938 | 938 | * @return string |
939 | 939 | */ |
940 | - public function get_email( $context = 'view' ) { |
|
941 | - return $this->get_prop( 'email', $context ); |
|
940 | + public function get_email($context = 'view') { |
|
941 | + return $this->get_prop('email', $context); |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | /** |
@@ -948,8 +948,8 @@ discard block |
||
948 | 948 | * @param string $context View or edit context. |
949 | 949 | * @return string |
950 | 950 | */ |
951 | - public function get_email_address( $context = 'view' ) { |
|
952 | - return $this->get_email( $context ); |
|
951 | + public function get_email_address($context = 'view') { |
|
952 | + return $this->get_email($context); |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | /** |
@@ -959,8 +959,8 @@ discard block |
||
959 | 959 | * @param string $context View or edit context. |
960 | 960 | * @return int |
961 | 961 | */ |
962 | - public function get_user_email( $context = 'view' ) { |
|
963 | - return $this->get_email( $context ); |
|
962 | + public function get_user_email($context = 'view') { |
|
963 | + return $this->get_email($context); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -970,8 +970,8 @@ discard block |
||
970 | 970 | * @param string $context View or edit context. |
971 | 971 | * @return int |
972 | 972 | */ |
973 | - public function get_customer_email( $context = 'view' ) { |
|
974 | - return $this->get_email( $context ); |
|
973 | + public function get_customer_email($context = 'view') { |
|
974 | + return $this->get_email($context); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | /** |
@@ -981,9 +981,9 @@ discard block |
||
981 | 981 | * @param string $context View or edit context. |
982 | 982 | * @return string |
983 | 983 | */ |
984 | - public function get_country( $context = 'view' ) { |
|
985 | - $country = $this->get_prop( 'country', $context ); |
|
986 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
984 | + public function get_country($context = 'view') { |
|
985 | + $country = $this->get_prop('country', $context); |
|
986 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | /** |
@@ -993,8 +993,8 @@ discard block |
||
993 | 993 | * @param string $context View or edit context. |
994 | 994 | * @return int |
995 | 995 | */ |
996 | - public function get_user_country( $context = 'view' ) { |
|
997 | - return $this->get_country( $context ); |
|
996 | + public function get_user_country($context = 'view') { |
|
997 | + return $this->get_country($context); |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | /** |
@@ -1004,8 +1004,8 @@ discard block |
||
1004 | 1004 | * @param string $context View or edit context. |
1005 | 1005 | * @return int |
1006 | 1006 | */ |
1007 | - public function get_customer_country( $context = 'view' ) { |
|
1008 | - return $this->get_country( $context ); |
|
1007 | + public function get_customer_country($context = 'view') { |
|
1008 | + return $this->get_country($context); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | /** |
@@ -1015,9 +1015,9 @@ discard block |
||
1015 | 1015 | * @param string $context View or edit context. |
1016 | 1016 | * @return string |
1017 | 1017 | */ |
1018 | - public function get_state( $context = 'view' ) { |
|
1019 | - $state = $this->get_prop( 'state', $context ); |
|
1020 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1018 | + public function get_state($context = 'view') { |
|
1019 | + $state = $this->get_prop('state', $context); |
|
1020 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
@@ -1027,8 +1027,8 @@ discard block |
||
1027 | 1027 | * @param string $context View or edit context. |
1028 | 1028 | * @return int |
1029 | 1029 | */ |
1030 | - public function get_user_state( $context = 'view' ) { |
|
1031 | - return $this->get_state( $context ); |
|
1030 | + public function get_user_state($context = 'view') { |
|
1031 | + return $this->get_state($context); |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | /** |
@@ -1038,8 +1038,8 @@ discard block |
||
1038 | 1038 | * @param string $context View or edit context. |
1039 | 1039 | * @return int |
1040 | 1040 | */ |
1041 | - public function get_customer_state( $context = 'view' ) { |
|
1042 | - return $this->get_state( $context ); |
|
1041 | + public function get_customer_state($context = 'view') { |
|
1042 | + return $this->get_state($context); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | /** |
@@ -1049,8 +1049,8 @@ discard block |
||
1049 | 1049 | * @param string $context View or edit context. |
1050 | 1050 | * @return string |
1051 | 1051 | */ |
1052 | - public function get_city( $context = 'view' ) { |
|
1053 | - return $this->get_prop( 'city', $context ); |
|
1052 | + public function get_city($context = 'view') { |
|
1053 | + return $this->get_prop('city', $context); |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | /** |
@@ -1060,8 +1060,8 @@ discard block |
||
1060 | 1060 | * @param string $context View or edit context. |
1061 | 1061 | * @return string |
1062 | 1062 | */ |
1063 | - public function get_user_city( $context = 'view' ) { |
|
1064 | - return $this->get_city( $context ); |
|
1063 | + public function get_user_city($context = 'view') { |
|
1064 | + return $this->get_city($context); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | /** |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * @param string $context View or edit context. |
1072 | 1072 | * @return string |
1073 | 1073 | */ |
1074 | - public function get_customer_city( $context = 'view' ) { |
|
1075 | - return $this->get_city( $context ); |
|
1074 | + public function get_customer_city($context = 'view') { |
|
1075 | + return $this->get_city($context); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | /** |
@@ -1082,8 +1082,8 @@ discard block |
||
1082 | 1082 | * @param string $context View or edit context. |
1083 | 1083 | * @return string |
1084 | 1084 | */ |
1085 | - public function get_zip( $context = 'view' ) { |
|
1086 | - return $this->get_prop( 'zip', $context ); |
|
1085 | + public function get_zip($context = 'view') { |
|
1086 | + return $this->get_prop('zip', $context); |
|
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | /** |
@@ -1093,8 +1093,8 @@ discard block |
||
1093 | 1093 | * @param string $context View or edit context. |
1094 | 1094 | * @return string |
1095 | 1095 | */ |
1096 | - public function get_user_zip( $context = 'view' ) { |
|
1097 | - return $this->get_zip( $context ); |
|
1096 | + public function get_user_zip($context = 'view') { |
|
1097 | + return $this->get_zip($context); |
|
1098 | 1098 | } |
1099 | 1099 | |
1100 | 1100 | /** |
@@ -1104,8 +1104,8 @@ discard block |
||
1104 | 1104 | * @param string $context View or edit context. |
1105 | 1105 | * @return string |
1106 | 1106 | */ |
1107 | - public function get_customer_zip( $context = 'view' ) { |
|
1108 | - return $this->get_zip( $context ); |
|
1107 | + public function get_customer_zip($context = 'view') { |
|
1108 | + return $this->get_zip($context); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | /** |
@@ -1115,8 +1115,8 @@ discard block |
||
1115 | 1115 | * @param string $context View or edit context. |
1116 | 1116 | * @return string |
1117 | 1117 | */ |
1118 | - public function get_company( $context = 'view' ) { |
|
1119 | - return $this->get_prop( 'company', $context ); |
|
1118 | + public function get_company($context = 'view') { |
|
1119 | + return $this->get_prop('company', $context); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | /** |
@@ -1126,8 +1126,8 @@ discard block |
||
1126 | 1126 | * @param string $context View or edit context. |
1127 | 1127 | * @return string |
1128 | 1128 | */ |
1129 | - public function get_user_company( $context = 'view' ) { |
|
1130 | - return $this->get_company( $context ); |
|
1129 | + public function get_user_company($context = 'view') { |
|
1130 | + return $this->get_company($context); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | /** |
@@ -1137,8 +1137,8 @@ discard block |
||
1137 | 1137 | * @param string $context View or edit context. |
1138 | 1138 | * @return string |
1139 | 1139 | */ |
1140 | - public function get_customer_company( $context = 'view' ) { |
|
1141 | - return $this->get_company( $context ); |
|
1140 | + public function get_customer_company($context = 'view') { |
|
1141 | + return $this->get_company($context); |
|
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | /** |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | * @param string $context View or edit context. |
1149 | 1149 | * @return string |
1150 | 1150 | */ |
1151 | - public function get_vat_number( $context = 'view' ) { |
|
1152 | - return $this->get_prop( 'vat_number', $context ); |
|
1151 | + public function get_vat_number($context = 'view') { |
|
1152 | + return $this->get_prop('vat_number', $context); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | /** |
@@ -1159,8 +1159,8 @@ discard block |
||
1159 | 1159 | * @param string $context View or edit context. |
1160 | 1160 | * @return string |
1161 | 1161 | */ |
1162 | - public function get_user_vat_number( $context = 'view' ) { |
|
1163 | - return $this->get_vat_number( $context ); |
|
1162 | + public function get_user_vat_number($context = 'view') { |
|
1163 | + return $this->get_vat_number($context); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | /** |
@@ -1170,8 +1170,8 @@ discard block |
||
1170 | 1170 | * @param string $context View or edit context. |
1171 | 1171 | * @return string |
1172 | 1172 | */ |
1173 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1174 | - return $this->get_vat_number( $context ); |
|
1173 | + public function get_customer_vat_number($context = 'view') { |
|
1174 | + return $this->get_vat_number($context); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | /** |
@@ -1181,8 +1181,8 @@ discard block |
||
1181 | 1181 | * @param string $context View or edit context. |
1182 | 1182 | * @return string |
1183 | 1183 | */ |
1184 | - public function get_vat_rate( $context = 'view' ) { |
|
1185 | - return $this->get_prop( 'vat_rate', $context ); |
|
1184 | + public function get_vat_rate($context = 'view') { |
|
1185 | + return $this->get_prop('vat_rate', $context); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | /** |
@@ -1192,8 +1192,8 @@ discard block |
||
1192 | 1192 | * @param string $context View or edit context. |
1193 | 1193 | * @return string |
1194 | 1194 | */ |
1195 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1196 | - return $this->get_vat_rate( $context ); |
|
1195 | + public function get_user_vat_rate($context = 'view') { |
|
1196 | + return $this->get_vat_rate($context); |
|
1197 | 1197 | } |
1198 | 1198 | |
1199 | 1199 | /** |
@@ -1203,8 +1203,8 @@ discard block |
||
1203 | 1203 | * @param string $context View or edit context. |
1204 | 1204 | * @return string |
1205 | 1205 | */ |
1206 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1207 | - return $this->get_vat_rate( $context ); |
|
1206 | + public function get_customer_vat_rate($context = 'view') { |
|
1207 | + return $this->get_vat_rate($context); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | /** |
@@ -1214,8 +1214,8 @@ discard block |
||
1214 | 1214 | * @param string $context View or edit context. |
1215 | 1215 | * @return string |
1216 | 1216 | */ |
1217 | - public function get_address( $context = 'view' ) { |
|
1218 | - return $this->get_prop( 'address', $context ); |
|
1217 | + public function get_address($context = 'view') { |
|
1218 | + return $this->get_prop('address', $context); |
|
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | /** |
@@ -1225,8 +1225,8 @@ discard block |
||
1225 | 1225 | * @param string $context View or edit context. |
1226 | 1226 | * @return string |
1227 | 1227 | */ |
1228 | - public function get_user_address( $context = 'view' ) { |
|
1229 | - return $this->get_address( $context ); |
|
1228 | + public function get_user_address($context = 'view') { |
|
1229 | + return $this->get_address($context); |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | /** |
@@ -1236,8 +1236,8 @@ discard block |
||
1236 | 1236 | * @param string $context View or edit context. |
1237 | 1237 | * @return string |
1238 | 1238 | */ |
1239 | - public function get_customer_address( $context = 'view' ) { |
|
1240 | - return $this->get_address( $context ); |
|
1239 | + public function get_customer_address($context = 'view') { |
|
1240 | + return $this->get_address($context); |
|
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | /** |
@@ -1247,8 +1247,8 @@ discard block |
||
1247 | 1247 | * @param string $context View or edit context. |
1248 | 1248 | * @return bool |
1249 | 1249 | */ |
1250 | - public function get_is_viewed( $context = 'view' ) { |
|
1251 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1250 | + public function get_is_viewed($context = 'view') { |
|
1251 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | /** |
@@ -1258,8 +1258,8 @@ discard block |
||
1258 | 1258 | * @param string $context View or edit context. |
1259 | 1259 | * @return bool |
1260 | 1260 | */ |
1261 | - public function get_email_cc( $context = 'view' ) { |
|
1262 | - return $this->get_prop( 'email_cc', $context ); |
|
1261 | + public function get_email_cc($context = 'view') { |
|
1262 | + return $this->get_prop('email_cc', $context); |
|
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | /** |
@@ -1269,8 +1269,8 @@ discard block |
||
1269 | 1269 | * @param string $context View or edit context. |
1270 | 1270 | * @return bool |
1271 | 1271 | */ |
1272 | - public function get_template( $context = 'view' ) { |
|
1273 | - return $this->get_prop( 'template', $context ); |
|
1272 | + public function get_template($context = 'view') { |
|
1273 | + return $this->get_prop('template', $context); |
|
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | /** |
@@ -1280,8 +1280,8 @@ discard block |
||
1280 | 1280 | * @param string $context View or edit context. |
1281 | 1281 | * @return bool |
1282 | 1282 | */ |
1283 | - public function get_address_confirmed( $context = 'view' ) { |
|
1284 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1283 | + public function get_address_confirmed($context = 'view') { |
|
1284 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | /** |
@@ -1291,8 +1291,8 @@ discard block |
||
1291 | 1291 | * @param string $context View or edit context. |
1292 | 1292 | * @return bool |
1293 | 1293 | */ |
1294 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1295 | - return $this->get_address_confirmed( $context ); |
|
1294 | + public function get_user_address_confirmed($context = 'view') { |
|
1295 | + return $this->get_address_confirmed($context); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | /** |
@@ -1302,8 +1302,8 @@ discard block |
||
1302 | 1302 | * @param string $context View or edit context. |
1303 | 1303 | * @return bool |
1304 | 1304 | */ |
1305 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1306 | - return $this->get_address_confirmed( $context ); |
|
1305 | + public function get_customer_address_confirmed($context = 'view') { |
|
1306 | + return $this->get_address_confirmed($context); |
|
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | /** |
@@ -1313,12 +1313,12 @@ discard block |
||
1313 | 1313 | * @param string $context View or edit context. |
1314 | 1314 | * @return float |
1315 | 1315 | */ |
1316 | - public function get_subtotal( $context = 'view' ) { |
|
1317 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1316 | + public function get_subtotal($context = 'view') { |
|
1317 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1318 | 1318 | |
1319 | 1319 | // Backwards compatibility. |
1320 | - if ( is_bool( $context ) && $context ) { |
|
1321 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
1320 | + if (is_bool($context) && $context) { |
|
1321 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | return $subtotal; |
@@ -1331,8 +1331,8 @@ discard block |
||
1331 | 1331 | * @param string $context View or edit context. |
1332 | 1332 | * @return float |
1333 | 1333 | */ |
1334 | - public function get_total_discount( $context = 'view' ) { |
|
1335 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
1334 | + public function get_total_discount($context = 'view') { |
|
1335 | + return (float) $this->get_prop('total_discount', $context); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | /** |
@@ -1342,18 +1342,18 @@ discard block |
||
1342 | 1342 | * @param string $context View or edit context. |
1343 | 1343 | * @return float |
1344 | 1344 | */ |
1345 | - public function get_total_tax( $context = 'view' ) { |
|
1346 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
1345 | + public function get_total_tax($context = 'view') { |
|
1346 | + return (float) $this->get_prop('total_tax', $context); |
|
1347 | 1347 | } |
1348 | 1348 | |
1349 | 1349 | /** |
1350 | 1350 | * @deprecated |
1351 | 1351 | */ |
1352 | - public function get_final_tax( $currency = false ) { |
|
1352 | + public function get_final_tax($currency = false) { |
|
1353 | 1353 | $tax = $this->get_total_tax(); |
1354 | 1354 | |
1355 | - if ( $currency ) { |
|
1356 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
1355 | + if ($currency) { |
|
1356 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | return $tax; |
@@ -1366,8 +1366,8 @@ discard block |
||
1366 | 1366 | * @param string $context View or edit context. |
1367 | 1367 | * @return float |
1368 | 1368 | */ |
1369 | - public function get_total_fees( $context = 'view' ) { |
|
1370 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
1369 | + public function get_total_fees($context = 'view') { |
|
1370 | + return (float) $this->get_prop('total_fees', $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 float |
1379 | 1379 | */ |
1380 | - public function get_fees_total( $context = 'view' ) { |
|
1381 | - return $this->get_total_fees( $context ); |
|
1380 | + public function get_fees_total($context = 'view') { |
|
1381 | + return $this->get_total_fees($context); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | /** |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | */ |
1390 | 1390 | public function get_total() { |
1391 | 1391 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
1392 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1392 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | /** |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | */ |
1412 | 1412 | public function get_initial_total() { |
1413 | 1413 | |
1414 | - if ( empty( $this->totals ) ) { |
|
1414 | + if (empty($this->totals)) { |
|
1415 | 1415 | $this->recalculate_total(); |
1416 | 1416 | } |
1417 | 1417 | |
@@ -1421,11 +1421,11 @@ discard block |
||
1421 | 1421 | $subtotal = $this->totals['subtotal']['initial']; |
1422 | 1422 | $total = $tax + $fee - $discount + $subtotal; |
1423 | 1423 | |
1424 | - if ( 0 > $total ) { |
|
1424 | + if (0 > $total) { |
|
1425 | 1425 | $total = 0; |
1426 | 1426 | } |
1427 | 1427 | |
1428 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1428 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1429 | 1429 | } |
1430 | 1430 | |
1431 | 1431 | /** |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | */ |
1438 | 1438 | public function get_recurring_total() { |
1439 | 1439 | |
1440 | - if ( empty( $this->totals ) ) { |
|
1440 | + if (empty($this->totals)) { |
|
1441 | 1441 | $this->recalculate_total(); |
1442 | 1442 | } |
1443 | 1443 | |
@@ -1447,11 +1447,11 @@ discard block |
||
1447 | 1447 | $subtotal = $this->totals['subtotal']['recurring']; |
1448 | 1448 | $total = $tax + $fee - $discount + $subtotal; |
1449 | 1449 | |
1450 | - if ( 0 > $total ) { |
|
1450 | + if (0 > $total) { |
|
1451 | 1451 | $total = 0; |
1452 | 1452 | } |
1453 | 1453 | |
1454 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1454 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1455 | 1455 | } |
1456 | 1456 | |
1457 | 1457 | /** |
@@ -1462,10 +1462,10 @@ discard block |
||
1462 | 1462 | * @param string $currency Whether to include the currency. |
1463 | 1463 | * @return float |
1464 | 1464 | */ |
1465 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1465 | + public function get_recurring_details($field = '', $currency = false) { |
|
1466 | 1466 | |
1467 | 1467 | // Maybe recalculate totals. |
1468 | - if ( empty( $this->totals ) ) { |
|
1468 | + if (empty($this->totals)) { |
|
1469 | 1469 | $this->recalculate_total(); |
1470 | 1470 | } |
1471 | 1471 | |
@@ -1485,8 +1485,8 @@ discard block |
||
1485 | 1485 | $currency |
1486 | 1486 | ); |
1487 | 1487 | |
1488 | - if ( isset( $data[$field] ) ) { |
|
1489 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1488 | + if (isset($data[$field])) { |
|
1489 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | return $data; |
@@ -1499,8 +1499,8 @@ discard block |
||
1499 | 1499 | * @param string $context View or edit context. |
1500 | 1500 | * @return array |
1501 | 1501 | */ |
1502 | - public function get_fees( $context = 'view' ) { |
|
1503 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1502 | + public function get_fees($context = 'view') { |
|
1503 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1504 | 1504 | } |
1505 | 1505 | |
1506 | 1506 | /** |
@@ -1510,8 +1510,8 @@ discard block |
||
1510 | 1510 | * @param string $context View or edit context. |
1511 | 1511 | * @return array |
1512 | 1512 | */ |
1513 | - public function get_discounts( $context = 'view' ) { |
|
1514 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1513 | + public function get_discounts($context = 'view') { |
|
1514 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1515 | 1515 | } |
1516 | 1516 | |
1517 | 1517 | /** |
@@ -1521,8 +1521,8 @@ discard block |
||
1521 | 1521 | * @param string $context View or edit context. |
1522 | 1522 | * @return array |
1523 | 1523 | */ |
1524 | - public function get_taxes( $context = 'view' ) { |
|
1525 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1524 | + public function get_taxes($context = 'view') { |
|
1525 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | /** |
@@ -1532,8 +1532,8 @@ discard block |
||
1532 | 1532 | * @param string $context View or edit context. |
1533 | 1533 | * @return GetPaid_Form_Item[] |
1534 | 1534 | */ |
1535 | - public function get_items( $context = 'view' ) { |
|
1536 | - return $this->get_prop( 'items', $context ); |
|
1535 | + public function get_items($context = 'view') { |
|
1536 | + return $this->get_prop('items', $context); |
|
1537 | 1537 | } |
1538 | 1538 | |
1539 | 1539 | /** |
@@ -1543,8 +1543,8 @@ discard block |
||
1543 | 1543 | * @param string $context View or edit context. |
1544 | 1544 | * @return int |
1545 | 1545 | */ |
1546 | - public function get_payment_form( $context = 'view' ) { |
|
1547 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1546 | + public function get_payment_form($context = 'view') { |
|
1547 | + return intval($this->get_prop('payment_form', $context)); |
|
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | /** |
@@ -1554,8 +1554,8 @@ discard block |
||
1554 | 1554 | * @param string $context View or edit context. |
1555 | 1555 | * @return string |
1556 | 1556 | */ |
1557 | - public function get_submission_id( $context = 'view' ) { |
|
1558 | - return $this->get_prop( 'submission_id', $context ); |
|
1557 | + public function get_submission_id($context = 'view') { |
|
1558 | + return $this->get_prop('submission_id', $context); |
|
1559 | 1559 | } |
1560 | 1560 | |
1561 | 1561 | /** |
@@ -1565,8 +1565,8 @@ discard block |
||
1565 | 1565 | * @param string $context View or edit context. |
1566 | 1566 | * @return string |
1567 | 1567 | */ |
1568 | - public function get_discount_code( $context = 'view' ) { |
|
1569 | - return $this->get_prop( 'discount_code', $context ); |
|
1568 | + public function get_discount_code($context = 'view') { |
|
1569 | + return $this->get_prop('discount_code', $context); |
|
1570 | 1570 | } |
1571 | 1571 | |
1572 | 1572 | /** |
@@ -1576,8 +1576,8 @@ discard block |
||
1576 | 1576 | * @param string $context View or edit context. |
1577 | 1577 | * @return string |
1578 | 1578 | */ |
1579 | - public function get_gateway( $context = 'view' ) { |
|
1580 | - return $this->get_prop( 'gateway', $context ); |
|
1579 | + public function get_gateway($context = 'view') { |
|
1580 | + return $this->get_prop('gateway', $context); |
|
1581 | 1581 | } |
1582 | 1582 | |
1583 | 1583 | /** |
@@ -1587,8 +1587,8 @@ discard block |
||
1587 | 1587 | * @return string |
1588 | 1588 | */ |
1589 | 1589 | public function get_gateway_title() { |
1590 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1591 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1590 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1591 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1592 | 1592 | } |
1593 | 1593 | |
1594 | 1594 | /** |
@@ -1598,8 +1598,8 @@ discard block |
||
1598 | 1598 | * @param string $context View or edit context. |
1599 | 1599 | * @return string |
1600 | 1600 | */ |
1601 | - public function get_transaction_id( $context = 'view' ) { |
|
1602 | - return $this->get_prop( 'transaction_id', $context ); |
|
1601 | + public function get_transaction_id($context = 'view') { |
|
1602 | + return $this->get_prop('transaction_id', $context); |
|
1603 | 1603 | } |
1604 | 1604 | |
1605 | 1605 | /** |
@@ -1609,9 +1609,9 @@ discard block |
||
1609 | 1609 | * @param string $context View or edit context. |
1610 | 1610 | * @return string |
1611 | 1611 | */ |
1612 | - public function get_currency( $context = 'view' ) { |
|
1613 | - $currency = $this->get_prop( 'currency', $context ); |
|
1614 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1612 | + public function get_currency($context = 'view') { |
|
1613 | + $currency = $this->get_prop('currency', $context); |
|
1614 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1615 | 1615 | } |
1616 | 1616 | |
1617 | 1617 | /** |
@@ -1621,8 +1621,8 @@ discard block |
||
1621 | 1621 | * @param string $context View or edit context. |
1622 | 1622 | * @return bool |
1623 | 1623 | */ |
1624 | - public function get_disable_taxes( $context = 'view' ) { |
|
1625 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1624 | + public function get_disable_taxes($context = 'view') { |
|
1625 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | /** |
@@ -1632,12 +1632,12 @@ discard block |
||
1632 | 1632 | * @param string $context View or edit context. |
1633 | 1633 | * @return int |
1634 | 1634 | */ |
1635 | - public function get_subscription_id( $context = 'view' ) { |
|
1636 | - $subscription_id = $this->get_prop( 'subscription_id', $context ); |
|
1635 | + public function get_subscription_id($context = 'view') { |
|
1636 | + $subscription_id = $this->get_prop('subscription_id', $context); |
|
1637 | 1637 | |
1638 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1638 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1639 | 1639 | $parent = $this->get_parent(); |
1640 | - return $parent->get_subscription_id( $context ); |
|
1640 | + return $parent->get_subscription_id($context); |
|
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | return $subscription_id; |
@@ -1650,20 +1650,20 @@ discard block |
||
1650 | 1650 | * @param string $context View or edit context. |
1651 | 1651 | * @return array |
1652 | 1652 | */ |
1653 | - public function get_payment_meta( $context = 'view' ) { |
|
1653 | + public function get_payment_meta($context = 'view') { |
|
1654 | 1654 | |
1655 | 1655 | return array( |
1656 | - 'price' => $this->get_total( $context ), |
|
1657 | - 'date' => $this->get_date_created( $context ), |
|
1658 | - 'user_email' => $this->get_email( $context ), |
|
1659 | - 'invoice_key' => $this->get_key( $context ), |
|
1660 | - 'currency' => $this->get_currency( $context ), |
|
1661 | - 'items' => $this->get_items( $context ), |
|
1662 | - 'user_info' => $this->get_user_info( $context ), |
|
1656 | + 'price' => $this->get_total($context), |
|
1657 | + 'date' => $this->get_date_created($context), |
|
1658 | + 'user_email' => $this->get_email($context), |
|
1659 | + 'invoice_key' => $this->get_key($context), |
|
1660 | + 'currency' => $this->get_currency($context), |
|
1661 | + 'items' => $this->get_items($context), |
|
1662 | + 'user_info' => $this->get_user_info($context), |
|
1663 | 1663 | 'cart_details' => $this->get_cart_details(), |
1664 | - 'status' => $this->get_status( $context ), |
|
1665 | - 'fees' => $this->get_fees( $context ), |
|
1666 | - 'taxes' => $this->get_taxes( $context ), |
|
1664 | + 'status' => $this->get_status($context), |
|
1665 | + 'fees' => $this->get_fees($context), |
|
1666 | + 'taxes' => $this->get_taxes($context), |
|
1667 | 1667 | ); |
1668 | 1668 | |
1669 | 1669 | } |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | $items = $this->get_items(); |
1679 | 1679 | $cart_details = array(); |
1680 | 1680 | |
1681 | - foreach ( $items as $item_id => $item ) { |
|
1681 | + foreach ($items as $item_id => $item) { |
|
1682 | 1682 | $cart_details[] = $item->prepare_data_for_saving(); |
1683 | 1683 | } |
1684 | 1684 | |
@@ -1690,11 +1690,11 @@ discard block |
||
1690 | 1690 | * |
1691 | 1691 | * @return null|GetPaid_Form_Item|int |
1692 | 1692 | */ |
1693 | - public function get_recurring( $object = false ) { |
|
1693 | + public function get_recurring($object = false) { |
|
1694 | 1694 | |
1695 | 1695 | // Are we returning an object? |
1696 | - if ( $object ) { |
|
1697 | - return $this->get_item( $this->recurring_item ); |
|
1696 | + if ($object) { |
|
1697 | + return $this->get_item($this->recurring_item); |
|
1698 | 1698 | } |
1699 | 1699 | |
1700 | 1700 | return $this->recurring_item; |
@@ -1709,15 +1709,15 @@ discard block |
||
1709 | 1709 | public function get_subscription_name() { |
1710 | 1710 | |
1711 | 1711 | // Retrieve the recurring name |
1712 | - $item = $this->get_recurring( true ); |
|
1712 | + $item = $this->get_recurring(true); |
|
1713 | 1713 | |
1714 | 1714 | // Abort if it does not exist. |
1715 | - if ( empty( $item ) ) { |
|
1715 | + if (empty($item)) { |
|
1716 | 1716 | return ''; |
1717 | 1717 | } |
1718 | 1718 | |
1719 | 1719 | // Return the item name. |
1720 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1720 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1721 | 1721 | } |
1722 | 1722 | |
1723 | 1723 | /** |
@@ -1727,9 +1727,9 @@ discard block |
||
1727 | 1727 | * @return string |
1728 | 1728 | */ |
1729 | 1729 | public function get_view_url() { |
1730 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1731 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1732 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1730 | + $invoice_url = get_permalink($this->get_id()); |
|
1731 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1732 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1733 | 1733 | } |
1734 | 1734 | |
1735 | 1735 | /** |
@@ -1738,25 +1738,25 @@ discard block |
||
1738 | 1738 | * @since 1.0.19 |
1739 | 1739 | * @return string |
1740 | 1740 | */ |
1741 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1741 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1742 | 1742 | |
1743 | 1743 | // Retrieve the checkout url. |
1744 | 1744 | $pay_url = wpinv_get_checkout_uri(); |
1745 | 1745 | |
1746 | 1746 | // Maybe force ssl. |
1747 | - if ( is_ssl() ) { |
|
1748 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1747 | + if (is_ssl()) { |
|
1748 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | // Add the invoice key. |
1752 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1752 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1753 | 1753 | |
1754 | 1754 | // (Maybe?) add a secret |
1755 | - if ( $secret ) { |
|
1756 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1755 | + if ($secret) { |
|
1756 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1757 | 1757 | } |
1758 | 1758 | |
1759 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1759 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | /** |
@@ -1771,14 +1771,14 @@ discard block |
||
1771 | 1771 | $receipt_url = wpinv_get_success_page_uri(); |
1772 | 1772 | |
1773 | 1773 | // Maybe force ssl. |
1774 | - if ( is_ssl() ) { |
|
1775 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1774 | + if (is_ssl()) { |
|
1775 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1776 | 1776 | } |
1777 | 1777 | |
1778 | 1778 | // Add the invoice key. |
1779 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1779 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1780 | 1780 | |
1781 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1781 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | /** |
@@ -1791,8 +1791,8 @@ discard block |
||
1791 | 1791 | * @param string $context View or edit context. |
1792 | 1792 | * @return mixed Value of the given invoice property (if set). |
1793 | 1793 | */ |
1794 | - public function get( $key, $context = 'view' ) { |
|
1795 | - return $this->get_prop( $key, $context ); |
|
1794 | + public function get($key, $context = 'view') { |
|
1795 | + return $this->get_prop($key, $context); |
|
1796 | 1796 | } |
1797 | 1797 | |
1798 | 1798 | /* |
@@ -1815,11 +1815,11 @@ discard block |
||
1815 | 1815 | * @param mixed $value new value. |
1816 | 1816 | * @return mixed Value of the given invoice property (if set). |
1817 | 1817 | */ |
1818 | - public function set( $key, $value ) { |
|
1818 | + public function set($key, $value) { |
|
1819 | 1819 | |
1820 | 1820 | $setter = "set_$key"; |
1821 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
1822 | - $this->{$setter}( $value ); |
|
1821 | + if (is_callable(array($this, $setter))) { |
|
1822 | + $this->{$setter}($value); |
|
1823 | 1823 | } |
1824 | 1824 | |
1825 | 1825 | } |
@@ -1833,47 +1833,47 @@ discard block |
||
1833 | 1833 | * @param bool $manual_update Is this a manual status change?. |
1834 | 1834 | * @return array details of change. |
1835 | 1835 | */ |
1836 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1836 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
1837 | 1837 | $old_status = $this->get_status(); |
1838 | 1838 | |
1839 | 1839 | $statuses = $this->get_all_statuses(); |
1840 | 1840 | |
1841 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
1842 | - unset( $statuses[ 'draft' ] ); |
|
1841 | + if (isset($statuses['draft'])) { |
|
1842 | + unset($statuses['draft']); |
|
1843 | 1843 | } |
1844 | 1844 | |
1845 | - $this->set_prop( 'status', $new_status ); |
|
1845 | + $this->set_prop('status', $new_status); |
|
1846 | 1846 | |
1847 | 1847 | // If setting the status, ensure it's set to a valid status. |
1848 | - if ( true === $this->object_read ) { |
|
1848 | + if (true === $this->object_read) { |
|
1849 | 1849 | |
1850 | 1850 | // Only allow valid new status. |
1851 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
1851 | + if (!array_key_exists($new_status, $statuses)) { |
|
1852 | 1852 | $new_status = 'wpi-pending'; |
1853 | 1853 | } |
1854 | 1854 | |
1855 | 1855 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
1856 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
1856 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
1857 | 1857 | $old_status = 'wpi-pending'; |
1858 | 1858 | } |
1859 | 1859 | |
1860 | 1860 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
1861 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
1861 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
1862 | 1862 | $old_status = 'wpi-pending'; |
1863 | 1863 | } |
1864 | 1864 | |
1865 | 1865 | } |
1866 | 1866 | |
1867 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1867 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
1868 | 1868 | $this->status_transition = array( |
1869 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1869 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
1870 | 1870 | 'to' => $new_status, |
1871 | 1871 | 'note' => $note, |
1872 | 1872 | 'manual' => (bool) $manual_update, |
1873 | 1873 | ); |
1874 | 1874 | |
1875 | - if ( $manual_update ) { |
|
1876 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1875 | + if ($manual_update) { |
|
1876 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
1877 | 1877 | } |
1878 | 1878 | |
1879 | 1879 | $this->maybe_set_date_paid(); |
@@ -1896,8 +1896,8 @@ discard block |
||
1896 | 1896 | */ |
1897 | 1897 | public function maybe_set_date_paid() { |
1898 | 1898 | |
1899 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1900 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1899 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
1900 | + $this->set_date_completed(current_time('mysql')); |
|
1901 | 1901 | } |
1902 | 1902 | } |
1903 | 1903 | |
@@ -1906,11 +1906,11 @@ discard block |
||
1906 | 1906 | * |
1907 | 1907 | * @since 1.0.19 |
1908 | 1908 | */ |
1909 | - public function set_parent_id( $value ) { |
|
1910 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1909 | + public function set_parent_id($value) { |
|
1910 | + if ($value && ($value === $this->get_id())) { |
|
1911 | 1911 | return; |
1912 | 1912 | } |
1913 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1913 | + $this->set_prop('parent_id', absint($value)); |
|
1914 | 1914 | } |
1915 | 1915 | |
1916 | 1916 | /** |
@@ -1918,8 +1918,8 @@ discard block |
||
1918 | 1918 | * |
1919 | 1919 | * @since 1.0.19 |
1920 | 1920 | */ |
1921 | - public function set_version( $value ) { |
|
1922 | - $this->set_prop( 'version', $value ); |
|
1921 | + public function set_version($value) { |
|
1922 | + $this->set_prop('version', $value); |
|
1923 | 1923 | } |
1924 | 1924 | |
1925 | 1925 | /** |
@@ -1929,15 +1929,15 @@ discard block |
||
1929 | 1929 | * @param string $value Value to set. |
1930 | 1930 | * @return bool Whether or not the date was set. |
1931 | 1931 | */ |
1932 | - public function set_date_created( $value ) { |
|
1933 | - $date = strtotime( $value ); |
|
1932 | + public function set_date_created($value) { |
|
1933 | + $date = strtotime($value); |
|
1934 | 1934 | |
1935 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1936 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
1935 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1936 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
1937 | 1937 | return true; |
1938 | 1938 | } |
1939 | 1939 | |
1940 | - return $this->set_prop( 'date_created', '' ); |
|
1940 | + return $this->set_prop('date_created', ''); |
|
1941 | 1941 | |
1942 | 1942 | } |
1943 | 1943 | |
@@ -1948,15 +1948,15 @@ discard block |
||
1948 | 1948 | * @param string $value Value to set. |
1949 | 1949 | * @return bool Whether or not the date was set. |
1950 | 1950 | */ |
1951 | - public function set_due_date( $value ) { |
|
1952 | - $date = strtotime( $value ); |
|
1951 | + public function set_due_date($value) { |
|
1952 | + $date = strtotime($value); |
|
1953 | 1953 | |
1954 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1955 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
1954 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1955 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
1956 | 1956 | return true; |
1957 | 1957 | } |
1958 | 1958 | |
1959 | - $this->set_prop( 'due_date', '' ); |
|
1959 | + $this->set_prop('due_date', ''); |
|
1960 | 1960 | return false; |
1961 | 1961 | |
1962 | 1962 | } |
@@ -1967,8 +1967,8 @@ discard block |
||
1967 | 1967 | * @since 1.0.19 |
1968 | 1968 | * @param string $value New name. |
1969 | 1969 | */ |
1970 | - public function set_date_due( $value ) { |
|
1971 | - $this->set_due_date( $value ); |
|
1970 | + public function set_date_due($value) { |
|
1971 | + $this->set_due_date($value); |
|
1972 | 1972 | } |
1973 | 1973 | |
1974 | 1974 | /** |
@@ -1978,15 +1978,15 @@ discard block |
||
1978 | 1978 | * @param string $value Value to set. |
1979 | 1979 | * @return bool Whether or not the date was set. |
1980 | 1980 | */ |
1981 | - public function set_completed_date( $value ) { |
|
1982 | - $date = strtotime( $value ); |
|
1981 | + public function set_completed_date($value) { |
|
1982 | + $date = strtotime($value); |
|
1983 | 1983 | |
1984 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1985 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
1984 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1985 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
1986 | 1986 | return true; |
1987 | 1987 | } |
1988 | 1988 | |
1989 | - $this->set_prop( 'completed_date', '' ); |
|
1989 | + $this->set_prop('completed_date', ''); |
|
1990 | 1990 | return false; |
1991 | 1991 | |
1992 | 1992 | } |
@@ -1997,8 +1997,8 @@ discard block |
||
1997 | 1997 | * @since 1.0.19 |
1998 | 1998 | * @param string $value New name. |
1999 | 1999 | */ |
2000 | - public function set_date_completed( $value ) { |
|
2001 | - $this->set_completed_date( $value ); |
|
2000 | + public function set_date_completed($value) { |
|
2001 | + $this->set_completed_date($value); |
|
2002 | 2002 | } |
2003 | 2003 | |
2004 | 2004 | /** |
@@ -2008,15 +2008,15 @@ discard block |
||
2008 | 2008 | * @param string $value Value to set. |
2009 | 2009 | * @return bool Whether or not the date was set. |
2010 | 2010 | */ |
2011 | - public function set_date_modified( $value ) { |
|
2012 | - $date = strtotime( $value ); |
|
2011 | + public function set_date_modified($value) { |
|
2012 | + $date = strtotime($value); |
|
2013 | 2013 | |
2014 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2015 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2014 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2015 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2016 | 2016 | return true; |
2017 | 2017 | } |
2018 | 2018 | |
2019 | - $this->set_prop( 'date_modified', '' ); |
|
2019 | + $this->set_prop('date_modified', ''); |
|
2020 | 2020 | return false; |
2021 | 2021 | |
2022 | 2022 | } |
@@ -2027,9 +2027,9 @@ discard block |
||
2027 | 2027 | * @since 1.0.19 |
2028 | 2028 | * @param string $value New number. |
2029 | 2029 | */ |
2030 | - public function set_number( $value ) { |
|
2031 | - $number = sanitize_text_field( $value ); |
|
2032 | - $this->set_prop( 'number', $number ); |
|
2030 | + public function set_number($value) { |
|
2031 | + $number = sanitize_text_field($value); |
|
2032 | + $this->set_prop('number', $number); |
|
2033 | 2033 | } |
2034 | 2034 | |
2035 | 2035 | /** |
@@ -2038,9 +2038,9 @@ discard block |
||
2038 | 2038 | * @since 1.0.19 |
2039 | 2039 | * @param string $value Type. |
2040 | 2040 | */ |
2041 | - public function set_type( $value ) { |
|
2042 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2043 | - $this->set_prop( 'type', $type ); |
|
2041 | + public function set_type($value) { |
|
2042 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2043 | + $this->set_prop('type', $type); |
|
2044 | 2044 | } |
2045 | 2045 | |
2046 | 2046 | /** |
@@ -2049,10 +2049,10 @@ discard block |
||
2049 | 2049 | * @since 1.0.19 |
2050 | 2050 | * @param string $value Post type. |
2051 | 2051 | */ |
2052 | - public function set_post_type( $value ) { |
|
2053 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2054 | - $this->set_type( $value ); |
|
2055 | - $this->set_prop( 'post_type', $value ); |
|
2052 | + public function set_post_type($value) { |
|
2053 | + if (getpaid_is_invoice_post_type($value)) { |
|
2054 | + $this->set_type($value); |
|
2055 | + $this->set_prop('post_type', $value); |
|
2056 | 2056 | } |
2057 | 2057 | } |
2058 | 2058 | |
@@ -2062,9 +2062,9 @@ discard block |
||
2062 | 2062 | * @since 1.0.19 |
2063 | 2063 | * @param string $value New key. |
2064 | 2064 | */ |
2065 | - public function set_key( $value ) { |
|
2066 | - $key = sanitize_text_field( $value ); |
|
2067 | - $this->set_prop( 'key', $key ); |
|
2065 | + public function set_key($value) { |
|
2066 | + $key = sanitize_text_field($value); |
|
2067 | + $this->set_prop('key', $key); |
|
2068 | 2068 | } |
2069 | 2069 | |
2070 | 2070 | /** |
@@ -2073,9 +2073,9 @@ discard block |
||
2073 | 2073 | * @since 1.0.19 |
2074 | 2074 | * @param string $value mode. |
2075 | 2075 | */ |
2076 | - public function set_mode( $value ) { |
|
2077 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
2078 | - $this->set_prop( 'value', $value ); |
|
2076 | + public function set_mode($value) { |
|
2077 | + if (!in_array($value, array('live', 'test'))) { |
|
2078 | + $this->set_prop('value', $value); |
|
2079 | 2079 | } |
2080 | 2080 | } |
2081 | 2081 | |
@@ -2085,8 +2085,8 @@ discard block |
||
2085 | 2085 | * @since 1.0.19 |
2086 | 2086 | * @param string $value path. |
2087 | 2087 | */ |
2088 | - public function set_path( $value ) { |
|
2089 | - $this->set_prop( 'path', $value ); |
|
2088 | + public function set_path($value) { |
|
2089 | + $this->set_prop('path', $value); |
|
2090 | 2090 | } |
2091 | 2091 | |
2092 | 2092 | /** |
@@ -2095,9 +2095,9 @@ discard block |
||
2095 | 2095 | * @since 1.0.19 |
2096 | 2096 | * @param string $value New name. |
2097 | 2097 | */ |
2098 | - public function set_name( $value ) { |
|
2099 | - $name = sanitize_text_field( $value ); |
|
2100 | - $this->set_prop( 'name', $name ); |
|
2098 | + public function set_name($value) { |
|
2099 | + $name = sanitize_text_field($value); |
|
2100 | + $this->set_prop('name', $name); |
|
2101 | 2101 | } |
2102 | 2102 | |
2103 | 2103 | /** |
@@ -2106,8 +2106,8 @@ discard block |
||
2106 | 2106 | * @since 1.0.19 |
2107 | 2107 | * @param string $value New name. |
2108 | 2108 | */ |
2109 | - public function set_title( $value ) { |
|
2110 | - $this->set_name( $value ); |
|
2109 | + public function set_title($value) { |
|
2110 | + $this->set_name($value); |
|
2111 | 2111 | } |
2112 | 2112 | |
2113 | 2113 | /** |
@@ -2116,9 +2116,9 @@ discard block |
||
2116 | 2116 | * @since 1.0.19 |
2117 | 2117 | * @param string $value New description. |
2118 | 2118 | */ |
2119 | - public function set_description( $value ) { |
|
2120 | - $description = wp_kses_post( $value ); |
|
2121 | - return $this->set_prop( 'description', $description ); |
|
2119 | + public function set_description($value) { |
|
2120 | + $description = wp_kses_post($value); |
|
2121 | + return $this->set_prop('description', $description); |
|
2122 | 2122 | } |
2123 | 2123 | |
2124 | 2124 | /** |
@@ -2127,8 +2127,8 @@ discard block |
||
2127 | 2127 | * @since 1.0.19 |
2128 | 2128 | * @param string $value New description. |
2129 | 2129 | */ |
2130 | - public function set_excerpt( $value ) { |
|
2131 | - $this->set_description( $value ); |
|
2130 | + public function set_excerpt($value) { |
|
2131 | + $this->set_description($value); |
|
2132 | 2132 | } |
2133 | 2133 | |
2134 | 2134 | /** |
@@ -2137,8 +2137,8 @@ discard block |
||
2137 | 2137 | * @since 1.0.19 |
2138 | 2138 | * @param string $value New description. |
2139 | 2139 | */ |
2140 | - public function set_summary( $value ) { |
|
2141 | - $this->set_description( $value ); |
|
2140 | + public function set_summary($value) { |
|
2141 | + $this->set_description($value); |
|
2142 | 2142 | } |
2143 | 2143 | |
2144 | 2144 | /** |
@@ -2147,12 +2147,12 @@ discard block |
||
2147 | 2147 | * @since 1.0.19 |
2148 | 2148 | * @param int $value New author. |
2149 | 2149 | */ |
2150 | - public function set_author( $value ) { |
|
2151 | - $user = get_user_by( 'id', (int) $value ); |
|
2150 | + public function set_author($value) { |
|
2151 | + $user = get_user_by('id', (int) $value); |
|
2152 | 2152 | |
2153 | - if ( $user && $user->ID ) { |
|
2154 | - $this->set_prop( 'author', $user->ID ); |
|
2155 | - $this->set_prop( 'email', $user->user_email ); |
|
2153 | + if ($user && $user->ID) { |
|
2154 | + $this->set_prop('author', $user->ID); |
|
2155 | + $this->set_prop('email', $user->user_email); |
|
2156 | 2156 | } |
2157 | 2157 | |
2158 | 2158 | } |
@@ -2163,8 +2163,8 @@ discard block |
||
2163 | 2163 | * @since 1.0.19 |
2164 | 2164 | * @param int $value New user id. |
2165 | 2165 | */ |
2166 | - public function set_user_id( $value ) { |
|
2167 | - $this->set_author( $value ); |
|
2166 | + public function set_user_id($value) { |
|
2167 | + $this->set_author($value); |
|
2168 | 2168 | } |
2169 | 2169 | |
2170 | 2170 | /** |
@@ -2173,8 +2173,8 @@ discard block |
||
2173 | 2173 | * @since 1.0.19 |
2174 | 2174 | * @param int $value New user id. |
2175 | 2175 | */ |
2176 | - public function set_customer_id( $value ) { |
|
2177 | - $this->set_author( $value ); |
|
2176 | + public function set_customer_id($value) { |
|
2177 | + $this->set_author($value); |
|
2178 | 2178 | } |
2179 | 2179 | |
2180 | 2180 | /** |
@@ -2183,8 +2183,8 @@ discard block |
||
2183 | 2183 | * @since 1.0.19 |
2184 | 2184 | * @param string $value ip address. |
2185 | 2185 | */ |
2186 | - public function set_ip( $value ) { |
|
2187 | - $this->set_prop( 'ip', $value ); |
|
2186 | + public function set_ip($value) { |
|
2187 | + $this->set_prop('ip', $value); |
|
2188 | 2188 | } |
2189 | 2189 | |
2190 | 2190 | /** |
@@ -2193,8 +2193,8 @@ discard block |
||
2193 | 2193 | * @since 1.0.19 |
2194 | 2194 | * @param string $value ip address. |
2195 | 2195 | */ |
2196 | - public function set_user_ip( $value ) { |
|
2197 | - $this->set_ip( $value ); |
|
2196 | + public function set_user_ip($value) { |
|
2197 | + $this->set_ip($value); |
|
2198 | 2198 | } |
2199 | 2199 | |
2200 | 2200 | /** |
@@ -2203,8 +2203,8 @@ discard block |
||
2203 | 2203 | * @since 1.0.19 |
2204 | 2204 | * @param string $value first name. |
2205 | 2205 | */ |
2206 | - public function set_first_name( $value ) { |
|
2207 | - $this->set_prop( 'first_name', $value ); |
|
2206 | + public function set_first_name($value) { |
|
2207 | + $this->set_prop('first_name', $value); |
|
2208 | 2208 | } |
2209 | 2209 | |
2210 | 2210 | /** |
@@ -2213,8 +2213,8 @@ discard block |
||
2213 | 2213 | * @since 1.0.19 |
2214 | 2214 | * @param string $value first name. |
2215 | 2215 | */ |
2216 | - public function set_user_first_name( $value ) { |
|
2217 | - $this->set_first_name( $value ); |
|
2216 | + public function set_user_first_name($value) { |
|
2217 | + $this->set_first_name($value); |
|
2218 | 2218 | } |
2219 | 2219 | |
2220 | 2220 | /** |
@@ -2223,8 +2223,8 @@ discard block |
||
2223 | 2223 | * @since 1.0.19 |
2224 | 2224 | * @param string $value first name. |
2225 | 2225 | */ |
2226 | - public function set_customer_first_name( $value ) { |
|
2227 | - $this->set_first_name( $value ); |
|
2226 | + public function set_customer_first_name($value) { |
|
2227 | + $this->set_first_name($value); |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | 2230 | /** |
@@ -2233,8 +2233,8 @@ discard block |
||
2233 | 2233 | * @since 1.0.19 |
2234 | 2234 | * @param string $value last name. |
2235 | 2235 | */ |
2236 | - public function set_last_name( $value ) { |
|
2237 | - $this->set_prop( 'last_name', $value ); |
|
2236 | + public function set_last_name($value) { |
|
2237 | + $this->set_prop('last_name', $value); |
|
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | /** |
@@ -2243,8 +2243,8 @@ discard block |
||
2243 | 2243 | * @since 1.0.19 |
2244 | 2244 | * @param string $value last name. |
2245 | 2245 | */ |
2246 | - public function set_user_last_name( $value ) { |
|
2247 | - $this->set_last_name( $value ); |
|
2246 | + public function set_user_last_name($value) { |
|
2247 | + $this->set_last_name($value); |
|
2248 | 2248 | } |
2249 | 2249 | |
2250 | 2250 | /** |
@@ -2253,8 +2253,8 @@ discard block |
||
2253 | 2253 | * @since 1.0.19 |
2254 | 2254 | * @param string $value last name. |
2255 | 2255 | */ |
2256 | - public function set_customer_last_name( $value ) { |
|
2257 | - $this->set_last_name( $value ); |
|
2256 | + public function set_customer_last_name($value) { |
|
2257 | + $this->set_last_name($value); |
|
2258 | 2258 | } |
2259 | 2259 | |
2260 | 2260 | /** |
@@ -2263,8 +2263,8 @@ discard block |
||
2263 | 2263 | * @since 1.0.19 |
2264 | 2264 | * @param string $value phone. |
2265 | 2265 | */ |
2266 | - public function set_phone( $value ) { |
|
2267 | - $this->set_prop( 'phone', $value ); |
|
2266 | + public function set_phone($value) { |
|
2267 | + $this->set_prop('phone', $value); |
|
2268 | 2268 | } |
2269 | 2269 | |
2270 | 2270 | /** |
@@ -2273,8 +2273,8 @@ discard block |
||
2273 | 2273 | * @since 1.0.19 |
2274 | 2274 | * @param string $value phone. |
2275 | 2275 | */ |
2276 | - public function set_user_phone( $value ) { |
|
2277 | - $this->set_phone( $value ); |
|
2276 | + public function set_user_phone($value) { |
|
2277 | + $this->set_phone($value); |
|
2278 | 2278 | } |
2279 | 2279 | |
2280 | 2280 | /** |
@@ -2283,8 +2283,8 @@ discard block |
||
2283 | 2283 | * @since 1.0.19 |
2284 | 2284 | * @param string $value phone. |
2285 | 2285 | */ |
2286 | - public function set_customer_phone( $value ) { |
|
2287 | - $this->set_phone( $value ); |
|
2286 | + public function set_customer_phone($value) { |
|
2287 | + $this->set_phone($value); |
|
2288 | 2288 | } |
2289 | 2289 | |
2290 | 2290 | /** |
@@ -2293,8 +2293,8 @@ discard block |
||
2293 | 2293 | * @since 1.0.19 |
2294 | 2294 | * @param string $value phone. |
2295 | 2295 | */ |
2296 | - public function set_phone_number( $value ) { |
|
2297 | - $this->set_phone( $value ); |
|
2296 | + public function set_phone_number($value) { |
|
2297 | + $this->set_phone($value); |
|
2298 | 2298 | } |
2299 | 2299 | |
2300 | 2300 | /** |
@@ -2303,8 +2303,8 @@ discard block |
||
2303 | 2303 | * @since 1.0.19 |
2304 | 2304 | * @param string $value email address. |
2305 | 2305 | */ |
2306 | - public function set_email( $value ) { |
|
2307 | - $this->set_prop( 'email', $value ); |
|
2306 | + public function set_email($value) { |
|
2307 | + $this->set_prop('email', $value); |
|
2308 | 2308 | } |
2309 | 2309 | |
2310 | 2310 | /** |
@@ -2313,8 +2313,8 @@ discard block |
||
2313 | 2313 | * @since 1.0.19 |
2314 | 2314 | * @param string $value email address. |
2315 | 2315 | */ |
2316 | - public function set_user_email( $value ) { |
|
2317 | - $this->set_email( $value ); |
|
2316 | + public function set_user_email($value) { |
|
2317 | + $this->set_email($value); |
|
2318 | 2318 | } |
2319 | 2319 | |
2320 | 2320 | /** |
@@ -2323,8 +2323,8 @@ discard block |
||
2323 | 2323 | * @since 1.0.19 |
2324 | 2324 | * @param string $value email address. |
2325 | 2325 | */ |
2326 | - public function set_email_address( $value ) { |
|
2327 | - $this->set_email( $value ); |
|
2326 | + public function set_email_address($value) { |
|
2327 | + $this->set_email($value); |
|
2328 | 2328 | } |
2329 | 2329 | |
2330 | 2330 | /** |
@@ -2333,8 +2333,8 @@ discard block |
||
2333 | 2333 | * @since 1.0.19 |
2334 | 2334 | * @param string $value email address. |
2335 | 2335 | */ |
2336 | - public function set_customer_email( $value ) { |
|
2337 | - $this->set_email( $value ); |
|
2336 | + public function set_customer_email($value) { |
|
2337 | + $this->set_email($value); |
|
2338 | 2338 | } |
2339 | 2339 | |
2340 | 2340 | /** |
@@ -2343,8 +2343,8 @@ discard block |
||
2343 | 2343 | * @since 1.0.19 |
2344 | 2344 | * @param string $value country. |
2345 | 2345 | */ |
2346 | - public function set_country( $value ) { |
|
2347 | - $this->set_prop( 'country', $value ); |
|
2346 | + public function set_country($value) { |
|
2347 | + $this->set_prop('country', $value); |
|
2348 | 2348 | } |
2349 | 2349 | |
2350 | 2350 | /** |
@@ -2353,8 +2353,8 @@ discard block |
||
2353 | 2353 | * @since 1.0.19 |
2354 | 2354 | * @param string $value country. |
2355 | 2355 | */ |
2356 | - public function set_user_country( $value ) { |
|
2357 | - $this->set_country( $value ); |
|
2356 | + public function set_user_country($value) { |
|
2357 | + $this->set_country($value); |
|
2358 | 2358 | } |
2359 | 2359 | |
2360 | 2360 | /** |
@@ -2363,8 +2363,8 @@ discard block |
||
2363 | 2363 | * @since 1.0.19 |
2364 | 2364 | * @param string $value country. |
2365 | 2365 | */ |
2366 | - public function set_customer_country( $value ) { |
|
2367 | - $this->set_country( $value ); |
|
2366 | + public function set_customer_country($value) { |
|
2367 | + $this->set_country($value); |
|
2368 | 2368 | } |
2369 | 2369 | |
2370 | 2370 | /** |
@@ -2373,8 +2373,8 @@ discard block |
||
2373 | 2373 | * @since 1.0.19 |
2374 | 2374 | * @param string $value state. |
2375 | 2375 | */ |
2376 | - public function set_state( $value ) { |
|
2377 | - $this->set_prop( 'state', $value ); |
|
2376 | + public function set_state($value) { |
|
2377 | + $this->set_prop('state', $value); |
|
2378 | 2378 | } |
2379 | 2379 | |
2380 | 2380 | /** |
@@ -2383,8 +2383,8 @@ discard block |
||
2383 | 2383 | * @since 1.0.19 |
2384 | 2384 | * @param string $value state. |
2385 | 2385 | */ |
2386 | - public function set_user_state( $value ) { |
|
2387 | - $this->set_state( $value ); |
|
2386 | + public function set_user_state($value) { |
|
2387 | + $this->set_state($value); |
|
2388 | 2388 | } |
2389 | 2389 | |
2390 | 2390 | /** |
@@ -2393,8 +2393,8 @@ discard block |
||
2393 | 2393 | * @since 1.0.19 |
2394 | 2394 | * @param string $value state. |
2395 | 2395 | */ |
2396 | - public function set_customer_state( $value ) { |
|
2397 | - $this->set_state( $value ); |
|
2396 | + public function set_customer_state($value) { |
|
2397 | + $this->set_state($value); |
|
2398 | 2398 | } |
2399 | 2399 | |
2400 | 2400 | /** |
@@ -2403,8 +2403,8 @@ discard block |
||
2403 | 2403 | * @since 1.0.19 |
2404 | 2404 | * @param string $value city. |
2405 | 2405 | */ |
2406 | - public function set_city( $value ) { |
|
2407 | - $this->set_prop( 'city', $value ); |
|
2406 | + public function set_city($value) { |
|
2407 | + $this->set_prop('city', $value); |
|
2408 | 2408 | } |
2409 | 2409 | |
2410 | 2410 | /** |
@@ -2413,8 +2413,8 @@ discard block |
||
2413 | 2413 | * @since 1.0.19 |
2414 | 2414 | * @param string $value city. |
2415 | 2415 | */ |
2416 | - public function set_user_city( $value ) { |
|
2417 | - $this->set_city( $value ); |
|
2416 | + public function set_user_city($value) { |
|
2417 | + $this->set_city($value); |
|
2418 | 2418 | } |
2419 | 2419 | |
2420 | 2420 | /** |
@@ -2423,8 +2423,8 @@ discard block |
||
2423 | 2423 | * @since 1.0.19 |
2424 | 2424 | * @param string $value city. |
2425 | 2425 | */ |
2426 | - public function set_customer_city( $value ) { |
|
2427 | - $this->set_city( $value ); |
|
2426 | + public function set_customer_city($value) { |
|
2427 | + $this->set_city($value); |
|
2428 | 2428 | } |
2429 | 2429 | |
2430 | 2430 | /** |
@@ -2433,8 +2433,8 @@ discard block |
||
2433 | 2433 | * @since 1.0.19 |
2434 | 2434 | * @param string $value zip. |
2435 | 2435 | */ |
2436 | - public function set_zip( $value ) { |
|
2437 | - $this->set_prop( 'zip', $value ); |
|
2436 | + public function set_zip($value) { |
|
2437 | + $this->set_prop('zip', $value); |
|
2438 | 2438 | } |
2439 | 2439 | |
2440 | 2440 | /** |
@@ -2443,8 +2443,8 @@ discard block |
||
2443 | 2443 | * @since 1.0.19 |
2444 | 2444 | * @param string $value zip. |
2445 | 2445 | */ |
2446 | - public function set_user_zip( $value ) { |
|
2447 | - $this->set_zip( $value ); |
|
2446 | + public function set_user_zip($value) { |
|
2447 | + $this->set_zip($value); |
|
2448 | 2448 | } |
2449 | 2449 | |
2450 | 2450 | /** |
@@ -2453,8 +2453,8 @@ discard block |
||
2453 | 2453 | * @since 1.0.19 |
2454 | 2454 | * @param string $value zip. |
2455 | 2455 | */ |
2456 | - public function set_customer_zip( $value ) { |
|
2457 | - $this->set_zip( $value ); |
|
2456 | + public function set_customer_zip($value) { |
|
2457 | + $this->set_zip($value); |
|
2458 | 2458 | } |
2459 | 2459 | |
2460 | 2460 | /** |
@@ -2463,8 +2463,8 @@ discard block |
||
2463 | 2463 | * @since 1.0.19 |
2464 | 2464 | * @param string $value company. |
2465 | 2465 | */ |
2466 | - public function set_company( $value ) { |
|
2467 | - $this->set_prop( 'company', $value ); |
|
2466 | + public function set_company($value) { |
|
2467 | + $this->set_prop('company', $value); |
|
2468 | 2468 | } |
2469 | 2469 | |
2470 | 2470 | /** |
@@ -2473,8 +2473,8 @@ discard block |
||
2473 | 2473 | * @since 1.0.19 |
2474 | 2474 | * @param string $value company. |
2475 | 2475 | */ |
2476 | - public function set_user_company( $value ) { |
|
2477 | - $this->set_company( $value ); |
|
2476 | + public function set_user_company($value) { |
|
2477 | + $this->set_company($value); |
|
2478 | 2478 | } |
2479 | 2479 | |
2480 | 2480 | /** |
@@ -2483,8 +2483,8 @@ discard block |
||
2483 | 2483 | * @since 1.0.19 |
2484 | 2484 | * @param string $value company. |
2485 | 2485 | */ |
2486 | - public function set_customer_company( $value ) { |
|
2487 | - $this->set_company( $value ); |
|
2486 | + public function set_customer_company($value) { |
|
2487 | + $this->set_company($value); |
|
2488 | 2488 | } |
2489 | 2489 | |
2490 | 2490 | /** |
@@ -2493,8 +2493,8 @@ discard block |
||
2493 | 2493 | * @since 1.0.19 |
2494 | 2494 | * @param string $value var number. |
2495 | 2495 | */ |
2496 | - public function set_vat_number( $value ) { |
|
2497 | - $this->set_prop( 'vat_number', $value ); |
|
2496 | + public function set_vat_number($value) { |
|
2497 | + $this->set_prop('vat_number', $value); |
|
2498 | 2498 | } |
2499 | 2499 | |
2500 | 2500 | /** |
@@ -2503,8 +2503,8 @@ discard block |
||
2503 | 2503 | * @since 1.0.19 |
2504 | 2504 | * @param string $value var number. |
2505 | 2505 | */ |
2506 | - public function set_user_vat_number( $value ) { |
|
2507 | - $this->set_vat_number( $value ); |
|
2506 | + public function set_user_vat_number($value) { |
|
2507 | + $this->set_vat_number($value); |
|
2508 | 2508 | } |
2509 | 2509 | |
2510 | 2510 | /** |
@@ -2513,8 +2513,8 @@ discard block |
||
2513 | 2513 | * @since 1.0.19 |
2514 | 2514 | * @param string $value var number. |
2515 | 2515 | */ |
2516 | - public function set_customer_vat_number( $value ) { |
|
2517 | - $this->set_vat_number( $value ); |
|
2516 | + public function set_customer_vat_number($value) { |
|
2517 | + $this->set_vat_number($value); |
|
2518 | 2518 | } |
2519 | 2519 | |
2520 | 2520 | /** |
@@ -2523,8 +2523,8 @@ discard block |
||
2523 | 2523 | * @since 1.0.19 |
2524 | 2524 | * @param string $value var rate. |
2525 | 2525 | */ |
2526 | - public function set_vat_rate( $value ) { |
|
2527 | - $this->set_prop( 'vat_rate', $value ); |
|
2526 | + public function set_vat_rate($value) { |
|
2527 | + $this->set_prop('vat_rate', $value); |
|
2528 | 2528 | } |
2529 | 2529 | |
2530 | 2530 | /** |
@@ -2533,8 +2533,8 @@ discard block |
||
2533 | 2533 | * @since 1.0.19 |
2534 | 2534 | * @param string $value var number. |
2535 | 2535 | */ |
2536 | - public function set_user_vat_rate( $value ) { |
|
2537 | - $this->set_vat_rate( $value ); |
|
2536 | + public function set_user_vat_rate($value) { |
|
2537 | + $this->set_vat_rate($value); |
|
2538 | 2538 | } |
2539 | 2539 | |
2540 | 2540 | /** |
@@ -2543,8 +2543,8 @@ discard block |
||
2543 | 2543 | * @since 1.0.19 |
2544 | 2544 | * @param string $value var number. |
2545 | 2545 | */ |
2546 | - public function set_customer_vat_rate( $value ) { |
|
2547 | - $this->set_vat_rate( $value ); |
|
2546 | + public function set_customer_vat_rate($value) { |
|
2547 | + $this->set_vat_rate($value); |
|
2548 | 2548 | } |
2549 | 2549 | |
2550 | 2550 | /** |
@@ -2553,8 +2553,8 @@ discard block |
||
2553 | 2553 | * @since 1.0.19 |
2554 | 2554 | * @param string $value address. |
2555 | 2555 | */ |
2556 | - public function set_address( $value ) { |
|
2557 | - $this->set_prop( 'address', $value ); |
|
2556 | + public function set_address($value) { |
|
2557 | + $this->set_prop('address', $value); |
|
2558 | 2558 | } |
2559 | 2559 | |
2560 | 2560 | /** |
@@ -2563,8 +2563,8 @@ discard block |
||
2563 | 2563 | * @since 1.0.19 |
2564 | 2564 | * @param string $value address. |
2565 | 2565 | */ |
2566 | - public function set_user_address( $value ) { |
|
2567 | - $this->set_address( $value ); |
|
2566 | + public function set_user_address($value) { |
|
2567 | + $this->set_address($value); |
|
2568 | 2568 | } |
2569 | 2569 | |
2570 | 2570 | /** |
@@ -2573,8 +2573,8 @@ discard block |
||
2573 | 2573 | * @since 1.0.19 |
2574 | 2574 | * @param string $value address. |
2575 | 2575 | */ |
2576 | - public function set_customer_address( $value ) { |
|
2577 | - $this->set_address( $value ); |
|
2576 | + public function set_customer_address($value) { |
|
2577 | + $this->set_address($value); |
|
2578 | 2578 | } |
2579 | 2579 | |
2580 | 2580 | /** |
@@ -2583,8 +2583,8 @@ discard block |
||
2583 | 2583 | * @since 1.0.19 |
2584 | 2584 | * @param int|bool $value confirmed. |
2585 | 2585 | */ |
2586 | - public function set_is_viewed( $value ) { |
|
2587 | - $this->set_prop( 'is_viewed', $value ); |
|
2586 | + public function set_is_viewed($value) { |
|
2587 | + $this->set_prop('is_viewed', $value); |
|
2588 | 2588 | } |
2589 | 2589 | |
2590 | 2590 | /** |
@@ -2593,8 +2593,8 @@ discard block |
||
2593 | 2593 | * @since 1.0.19 |
2594 | 2594 | * @param string $value email recipients. |
2595 | 2595 | */ |
2596 | - public function set_email_cc( $value ) { |
|
2597 | - $this->set_prop( 'email_cc', $value ); |
|
2596 | + public function set_email_cc($value) { |
|
2597 | + $this->set_prop('email_cc', $value); |
|
2598 | 2598 | } |
2599 | 2599 | |
2600 | 2600 | /** |
@@ -2603,9 +2603,9 @@ discard block |
||
2603 | 2603 | * @since 1.0.19 |
2604 | 2604 | * @param string $value email recipients. |
2605 | 2605 | */ |
2606 | - public function set_template( $value ) { |
|
2607 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2608 | - $this->set_prop( 'template', $value ); |
|
2606 | + public function set_template($value) { |
|
2607 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2608 | + $this->set_prop('template', $value); |
|
2609 | 2609 | } |
2610 | 2610 | } |
2611 | 2611 | |
@@ -2615,8 +2615,8 @@ discard block |
||
2615 | 2615 | * @since 1.0.19 |
2616 | 2616 | * @param int|bool $value confirmed. |
2617 | 2617 | */ |
2618 | - public function set_address_confirmed( $value ) { |
|
2619 | - $this->set_prop( 'address_confirmed', $value ); |
|
2618 | + public function set_address_confirmed($value) { |
|
2619 | + $this->set_prop('address_confirmed', $value); |
|
2620 | 2620 | } |
2621 | 2621 | |
2622 | 2622 | /** |
@@ -2625,8 +2625,8 @@ discard block |
||
2625 | 2625 | * @since 1.0.19 |
2626 | 2626 | * @param int|bool $value confirmed. |
2627 | 2627 | */ |
2628 | - public function set_user_address_confirmed( $value ) { |
|
2629 | - $this->set_address_confirmed( $value ); |
|
2628 | + public function set_user_address_confirmed($value) { |
|
2629 | + $this->set_address_confirmed($value); |
|
2630 | 2630 | } |
2631 | 2631 | |
2632 | 2632 | /** |
@@ -2635,8 +2635,8 @@ discard block |
||
2635 | 2635 | * @since 1.0.19 |
2636 | 2636 | * @param int|bool $value confirmed. |
2637 | 2637 | */ |
2638 | - public function set_customer_address_confirmed( $value ) { |
|
2639 | - $this->set_address_confirmed( $value ); |
|
2638 | + public function set_customer_address_confirmed($value) { |
|
2639 | + $this->set_address_confirmed($value); |
|
2640 | 2640 | } |
2641 | 2641 | |
2642 | 2642 | /** |
@@ -2645,8 +2645,8 @@ discard block |
||
2645 | 2645 | * @since 1.0.19 |
2646 | 2646 | * @param float $value sub total. |
2647 | 2647 | */ |
2648 | - public function set_subtotal( $value ) { |
|
2649 | - $this->set_prop( 'subtotal', $value ); |
|
2648 | + public function set_subtotal($value) { |
|
2649 | + $this->set_prop('subtotal', $value); |
|
2650 | 2650 | } |
2651 | 2651 | |
2652 | 2652 | /** |
@@ -2655,8 +2655,8 @@ discard block |
||
2655 | 2655 | * @since 1.0.19 |
2656 | 2656 | * @param float $value discount total. |
2657 | 2657 | */ |
2658 | - public function set_total_discount( $value ) { |
|
2659 | - $this->set_prop( 'total_discount', $value ); |
|
2658 | + public function set_total_discount($value) { |
|
2659 | + $this->set_prop('total_discount', $value); |
|
2660 | 2660 | } |
2661 | 2661 | |
2662 | 2662 | /** |
@@ -2665,8 +2665,8 @@ discard block |
||
2665 | 2665 | * @since 1.0.19 |
2666 | 2666 | * @param float $value discount total. |
2667 | 2667 | */ |
2668 | - public function set_discount( $value ) { |
|
2669 | - $this->set_total_discount( $value ); |
|
2668 | + public function set_discount($value) { |
|
2669 | + $this->set_total_discount($value); |
|
2670 | 2670 | } |
2671 | 2671 | |
2672 | 2672 | /** |
@@ -2675,8 +2675,8 @@ discard block |
||
2675 | 2675 | * @since 1.0.19 |
2676 | 2676 | * @param float $value tax total. |
2677 | 2677 | */ |
2678 | - public function set_total_tax( $value ) { |
|
2679 | - $this->set_prop( 'total_tax', $value ); |
|
2678 | + public function set_total_tax($value) { |
|
2679 | + $this->set_prop('total_tax', $value); |
|
2680 | 2680 | } |
2681 | 2681 | |
2682 | 2682 | /** |
@@ -2685,8 +2685,8 @@ discard block |
||
2685 | 2685 | * @since 1.0.19 |
2686 | 2686 | * @param float $value tax total. |
2687 | 2687 | */ |
2688 | - public function set_tax_total( $value ) { |
|
2689 | - $this->set_total_tax( $value ); |
|
2688 | + public function set_tax_total($value) { |
|
2689 | + $this->set_total_tax($value); |
|
2690 | 2690 | } |
2691 | 2691 | |
2692 | 2692 | /** |
@@ -2695,8 +2695,8 @@ discard block |
||
2695 | 2695 | * @since 1.0.19 |
2696 | 2696 | * @param float $value fees total. |
2697 | 2697 | */ |
2698 | - public function set_total_fees( $value ) { |
|
2699 | - $this->set_prop( 'total_fees', $value ); |
|
2698 | + public function set_total_fees($value) { |
|
2699 | + $this->set_prop('total_fees', $value); |
|
2700 | 2700 | } |
2701 | 2701 | |
2702 | 2702 | /** |
@@ -2705,8 +2705,8 @@ discard block |
||
2705 | 2705 | * @since 1.0.19 |
2706 | 2706 | * @param float $value fees total. |
2707 | 2707 | */ |
2708 | - public function set_fees_total( $value ) { |
|
2709 | - $this->set_total_fees( $value ); |
|
2708 | + public function set_fees_total($value) { |
|
2709 | + $this->set_total_fees($value); |
|
2710 | 2710 | } |
2711 | 2711 | |
2712 | 2712 | /** |
@@ -2715,18 +2715,18 @@ discard block |
||
2715 | 2715 | * @since 1.0.19 |
2716 | 2716 | * @param array $value fees. |
2717 | 2717 | */ |
2718 | - public function set_fees( $value ) { |
|
2718 | + public function set_fees($value) { |
|
2719 | 2719 | |
2720 | - $this->set_prop( 'fees', array() ); |
|
2720 | + $this->set_prop('fees', array()); |
|
2721 | 2721 | |
2722 | 2722 | // Ensure that we have an array. |
2723 | - if ( ! is_array( $value ) ) { |
|
2723 | + if (!is_array($value)) { |
|
2724 | 2724 | return; |
2725 | 2725 | } |
2726 | 2726 | |
2727 | - foreach ( $value as $name => $data ) { |
|
2728 | - if ( isset( $data['amount'] ) ) { |
|
2729 | - $this->add_fee( $name, $data['amount'], $data['recurring'] ); |
|
2727 | + foreach ($value as $name => $data) { |
|
2728 | + if (isset($data['amount'])) { |
|
2729 | + $this->add_fee($name, $data['amount'], $data['recurring']); |
|
2730 | 2730 | } |
2731 | 2731 | } |
2732 | 2732 | |
@@ -2738,8 +2738,8 @@ discard block |
||
2738 | 2738 | * @since 1.0.19 |
2739 | 2739 | * @param array $value taxes. |
2740 | 2740 | */ |
2741 | - public function set_taxes( $value ) { |
|
2742 | - $this->set_prop( 'taxes', $value ); |
|
2741 | + public function set_taxes($value) { |
|
2742 | + $this->set_prop('taxes', $value); |
|
2743 | 2743 | } |
2744 | 2744 | |
2745 | 2745 | /** |
@@ -2748,17 +2748,17 @@ discard block |
||
2748 | 2748 | * @since 1.0.19 |
2749 | 2749 | * @param array $value discounts. |
2750 | 2750 | */ |
2751 | - public function set_discounts( $value ) { |
|
2752 | - $this->set_prop( 'discounts', array() ); |
|
2751 | + public function set_discounts($value) { |
|
2752 | + $this->set_prop('discounts', array()); |
|
2753 | 2753 | |
2754 | 2754 | // Ensure that we have an array. |
2755 | - if ( ! is_array( $value ) ) { |
|
2755 | + if (!is_array($value)) { |
|
2756 | 2756 | return; |
2757 | 2757 | } |
2758 | 2758 | |
2759 | - foreach ( $value as $name => $data ) { |
|
2760 | - if ( isset( $data['amount'] ) ) { |
|
2761 | - $this->add_discount( $name, $data['amount'], $data['recurring'] ); |
|
2759 | + foreach ($value as $name => $data) { |
|
2760 | + if (isset($data['amount'])) { |
|
2761 | + $this->add_discount($name, $data['amount'], $data['recurring']); |
|
2762 | 2762 | } |
2763 | 2763 | } |
2764 | 2764 | } |
@@ -2769,18 +2769,18 @@ discard block |
||
2769 | 2769 | * @since 1.0.19 |
2770 | 2770 | * @param GetPaid_Form_Item[] $value items. |
2771 | 2771 | */ |
2772 | - public function set_items( $value ) { |
|
2772 | + public function set_items($value) { |
|
2773 | 2773 | |
2774 | 2774 | // Remove existing items. |
2775 | - $this->set_prop( 'items', array() ); |
|
2775 | + $this->set_prop('items', array()); |
|
2776 | 2776 | |
2777 | 2777 | // Ensure that we have an array. |
2778 | - if ( ! is_array( $value ) ) { |
|
2778 | + if (!is_array($value)) { |
|
2779 | 2779 | return; |
2780 | 2780 | } |
2781 | 2781 | |
2782 | - foreach ( $value as $item ) { |
|
2783 | - $this->add_item( $item ); |
|
2782 | + foreach ($value as $item) { |
|
2783 | + $this->add_item($item); |
|
2784 | 2784 | } |
2785 | 2785 | |
2786 | 2786 | } |
@@ -2791,8 +2791,8 @@ discard block |
||
2791 | 2791 | * @since 1.0.19 |
2792 | 2792 | * @param int $value payment form. |
2793 | 2793 | */ |
2794 | - public function set_payment_form( $value ) { |
|
2795 | - $this->set_prop( 'payment_form', $value ); |
|
2794 | + public function set_payment_form($value) { |
|
2795 | + $this->set_prop('payment_form', $value); |
|
2796 | 2796 | } |
2797 | 2797 | |
2798 | 2798 | /** |
@@ -2801,8 +2801,8 @@ discard block |
||
2801 | 2801 | * @since 1.0.19 |
2802 | 2802 | * @param string $value submission id. |
2803 | 2803 | */ |
2804 | - public function set_submission_id( $value ) { |
|
2805 | - $this->set_prop( 'submission_id', $value ); |
|
2804 | + public function set_submission_id($value) { |
|
2805 | + $this->set_prop('submission_id', $value); |
|
2806 | 2806 | } |
2807 | 2807 | |
2808 | 2808 | /** |
@@ -2811,8 +2811,8 @@ discard block |
||
2811 | 2811 | * @since 1.0.19 |
2812 | 2812 | * @param string $value discount code. |
2813 | 2813 | */ |
2814 | - public function set_discount_code( $value ) { |
|
2815 | - $this->set_prop( 'discount_code', $value ); |
|
2814 | + public function set_discount_code($value) { |
|
2815 | + $this->set_prop('discount_code', $value); |
|
2816 | 2816 | } |
2817 | 2817 | |
2818 | 2818 | /** |
@@ -2821,8 +2821,8 @@ discard block |
||
2821 | 2821 | * @since 1.0.19 |
2822 | 2822 | * @param string $value gateway. |
2823 | 2823 | */ |
2824 | - public function set_gateway( $value ) { |
|
2825 | - $this->set_prop( 'gateway', $value ); |
|
2824 | + public function set_gateway($value) { |
|
2825 | + $this->set_prop('gateway', $value); |
|
2826 | 2826 | } |
2827 | 2827 | |
2828 | 2828 | /** |
@@ -2831,9 +2831,9 @@ discard block |
||
2831 | 2831 | * @since 1.0.19 |
2832 | 2832 | * @param string $value transaction id. |
2833 | 2833 | */ |
2834 | - public function set_transaction_id( $value ) { |
|
2835 | - if ( ! empty( $value ) ) { |
|
2836 | - $this->set_prop( 'transaction_id', $value ); |
|
2834 | + public function set_transaction_id($value) { |
|
2835 | + if (!empty($value)) { |
|
2836 | + $this->set_prop('transaction_id', $value); |
|
2837 | 2837 | } |
2838 | 2838 | } |
2839 | 2839 | |
@@ -2843,8 +2843,8 @@ discard block |
||
2843 | 2843 | * @since 1.0.19 |
2844 | 2844 | * @param string $value currency id. |
2845 | 2845 | */ |
2846 | - public function set_currency( $value ) { |
|
2847 | - $this->set_prop( 'currency', $value ); |
|
2846 | + public function set_currency($value) { |
|
2847 | + $this->set_prop('currency', $value); |
|
2848 | 2848 | } |
2849 | 2849 | |
2850 | 2850 | /** |
@@ -2853,8 +2853,8 @@ discard block |
||
2853 | 2853 | * @since 1.0.19 |
2854 | 2854 | * @param bool $value value. |
2855 | 2855 | */ |
2856 | - public function set_disable_taxes( $value ) { |
|
2857 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2856 | + public function set_disable_taxes($value) { |
|
2857 | + $this->set_prop('disable_taxes', (bool) $value); |
|
2858 | 2858 | } |
2859 | 2859 | |
2860 | 2860 | /** |
@@ -2863,8 +2863,8 @@ discard block |
||
2863 | 2863 | * @since 1.0.19 |
2864 | 2864 | * @param string $value subscription id. |
2865 | 2865 | */ |
2866 | - public function set_subscription_id( $value ) { |
|
2867 | - $this->set_prop( 'subscription_id', $value ); |
|
2866 | + public function set_subscription_id($value) { |
|
2867 | + $this->set_prop('subscription_id', $value); |
|
2868 | 2868 | } |
2869 | 2869 | |
2870 | 2870 | /* |
@@ -2881,28 +2881,28 @@ discard block |
||
2881 | 2881 | */ |
2882 | 2882 | public function is_parent() { |
2883 | 2883 | $parent = $this->get_parent_id(); |
2884 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
2884 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
2885 | 2885 | } |
2886 | 2886 | |
2887 | 2887 | /** |
2888 | 2888 | * Checks if this is a renewal invoice. |
2889 | 2889 | */ |
2890 | 2890 | public function is_renewal() { |
2891 | - return ! $this->is_parent(); |
|
2891 | + return !$this->is_parent(); |
|
2892 | 2892 | } |
2893 | 2893 | |
2894 | 2894 | /** |
2895 | 2895 | * Checks if this is a recurring invoice. |
2896 | 2896 | */ |
2897 | 2897 | public function is_recurring() { |
2898 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
2898 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
2899 | 2899 | } |
2900 | 2900 | |
2901 | 2901 | /** |
2902 | 2902 | * Checks if this is a taxable invoice. |
2903 | 2903 | */ |
2904 | 2904 | public function is_taxable() { |
2905 | - return ! $this->get_disable_taxes(); |
|
2905 | + return !$this->get_disable_taxes(); |
|
2906 | 2906 | } |
2907 | 2907 | |
2908 | 2908 | /** |
@@ -2913,57 +2913,57 @@ discard block |
||
2913 | 2913 | |
2914 | 2914 | $requires_vat = false; |
2915 | 2915 | |
2916 | - if ( $this->country ) { |
|
2916 | + if ($this->country) { |
|
2917 | 2917 | $wpi_country = $this->country; |
2918 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
2918 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
2919 | 2919 | } |
2920 | 2920 | |
2921 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
2921 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
2922 | 2922 | } |
2923 | 2923 | |
2924 | 2924 | /** |
2925 | 2925 | * Checks to see if the invoice requires payment. |
2926 | 2926 | */ |
2927 | 2927 | public function is_free() { |
2928 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
2928 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
2929 | 2929 | |
2930 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
2930 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
2931 | 2931 | $is_free = false; |
2932 | 2932 | } |
2933 | 2933 | |
2934 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
2934 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
2935 | 2935 | } |
2936 | 2936 | |
2937 | 2937 | /** |
2938 | 2938 | * Checks if the invoice is paid. |
2939 | 2939 | */ |
2940 | 2940 | public function is_paid() { |
2941 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
2942 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
2941 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
2942 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
2943 | 2943 | } |
2944 | 2944 | |
2945 | 2945 | /** |
2946 | 2946 | * Checks if the invoice needs payment. |
2947 | 2947 | */ |
2948 | 2948 | public function needs_payment() { |
2949 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
2950 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
2949 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
2950 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
2951 | 2951 | } |
2952 | 2952 | |
2953 | 2953 | /** |
2954 | 2954 | * Checks if the invoice is refunded. |
2955 | 2955 | */ |
2956 | 2956 | public function is_refunded() { |
2957 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
2958 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
2957 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
2958 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
2959 | 2959 | } |
2960 | 2960 | |
2961 | 2961 | /** |
2962 | 2962 | * Checks if the invoice is held. |
2963 | 2963 | */ |
2964 | 2964 | public function is_held() { |
2965 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
2966 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
2965 | + $is_held = $this->has_status('wpi-onhold'); |
|
2966 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
2967 | 2967 | } |
2968 | 2968 | |
2969 | 2969 | /** |
@@ -2971,30 +2971,30 @@ discard block |
||
2971 | 2971 | */ |
2972 | 2972 | public function is_due() { |
2973 | 2973 | $due_date = $this->get_due_date(); |
2974 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
2974 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
2975 | 2975 | } |
2976 | 2976 | |
2977 | 2977 | /** |
2978 | 2978 | * Checks if the invoice is draft. |
2979 | 2979 | */ |
2980 | 2980 | public function is_draft() { |
2981 | - return $this->has_status( 'draft, auto-draft' ); |
|
2981 | + return $this->has_status('draft, auto-draft'); |
|
2982 | 2982 | } |
2983 | 2983 | |
2984 | 2984 | /** |
2985 | 2985 | * Checks if the invoice has a given status. |
2986 | 2986 | */ |
2987 | - public function has_status( $status ) { |
|
2988 | - $status = wpinv_parse_list( $status ); |
|
2989 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
2987 | + public function has_status($status) { |
|
2988 | + $status = wpinv_parse_list($status); |
|
2989 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
2990 | 2990 | } |
2991 | 2991 | |
2992 | 2992 | /** |
2993 | 2993 | * Checks if the invoice is of a given type. |
2994 | 2994 | */ |
2995 | - public function is_type( $type ) { |
|
2996 | - $type = wpinv_parse_list( $type ); |
|
2997 | - return in_array( $this->get_type(), $type ); |
|
2995 | + public function is_type($type) { |
|
2996 | + $type = wpinv_parse_list($type); |
|
2997 | + return in_array($this->get_type(), $type); |
|
2998 | 2998 | } |
2999 | 2999 | |
3000 | 3000 | /** |
@@ -3026,8 +3026,8 @@ discard block |
||
3026 | 3026 | * |
3027 | 3027 | */ |
3028 | 3028 | public function is_initial_free() { |
3029 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3030 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3029 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3030 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3031 | 3031 | } |
3032 | 3032 | |
3033 | 3033 | /** |
@@ -3037,11 +3037,11 @@ discard block |
||
3037 | 3037 | public function item_has_free_trial() { |
3038 | 3038 | |
3039 | 3039 | // Ensure we have a recurring item. |
3040 | - if ( ! $this->is_recurring() ) { |
|
3040 | + if (!$this->is_recurring()) { |
|
3041 | 3041 | return false; |
3042 | 3042 | } |
3043 | 3043 | |
3044 | - $item = $this->get_recurring( true ); |
|
3044 | + $item = $this->get_recurring(true); |
|
3045 | 3045 | return $item->has_free_trial(); |
3046 | 3046 | } |
3047 | 3047 | |
@@ -3049,7 +3049,7 @@ discard block |
||
3049 | 3049 | * Check if the free trial is a result of a discount. |
3050 | 3050 | */ |
3051 | 3051 | public function is_free_trial_from_discount() { |
3052 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3052 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3053 | 3053 | } |
3054 | 3054 | |
3055 | 3055 | /** |
@@ -3058,17 +3058,17 @@ discard block |
||
3058 | 3058 | public function discount_first_payment_only() { |
3059 | 3059 | |
3060 | 3060 | $discount_code = $this->get_discount_code(); |
3061 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
3061 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
3062 | 3062 | return true; |
3063 | 3063 | } |
3064 | 3064 | |
3065 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3065 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3066 | 3066 | |
3067 | - if ( ! $discount || ! $discount->exists() ) { |
|
3067 | + if (!$discount || !$discount->exists()) { |
|
3068 | 3068 | return true; |
3069 | 3069 | } |
3070 | 3070 | |
3071 | - return ! $discount->get_is_recurring(); |
|
3071 | + return !$discount->get_is_recurring(); |
|
3072 | 3072 | } |
3073 | 3073 | |
3074 | 3074 | /* |
@@ -3086,27 +3086,27 @@ discard block |
||
3086 | 3086 | * @param GetPaid_Form_Item|array $item |
3087 | 3087 | * @return WP_Error|Bool |
3088 | 3088 | */ |
3089 | - public function add_item( $item ) { |
|
3089 | + public function add_item($item) { |
|
3090 | 3090 | |
3091 | - if ( is_array( $item ) ) { |
|
3092 | - $item = $this->process_array_item( $item ); |
|
3091 | + if (is_array($item)) { |
|
3092 | + $item = $this->process_array_item($item); |
|
3093 | 3093 | } |
3094 | 3094 | |
3095 | - if ( is_numeric( $item ) ) { |
|
3096 | - $item = new GetPaid_Form_Item( $item ); |
|
3095 | + if (is_numeric($item)) { |
|
3096 | + $item = new GetPaid_Form_Item($item); |
|
3097 | 3097 | } |
3098 | 3098 | |
3099 | 3099 | // Make sure that it is available for purchase. |
3100 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3101 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3100 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3101 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3102 | 3102 | } |
3103 | 3103 | |
3104 | 3104 | // Do we have a recurring item? |
3105 | - if ( $item->is_recurring() ) { |
|
3105 | + if ($item->is_recurring()) { |
|
3106 | 3106 | |
3107 | 3107 | // An invoice can only contain one recurring item. |
3108 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
3109 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
3108 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
3109 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
3110 | 3110 | } |
3111 | 3111 | |
3112 | 3112 | $this->recurring_item = $item->get_id(); |
@@ -3117,9 +3117,9 @@ discard block |
||
3117 | 3117 | |
3118 | 3118 | // Retrieve all items. |
3119 | 3119 | $items = $this->get_items(); |
3120 | - $items[ (int) $item->get_id() ] = $item; |
|
3120 | + $items[(int) $item->get_id()] = $item; |
|
3121 | 3121 | |
3122 | - $this->set_prop( 'items', $items ); |
|
3122 | + $this->set_prop('items', $items); |
|
3123 | 3123 | return true; |
3124 | 3124 | } |
3125 | 3125 | |
@@ -3129,26 +3129,26 @@ discard block |
||
3129 | 3129 | * @since 1.0.19 |
3130 | 3130 | * @return GetPaid_Form_Item |
3131 | 3131 | */ |
3132 | - protected function process_array_item( $array ) { |
|
3132 | + protected function process_array_item($array) { |
|
3133 | 3133 | |
3134 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3135 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3134 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3135 | + $item = new GetPaid_Form_Item($item_id); |
|
3136 | 3136 | |
3137 | 3137 | // Set item data. |
3138 | - foreach( array( 'name', 'price', 'description' ) as $key ) { |
|
3139 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3138 | + foreach (array('name', 'price', 'description') as $key) { |
|
3139 | + if (isset($array["item_$key"])) { |
|
3140 | 3140 | $method = "set_$key"; |
3141 | - $item->$method( $array[ "item_$key" ] ); |
|
3141 | + $item->$method($array["item_$key"]); |
|
3142 | 3142 | } |
3143 | 3143 | } |
3144 | 3144 | |
3145 | - if ( isset( $array['quantity'] ) ) { |
|
3146 | - $item->set_quantity( $array['quantity'] ); |
|
3145 | + if (isset($array['quantity'])) { |
|
3146 | + $item->set_quantity($array['quantity']); |
|
3147 | 3147 | } |
3148 | 3148 | |
3149 | 3149 | // Set item meta. |
3150 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3151 | - $item->set_item_meta( $array['meta'] ); |
|
3150 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3151 | + $item->set_item_meta($array['meta']); |
|
3152 | 3152 | } |
3153 | 3153 | |
3154 | 3154 | return $item; |
@@ -3160,10 +3160,10 @@ discard block |
||
3160 | 3160 | * |
3161 | 3161 | * @since 1.0.19 |
3162 | 3162 | */ |
3163 | - public function get_item( $item_id ) { |
|
3163 | + public function get_item($item_id) { |
|
3164 | 3164 | $items = $this->get_items(); |
3165 | 3165 | $item_id = (int) $item_id; |
3166 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3166 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
3167 | 3167 | } |
3168 | 3168 | |
3169 | 3169 | /** |
@@ -3171,17 +3171,17 @@ discard block |
||
3171 | 3171 | * |
3172 | 3172 | * @since 1.0.19 |
3173 | 3173 | */ |
3174 | - public function remove_item( $item_id ) { |
|
3174 | + public function remove_item($item_id) { |
|
3175 | 3175 | $items = $this->get_items(); |
3176 | 3176 | $item_id = (int) $item_id; |
3177 | 3177 | |
3178 | - if ( $item_id == $this->recurring_item ) { |
|
3178 | + if ($item_id == $this->recurring_item) { |
|
3179 | 3179 | $this->recurring_item = null; |
3180 | 3180 | } |
3181 | 3181 | |
3182 | - if ( isset( $items[ $item_id ] ) ) { |
|
3183 | - unset( $items[ $item_id ] ); |
|
3184 | - $this->set_prop( 'items', $items ); |
|
3182 | + if (isset($items[$item_id])) { |
|
3183 | + unset($items[$item_id]); |
|
3184 | + $this->set_prop('items', $items); |
|
3185 | 3185 | } |
3186 | 3186 | } |
3187 | 3187 | |
@@ -3192,27 +3192,27 @@ discard block |
||
3192 | 3192 | * @param float $value |
3193 | 3193 | * @return WP_Error|Bool |
3194 | 3194 | */ |
3195 | - public function add_fee( $fee, $value, $recurring = false ) { |
|
3195 | + public function add_fee($fee, $value, $recurring = false) { |
|
3196 | 3196 | |
3197 | - $amount = wpinv_sanitize_amount( $value ); |
|
3197 | + $amount = wpinv_sanitize_amount($value); |
|
3198 | 3198 | $fees = $this->get_fees(); |
3199 | 3199 | |
3200 | - if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
|
3200 | + if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) { |
|
3201 | 3201 | |
3202 | - $amount = $fees[ $fee ]['amount'] += $amount; |
|
3203 | - $fees[ $fee ] = array( |
|
3202 | + $amount = $fees[$fee]['amount'] += $amount; |
|
3203 | + $fees[$fee] = array( |
|
3204 | 3204 | 'amount' => $amount, |
3205 | 3205 | 'recurring' => (bool) $recurring, |
3206 | 3206 | ); |
3207 | 3207 | |
3208 | 3208 | } else { |
3209 | - $fees[ $fee ] = array( |
|
3209 | + $fees[$fee] = array( |
|
3210 | 3210 | 'amount' => $amount, |
3211 | 3211 | 'recurring' => (bool) $recurring, |
3212 | 3212 | ); |
3213 | 3213 | } |
3214 | 3214 | |
3215 | - $this->set_prop( 'fees', $fee ); |
|
3215 | + $this->set_prop('fees', $fee); |
|
3216 | 3216 | |
3217 | 3217 | } |
3218 | 3218 | |
@@ -3221,9 +3221,9 @@ discard block |
||
3221 | 3221 | * |
3222 | 3222 | * @since 1.0.19 |
3223 | 3223 | */ |
3224 | - public function get_fee( $fee ) { |
|
3224 | + public function get_fee($fee) { |
|
3225 | 3225 | $fees = $this->get_fees(); |
3226 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3226 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3227 | 3227 | } |
3228 | 3228 | |
3229 | 3229 | /** |
@@ -3231,11 +3231,11 @@ discard block |
||
3231 | 3231 | * |
3232 | 3232 | * @since 1.0.19 |
3233 | 3233 | */ |
3234 | - public function remove_fee( $fee ) { |
|
3234 | + public function remove_fee($fee) { |
|
3235 | 3235 | $fees = $this->get_fees(); |
3236 | - if ( isset( $fees[ $fee ] ) ) { |
|
3237 | - unset( $fees[ $fee ] ); |
|
3238 | - $this->set_prop( 'fees', $fees ); |
|
3236 | + if (isset($fees[$fee])) { |
|
3237 | + unset($fees[$fee]); |
|
3238 | + $this->set_prop('fees', $fees); |
|
3239 | 3239 | } |
3240 | 3240 | } |
3241 | 3241 | |
@@ -3246,27 +3246,27 @@ discard block |
||
3246 | 3246 | * @param float $value |
3247 | 3247 | * @return WP_Error|Bool |
3248 | 3248 | */ |
3249 | - public function add_discount( $discount, $value, $recurring = false ) { |
|
3249 | + public function add_discount($discount, $value, $recurring = false) { |
|
3250 | 3250 | |
3251 | - $amount = wpinv_sanitize_amount( $value ); |
|
3251 | + $amount = wpinv_sanitize_amount($value); |
|
3252 | 3252 | $discounts = $this->get_discounts(); |
3253 | 3253 | |
3254 | - if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
|
3254 | + if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) { |
|
3255 | 3255 | |
3256 | - $amount = $discounts[ $discount ]['amount'] += $amount; |
|
3257 | - $discounts[ $discount ] = array( |
|
3256 | + $amount = $discounts[$discount]['amount'] += $amount; |
|
3257 | + $discounts[$discount] = array( |
|
3258 | 3258 | 'amount' => $amount, |
3259 | 3259 | 'recurring' => (bool) $recurring, |
3260 | 3260 | ); |
3261 | 3261 | |
3262 | 3262 | } else { |
3263 | - $discounts[ $discount ] = array( |
|
3263 | + $discounts[$discount] = array( |
|
3264 | 3264 | 'amount' => $amount, |
3265 | 3265 | 'recurring' => (bool) $recurring, |
3266 | 3266 | ); |
3267 | 3267 | } |
3268 | 3268 | |
3269 | - $this->set_prop( 'discounts', $discount ); |
|
3269 | + $this->set_prop('discounts', $discount); |
|
3270 | 3270 | |
3271 | 3271 | } |
3272 | 3272 | |
@@ -3275,15 +3275,15 @@ discard block |
||
3275 | 3275 | * |
3276 | 3276 | * @since 1.0.19 |
3277 | 3277 | */ |
3278 | - public function get_discount( $discount = false ) { |
|
3278 | + public function get_discount($discount = false) { |
|
3279 | 3279 | |
3280 | 3280 | // Backwards compatibilty. |
3281 | - if ( empty( $discount ) ) { |
|
3281 | + if (empty($discount)) { |
|
3282 | 3282 | return $this->get_total_discount(); |
3283 | 3283 | } |
3284 | 3284 | |
3285 | 3285 | $discounts = $this->get_discounts(); |
3286 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3286 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3287 | 3287 | } |
3288 | 3288 | |
3289 | 3289 | /** |
@@ -3291,11 +3291,11 @@ discard block |
||
3291 | 3291 | * |
3292 | 3292 | * @since 1.0.19 |
3293 | 3293 | */ |
3294 | - public function remove_discount( $discount ) { |
|
3294 | + public function remove_discount($discount) { |
|
3295 | 3295 | $discounts = $this->get_discounts(); |
3296 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3297 | - unset( $discounts[ $discount ] ); |
|
3298 | - $this->set_prop( 'discounts', $discounts ); |
|
3296 | + if (isset($discounts[$discount])) { |
|
3297 | + unset($discounts[$discount]); |
|
3298 | + $this->set_prop('discounts', $discounts); |
|
3299 | 3299 | } |
3300 | 3300 | } |
3301 | 3301 | |
@@ -3305,31 +3305,31 @@ discard block |
||
3305 | 3305 | * @param string $tax |
3306 | 3306 | * @param float $value |
3307 | 3307 | */ |
3308 | - public function add_tax( $tax, $value, $recurring = true ) { |
|
3308 | + public function add_tax($tax, $value, $recurring = true) { |
|
3309 | 3309 | |
3310 | - if ( ! $this->is_taxable() ) { |
|
3310 | + if (!$this->is_taxable()) { |
|
3311 | 3311 | return; |
3312 | 3312 | } |
3313 | 3313 | |
3314 | - $amount = wpinv_sanitize_amount( $value ); |
|
3314 | + $amount = wpinv_sanitize_amount($value); |
|
3315 | 3315 | $taxes = $this->get_taxes(); |
3316 | 3316 | |
3317 | - if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
|
3317 | + if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) { |
|
3318 | 3318 | |
3319 | - $amount = $taxes[ $tax ]['amount'] += $amount; |
|
3320 | - $taxes[ $tax ] = array( |
|
3319 | + $amount = $taxes[$tax]['amount'] += $amount; |
|
3320 | + $taxes[$tax] = array( |
|
3321 | 3321 | 'amount' => $amount, |
3322 | 3322 | 'recurring' => (bool) $recurring, |
3323 | 3323 | ); |
3324 | 3324 | |
3325 | 3325 | } else { |
3326 | - $taxes[ $tax ] = array( |
|
3326 | + $taxes[$tax] = array( |
|
3327 | 3327 | 'amount' => $amount, |
3328 | 3328 | 'recurring' => (bool) $recurring, |
3329 | 3329 | ); |
3330 | 3330 | } |
3331 | 3331 | |
3332 | - $this->set_prop( 'taxes', $tax ); |
|
3332 | + $this->set_prop('taxes', $tax); |
|
3333 | 3333 | |
3334 | 3334 | } |
3335 | 3335 | |
@@ -3338,15 +3338,15 @@ discard block |
||
3338 | 3338 | * |
3339 | 3339 | * @since 1.0.19 |
3340 | 3340 | */ |
3341 | - public function get_tax( $tax = null ) { |
|
3341 | + public function get_tax($tax = null) { |
|
3342 | 3342 | |
3343 | 3343 | // Backwards compatility. |
3344 | - if ( empty( $tax ) ) { |
|
3344 | + if (empty($tax)) { |
|
3345 | 3345 | return $this->get_total_tax(); |
3346 | 3346 | } |
3347 | 3347 | |
3348 | 3348 | $taxes = $this->get_taxes(); |
3349 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3349 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3350 | 3350 | } |
3351 | 3351 | |
3352 | 3352 | /** |
@@ -3354,11 +3354,11 @@ discard block |
||
3354 | 3354 | * |
3355 | 3355 | * @since 1.0.19 |
3356 | 3356 | */ |
3357 | - public function remove_tax( $tax ) { |
|
3357 | + public function remove_tax($tax) { |
|
3358 | 3358 | $taxes = $this->get_discounts(); |
3359 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3360 | - unset( $taxes[ $tax ] ); |
|
3361 | - $this->set_prop( 'taxes', $taxes ); |
|
3359 | + if (isset($taxes[$tax])) { |
|
3360 | + unset($taxes[$tax]); |
|
3361 | + $this->set_prop('taxes', $taxes); |
|
3362 | 3362 | } |
3363 | 3363 | } |
3364 | 3364 | |
@@ -3369,19 +3369,19 @@ discard block |
||
3369 | 3369 | * @return float The recalculated subtotal |
3370 | 3370 | */ |
3371 | 3371 | public function recalculate_subtotal() { |
3372 | - $items = $this->get_items(); |
|
3372 | + $items = $this->get_items(); |
|
3373 | 3373 | $subtotal = 0; |
3374 | 3374 | $recurring = 0; |
3375 | 3375 | |
3376 | - foreach ( $items as $item ) { |
|
3376 | + foreach ($items as $item) { |
|
3377 | 3377 | $subtotal += $item->get_sub_total(); |
3378 | 3378 | $recurring += $item->get_recurring_sub_total(); |
3379 | 3379 | } |
3380 | 3380 | |
3381 | - if ( $this->is_renewal() ) { |
|
3382 | - $this->set_subtotal( $recurring ); |
|
3381 | + if ($this->is_renewal()) { |
|
3382 | + $this->set_subtotal($recurring); |
|
3383 | 3383 | } else { |
3384 | - $this->set_subtotal( $subtotal ); |
|
3384 | + $this->set_subtotal($subtotal); |
|
3385 | 3385 | } |
3386 | 3386 | |
3387 | 3387 | $this->totals['subtotal'] = array( |
@@ -3403,9 +3403,9 @@ discard block |
||
3403 | 3403 | $discount = 0; |
3404 | 3404 | $recurring = 0; |
3405 | 3405 | |
3406 | - foreach ( $discounts as $data ) { |
|
3406 | + foreach ($discounts as $data) { |
|
3407 | 3407 | |
3408 | - if ( $data['recurring'] ) { |
|
3408 | + if ($data['recurring']) { |
|
3409 | 3409 | $recurring += $data['amount']; |
3410 | 3410 | } else { |
3411 | 3411 | $discount += $data['amount']; |
@@ -3413,10 +3413,10 @@ discard block |
||
3413 | 3413 | |
3414 | 3414 | } |
3415 | 3415 | |
3416 | - if ( $this->is_renewal() ) { |
|
3417 | - $this->set_total_discount( $recurring ); |
|
3416 | + if ($this->is_renewal()) { |
|
3417 | + $this->set_total_discount($recurring); |
|
3418 | 3418 | } else { |
3419 | - $this->set_total_discount( $discount ); |
|
3419 | + $this->set_total_discount($discount); |
|
3420 | 3420 | } |
3421 | 3421 | |
3422 | 3422 | $this->totals['discount'] = array( |
@@ -3435,13 +3435,13 @@ discard block |
||
3435 | 3435 | * @return float The recalculated tax |
3436 | 3436 | */ |
3437 | 3437 | public function recalculate_total_tax() { |
3438 | - $taxes = $this->get_taxes(); |
|
3438 | + $taxes = $this->get_taxes(); |
|
3439 | 3439 | $tax = 0; |
3440 | 3440 | $recurring = 0; |
3441 | 3441 | |
3442 | - foreach ( $taxes as $data ) { |
|
3442 | + foreach ($taxes as $data) { |
|
3443 | 3443 | |
3444 | - if ( $data['recurring'] ) { |
|
3444 | + if ($data['recurring']) { |
|
3445 | 3445 | $recurring += $data['amount']; |
3446 | 3446 | } else { |
3447 | 3447 | $tax += $data['amount']; |
@@ -3449,10 +3449,10 @@ discard block |
||
3449 | 3449 | |
3450 | 3450 | } |
3451 | 3451 | |
3452 | - if ( $this->is_renewal() ) { |
|
3453 | - $this->set_total_tax( $recurring ); |
|
3452 | + if ($this->is_renewal()) { |
|
3453 | + $this->set_total_tax($recurring); |
|
3454 | 3454 | } else { |
3455 | - $this->set_total_tax( $tax ); |
|
3455 | + $this->set_total_tax($tax); |
|
3456 | 3456 | } |
3457 | 3457 | |
3458 | 3458 | $this->totals['tax'] = array( |
@@ -3475,9 +3475,9 @@ discard block |
||
3475 | 3475 | $fee = 0; |
3476 | 3476 | $recurring = 0; |
3477 | 3477 | |
3478 | - foreach ( $fees as $data ) { |
|
3478 | + foreach ($fees as $data) { |
|
3479 | 3479 | |
3480 | - if ( $data['recurring'] ) { |
|
3480 | + if ($data['recurring']) { |
|
3481 | 3481 | $recurring += $data['amount']; |
3482 | 3482 | } else { |
3483 | 3483 | $fee += $data['amount']; |
@@ -3485,10 +3485,10 @@ discard block |
||
3485 | 3485 | |
3486 | 3486 | } |
3487 | 3487 | |
3488 | - if ( $this->is_renewal() ) { |
|
3489 | - $this->set_total_fees( $recurring ); |
|
3488 | + if ($this->is_renewal()) { |
|
3489 | + $this->set_total_fees($recurring); |
|
3490 | 3490 | } else { |
3491 | - $this->set_total_fees( $fee ); |
|
3491 | + $this->set_total_fees($fee); |
|
3492 | 3492 | } |
3493 | 3493 | |
3494 | 3494 | $this->totals['fee'] = array( |
@@ -3496,7 +3496,7 @@ discard block |
||
3496 | 3496 | 'recurring' => $recurring, |
3497 | 3497 | ); |
3498 | 3498 | |
3499 | - $this->set_total_fees( $fee ); |
|
3499 | + $this->set_total_fees($fee); |
|
3500 | 3500 | return $this->is_renewal() ? $recurring : $fee; |
3501 | 3501 | } |
3502 | 3502 | |
@@ -3517,9 +3517,9 @@ discard block |
||
3517 | 3517 | /** |
3518 | 3518 | * @deprecated |
3519 | 3519 | */ |
3520 | - public function recalculate_totals( $temp = false ) { |
|
3521 | - $this->update_items( $temp ); |
|
3522 | - $this->save( true ); |
|
3520 | + public function recalculate_totals($temp = false) { |
|
3521 | + $this->update_items($temp); |
|
3522 | + $this->save(true); |
|
3523 | 3523 | return $this; |
3524 | 3524 | } |
3525 | 3525 | |
@@ -3537,36 +3537,36 @@ discard block |
||
3537 | 3537 | * @return int|false The new note's ID on success, false on failure. |
3538 | 3538 | * |
3539 | 3539 | */ |
3540 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3540 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3541 | 3541 | |
3542 | 3542 | // Bail if no note specified or this invoice is not yet saved. |
3543 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3543 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3544 | 3544 | return false; |
3545 | 3545 | } |
3546 | 3546 | |
3547 | 3547 | // If this is an admin comment or it has been added by the user. |
3548 | - if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) { |
|
3549 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3548 | + if (is_user_logged_in() && (wpinv_current_user_can_manage_invoicing() || $added_by_user)) { |
|
3549 | + $user = get_user_by('id', get_current_user_id()); |
|
3550 | 3550 | $author = $user->display_name; |
3551 | 3551 | $author_email = $user->user_email; |
3552 | 3552 | } |
3553 | 3553 | |
3554 | - if ( $system ) { |
|
3555 | - $author = 'System'; |
|
3554 | + if ($system) { |
|
3555 | + $author = 'System'; |
|
3556 | 3556 | $author_email = '[email protected]'; |
3557 | 3557 | } |
3558 | 3558 | |
3559 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3559 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3560 | 3560 | |
3561 | 3561 | } |
3562 | 3562 | |
3563 | 3563 | /** |
3564 | 3564 | * Generates a unique key for the invoice. |
3565 | 3565 | */ |
3566 | - public function generate_key( $string = '' ) { |
|
3567 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3566 | + public function generate_key($string = '') { |
|
3567 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3568 | 3568 | return strtolower( |
3569 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3569 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3570 | 3570 | ); |
3571 | 3571 | } |
3572 | 3572 | |
@@ -3576,11 +3576,11 @@ discard block |
||
3576 | 3576 | public function generate_number() { |
3577 | 3577 | $number = $this->get_id(); |
3578 | 3578 | |
3579 | - if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) { |
|
3580 | - $number = wpinv_get_next_invoice_number( $this->post_type ); |
|
3579 | + if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) { |
|
3580 | + $number = wpinv_get_next_invoice_number($this->post_type); |
|
3581 | 3581 | } |
3582 | 3582 | |
3583 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
3583 | + $number = wpinv_format_invoice_number($number, $this->post_type); |
|
3584 | 3584 | |
3585 | 3585 | return $number; |
3586 | 3586 | } |
@@ -3594,47 +3594,47 @@ discard block |
||
3594 | 3594 | // Reset status transition variable. |
3595 | 3595 | $this->status_transition = false; |
3596 | 3596 | |
3597 | - if ( $status_transition ) { |
|
3597 | + if ($status_transition) { |
|
3598 | 3598 | try { |
3599 | 3599 | |
3600 | 3600 | // Fire a hook for the status change. |
3601 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
3601 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
3602 | 3602 | |
3603 | 3603 | // @deprecated this is deprecated and will be removed in the future. |
3604 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3604 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3605 | 3605 | |
3606 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3606 | + if (!empty($status_transition['from'])) { |
|
3607 | 3607 | |
3608 | 3608 | /* translators: 1: old invoice status 2: new invoice status */ |
3609 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3609 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to'])); |
|
3610 | 3610 | |
3611 | 3611 | // Fire another hook. |
3612 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
3613 | - do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
3612 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
3613 | + do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this); |
|
3614 | 3614 | |
3615 | 3615 | // @deprecated this is deprecated and will be removed in the future. |
3616 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3616 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3617 | 3617 | |
3618 | 3618 | // Note the transition occurred. |
3619 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3619 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3620 | 3620 | |
3621 | 3621 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3622 | 3622 | if ( |
3623 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true ) |
|
3624 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3623 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true) |
|
3624 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3625 | 3625 | ) { |
3626 | - do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
3626 | + do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition); |
|
3627 | 3627 | } |
3628 | 3628 | } else { |
3629 | 3629 | /* translators: %s: new invoice status */ |
3630 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3630 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'])); |
|
3631 | 3631 | |
3632 | 3632 | // Note the transition occurred. |
3633 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3633 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3634 | 3634 | |
3635 | 3635 | } |
3636 | - } catch ( Exception $e ) { |
|
3637 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3636 | + } catch (Exception $e) { |
|
3637 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3638 | 3638 | } |
3639 | 3639 | } |
3640 | 3640 | } |
@@ -3642,13 +3642,13 @@ discard block |
||
3642 | 3642 | /** |
3643 | 3643 | * Updates an invoice status. |
3644 | 3644 | */ |
3645 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3645 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3646 | 3646 | |
3647 | 3647 | // Fires before updating a status. |
3648 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3648 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3649 | 3649 | |
3650 | 3650 | // Update the status. |
3651 | - $this->set_status( $new_status, $note, $manual ); |
|
3651 | + $this->set_status($new_status, $note, $manual); |
|
3652 | 3652 | |
3653 | 3653 | // Save the order. |
3654 | 3654 | return $this->save(); |
@@ -3659,18 +3659,18 @@ discard block |
||
3659 | 3659 | * @deprecated |
3660 | 3660 | */ |
3661 | 3661 | public function refresh_item_ids() { |
3662 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
3663 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3662 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
3663 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3664 | 3664 | } |
3665 | 3665 | |
3666 | 3666 | /** |
3667 | 3667 | * @deprecated |
3668 | 3668 | */ |
3669 | - public function update_items( $temp = false ) { |
|
3669 | + public function update_items($temp = false) { |
|
3670 | 3670 | |
3671 | - $this->set_items( $this->get_items() ); |
|
3671 | + $this->set_items($this->get_items()); |
|
3672 | 3672 | |
3673 | - if ( ! $temp ) { |
|
3673 | + if (!$temp) { |
|
3674 | 3674 | $this->save(); |
3675 | 3675 | } |
3676 | 3676 | |
@@ -3684,11 +3684,11 @@ discard block |
||
3684 | 3684 | |
3685 | 3685 | $discount_code = $this->get_discount_code(); |
3686 | 3686 | |
3687 | - if ( empty( $discount_code ) ) { |
|
3687 | + if (empty($discount_code)) { |
|
3688 | 3688 | return false; |
3689 | 3689 | } |
3690 | 3690 | |
3691 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3691 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3692 | 3692 | |
3693 | 3693 | // Ensure it is active. |
3694 | 3694 | return $discount->exists(); |
@@ -3699,7 +3699,7 @@ discard block |
||
3699 | 3699 | * Refunds an invoice. |
3700 | 3700 | */ |
3701 | 3701 | public function refund() { |
3702 | - $this->set_status( 'wpi-refunded' ); |
|
3702 | + $this->set_status('wpi-refunded'); |
|
3703 | 3703 | $this->save(); |
3704 | 3704 | } |
3705 | 3705 | |
@@ -3708,56 +3708,56 @@ discard block |
||
3708 | 3708 | * |
3709 | 3709 | * @param string $transaction_id |
3710 | 3710 | */ |
3711 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3711 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3712 | 3712 | |
3713 | 3713 | // Set the transaction id. |
3714 | - if ( empty( $transaction_id ) ) { |
|
3714 | + if (empty($transaction_id)) { |
|
3715 | 3715 | $transaction_id = $this->generate_key('trans_'); |
3716 | 3716 | } |
3717 | 3717 | |
3718 | - if ( ! $this->get_transaction_id() ) { |
|
3719 | - $this->set_transaction_id( $transaction_id ); |
|
3718 | + if (!$this->get_transaction_id()) { |
|
3719 | + $this->set_transaction_id($transaction_id); |
|
3720 | 3720 | } |
3721 | 3721 | |
3722 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3722 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3723 | 3723 | return $this->save(); |
3724 | 3724 | } |
3725 | 3725 | |
3726 | 3726 | // Set the completed date. |
3727 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3727 | + $this->set_date_completed(current_time('mysql')); |
|
3728 | 3728 | |
3729 | 3729 | // Set the new status. |
3730 | - if ( $this->is_renewal() ) { |
|
3730 | + if ($this->is_renewal()) { |
|
3731 | 3731 | |
3732 | 3732 | $_note = sprintf( |
3733 | - __( 'Renewed via %s', 'invoicing' ), |
|
3734 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3733 | + __('Renewed via %s', 'invoicing'), |
|
3734 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3735 | 3735 | ); |
3736 | 3736 | |
3737 | - if ( 'none' == $this->get_gateway() ) { |
|
3737 | + if ('none' == $this->get_gateway()) { |
|
3738 | 3738 | $_note = $note; |
3739 | 3739 | } |
3740 | 3740 | |
3741 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3741 | + $this->set_status('wpi-renewal', $_note); |
|
3742 | 3742 | |
3743 | 3743 | } else { |
3744 | 3744 | |
3745 | 3745 | $_note = sprintf( |
3746 | - __( 'Paid via %s', 'invoicing' ), |
|
3747 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3746 | + __('Paid via %s', 'invoicing'), |
|
3747 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3748 | 3748 | ); |
3749 | 3749 | |
3750 | - if ( 'none' == $this->get_gateway() ) { |
|
3750 | + if ('none' == $this->get_gateway()) { |
|
3751 | 3751 | $_note = $note; |
3752 | 3752 | } |
3753 | 3753 | |
3754 | - $this->set_status( 'publish',$_note ); |
|
3754 | + $this->set_status('publish', $_note); |
|
3755 | 3755 | |
3756 | 3756 | } |
3757 | 3757 | |
3758 | 3758 | // Set checkout mode. |
3759 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
3760 | - $this->set_mode( $mode ); |
|
3759 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
3760 | + $this->set_mode($mode); |
|
3761 | 3761 | |
3762 | 3762 | // Save the invoice. |
3763 | 3763 | $this->save(); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * GetPaid_Subscription_Data_Store class file. |
5 | 5 | * |
6 | 6 | */ |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -50,28 +50,28 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param WPInv_Subscription $subscription Subscription object. |
52 | 52 | */ |
53 | - public function create( &$subscription ) { |
|
53 | + public function create(&$subscription) { |
|
54 | 54 | global $wpdb; |
55 | 55 | |
56 | 56 | $values = array(); |
57 | 57 | $formats = array(); |
58 | 58 | |
59 | 59 | $fields = $this->database_fields_to_data_type; |
60 | - unset( $fields['id'] ); |
|
60 | + unset($fields['id']); |
|
61 | 61 | |
62 | - foreach ( $fields as $key => $format ) { |
|
62 | + foreach ($fields as $key => $format) { |
|
63 | 63 | $method = "get_$key"; |
64 | - $values[$key] = $subscription->$method( 'edit' ); |
|
64 | + $values[$key] = $subscription->$method('edit'); |
|
65 | 65 | $formats[] = $format; |
66 | 66 | } |
67 | 67 | |
68 | - $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $fields, $formats ); |
|
68 | + $result = $wpdb->insert($wpdb->prefix . 'wpinv_subscriptions', $fields, $formats); |
|
69 | 69 | |
70 | - if ( $result ) { |
|
71 | - $subscription->set_id( $wpdb->insert_id ); |
|
70 | + if ($result) { |
|
71 | + $subscription->set_id($wpdb->insert_id); |
|
72 | 72 | $subscription->apply_changes(); |
73 | 73 | $subscription->clear_cache(); |
74 | - do_action( 'getpaid_new_subscription', $subscription ); |
|
74 | + do_action('getpaid_new_subscription', $subscription); |
|
75 | 75 | return true; |
76 | 76 | } |
77 | 77 | |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | * @param WPInv_Subscription $subscription Subscription object. |
85 | 85 | * |
86 | 86 | */ |
87 | - public function read( &$subscription ) { |
|
87 | + public function read(&$subscription) { |
|
88 | 88 | global $wpdb; |
89 | 89 | |
90 | 90 | $subscription->set_defaults(); |
91 | 91 | |
92 | - if ( ! $subscription->get_id() ) { |
|
93 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
94 | - $subscription->set_id( 0 ); |
|
92 | + if (!$subscription->get_id()) { |
|
93 | + $subscription->last_error = __('Invalid subscription ID.', 'invoicing'); |
|
94 | + $subscription->set_id(0); |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Maybe retrieve from the cache. |
99 | - $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' ); |
|
99 | + $raw_subscription = wp_cache_get($subscription->get_id(), 'getpaid_subscriptions'); |
|
100 | 100 | |
101 | 101 | // If not found, retrieve from the db. |
102 | - if ( false === $raw_subscription ) { |
|
102 | + if (false === $raw_subscription) { |
|
103 | 103 | |
104 | 104 | $raw_subscription = $wpdb->get_row( |
105 | 105 | $wpdb->prepare( |
@@ -109,22 +109,22 @@ discard block |
||
109 | 109 | ); |
110 | 110 | |
111 | 111 | // Update the cache with our data |
112 | - wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' ); |
|
112 | + wp_cache_set($subscription->get_id(), $raw_subscription, 'getpaid_subscriptions'); |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | - if ( ! $raw_subscription ) { |
|
117 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
116 | + if (!$raw_subscription) { |
|
117 | + $subscription->last_error = __('Invalid subscription ID.', 'invoicing'); |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | - foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) { |
|
122 | - $method = "set_$key"; |
|
123 | - $subscription->$method( $raw_subscription->$key ); |
|
121 | + foreach (array_keys($this->database_fields_to_data_type) as $key) { |
|
122 | + $method = "set_$key"; |
|
123 | + $subscription->$method($raw_subscription->$key); |
|
124 | 124 | } |
125 | 125 | |
126 | - $subscription->set_object_read( true ); |
|
127 | - do_action( 'getpaid_read_subscription', $subscription ); |
|
126 | + $subscription->set_object_read(true); |
|
127 | + do_action('getpaid_read_subscription', $subscription); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -133,22 +133,22 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @param WPInv_Subscription $subscription Subscription object. |
135 | 135 | */ |
136 | - public function update( &$subscription ) { |
|
136 | + public function update(&$subscription) { |
|
137 | 137 | global $wpdb; |
138 | 138 | |
139 | 139 | $changes = $subscription->get_changes(); |
140 | 140 | $values = array(); |
141 | 141 | $format = array(); |
142 | 142 | |
143 | - foreach ( $this->database_fields_to_data_type as $key => $format ) { |
|
144 | - if ( array_key_exists( $key, $changes ) ) { |
|
143 | + foreach ($this->database_fields_to_data_type as $key => $format) { |
|
144 | + if (array_key_exists($key, $changes)) { |
|
145 | 145 | $method = "get_$key"; |
146 | - $values[$key] = $subscription->$method( 'edit' ); |
|
146 | + $values[$key] = $subscription->$method('edit'); |
|
147 | 147 | $formats[] = $format; |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - if ( empty( $values ) ) { |
|
151 | + if (empty($values)) { |
|
152 | 152 | return; |
153 | 153 | } |
154 | 154 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $subscription->clear_cache(); |
170 | 170 | |
171 | 171 | // Fire a hook. |
172 | - do_action( 'getpaid_update_subscription', $subscription->get_id(), $subscription ); |
|
172 | + do_action('getpaid_update_subscription', $subscription->get_id(), $subscription); |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @param WPInv_Subscription $subscription |
180 | 180 | */ |
181 | - public function delete( &$subscription ) { |
|
181 | + public function delete(&$subscription) { |
|
182 | 182 | global $wpdb; |
183 | 183 | |
184 | 184 | $wpdb->query( |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | $subscription->clear_cache(); |
194 | 194 | |
195 | 195 | // Fire a hook. |
196 | - do_action( 'getpaid_delete_subscription', $subscription->get_id(), $subscription ); |
|
196 | + do_action('getpaid_delete_subscription', $subscription->get_id(), $subscription); |
|
197 | 197 | |
198 | - $subscription->set_id( 0 ); |
|
198 | + $subscription->set_id(0); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /* |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | function wpinv_subscription_init() { |
6 | 6 | return WPInv_Subscriptions::instance(); |
7 | 7 | } |
8 | -add_action( 'plugins_loaded', 'wpinv_subscription_init', 100 ); |
|
8 | +add_action('plugins_loaded', 'wpinv_subscription_init', 100); |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * WPInv_Subscriptions Class. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * Main WPInv_Subscriptions Instance |
21 | 21 | */ |
22 | 22 | public static function instance() { |
23 | - if ( ! isset( self::$instance ) ) { |
|
23 | + if (!isset(self::$instance)) { |
|
24 | 24 | self::$instance = new WPInv_Subscriptions; |
25 | 25 | |
26 | 26 | self::$instance->init(); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | - private function __construct(){ |
|
37 | + private function __construct() { |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | private function setup_constants() { |
64 | 64 | |
65 | 65 | // Make sure CAL_GREGORIAN is defined. |
66 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
67 | - define( 'CAL_GREGORIAN', 1 ); |
|
66 | + if (!defined('CAL_GREGORIAN')) { |
|
67 | + define('CAL_GREGORIAN', 1); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private function actions() { |
78 | 78 | |
79 | - add_action( 'admin_menu', array( $this, 'wpinv_subscriptions_list' ), 40 ); |
|
80 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
81 | - add_action( 'init', array( $this, 'wpinv_post_actions' ) ); |
|
82 | - add_action( 'init', array( $this, 'wpinv_get_actions' ) ); |
|
83 | - add_action( 'wpinv_cancel_subscription', array( $this, 'wpinv_process_cancellation' ) ); |
|
84 | - add_action( 'getpaid_checkout_before_gateway', array( $this, 'add_subscription' ), -999 ); |
|
85 | - add_action( 'wpinv_subscriptions_front_notices', array( $this, 'notices' ) ); |
|
86 | - add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) ); |
|
87 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) ); |
|
79 | + add_action('admin_menu', array($this, 'wpinv_subscriptions_list'), 40); |
|
80 | + add_action('admin_notices', array($this, 'notices')); |
|
81 | + add_action('init', array($this, 'wpinv_post_actions')); |
|
82 | + add_action('init', array($this, 'wpinv_get_actions')); |
|
83 | + add_action('wpinv_cancel_subscription', array($this, 'wpinv_process_cancellation')); |
|
84 | + add_action('getpaid_checkout_before_gateway', array($this, 'add_subscription'), -999); |
|
85 | + add_action('wpinv_subscriptions_front_notices', array($this, 'notices')); |
|
86 | + add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription')); |
|
87 | + add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription')); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | public function wpinv_subscriptions_list() { |
107 | 107 | add_submenu_page( |
108 | 108 | 'wpinv', |
109 | - __( 'Subscriptions', 'invoicing' ), |
|
110 | - __( 'Subscriptions', 'invoicing' ), |
|
109 | + __('Subscriptions', 'invoicing'), |
|
110 | + __('Subscriptions', 'invoicing'), |
|
111 | 111 | wpinv_get_capability(), |
112 | 112 | 'wpinv-subscriptions', |
113 | 113 | 'wpinv_subscriptions_page' |
@@ -116,37 +116,37 @@ discard block |
||
116 | 116 | |
117 | 117 | public function notices() { |
118 | 118 | |
119 | - if( empty( $_GET['wpinv-message'] ) ) { |
|
119 | + if (empty($_GET['wpinv-message'])) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | 123 | $type = 'updated'; |
124 | 124 | $message = ''; |
125 | 125 | |
126 | - switch( strtolower( $_GET['wpinv-message'] ) ) { |
|
126 | + switch (strtolower($_GET['wpinv-message'])) { |
|
127 | 127 | |
128 | 128 | case 'updated' : |
129 | 129 | |
130 | - $message = __( 'Subscription updated successfully.', 'invoicing' ); |
|
130 | + $message = __('Subscription updated successfully.', 'invoicing'); |
|
131 | 131 | |
132 | 132 | break; |
133 | 133 | |
134 | 134 | case 'deleted' : |
135 | 135 | |
136 | - $message = __( 'Subscription deleted successfully.', 'invoicing' ); |
|
136 | + $message = __('Subscription deleted successfully.', 'invoicing'); |
|
137 | 137 | |
138 | 138 | break; |
139 | 139 | |
140 | 140 | case 'cancelled' : |
141 | 141 | |
142 | - $message = __( 'Subscription cancelled successfully.', 'invoicing' ); |
|
142 | + $message = __('Subscription cancelled successfully.', 'invoicing'); |
|
143 | 143 | |
144 | 144 | break; |
145 | 145 | |
146 | 146 | } |
147 | 147 | |
148 | - if ( ! empty( $message ) ) { |
|
149 | - echo '<div class="' . esc_attr( $type ) . '"><p>' . $message . '</p></div>'; |
|
148 | + if (!empty($message)) { |
|
149 | + echo '<div class="' . esc_attr($type) . '"><p>' . $message . '</p></div>'; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | } |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | * @return void |
160 | 160 | */ |
161 | 161 | function wpinv_get_actions() { |
162 | - if ( isset( $_GET['wpinv_action'] ) ) { |
|
163 | - do_action( 'wpinv_' . $_GET['wpinv_action'], $_GET ); |
|
162 | + if (isset($_GET['wpinv_action'])) { |
|
163 | + do_action('wpinv_' . $_GET['wpinv_action'], $_GET); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @return void |
173 | 173 | */ |
174 | 174 | function wpinv_post_actions() { |
175 | - if ( isset( $_POST['wpinv_action'] ) ) { |
|
176 | - do_action( 'wpinv_' . $_POST['wpinv_action'], $_POST ); |
|
175 | + if (isset($_POST['wpinv_action'])) { |
|
176 | + do_action('wpinv_' . $_POST['wpinv_action'], $_POST); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
@@ -184,29 +184,29 @@ discard block |
||
184 | 184 | * @param int $frequency_count The frequency of the period. |
185 | 185 | * @return mixed|string|void |
186 | 186 | */ |
187 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) { |
|
187 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
188 | 188 | |
189 | 189 | $frequency = ''; |
190 | 190 | //Format period details |
191 | - switch ( strtolower( $period ) ) { |
|
191 | + switch (strtolower($period)) { |
|
192 | 192 | case 'day' : |
193 | 193 | case 'd' : |
194 | - $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
194 | + $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
195 | 195 | break; |
196 | 196 | case 'week' : |
197 | 197 | case 'w' : |
198 | - $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
198 | + $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
199 | 199 | break; |
200 | 200 | case 'month' : |
201 | 201 | case 'm' : |
202 | - $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
202 | + $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
203 | 203 | break; |
204 | 204 | case 'year' : |
205 | 205 | case 'y' : |
206 | - $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
206 | + $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
207 | 207 | break; |
208 | 208 | default : |
209 | - $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count ); |
|
209 | + $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count); |
|
210 | 210 | break; |
211 | 211 | } |
212 | 212 | |
@@ -221,50 +221,50 @@ discard block |
||
221 | 221 | * @since 1.0.0 |
222 | 222 | * @return void |
223 | 223 | */ |
224 | - public function wpinv_process_cancellation( $data ) { |
|
224 | + public function wpinv_process_cancellation($data) { |
|
225 | 225 | |
226 | 226 | |
227 | - if( empty( $data['sub_id'] ) ) { |
|
227 | + if (empty($data['sub_id'])) { |
|
228 | 228 | return; |
229 | 229 | } |
230 | 230 | |
231 | - if( ! is_user_logged_in() ) { |
|
231 | + if (!is_user_logged_in()) { |
|
232 | 232 | return; |
233 | 233 | } |
234 | 234 | |
235 | - if( ! wp_verify_nonce( $data['_wpnonce'], 'wpinv-recurring-cancel' ) ) { |
|
236 | - wp_die( __( 'Error', 'invoicing' ), __( 'Nonce verification failed', 'invoicing' ), array( 'response' => 403 ) ); |
|
235 | + if (!wp_verify_nonce($data['_wpnonce'], 'wpinv-recurring-cancel')) { |
|
236 | + wp_die(__('Error', 'invoicing'), __('Nonce verification failed', 'invoicing'), array('response' => 403)); |
|
237 | 237 | } |
238 | 238 | |
239 | - $data['sub_id'] = absint( $data['sub_id'] ); |
|
240 | - $subscription = new WPInv_Subscription( $data['sub_id'] ); |
|
239 | + $data['sub_id'] = absint($data['sub_id']); |
|
240 | + $subscription = new WPInv_Subscription($data['sub_id']); |
|
241 | 241 | |
242 | - if( ! $subscription->can_cancel() ) { |
|
243 | - wp_die( __( 'Error', 'invoicing' ), __( 'This subscription cannot be cancelled', 'invoicing' ), array( 'response' => 403 ) ); |
|
242 | + if (!$subscription->can_cancel()) { |
|
243 | + wp_die(__('Error', 'invoicing'), __('This subscription cannot be cancelled', 'invoicing'), array('response' => 403)); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | try { |
247 | 247 | |
248 | - do_action( 'wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true ); |
|
248 | + do_action('wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true); |
|
249 | 249 | |
250 | 250 | $subscription->cancel(); |
251 | 251 | |
252 | - if( is_admin() ) { |
|
252 | + if (is_admin()) { |
|
253 | 253 | |
254 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id ) ); |
|
254 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id)); |
|
255 | 255 | exit; |
256 | 256 | |
257 | 257 | } else { |
258 | 258 | |
259 | - $redirect = remove_query_arg( array( '_wpnonce', 'wpinv_action', 'sub_id' ), add_query_arg( array( 'wpinv-message' => 'cancelled' ) ) ); |
|
260 | - $redirect = apply_filters( 'wpinv_recurring_cancellation_redirect', $redirect, $subscription ); |
|
261 | - wp_safe_redirect( $redirect ); |
|
259 | + $redirect = remove_query_arg(array('_wpnonce', 'wpinv_action', 'sub_id'), add_query_arg(array('wpinv-message' => 'cancelled'))); |
|
260 | + $redirect = apply_filters('wpinv_recurring_cancellation_redirect', $redirect, $subscription); |
|
261 | + wp_safe_redirect($redirect); |
|
262 | 262 | exit; |
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | - } catch ( Exception $e ) { |
|
267 | - wp_die( __( 'Error', 'invoicing' ), $e->getMessage(), array( 'response' => 403 ) ); |
|
266 | + } catch (Exception $e) { |
|
267 | + wp_die(__('Error', 'invoicing'), $e->getMessage(), array('response' => 403)); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | } |
@@ -277,33 +277,33 @@ discard block |
||
277 | 277 | * @since 1.0.0 |
278 | 278 | * @return void |
279 | 279 | */ |
280 | - public function add_subscription( $invoice ) { |
|
280 | + public function add_subscription($invoice) { |
|
281 | 281 | |
282 | - $invoice = new WPInv_Invoice( $invoice ); |
|
282 | + $invoice = new WPInv_Invoice($invoice); |
|
283 | 283 | |
284 | 284 | // Abort if it is not recurring. |
285 | - if ( ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
285 | + if (!$invoice->is_recurring() || $invoice->is_renewal()) { |
|
286 | 286 | return; |
287 | 287 | } |
288 | 288 | |
289 | 289 | // Should we create a subscription for the invoice? |
290 | - if ( apply_filters( 'wpinv_skip_invoice_subscription_creation', false, $invoice ) ) { |
|
290 | + if (apply_filters('wpinv_skip_invoice_subscription_creation', false, $invoice)) { |
|
291 | 291 | return; |
292 | 292 | } |
293 | 293 | |
294 | 294 | // Get the recurring item. |
295 | - $subscription_item = $invoice->get_recurring( true ); |
|
295 | + $subscription_item = $invoice->get_recurring(true); |
|
296 | 296 | |
297 | 297 | // Prepare the subscription details. |
298 | - $period = $subscription_item->get_recurring_period( true ); |
|
298 | + $period = $subscription_item->get_recurring_period(true); |
|
299 | 299 | $interval = $subscription_item->get_recurring_interval(); |
300 | 300 | $add_period = $interval . ' ' . $period; |
301 | 301 | $trial_period = ''; |
302 | 302 | |
303 | - if ( $invoice->has_free_trial() ) { |
|
303 | + if ($invoice->has_free_trial()) { |
|
304 | 304 | |
305 | - if ( $subscription_item->has_free_trial() ) { |
|
306 | - $trial_period = $subscription_item->get_trial_period( true ); |
|
305 | + if ($subscription_item->has_free_trial()) { |
|
306 | + $trial_period = $subscription_item->get_trial_period(true); |
|
307 | 307 | $free_interval = $subscription_item->get_trial_interval(); |
308 | 308 | } else { |
309 | 309 | $trial_period = $period; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | } |
317 | 317 | |
318 | 318 | // Calculate the next renewal date. |
319 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+ $add_period", current_time( 'timestamp' ) ) ); |
|
319 | + $expiration = date('Y-m-d H:i:s', strtotime("+ $add_period", current_time('timestamp'))); |
|
320 | 320 | |
321 | 321 | // Subscription arguments. |
322 | 322 | $args = array( |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | 'initial_amount' => $invoice->get_initial_total(), |
330 | 330 | 'recurring_amount' => $invoice->get_recurring_total(), |
331 | 331 | 'bill_times' => $subscription_item->get_recurring_limit(), |
332 | - 'created' => current_time( 'mysql' ), |
|
332 | + 'created' => current_time('mysql'), |
|
333 | 333 | 'expiration' => $expiration, |
334 | 334 | 'trial_period' => $trial_period, |
335 | 335 | 'profile_id' => '', |
@@ -337,19 +337,19 @@ discard block |
||
337 | 337 | ); |
338 | 338 | |
339 | 339 | // Create or update the subscription. |
340 | - $subscription = wpinv_get_subscription( $invoice ); |
|
340 | + $subscription = wpinv_get_subscription($invoice); |
|
341 | 341 | |
342 | - if ( empty( $subscription ) ) { |
|
342 | + if (empty($subscription)) { |
|
343 | 343 | |
344 | 344 | $subscription = new WPInv_Subscription(); |
345 | - $subscription->create( $args ); |
|
345 | + $subscription->create($args); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
349 | 349 | |
350 | - unset( $args['transaction_id'] ); |
|
351 | - unset( $args['profile_id'] ); |
|
352 | - $subscription->update( $args ); |
|
350 | + unset($args['transaction_id']); |
|
351 | + unset($args['profile_id']); |
|
352 | + $subscription->update($args); |
|
353 | 353 | |
354 | 354 | } |
355 | 355 | |
@@ -362,21 +362,21 @@ discard block |
||
362 | 362 | * @param array $data |
363 | 363 | * @since 1.0.19 |
364 | 364 | */ |
365 | - public function admin_update_single_subscription( $args ) { |
|
365 | + public function admin_update_single_subscription($args) { |
|
366 | 366 | |
367 | 367 | // Ensure the subscription exists and that a status has been given. |
368 | - if ( empty( $args['subscription_id'] ) || empty( $args['subscription_status'] ) ) { |
|
368 | + if (empty($args['subscription_id']) || empty($args['subscription_status'])) { |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 | |
372 | 372 | // Retrieve the subscriptions. |
373 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
373 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
374 | 374 | |
375 | - if ( $subscription->get_id() ) { |
|
375 | + if ($subscription->get_id()) { |
|
376 | 376 | |
377 | - $subscription->set_status( $args['subscription_status'] ); |
|
377 | + $subscription->set_status($args['subscription_status']); |
|
378 | 378 | $subscription->save(); |
379 | - getpaid_admin()->show_info( __( 'Your changes have been saved', 'invoicing' ) ); |
|
379 | + getpaid_admin()->show_info(__('Your changes have been saved', 'invoicing')); |
|
380 | 380 | |
381 | 381 | } |
382 | 382 | |
@@ -388,25 +388,25 @@ discard block |
||
388 | 388 | * @param array $data |
389 | 389 | * @since 1.0.19 |
390 | 390 | */ |
391 | - public function admin_renew_single_subscription( $args ) { |
|
391 | + public function admin_renew_single_subscription($args) { |
|
392 | 392 | |
393 | 393 | // Ensure the subscription exists and that a status has been given. |
394 | - if ( empty( $args['id'] ) ) { |
|
394 | + if (empty($args['id'])) { |
|
395 | 395 | return; |
396 | 396 | } |
397 | 397 | |
398 | 398 | // Retrieve the subscriptions. |
399 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
399 | + $subscription = new WPInv_Subscription($args['id']); |
|
400 | 400 | |
401 | - if ( $subscription->get_id() ) { |
|
401 | + if ($subscription->get_id()) { |
|
402 | 402 | |
403 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
403 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
404 | 404 | |
405 | - if ( $subscription->add_payment( $args ) ) { |
|
405 | + if ($subscription->add_payment($args)) { |
|
406 | 406 | $subscription->renew(); |
407 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
407 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
408 | 408 | } else { |
409 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
409 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | wp_safe_redirect( |
@@ -7,86 +7,86 @@ 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_item_quantities_enabled() { |
15 | - $ret = wpinv_get_option( 'item_quantities', true ); |
|
15 | + $ret = wpinv_get_option('item_quantities', true); |
|
16 | 16 | |
17 | - return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret ); |
|
17 | + return (bool) apply_filters('wpinv_item_quantities_enabled', $ret); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | function wpinv_get_ip() { |
21 | 21 | $ip = '127.0.0.1'; |
22 | 22 | |
23 | - if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
24 | - $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] ); |
|
25 | - } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
26 | - $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] ); |
|
27 | - } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
28 | - $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); |
|
23 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
24 | + $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']); |
|
25 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
26 | + $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); |
|
27 | + } elseif (!empty($_SERVER['REMOTE_ADDR'])) { |
|
28 | + $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']); |
|
29 | 29 | } |
30 | 30 | |
31 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
31 | + return apply_filters('wpinv_get_ip', $ip); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | function wpinv_get_user_agent() { |
35 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
36 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
35 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
36 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
37 | 37 | } else { |
38 | 38 | $user_agent = ''; |
39 | 39 | } |
40 | 40 | |
41 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
41 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
42 | 42 | } |
43 | 43 | |
44 | -function wpinv_sanitize_amount( $amount, $decimals = NULL ) { |
|
44 | +function wpinv_sanitize_amount($amount, $decimals = NULL) { |
|
45 | 45 | $is_negative = false; |
46 | 46 | $thousands_sep = wpinv_thousands_separator(); |
47 | 47 | $decimal_sep = wpinv_decimal_separator(); |
48 | - if ( $decimals === NULL ) { |
|
48 | + if ($decimals === NULL) { |
|
49 | 49 | $decimals = wpinv_decimals(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Sanitize the amount |
53 | - if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) { |
|
54 | - if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
55 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
56 | - } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) { |
|
57 | - $amount = str_replace( '.', '', $amount ); |
|
53 | + if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) { |
|
54 | + if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) { |
|
55 | + $amount = str_replace($thousands_sep, '', $amount); |
|
56 | + } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) { |
|
57 | + $amount = str_replace('.', '', $amount); |
|
58 | 58 | } |
59 | 59 | |
60 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
61 | - } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
62 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
60 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
61 | + } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
62 | + $amount = str_replace($thousands_sep, '', $amount); |
|
63 | 63 | } |
64 | 64 | |
65 | - if( $amount < 0 ) { |
|
65 | + if ($amount < 0) { |
|
66 | 66 | $is_negative = true; |
67 | 67 | } |
68 | 68 | |
69 | - $amount = preg_replace( '/[^0-9\.]/', '', $amount ); |
|
69 | + $amount = preg_replace('/[^0-9\.]/', '', $amount); |
|
70 | 70 | |
71 | - $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount ); |
|
72 | - $amount = number_format( (double) $amount, absint( $decimals ), '.', '' ); |
|
71 | + $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount); |
|
72 | + $amount = number_format((double) $amount, absint($decimals), '.', ''); |
|
73 | 73 | |
74 | - if( $is_negative ) { |
|
74 | + if ($is_negative) { |
|
75 | 75 | $amount *= -1; |
76 | 76 | } |
77 | 77 | |
78 | - return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals ); |
|
78 | + return apply_filters('wpinv_sanitize_amount', $amount, $decimals); |
|
79 | 79 | } |
80 | -add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
80 | +add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
81 | 81 | |
82 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
83 | - if ( $decimals === NULL ) { |
|
82 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
83 | + if ($decimals === NULL) { |
|
84 | 84 | $decimals = wpinv_decimals(); |
85 | 85 | } |
86 | 86 | |
87 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
87 | + $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
88 | 88 | |
89 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
89 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,32 +95,32 @@ discard block |
||
95 | 95 | * @since 1.0.19 |
96 | 96 | * @return array |
97 | 97 | */ |
98 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
98 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
99 | 99 | $invoice_statuses = array( |
100 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
101 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
102 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
103 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
104 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
105 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
106 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
107 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
100 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
101 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
102 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
103 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
104 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
105 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
106 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
107 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
108 | 108 | ); |
109 | 109 | |
110 | - if ( $draft ) { |
|
111 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
110 | + if ($draft) { |
|
111 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
112 | 112 | } |
113 | 113 | |
114 | - if ( $trashed ) { |
|
115 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
114 | + if ($trashed) { |
|
115 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
116 | 116 | } |
117 | 117 | |
118 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
118 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
119 | 119 | } |
120 | 120 | |
121 | -function wpinv_status_nicename( $status ) { |
|
122 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
123 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
121 | +function wpinv_status_nicename($status) { |
|
122 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
123 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
124 | 124 | |
125 | 125 | return $status; |
126 | 126 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * Retrieves the default currency code. |
130 | 130 | */ |
131 | 131 | function wpinv_get_currency() { |
132 | - return apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
132 | + return apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -137,61 +137,61 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @param string|null $currency The currency code. Defaults to the default currency. |
139 | 139 | */ |
140 | -function wpinv_currency_symbol( $currency = null ) { |
|
140 | +function wpinv_currency_symbol($currency = null) { |
|
141 | 141 | |
142 | 142 | // Prepare the currency. |
143 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
143 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
144 | 144 | |
145 | 145 | // Fetch all symbols. |
146 | 146 | $symbols = wpinv_get_currency_symbols(); |
147 | 147 | |
148 | 148 | // Fetch this currencies symbol. |
149 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
149 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
150 | 150 | |
151 | 151 | // Filter the symbol. |
152 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
152 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | function wpinv_currency_position() { |
156 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
156 | + $position = wpinv_get_option('currency_position', 'left'); |
|
157 | 157 | |
158 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
158 | + return apply_filters('wpinv_currency_position', $position); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | function wpinv_thousands_separator() { |
162 | - $thousand_sep = wpinv_get_option( 'thousands_separator', ',' ); |
|
162 | + $thousand_sep = wpinv_get_option('thousands_separator', ','); |
|
163 | 163 | |
164 | - return apply_filters( 'wpinv_thousands_separator', $thousand_sep ); |
|
164 | + return apply_filters('wpinv_thousands_separator', $thousand_sep); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | function wpinv_decimal_separator() { |
168 | - $decimal_sep = wpinv_get_option( 'decimal_separator', '.' ); |
|
168 | + $decimal_sep = wpinv_get_option('decimal_separator', '.'); |
|
169 | 169 | |
170 | - return apply_filters( 'wpinv_decimal_separator', $decimal_sep ); |
|
170 | + return apply_filters('wpinv_decimal_separator', $decimal_sep); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | function wpinv_decimals() { |
174 | - $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) ); |
|
174 | + $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2)); |
|
175 | 175 | |
176 | - return absint( $decimals ); |
|
176 | + return absint($decimals); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | 180 | * Retrieves a list of all supported currencies. |
181 | 181 | */ |
182 | 182 | function wpinv_get_currencies() { |
183 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
183 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Retrieves a list of all currency symbols. |
188 | 188 | */ |
189 | 189 | function wpinv_get_currency_symbols() { |
190 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
190 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
191 | 191 | } |
192 | 192 | |
193 | -function wpinv_price( $amount = '', $currency = '' ) { |
|
194 | - if( empty( $currency ) ) { |
|
193 | +function wpinv_price($amount = '', $currency = '') { |
|
194 | + if (empty($currency)) { |
|
195 | 195 | $currency = wpinv_get_currency(); |
196 | 196 | } |
197 | 197 | |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | |
200 | 200 | $negative = $amount < 0; |
201 | 201 | |
202 | - if ( $negative ) { |
|
203 | - $amount = substr( $amount, 1 ); |
|
202 | + if ($negative) { |
|
203 | + $amount = substr($amount, 1); |
|
204 | 204 | } |
205 | 205 | |
206 | - $symbol = wpinv_currency_symbol( $currency ); |
|
206 | + $symbol = wpinv_currency_symbol($currency); |
|
207 | 207 | |
208 | - if ( $position == 'left' || $position == 'left_space' ) { |
|
209 | - switch ( $currency ) { |
|
208 | + if ($position == 'left' || $position == 'left_space') { |
|
209 | + switch ($currency) { |
|
210 | 210 | case "GBP" : |
211 | 211 | case "BRL" : |
212 | 212 | case "EUR" : |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | case "NZD" : |
219 | 219 | case "SGD" : |
220 | 220 | case "JPY" : |
221 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
221 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
222 | 222 | break; |
223 | 223 | default : |
224 | 224 | //$price = $currency . ' ' . $amount; |
225 | - $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
225 | + $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount; |
|
226 | 226 | break; |
227 | 227 | } |
228 | 228 | } else { |
229 | - switch ( $currency ) { |
|
229 | + switch ($currency) { |
|
230 | 230 | case "GBP" : |
231 | 231 | case "BRL" : |
232 | 232 | case "EUR" : |
@@ -237,83 +237,83 @@ discard block |
||
237 | 237 | case "MXN" : |
238 | 238 | case "SGD" : |
239 | 239 | case "JPY" : |
240 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
240 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
241 | 241 | break; |
242 | 242 | default : |
243 | 243 | //$price = $amount . ' ' . $currency; |
244 | - $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
244 | + $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol; |
|
245 | 245 | break; |
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | - if ( $negative ) { |
|
249 | + if ($negative) { |
|
250 | 250 | $price = '-' . $price; |
251 | 251 | } |
252 | 252 | |
253 | - $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount ); |
|
253 | + $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount); |
|
254 | 254 | |
255 | 255 | return $price; |
256 | 256 | } |
257 | 257 | |
258 | -function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) { |
|
258 | +function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) { |
|
259 | 259 | $thousands_sep = wpinv_thousands_separator(); |
260 | 260 | $decimal_sep = wpinv_decimal_separator(); |
261 | 261 | |
262 | - if ( $decimals === NULL ) { |
|
262 | + if ($decimals === NULL) { |
|
263 | 263 | $decimals = wpinv_decimals(); |
264 | 264 | } |
265 | 265 | |
266 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
267 | - $whole = substr( $amount, 0, $sep_found ); |
|
268 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
266 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
267 | + $whole = substr($amount, 0, $sep_found); |
|
268 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
269 | 269 | $amount = $whole . '.' . $part; |
270 | 270 | } |
271 | 271 | |
272 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
273 | - $amount = str_replace( ',', '', $amount ); |
|
272 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
273 | + $amount = str_replace(',', '', $amount); |
|
274 | 274 | } |
275 | 275 | |
276 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
277 | - $amount = str_replace( ' ', '', $amount ); |
|
276 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
277 | + $amount = str_replace(' ', '', $amount); |
|
278 | 278 | } |
279 | 279 | |
280 | - if ( empty( $amount ) ) { |
|
280 | + if (empty($amount)) { |
|
281 | 281 | $amount = 0; |
282 | 282 | } |
283 | 283 | |
284 | - $decimals = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate ); |
|
285 | - $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep ); |
|
284 | + $decimals = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate); |
|
285 | + $formatted = number_format((float) $amount, $decimals, $decimal_sep, $thousands_sep); |
|
286 | 286 | |
287 | - if ( $calculate ) { |
|
288 | - if ( $thousands_sep === "," ) { |
|
289 | - $formatted = str_replace( ",", "", $formatted ); |
|
287 | + if ($calculate) { |
|
288 | + if ($thousands_sep === ",") { |
|
289 | + $formatted = str_replace(",", "", $formatted); |
|
290 | 290 | } |
291 | 291 | |
292 | - if ( $decimal_sep === "," ) { |
|
293 | - $formatted = str_replace( ",", ".", $formatted ); |
|
292 | + if ($decimal_sep === ",") { |
|
293 | + $formatted = str_replace(",", ".", $formatted); |
|
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
297 | - return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate ); |
|
297 | + return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate); |
|
298 | 298 | } |
299 | -add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 ); |
|
299 | +add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1); |
|
300 | 300 | |
301 | -function wpinv_sanitize_key( $key ) { |
|
301 | +function wpinv_sanitize_key($key) { |
|
302 | 302 | $raw_key = $key; |
303 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
303 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
304 | 304 | |
305 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
305 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
306 | 306 | } |
307 | 307 | |
308 | -function wpinv_get_file_extension( $str ) { |
|
309 | - $parts = explode( '.', $str ); |
|
310 | - return end( $parts ); |
|
308 | +function wpinv_get_file_extension($str) { |
|
309 | + $parts = explode('.', $str); |
|
310 | + return end($parts); |
|
311 | 311 | } |
312 | 312 | |
313 | -function wpinv_string_is_image_url( $str ) { |
|
314 | - $ext = wpinv_get_file_extension( $str ); |
|
313 | +function wpinv_string_is_image_url($str) { |
|
314 | + $ext = wpinv_get_file_extension($str); |
|
315 | 315 | |
316 | - switch ( strtolower( $ext ) ) { |
|
316 | + switch (strtolower($ext)) { |
|
317 | 317 | case 'jpeg'; |
318 | 318 | case 'jpg'; |
319 | 319 | $return = true; |
@@ -329,33 +329,33 @@ discard block |
||
329 | 329 | break; |
330 | 330 | } |
331 | 331 | |
332 | - return (bool)apply_filters( 'wpinv_string_is_image', $return, $str ); |
|
332 | + return (bool) apply_filters('wpinv_string_is_image', $return, $str); |
|
333 | 333 | } |
334 | 334 | |
335 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
336 | - $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG ); |
|
335 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
336 | + $should_log = apply_filters('wpinv_log_errors', WP_DEBUG); |
|
337 | 337 | |
338 | - if ( true === $should_log ) { |
|
338 | + if (true === $should_log) { |
|
339 | 339 | $label = ''; |
340 | - if ( $file && $file !== '' ) { |
|
341 | - $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' ); |
|
340 | + if ($file && $file !== '') { |
|
341 | + $label .= basename($file) . ($line ? '(' . $line . ')' : ''); |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( $title && $title !== '' ) { |
|
344 | + if ($title && $title !== '') { |
|
345 | 345 | $label = $label !== '' ? $label . ' ' : ''; |
346 | 346 | $label .= $title . ' '; |
347 | 347 | } |
348 | 348 | |
349 | - $label = $label !== '' ? trim( $label ) . ' : ' : ''; |
|
349 | + $label = $label !== '' ? trim($label) . ' : ' : ''; |
|
350 | 350 | |
351 | - if ( is_array( $log ) || is_object( $log ) ) { |
|
352 | - error_log( $label . print_r( $log, true ) ); |
|
351 | + if (is_array($log) || is_object($log)) { |
|
352 | + error_log($label . print_r($log, true)); |
|
353 | 353 | } else { |
354 | - error_log( $label . $log ); |
|
354 | + error_log($label . $log); |
|
355 | 355 | } |
356 | 356 | |
357 | - error_log( wp_debug_backtrace_summary() ); |
|
358 | - if ( $exit ) { |
|
357 | + error_log(wp_debug_backtrace_summary()); |
|
358 | + if ($exit) { |
|
359 | 359 | exit; |
360 | 360 | } |
361 | 361 | } |
@@ -363,32 +363,32 @@ discard block |
||
363 | 363 | |
364 | 364 | function wpinv_is_ajax_disabled() { |
365 | 365 | $retval = false; |
366 | - return apply_filters( 'wpinv_is_ajax_disabled', $retval ); |
|
366 | + return apply_filters('wpinv_is_ajax_disabled', $retval); |
|
367 | 367 | } |
368 | 368 | |
369 | -function wpinv_get_current_page_url( $nocache = false ) { |
|
369 | +function wpinv_get_current_page_url($nocache = false) { |
|
370 | 370 | global $wp; |
371 | 371 | |
372 | - if ( get_option( 'permalink_structure' ) ) { |
|
373 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
372 | + if (get_option('permalink_structure')) { |
|
373 | + $base = trailingslashit(home_url($wp->request)); |
|
374 | 374 | } else { |
375 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
376 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
375 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
376 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | $scheme = is_ssl() ? 'https' : 'http'; |
380 | - $uri = set_url_scheme( $base, $scheme ); |
|
380 | + $uri = set_url_scheme($base, $scheme); |
|
381 | 381 | |
382 | - if ( is_front_page() ) { |
|
383 | - $uri = home_url( '/' ); |
|
384 | - } elseif ( wpinv_is_checkout( array(), false ) ) { |
|
382 | + if (is_front_page()) { |
|
383 | + $uri = home_url('/'); |
|
384 | + } elseif (wpinv_is_checkout(array(), false)) { |
|
385 | 385 | $uri = wpinv_get_checkout_uri(); |
386 | 386 | } |
387 | 387 | |
388 | - $uri = apply_filters( 'wpinv_get_current_page_url', $uri ); |
|
388 | + $uri = apply_filters('wpinv_get_current_page_url', $uri); |
|
389 | 389 | |
390 | - if ( $nocache ) { |
|
391 | - $uri = wpinv_add_cache_busting( $uri ); |
|
390 | + if ($nocache) { |
|
391 | + $uri = wpinv_add_cache_busting($uri); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | return $uri; |
@@ -401,46 +401,46 @@ discard block |
||
401 | 401 | * @param string $name Constant name. |
402 | 402 | * @param mixed $value Value. |
403 | 403 | */ |
404 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
405 | - if ( ! defined( $name ) ) { |
|
406 | - define( $name, $value ); |
|
404 | +function getpaid_maybe_define_constant($name, $value) { |
|
405 | + if (!defined($name)) { |
|
406 | + define($name, $value); |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | |
410 | 410 | function wpinv_get_php_arg_separator_output() { |
411 | - return ini_get( 'arg_separator.output' ); |
|
411 | + return ini_get('arg_separator.output'); |
|
412 | 412 | } |
413 | 413 | |
414 | -function wpinv_rgb_from_hex( $color ) { |
|
415 | - $color = str_replace( '#', '', $color ); |
|
414 | +function wpinv_rgb_from_hex($color) { |
|
415 | + $color = str_replace('#', '', $color); |
|
416 | 416 | |
417 | 417 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
418 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
419 | - if ( empty( $color ) ) { |
|
418 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
419 | + if (empty($color)) { |
|
420 | 420 | return NULL; |
421 | 421 | } |
422 | 422 | |
423 | - $color = str_split( $color ); |
|
423 | + $color = str_split($color); |
|
424 | 424 | |
425 | 425 | $rgb = array(); |
426 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
427 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
428 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
426 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
427 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
428 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
429 | 429 | |
430 | 430 | return $rgb; |
431 | 431 | } |
432 | 432 | |
433 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
434 | - $base = wpinv_rgb_from_hex( $color ); |
|
433 | +function wpinv_hex_darker($color, $factor = 30) { |
|
434 | + $base = wpinv_rgb_from_hex($color); |
|
435 | 435 | $color = '#'; |
436 | 436 | |
437 | - foreach ( $base as $k => $v ) { |
|
437 | + foreach ($base as $k => $v) { |
|
438 | 438 | $amount = $v / 100; |
439 | - $amount = round( $amount * $factor ); |
|
439 | + $amount = round($amount * $factor); |
|
440 | 440 | $new_decimal = $v - $amount; |
441 | 441 | |
442 | - $new_hex_component = dechex( $new_decimal ); |
|
443 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
442 | + $new_hex_component = dechex($new_decimal); |
|
443 | + if (strlen($new_hex_component) < 2) { |
|
444 | 444 | $new_hex_component = "0" . $new_hex_component; |
445 | 445 | } |
446 | 446 | $color .= $new_hex_component; |
@@ -449,18 +449,18 @@ discard block |
||
449 | 449 | return $color; |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
453 | - $base = wpinv_rgb_from_hex( $color ); |
|
452 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
453 | + $base = wpinv_rgb_from_hex($color); |
|
454 | 454 | $color = '#'; |
455 | 455 | |
456 | - foreach ( $base as $k => $v ) { |
|
456 | + foreach ($base as $k => $v) { |
|
457 | 457 | $amount = 255 - $v; |
458 | 458 | $amount = $amount / 100; |
459 | - $amount = round( $amount * $factor ); |
|
459 | + $amount = round($amount * $factor); |
|
460 | 460 | $new_decimal = $v + $amount; |
461 | 461 | |
462 | - $new_hex_component = dechex( $new_decimal ); |
|
463 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
462 | + $new_hex_component = dechex($new_decimal); |
|
463 | + if (strlen($new_hex_component) < 2) { |
|
464 | 464 | $new_hex_component = "0" . $new_hex_component; |
465 | 465 | } |
466 | 466 | $color .= $new_hex_component; |
@@ -469,22 +469,22 @@ discard block |
||
469 | 469 | return $color; |
470 | 470 | } |
471 | 471 | |
472 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
473 | - $hex = str_replace( '#', '', $color ); |
|
472 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
473 | + $hex = str_replace('#', '', $color); |
|
474 | 474 | |
475 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
476 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
477 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
475 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
476 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
477 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
478 | 478 | |
479 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
479 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
480 | 480 | |
481 | 481 | return $brightness > 155 ? $dark : $light; |
482 | 482 | } |
483 | 483 | |
484 | -function wpinv_format_hex( $hex ) { |
|
485 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
484 | +function wpinv_format_hex($hex) { |
|
485 | + $hex = trim(str_replace('#', '', $hex)); |
|
486 | 486 | |
487 | - if ( strlen( $hex ) == 3 ) { |
|
487 | + if (strlen($hex) == 3) { |
|
488 | 488 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
489 | 489 | } |
490 | 490 | |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
505 | 505 | * @return string |
506 | 506 | */ |
507 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
508 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
509 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
507 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
508 | + if (function_exists('mb_strimwidth')) { |
|
509 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
510 | 510 | } |
511 | 511 | |
512 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
512 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
@@ -521,28 +521,28 @@ discard block |
||
521 | 521 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
522 | 522 | * @return int Returns the number of characters in string. |
523 | 523 | */ |
524 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
525 | - if ( function_exists( 'mb_strlen' ) ) { |
|
526 | - return mb_strlen( $str, $encoding ); |
|
524 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
525 | + if (function_exists('mb_strlen')) { |
|
526 | + return mb_strlen($str, $encoding); |
|
527 | 527 | } |
528 | 528 | |
529 | - return strlen( $str ); |
|
529 | + return strlen($str); |
|
530 | 530 | } |
531 | 531 | |
532 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
533 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
534 | - return mb_strtolower( $str, $encoding ); |
|
532 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
533 | + if (function_exists('mb_strtolower')) { |
|
534 | + return mb_strtolower($str, $encoding); |
|
535 | 535 | } |
536 | 536 | |
537 | - return strtolower( $str ); |
|
537 | + return strtolower($str); |
|
538 | 538 | } |
539 | 539 | |
540 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
541 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
542 | - return mb_strtoupper( $str, $encoding ); |
|
540 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
541 | + if (function_exists('mb_strtoupper')) { |
|
542 | + return mb_strtoupper($str, $encoding); |
|
543 | 543 | } |
544 | 544 | |
545 | - return strtoupper( $str ); |
|
545 | + return strtoupper($str); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
557 | 557 | * @return int Returns the position of the first occurrence of search in the string. |
558 | 558 | */ |
559 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
560 | - if ( function_exists( 'mb_strpos' ) ) { |
|
561 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
559 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
560 | + if (function_exists('mb_strpos')) { |
|
561 | + return mb_strpos($str, $find, $offset, $encoding); |
|
562 | 562 | } |
563 | 563 | |
564 | - return strpos( $str, $find, $offset ); |
|
564 | + return strpos($str, $find, $offset); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -575,12 +575,12 @@ discard block |
||
575 | 575 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
576 | 576 | * @return int Returns the position of the last occurrence of search. |
577 | 577 | */ |
578 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
579 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
580 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
578 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
579 | + if (function_exists('mb_strrpos')) { |
|
580 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
581 | 581 | } |
582 | 582 | |
583 | - return strrpos( $str, $find, $offset ); |
|
583 | + return strrpos($str, $find, $offset); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
@@ -595,16 +595,16 @@ discard block |
||
595 | 595 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
596 | 596 | * @return string |
597 | 597 | */ |
598 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
599 | - if ( function_exists( 'mb_substr' ) ) { |
|
600 | - if ( $length === null ) { |
|
601 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
598 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
599 | + if (function_exists('mb_substr')) { |
|
600 | + if ($length === null) { |
|
601 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
602 | 602 | } else { |
603 | - return mb_substr( $str, $start, $length, $encoding ); |
|
603 | + return mb_substr($str, $start, $length, $encoding); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
607 | - return substr( $str, $start, $length ); |
|
607 | + return substr($str, $start, $length); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -616,48 +616,48 @@ discard block |
||
616 | 616 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
617 | 617 | * @return string The width of string. |
618 | 618 | */ |
619 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
620 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
621 | - return mb_strwidth( $str, $encoding ); |
|
619 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
620 | + if (function_exists('mb_strwidth')) { |
|
621 | + return mb_strwidth($str, $encoding); |
|
622 | 622 | } |
623 | 623 | |
624 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
624 | + return wpinv_utf8_strlen($str, $encoding); |
|
625 | 625 | } |
626 | 626 | |
627 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
628 | - if ( function_exists( 'mb_strlen' ) ) { |
|
629 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
627 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
628 | + if (function_exists('mb_strlen')) { |
|
629 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
630 | 630 | $str_end = ""; |
631 | 631 | |
632 | - if ( $lower_str_end ) { |
|
633 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
632 | + if ($lower_str_end) { |
|
633 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
634 | 634 | } else { |
635 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
635 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | return $first_letter . $str_end; |
639 | 639 | } |
640 | 640 | |
641 | - return ucfirst( $str ); |
|
641 | + return ucfirst($str); |
|
642 | 642 | } |
643 | 643 | |
644 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
645 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
646 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
644 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
645 | + if (function_exists('mb_convert_case')) { |
|
646 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
647 | 647 | } |
648 | 648 | |
649 | - return ucwords( $str ); |
|
649 | + return ucwords($str); |
|
650 | 650 | } |
651 | 651 | |
652 | -function wpinv_period_in_days( $period, $unit ) { |
|
653 | - $period = absint( $period ); |
|
652 | +function wpinv_period_in_days($period, $unit) { |
|
653 | + $period = absint($period); |
|
654 | 654 | |
655 | - if ( $period > 0 ) { |
|
656 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
655 | + if ($period > 0) { |
|
656 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
657 | 657 | $period = $period * 7; |
658 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
658 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
659 | 659 | $period = $period * 30; |
660 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
660 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
661 | 661 | $period = $period * 365; |
662 | 662 | } |
663 | 663 | } |
@@ -665,14 +665,14 @@ discard block |
||
665 | 665 | return $period; |
666 | 666 | } |
667 | 667 | |
668 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
669 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
670 | - return cal_days_in_month( $calendar, $month, $year ); |
|
668 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
669 | + if (function_exists('cal_days_in_month')) { |
|
670 | + return cal_days_in_month($calendar, $month, $year); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | // Fallback in case the calendar extension is not loaded in PHP |
674 | 674 | // Only supports Gregorian calendar |
675 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
675 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | /** |
@@ -683,11 +683,11 @@ discard block |
||
683 | 683 | * |
684 | 684 | * @return string |
685 | 685 | */ |
686 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
687 | - if ( $allow_html ) { |
|
688 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
686 | +function wpi_help_tip($tip, $allow_html = false) { |
|
687 | + if ($allow_html) { |
|
688 | + $tip = wpi_sanitize_tooltip($tip); |
|
689 | 689 | } else { |
690 | - $tip = esc_attr( $tip ); |
|
690 | + $tip = esc_attr($tip); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | * @param string $var |
702 | 702 | * @return string |
703 | 703 | */ |
704 | -function wpi_sanitize_tooltip( $var ) { |
|
705 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
704 | +function wpi_sanitize_tooltip($var) { |
|
705 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
706 | 706 | 'br' => array(), |
707 | 707 | 'em' => array(), |
708 | 708 | 'strong' => array(), |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | 'li' => array(), |
713 | 713 | 'ol' => array(), |
714 | 714 | 'p' => array(), |
715 | - ) ) ); |
|
715 | + ))); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /** |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | */ |
723 | 723 | function wpinv_get_screen_ids() { |
724 | 724 | |
725 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
725 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
726 | 726 | |
727 | 727 | $screen_ids = array( |
728 | 728 | 'toplevel_page_' . $screen_id, |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | 'invoicing_page_wpi-addons', |
741 | 741 | ); |
742 | 742 | |
743 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
743 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
@@ -751,14 +751,14 @@ discard block |
||
751 | 751 | * @param array|string $list List of values. |
752 | 752 | * @return array Sanitized array of values. |
753 | 753 | */ |
754 | -function wpinv_parse_list( $list ) { |
|
754 | +function wpinv_parse_list($list) { |
|
755 | 755 | |
756 | - if ( empty( $list ) ) { |
|
756 | + if (empty($list)) { |
|
757 | 757 | $list = array(); |
758 | 758 | } |
759 | 759 | |
760 | - if ( ! is_array( $list ) ) { |
|
761 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
760 | + if (!is_array($list)) { |
|
761 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | return $list; |
@@ -772,16 +772,16 @@ discard block |
||
772 | 772 | * @param string $key Type of data to fetch. |
773 | 773 | * @return mixed Fetched data. |
774 | 774 | */ |
775 | -function wpinv_get_data( $key ) { |
|
775 | +function wpinv_get_data($key) { |
|
776 | 776 | |
777 | 777 | // Try fetching it from the cache. |
778 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
779 | - if( $data ) { |
|
778 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
779 | + if ($data) { |
|
780 | 780 | return $data; |
781 | 781 | } |
782 | 782 | |
783 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
784 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
783 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
784 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
785 | 785 | |
786 | 786 | return $data; |
787 | 787 | } |
@@ -795,10 +795,10 @@ discard block |
||
795 | 795 | * @param bool $first_empty Whether or not the first item in the list should be empty |
796 | 796 | * @return mixed Fetched data. |
797 | 797 | */ |
798 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
798 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
799 | 799 | |
800 | - if ( ! empty( $options ) && $first_empty ) { |
|
801 | - return array_merge( array( '' => '' ), $options ); |
|
800 | + if (!empty($options) && $first_empty) { |
|
801 | + return array_merge(array('' => ''), $options); |
|
802 | 802 | } |
803 | 803 | return $options; |
804 | 804 | |
@@ -810,21 +810,21 @@ discard block |
||
810 | 810 | * @param mixed $var Data to sanitize. |
811 | 811 | * @return string|array |
812 | 812 | */ |
813 | -function wpinv_clean( $var ) { |
|
813 | +function wpinv_clean($var) { |
|
814 | 814 | |
815 | - if ( is_array( $var ) ) { |
|
816 | - return array_map( 'wpinv_clean', $var ); |
|
815 | + if (is_array($var)) { |
|
816 | + return array_map('wpinv_clean', $var); |
|
817 | 817 | } |
818 | 818 | |
819 | - if ( is_object( $var ) ) { |
|
820 | - $object_vars = get_object_vars( $var ); |
|
821 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
822 | - $var->$property_name = wpinv_clean( $property_value ); |
|
819 | + if (is_object($var)) { |
|
820 | + $object_vars = get_object_vars($var); |
|
821 | + foreach ($object_vars as $property_name => $property_value) { |
|
822 | + $var->$property_name = wpinv_clean($property_value); |
|
823 | 823 | } |
824 | 824 | return $var; |
825 | 825 | } |
826 | 826 | |
827 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
827 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | /** |
@@ -833,43 +833,43 @@ discard block |
||
833 | 833 | * @param string $str Data to convert. |
834 | 834 | * @return string|array |
835 | 835 | */ |
836 | -function getpaid_convert_price_string_to_options( $str ) { |
|
836 | +function getpaid_convert_price_string_to_options($str) { |
|
837 | 837 | |
838 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
839 | - $options = array(); |
|
838 | + $raw_options = array_map('trim', explode(',', $str)); |
|
839 | + $options = array(); |
|
840 | 840 | |
841 | - foreach ( $raw_options as $option ) { |
|
841 | + foreach ($raw_options as $option) { |
|
842 | 842 | |
843 | - if ( '' == $option ) { |
|
843 | + if ('' == $option) { |
|
844 | 844 | continue; |
845 | 845 | } |
846 | 846 | |
847 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
847 | + $option = array_map('trim', explode('|', $option)); |
|
848 | 848 | |
849 | 849 | $price = null; |
850 | 850 | $label = null; |
851 | 851 | |
852 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
853 | - $label = $option[0]; |
|
852 | + if (isset($option[0]) && '' != $option[0]) { |
|
853 | + $label = $option[0]; |
|
854 | 854 | } |
855 | 855 | |
856 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
856 | + if (isset($option[1]) && '' != $option[1]) { |
|
857 | 857 | $price = $option[1]; |
858 | 858 | } |
859 | 859 | |
860 | - if ( ! isset( $price ) ) { |
|
860 | + if (!isset($price)) { |
|
861 | 861 | $price = $label; |
862 | 862 | } |
863 | 863 | |
864 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
864 | + if (!isset($price) || !is_numeric($price)) { |
|
865 | 865 | continue; |
866 | 866 | } |
867 | 867 | |
868 | - if ( ! isset( $label ) ) { |
|
868 | + if (!isset($label)) { |
|
869 | 869 | $label = $price; |
870 | 870 | } |
871 | 871 | |
872 | - $options[ $price ] = $label; |
|
872 | + $options[$price] = $label; |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | return $options; |
@@ -878,23 +878,23 @@ discard block |
||
878 | 878 | /** |
879 | 879 | * Returns the help tip. |
880 | 880 | */ |
881 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
882 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
883 | - $tip = esc_attr__( $tip ); |
|
881 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
882 | + $additional_classes = sanitize_html_class($additional_classes); |
|
883 | + $tip = esc_attr__($tip); |
|
884 | 884 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
885 | 885 | } |
886 | 886 | |
887 | 887 | /** |
888 | 888 | * Formats a date |
889 | 889 | */ |
890 | -function getpaid_format_date( $date ) { |
|
890 | +function getpaid_format_date($date) { |
|
891 | 891 | |
892 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
892 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
893 | 893 | return ''; |
894 | 894 | } |
895 | 895 | |
896 | 896 | |
897 | - return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $date ) ); |
|
897 | + return date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($date)); |
|
898 | 898 | |
899 | 899 | } |
900 | 900 | |
@@ -905,16 +905,16 @@ discard block |
||
905 | 905 | * @param integer $limit Limit size in characters. |
906 | 906 | * @return string |
907 | 907 | */ |
908 | -function getpaid_limit_length( $string, $limit ) { |
|
908 | +function getpaid_limit_length($string, $limit) { |
|
909 | 909 | $str_limit = $limit - 3; |
910 | 910 | |
911 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
912 | - if ( mb_strlen( $string ) > $limit ) { |
|
913 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
911 | + if (function_exists('mb_strimwidth')) { |
|
912 | + if (mb_strlen($string) > $limit) { |
|
913 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
914 | 914 | } |
915 | 915 | } else { |
916 | - if ( strlen( $string ) > $limit ) { |
|
917 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
916 | + if (strlen($string) > $limit) { |
|
917 | + $string = substr($string, 0, $str_limit) . '...'; |
|
918 | 918 | } |
919 | 919 | } |
920 | 920 | return $string; |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * @since 1.0.19 |
929 | 929 | */ |
930 | 930 | function getpaid_api() { |
931 | - return getpaid()->get( 'api' ); |
|
931 | + return getpaid()->get('api'); |
|
932 | 932 | } |
933 | 933 | |
934 | 934 | /** |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | * @since 1.0.19 |
939 | 939 | */ |
940 | 940 | function getpaid_post_types() { |
941 | - return getpaid()->get( 'post_types' ); |
|
941 | + return getpaid()->get('post_types'); |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | /** |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | * @since 1.0.19 |
949 | 949 | */ |
950 | 950 | function getpaid_session() { |
951 | - return getpaid()->get( 'session' ); |
|
951 | + return getpaid()->get('session'); |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | /** |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | * @since 1.0.19 |
959 | 959 | */ |
960 | 960 | function getpaid_notes() { |
961 | - return getpaid()->get( 'notes' ); |
|
961 | + return getpaid()->get('notes'); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -970,28 +970,28 @@ discard block |
||
970 | 970 | * |
971 | 971 | * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query |
972 | 972 | */ |
973 | -function getpaid_get_subscriptions( $args = array(), $return = 'results' ) { |
|
973 | +function getpaid_get_subscriptions($args = array(), $return = 'results') { |
|
974 | 974 | |
975 | - $args = wp_parse_args( $args, array() ); |
|
975 | + $args = wp_parse_args($args, array()); |
|
976 | 976 | |
977 | 977 | // Do not retrieve all fields if we just want the count. |
978 | - if ( 'count' == $return ) { |
|
978 | + if ('count' == $return) { |
|
979 | 979 | $args['fields'] = 'id'; |
980 | 980 | $args['number'] = 1; |
981 | 981 | } |
982 | 982 | |
983 | 983 | // Do not count all matches if we just want the results. |
984 | - if ( 'results' == $return ) { |
|
984 | + if ('results' == $return) { |
|
985 | 985 | $args['count_total'] = false; |
986 | 986 | } |
987 | 987 | |
988 | - $query = new GetPaid_Subscriptions_Query( $args ); |
|
988 | + $query = new GetPaid_Subscriptions_Query($args); |
|
989 | 989 | |
990 | - if ( 'results' == $return ) { |
|
990 | + if ('results' == $return) { |
|
991 | 991 | return $query->get_results(); |
992 | 992 | } |
993 | 993 | |
994 | - if ( 'count' == $return ) { |
|
994 | + if ('count' == $return) { |
|
995 | 995 | return $query->get_total(); |
996 | 996 | } |
997 | 997 | |
@@ -1008,13 +1008,13 @@ discard block |
||
1008 | 1008 | return apply_filters( |
1009 | 1009 | 'getpaid_get_subscription_statuses', |
1010 | 1010 | array( |
1011 | - 'pending' => __( 'Pending', 'invoicing' ), |
|
1012 | - 'trialling' => __( 'Trialing', 'invoicing' ), |
|
1013 | - 'active' => __( 'Active', 'invoicing' ), |
|
1014 | - 'failing' => __( 'Failing', 'invoicing' ), |
|
1015 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
1016 | - 'completed' => __( 'Complete', 'invoicing' ), |
|
1017 | - 'cancelled' =>__( 'Cancelled', 'invoicing' ), |
|
1011 | + 'pending' => __('Pending', 'invoicing'), |
|
1012 | + 'trialling' => __('Trialing', 'invoicing'), |
|
1013 | + 'active' => __('Active', 'invoicing'), |
|
1014 | + 'failing' => __('Failing', 'invoicing'), |
|
1015 | + 'expired' => __('Expired', 'invoicing'), |
|
1016 | + 'completed' => __('Complete', 'invoicing'), |
|
1017 | + 'cancelled' =>__('Cancelled', 'invoicing'), |
|
1018 | 1018 | ) |
1019 | 1019 | ); |
1020 | 1020 | |
@@ -1025,9 +1025,9 @@ discard block |
||
1025 | 1025 | * |
1026 | 1026 | * @return string |
1027 | 1027 | */ |
1028 | -function getpaid_get_subscription_status_label( $status ) { |
|
1028 | +function getpaid_get_subscription_status_label($status) { |
|
1029 | 1029 | $statuses = getpaid_get_subscription_statuses(); |
1030 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( $status ); |
|
1030 | + return isset($statuses[$status]) ? $statuses[$status] : ucfirst($status); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | /** |
@@ -1057,14 +1057,14 @@ discard block |
||
1057 | 1057 | * |
1058 | 1058 | * @return array |
1059 | 1059 | */ |
1060 | -function getpaid_get_subscription_status_counts( $args = array() ) { |
|
1060 | +function getpaid_get_subscription_status_counts($args = array()) { |
|
1061 | 1061 | |
1062 | - $statuses = array_keys( getpaid_get_subscription_statuses() ); |
|
1062 | + $statuses = array_keys(getpaid_get_subscription_statuses()); |
|
1063 | 1063 | $counts = array(); |
1064 | 1064 | |
1065 | - foreach ( $statuses as $status ) { |
|
1066 | - $_args = wp_parse_args( "status=$status", $args ); |
|
1067 | - $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' ); |
|
1065 | + foreach ($statuses as $status) { |
|
1066 | + $_args = wp_parse_args("status=$status", $args); |
|
1067 | + $counts[$status] = getpaid_get_subscriptions($_args, 'count'); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | return $counts; |
@@ -1076,20 +1076,20 @@ discard block |
||
1076 | 1076 | * |
1077 | 1077 | * @return string |
1078 | 1078 | */ |
1079 | -function getpaid_get_subscription_period_label( $period ) { |
|
1079 | +function getpaid_get_subscription_period_label($period) { |
|
1080 | 1080 | |
1081 | 1081 | $periods = array( |
1082 | - 'd' => __( 'day', 'invoicing' ), |
|
1083 | - 'day' => __( 'day', 'invoicing' ), |
|
1084 | - 'w' => __( 'week', 'invoicing' ), |
|
1085 | - 'week' => __( 'week', 'invoicing' ), |
|
1086 | - 'm' => __( 'month', 'invoicing' ), |
|
1087 | - 'month' => __( 'month', 'invoicing' ), |
|
1088 | - 'y' => __( 'year', 'invoicing' ), |
|
1089 | - 'year' => __( 'year', 'invoicing' ), |
|
1082 | + 'd' => __('day', 'invoicing'), |
|
1083 | + 'day' => __('day', 'invoicing'), |
|
1084 | + 'w' => __('week', 'invoicing'), |
|
1085 | + 'week' => __('week', 'invoicing'), |
|
1086 | + 'm' => __('month', 'invoicing'), |
|
1087 | + 'month' => __('month', 'invoicing'), |
|
1088 | + 'y' => __('year', 'invoicing'), |
|
1089 | + 'year' => __('year', 'invoicing'), |
|
1090 | 1090 | ); |
1091 | 1091 | |
1092 | - return isset( $periods[ $period ] ) ? strtolower( $periods[ $period ] ) : strtolower( $periods['d'] ); |
|
1092 | + return isset($periods[$period]) ? strtolower($periods[$period]) : strtolower($periods['d']); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | /** |
@@ -1098,5 +1098,5 @@ discard block |
||
1098 | 1098 | * @return GetPaid_Admin |
1099 | 1099 | */ |
1100 | 1100 | function getpaid_admin() { |
1101 | - return getpaid()->get( 'admin' ); |
|
1101 | + return getpaid()->get('admin'); |
|
1102 | 1102 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Abstaract Payment Gateway class. |
@@ -137,50 +137,50 @@ discard block |
||
137 | 137 | * Class constructor. |
138 | 138 | */ |
139 | 139 | public function __construct() { |
140 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
140 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
141 | 141 | |
142 | 142 | // Register gateway. |
143 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
144 | 144 | |
145 | 145 | // Enable Subscriptions. |
146 | - if ( $this->supports( 'subscription' ) ) { |
|
147 | - add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' ); |
|
146 | + if ($this->supports('subscription')) { |
|
147 | + add_filter("wpinv_{$this->id}_support_subscription", '__return_true'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // Enable sandbox. |
151 | - if ( $this->supports( 'sandbox' ) ) { |
|
152 | - add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' ); |
|
151 | + if ($this->supports('sandbox')) { |
|
152 | + add_filter("wpinv_{$this->id}_supports_sandbox", '__return_true'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | // Gateway settings. |
156 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
156 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | // Gateway checkout fiellds. |
160 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
160 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
161 | 161 | |
162 | 162 | // Process payment. |
163 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
163 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
164 | 164 | |
165 | 165 | // Change the checkout button text. |
166 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
167 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
166 | + if (!empty($this->checkout_button_text)) { |
|
167 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // Check if a gateway is valid for a given currency. |
171 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
171 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
172 | 172 | |
173 | 173 | // Generate the transaction url. |
174 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
174 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
175 | 175 | |
176 | 176 | // Generate the subscription url. |
177 | - add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 ); |
|
177 | + add_filter("getpaid_gateway_{$this->id}_subscription_url", array($this, 'filter_subscription_url'), 10, 2); |
|
178 | 178 | |
179 | 179 | // Confirm payments. |
180 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
180 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
181 | 181 | |
182 | 182 | // Verify IPNs. |
183 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
183 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
184 | 184 | |
185 | 185 | } |
186 | 186 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @since 1.0.19 |
191 | 191 | * @return bool |
192 | 192 | */ |
193 | - public function is( $gateway ) { |
|
193 | + public function is($gateway) { |
|
194 | 194 | return $gateway == $this->id; |
195 | 195 | } |
196 | 196 | |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | * @since 1.0.19 |
201 | 201 | * @return array |
202 | 202 | */ |
203 | - public function get_tokens( $sandbox = null ) { |
|
203 | + public function get_tokens($sandbox = null) { |
|
204 | 204 | |
205 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
206 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
205 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
206 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
207 | 207 | |
208 | - if ( is_array( $tokens ) ) { |
|
208 | + if (is_array($tokens)) { |
|
209 | 209 | $this->tokens = $tokens; |
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
213 | 213 | |
214 | - if ( ! is_bool( $sandbox ) ) { |
|
214 | + if (!is_bool($sandbox)) { |
|
215 | 215 | return $this->tokens; |
216 | 216 | } |
217 | 217 | |
218 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
219 | - return wp_list_filter( $this->tokens, $args ); |
|
218 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
219 | + return wp_list_filter($this->tokens, $args); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @since 1.0.19 |
227 | 227 | */ |
228 | - public function save_token( $token ) { |
|
228 | + public function save_token($token) { |
|
229 | 229 | |
230 | 230 | $tokens = $this->get_tokens(); |
231 | 231 | $tokens[] = $token; |
232 | 232 | |
233 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
233 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
234 | 234 | |
235 | 235 | $this->tokens = $tokens; |
236 | 236 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return string |
243 | 243 | */ |
244 | 244 | public function get_method_title() { |
245 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
245 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return string |
252 | 252 | */ |
253 | 253 | public function get_method_description() { |
254 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
254 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param WPInv_Invoice $invoice Invoice object. |
261 | 261 | * @return string |
262 | 262 | */ |
263 | - public function get_return_url( $invoice ) { |
|
263 | + public function get_return_url($invoice) { |
|
264 | 264 | |
265 | 265 | // Payment success url |
266 | 266 | $return_url = add_query_arg( |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | wpinv_get_success_page_uri() |
273 | 273 | ); |
274 | 274 | |
275 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
275 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -281,24 +281,24 @@ discard block |
||
281 | 281 | * @param string $content Success page content. |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - public function get_confirm_payment( $content ) { |
|
284 | + public function get_confirm_payment($content) { |
|
285 | 285 | |
286 | 286 | // Retrieve the invoice. |
287 | 287 | $invoice_id = getpaid_get_current_invoice_id(); |
288 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
288 | + $invoice = wpinv_get_invoice($invoice_id); |
|
289 | 289 | |
290 | 290 | // Ensure that it exists and that it is pending payment. |
291 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
291 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
292 | 292 | return $content; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // Can the user view this invoice?? |
296 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
296 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
297 | 297 | return $content; |
298 | 298 | } |
299 | 299 | |
300 | 300 | // Show payment processing indicator. |
301 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
301 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -315,14 +315,14 @@ discard block |
||
315 | 315 | * @param WPInv_Invoice $invoice Invoice object. |
316 | 316 | * @return string transaction URL, or empty string. |
317 | 317 | */ |
318 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
318 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
319 | 319 | |
320 | - $transaction_id = $invoice->get_transaction_id(); |
|
320 | + $transaction_id = $invoice->get_transaction_id(); |
|
321 | 321 | |
322 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
323 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
324 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
325 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
322 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
323 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
324 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
325 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | return $transaction_url; |
@@ -335,15 +335,15 @@ discard block |
||
335 | 335 | * @param WPInv_Invoice $invoice Invoice object. |
336 | 336 | * @return string subscription URL, or empty string. |
337 | 337 | */ |
338 | - public function filter_subscription_url( $subscription_url, $invoice ) { |
|
338 | + public function filter_subscription_url($subscription_url, $invoice) { |
|
339 | 339 | |
340 | - $profile_id = $invoice->get_subscription_id(); |
|
340 | + $profile_id = $invoice->get_subscription_id(); |
|
341 | 341 | |
342 | - if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
342 | + if (!empty($this->view_subscription_url) && !empty($profile_id)) { |
|
343 | 343 | |
344 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
345 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
346 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
344 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
345 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
346 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @return bool |
357 | 357 | */ |
358 | 358 | public function is_available() { |
359 | - return ! empty( $this->enabled ); |
|
359 | + return !empty($this->enabled); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @return string |
366 | 366 | */ |
367 | 367 | public function get_title() { |
368 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
368 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @return string |
375 | 375 | */ |
376 | 376 | public function get_description() { |
377 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
377 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
387 | 387 | * @return void |
388 | 388 | */ |
389 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
389 | + public function process_payment($invoice, $submission_data, $submission) { |
|
390 | 390 | // Process the payment then either redirect to the success page or the gateway. |
391 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
391 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | * @param string $reason Refund reason. |
403 | 403 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
404 | 404 | */ |
405 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
406 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
405 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
406 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | * @param int $invoice_id 0 or invoice id. |
413 | 413 | * @param GetPaid_Payment_Form $form Current payment form. |
414 | 414 | */ |
415 | - public function payment_fields( $invoice_id, $form ) { |
|
416 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
415 | + public function payment_fields($invoice_id, $form) { |
|
416 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @param array $admin_settings |
423 | 423 | */ |
424 | - public function admin_settings( $admin_settings ) { |
|
424 | + public function admin_settings($admin_settings) { |
|
425 | 425 | return $admin_settings; |
426 | 426 | } |
427 | 427 | |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @param string $option |
432 | 432 | */ |
433 | - public function get_option( $option, $default = false ) { |
|
434 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
433 | + public function get_option($option, $default = false) { |
|
434 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | * @return bool True if the gateway supports the feature, false otherwise. |
445 | 445 | * @since 1.0.19 |
446 | 446 | */ |
447 | - public function supports( $feature ) { |
|
448 | - return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this ); |
|
447 | + public function supports($feature) { |
|
448 | + return apply_filters('getpaid_payment_gateway_supports', in_array($feature, $this->supports), $feature, $this); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -453,36 +453,36 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param bool $save whether or not to display the save button. |
455 | 455 | */ |
456 | - public function get_cc_form( $save = false ) { |
|
456 | + public function get_cc_form($save = false) { |
|
457 | 457 | |
458 | 458 | ob_start(); |
459 | 459 | |
460 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
460 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
461 | 461 | |
462 | 462 | $months = array( |
463 | - '01' => __( 'January', 'invoicing' ), |
|
464 | - '02' => __( 'February', 'invoicing' ), |
|
465 | - '03' => __( 'March', 'invoicing' ), |
|
466 | - '04' => __( 'April', 'invoicing' ), |
|
467 | - '05' => __( 'May', 'invoicing' ), |
|
468 | - '06' => __( 'June', 'invoicing' ), |
|
469 | - '07' => __( 'July', 'invoicing' ), |
|
470 | - '08' => __( 'August', 'invoicing' ), |
|
471 | - '09' => __( 'September', 'invoicing' ), |
|
472 | - '10' => __( 'October', 'invoicing' ), |
|
473 | - '11' => __( 'November', 'invoicing' ), |
|
474 | - '12' => __( 'December', 'invoicing' ), |
|
463 | + '01' => __('January', 'invoicing'), |
|
464 | + '02' => __('February', 'invoicing'), |
|
465 | + '03' => __('March', 'invoicing'), |
|
466 | + '04' => __('April', 'invoicing'), |
|
467 | + '05' => __('May', 'invoicing'), |
|
468 | + '06' => __('June', 'invoicing'), |
|
469 | + '07' => __('July', 'invoicing'), |
|
470 | + '08' => __('August', 'invoicing'), |
|
471 | + '09' => __('September', 'invoicing'), |
|
472 | + '10' => __('October', 'invoicing'), |
|
473 | + '11' => __('November', 'invoicing'), |
|
474 | + '12' => __('December', 'invoicing'), |
|
475 | 475 | ); |
476 | 476 | |
477 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
477 | + $year = (int) date('Y', current_time('timestamp')); |
|
478 | 478 | $years = array(); |
479 | 479 | |
480 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
481 | - $years[ $year + $i ] = $year + $i; |
|
480 | + for ($i = 0; $i <= 10; $i++) { |
|
481 | + $years[$year + $i] = $year + $i; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | ?> |
485 | - <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form card mt-4"> |
|
485 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form card mt-4"> |
|
486 | 486 | |
487 | 487 | |
488 | 488 | <div class="card-body"> |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | array( |
497 | 497 | 'name' => $this->id . '[cc_number]', |
498 | 498 | 'id' => "$id_prefix-cc-number", |
499 | - 'label' => __( 'Card number', 'invoicing' ), |
|
499 | + 'label' => __('Card number', 'invoicing'), |
|
500 | 500 | 'label_type' => 'vertical', |
501 | 501 | 'input_group_left' => '<span class="input-group-text"><i class="fa fa-credit-card"></i></span>', |
502 | 502 | ) |
@@ -507,17 +507,17 @@ discard block |
||
507 | 507 | |
508 | 508 | <div class="col-12 col-sm-4"> |
509 | 509 | <div class="form-group"> |
510 | - <label><?php _e( 'Expiration', 'invoicing' ); ?></label> |
|
510 | + <label><?php _e('Expiration', 'invoicing'); ?></label> |
|
511 | 511 | <div class="form-row"> |
512 | 512 | |
513 | 513 | <div class="col"> |
514 | - <select class="form-control" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]"> |
|
515 | - <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option> |
|
514 | + <select class="form-control" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
515 | + <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option> |
|
516 | 516 | |
517 | 517 | <?php |
518 | - foreach ( $months as $key => $month ) { |
|
519 | - $key = esc_attr( $key ); |
|
520 | - $month = wpinv_clean( $month ); |
|
518 | + foreach ($months as $key => $month) { |
|
519 | + $key = esc_attr($key); |
|
520 | + $month = wpinv_clean($month); |
|
521 | 521 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
522 | 522 | } |
523 | 523 | ?> |
@@ -526,13 +526,13 @@ discard block |
||
526 | 526 | </div> |
527 | 527 | |
528 | 528 | <div class="col"> |
529 | - <select class="form-control" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]"> |
|
530 | - <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option> |
|
529 | + <select class="form-control" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
530 | + <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option> |
|
531 | 531 | |
532 | 532 | <?php |
533 | - foreach ( $years as $key => $year ) { |
|
534 | - $key = esc_attr( $key ); |
|
535 | - $year = wpinv_clean( $year ); |
|
533 | + foreach ($years as $key => $year) { |
|
534 | + $key = esc_attr($key); |
|
535 | + $year = wpinv_clean($year); |
|
536 | 536 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
537 | 537 | } |
538 | 538 | ?> |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | array( |
551 | 551 | 'name' => $this->id . '[cc_cvv2]', |
552 | 552 | 'id' => "$id_prefix-cc-cvv2", |
553 | - 'label' => __( 'CCV', 'invoicing' ), |
|
553 | + 'label' => __('CCV', 'invoicing'), |
|
554 | 554 | 'label_type' => 'vertical', |
555 | 555 | ) |
556 | 556 | ); |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | |
562 | 562 | <?php |
563 | 563 | |
564 | - if ( $save ) { |
|
564 | + if ($save) { |
|
565 | 565 | echo $this->save_payment_method_checkbox(); |
566 | 566 | } |
567 | 567 | |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @since 1.0.19 |
582 | 582 | */ |
583 | - public function new_payment_method_entry( $form ) { |
|
583 | + public function new_payment_method_entry($form) { |
|
584 | 584 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
585 | 585 | } |
586 | 586 | |
@@ -590,16 +590,16 @@ discard block |
||
590 | 590 | * @since 1.0.19 |
591 | 591 | */ |
592 | 592 | public function saved_payment_methods() { |
593 | - $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
593 | + $html = '<ul class="getpaid-saved-payment-methods m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
594 | 594 | |
595 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
596 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
595 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
596 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | $html .= $this->get_new_payment_method_option_html(); |
600 | 600 | $html .= '</ul>'; |
601 | 601 | |
602 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
602 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * @param array $token Payment Token. |
610 | 610 | * @return string Generated payment method HTML |
611 | 611 | */ |
612 | - public function get_saved_payment_method_option_html( $token ) { |
|
612 | + public function get_saved_payment_method_option_html($token) { |
|
613 | 613 | |
614 | 614 | return sprintf( |
615 | 615 | '<li class="getpaid-payment-method form-group"> |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | <span>%3$s</span> |
619 | 619 | </label> |
620 | 620 | </li>', |
621 | - esc_attr( $this->id ), |
|
622 | - esc_attr( $token['id'] ), |
|
623 | - esc_html( $token['name'] ), |
|
624 | - checked( empty( $token['default'] ), false, false ) |
|
621 | + esc_attr($this->id), |
|
622 | + esc_attr($token['id']), |
|
623 | + esc_html($token['name']), |
|
624 | + checked(empty($token['default']), false, false) |
|
625 | 625 | ); |
626 | 626 | |
627 | 627 | } |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | */ |
634 | 634 | public function get_new_payment_method_option_html() { |
635 | 635 | |
636 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
636 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
637 | 637 | |
638 | 638 | return sprintf( |
639 | 639 | '<li class="getpaid-new-payment-method"> |
@@ -642,8 +642,8 @@ discard block |
||
642 | 642 | <span>%2$s</span> |
643 | 643 | </label> |
644 | 644 | </li>', |
645 | - esc_attr( $this->id ), |
|
646 | - esc_html( $label ) |
|
645 | + esc_attr($this->id), |
|
646 | + esc_html($label) |
|
647 | 647 | ); |
648 | 648 | |
649 | 649 | } |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | <span>%2$s</span> |
663 | 663 | </label> |
664 | 664 | </p>', |
665 | - esc_attr( $this->id ), |
|
666 | - esc_html__( 'Save payment method', 'invoicing' ) |
|
665 | + esc_attr($this->id), |
|
666 | + esc_html__('Save payment method', 'invoicing') |
|
667 | 667 | ); |
668 | 668 | |
669 | 669 | } |
@@ -673,9 +673,9 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return array |
675 | 675 | */ |
676 | - public function register_gateway( $gateways ) { |
|
676 | + public function register_gateway($gateways) { |
|
677 | 677 | |
678 | - $gateways[ $this->id ] = array( |
|
678 | + $gateways[$this->id] = array( |
|
679 | 679 | |
680 | 680 | 'admin_label' => $this->method_title, |
681 | 681 | 'checkout_label' => $this->title, |
@@ -693,13 +693,13 @@ discard block |
||
693 | 693 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
694 | 694 | * @return bool |
695 | 695 | */ |
696 | - public function is_sandbox( $invoice = null ) { |
|
696 | + public function is_sandbox($invoice = null) { |
|
697 | 697 | |
698 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
698 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
699 | 699 | return $invoice->get_mode() == 'test'; |
700 | 700 | } |
701 | 701 | |
702 | - return wpinv_is_test_mode( $this->id ); |
|
702 | + return wpinv_is_test_mode($this->id); |
|
703 | 703 | |
704 | 704 | } |
705 | 705 | |
@@ -717,15 +717,15 @@ discard block |
||
717 | 717 | * |
718 | 718 | * @return bool |
719 | 719 | */ |
720 | - public function validate_currency( $validation, $currency ) { |
|
720 | + public function validate_currency($validation, $currency) { |
|
721 | 721 | |
722 | 722 | // Required currencies. |
723 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
723 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
724 | 724 | return false; |
725 | 725 | } |
726 | 726 | |
727 | 727 | // Excluded currencies. |
728 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
728 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
729 | 729 | return false; |
730 | 730 | } |
731 | 731 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | * @param string $prop The prop to set. |
64 | 64 | * @param mixed $value The value to retrieve. |
65 | 65 | */ |
66 | - public function set( $prop, $value ) { |
|
67 | - $this->data[ $prop ] = $value; |
|
66 | + public function set($prop, $value) { |
|
67 | + $this->data[$prop] = $value; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * @param string $prop The prop to set. |
74 | 74 | * @return mixed The value. |
75 | 75 | */ |
76 | - public function get( $prop ) { |
|
76 | + public function get($prop) { |
|
77 | 77 | |
78 | - if ( isset( $this->data[ $prop ] ) ) { |
|
79 | - return $this->data[ $prop ]; |
|
78 | + if (isset($this->data[$prop])) { |
|
79 | + return $this->data[$prop]; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | return null; |
@@ -88,29 +88,29 @@ discard block |
||
88 | 88 | public function set_properties() { |
89 | 89 | |
90 | 90 | // Sessions. |
91 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
92 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
91 | + $this->set('session', new WPInv_Session_Handler()); |
|
92 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
93 | 93 | $this->form_elements = new WPInv_Payment_Form_Elements(); |
94 | 94 | $this->tax = new WPInv_EUVat(); |
95 | 95 | $this->tax->init(); |
96 | 96 | $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
97 | 97 | |
98 | 98 | // Init other objects. |
99 | - $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor. |
|
100 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
101 | - $this->set( 'notes', new WPInv_Notes() ); |
|
102 | - $this->set( 'api', new WPInv_API() ); |
|
103 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
104 | - $this->set( 'template', new GetPaid_Template() ); |
|
105 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
99 | + $this->set('reports', new WPInv_Reports()); // TODO: Refactor. |
|
100 | + $this->set('session', new WPInv_Session_Handler()); |
|
101 | + $this->set('notes', new WPInv_Notes()); |
|
102 | + $this->set('api', new WPInv_API()); |
|
103 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
104 | + $this->set('template', new GetPaid_Template()); |
|
105 | + $this->set('admin', new GetPaid_Admin()); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * Define plugin constants. |
110 | 110 | */ |
111 | 111 | public function define_constants() { |
112 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
113 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
112 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
113 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
114 | 114 | $this->version = WPINV_VERSION; |
115 | 115 | } |
116 | 116 | |
@@ -121,26 +121,26 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function init_hooks() { |
123 | 123 | /* Internationalize the text strings used. */ |
124 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
124 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
125 | 125 | |
126 | 126 | // Init the plugin after WordPress inits. |
127 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
128 | - add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 ); |
|
129 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
127 | + add_action('init', array($this, 'init'), 1); |
|
128 | + add_action('getpaid_init', array($this, 'maybe_process_ipn'), 5); |
|
129 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
130 | 130 | |
131 | - if ( class_exists( 'BuddyPress' ) ) { |
|
132 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
131 | + if (class_exists('BuddyPress')) { |
|
132 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
133 | 133 | } |
134 | 134 | |
135 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
136 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
137 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
138 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
139 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
135 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
136 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
137 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
138 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
139 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
140 | 140 | |
141 | 141 | // Fires after registering actions. |
142 | - do_action( 'wpinv_actions', $this ); |
|
143 | - do_action( 'getpaid_actions', $this ); |
|
142 | + do_action('wpinv_actions', $this); |
|
143 | + do_action('getpaid_actions', $this); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | /* Internationalize the text strings used. */ |
149 | 149 | $this->load_textdomain(); |
150 | 150 | |
151 | - do_action( 'wpinv_loaded' ); |
|
151 | + do_action('wpinv_loaded'); |
|
152 | 152 | |
153 | 153 | // Fix oxygen page builder conflict |
154 | - if ( function_exists( 'ct_css_output' ) ) { |
|
154 | + if (function_exists('ct_css_output')) { |
|
155 | 155 | wpinv_oxygen_fix_conflict(); |
156 | 156 | } |
157 | 157 | } |
@@ -161,21 +161,21 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @since 1.0 |
163 | 163 | */ |
164 | - public function load_textdomain( $locale = NULL ) { |
|
165 | - if ( empty( $locale ) ) { |
|
166 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
164 | + public function load_textdomain($locale = NULL) { |
|
165 | + if (empty($locale)) { |
|
166 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
167 | 167 | } |
168 | 168 | |
169 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
169 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
170 | 170 | |
171 | - unload_textdomain( 'invoicing' ); |
|
172 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
173 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
171 | + unload_textdomain('invoicing'); |
|
172 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
173 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
174 | 174 | |
175 | 175 | /** |
176 | 176 | * Define language constants. |
177 | 177 | */ |
178 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
178 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -184,114 +184,114 @@ discard block |
||
184 | 184 | public function includes() { |
185 | 185 | |
186 | 186 | // Start with the settings. |
187 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
187 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
188 | 188 | |
189 | 189 | // Packages/libraries. |
190 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' ); |
|
190 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
191 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
192 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php'); |
|
193 | 193 | |
194 | 194 | // Load functions. |
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
207 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
208 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
195 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
196 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
197 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
198 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
199 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
200 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
201 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
202 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
203 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
204 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
205 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
206 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
207 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
208 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
209 | 209 | |
210 | 210 | // Register autoloader. |
211 | 211 | try { |
212 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
213 | - } catch ( Exception $e ) { |
|
214 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
212 | + spl_autoload_register(array($this, 'autoload'), true); |
|
213 | + } catch (Exception $e) { |
|
214 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
215 | 215 | } |
216 | 216 | |
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
234 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
235 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
236 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
237 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' ); |
|
217 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
218 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
219 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
220 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
221 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
222 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
223 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
224 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
226 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php'); |
|
227 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
228 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
229 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
230 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
231 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
232 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
233 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
234 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
235 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
236 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
237 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
238 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
239 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php'); |
|
240 | 240 | |
241 | 241 | /** |
242 | 242 | * Load the tax class. |
243 | 243 | */ |
244 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
245 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
244 | + if (!class_exists('WPInv_EUVat')) { |
|
245 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
246 | 246 | } |
247 | 247 | |
248 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
249 | - if ( !empty( $gateways ) ) { |
|
250 | - foreach ( $gateways as $gateway ) { |
|
251 | - if ( $gateway == 'manual' ) { |
|
248 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
249 | + if (!empty($gateways)) { |
|
250 | + foreach ($gateways as $gateway) { |
|
251 | + if ($gateway == 'manual') { |
|
252 | 252 | continue; |
253 | 253 | } |
254 | 254 | |
255 | 255 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
256 | 256 | |
257 | - if ( file_exists( $gateway_file ) ) { |
|
258 | - require_once( $gateway_file ); |
|
257 | + if (file_exists($gateway_file)) { |
|
258 | + require_once($gateway_file); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
263 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
264 | 264 | GetPaid_Post_Types_Admin::init(); |
265 | 265 | |
266 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
267 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
266 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
267 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
268 | 268 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
269 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
270 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
271 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
272 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
273 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
274 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
269 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
270 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
271 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
272 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
273 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
274 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
275 | 275 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
276 | 276 | // load the user class only on the users.php page |
277 | 277 | global $pagenow; |
278 | - if($pagenow=='users.php'){ |
|
278 | + if ($pagenow == 'users.php') { |
|
279 | 279 | new WPInv_Admin_Users(); |
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Register cli commands |
284 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
285 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
286 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
284 | + if (defined('WP_CLI') && WP_CLI) { |
|
285 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
286 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | // include css inliner |
290 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
291 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
290 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
291 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
292 | 292 | } |
293 | 293 | |
294 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
294 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -302,21 +302,21 @@ discard block |
||
302 | 302 | * @since 1.0.19 |
303 | 303 | * @return void |
304 | 304 | */ |
305 | - public function autoload( $class_name ) { |
|
305 | + public function autoload($class_name) { |
|
306 | 306 | |
307 | 307 | // Normalize the class name... |
308 | - $class_name = strtolower( $class_name ); |
|
308 | + $class_name = strtolower($class_name); |
|
309 | 309 | |
310 | 310 | // ... and make sure it is our class. |
311 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
311 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
312 | 312 | return; |
313 | 313 | } |
314 | 314 | |
315 | 315 | // Next, prepare the file name from the class. |
316 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
316 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
317 | 317 | |
318 | 318 | // Base path of the classes. |
319 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
319 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
320 | 320 | |
321 | 321 | // And an array of possible locations in order of importance. |
322 | 322 | $locations = array( |
@@ -328,10 +328,10 @@ discard block |
||
328 | 328 | "$plugin_path/includes/admin/meta-boxes", |
329 | 329 | ); |
330 | 330 | |
331 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
331 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
332 | 332 | |
333 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
334 | - include trailingslashit( $location ) . $file_name; |
|
333 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
334 | + include trailingslashit($location) . $file_name; |
|
335 | 335 | break; |
336 | 336 | } |
337 | 337 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | public function init() { |
346 | 346 | |
347 | 347 | // Fires before getpaid inits. |
348 | - do_action( 'before_getpaid_init', $this ); |
|
348 | + do_action('before_getpaid_init', $this); |
|
349 | 349 | |
350 | 350 | // Load default gateways. |
351 | 351 | $gateways = apply_filters( |
@@ -359,12 +359,12 @@ discard block |
||
359 | 359 | ) |
360 | 360 | ); |
361 | 361 | |
362 | - foreach ( $gateways as $id => $class ) { |
|
363 | - $this->gateways[ $id ] = new $class(); |
|
362 | + foreach ($gateways as $id => $class) { |
|
363 | + $this->gateways[$id] = new $class(); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | // Fires after getpaid inits. |
367 | - do_action( 'getpaid_init', $this ); |
|
367 | + do_action('getpaid_init', $this); |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -374,82 +374,82 @@ discard block |
||
374 | 374 | public function maybe_process_ipn() { |
375 | 375 | |
376 | 376 | // Ensure that this is an IPN request. |
377 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
377 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
378 | 378 | return; |
379 | 379 | } |
380 | 380 | |
381 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
381 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
382 | 382 | |
383 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
384 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
383 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
384 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
385 | 385 | exit; |
386 | 386 | |
387 | 387 | } |
388 | 388 | |
389 | 389 | public function enqueue_scripts() { |
390 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
390 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
391 | 391 | |
392 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
393 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
394 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
392 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css'); |
|
393 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version); |
|
394 | + wp_enqueue_style('wpinv_front_style'); |
|
395 | 395 | |
396 | 396 | // Register scripts |
397 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
398 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
397 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
398 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js')); |
|
399 | 399 | |
400 | 400 | $localize = array(); |
401 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
402 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
401 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
402 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
403 | 403 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
404 | 404 | $localize['currency_pos'] = wpinv_currency_position(); |
405 | 405 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
406 | 406 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
407 | 407 | $localize['decimals'] = wpinv_decimals(); |
408 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
408 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
409 | 409 | $localize['UseTaxes'] = wpinv_use_taxes(); |
410 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
411 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
412 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
410 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
411 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
412 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
413 | 413 | |
414 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
414 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
415 | 415 | |
416 | - wp_enqueue_script( 'jquery-blockui' ); |
|
416 | + wp_enqueue_script('jquery-blockui'); |
|
417 | 417 | $autofill_api = wpinv_get_option('address_autofill_api'); |
418 | 418 | $autofill_active = wpinv_get_option('address_autofill_active'); |
419 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
420 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
421 | - wp_dequeue_script( 'google-maps-api' ); |
|
419 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
420 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
421 | + wp_dequeue_script('google-maps-api'); |
|
422 | 422 | } |
423 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
424 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
423 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
424 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
425 | 425 | } |
426 | 426 | |
427 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
428 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
427 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
428 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
429 | 429 | |
430 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
431 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
430 | + wp_enqueue_script('wpinv-front-script'); |
|
431 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
432 | 432 | |
433 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
434 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
433 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
434 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | public function wpinv_actions() { |
438 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
439 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
438 | + if (isset($_REQUEST['wpi_action'])) { |
|
439 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | - public function pre_get_posts( $wp_query ) { |
|
444 | - if ( ! is_admin() && !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
445 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
443 | + public function pre_get_posts($wp_query) { |
|
444 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
445 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | return $wp_query; |
449 | 449 | } |
450 | 450 | |
451 | 451 | public function bp_invoicing_init() { |
452 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
452 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | ) |
471 | 471 | ); |
472 | 472 | |
473 | - foreach ( $widgets as $widget ) { |
|
474 | - register_widget( $widget ); |
|
473 | + foreach ($widgets as $widget) { |
|
474 | + register_widget($widget); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | } |
@@ -482,10 +482,10 @@ discard block |
||
482 | 482 | * @since 1.0.19 |
483 | 483 | * @param int[] $excluded_posts_ids |
484 | 484 | */ |
485 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
485 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
486 | 486 | |
487 | 487 | // Ensure that we have an array. |
488 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
488 | + if (!is_array($excluded_posts_ids)) { |
|
489 | 489 | $excluded_posts_ids = array(); |
490 | 490 | } |
491 | 491 | |
@@ -493,24 +493,24 @@ discard block |
||
493 | 493 | $our_pages = array(); |
494 | 494 | |
495 | 495 | // Checkout page. |
496 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
496 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
497 | 497 | |
498 | 498 | // Success page. |
499 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
499 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
500 | 500 | |
501 | 501 | // Failure page. |
502 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
502 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
503 | 503 | |
504 | 504 | // History page. |
505 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
505 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
506 | 506 | |
507 | 507 | // Subscriptions page. |
508 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
508 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
509 | 509 | |
510 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
510 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
511 | 511 | |
512 | 512 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
513 | - return array_unique( $excluded_posts_ids ); |
|
513 | + return array_unique($excluded_posts_ids); |
|
514 | 514 | |
515 | 515 | } |
516 | 516 |
@@ -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 |
@@ -70,27 +70,27 @@ discard block |
||
70 | 70 | * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
71 | 71 | * @param bool $deprecated |
72 | 72 | */ |
73 | - function __construct( $subscription = 0, $deprecated = false ) { |
|
73 | + function __construct($subscription = 0, $deprecated = false) { |
|
74 | 74 | |
75 | - parent::__construct( $subscription ); |
|
75 | + parent::__construct($subscription); |
|
76 | 76 | |
77 | - if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
78 | - $this->set_id( $subscription ); |
|
79 | - } elseif ( $subscription instanceof self ) { |
|
80 | - $this->set_id( $subscription->get_id() ); |
|
81 | - } elseif ( ! empty( $subscription->id ) ) { |
|
82 | - $this->set_id( $subscription->id ); |
|
83 | - } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
84 | - $this->set_id( $subscription_id ); |
|
77 | + if (!$deprecated && !empty($subscription) && is_numeric($subscription)) { |
|
78 | + $this->set_id($subscription); |
|
79 | + } elseif ($subscription instanceof self) { |
|
80 | + $this->set_id($subscription->get_id()); |
|
81 | + } elseif (!empty($subscription->id)) { |
|
82 | + $this->set_id($subscription->id); |
|
83 | + } elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) { |
|
84 | + $this->set_id($subscription_id); |
|
85 | 85 | } else { |
86 | - $this->set_object_read( true ); |
|
86 | + $this->set_object_read(true); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // Load the datastore. |
90 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
90 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
91 | 91 | |
92 | - if ( $this->get_id() > 0 ) { |
|
93 | - $this->data_store->read( $this ); |
|
92 | + if ($this->get_id() > 0) { |
|
93 | + $this->data_store->read($this); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | } |
@@ -105,17 +105,17 @@ discard block |
||
105 | 105 | * @since 1.0.19 |
106 | 106 | * @return int |
107 | 107 | */ |
108 | - public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
108 | + public static function get_subscription_id_by_field($value, $field = 'profile_id') { |
|
109 | 109 | global $wpdb; |
110 | 110 | |
111 | 111 | // Trim the value. |
112 | - $value = trim( $value ); |
|
112 | + $value = trim($value); |
|
113 | 113 | |
114 | - if ( empty( $value ) ) { |
|
114 | + if (empty($value)) { |
|
115 | 115 | return 0; |
116 | 116 | } |
117 | 117 | |
118 | - if ( 'invoice_id' == $field ) { |
|
118 | + if ('invoice_id' == $field) { |
|
119 | 119 | $field = 'parent_payment_id'; |
120 | 120 | } |
121 | 121 | |
@@ -127,28 +127,28 @@ discard block |
||
127 | 127 | ); |
128 | 128 | |
129 | 129 | // Ensure a field has been passed. |
130 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
130 | + if (empty($field) || !in_array($field, $fields)) { |
|
131 | 131 | return 0; |
132 | 132 | } |
133 | 133 | |
134 | 134 | // Maybe retrieve from the cache. |
135 | - $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
136 | - if ( ! empty( $subscription_id ) ) { |
|
135 | + $subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
136 | + if (!empty($subscription_id)) { |
|
137 | 137 | return $subscription_id; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // Fetch from the db. |
141 | 141 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
142 | 142 | $subscription_id = (int) $wpdb->get_var( |
143 | - $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
143 | + $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
144 | 144 | ); |
145 | 145 | |
146 | - if ( empty( $subscription_id ) ) { |
|
146 | + if (empty($subscription_id)) { |
|
147 | 147 | return 0; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Update the cache with our data. |
151 | - wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
151 | + wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
152 | 152 | |
153 | 153 | return $subscription_id; |
154 | 154 | } |
@@ -157,17 +157,17 @@ discard block |
||
157 | 157 | * Clears the subscription's cache. |
158 | 158 | */ |
159 | 159 | public function clear_cache() { |
160 | - wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
161 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
162 | - wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
163 | - wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
160 | + wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids'); |
|
161 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
162 | + wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids'); |
|
163 | + wp_cache_delete($this->get_id(), 'getpaid_subscriptions'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
167 | 167 | * Checks if a subscription key is set. |
168 | 168 | */ |
169 | - public function _isset( $key ) { |
|
170 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
169 | + public function _isset($key) { |
|
170 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /* |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @param string $context View or edit context. |
193 | 193 | * @return int |
194 | 194 | */ |
195 | - public function get_customer_id( $context = 'view' ) { |
|
196 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
195 | + public function get_customer_id($context = 'view') { |
|
196 | + return (int) $this->get_prop('customer_id', $context); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @param string $context View or edit context. |
204 | 204 | * @return WP_User|false WP_User object on success, false on failure. |
205 | 205 | */ |
206 | - public function get_customer( $context = 'view' ) { |
|
207 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
206 | + public function get_customer($context = 'view') { |
|
207 | + return get_userdata($this->get_customer_id($context)); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @param string $context View or edit context. |
215 | 215 | * @return int |
216 | 216 | */ |
217 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
218 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
217 | + public function get_parent_invoice_id($context = 'view') { |
|
218 | + return (int) $this->get_prop('parent_payment_id', $context); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | * @param string $context View or edit context. |
226 | 226 | * @return int |
227 | 227 | */ |
228 | - public function get_parent_payment_id( $context = 'view' ) { |
|
229 | - return $this->get_parent_invoice_id( $context ); |
|
228 | + public function get_parent_payment_id($context = 'view') { |
|
229 | + return $this->get_parent_invoice_id($context); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | * @since 1.0.0 |
236 | 236 | * @return int |
237 | 237 | */ |
238 | - public function get_original_payment_id( $context = 'view' ) { |
|
239 | - return $this->get_parent_invoice_id( $context ); |
|
238 | + public function get_original_payment_id($context = 'view') { |
|
239 | + return $this->get_parent_invoice_id($context); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | * @param string $context View or edit context. |
247 | 247 | * @return WPInv_Invoice |
248 | 248 | */ |
249 | - public function get_parent_invoice( $context = 'view' ) { |
|
250 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
249 | + public function get_parent_invoice($context = 'view') { |
|
250 | + return new WPInv_Invoice($this->get_parent_invoice_id($context)); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @param string $context View or edit context. |
258 | 258 | * @return WPInv_Invoice |
259 | 259 | */ |
260 | - public function get_parent_payment( $context = 'view' ) { |
|
261 | - return $this->get_parent_invoice( $context ); |
|
260 | + public function get_parent_payment($context = 'view') { |
|
261 | + return $this->get_parent_invoice($context); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param string $context View or edit context. |
269 | 269 | * @return int |
270 | 270 | */ |
271 | - public function get_product_id( $context = 'view' ) { |
|
272 | - return (int) $this->get_prop( 'product_id', $context ); |
|
271 | + public function get_product_id($context = 'view') { |
|
272 | + return (int) $this->get_prop('product_id', $context); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * @param string $context View or edit context. |
280 | 280 | * @return WPInv_Item |
281 | 281 | */ |
282 | - public function get_product( $context = 'view' ) { |
|
283 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
282 | + public function get_product($context = 'view') { |
|
283 | + return new WPInv_Item($this->get_product_id($context)); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | * @param string $context View or edit context. |
293 | 293 | * @return string |
294 | 294 | */ |
295 | - public function get_gateway( $context = 'view' ) { |
|
296 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
295 | + public function get_gateway($context = 'view') { |
|
296 | + return $this->get_parent_invoice($context)->get_gateway(); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param string $context View or edit context. |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - public function get_period( $context = 'view' ) { |
|
307 | - return $this->get_prop( 'period', $context ); |
|
306 | + public function get_period($context = 'view') { |
|
307 | + return $this->get_prop('period', $context); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | * @param string $context View or edit context. |
315 | 315 | * @return int |
316 | 316 | */ |
317 | - public function get_frequency( $context = 'view' ) { |
|
318 | - return (int) $this->get_prop( 'frequency', $context ); |
|
317 | + public function get_frequency($context = 'view') { |
|
318 | + return (int) $this->get_prop('frequency', $context); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | * @param string $context View or edit context. |
326 | 326 | * @return float |
327 | 327 | */ |
328 | - public function get_initial_amount( $context = 'view' ) { |
|
329 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
328 | + public function get_initial_amount($context = 'view') { |
|
329 | + return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context)); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @param string $context View or edit context. |
337 | 337 | * @return float |
338 | 338 | */ |
339 | - public function get_recurring_amount( $context = 'view' ) { |
|
340 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
339 | + public function get_recurring_amount($context = 'view') { |
|
340 | + return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context)); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * @param string $context View or edit context. |
348 | 348 | * @return int |
349 | 349 | */ |
350 | - public function get_bill_times( $context = 'view' ) { |
|
351 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
350 | + public function get_bill_times($context = 'view') { |
|
351 | + return (int) $this->get_prop('bill_times', $context); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | * @param string $context View or edit context. |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function get_transaction_id( $context = 'view' ) { |
|
362 | - return $this->get_prop( 'transaction_id', $context ); |
|
361 | + public function get_transaction_id($context = 'view') { |
|
362 | + return $this->get_prop('transaction_id', $context); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -369,8 +369,8 @@ discard block |
||
369 | 369 | * @param string $context View or edit context. |
370 | 370 | * @return string |
371 | 371 | */ |
372 | - public function get_created( $context = 'view' ) { |
|
373 | - return $this->get_prop( 'created', $context ); |
|
372 | + public function get_created($context = 'view') { |
|
373 | + return $this->get_prop('created', $context); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -380,8 +380,8 @@ discard block |
||
380 | 380 | * @param string $context View or edit context. |
381 | 381 | * @return string |
382 | 382 | */ |
383 | - public function get_date_created( $context = 'view' ) { |
|
384 | - return $this->get_created( $context ); |
|
383 | + public function get_date_created($context = 'view') { |
|
384 | + return $this->get_created($context); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | */ |
393 | 393 | public function get_time_created() { |
394 | 394 | $created = $this->get_date_created(); |
395 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
395 | + return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp')); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | * @param string $context View or edit context. |
403 | 403 | * @return string |
404 | 404 | */ |
405 | - public function get_date_created_gmt( $context = 'view' ) { |
|
406 | - $date = $this->get_date_created( $context ); |
|
405 | + public function get_date_created_gmt($context = 'view') { |
|
406 | + $date = $this->get_date_created($context); |
|
407 | 407 | |
408 | - if ( $date ) { |
|
409 | - $date = get_gmt_from_date( $date ); |
|
408 | + if ($date) { |
|
409 | + $date = get_gmt_from_date($date); |
|
410 | 410 | } |
411 | 411 | return $date; |
412 | 412 | } |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * @param string $context View or edit context. |
419 | 419 | * @return string |
420 | 420 | */ |
421 | - public function get_next_renewal_date( $context = 'view' ) { |
|
422 | - return $this->get_prop( 'expiration', $context ); |
|
421 | + public function get_next_renewal_date($context = 'view') { |
|
422 | + return $this->get_prop('expiration', $context); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param string $context View or edit context. |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function get_expiration( $context = 'view' ) { |
|
433 | - return $this->get_next_renewal_date( $context ); |
|
432 | + public function get_expiration($context = 'view') { |
|
433 | + return $this->get_next_renewal_date($context); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -442,12 +442,12 @@ discard block |
||
442 | 442 | public function get_expiration_time() { |
443 | 443 | $expiration = $this->get_expiration(); |
444 | 444 | |
445 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
446 | - return current_time( 'timestamp' ); |
|
445 | + if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) { |
|
446 | + return current_time('timestamp'); |
|
447 | 447 | } |
448 | 448 | |
449 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
450 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
449 | + $expiration = strtotime($expiration, current_time('timestamp')); |
|
450 | + return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration; |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -457,11 +457,11 @@ discard block |
||
457 | 457 | * @param string $context View or edit context. |
458 | 458 | * @return string |
459 | 459 | */ |
460 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
461 | - $date = $this->get_next_renewal_date( $context ); |
|
460 | + public function get_next_renewal_date_gmt($context = 'view') { |
|
461 | + $date = $this->get_next_renewal_date($context); |
|
462 | 462 | |
463 | - if ( $date ) { |
|
464 | - $date = get_gmt_from_date( $date ); |
|
463 | + if ($date) { |
|
464 | + $date = get_gmt_from_date($date); |
|
465 | 465 | } |
466 | 466 | return $date; |
467 | 467 | } |
@@ -473,8 +473,8 @@ discard block |
||
473 | 473 | * @param string $context View or edit context. |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public function get_trial_period( $context = 'view' ) { |
|
477 | - return $this->get_prop( 'trial_period', $context ); |
|
476 | + public function get_trial_period($context = 'view') { |
|
477 | + return $this->get_prop('trial_period', $context); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | * @param string $context View or edit context. |
485 | 485 | * @return string |
486 | 486 | */ |
487 | - public function get_status( $context = 'view' ) { |
|
488 | - return $this->get_prop( 'status', $context ); |
|
487 | + public function get_status($context = 'view') { |
|
488 | + return $this->get_prop('status', $context); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | * @param string $context View or edit context. |
496 | 496 | * @return string |
497 | 497 | */ |
498 | - public function get_profile_id( $context = 'view' ) { |
|
499 | - return $this->get_prop( 'profile_id', $context ); |
|
498 | + public function get_profile_id($context = 'view') { |
|
499 | + return $this->get_prop('profile_id', $context); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /* |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | * @since 1.0.19 |
512 | 512 | * @param int $value The customer's id. |
513 | 513 | */ |
514 | - public function set_customer_id( $value ) { |
|
515 | - $this->set_prop( 'customer_id', (int) $value ); |
|
514 | + public function set_customer_id($value) { |
|
515 | + $this->set_prop('customer_id', (int) $value); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
@@ -521,8 +521,8 @@ discard block |
||
521 | 521 | * @since 1.0.19 |
522 | 522 | * @param int $value The parent invoice id. |
523 | 523 | */ |
524 | - public function set_parent_invoice_id( $value ) { |
|
525 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
524 | + public function set_parent_invoice_id($value) { |
|
525 | + $this->set_prop('parent_payment_id', (int) $value); |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | /** |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | * @since 1.0.19 |
532 | 532 | * @param int $value The parent invoice id. |
533 | 533 | */ |
534 | - public function set_parent_payment_id( $value ) { |
|
535 | - $this->set_parent_invoice_id( $value ); |
|
534 | + public function set_parent_payment_id($value) { |
|
535 | + $this->set_parent_invoice_id($value); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | * @since 1.0.19 |
542 | 542 | * @param int $value The parent invoice id. |
543 | 543 | */ |
544 | - public function set_original_payment_id( $value ) { |
|
545 | - $this->set_parent_invoice_id( $value ); |
|
544 | + public function set_original_payment_id($value) { |
|
545 | + $this->set_parent_invoice_id($value); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | * @since 1.0.19 |
552 | 552 | * @param int $value The subscription product id. |
553 | 553 | */ |
554 | - public function set_product_id( $value ) { |
|
555 | - $this->set_prop( 'product_id', (int) $value ); |
|
554 | + public function set_product_id($value) { |
|
555 | + $this->set_prop('product_id', (int) $value); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -561,8 +561,8 @@ discard block |
||
561 | 561 | * @since 1.0.19 |
562 | 562 | * @param string $value The renewal period. |
563 | 563 | */ |
564 | - public function set_period( $value ) { |
|
565 | - $this->set_prop( 'period', $value ); |
|
564 | + public function set_period($value) { |
|
565 | + $this->set_prop('period', $value); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | /** |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | * @since 1.0.19 |
572 | 572 | * @param int $value The subscription frequency. |
573 | 573 | */ |
574 | - public function set_frequency( $value ) { |
|
575 | - $value = empty( $value ) ? 1 : (int) $value; |
|
576 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
574 | + public function set_frequency($value) { |
|
575 | + $value = empty($value) ? 1 : (int) $value; |
|
576 | + $this->set_prop('frequency', absint($value)); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | * @since 1.0.19 |
583 | 583 | * @param float $value The initial subcription amount. |
584 | 584 | */ |
585 | - public function set_initial_amount( $value ) { |
|
586 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
585 | + public function set_initial_amount($value) { |
|
586 | + $this->set_prop('initial_amount', wpinv_sanitize_amount($value)); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -592,8 +592,8 @@ discard block |
||
592 | 592 | * @since 1.0.19 |
593 | 593 | * @param float $value The recurring subcription amount. |
594 | 594 | */ |
595 | - public function set_recurring_amount( $value ) { |
|
596 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
595 | + public function set_recurring_amount($value) { |
|
596 | + $this->set_prop('recurring_amount', wpinv_sanitize_amount($value)); |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -602,8 +602,8 @@ discard block |
||
602 | 602 | * @since 1.0.19 |
603 | 603 | * @param int $value Bill times. |
604 | 604 | */ |
605 | - public function set_bill_times( $value ) { |
|
606 | - $this->set_prop( 'bill_times', (int) $value ); |
|
605 | + public function set_bill_times($value) { |
|
606 | + $this->set_prop('bill_times', (int) $value); |
|
607 | 607 | } |
608 | 608 | |
609 | 609 | /** |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | * @since 1.0.19 |
613 | 613 | * @param string $value Bill times. |
614 | 614 | */ |
615 | - public function set_transaction_id( $value ) { |
|
616 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
615 | + public function set_transaction_id($value) { |
|
616 | + $this->set_prop('transaction_id', sanitize_text_field($value)); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
@@ -622,15 +622,15 @@ discard block |
||
622 | 622 | * @since 1.0.19 |
623 | 623 | * @param string $value strtotime compliant date. |
624 | 624 | */ |
625 | - public function set_created( $value ) { |
|
626 | - $date = strtotime( $value ); |
|
625 | + public function set_created($value) { |
|
626 | + $date = strtotime($value); |
|
627 | 627 | |
628 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
629 | - $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
628 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
629 | + $this->set_prop('created', date('Y-m-d H:i:s', $date)); |
|
630 | 630 | return; |
631 | 631 | } |
632 | 632 | |
633 | - $this->set_prop( 'created', '' ); |
|
633 | + $this->set_prop('created', ''); |
|
634 | 634 | |
635 | 635 | } |
636 | 636 | |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * @since 1.0.19 |
641 | 641 | * @param string $value strtotime compliant date. |
642 | 642 | */ |
643 | - public function set_date_created( $value ) { |
|
644 | - $this->set_created( $value ); |
|
643 | + public function set_date_created($value) { |
|
644 | + $this->set_created($value); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -650,15 +650,15 @@ discard block |
||
650 | 650 | * @since 1.0.19 |
651 | 651 | * @param string $value strtotime compliant date. |
652 | 652 | */ |
653 | - public function set_next_renewal_date( $value ) { |
|
654 | - $date = strtotime( $value ); |
|
653 | + public function set_next_renewal_date($value) { |
|
654 | + $date = strtotime($value); |
|
655 | 655 | |
656 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
657 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
656 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
657 | + $this->set_prop('expiration', date('Y-m-d H:i:s', $date)); |
|
658 | 658 | return; |
659 | 659 | } |
660 | 660 | |
661 | - $this->set_prop( 'expiration', '' ); |
|
661 | + $this->set_prop('expiration', ''); |
|
662 | 662 | |
663 | 663 | } |
664 | 664 | |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | * @since 1.0.19 |
669 | 669 | * @param string $value strtotime compliant date. |
670 | 670 | */ |
671 | - public function set_expiration( $value ) { |
|
672 | - $this->set_next_renewal_date( $value ); |
|
671 | + public function set_expiration($value) { |
|
672 | + $this->set_next_renewal_date($value); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -678,8 +678,8 @@ discard block |
||
678 | 678 | * @since 1.0.19 |
679 | 679 | * @param string $value trial period e.g 1 year. |
680 | 680 | */ |
681 | - public function set_trial_period( $value ) { |
|
682 | - $this->set_prop( 'trial_period', $value ); |
|
681 | + public function set_trial_period($value) { |
|
682 | + $this->set_prop('trial_period', $value); |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | /** |
@@ -688,19 +688,19 @@ discard block |
||
688 | 688 | * @since 1.0.19 |
689 | 689 | * @param string $new_status New subscription status. |
690 | 690 | */ |
691 | - public function set_status( $new_status ) { |
|
691 | + public function set_status($new_status) { |
|
692 | 692 | |
693 | 693 | // Abort if this is not a valid status; |
694 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
694 | + if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) { |
|
695 | 695 | return; |
696 | 696 | } |
697 | 697 | |
698 | 698 | $old_status = $this->get_status(); |
699 | - $this->set_prop( 'status', $new_status ); |
|
699 | + $this->set_prop('status', $new_status); |
|
700 | 700 | |
701 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
701 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
702 | 702 | $this->status_transition = array( |
703 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
703 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
704 | 704 | 'to' => $new_status, |
705 | 705 | ); |
706 | 706 | } |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | * @since 1.0.19 |
714 | 714 | * @param string $value the remote profile id. |
715 | 715 | */ |
716 | - public function set_profile_id( $value ) { |
|
717 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
716 | + public function set_profile_id($value) { |
|
717 | + $this->set_prop('profile_id', sanitize_text_field($value)); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /* |
@@ -732,8 +732,8 @@ discard block |
||
732 | 732 | * @param string|array String or array of strings to check for. |
733 | 733 | * @return bool |
734 | 734 | */ |
735 | - public function has_status( $status ) { |
|
736 | - return in_array( $this->get_status(), wpinv_parse_list( $status ) ); |
|
735 | + public function has_status($status) { |
|
736 | + return in_array($this->get_status(), wpinv_parse_list($status)); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | /** |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | */ |
744 | 744 | public function has_trial_period() { |
745 | 745 | $period = $this->get_trial_period(); |
746 | - return ! empty( $period ); |
|
746 | + return !empty($period); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | /** |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | * @return bool |
753 | 753 | */ |
754 | 754 | public function is_active() { |
755 | - return $this->has_status( 'active trialling' ) && $this->get_expiration_time() > current_time( 'mysql' ); |
|
755 | + return $this->has_status('active trialling') && $this->get_expiration_time() > current_time('mysql'); |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | /** |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | * @return bool |
762 | 762 | */ |
763 | 763 | public function is_expired() { |
764 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) ); |
|
764 | + return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql')); |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | /* |
@@ -776,11 +776,11 @@ discard block |
||
776 | 776 | /** |
777 | 777 | * Backwards compatibilty. |
778 | 778 | */ |
779 | - public function create( $data = array() ) { |
|
779 | + public function create($data = array()) { |
|
780 | 780 | |
781 | 781 | // Set the properties. |
782 | - if ( is_array( $data ) ) { |
|
783 | - $this->set_props( $data ); |
|
782 | + if (is_array($data)) { |
|
783 | + $this->set_props($data); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | // Save the item. |
@@ -791,8 +791,8 @@ discard block |
||
791 | 791 | /** |
792 | 792 | * Backwards compatibilty. |
793 | 793 | */ |
794 | - public function update( $args = array() ) { |
|
795 | - return $this->create( $args ); |
|
794 | + public function update($args = array()) { |
|
795 | + return $this->create($args); |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | /** |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | array( |
807 | 807 | 'post_parent' => $this->get_parent_payment_id(), |
808 | 808 | 'numberposts' => -1, |
809 | - 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
809 | + 'post_status' => array('publish', 'wpi-processing', 'wpi-renewal'), |
|
810 | 810 | 'orderby' => 'ID', |
811 | 811 | 'order' => 'DESC', |
812 | 812 | 'post_type' => 'wpi_invoice' |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | ); |
832 | 832 | |
833 | 833 | // Maybe include parent invoice. |
834 | - if ( ! $this->has_status( 'pending' ) ) { |
|
834 | + if (!$this->has_status('pending')) { |
|
835 | 835 | $count++; |
836 | 836 | } |
837 | 837 | |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | public function get_times_billed() { |
848 | 848 | $times_billed = $this->get_total_payments(); |
849 | 849 | |
850 | - if ( $this->has_trial_period() && $times_billed > 0 ) { |
|
850 | + if ($this->has_trial_period() && $times_billed > 0) { |
|
851 | 851 | $times_billed--; |
852 | 852 | } |
853 | 853 | |
@@ -862,49 +862,49 @@ discard block |
||
862 | 862 | * @param WPInv_Invoice $invoice If adding an existing invoice. |
863 | 863 | * @return bool |
864 | 864 | */ |
865 | - public function add_payment( $args = array(), $invoice = false ) { |
|
865 | + public function add_payment($args = array(), $invoice = false) { |
|
866 | 866 | |
867 | 867 | // Process each payment once. |
868 | - if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) { |
|
868 | + if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) { |
|
869 | 869 | return false; |
870 | 870 | } |
871 | 871 | |
872 | 872 | // Are we creating a new invoice? |
873 | - if ( empty( $invoice ) ) { |
|
873 | + if (empty($invoice)) { |
|
874 | 874 | $invoice = $this->create_payment(); |
875 | 875 | |
876 | - if ( empty( $invoice ) ) { |
|
876 | + if (empty($invoice)) { |
|
877 | 877 | return false; |
878 | 878 | } |
879 | 879 | |
880 | - $invoice->set_status( 'wpi-renewal' ); |
|
880 | + $invoice->set_status('wpi-renewal'); |
|
881 | 881 | |
882 | 882 | } |
883 | 883 | |
884 | 884 | // Maybe set a transaction id. |
885 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
886 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
885 | + if (!empty($args['transaction_id'])) { |
|
886 | + $invoice->set_transaction_id($args['transaction_id']); |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | // Set the completed date. |
890 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
890 | + $invoice->set_completed_date(current_time('mysql')); |
|
891 | 891 | |
892 | 892 | // And the gateway. |
893 | - if ( ! empty( $args['gateway'] ) ) { |
|
894 | - $invoice->set_gateway( $args['gateway'] ); |
|
893 | + if (!empty($args['gateway'])) { |
|
894 | + $invoice->set_gateway($args['gateway']); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | $invoice->save(); |
898 | 898 | |
899 | - if ( ! $invoice->get_id() ) { |
|
899 | + if (!$invoice->get_id()) { |
|
900 | 900 | return 0; |
901 | 901 | } |
902 | 902 | |
903 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
904 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
905 | - do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
|
903 | + do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this); |
|
904 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
905 | + do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id()); |
|
906 | 906 | |
907 | - update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
|
907 | + update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id); |
|
908 | 908 | |
909 | 909 | return $invoice->get_id(); |
910 | 910 | } |
@@ -919,21 +919,21 @@ discard block |
||
919 | 919 | |
920 | 920 | $parent_invoice = $this->get_parent_payment(); |
921 | 921 | |
922 | - if ( ! $parent_invoice->get_id() ) { |
|
922 | + if (!$parent_invoice->get_id()) { |
|
923 | 923 | return false; |
924 | 924 | } |
925 | 925 | |
926 | 926 | // Duplicate the parent invoice. |
927 | 927 | $invoice = new WPInv_Invoice(); |
928 | - $invoice->set_props( $parent_invoice->get_data() ); |
|
929 | - $invoice->set_id( 0 ); |
|
930 | - $invoice->set_items( $parent_invoice->get_items() ); |
|
931 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
932 | - $invoice->set_transaction_id( '' ); |
|
933 | - $invoice->set_key( $invoice->generate_key( 'renewal_' ) ); |
|
934 | - $invoice->set_number( '' ); |
|
935 | - $invoice->set_completed_date( '' ); |
|
936 | - $invoice->set_status( 'wpi-pending' ); |
|
928 | + $invoice->set_props($parent_invoice->get_data()); |
|
929 | + $invoice->set_id(0); |
|
930 | + $invoice->set_items($parent_invoice->get_items()); |
|
931 | + $invoice->set_parent_id($parent_invoice->get_id()); |
|
932 | + $invoice->set_transaction_id(''); |
|
933 | + $invoice->set_key($invoice->generate_key('renewal_')); |
|
934 | + $invoice->set_number(''); |
|
935 | + $invoice->set_completed_date(''); |
|
936 | + $invoice->set_status('wpi-pending'); |
|
937 | 937 | $invoice->recalculate_total(); |
938 | 938 | $invoice->save(); |
939 | 939 | |
@@ -949,20 +949,20 @@ discard block |
||
949 | 949 | public function renew() { |
950 | 950 | |
951 | 951 | // Complete subscription if applicable |
952 | - if ( $this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times() ) { |
|
952 | + if ($this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times()) { |
|
953 | 953 | return $this->complete(); |
954 | 954 | } |
955 | 955 | |
956 | 956 | // Calculate new expiration |
957 | 957 | $frequency = $this->get_frequency(); |
958 | 958 | $period = $this->get_period(); |
959 | - $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
959 | + $new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time()); |
|
960 | 960 | |
961 | - $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
962 | - $this->set_status( 'active' ); |
|
961 | + $this->set_expiration(date('Y-m-d H:i:s', $new_expiration)); |
|
962 | + $this->set_status('active'); |
|
963 | 963 | return $this->save(); |
964 | 964 | |
965 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
965 | + do_action('getpaid_subscription_renewed', $this); |
|
966 | 966 | |
967 | 967 | } |
968 | 968 | |
@@ -977,11 +977,11 @@ discard block |
||
977 | 977 | public function complete() { |
978 | 978 | |
979 | 979 | // Only mark a subscription as complete if it's not already cancelled. |
980 | - if ( $this->has_status( 'cancelled' ) ) { |
|
980 | + if ($this->has_status('cancelled')) { |
|
981 | 981 | return false; |
982 | 982 | } |
983 | 983 | |
984 | - $this->set_status( 'completed' ); |
|
984 | + $this->set_status('completed'); |
|
985 | 985 | return $this->save(); |
986 | 986 | |
987 | 987 | } |
@@ -993,14 +993,14 @@ discard block |
||
993 | 993 | * @param bool $check_expiration |
994 | 994 | * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
995 | 995 | */ |
996 | - public function expire( $check_expiration = false ) { |
|
996 | + public function expire($check_expiration = false) { |
|
997 | 997 | |
998 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
998 | + if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) { |
|
999 | 999 | // Do not mark as expired since real expiration date is in the future |
1000 | 1000 | return false; |
1001 | 1001 | } |
1002 | 1002 | |
1003 | - $this->set_status( 'expired' ); |
|
1003 | + $this->set_status('expired'); |
|
1004 | 1004 | return $this->save(); |
1005 | 1005 | |
1006 | 1006 | } |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | * @return int Subscription id. |
1013 | 1013 | */ |
1014 | 1014 | public function failing() { |
1015 | - $this->set_status( 'failing' ); |
|
1015 | + $this->set_status('failing'); |
|
1016 | 1016 | return $this->save(); |
1017 | 1017 | } |
1018 | 1018 | |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | * @return int Subscription id. |
1024 | 1024 | */ |
1025 | 1025 | public function cancel() { |
1026 | - $this->set_status( 'cancelled' ); |
|
1026 | + $this->set_status('cancelled'); |
|
1027 | 1027 | return $this->save(); |
1028 | 1028 | } |
1029 | 1029 | |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | * @return bool |
1035 | 1035 | */ |
1036 | 1036 | public function can_cancel() { |
1037 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1037 | + return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | /** |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | * @return array |
1046 | 1046 | */ |
1047 | 1047 | public function get_cancellable_statuses() { |
1048 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
1048 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | /** |
@@ -1055,8 +1055,8 @@ discard block |
||
1055 | 1055 | * @return string |
1056 | 1056 | */ |
1057 | 1057 | public function get_cancel_url() { |
1058 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->get_id() ) ), 'wpinv-recurring-cancel' ); |
|
1059 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1058 | + $url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'cancel_subscription', 'sub_id' => $this->get_id())), 'wpinv-recurring-cancel'); |
|
1059 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | /** |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | * @return bool |
1070 | 1070 | */ |
1071 | 1071 | public function can_renew() { |
1072 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1072 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | /** |
@@ -1079,8 +1079,8 @@ discard block |
||
1079 | 1079 | * @return string |
1080 | 1080 | */ |
1081 | 1081 | public function get_renew_url() { |
1082 | - $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'wpinv-recurring-renew' ); |
|
1083 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1082 | + $url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'wpinv-recurring-renew'); |
|
1083 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | /** |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | * @return bool |
1091 | 1091 | */ |
1092 | 1092 | public function can_update() { |
1093 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1093 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | /** |
@@ -1100,8 +1100,8 @@ discard block |
||
1100 | 1100 | * @return string |
1101 | 1101 | */ |
1102 | 1102 | public function get_update_url() { |
1103 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1104 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1103 | + $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id())); |
|
1104 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | /** |
@@ -1111,7 +1111,7 @@ discard block |
||
1111 | 1111 | * @return string |
1112 | 1112 | */ |
1113 | 1113 | public function get_status_label() { |
1114 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1114 | + return getpaid_get_subscription_status_label($this->get_status()); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | /** |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | */ |
1123 | 1123 | public function get_status_class() { |
1124 | 1124 | $statuses = getpaid_get_subscription_status_classes(); |
1125 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary'; |
|
1125 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'text-white bg-secondary'; |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | /** |
@@ -1133,9 +1133,9 @@ discard block |
||
1133 | 1133 | */ |
1134 | 1134 | public function get_status_label_html() { |
1135 | 1135 | |
1136 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1137 | - $class = esc_attr( $this->get_status_class() ); |
|
1138 | - $status = sanitize_html_class( $this->get_status_label() ); |
|
1136 | + $status_label = sanitize_text_field($this->get_status_label()); |
|
1137 | + $class = esc_attr($this->get_status_class()); |
|
1138 | + $status = sanitize_html_class($this->get_status_label()); |
|
1139 | 1139 | |
1140 | 1140 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded $class $status'>$status_label</span></span>"; |
1141 | 1141 | } |
@@ -1147,9 +1147,9 @@ discard block |
||
1147 | 1147 | * @param string $txn_id The transaction ID from the merchant processor |
1148 | 1148 | * @return bool |
1149 | 1149 | */ |
1150 | - public function payment_exists( $txn_id = '' ) { |
|
1151 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1152 | - return ! empty( $invoice_id ); |
|
1150 | + public function payment_exists($txn_id = '') { |
|
1151 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id'); |
|
1152 | + return !empty($invoice_id); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | /** |
@@ -1161,35 +1161,35 @@ discard block |
||
1161 | 1161 | // Reset status transition variable. |
1162 | 1162 | $this->status_transition = false; |
1163 | 1163 | |
1164 | - if ( $status_transition ) { |
|
1164 | + if ($status_transition) { |
|
1165 | 1165 | try { |
1166 | 1166 | |
1167 | 1167 | // Fire a hook for the status change. |
1168 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1169 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1168 | + do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
1169 | + do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition); |
|
1170 | 1170 | |
1171 | - if ( ! empty( $status_transition['from'] ) ) { |
|
1171 | + if (!empty($status_transition['from'])) { |
|
1172 | 1172 | |
1173 | 1173 | /* translators: 1: old subscription status 2: new subscription status */ |
1174 | - $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'] ) ); |
|
1174 | + $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'])); |
|
1175 | 1175 | |
1176 | 1176 | // Fire another hook. |
1177 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1178 | - do_action( 'getpaid_subscription_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
1177 | + do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
1178 | + do_action('getpaid_subscription_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this); |
|
1179 | 1179 | |
1180 | 1180 | // Note the transition occurred. |
1181 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1181 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1182 | 1182 | |
1183 | 1183 | } else { |
1184 | 1184 | /* translators: %s: new invoice status */ |
1185 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1185 | + $transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1186 | 1186 | |
1187 | 1187 | // Note the transition occurred. |
1188 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1188 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1189 | 1189 | |
1190 | 1190 | } |
1191 | - } catch ( Exception $e ) { |
|
1192 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1191 | + } catch (Exception $e) { |
|
1192 | + $this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
1193 | 1193 | } |
1194 | 1194 | } |
1195 | 1195 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains functions that display the subscriptions admin page. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Render the Subscriptions page |
@@ -17,22 +17,22 @@ discard block |
||
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div class="wrap"> |
20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
21 | 21 | <div class="bsui"> |
22 | 22 | |
23 | 23 | <?php |
24 | 24 | |
25 | 25 | // Verify user permissions. |
26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
27 | 27 | |
28 | 28 | echo aui()->alert( |
29 | 29 | array( |
30 | 30 | 'type' => 'danger', |
31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
36 | 36 | |
37 | 37 | // Display a single subscription. |
38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | function wpinv_recurring_subscription_details() { |
82 | 82 | |
83 | 83 | // Fetch the subscription. |
84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
85 | - if ( ! $sub->get_id() ) { |
|
84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
85 | + if (!$sub->get_id()) { |
|
86 | 86 | |
87 | 87 | echo aui()->alert( |
88 | 88 | array( |
89 | 89 | 'type' => 'danger', |
90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
91 | 91 | ) |
92 | 92 | ); |
93 | 93 | |
@@ -95,31 +95,31 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | // Use metaboxes to display the subscription details. |
98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' ); |
|
99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
100 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
101 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal'); |
|
99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
100 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
101 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
102 | 102 | |
103 | 103 | ?> |
104 | 104 | |
105 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
105 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
106 | 106 | |
107 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
108 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
109 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
107 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
108 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
109 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
110 | 110 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
111 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
111 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
112 | 112 | |
113 | 113 | <div id="poststuff"> |
114 | 114 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
115 | 115 | |
116 | 116 | <div id="postbox-container-1" class="postbox-container"> |
117 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
117 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
118 | 118 | </div> |
119 | 119 | |
120 | 120 | <div id="postbox-container-2" class="postbox-container"> |
121 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
122 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
121 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
122 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
123 | 123 | </div> |
124 | 124 | |
125 | 125 | </div> |
@@ -138,27 +138,27 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @param WPInv_Subscription $sub |
140 | 140 | */ |
141 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
141 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
142 | 142 | |
143 | 143 | // Prepare subscription detail columns. |
144 | 144 | $fields = apply_filters( |
145 | 145 | 'getpaid_subscription_admin_page_fields', |
146 | 146 | array( |
147 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
148 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
149 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
150 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
151 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
152 | - 'renewals' => __( 'Renewals', 'invoicing' ), |
|
153 | - 'item' => __( 'Item', 'invoicing' ), |
|
154 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
155 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
156 | - 'status' => __( 'Status', 'invoicing' ), |
|
147 | + 'subscription' => __('Subscription', 'invoicing'), |
|
148 | + 'customer' => __('Customer', 'invoicing'), |
|
149 | + 'amount' => __('Amount', 'invoicing'), |
|
150 | + 'start_date' => __('Start Date', 'invoicing'), |
|
151 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
152 | + 'renewals' => __('Renewals', 'invoicing'), |
|
153 | + 'item' => __('Item', 'invoicing'), |
|
154 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
155 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
156 | + 'status' => __('Status', 'invoicing'), |
|
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | - if ( ! $sub->is_active() && isset( $fields['renews_on'] ) ) { |
|
161 | - unset( $fields['renews_on'] ); |
|
160 | + if (!$sub->is_active() && isset($fields['renews_on'])) { |
|
161 | + unset($fields['renews_on']); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | ?> |
@@ -166,16 +166,16 @@ discard block |
||
166 | 166 | <table class="table table-borderless" style="font-size: 14px;"> |
167 | 167 | <tbody> |
168 | 168 | |
169 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
169 | + <?php foreach ($fields as $key => $label) : ?> |
|
170 | 170 | |
171 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
171 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
172 | 172 | |
173 | 173 | <th class="w-25" style="font-weight: 500;"> |
174 | - <?php echo sanitize_text_field( $label ); ?> |
|
174 | + <?php echo sanitize_text_field($label); ?> |
|
175 | 175 | </th> |
176 | 176 | |
177 | 177 | <td class="w-75 text-muted"> |
178 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub ); ?> |
|
178 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub); ?> |
|
179 | 179 | </td> |
180 | 180 | |
181 | 181 | </tr> |
@@ -193,201 +193,201 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param WPInv_Subscription $subscription |
195 | 195 | */ |
196 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
196 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
197 | 197 | |
198 | - $username = __( '(Missing User)', 'invoicing' ); |
|
198 | + $username = __('(Missing User)', 'invoicing'); |
|
199 | 199 | |
200 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
201 | - if ( $user ) { |
|
200 | + $user = get_userdata($subscription->get_customer_id()); |
|
201 | + if ($user) { |
|
202 | 202 | |
203 | 203 | $username = sprintf( |
204 | 204 | '<a href="user-edit.php?user_id=%s">%s</a>', |
205 | - absint( $user->ID ), |
|
206 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
205 | + absint($user->ID), |
|
206 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | } |
210 | 210 | |
211 | 211 | echo $username; |
212 | 212 | } |
213 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
213 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
214 | 214 | |
215 | 215 | /** |
216 | 216 | * Displays the subscription amount. |
217 | 217 | * |
218 | 218 | * @param WPInv_Subscription $subscription |
219 | 219 | */ |
220 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
220 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
221 | 221 | |
222 | - $initial = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_initial_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
223 | - $recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() ); |
|
224 | - $period = 1 == $subscription->get_frequency() ? getpaid_get_subscription_period_label( $subscription->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->get_period(),$subscription->get_frequency() ); |
|
222 | + $initial = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($subscription->get_initial_amount())), $subscription->get_parent_payment()->get_currency()); |
|
223 | + $recurring = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($subscription->get_recurring_amount())), $subscription->get_parent_payment()->get_currency()); |
|
224 | + $period = 1 == $subscription->get_frequency() ? getpaid_get_subscription_period_label($subscription->get_period()) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->get_period(), $subscription->get_frequency()); |
|
225 | 225 | |
226 | - if ( $subscription->has_trial_period() ) { |
|
226 | + if ($subscription->has_trial_period()) { |
|
227 | 227 | |
228 | 228 | // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period |
229 | 229 | $amount = sprintf( |
230 | - _x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ), |
|
230 | + _x('%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'), |
|
231 | 231 | $initial, |
232 | - sanitize_text_field( $subscription->get_trial_period() ), |
|
232 | + sanitize_text_field($subscription->get_trial_period()), |
|
233 | 233 | $recurring, |
234 | - sanitize_text_field( strtolower( $period ) ) |
|
234 | + sanitize_text_field(strtolower($period)) |
|
235 | 235 | ); |
236 | 236 | |
237 | - } else if ( $initial != $recurring ) { |
|
237 | + } else if ($initial != $recurring) { |
|
238 | 238 | |
239 | 239 | // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio |
240 | 240 | $amount = sprintf( |
241 | - _x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ), |
|
241 | + _x('Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing'), |
|
242 | 242 | $initial, |
243 | 243 | $recurring, |
244 | - sanitize_text_field( strtolower( $period ) ) |
|
244 | + sanitize_text_field(strtolower($period)) |
|
245 | 245 | ); |
246 | 246 | |
247 | 247 | } else { |
248 | 248 | |
249 | 249 | // translators: $1: is the recurring amount, $2: is the recurring period |
250 | 250 | $amount = sprintf( |
251 | - _x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ), |
|
251 | + _x('%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing'), |
|
252 | 252 | $initial, |
253 | - sanitize_text_field( strtolower( $period ) ) |
|
253 | + sanitize_text_field(strtolower($period)) |
|
254 | 254 | ); |
255 | 255 | |
256 | 256 | } |
257 | 257 | |
258 | 258 | echo "<span>$amount</span>"; |
259 | 259 | } |
260 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
260 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * Displays the subscription id. |
264 | 264 | * |
265 | 265 | * @param WPInv_Subscription $subscription |
266 | 266 | */ |
267 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
268 | - echo '#' . absint( $subscription->get_id() ); |
|
267 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
268 | + echo '#' . absint($subscription->get_id()); |
|
269 | 269 | } |
270 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
270 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
271 | 271 | |
272 | 272 | /** |
273 | 273 | * Displays the subscription renewal date. |
274 | 274 | * |
275 | 275 | * @param WPInv_Subscription $subscription |
276 | 276 | */ |
277 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
277 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
278 | 278 | |
279 | 279 | $created = $subscription->get_date_created(); |
280 | - if ( empty( $created ) || '0000-00-00 00:00:00' == $created ) { |
|
280 | + if (empty($created) || '0000-00-00 00:00:00' == $created) { |
|
281 | 281 | echo "—"; |
282 | 282 | } else { |
283 | - echo date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $created ) ); |
|
283 | + echo date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($created)); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | } |
287 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
287 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
288 | 288 | |
289 | 289 | /** |
290 | 290 | * Displays the subscription renewal date. |
291 | 291 | * |
292 | 292 | * @param WPInv_Subscription $subscription |
293 | 293 | */ |
294 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
294 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
295 | 295 | |
296 | 296 | $expiration = $subscription->get_expiration(); |
297 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
297 | + if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) { |
|
298 | 298 | echo "—"; |
299 | 299 | } else { |
300 | - echo date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $expiration ) ); |
|
300 | + echo date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($expiration)); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | } |
304 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
304 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Displays the subscription renewal count. |
308 | 308 | * |
309 | 309 | * @param WPInv_Subscription $subscription |
310 | 310 | */ |
311 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
311 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
312 | 312 | $max_bills = $subscription->get_bill_times(); |
313 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
313 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
314 | 314 | } |
315 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
315 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
316 | 316 | |
317 | 317 | /** |
318 | 318 | * Displays the subscription item. |
319 | 319 | * |
320 | 320 | * @param WPInv_Subscription $subscription |
321 | 321 | */ |
322 | -function getpaid_admin_subscription_metabox_display_item( $subscription ) { |
|
322 | +function getpaid_admin_subscription_metabox_display_item($subscription) { |
|
323 | 323 | |
324 | - $item = get_post( $subscription->get_product_id() ); |
|
324 | + $item = get_post($subscription->get_product_id()); |
|
325 | 325 | |
326 | - if ( ! empty( $item ) ) { |
|
327 | - $link = get_edit_post_link( $item ); |
|
328 | - $link = esc_url( $link ); |
|
329 | - $name = esc_html( get_the_title( $item ) ); |
|
326 | + if (!empty($item)) { |
|
327 | + $link = get_edit_post_link($item); |
|
328 | + $link = esc_url($link); |
|
329 | + $name = esc_html(get_the_title($item)); |
|
330 | 330 | echo "<a href='$link'>$name</a>"; |
331 | 331 | } else { |
332 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
332 | + echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id()); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | } |
336 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' ); |
|
336 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item'); |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * Displays the subscription gateway. |
340 | 340 | * |
341 | 341 | * @param WPInv_Subscription $subscription |
342 | 342 | */ |
343 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
343 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
344 | 344 | |
345 | 345 | $gateway = $subscription->get_gateway(); |
346 | 346 | |
347 | - if ( ! empty( $gateway ) ) { |
|
348 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
347 | + if (!empty($gateway)) { |
|
348 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
349 | 349 | } else { |
350 | 350 | echo "—"; |
351 | 351 | } |
352 | 352 | |
353 | 353 | } |
354 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
354 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * Displays the subscription status. |
358 | 358 | * |
359 | 359 | * @param WPInv_Subscription $subscription |
360 | 360 | */ |
361 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
361 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
362 | 362 | echo $subscription->get_status_label_html(); |
363 | 363 | } |
364 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
364 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
365 | 365 | |
366 | 366 | /** |
367 | 367 | * Displays the subscription profile id. |
368 | 368 | * |
369 | 369 | * @param WPInv_Subscription $subscription |
370 | 370 | */ |
371 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
371 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
372 | 372 | |
373 | 373 | $profile_id = $subscription->get_profile_id(); |
374 | 374 | |
375 | - if ( ! empty( $profile_id ) ) { |
|
376 | - $profile_id = sanitize_text_field( $profile_id ); |
|
377 | - echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription ); |
|
375 | + if (!empty($profile_id)) { |
|
376 | + $profile_id = sanitize_text_field($profile_id); |
|
377 | + echo apply_filters('getpaid_subscription_profile_id_display', $profile_id, $subscription); |
|
378 | 378 | } else { |
379 | 379 | echo "—"; |
380 | 380 | } |
381 | 381 | |
382 | 382 | } |
383 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
383 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
384 | 384 | |
385 | 385 | /** |
386 | 386 | * Displays the subscriptions update metabox. |
387 | 387 | * |
388 | 388 | * @param WPInv_Subscription $subscription |
389 | 389 | */ |
390 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
390 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
391 | 391 | |
392 | 392 | ?> |
393 | 393 | <div class="mt-3"> |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | 'id' => 'subscription_status_update_select', |
401 | 401 | 'required' => true, |
402 | 402 | 'no_wrap' => false, |
403 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
404 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
403 | + 'label' => __('Subscription Status', 'invoicing'), |
|
404 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
405 | 405 | 'select2' => true, |
406 | - 'value' => $subscription->get_status( 'edit' ), |
|
406 | + 'value' => $subscription->get_status('edit'), |
|
407 | 407 | ) |
408 | 408 | ); |
409 | 409 | ?> |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
412 | 412 | |
413 | 413 | <?php |
414 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
414 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
415 | 415 | |
416 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
417 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
418 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
416 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
417 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
418 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
419 | 419 | |
420 | - if ( $subscription->is_active() ) { |
|
420 | + if ($subscription->is_active()) { |
|
421 | 421 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
422 | 422 | } |
423 | 423 | |
@@ -429,17 +429,17 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @param WPInv_Subscription $subscription |
431 | 431 | */ |
432 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription ) { |
|
432 | +function getpaid_admin_subscription_invoice_details_metabox($subscription) { |
|
433 | 433 | |
434 | 434 | $columns = apply_filters( |
435 | 435 | 'getpaid_subscription_related_invoices_columns', |
436 | 436 | array( |
437 | 437 | |
438 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
439 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
440 | - 'date' => __( 'Date', 'invoicing' ), |
|
441 | - 'status' => __( 'Status', 'invoicing' ), |
|
442 | - 'total' => __( 'Total', 'invoicing' ), |
|
438 | + 'invoice' => __('Invoice', 'invoicing'), |
|
439 | + 'relationship' => __('Relationship', 'invoicing'), |
|
440 | + 'date' => __('Date', 'invoicing'), |
|
441 | + 'status' => __('Status', 'invoicing'), |
|
442 | + 'total' => __('Total', 'invoicing'), |
|
443 | 443 | ) |
444 | 444 | ); |
445 | 445 | |
@@ -447,8 +447,8 @@ discard block |
||
447 | 447 | $payments = $subscription->get_child_payments(); |
448 | 448 | $parent = $subscription->get_parent_invoice(); |
449 | 449 | |
450 | - if ( $parent->get_id() ) { |
|
451 | - $payments = array_merge( array( $parent ), $payments ); |
|
450 | + if ($parent->get_id()) { |
|
451 | + $payments = array_merge(array($parent), $payments); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | ?> |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | <thead> |
460 | 460 | <tr> |
461 | 461 | <?php |
462 | - foreach ( $columns as $key => $label ) { |
|
463 | - $key = esc_attr( $key ); |
|
464 | - $label = sanitize_text_field( $label ); |
|
462 | + foreach ($columns as $key => $label) { |
|
463 | + $key = esc_attr($key); |
|
464 | + $label = sanitize_text_field($label); |
|
465 | 465 | |
466 | 466 | echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>"; |
467 | 467 | } |
@@ -473,36 +473,36 @@ discard block |
||
473 | 473 | |
474 | 474 | <?php |
475 | 475 | |
476 | - foreach( $payments as $payment ) : |
|
476 | + foreach ($payments as $payment) : |
|
477 | 477 | |
478 | 478 | // Ensure that we have an invoice. |
479 | - if ( ! is_a( $payment, 'WPInv_Invoice' ) ) { |
|
480 | - $payment = new WPInv_Invoice( $payment ); |
|
479 | + if (!is_a($payment, 'WPInv_Invoice')) { |
|
480 | + $payment = new WPInv_Invoice($payment); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | // Abort if the invoice is invalid. |
484 | - if ( ! $payment->get_id() ) { |
|
484 | + if (!$payment->get_id()) { |
|
485 | 485 | continue; |
486 | 486 | } |
487 | 487 | |
488 | 488 | echo '<tr>'; |
489 | 489 | |
490 | - foreach ( array_keys( $columns ) as $key ) { |
|
490 | + foreach (array_keys($columns) as $key) { |
|
491 | 491 | |
492 | 492 | echo '<td class="p-2 text-left">'; |
493 | 493 | |
494 | - switch( $key ) { |
|
494 | + switch ($key) { |
|
495 | 495 | |
496 | 496 | case 'total': |
497 | - echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total ) ), $payment->get_currency() ) . '</strong>'; |
|
497 | + echo '<strong>' . wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($payment->get_total)), $payment->get_currency()) . '</strong>'; |
|
498 | 498 | break; |
499 | 499 | |
500 | 500 | case 'relationship': |
501 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
501 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
502 | 502 | break; |
503 | 503 | |
504 | 504 | case 'date': |
505 | - echo date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $payment->get_date_created() ) ); |
|
505 | + echo date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($payment->get_date_created())); |
|
506 | 506 | break; |
507 | 507 | |
508 | 508 | case 'status': |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | break; |
511 | 511 | |
512 | 512 | case 'invoice': |
513 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
514 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
513 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
514 | + $invoice = sanitize_text_field($payment->get_number()); |
|
515 | 515 | echo "<a href='$link'>$invoice</a>"; |
516 | 516 | break; |
517 | 517 | } |
@@ -543,30 +543,30 @@ discard block |
||
543 | 543 | */ |
544 | 544 | function wpinv_recurring_process_subscription_deletion() { |
545 | 545 | |
546 | - if( empty( $_POST['sub_id'] ) ) { |
|
546 | + if (empty($_POST['sub_id'])) { |
|
547 | 547 | return; |
548 | 548 | } |
549 | 549 | |
550 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
550 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
551 | 551 | return; |
552 | 552 | } |
553 | 553 | |
554 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
554 | + if (!current_user_can('manage_invoicing')) { |
|
555 | 555 | return; |
556 | 556 | } |
557 | 557 | |
558 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
559 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
558 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
559 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
560 | 560 | } |
561 | 561 | |
562 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
562 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
563 | 563 | |
564 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
564 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
565 | 565 | |
566 | 566 | $subscription->delete(); |
567 | 567 | |
568 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
568 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
569 | 569 | exit; |
570 | 570 | |
571 | 571 | } |
572 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
572 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * The main admin class. |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * Class constructor. |
32 | 32 | */ |
33 | - public function __construct(){ |
|
33 | + public function __construct() { |
|
34 | 34 | |
35 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
36 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
35 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
36 | + $this->admin_url = plugins_url('/', __FILE__); |
|
37 | 37 | |
38 | - if ( is_admin() ) { |
|
38 | + if (is_admin()) { |
|
39 | 39 | $this->init_admin_hooks(); |
40 | 40 | } |
41 | 41 | |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | * |
47 | 47 | */ |
48 | 48 | private function init_admin_hooks() { |
49 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
|
50 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
51 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
52 | - add_action( 'admin_init', array( $this, 'activation_redirect') ); |
|
53 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
|
54 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
55 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
49 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts')); |
|
50 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
51 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
52 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
53 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
54 | + add_action('admin_notices', array($this, 'show_notices')); |
|
55 | + do_action('getpaid_init_admin_hooks', $this); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -62,48 +62,48 @@ discard block |
||
62 | 62 | public function enqeue_scripts() { |
63 | 63 | global $current_screen; |
64 | 64 | |
65 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
65 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
66 | 66 | |
67 | - if ( ! empty( $current_screen->post_type ) ) { |
|
67 | + if (!empty($current_screen->post_type)) { |
|
68 | 68 | $page = $current_screen->post_type; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // General styles. |
72 | - if ( false!== stripos( $page, 'wpi' ) ) { |
|
72 | + if (false !== stripos($page, 'wpi')) { |
|
73 | 73 | |
74 | 74 | // Styles. |
75 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
76 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
77 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
78 | - wp_enqueue_style( 'wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
79 | - wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' ); |
|
75 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
76 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
77 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
78 | + wp_enqueue_style('wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
79 | + wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16'); |
|
80 | 80 | |
81 | 81 | // Scripts. |
82 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true ); |
|
83 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
82 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true); |
|
83 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
84 | 84 | |
85 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
86 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ), $version ); |
|
87 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
85 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
86 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version); |
|
87 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Payment form scripts. |
92 | - if ( 'wpi_payment_form' == $page ) { |
|
92 | + if ('wpi_payment_form' == $page) { |
|
93 | 93 | $this->load_payment_form_scripts(); |
94 | 94 | } |
95 | 95 | |
96 | - if ( $page == 'wpinv-subscriptions' ) { |
|
97 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
98 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
96 | + if ($page == 'wpinv-subscriptions') { |
|
97 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
98 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( $page == 'wpinv-reports' ) { |
|
102 | - wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' ); |
|
101 | + if ($page == 'wpinv-reports') { |
|
102 | + wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7'); |
|
103 | 103 | } |
104 | 104 | |
105 | - if ( $page == 'wpinv-subscriptions' ) { |
|
106 | - wp_enqueue_script( 'postbox' ); |
|
105 | + if ($page == 'wpinv-subscriptions') { |
|
106 | + wp_enqueue_script('postbox'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | } |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | global $post; |
117 | 117 | |
118 | 118 | return array( |
119 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
120 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
121 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
122 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
123 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
124 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
125 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
119 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
120 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
121 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
122 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
123 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
124 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
125 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
126 | 126 | 'tax' => wpinv_tax_amount(), |
127 | 127 | 'discount' => wpinv_discount_amount(), |
128 | 128 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -130,24 +130,24 @@ discard block |
||
130 | 130 | 'thousand_sep' => wpinv_thousands_separator(), |
131 | 131 | 'decimal_sep' => wpinv_decimal_separator(), |
132 | 132 | 'decimals' => wpinv_decimals(), |
133 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
134 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
135 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
136 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
137 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
138 | - 'OneItemMin' => __( 'Invoice must contain at least one item', 'invoicing' ), |
|
139 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
140 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
141 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
142 | - 'emptyInvoice' => __( 'Add at least one item to save invoice!', 'invoicing' ), |
|
143 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
144 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
145 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
146 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
147 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
148 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
149 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
150 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
133 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
134 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
135 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
136 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
137 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
138 | + 'OneItemMin' => __('Invoice must contain at least one item', 'invoicing'), |
|
139 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
140 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
141 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
142 | + 'emptyInvoice' => __('Add at least one item to save invoice!', 'invoicing'), |
|
143 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
144 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
145 | + 'action_edit' => __('Edit', 'invoicing'), |
|
146 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
147 | + 'item_description' => __('Item Description', 'invoicing'), |
|
148 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
149 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
150 | + 'searching' => __('Searching', 'invoicing'), |
|
151 | 151 | ); |
152 | 152 | |
153 | 153 | } |
@@ -159,31 +159,31 @@ discard block |
||
159 | 159 | protected function load_payment_form_scripts() { |
160 | 160 | global $post; |
161 | 161 | |
162 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
163 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
164 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
162 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
163 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
164 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
165 | 165 | |
166 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
167 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
166 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
167 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
168 | 168 | |
169 | 169 | wp_localize_script( |
170 | 170 | 'wpinv-admin-payment-form-script', |
171 | 171 | 'wpinvPaymentFormAdmin', |
172 | 172 | array( |
173 | 173 | 'elements' => $this->form_elements->get_elements(), |
174 | - 'form_elements' => $this->form_elements->get_form_elements( $post->ID ), |
|
174 | + 'form_elements' => $this->form_elements->get_form_elements($post->ID), |
|
175 | 175 | 'all_items' => $this->form_elements->get_published_items(), |
176 | 176 | 'currency' => wpinv_currency_symbol(), |
177 | 177 | 'position' => wpinv_currency_position(), |
178 | 178 | 'decimals' => (int) wpinv_decimals(), |
179 | 179 | 'thousands_sep' => wpinv_thousands_separator(), |
180 | 180 | 'decimals_sep' => wpinv_decimal_separator(), |
181 | - 'form_items' => $this->form_elements->get_form_items( $post->ID ), |
|
181 | + 'form_items' => $this->form_elements->get_form_items($post->ID), |
|
182 | 182 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
183 | 183 | ) |
184 | 184 | ); |
185 | 185 | |
186 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
186 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
@@ -194,25 +194,25 @@ discard block |
||
194 | 194 | * @return string |
195 | 195 | * |
196 | 196 | */ |
197 | - public function admin_body_class( $classes ) { |
|
197 | + public function admin_body_class($classes) { |
|
198 | 198 | global $pagenow, $post, $current_screen; |
199 | 199 | |
200 | 200 | |
201 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
201 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
202 | 202 | |
203 | - if ( ! empty( $current_screen->post_type ) ) { |
|
203 | + if (!empty($current_screen->post_type)) { |
|
204 | 204 | $page = $current_screen->post_type; |
205 | 205 | } |
206 | 206 | |
207 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
208 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
207 | + if (false !== stripos($page, 'wpi')) { |
|
208 | + $classes .= ' wpi-' . sanitize_key($page); |
|
209 | 209 | } |
210 | 210 | |
211 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
211 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
212 | 212 | $classes .= ' wpinv-cpt wpinv'; |
213 | 213 | } |
214 | 214 | |
215 | - if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) { |
|
215 | + if ($pagenow == 'post.php' && $page == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
216 | 216 | $classes .= ' wpi-editable-n'; |
217 | 217 | } |
218 | 218 | |
@@ -222,19 +222,19 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * Maybe show the AyeCode Connect Notice. |
224 | 224 | */ |
225 | - public function init_ayecode_connect_helper(){ |
|
225 | + public function init_ayecode_connect_helper() { |
|
226 | 226 | |
227 | 227 | new AyeCode_Connect_Helper( |
228 | 228 | array( |
229 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
230 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
231 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
232 | - 'connect_button' => __("Connect Site","invoicing"), |
|
233 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
234 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
235 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
229 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
230 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
231 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
232 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
233 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
234 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
235 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
236 | 236 | ), |
237 | - array( 'wpi-addons' ) |
|
237 | + array('wpi-addons') |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | } |
@@ -245,19 +245,19 @@ discard block |
||
245 | 245 | public function activation_redirect() { |
246 | 246 | |
247 | 247 | // Bail if no activation redirect. |
248 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || is_ajax() ) { |
|
248 | + if (!get_transient('_wpinv_activation_redirect') || is_ajax()) { |
|
249 | 249 | return; |
250 | 250 | } |
251 | 251 | |
252 | 252 | // Delete the redirect transient. |
253 | - delete_transient( '_wpinv_activation_redirect' ); |
|
253 | + delete_transient('_wpinv_activation_redirect'); |
|
254 | 254 | |
255 | 255 | // Bail if activating from network, or bulk |
256 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
256 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
260 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
261 | 261 | exit; |
262 | 262 | } |
263 | 263 | |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function maybe_do_admin_action() { |
268 | 268 | |
269 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
270 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
271 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
269 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
270 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
271 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | } |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | * @return array |
281 | 281 | */ |
282 | 282 | public function get_notices() { |
283 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
284 | - return is_array( $notices ) ? $notices : array(); |
|
283 | + $notices = get_option('wpinv_admin_notices'); |
|
284 | + return is_array($notices) ? $notices : array(); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @since 1.0.19 |
292 | 292 | */ |
293 | 293 | public function clear_notices() { |
294 | - delete_option( 'wpinv_admin_notices' ); |
|
294 | + delete_option('wpinv_admin_notices'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | * @access public |
301 | 301 | * @since 1.0.19 |
302 | 302 | */ |
303 | - public function save_notice( $type, $message ) { |
|
303 | + public function save_notice($type, $message) { |
|
304 | 304 | $notices = $this->get_notices(); |
305 | 305 | |
306 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
307 | - $notices[ $type ] = array(); |
|
306 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
307 | + $notices[$type] = array(); |
|
308 | 308 | } |
309 | 309 | |
310 | - $notices[ $type ][] = $message; |
|
310 | + $notices[$type][] = $message; |
|
311 | 311 | |
312 | - update_option( 'wpinv_admin_notices', $notices ); |
|
312 | + update_option('wpinv_admin_notices', $notices); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @access public |
320 | 320 | * @since 1.0.19 |
321 | 321 | */ |
322 | - public function show_success( $msg ) { |
|
323 | - $this->save_notice( 'success', $msg ); |
|
322 | + public function show_success($msg) { |
|
323 | + $this->save_notice('success', $msg); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | * @param string $msg The message to qeue. |
331 | 331 | * @since 1.0.19 |
332 | 332 | */ |
333 | - public function show_error( $msg ) { |
|
334 | - $this->save_notice( 'error', $msg ); |
|
333 | + public function show_error($msg) { |
|
334 | + $this->save_notice('error', $msg); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | * @param string $msg The message to qeue. |
342 | 342 | * @since 1.0.19 |
343 | 343 | */ |
344 | - public function show_warning( $msg ) { |
|
345 | - $this->save_notice( 'warning', $msg ); |
|
344 | + public function show_warning($msg) { |
|
345 | + $this->save_notice('warning', $msg); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | * @param string $msg The message to qeue. |
353 | 353 | * @since 1.0.19 |
354 | 354 | */ |
355 | - public function show_info( $msg ) { |
|
356 | - $this->save_notice( 'info', $msg ); |
|
355 | + public function show_info($msg) { |
|
356 | + $this->save_notice('info', $msg); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -367,15 +367,15 @@ discard block |
||
367 | 367 | $notices = $this->get_notices(); |
368 | 368 | $this->clear_notices(); |
369 | 369 | |
370 | - foreach ( $notices as $type => $messages ) { |
|
370 | + foreach ($notices as $type => $messages) { |
|
371 | 371 | |
372 | - if ( ! is_array( $messages ) ) { |
|
372 | + if (!is_array($messages)) { |
|
373 | 373 | continue; |
374 | 374 | } |
375 | 375 | |
376 | - $type = sanitize_key( $type ); |
|
377 | - foreach ( $messages as $message ) { |
|
378 | - $message = wp_kses_post( $message ); |
|
376 | + $type = sanitize_key($type); |
|
377 | + foreach ($messages as $message) { |
|
378 | + $message = wp_kses_post($message); |
|
379 | 379 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
380 | 380 | } |
381 | 381 |