@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = esc_attr( $option['desc'] ); |
|
201 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
202 | - unset( $option['desc'] ); |
|
203 | - } |
|
199 | + if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | + $tip = esc_attr( $option['desc'] ); |
|
201 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
202 | + unset( $option['desc'] ); |
|
203 | + } |
|
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
@@ -279,10 +279,10 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | // General filter |
282 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
282 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
283 | 283 | |
284 | - // Key specific filter. |
|
285 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
284 | + // Key specific filter. |
|
285 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -338,14 +338,14 @@ discard block |
||
338 | 338 | |
339 | 339 | foreach ( $new_rates as $rate ) { |
340 | 340 | |
341 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
342 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
343 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
344 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
345 | - $rate['global'] = empty( $rate['state'] ); |
|
346 | - $tax_rates[] = $rate; |
|
341 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
342 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
343 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
344 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
345 | + $rate['global'] = empty( $rate['state'] ); |
|
346 | + $tax_rates[] = $rate; |
|
347 | 347 | |
348 | - } |
|
348 | + } |
|
349 | 349 | |
350 | 350 | update_option( 'wpinv_tax_rates', $tax_rates ); |
351 | 351 | |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | ) ), |
403 | 403 | 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
404 | 404 | 'main' => __( 'Tax Settings', 'invoicing' ), |
405 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
406 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
405 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
406 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
407 | 407 | ) ), |
408 | 408 | 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
409 | 409 | 'main' => __( 'Email Settings', 'invoicing' ), |
@@ -426,51 +426,51 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
429 | - $pages_options = array(); |
|
429 | + $pages_options = array(); |
|
430 | 430 | |
431 | - if( $default_label !== NULL && $default_label !== false ) { |
|
432 | - $pages_options = array( '' => $default_label ); // Blank option |
|
433 | - } |
|
431 | + if( $default_label !== NULL && $default_label !== false ) { |
|
432 | + $pages_options = array( '' => $default_label ); // Blank option |
|
433 | + } |
|
434 | 434 | |
435 | - $pages = get_pages(); |
|
436 | - if ( $pages ) { |
|
437 | - foreach ( $pages as $page ) { |
|
438 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
435 | + $pages = get_pages(); |
|
436 | + if ( $pages ) { |
|
437 | + foreach ( $pages as $page ) { |
|
438 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
439 | 439 | $pages_options[ $page->ID ] = $title; |
440 | - } |
|
441 | - } |
|
440 | + } |
|
441 | + } |
|
442 | 442 | |
443 | - return $pages_options; |
|
443 | + return $pages_options; |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | function wpinv_header_callback( $args ) { |
447 | - if ( !empty( $args['desc'] ) ) { |
|
447 | + if ( !empty( $args['desc'] ) ) { |
|
448 | 448 | echo $args['desc']; |
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
452 | 452 | function wpinv_hidden_callback( $args ) { |
453 | - global $wpinv_options; |
|
454 | - |
|
455 | - if ( isset( $args['set_value'] ) ) { |
|
456 | - $value = $args['set_value']; |
|
457 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
458 | - $value = $wpinv_options[ $args['id'] ]; |
|
459 | - } else { |
|
460 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
461 | - } |
|
462 | - |
|
463 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
464 | - $args['readonly'] = true; |
|
465 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
466 | - $name = ''; |
|
467 | - } else { |
|
468 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
469 | - } |
|
470 | - |
|
471 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
453 | + global $wpinv_options; |
|
454 | + |
|
455 | + if ( isset( $args['set_value'] ) ) { |
|
456 | + $value = $args['set_value']; |
|
457 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
458 | + $value = $wpinv_options[ $args['id'] ]; |
|
459 | + } else { |
|
460 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
461 | + } |
|
462 | + |
|
463 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
464 | + $args['readonly'] = true; |
|
465 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
466 | + $name = ''; |
|
467 | + } else { |
|
468 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
469 | + } |
|
470 | + |
|
471 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
472 | 472 | |
473 | - echo $html; |
|
473 | + echo $html; |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -478,12 +478,12 @@ discard block |
||
478 | 478 | */ |
479 | 479 | function wpinv_checkbox_callback( $args ) { |
480 | 480 | |
481 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
482 | - $std = wpinv_get_option( $args['id'], $std ); |
|
483 | - $id = esc_attr( $args['id'] ); |
|
481 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
482 | + $std = wpinv_get_option( $args['id'], $std ); |
|
483 | + $id = esc_attr( $args['id'] ); |
|
484 | 484 | |
485 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
486 | - ?> |
|
485 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
486 | + ?> |
|
487 | 487 | <fieldset> |
488 | 488 | <label> |
489 | 489 | <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -495,77 +495,77 @@ discard block |
||
495 | 495 | |
496 | 496 | function wpinv_multicheck_callback( $args ) { |
497 | 497 | |
498 | - global $wpinv_options; |
|
498 | + global $wpinv_options; |
|
499 | 499 | |
500 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
501 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
500 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
501 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
502 | 502 | |
503 | - if ( ! empty( $args['options'] ) ) { |
|
503 | + if ( ! empty( $args['options'] ) ) { |
|
504 | 504 | |
505 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
506 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
505 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
506 | + $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
507 | 507 | |
508 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
508 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
509 | 509 | foreach( $args['options'] as $key => $option ): |
510 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
511 | - if ( in_array( $sanitize_key, $value ) ) { |
|
512 | - $enabled = $sanitize_key; |
|
513 | - } else { |
|
514 | - $enabled = NULL; |
|
515 | - } |
|
516 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
517 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
518 | - endforeach; |
|
519 | - echo '</div>'; |
|
520 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
521 | - } |
|
510 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
511 | + if ( in_array( $sanitize_key, $value ) ) { |
|
512 | + $enabled = $sanitize_key; |
|
513 | + } else { |
|
514 | + $enabled = NULL; |
|
515 | + } |
|
516 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
517 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
518 | + endforeach; |
|
519 | + echo '</div>'; |
|
520 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
521 | + } |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | function wpinv_payment_icons_callback( $args ) { |
525 | - global $wpinv_options; |
|
525 | + global $wpinv_options; |
|
526 | 526 | |
527 | 527 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
528 | 528 | |
529 | - if ( ! empty( $args['options'] ) ) { |
|
530 | - foreach( $args['options'] as $key => $option ) { |
|
529 | + if ( ! empty( $args['options'] ) ) { |
|
530 | + foreach( $args['options'] as $key => $option ) { |
|
531 | 531 | $sanitize_key = wpinv_sanitize_key( $key ); |
532 | 532 | |
533 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
534 | - $enabled = $option; |
|
535 | - } else { |
|
536 | - $enabled = NULL; |
|
537 | - } |
|
538 | - |
|
539 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
540 | - |
|
541 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
542 | - |
|
543 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
544 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
545 | - } else { |
|
546 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
547 | - |
|
548 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
549 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
550 | - } else { |
|
551 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
552 | - $content_dir = WP_CONTENT_DIR; |
|
553 | - |
|
554 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
555 | - // Replaces backslashes with forward slashes for Windows systems |
|
556 | - $image = wp_normalize_path( $image ); |
|
557 | - $content_dir = wp_normalize_path( $content_dir ); |
|
558 | - } |
|
559 | - |
|
560 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
561 | - } |
|
562 | - |
|
563 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
564 | - } |
|
565 | - echo $option . '</label>'; |
|
566 | - } |
|
567 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
568 | - } |
|
533 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
534 | + $enabled = $option; |
|
535 | + } else { |
|
536 | + $enabled = NULL; |
|
537 | + } |
|
538 | + |
|
539 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
540 | + |
|
541 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
542 | + |
|
543 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
544 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
545 | + } else { |
|
546 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
547 | + |
|
548 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
549 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
550 | + } else { |
|
551 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
552 | + $content_dir = WP_CONTENT_DIR; |
|
553 | + |
|
554 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
555 | + // Replaces backslashes with forward slashes for Windows systems |
|
556 | + $image = wp_normalize_path( $image ); |
|
557 | + $content_dir = wp_normalize_path( $content_dir ); |
|
558 | + } |
|
559 | + |
|
560 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
561 | + } |
|
562 | + |
|
563 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
564 | + } |
|
565 | + echo $option . '</label>'; |
|
566 | + } |
|
567 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
568 | + } |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -573,9 +573,9 @@ discard block |
||
573 | 573 | */ |
574 | 574 | function wpinv_radio_callback( $args ) { |
575 | 575 | |
576 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
577 | - $std = wpinv_get_option( $args['id'], $std ); |
|
578 | - ?> |
|
576 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
577 | + $std = wpinv_get_option( $args['id'], $std ); |
|
578 | + ?> |
|
579 | 579 | <fieldset> |
580 | 580 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
581 | 581 | <?php foreach( $args['options'] as $key => $option ) : ?> |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | </ul> |
590 | 590 | </fieldset> |
591 | 591 | <?php |
592 | - getpaid_settings_description_callback( $args ); |
|
592 | + getpaid_settings_description_callback( $args ); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -597,176 +597,176 @@ discard block |
||
597 | 597 | */ |
598 | 598 | function getpaid_settings_description_callback( $args ) { |
599 | 599 | |
600 | - if ( ! empty( $args['desc'] ) ) { |
|
601 | - $description = wp_kses_post( $args['desc'] ); |
|
602 | - echo "<p class='description'>$description</p>"; |
|
603 | - } |
|
600 | + if ( ! empty( $args['desc'] ) ) { |
|
601 | + $description = wp_kses_post( $args['desc'] ); |
|
602 | + echo "<p class='description'>$description</p>"; |
|
603 | + } |
|
604 | 604 | |
605 | 605 | } |
606 | 606 | |
607 | 607 | function wpinv_gateways_callback( $args ) { |
608 | - global $wpinv_options; |
|
608 | + global $wpinv_options; |
|
609 | 609 | |
610 | 610 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
611 | 611 | |
612 | - foreach ( $args['options'] as $key => $option ) : |
|
613 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
612 | + foreach ( $args['options'] as $key => $option ) : |
|
613 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
614 | 614 | |
615 | 615 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
616 | - $enabled = '1'; |
|
617 | - else |
|
618 | - $enabled = null; |
|
616 | + $enabled = '1'; |
|
617 | + else |
|
618 | + $enabled = null; |
|
619 | 619 | |
620 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
621 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
622 | - endforeach; |
|
620 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
621 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
622 | + endforeach; |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | function wpinv_gateway_select_callback($args) { |
626 | - global $wpinv_options; |
|
626 | + global $wpinv_options; |
|
627 | 627 | |
628 | 628 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
629 | 629 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
630 | 630 | |
631 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
631 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
632 | 632 | |
633 | - foreach ( $args['options'] as $key => $option ) : |
|
634 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
633 | + foreach ( $args['options'] as $key => $option ) : |
|
634 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
635 | 635 | $selected = selected( $key, $args['selected'], false ); |
636 | 636 | } else { |
637 | 637 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
638 | 638 | } |
639 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
640 | - endforeach; |
|
639 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
640 | + endforeach; |
|
641 | 641 | |
642 | - echo '</select>'; |
|
643 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
642 | + echo '</select>'; |
|
643 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | function wpinv_text_callback( $args ) { |
647 | - global $wpinv_options; |
|
647 | + global $wpinv_options; |
|
648 | 648 | |
649 | 649 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
650 | 650 | |
651 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
652 | - $value = $wpinv_options[ $args['id'] ]; |
|
653 | - } else { |
|
654 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
655 | - } |
|
656 | - |
|
657 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
658 | - $args['readonly'] = true; |
|
659 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
660 | - $name = ''; |
|
661 | - } else { |
|
662 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
663 | - } |
|
664 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
665 | - |
|
666 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
667 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
668 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
669 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
670 | - |
|
671 | - echo $html; |
|
651 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
652 | + $value = $wpinv_options[ $args['id'] ]; |
|
653 | + } else { |
|
654 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
655 | + } |
|
656 | + |
|
657 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
658 | + $args['readonly'] = true; |
|
659 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
660 | + $name = ''; |
|
661 | + } else { |
|
662 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
663 | + } |
|
664 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
665 | + |
|
666 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
667 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
668 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
669 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
670 | + |
|
671 | + echo $html; |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | function wpinv_number_callback( $args ) { |
675 | - global $wpinv_options; |
|
675 | + global $wpinv_options; |
|
676 | 676 | |
677 | 677 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
678 | 678 | |
679 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
680 | - $value = $wpinv_options[ $args['id'] ]; |
|
681 | - } else { |
|
682 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
683 | - } |
|
684 | - |
|
685 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
686 | - $args['readonly'] = true; |
|
687 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
688 | - $name = ''; |
|
689 | - } else { |
|
690 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
691 | - } |
|
692 | - |
|
693 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
694 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
695 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
696 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
697 | - |
|
698 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
699 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
700 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
701 | - |
|
702 | - echo $html; |
|
679 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
680 | + $value = $wpinv_options[ $args['id'] ]; |
|
681 | + } else { |
|
682 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
683 | + } |
|
684 | + |
|
685 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
686 | + $args['readonly'] = true; |
|
687 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
688 | + $name = ''; |
|
689 | + } else { |
|
690 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
691 | + } |
|
692 | + |
|
693 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
694 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
695 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
696 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
697 | + |
|
698 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
699 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
700 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
701 | + |
|
702 | + echo $html; |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | function wpinv_textarea_callback( $args ) { |
706 | - global $wpinv_options; |
|
706 | + global $wpinv_options; |
|
707 | 707 | |
708 | 708 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
709 | 709 | |
710 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
711 | - $value = $wpinv_options[ $args['id'] ]; |
|
712 | - } else { |
|
713 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
714 | - } |
|
710 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
711 | + $value = $wpinv_options[ $args['id'] ]; |
|
712 | + } else { |
|
713 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
714 | + } |
|
715 | 715 | |
716 | 716 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
717 | 717 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
718 | 718 | |
719 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
720 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
719 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
720 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
721 | 721 | |
722 | - echo $html; |
|
722 | + echo $html; |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | function wpinv_password_callback( $args ) { |
726 | - global $wpinv_options; |
|
726 | + global $wpinv_options; |
|
727 | 727 | |
728 | 728 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
729 | 729 | |
730 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
731 | - $value = $wpinv_options[ $args['id'] ]; |
|
732 | - } else { |
|
733 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
734 | - } |
|
730 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
731 | + $value = $wpinv_options[ $args['id'] ]; |
|
732 | + } else { |
|
733 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
734 | + } |
|
735 | 735 | |
736 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
737 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
738 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
736 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
737 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
738 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
739 | 739 | |
740 | - echo $html; |
|
740 | + echo $html; |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | function wpinv_missing_callback($args) { |
744 | - printf( |
|
745 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
746 | - '<strong>' . $args['id'] . '</strong>' |
|
747 | - ); |
|
744 | + printf( |
|
745 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
746 | + '<strong>' . $args['id'] . '</strong>' |
|
747 | + ); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | function wpinv_select_callback($args) { |
751 | - global $wpinv_options; |
|
751 | + global $wpinv_options; |
|
752 | 752 | |
753 | 753 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
754 | 754 | |
755 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
756 | - $value = $wpinv_options[ $args['id'] ]; |
|
757 | - } else { |
|
758 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
759 | - } |
|
755 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
756 | + $value = $wpinv_options[ $args['id'] ]; |
|
757 | + } else { |
|
758 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
759 | + } |
|
760 | 760 | |
761 | 761 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
762 | 762 | $value = $args['selected']; |
763 | 763 | } |
764 | 764 | |
765 | - if ( isset( $args['placeholder'] ) ) { |
|
766 | - $placeholder = $args['placeholder']; |
|
767 | - } else { |
|
768 | - $placeholder = ''; |
|
769 | - } |
|
765 | + if ( isset( $args['placeholder'] ) ) { |
|
766 | + $placeholder = $args['placeholder']; |
|
767 | + } else { |
|
768 | + $placeholder = ''; |
|
769 | + } |
|
770 | 770 | |
771 | 771 | if( !empty( $args['onchange'] ) ) { |
772 | 772 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -776,137 +776,137 @@ discard block |
||
776 | 776 | |
777 | 777 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
778 | 778 | |
779 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
779 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
780 | 780 | |
781 | - foreach ( $args['options'] as $option => $name ) { |
|
782 | - $selected = selected( $option, $value, false ); |
|
783 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
784 | - } |
|
781 | + foreach ( $args['options'] as $option => $name ) { |
|
782 | + $selected = selected( $option, $value, false ); |
|
783 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
784 | + } |
|
785 | 785 | |
786 | - $html .= '</select>'; |
|
787 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
786 | + $html .= '</select>'; |
|
787 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
788 | 788 | |
789 | - echo $html; |
|
789 | + echo $html; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | function wpinv_color_select_callback( $args ) { |
793 | - global $wpinv_options; |
|
793 | + global $wpinv_options; |
|
794 | 794 | |
795 | 795 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
796 | 796 | |
797 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
798 | - $value = $wpinv_options[ $args['id'] ]; |
|
799 | - } else { |
|
800 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
801 | - } |
|
797 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
798 | + $value = $wpinv_options[ $args['id'] ]; |
|
799 | + } else { |
|
800 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
801 | + } |
|
802 | 802 | |
803 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
803 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
804 | 804 | |
805 | - foreach ( $args['options'] as $option => $color ) { |
|
806 | - $selected = selected( $option, $value, false ); |
|
807 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
808 | - } |
|
805 | + foreach ( $args['options'] as $option => $color ) { |
|
806 | + $selected = selected( $option, $value, false ); |
|
807 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
808 | + } |
|
809 | 809 | |
810 | - $html .= '</select>'; |
|
811 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
810 | + $html .= '</select>'; |
|
811 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
812 | 812 | |
813 | - echo $html; |
|
813 | + echo $html; |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | function wpinv_rich_editor_callback( $args ) { |
817 | - global $wpinv_options, $wp_version; |
|
817 | + global $wpinv_options, $wp_version; |
|
818 | 818 | |
819 | 819 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
820 | 820 | |
821 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
822 | - $value = $wpinv_options[ $args['id'] ]; |
|
821 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
822 | + $value = $wpinv_options[ $args['id'] ]; |
|
823 | 823 | |
824 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
825 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
826 | - } |
|
827 | - } else { |
|
828 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
829 | - } |
|
824 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
825 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
826 | + } |
|
827 | + } else { |
|
828 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
829 | + } |
|
830 | 830 | |
831 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
831 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
832 | 832 | |
833 | - $html = '<div class="getpaid-settings-editor-input">'; |
|
834 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
835 | - ob_start(); |
|
836 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
837 | - $html .= ob_get_clean(); |
|
838 | - } else { |
|
839 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
840 | - } |
|
833 | + $html = '<div class="getpaid-settings-editor-input">'; |
|
834 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
835 | + ob_start(); |
|
836 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
837 | + $html .= ob_get_clean(); |
|
838 | + } else { |
|
839 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
840 | + } |
|
841 | 841 | |
842 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
842 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
843 | 843 | |
844 | - echo $html; |
|
844 | + echo $html; |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | function wpinv_upload_callback( $args ) { |
848 | - global $wpinv_options; |
|
848 | + global $wpinv_options; |
|
849 | 849 | |
850 | 850 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
851 | 851 | |
852 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
853 | - $value = $wpinv_options[$args['id']]; |
|
854 | - } else { |
|
855 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
856 | - } |
|
852 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
853 | + $value = $wpinv_options[$args['id']]; |
|
854 | + } else { |
|
855 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
856 | + } |
|
857 | 857 | |
858 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
859 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
860 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
861 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
858 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
859 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
860 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
861 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
862 | 862 | |
863 | - echo $html; |
|
863 | + echo $html; |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | function wpinv_color_callback( $args ) { |
867 | - global $wpinv_options; |
|
867 | + global $wpinv_options; |
|
868 | 868 | |
869 | 869 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
870 | 870 | |
871 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
872 | - $value = $wpinv_options[ $args['id'] ]; |
|
873 | - } else { |
|
874 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
875 | - } |
|
871 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
872 | + $value = $wpinv_options[ $args['id'] ]; |
|
873 | + } else { |
|
874 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
875 | + } |
|
876 | 876 | |
877 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
877 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
878 | 878 | |
879 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
880 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
879 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
880 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
881 | 881 | |
882 | - echo $html; |
|
882 | + echo $html; |
|
883 | 883 | } |
884 | 884 | |
885 | 885 | function wpinv_country_states_callback($args) { |
886 | - global $wpinv_options; |
|
886 | + global $wpinv_options; |
|
887 | 887 | |
888 | 888 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
889 | 889 | |
890 | - if ( isset( $args['placeholder'] ) ) { |
|
891 | - $placeholder = $args['placeholder']; |
|
892 | - } else { |
|
893 | - $placeholder = ''; |
|
894 | - } |
|
890 | + if ( isset( $args['placeholder'] ) ) { |
|
891 | + $placeholder = $args['placeholder']; |
|
892 | + } else { |
|
893 | + $placeholder = ''; |
|
894 | + } |
|
895 | 895 | |
896 | - $states = wpinv_get_country_states(); |
|
896 | + $states = wpinv_get_country_states(); |
|
897 | 897 | |
898 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
899 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
898 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
899 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
900 | 900 | |
901 | - foreach ( $states as $option => $name ) { |
|
902 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
903 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
904 | - } |
|
901 | + foreach ( $states as $option => $name ) { |
|
902 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
903 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
904 | + } |
|
905 | 905 | |
906 | - $html .= '</select>'; |
|
907 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
906 | + $html .= '</select>'; |
|
907 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
908 | 908 | |
909 | - echo $html; |
|
909 | + echo $html; |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | */ |
915 | 915 | function wpinv_tax_rates_callback() { |
916 | 916 | |
917 | - ?> |
|
917 | + ?> |
|
918 | 918 | </td> |
919 | 919 | </tr> |
920 | 920 | <tr class="bsui"> |
@@ -929,17 +929,17 @@ discard block |
||
929 | 929 | * Displays a tax rate' edit row. |
930 | 930 | */ |
931 | 931 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
932 | - ob_start(); |
|
932 | + ob_start(); |
|
933 | 933 | |
934 | - $key = sanitize_key( $key ); |
|
935 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
936 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
934 | + $key = sanitize_key( $key ); |
|
935 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
936 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
937 | 937 | |
938 | - if ( $echo ) { |
|
939 | - echo ob_get_clean(); |
|
940 | - } else { |
|
941 | - return ob_get_clean(); |
|
942 | - } |
|
938 | + if ( $echo ) { |
|
939 | + echo ob_get_clean(); |
|
940 | + } else { |
|
941 | + return ob_get_clean(); |
|
942 | + } |
|
943 | 943 | |
944 | 944 | } |
945 | 945 | |
@@ -967,15 +967,15 @@ discard block |
||
967 | 967 | } |
968 | 968 | |
969 | 969 | function wpinv_descriptive_text_callback( $args ) { |
970 | - echo wp_kses_post( $args['desc'] ); |
|
970 | + echo wp_kses_post( $args['desc'] ); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | function wpinv_hook_callback( $args ) { |
974 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
974 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | function wpinv_set_settings_cap() { |
978 | - return wpinv_get_capability(); |
|
978 | + return wpinv_get_capability(); |
|
979 | 979 | } |
980 | 980 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
981 | 981 |
@@ -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 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | global $wpinv_options; |
44 | 44 | |
45 | 45 | // Try fetching the saved options. |
46 | - if ( ! is_array( $wpinv_options ) ) { |
|
47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
46 | + if (!is_array($wpinv_options)) { |
|
47 | + $wpinv_options = get_option('wpinv_settings'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
51 | - if ( ! is_array( $wpinv_options ) ) { |
|
51 | + if (!is_array($wpinv_options)) { |
|
52 | 52 | $wpinv_options = array(); |
53 | 53 | } |
54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
65 | +function wpinv_get_option($key = '', $default = false) { |
|
66 | 66 | |
67 | 67 | $options = wpinv_get_options(); |
68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param array $options the new options. |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | -function wpinv_update_options( $options ) { |
|
80 | +function wpinv_update_options($options) { |
|
81 | 81 | global $wpinv_options; |
82 | 82 | |
83 | 83 | // update the option. |
84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
85 | 85 | $wpinv_options = $options; |
86 | 86 | return true; |
87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @param mixed $value The setting value. |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
99 | +function wpinv_update_option($key = '', $value = false) { |
|
100 | 100 | |
101 | 101 | // If no key, exit. |
102 | - if ( empty( $key ) ) { |
|
102 | + if (empty($key)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Maybe delete the option instead. |
107 | - if ( is_null( $value ) ) { |
|
108 | - return wpinv_delete_option( $key ); |
|
107 | + if (is_null($value)) { |
|
108 | + return wpinv_delete_option($key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Prepare the new options. |
112 | 112 | $options = wpinv_get_options(); |
113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
114 | 114 | |
115 | 115 | // Save the new options. |
116 | - return wpinv_update_options( $options ); |
|
116 | + return wpinv_update_options($options); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * @param string $key the setting key. |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function wpinv_delete_option( $key = '' ) { |
|
126 | +function wpinv_delete_option($key = '') { |
|
127 | 127 | |
128 | 128 | // If no key, exit |
129 | - if ( empty( $key ) ) { |
|
129 | + if (empty($key)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $options = wpinv_get_options(); |
134 | 134 | |
135 | - if ( isset( $options[ $key ] ) ) { |
|
136 | - unset( $options[ $key ] ); |
|
137 | - return wpinv_update_options( $options ); |
|
135 | + if (isset($options[$key])) { |
|
136 | + unset($options[$key]); |
|
137 | + return wpinv_update_options($options); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | function wpinv_register_settings() { |
149 | 149 | |
150 | 150 | // Loop through all tabs. |
151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
152 | 152 | |
153 | 153 | // In each tab, loop through sections. |
154 | - foreach ( $sections as $section => $settings ) { |
|
154 | + foreach ($sections as $section => $settings) { |
|
155 | 155 | |
156 | 156 | // Check for backwards compatibility |
157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
159 | 159 | $section = 'main'; |
160 | 160 | $settings = $sections; |
161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $settings as $option ) { |
|
172 | - if ( ! empty( $option['id'] ) ) { |
|
173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
171 | + foreach ($settings as $option) { |
|
172 | + if (!empty($option['id'])) { |
|
173 | + wpinv_register_settings_option($tab, $section, $option); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | } |
183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Register a single settings option. |
@@ -190,46 +190,46 @@ discard block |
||
190 | 190 | * @param string $option |
191 | 191 | * |
192 | 192 | */ |
193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
194 | 194 | |
195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = esc_attr( $option['desc'] ); |
|
199 | + if (isset($option['desc']) && !empty($option['help-tip'])) { |
|
200 | + $tip = esc_attr($option['desc']); |
|
201 | 201 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
202 | - unset( $option['desc'] ); |
|
202 | + unset($option['desc']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
207 | 207 | 'wpinv_settings[' . $option['id'] . ']', |
208 | 208 | $name, |
209 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
209 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
210 | 210 | $section, |
211 | 211 | $section, |
212 | 212 | array( |
213 | 213 | 'section' => $section, |
214 | - 'id' => isset( $option['id'] ) ? $option['id'] : null, |
|
215 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
214 | + 'id' => isset($option['id']) ? $option['id'] : null, |
|
215 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
216 | 216 | 'name' => $name, |
217 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
218 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
219 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
220 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
221 | - 'min' => isset( $option['min'] ) ? $option['min'] : null, |
|
222 | - 'max' => isset( $option['max'] ) ? $option['max'] : null, |
|
223 | - 'step' => isset( $option['step'] ) ? $option['step'] : null, |
|
224 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
225 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
226 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
227 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
228 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
229 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
230 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
217 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
218 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
219 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
220 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
221 | + 'min' => isset($option['min']) ? $option['min'] : null, |
|
222 | + 'max' => isset($option['max']) ? $option['max'] : null, |
|
223 | + 'step' => isset($option['step']) ? $option['step'] : null, |
|
224 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
225 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
226 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
227 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
228 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
229 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
230 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
231 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
232 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
233 | 233 | ) |
234 | 234 | ); |
235 | 235 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return array |
242 | 242 | */ |
243 | 243 | function wpinv_get_registered_settings() { |
244 | - return apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ); |
|
244 | + return apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -249,135 +249,135 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return array |
251 | 251 | */ |
252 | -function wpinv_settings_sanitize( $input = array() ) { |
|
252 | +function wpinv_settings_sanitize($input = array()) { |
|
253 | 253 | |
254 | 254 | $wpinv_options = wpinv_get_options(); |
255 | 255 | |
256 | - if ( empty( wp_get_raw_referer() ) ) { |
|
256 | + if (empty(wp_get_raw_referer())) { |
|
257 | 257 | return $input; |
258 | 258 | } |
259 | 259 | |
260 | - wp_parse_str( wp_get_raw_referer(), $referrer ); |
|
260 | + wp_parse_str(wp_get_raw_referer(), $referrer); |
|
261 | 261 | |
262 | 262 | $settings = wpinv_get_registered_settings(); |
263 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
264 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
263 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
264 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
265 | 265 | |
266 | 266 | $input = $input ? $input : array(); |
267 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
268 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
267 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
268 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
269 | 269 | |
270 | 270 | // Loop through each setting being saved and pass it through a sanitization filter |
271 | - foreach ( $input as $key => $value ) { |
|
271 | + foreach ($input as $key => $value) { |
|
272 | 272 | |
273 | 273 | // Get the setting type (checkbox, select, etc) |
274 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
274 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
275 | 275 | |
276 | - if ( $type ) { |
|
276 | + if ($type) { |
|
277 | 277 | // Field type specific filter |
278 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
278 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // General filter |
282 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
282 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
283 | 283 | |
284 | 284 | // Key specific filter. |
285 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
285 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | // Loop through the whitelist and unset any that are empty for the tab being saved |
289 | - $main_settings = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
290 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
289 | + $main_settings = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
290 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
291 | 291 | |
292 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
292 | + $found_settings = array_merge($main_settings, $section_settings); |
|
293 | 293 | |
294 | - if ( ! empty( $found_settings ) ) { |
|
295 | - foreach ( $found_settings as $key => $value ) { |
|
294 | + if (!empty($found_settings)) { |
|
295 | + foreach ($found_settings as $key => $value) { |
|
296 | 296 | |
297 | 297 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
298 | - if ( is_numeric( $key ) ) { |
|
298 | + if (is_numeric($key)) { |
|
299 | 299 | $key = $value['id']; |
300 | 300 | } |
301 | 301 | |
302 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
303 | - unset( $wpinv_options[ $key ] ); |
|
302 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
303 | + unset($wpinv_options[$key]); |
|
304 | 304 | } |
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | 308 | // Merge our new settings with the existing |
309 | - $output = array_merge( $wpinv_options, $input ); |
|
309 | + $output = array_merge($wpinv_options, $input); |
|
310 | 310 | |
311 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
311 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
312 | 312 | |
313 | 313 | return $output; |
314 | 314 | } |
315 | 315 | |
316 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
316 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
317 | 317 | |
318 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
318 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
319 | 319 | return $input; |
320 | 320 | } |
321 | 321 | |
322 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
322 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
323 | 323 | // Shows an admin notice about upgrading previous order numbers |
324 | - getpaid_session()->set( 'upgrade_sequential', '1' ); |
|
324 | + getpaid_session()->set('upgrade_sequential', '1'); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | return $input; |
328 | 328 | } |
329 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
329 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
330 | 330 | |
331 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
332 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
331 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
332 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
333 | 333 | return $input; |
334 | 334 | } |
335 | 335 | |
336 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
336 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
337 | 337 | $tax_rates = array(); |
338 | 338 | |
339 | - foreach ( $new_rates as $rate ) { |
|
339 | + foreach ($new_rates as $rate) { |
|
340 | 340 | |
341 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
342 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
343 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
344 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
345 | - $rate['global'] = empty( $rate['state'] ); |
|
341 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
342 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
343 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
344 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
345 | + $rate['global'] = empty($rate['state']); |
|
346 | 346 | $tax_rates[] = $rate; |
347 | 347 | |
348 | 348 | } |
349 | 349 | |
350 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
350 | + update_option('wpinv_tax_rates', $tax_rates); |
|
351 | 351 | |
352 | 352 | return $input; |
353 | 353 | } |
354 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
354 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
355 | 355 | |
356 | -function wpinv_sanitize_text_field( $input ) { |
|
357 | - return trim( $input ); |
|
356 | +function wpinv_sanitize_text_field($input) { |
|
357 | + return trim($input); |
|
358 | 358 | } |
359 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
359 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
360 | 360 | |
361 | 361 | function wpinv_get_settings_tabs() { |
362 | 362 | $tabs = array(); |
363 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
364 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
365 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
366 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
367 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
368 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
369 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
370 | - |
|
371 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
363 | + $tabs['general'] = __('General', 'invoicing'); |
|
364 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
365 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
366 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
367 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
368 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
369 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
370 | + |
|
371 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
372 | 372 | } |
373 | 373 | |
374 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
374 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
375 | 375 | $tabs = false; |
376 | 376 | $sections = wpinv_get_registered_settings_sections(); |
377 | 377 | |
378 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
379 | - $tabs = $sections[ $tab ]; |
|
380 | - } else if ( $tab ) { |
|
378 | + if ($tab && !empty($sections[$tab])) { |
|
379 | + $tabs = $sections[$tab]; |
|
380 | + } else if ($tab) { |
|
381 | 381 | $tabs = false; |
382 | 382 | } |
383 | 383 | |
@@ -387,88 +387,88 @@ discard block |
||
387 | 387 | function wpinv_get_registered_settings_sections() { |
388 | 388 | static $sections = false; |
389 | 389 | |
390 | - if ( false !== $sections ) { |
|
390 | + if (false !== $sections) { |
|
391 | 391 | return $sections; |
392 | 392 | } |
393 | 393 | |
394 | 394 | $sections = array( |
395 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
396 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
397 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
398 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
399 | - ) ), |
|
400 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
401 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
402 | - ) ), |
|
403 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
404 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
405 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
406 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
407 | - ) ), |
|
408 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
409 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
410 | - ) ), |
|
411 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
412 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
413 | - ) ), |
|
414 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
415 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
416 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
417 | - ) ), |
|
418 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
419 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
420 | - ) ), |
|
395 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
396 | + 'main' => __('General Settings', 'invoicing'), |
|
397 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
398 | + 'labels' => __('Label Texts', 'invoicing'), |
|
399 | + )), |
|
400 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
401 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
402 | + )), |
|
403 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
404 | + 'main' => __('Tax Settings', 'invoicing'), |
|
405 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
406 | + 'vat' => __('EU VAT Settings', 'invoicing') |
|
407 | + )), |
|
408 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
409 | + 'main' => __('Email Settings', 'invoicing'), |
|
410 | + )), |
|
411 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
412 | + 'main' => __('Privacy policy', 'invoicing'), |
|
413 | + )), |
|
414 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
415 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
416 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
417 | + )), |
|
418 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
419 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
420 | + )), |
|
421 | 421 | ); |
422 | 422 | |
423 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
423 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
424 | 424 | |
425 | 425 | return $sections; |
426 | 426 | } |
427 | 427 | |
428 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
428 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
429 | 429 | $pages_options = array(); |
430 | 430 | |
431 | - if( $default_label !== NULL && $default_label !== false ) { |
|
432 | - $pages_options = array( '' => $default_label ); // Blank option |
|
431 | + if ($default_label !== NULL && $default_label !== false) { |
|
432 | + $pages_options = array('' => $default_label); // Blank option |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | $pages = get_pages(); |
436 | - if ( $pages ) { |
|
437 | - foreach ( $pages as $page ) { |
|
436 | + if ($pages) { |
|
437 | + foreach ($pages as $page) { |
|
438 | 438 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
439 | - $pages_options[ $page->ID ] = $title; |
|
439 | + $pages_options[$page->ID] = $title; |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | 443 | return $pages_options; |
444 | 444 | } |
445 | 445 | |
446 | -function wpinv_header_callback( $args ) { |
|
447 | - if ( !empty( $args['desc'] ) ) { |
|
446 | +function wpinv_header_callback($args) { |
|
447 | + if (!empty($args['desc'])) { |
|
448 | 448 | echo $args['desc']; |
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
452 | -function wpinv_hidden_callback( $args ) { |
|
452 | +function wpinv_hidden_callback($args) { |
|
453 | 453 | global $wpinv_options; |
454 | 454 | |
455 | - if ( isset( $args['set_value'] ) ) { |
|
455 | + if (isset($args['set_value'])) { |
|
456 | 456 | $value = $args['set_value']; |
457 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
458 | - $value = $wpinv_options[ $args['id'] ]; |
|
457 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
458 | + $value = $wpinv_options[$args['id']]; |
|
459 | 459 | } else { |
460 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
460 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
461 | 461 | } |
462 | 462 | |
463 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
463 | + if (isset($args['faux']) && true === $args['faux']) { |
|
464 | 464 | $args['readonly'] = true; |
465 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
465 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
466 | 466 | $name = ''; |
467 | 467 | } else { |
468 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
468 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
469 | 469 | } |
470 | 470 | |
471 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
471 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
472 | 472 | |
473 | 473 | echo $html; |
474 | 474 | } |
@@ -476,61 +476,61 @@ discard block |
||
476 | 476 | /** |
477 | 477 | * Displays a checkbox settings callback. |
478 | 478 | */ |
479 | -function wpinv_checkbox_callback( $args ) { |
|
479 | +function wpinv_checkbox_callback($args) { |
|
480 | 480 | |
481 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
482 | - $std = wpinv_get_option( $args['id'], $std ); |
|
483 | - $id = esc_attr( $args['id'] ); |
|
481 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
482 | + $std = wpinv_get_option($args['id'], $std); |
|
483 | + $id = esc_attr($args['id']); |
|
484 | 484 | |
485 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
485 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
486 | 486 | ?> |
487 | 487 | <fieldset> |
488 | 488 | <label> |
489 | - <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
490 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
489 | + <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
490 | + <?php echo wp_kses_post($args['desc']); ?> |
|
491 | 491 | </label> |
492 | 492 | </fieldset> |
493 | 493 | <?php |
494 | 494 | } |
495 | 495 | |
496 | -function wpinv_multicheck_callback( $args ) { |
|
496 | +function wpinv_multicheck_callback($args) { |
|
497 | 497 | |
498 | 498 | global $wpinv_options; |
499 | 499 | |
500 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
501 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
500 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
501 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
502 | 502 | |
503 | - if ( ! empty( $args['options'] ) ) { |
|
503 | + if (!empty($args['options'])) { |
|
504 | 504 | |
505 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
506 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
505 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
506 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
507 | 507 | |
508 | 508 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
509 | - foreach( $args['options'] as $key => $option ): |
|
510 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
511 | - if ( in_array( $sanitize_key, $value ) ) { |
|
509 | + foreach ($args['options'] as $key => $option): |
|
510 | + $sanitize_key = wpinv_sanitize_key($key); |
|
511 | + if (in_array($sanitize_key, $value)) { |
|
512 | 512 | $enabled = $sanitize_key; |
513 | 513 | } else { |
514 | 514 | $enabled = NULL; |
515 | 515 | } |
516 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
517 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
516 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
517 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
518 | 518 | endforeach; |
519 | 519 | echo '</div>'; |
520 | 520 | echo '<p class="description">' . $args['desc'] . '</p>'; |
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | -function wpinv_payment_icons_callback( $args ) { |
|
524 | +function wpinv_payment_icons_callback($args) { |
|
525 | 525 | global $wpinv_options; |
526 | 526 | |
527 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
527 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
528 | 528 | |
529 | - if ( ! empty( $args['options'] ) ) { |
|
530 | - foreach( $args['options'] as $key => $option ) { |
|
531 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
529 | + if (!empty($args['options'])) { |
|
530 | + foreach ($args['options'] as $key => $option) { |
|
531 | + $sanitize_key = wpinv_sanitize_key($key); |
|
532 | 532 | |
533 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
533 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
534 | 534 | $enabled = $option; |
535 | 535 | } else { |
536 | 536 | $enabled = NULL; |
@@ -538,211 +538,211 @@ discard block |
||
538 | 538 | |
539 | 539 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
540 | 540 | |
541 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
541 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
542 | 542 | |
543 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
544 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
543 | + if (wpinv_string_is_image_url($key)) { |
|
544 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
545 | 545 | } else { |
546 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
546 | + $card = strtolower(str_replace(' ', '', $option)); |
|
547 | 547 | |
548 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
549 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
548 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
549 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
550 | 550 | } else { |
551 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
551 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
552 | 552 | $content_dir = WP_CONTENT_DIR; |
553 | 553 | |
554 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
554 | + if (function_exists('wp_normalize_path')) { |
|
555 | 555 | // Replaces backslashes with forward slashes for Windows systems |
556 | - $image = wp_normalize_path( $image ); |
|
557 | - $content_dir = wp_normalize_path( $content_dir ); |
|
556 | + $image = wp_normalize_path($image); |
|
557 | + $content_dir = wp_normalize_path($content_dir); |
|
558 | 558 | } |
559 | 559 | |
560 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
560 | + $image = str_replace($content_dir, content_url(), $image); |
|
561 | 561 | } |
562 | 562 | |
563 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
563 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
564 | 564 | } |
565 | 565 | echo $option . '</label>'; |
566 | 566 | } |
567 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
567 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
572 | 572 | * Displays a radio settings field. |
573 | 573 | */ |
574 | -function wpinv_radio_callback( $args ) { |
|
574 | +function wpinv_radio_callback($args) { |
|
575 | 575 | |
576 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
577 | - $std = wpinv_get_option( $args['id'], $std ); |
|
576 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
577 | + $std = wpinv_get_option($args['id'], $std); |
|
578 | 578 | ?> |
579 | 579 | <fieldset> |
580 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
581 | - <?php foreach( $args['options'] as $key => $option ) : ?> |
|
580 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
581 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
582 | 582 | <li> |
583 | 583 | <label> |
584 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
585 | - <?php echo wp_kses_post( $option ); ?> |
|
584 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
585 | + <?php echo wp_kses_post($option); ?> |
|
586 | 586 | </label> |
587 | 587 | </li> |
588 | 588 | <?php endforeach; ?> |
589 | 589 | </ul> |
590 | 590 | </fieldset> |
591 | 591 | <?php |
592 | - getpaid_settings_description_callback( $args ); |
|
592 | + getpaid_settings_description_callback($args); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
596 | 596 | * Displays a description if available. |
597 | 597 | */ |
598 | -function getpaid_settings_description_callback( $args ) { |
|
598 | +function getpaid_settings_description_callback($args) { |
|
599 | 599 | |
600 | - if ( ! empty( $args['desc'] ) ) { |
|
601 | - $description = wp_kses_post( $args['desc'] ); |
|
600 | + if (!empty($args['desc'])) { |
|
601 | + $description = wp_kses_post($args['desc']); |
|
602 | 602 | echo "<p class='description'>$description</p>"; |
603 | 603 | } |
604 | 604 | |
605 | 605 | } |
606 | 606 | |
607 | -function wpinv_gateways_callback( $args ) { |
|
607 | +function wpinv_gateways_callback($args) { |
|
608 | 608 | global $wpinv_options; |
609 | 609 | |
610 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
610 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
611 | 611 | |
612 | - foreach ( $args['options'] as $key => $option ) : |
|
613 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
612 | + foreach ($args['options'] as $key => $option) : |
|
613 | + $sanitize_key = wpinv_sanitize_key($key); |
|
614 | 614 | |
615 | - if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
|
615 | + if (isset($wpinv_options['gateways'][$key])) |
|
616 | 616 | $enabled = '1'; |
617 | 617 | else |
618 | 618 | $enabled = null; |
619 | 619 | |
620 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
621 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
620 | + echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
621 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>'; |
|
622 | 622 | endforeach; |
623 | 623 | } |
624 | 624 | |
625 | 625 | function wpinv_gateway_select_callback($args) { |
626 | 626 | global $wpinv_options; |
627 | 627 | |
628 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
629 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
628 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
629 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
630 | 630 | |
631 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
631 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
632 | 632 | |
633 | - foreach ( $args['options'] as $key => $option ) : |
|
634 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
635 | - $selected = selected( $key, $args['selected'], false ); |
|
633 | + foreach ($args['options'] as $key => $option) : |
|
634 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
635 | + $selected = selected($key, $args['selected'], false); |
|
636 | 636 | } else { |
637 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
637 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
638 | 638 | } |
639 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
639 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
640 | 640 | endforeach; |
641 | 641 | |
642 | 642 | echo '</select>'; |
643 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
643 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
644 | 644 | } |
645 | 645 | |
646 | -function wpinv_text_callback( $args ) { |
|
646 | +function wpinv_text_callback($args) { |
|
647 | 647 | global $wpinv_options; |
648 | 648 | |
649 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
649 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
650 | 650 | |
651 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
652 | - $value = $wpinv_options[ $args['id'] ]; |
|
651 | + if (isset($wpinv_options[$args['id']])) { |
|
652 | + $value = $wpinv_options[$args['id']]; |
|
653 | 653 | } else { |
654 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
654 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
655 | 655 | } |
656 | 656 | |
657 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
657 | + if (isset($args['faux']) && true === $args['faux']) { |
|
658 | 658 | $args['readonly'] = true; |
659 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
659 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
660 | 660 | $name = ''; |
661 | 661 | } else { |
662 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
662 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
663 | 663 | } |
664 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
664 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
665 | 665 | |
666 | 666 | $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
667 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
668 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
669 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
667 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
668 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>'; |
|
669 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
670 | 670 | |
671 | 671 | echo $html; |
672 | 672 | } |
673 | 673 | |
674 | -function wpinv_number_callback( $args ) { |
|
674 | +function wpinv_number_callback($args) { |
|
675 | 675 | global $wpinv_options; |
676 | 676 | |
677 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
677 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
678 | 678 | |
679 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
680 | - $value = $wpinv_options[ $args['id'] ]; |
|
679 | + if (isset($wpinv_options[$args['id']])) { |
|
680 | + $value = $wpinv_options[$args['id']]; |
|
681 | 681 | } else { |
682 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
682 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
683 | 683 | } |
684 | 684 | |
685 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
685 | + if (isset($args['faux']) && true === $args['faux']) { |
|
686 | 686 | $args['readonly'] = true; |
687 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
687 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
688 | 688 | $name = ''; |
689 | 689 | } else { |
690 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
690 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
691 | 691 | } |
692 | 692 | |
693 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
694 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
695 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
696 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
693 | + $max = isset($args['max']) ? $args['max'] : 999999; |
|
694 | + $min = isset($args['min']) ? $args['min'] : 0; |
|
695 | + $step = isset($args['step']) ? $args['step'] : 1; |
|
696 | + $class = !empty($args['class']) ? sanitize_html_class($args['class']) : ''; |
|
697 | 697 | |
698 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
699 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
700 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
698 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
699 | + $html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
700 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
701 | 701 | |
702 | 702 | echo $html; |
703 | 703 | } |
704 | 704 | |
705 | -function wpinv_textarea_callback( $args ) { |
|
705 | +function wpinv_textarea_callback($args) { |
|
706 | 706 | global $wpinv_options; |
707 | 707 | |
708 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
708 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
709 | 709 | |
710 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
711 | - $value = $wpinv_options[ $args['id'] ]; |
|
710 | + if (isset($wpinv_options[$args['id']])) { |
|
711 | + $value = $wpinv_options[$args['id']]; |
|
712 | 712 | } else { |
713 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
713 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
714 | 714 | } |
715 | 715 | |
716 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
717 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
716 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
717 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
718 | 718 | |
719 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
720 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
719 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
720 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
721 | 721 | |
722 | 722 | echo $html; |
723 | 723 | } |
724 | 724 | |
725 | -function wpinv_password_callback( $args ) { |
|
725 | +function wpinv_password_callback($args) { |
|
726 | 726 | global $wpinv_options; |
727 | 727 | |
728 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
728 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
729 | 729 | |
730 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
731 | - $value = $wpinv_options[ $args['id'] ]; |
|
730 | + if (isset($wpinv_options[$args['id']])) { |
|
731 | + $value = $wpinv_options[$args['id']]; |
|
732 | 732 | } else { |
733 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
733 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
734 | 734 | } |
735 | 735 | |
736 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
737 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
738 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
736 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
737 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
738 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
739 | 739 | |
740 | 740 | echo $html; |
741 | 741 | } |
742 | 742 | |
743 | 743 | function wpinv_missing_callback($args) { |
744 | 744 | printf( |
745 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
745 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
746 | 746 | '<strong>' . $args['id'] . '</strong>' |
747 | 747 | ); |
748 | 748 | } |
@@ -750,134 +750,134 @@ discard block |
||
750 | 750 | function wpinv_select_callback($args) { |
751 | 751 | global $wpinv_options; |
752 | 752 | |
753 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
753 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
754 | 754 | |
755 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
756 | - $value = $wpinv_options[ $args['id'] ]; |
|
755 | + if (isset($wpinv_options[$args['id']])) { |
|
756 | + $value = $wpinv_options[$args['id']]; |
|
757 | 757 | } else { |
758 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
758 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
759 | 759 | } |
760 | 760 | |
761 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
761 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
762 | 762 | $value = $args['selected']; |
763 | 763 | } |
764 | 764 | |
765 | - if ( isset( $args['placeholder'] ) ) { |
|
765 | + if (isset($args['placeholder'])) { |
|
766 | 766 | $placeholder = $args['placeholder']; |
767 | 767 | } else { |
768 | 768 | $placeholder = ''; |
769 | 769 | } |
770 | 770 | |
771 | - if( !empty( $args['onchange'] ) ) { |
|
772 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
771 | + if (!empty($args['onchange'])) { |
|
772 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
773 | 773 | } else { |
774 | 774 | $onchange = ''; |
775 | 775 | } |
776 | 776 | |
777 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
777 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
778 | 778 | |
779 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
779 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />'; |
|
780 | 780 | |
781 | - foreach ( $args['options'] as $option => $name ) { |
|
782 | - $selected = selected( $option, $value, false ); |
|
783 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
781 | + foreach ($args['options'] as $option => $name) { |
|
782 | + $selected = selected($option, $value, false); |
|
783 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | $html .= '</select>'; |
787 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
787 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
788 | 788 | |
789 | 789 | echo $html; |
790 | 790 | } |
791 | 791 | |
792 | -function wpinv_color_select_callback( $args ) { |
|
792 | +function wpinv_color_select_callback($args) { |
|
793 | 793 | global $wpinv_options; |
794 | 794 | |
795 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
795 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
796 | 796 | |
797 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
798 | - $value = $wpinv_options[ $args['id'] ]; |
|
797 | + if (isset($wpinv_options[$args['id']])) { |
|
798 | + $value = $wpinv_options[$args['id']]; |
|
799 | 799 | } else { |
800 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
800 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
801 | 801 | } |
802 | 802 | |
803 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
803 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
804 | 804 | |
805 | - foreach ( $args['options'] as $option => $color ) { |
|
806 | - $selected = selected( $option, $value, false ); |
|
807 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
805 | + foreach ($args['options'] as $option => $color) { |
|
806 | + $selected = selected($option, $value, false); |
|
807 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | $html .= '</select>'; |
811 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
811 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
812 | 812 | |
813 | 813 | echo $html; |
814 | 814 | } |
815 | 815 | |
816 | -function wpinv_rich_editor_callback( $args ) { |
|
816 | +function wpinv_rich_editor_callback($args) { |
|
817 | 817 | global $wpinv_options, $wp_version; |
818 | 818 | |
819 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
819 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
820 | 820 | |
821 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
822 | - $value = $wpinv_options[ $args['id'] ]; |
|
821 | + if (isset($wpinv_options[$args['id']])) { |
|
822 | + $value = $wpinv_options[$args['id']]; |
|
823 | 823 | |
824 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
825 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
824 | + if (empty($args['allow_blank']) && empty($value)) { |
|
825 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
826 | 826 | } |
827 | 827 | } else { |
828 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
828 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
829 | 829 | } |
830 | 830 | |
831 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
831 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
832 | 832 | |
833 | 833 | $html = '<div class="getpaid-settings-editor-input">'; |
834 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
834 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
835 | 835 | ob_start(); |
836 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
836 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
837 | 837 | $html .= ob_get_clean(); |
838 | 838 | } else { |
839 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
839 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
840 | 840 | } |
841 | 841 | |
842 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
842 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
843 | 843 | |
844 | 844 | echo $html; |
845 | 845 | } |
846 | 846 | |
847 | -function wpinv_upload_callback( $args ) { |
|
847 | +function wpinv_upload_callback($args) { |
|
848 | 848 | global $wpinv_options; |
849 | 849 | |
850 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
850 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
851 | 851 | |
852 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
852 | + if (isset($wpinv_options[$args['id']])) { |
|
853 | 853 | $value = $wpinv_options[$args['id']]; |
854 | 854 | } else { |
855 | 855 | $value = isset($args['std']) ? $args['std'] : ''; |
856 | 856 | } |
857 | 857 | |
858 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
859 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
860 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
861 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
858 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
859 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
860 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
861 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
862 | 862 | |
863 | 863 | echo $html; |
864 | 864 | } |
865 | 865 | |
866 | -function wpinv_color_callback( $args ) { |
|
866 | +function wpinv_color_callback($args) { |
|
867 | 867 | global $wpinv_options; |
868 | 868 | |
869 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
869 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
870 | 870 | |
871 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
872 | - $value = $wpinv_options[ $args['id'] ]; |
|
871 | + if (isset($wpinv_options[$args['id']])) { |
|
872 | + $value = $wpinv_options[$args['id']]; |
|
873 | 873 | } else { |
874 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
874 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
875 | 875 | } |
876 | 876 | |
877 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
877 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
878 | 878 | |
879 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
880 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
879 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
880 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
881 | 881 | |
882 | 882 | echo $html; |
883 | 883 | } |
@@ -885,9 +885,9 @@ discard block |
||
885 | 885 | function wpinv_country_states_callback($args) { |
886 | 886 | global $wpinv_options; |
887 | 887 | |
888 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
888 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
889 | 889 | |
890 | - if ( isset( $args['placeholder'] ) ) { |
|
890 | + if (isset($args['placeholder'])) { |
|
891 | 891 | $placeholder = $args['placeholder']; |
892 | 892 | } else { |
893 | 893 | $placeholder = ''; |
@@ -895,16 +895,16 @@ discard block |
||
895 | 895 | |
896 | 896 | $states = wpinv_get_country_states(); |
897 | 897 | |
898 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
899 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
898 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
899 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
900 | 900 | |
901 | - foreach ( $states as $option => $name ) { |
|
902 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
903 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
901 | + foreach ($states as $option => $name) { |
|
902 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
903 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | $html .= '</select>'; |
907 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
907 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
908 | 908 | |
909 | 909 | echo $html; |
910 | 910 | } |
@@ -919,7 +919,7 @@ discard block |
||
919 | 919 | </tr> |
920 | 920 | <tr class="bsui"> |
921 | 921 | <td colspan="2" class="p-0"> |
922 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
922 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
923 | 923 | |
924 | 924 | <?php |
925 | 925 | |
@@ -928,14 +928,14 @@ discard block |
||
928 | 928 | /** |
929 | 929 | * Displays a tax rate' edit row. |
930 | 930 | */ |
931 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
931 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
932 | 932 | ob_start(); |
933 | 933 | |
934 | - $key = sanitize_key( $key ); |
|
935 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
936 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
934 | + $key = sanitize_key($key); |
|
935 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
936 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
937 | 937 | |
938 | - if ( $echo ) { |
|
938 | + if ($echo) { |
|
939 | 939 | echo ob_get_clean(); |
940 | 940 | } else { |
941 | 941 | return ob_get_clean(); |
@@ -947,77 +947,77 @@ discard block |
||
947 | 947 | ob_start(); ?> |
948 | 948 | </td><tr> |
949 | 949 | <td colspan="2" class="wpinv_tools_tdbox"> |
950 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
951 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
950 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
951 | + <?php do_action('wpinv_tools_before'); ?> |
|
952 | 952 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
953 | 953 | <thead> |
954 | 954 | <tr> |
955 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
956 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
957 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
955 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
956 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
957 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
958 | 958 | </tr> |
959 | 959 | </thead> |
960 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
960 | + <?php do_action('wpinv_tools_row'); ?> |
|
961 | 961 | <tbody> |
962 | 962 | </tbody> |
963 | 963 | </table> |
964 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
964 | + <?php do_action('wpinv_tools_after'); ?> |
|
965 | 965 | <?php |
966 | 966 | echo ob_get_clean(); |
967 | 967 | } |
968 | 968 | |
969 | -function wpinv_descriptive_text_callback( $args ) { |
|
970 | - echo wp_kses_post( $args['desc'] ); |
|
969 | +function wpinv_descriptive_text_callback($args) { |
|
970 | + echo wp_kses_post($args['desc']); |
|
971 | 971 | } |
972 | 972 | |
973 | -function wpinv_hook_callback( $args ) { |
|
974 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
973 | +function wpinv_hook_callback($args) { |
|
974 | + do_action('wpinv_' . $args['id'], $args); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | function wpinv_set_settings_cap() { |
978 | 978 | return wpinv_get_capability(); |
979 | 979 | } |
980 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
980 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
981 | 981 | |
982 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
982 | +function wpinv_settings_sanitize_input($value, $key) { |
|
983 | 983 | |
984 | - if ( $key == 'tax_rate' ) { |
|
985 | - $value = wpinv_sanitize_amount( $value ); |
|
984 | + if ($key == 'tax_rate') { |
|
985 | + $value = wpinv_sanitize_amount($value); |
|
986 | 986 | $value = $value >= 100 ? 99 : $value; |
987 | 987 | } |
988 | 988 | |
989 | 989 | return $value; |
990 | 990 | } |
991 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
991 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
992 | 992 | |
993 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
994 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
995 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
993 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
994 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
995 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
996 | 996 | |
997 | - if ( $old != $new ) { |
|
998 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
997 | + if ($old != $new) { |
|
998 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
999 | 999 | } |
1000 | 1000 | } |
1001 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1002 | -add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1003 | -add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1004 | -add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1005 | -add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1006 | -add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1007 | -add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1008 | -add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1009 | -add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1010 | -add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1011 | -add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 ); |
|
1012 | - |
|
1013 | -function wpinv_settings_tab_bottom_emails( $active_tab, $section ) { |
|
1001 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1002 | +add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1003 | +add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1004 | +add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1005 | +add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1006 | +add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1007 | +add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1008 | +add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1009 | +add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1010 | +add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1011 | +add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2); |
|
1012 | + |
|
1013 | +function wpinv_settings_tab_bottom_emails($active_tab, $section) { |
|
1014 | 1014 | ?> |
1015 | 1015 | <div class="wpinv-email-wc-row "> |
1016 | 1016 | <div class="wpinv-email-wc-td"> |
1017 | - <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3> |
|
1017 | + <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3> |
|
1018 | 1018 | <p class="wpinv-email-wc-description"> |
1019 | 1019 | <?php |
1020 | - $description = __( 'The following wildcards can be used in email subjects, heading and content:<br> |
|
1020 | + $description = __('The following wildcards can be used in email subjects, heading and content:<br> |
|
1021 | 1021 | <strong>{site_title} :</strong> Site Title<br> |
1022 | 1022 | <strong>{name} :</strong> Customer\'s full name<br> |
1023 | 1023 | <strong>{first_name} :</strong> Customer\'s first name<br> |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | <strong>{invoice_due_date} :</strong> The date the invoice is due<br> |
1032 | 1032 | <strong>{date} :</strong> Today\'s date.<br> |
1033 | 1033 | <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br> |
1034 | - <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' ); |
|
1034 | + <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing'); |
|
1035 | 1035 | echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section); |
1036 | 1036 | ?> |
1037 | 1037 | </p> |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,27 +21,27 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
31 | 31 | |
32 | 32 | // Set the currency position. |
33 | 33 | $position = wpinv_currency_position(); |
34 | 34 | |
35 | - if ( $position == 'left_space' ) { |
|
35 | + if ($position == 'left_space') { |
|
36 | 36 | $position = 'left'; |
37 | 37 | } |
38 | 38 | |
39 | - if ( $position == 'right_space' ) { |
|
39 | + if ($position == 'right_space') { |
|
40 | 40 | $position = 'right'; |
41 | 41 | } |
42 | 42 | |
43 | 43 | ?> |
44 | - <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" /> |
|
44 | + <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" /> |
|
45 | 45 | <style> |
46 | 46 | #poststuff .input-group-text, |
47 | 47 | #poststuff .form-control { |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | </style> |
56 | 56 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
57 | 57 | |
58 | - <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?> |
|
58 | + <?php do_action('wpinv_item_details_metabox_before_price', $item); ?> |
|
59 | 59 | <div class="form-group row"> |
60 | - <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label> |
|
60 | + <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label> |
|
61 | 61 | <div class="col-sm-8"> |
62 | 62 | <div class="row"> |
63 | 63 | <div class="col-sm-4 getpaid-price-input"> |
64 | 64 | <div class="input-group input-group-sm"> |
65 | - <?php if( 'left' == $position ) : ?> |
|
65 | + <?php if ('left' == $position) : ?> |
|
66 | 66 | <div class="input-group-prepend"> |
67 | 67 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
68 | 68 | </div> |
69 | 69 | <?php endif; ?> |
70 | - <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( $item->get_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
70 | + <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr($item->get_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
71 | 71 | |
72 | - <?php if( 'left' != $position ) : ?> |
|
72 | + <?php if ('left' != $position) : ?> |
|
73 | 73 | <div class="input-group-append"> |
74 | 74 | <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
75 | 75 | </div> |
@@ -83,25 +83,25 @@ discard block |
||
83 | 83 | array( |
84 | 84 | 'id' => 'wpinv_recurring_interval', |
85 | 85 | 'name' => 'wpinv_recurring_interval', |
86 | - 'label' => __( 'Interval', 'invoicing' ), |
|
87 | - 'placeholder' => __( 'Select Interval', 'invoicing' ), |
|
88 | - 'value' => $item->get_recurring_interval( 'edit' ), |
|
86 | + 'label' => __('Interval', 'invoicing'), |
|
87 | + 'placeholder' => __('Select Interval', 'invoicing'), |
|
88 | + 'value' => $item->get_recurring_interval('edit'), |
|
89 | 89 | 'select2' => true, |
90 | 90 | 'data-allow-clear' => 'false', |
91 | 91 | 'options' => array( |
92 | - '1' => __( 'every', 'invoicing' ), |
|
93 | - '2' => __( 'every 2nd', 'invoicing' ), |
|
94 | - '3' => __( 'every 3rd', 'invoicing' ), |
|
95 | - '4' => __( 'every 4th', 'invoicing' ), |
|
96 | - '5' => __( 'every 5th', 'invoicing' ), |
|
97 | - '6' => __( 'every 6th', 'invoicing' ), |
|
98 | - '8' => __( 'every 8th', 'invoicing' ), |
|
99 | - '9' => __( 'every 9th', 'invoicing' ), |
|
100 | - '10' => __( 'every 10th', 'invoicing' ), |
|
101 | - '11' => __( 'every 11th', 'invoicing' ), |
|
102 | - '12' => __( 'every 12th', 'invoicing' ), |
|
103 | - '13' => __( 'every 13th', 'invoicing' ), |
|
104 | - '14' => __( 'every 14th', 'invoicing' ), |
|
92 | + '1' => __('every', 'invoicing'), |
|
93 | + '2' => __('every 2nd', 'invoicing'), |
|
94 | + '3' => __('every 3rd', 'invoicing'), |
|
95 | + '4' => __('every 4th', 'invoicing'), |
|
96 | + '5' => __('every 5th', 'invoicing'), |
|
97 | + '6' => __('every 6th', 'invoicing'), |
|
98 | + '8' => __('every 8th', 'invoicing'), |
|
99 | + '9' => __('every 9th', 'invoicing'), |
|
100 | + '10' => __('every 10th', 'invoicing'), |
|
101 | + '11' => __('every 11th', 'invoicing'), |
|
102 | + '12' => __('every 12th', 'invoicing'), |
|
103 | + '13' => __('every 13th', 'invoicing'), |
|
104 | + '14' => __('every 14th', 'invoicing'), |
|
105 | 105 | ) |
106 | 106 | ) |
107 | 107 | ); |
@@ -113,16 +113,16 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'id' => 'wpinv_recurring_period', |
115 | 115 | 'name' => 'wpinv_recurring_period', |
116 | - 'label' => __( 'Period', 'invoicing' ), |
|
117 | - 'placeholder' => __( 'Select Period', 'invoicing' ), |
|
118 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
116 | + 'label' => __('Period', 'invoicing'), |
|
117 | + 'placeholder' => __('Select Period', 'invoicing'), |
|
118 | + 'value' => $item->get_recurring_period('edit'), |
|
119 | 119 | 'select2' => true, |
120 | 120 | 'data-allow-clear' => 'false', |
121 | 121 | 'options' => array( |
122 | - 'D' => __( 'day', 'invoicing' ), |
|
123 | - 'W' => __( 'week', 'invoicing' ), |
|
124 | - 'M' => __( 'month', 'invoicing' ), |
|
125 | - 'Y' => __( 'year', 'invoicing' ), |
|
122 | + 'D' => __('day', 'invoicing'), |
|
123 | + 'W' => __('week', 'invoicing'), |
|
124 | + 'M' => __('month', 'invoicing'), |
|
125 | + 'Y' => __('year', 'invoicing'), |
|
126 | 126 | ) |
127 | 127 | ) |
128 | 128 | ); |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | <?php |
135 | 135 | |
136 | 136 | // Dynamic pricing. |
137 | - if( $item->supports_dynamic_pricing() ) { |
|
137 | + if ($item->supports_dynamic_pricing()) { |
|
138 | 138 | |
139 | - do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item ); |
|
139 | + do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item); |
|
140 | 140 | |
141 | 141 | // NYP toggle. |
142 | 142 | echo aui()->input( |
@@ -144,31 +144,31 @@ discard block |
||
144 | 144 | 'id' => 'wpinv_name_your_price', |
145 | 145 | 'name' => 'wpinv_name_your_price', |
146 | 146 | 'type' => 'checkbox', |
147 | - 'label' => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ), |
|
147 | + 'label' => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')), |
|
148 | 148 | 'value' => '1', |
149 | 149 | 'checked' => $item->user_can_set_their_price(), |
150 | 150 | 'no_wrap' => true, |
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | |
154 | - do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item ); |
|
154 | + do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Subscriptions. |
159 | - do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item ); |
|
159 | + do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item); |
|
160 | 160 | echo aui()->input( |
161 | 161 | array( |
162 | 162 | 'id' => 'wpinv_is_recurring', |
163 | 163 | 'name' => 'wpinv_is_recurring', |
164 | 164 | 'type' => 'checkbox', |
165 | - 'label' => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ), |
|
165 | + 'label' => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')), |
|
166 | 166 | 'value' => '1', |
167 | 167 | 'checked' => $item->is_recurring(), |
168 | 168 | 'no_wrap' => true, |
169 | 169 | ) |
170 | 170 | ); |
171 | - do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item ); |
|
171 | + do_action('wpinv_item_details_metabox_subscription_checkbox', $item); |
|
172 | 172 | |
173 | 173 | ?> |
174 | 174 | <div class="wpinv_show_if_recurring"> |
@@ -178,30 +178,30 @@ discard block |
||
178 | 178 | </div> |
179 | 179 | </div> |
180 | 180 | <div class="col-sm-1 pt-2 pl-0"> |
181 | - <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span> |
|
181 | + <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span> |
|
182 | 182 | </div> |
183 | 183 | </div> |
184 | - <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?> |
|
184 | + <?php do_action('wpinv_item_details_metabox_after_price', $item); ?> |
|
185 | 185 | |
186 | - <?php if( $item->supports_dynamic_pricing() ) : ?> |
|
187 | - <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?> |
|
186 | + <?php if ($item->supports_dynamic_pricing()) : ?> |
|
187 | + <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?> |
|
188 | 188 | <div class="wpinv_show_if_dynamic wpinv_minimum_price"> |
189 | 189 | |
190 | 190 | <div class="form-group row"> |
191 | 191 | <label for="wpinv_minimum_price" class="col-sm-3 col-form-label"> |
192 | - <?php _e( 'Minimum Price', 'invoicing' );?> |
|
192 | + <?php _e('Minimum Price', 'invoicing'); ?> |
|
193 | 193 | </label> |
194 | 194 | <div class="col-sm-8"> |
195 | 195 | <div class="input-group input-group-sm"> |
196 | - <?php if( 'left' == $position ) : ?> |
|
196 | + <?php if ('left' == $position) : ?> |
|
197 | 197 | <div class="input-group-prepend"> |
198 | 198 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
199 | 199 | </div> |
200 | 200 | <?php endif; ?> |
201 | 201 | |
202 | - <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( $item->get_minimum_price( 'edit' ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control"> |
|
202 | + <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr($item->get_minimum_price('edit')); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control"> |
|
203 | 203 | |
204 | - <?php if( 'left' != $position ) : ?> |
|
204 | + <?php if ('left' != $position) : ?> |
|
205 | 205 | <div class="input-group-append"> |
206 | 206 | <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span> |
207 | 207 | </div> |
@@ -210,45 +210,45 @@ discard block |
||
210 | 210 | </div> |
211 | 211 | |
212 | 212 | <div class="col-sm-1 pt-2 pl-0"> |
213 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span> |
|
213 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span> |
|
214 | 214 | </div> |
215 | 215 | </div> |
216 | 216 | |
217 | 217 | </div> |
218 | - <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?> |
|
218 | + <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?> |
|
219 | 219 | <?php endif; ?> |
220 | 220 | |
221 | - <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?> |
|
221 | + <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?> |
|
222 | 222 | <div class="wpinv_show_if_recurring wpinv_maximum_renewals"> |
223 | 223 | |
224 | 224 | <div class="form-group row"> |
225 | 225 | <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label"> |
226 | - <?php _e( 'Maximum Renewals', 'invoicing' );?> |
|
226 | + <?php _e('Maximum Renewals', 'invoicing'); ?> |
|
227 | 227 | </label> |
228 | 228 | <div class="col-sm-8"> |
229 | - <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
229 | + <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" /> |
|
230 | 230 | </div> |
231 | 231 | <div class="col-sm-1 pt-2 pl-0"> |
232 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span> |
|
232 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span> |
|
233 | 233 | </div> |
234 | 234 | </div> |
235 | 235 | |
236 | 236 | </div> |
237 | - <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?> |
|
237 | + <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?> |
|
238 | 238 | |
239 | - <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?> |
|
239 | + <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?> |
|
240 | 240 | <div class="wpinv_show_if_recurring wpinv_free_trial"> |
241 | 241 | |
242 | 242 | <div class="form-group row"> |
243 | - <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label> |
|
243 | + <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label> |
|
244 | 244 | |
245 | 245 | <div class="col-sm-8"> |
246 | 246 | <div class="row"> |
247 | 247 | <div class="col-sm-6"> |
248 | - <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?> |
|
248 | + <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?> |
|
249 | 249 | |
250 | 250 | <div> |
251 | - <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" > |
|
251 | + <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" > |
|
252 | 252 | </div> |
253 | 253 | </div> |
254 | 254 | <div class="col-sm-6"> |
@@ -257,17 +257,17 @@ discard block |
||
257 | 257 | array( |
258 | 258 | 'id' => 'wpinv_trial_period', |
259 | 259 | 'name' => 'wpinv_trial_period', |
260 | - 'label' => __( 'Trial Period', 'invoicing' ), |
|
261 | - 'placeholder' => __( 'Trial Period', 'invoicing' ), |
|
262 | - 'value' => $item->get_recurring_period( 'edit' ), |
|
260 | + 'label' => __('Trial Period', 'invoicing'), |
|
261 | + 'placeholder' => __('Trial Period', 'invoicing'), |
|
262 | + 'value' => $item->get_recurring_period('edit'), |
|
263 | 263 | 'select2' => true, |
264 | 264 | 'data-allow-clear' => 'false', |
265 | 265 | 'no_wrap' => true, |
266 | 266 | 'options' => array( |
267 | - 'D' => __( 'day(s)', 'invoicing' ), |
|
268 | - 'W' => __( 'week(s)', 'invoicing' ), |
|
269 | - 'M' => __( 'month(s)', 'invoicing' ), |
|
270 | - 'Y' => __( 'year(s)', 'invoicing' ), |
|
267 | + 'D' => __('day(s)', 'invoicing'), |
|
268 | + 'W' => __('week(s)', 'invoicing'), |
|
269 | + 'M' => __('month(s)', 'invoicing'), |
|
270 | + 'Y' => __('year(s)', 'invoicing'), |
|
271 | 271 | ) |
272 | 272 | ) |
273 | 273 | ); |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | </div> |
279 | 279 | |
280 | 280 | <div class="col-sm-1 pt-2 pl-0"> |
281 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span> |
|
281 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span> |
|
282 | 282 | </div> |
283 | 283 | |
284 | 284 | </div> |
285 | 285 | |
286 | 286 | </div> |
287 | - <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?> |
|
287 | + <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?> |
|
288 | 288 | |
289 | - <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?> |
|
289 | + <?php do_action('wpinv_item_details_metabox_item_details', $item); ?> |
|
290 | 290 | </div> |
291 | 291 | <?php |
292 | 292 | |
@@ -297,31 +297,31 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @param int $post_id |
299 | 299 | */ |
300 | - public static function save( $post_id ) { |
|
300 | + public static function save($post_id) { |
|
301 | 301 | |
302 | 302 | // Prepare the item. |
303 | - $item = new WPInv_Item( $post_id ); |
|
303 | + $item = new WPInv_Item($post_id); |
|
304 | 304 | |
305 | 305 | // Load new data. |
306 | 306 | $item->set_props( |
307 | 307 | array( |
308 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
309 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
310 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
311 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
312 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
313 | - 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
314 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
315 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
316 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
317 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
318 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
319 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
320 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
308 | + 'price' => isset($_POST['wpinv_item_price']) ? (float) $_POST['wpinv_item_price'] : null, |
|
309 | + 'vat_rule' => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null, |
|
310 | + 'vat_class' => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null, |
|
311 | + 'type' => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null, |
|
312 | + 'is_dynamic_pricing' => isset($_POST['wpinv_name_your_price']), |
|
313 | + 'minimum_price' => isset($_POST['wpinv_minimum_price']) ? (float) $_POST['wpinv_minimum_price'] : null, |
|
314 | + 'is_recurring' => isset($_POST['wpinv_is_recurring']), |
|
315 | + 'recurring_period' => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null, |
|
316 | + 'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
317 | + 'recurring_limit' => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
318 | + 'is_free_trial' => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null, |
|
319 | + 'trial_period' => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null, |
|
320 | + 'trial_interval' => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
321 | 321 | ) |
322 | 322 | ); |
323 | 323 | |
324 | 324 | $item->save(); |
325 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
325 | + do_action('getpaid_item_metabox_save', $post_id, $item); |
|
326 | 326 | } |
327 | 327 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,26 +21,26 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | echo "<div class='bsui' style='max-width: 600px;padding-top: 10px;'>"; |
30 | 30 | |
31 | - do_action( 'wpinv_item_before_vat_metabox', $item ); |
|
31 | + do_action('wpinv_item_before_vat_metabox', $item); |
|
32 | 32 | |
33 | 33 | // Output the vat rules settings. |
34 | - do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item ); |
|
35 | - self::output_vat_rules( $item ); |
|
36 | - do_action( 'wpinv_item_vat_metabox_vat_rules', $item ); |
|
34 | + do_action('wpinv_item_vat_metabox_before_vat_rules', $item); |
|
35 | + self::output_vat_rules($item); |
|
36 | + do_action('wpinv_item_vat_metabox_vat_rules', $item); |
|
37 | 37 | |
38 | 38 | // Output vat class settings. |
39 | - do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item ); |
|
40 | - self::output_vat_classes( $item ); |
|
41 | - do_action( 'wpinv_item_vat_metabox_vat_class', $item ); |
|
39 | + do_action('wpinv_item_vat_metabox_before_vat_rules', $item); |
|
40 | + self::output_vat_classes($item); |
|
41 | + do_action('wpinv_item_vat_metabox_vat_class', $item); |
|
42 | 42 | |
43 | - do_action( 'wpinv_item_vat_metabox', $item ); |
|
43 | + do_action('wpinv_item_vat_metabox', $item); |
|
44 | 44 | |
45 | 45 | echo '</div>'; |
46 | 46 | } |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param WPInv_Item $item |
52 | 52 | */ |
53 | - public static function output_vat_rules( $item ) { |
|
53 | + public static function output_vat_rules($item) { |
|
54 | 54 | ?> |
55 | 55 | |
56 | 56 | <div class="wpinv_vat_rules"> |
57 | 57 | |
58 | 58 | <div class="form-group row"> |
59 | 59 | <label for="wpinv_vat_rules" class="col-sm-3 col-form-label"> |
60 | - <?php _e( 'Tax Rule', 'invoicing' );?> |
|
60 | + <?php _e('Tax Rule', 'invoicing'); ?> |
|
61 | 61 | </label> |
62 | 62 | <div class="col-sm-8"> |
63 | 63 | <?php |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | array( |
66 | 66 | 'id' => 'wpinv_vat_rules', |
67 | 67 | 'name' => 'wpinv_vat_rules', |
68 | - 'placeholder' => __( 'Select tax rule', 'invoicing' ), |
|
69 | - 'value' => $item->get_vat_rule( 'edit' ), |
|
68 | + 'placeholder' => __('Select tax rule', 'invoicing'), |
|
69 | + 'value' => $item->get_vat_rule('edit'), |
|
70 | 70 | 'select2' => true, |
71 | 71 | 'data-allow-clear' => 'false', |
72 | 72 | 'no_wrap' => true, |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param WPInv_Item $item |
90 | 90 | */ |
91 | - public static function output_vat_classes( $item ) { |
|
91 | + public static function output_vat_classes($item) { |
|
92 | 92 | ?> |
93 | 93 | |
94 | 94 | <div class="wpinv_vat_classes"> |
95 | 95 | |
96 | 96 | <div class="form-group row"> |
97 | 97 | <label for="wpinv_vat_class" class="col-sm-3 col-form-label"> |
98 | - <?php _e( 'Tax Class', 'invoicing' );?> |
|
98 | + <?php _e('Tax Class', 'invoicing'); ?> |
|
99 | 99 | </label> |
100 | 100 | <div class="col-sm-8"> |
101 | 101 | <?php |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | array( |
104 | 104 | 'id' => 'wpinv_vat_class', |
105 | 105 | 'name' => 'wpinv_vat_class', |
106 | - 'placeholder' => __( 'Select tax class', 'invoicing' ), |
|
107 | - 'value' => $item->get_vat_class( 'edit' ), |
|
106 | + 'placeholder' => __('Select tax class', 'invoicing'), |
|
107 | + 'value' => $item->get_vat_class('edit'), |
|
108 | 108 | 'select2' => true, |
109 | 109 | 'data-allow-clear' => 'false', |
110 | 110 | 'no_wrap' => true, |
@@ -12,267 +12,267 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Metaboxes { |
14 | 14 | |
15 | - /** |
|
16 | - * Only save metaboxes once. |
|
17 | - * |
|
18 | - * @var boolean |
|
19 | - */ |
|
20 | - private static $saved_meta_boxes = false; |
|
21 | - |
|
22 | 15 | /** |
23 | - * Hook in methods. |
|
24 | - */ |
|
25 | - public static function init() { |
|
26 | - |
|
27 | - // Register metaboxes. |
|
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
29 | - |
|
30 | - // Remove metaboxes. |
|
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
32 | - |
|
33 | - // Rename metaboxes. |
|
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
35 | - |
|
36 | - // Save metaboxes. |
|
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
38 | - } |
|
16 | + * Only save metaboxes once. |
|
17 | + * |
|
18 | + * @var boolean |
|
19 | + */ |
|
20 | + private static $saved_meta_boxes = false; |
|
39 | 21 | |
40 | - /** |
|
41 | - * Register core metaboxes. |
|
42 | - */ |
|
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
44 | - |
|
45 | - // For invoices... |
|
46 | - self::add_invoice_meta_boxes( $post_type, $post ); |
|
22 | + /** |
|
23 | + * Hook in methods. |
|
24 | + */ |
|
25 | + public static function init() { |
|
47 | 26 | |
48 | - // For payment forms. |
|
49 | - self::add_payment_form_meta_boxes( $post_type ); |
|
27 | + // Register metaboxes. |
|
28 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
50 | 29 | |
51 | - // For invoice items. |
|
52 | - self::add_item_meta_boxes( $post_type ); |
|
30 | + // Remove metaboxes. |
|
31 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
53 | 32 | |
54 | - // For invoice discounts. |
|
55 | - if ( $post_type == 'wpi_discount' ) { |
|
56 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
57 | - } |
|
33 | + // Rename metaboxes. |
|
34 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
58 | 35 | |
59 | - } |
|
36 | + // Save metaboxes. |
|
37 | + add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
38 | + } |
|
60 | 39 | |
61 | - /** |
|
62 | - * Register core metaboxes. |
|
63 | - */ |
|
64 | - protected static function add_payment_form_meta_boxes( $post_type ) { |
|
40 | + /** |
|
41 | + * Register core metaboxes. |
|
42 | + */ |
|
43 | + public static function add_meta_boxes( $post_type, $post ) { |
|
65 | 44 | |
66 | - // For payment forms. |
|
67 | - if ( $post_type == 'wpi_payment_form' ) { |
|
45 | + // For invoices... |
|
46 | + self::add_invoice_meta_boxes( $post_type, $post ); |
|
68 | 47 | |
69 | - // Design payment form. |
|
70 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
48 | + // For payment forms. |
|
49 | + self::add_payment_form_meta_boxes( $post_type ); |
|
71 | 50 | |
72 | - // Payment form information. |
|
73 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
51 | + // For invoice items. |
|
52 | + self::add_item_meta_boxes( $post_type ); |
|
74 | 53 | |
75 | - } |
|
54 | + // For invoice discounts. |
|
55 | + if ( $post_type == 'wpi_discount' ) { |
|
56 | + add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
57 | + } |
|
76 | 58 | |
77 | - } |
|
59 | + } |
|
78 | 60 | |
79 | - /** |
|
80 | - * Register core metaboxes. |
|
81 | - */ |
|
82 | - protected static function add_item_meta_boxes( $post_type ) { |
|
61 | + /** |
|
62 | + * Register core metaboxes. |
|
63 | + */ |
|
64 | + protected static function add_payment_form_meta_boxes( $post_type ) { |
|
83 | 65 | |
84 | - if ( $post_type == 'wpi_item' ) { |
|
66 | + // For payment forms. |
|
67 | + if ( $post_type == 'wpi_payment_form' ) { |
|
85 | 68 | |
86 | - // Item details. |
|
87 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
69 | + // Design payment form. |
|
70 | + add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
88 | 71 | |
89 | - // If taxes are enabled, register the tax metabox. |
|
90 | - if ( wpinv_use_taxes() ) { |
|
91 | - add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
92 | - } |
|
72 | + // Payment form information. |
|
73 | + add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
93 | 74 | |
94 | - // Item info. |
|
95 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
75 | + } |
|
96 | 76 | |
97 | - } |
|
77 | + } |
|
98 | 78 | |
99 | - } |
|
79 | + /** |
|
80 | + * Register core metaboxes. |
|
81 | + */ |
|
82 | + protected static function add_item_meta_boxes( $post_type ) { |
|
100 | 83 | |
101 | - /** |
|
102 | - * Register invoice metaboxes. |
|
103 | - */ |
|
104 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
84 | + if ( $post_type == 'wpi_item' ) { |
|
105 | 85 | |
106 | - // For invoices... |
|
107 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
108 | - $invoice = new WPInv_Invoice( $post ); |
|
86 | + // Item details. |
|
87 | + add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
109 | 88 | |
110 | - // Resend invoice. |
|
111 | - if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) { |
|
89 | + // If taxes are enabled, register the tax metabox. |
|
90 | + if ( wpinv_use_taxes() ) { |
|
91 | + add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
92 | + } |
|
112 | 93 | |
113 | - add_meta_box( |
|
114 | - 'wpinv-mb-resend-invoice', |
|
115 | - sprintf( |
|
116 | - __( 'Resend %s', 'invoicing' ), |
|
117 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
118 | - ), |
|
119 | - 'GetPaid_Meta_Box_Resend_Invoice::output', |
|
120 | - $post_type, |
|
121 | - 'side', |
|
122 | - 'low' |
|
123 | - ); |
|
94 | + // Item info. |
|
95 | + add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
124 | 96 | |
125 | - } |
|
97 | + } |
|
126 | 98 | |
127 | - // Subscriptions. |
|
128 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
129 | - if ( ! empty( $subscription ) ) { |
|
130 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
131 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
132 | - } |
|
133 | - |
|
134 | - // Invoice details. |
|
135 | - add_meta_box( |
|
136 | - 'wpinv-details', |
|
137 | - sprintf( |
|
138 | - __( '%s Details', 'invoicing' ), |
|
139 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
140 | - ), |
|
141 | - 'GetPaid_Meta_Box_Invoice_Details::output', |
|
142 | - $post_type, |
|
143 | - 'side' |
|
144 | - ); |
|
145 | - |
|
146 | - // Payment details. |
|
147 | - if ( ! $invoice->is_draft() ) { |
|
148 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
149 | - } |
|
99 | + } |
|
150 | 100 | |
151 | - // Billing details. |
|
152 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
101 | + /** |
|
102 | + * Register invoice metaboxes. |
|
103 | + */ |
|
104 | + protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
105 | + |
|
106 | + // For invoices... |
|
107 | + if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
108 | + $invoice = new WPInv_Invoice( $post ); |
|
109 | + |
|
110 | + // Resend invoice. |
|
111 | + if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) { |
|
112 | + |
|
113 | + add_meta_box( |
|
114 | + 'wpinv-mb-resend-invoice', |
|
115 | + sprintf( |
|
116 | + __( 'Resend %s', 'invoicing' ), |
|
117 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
118 | + ), |
|
119 | + 'GetPaid_Meta_Box_Resend_Invoice::output', |
|
120 | + $post_type, |
|
121 | + 'side', |
|
122 | + 'low' |
|
123 | + ); |
|
124 | + |
|
125 | + } |
|
126 | + |
|
127 | + // Subscriptions. |
|
128 | + $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
129 | + if ( ! empty( $subscription ) ) { |
|
130 | + add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
131 | + add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
132 | + } |
|
133 | + |
|
134 | + // Invoice details. |
|
135 | + add_meta_box( |
|
136 | + 'wpinv-details', |
|
137 | + sprintf( |
|
138 | + __( '%s Details', 'invoicing' ), |
|
139 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
140 | + ), |
|
141 | + 'GetPaid_Meta_Box_Invoice_Details::output', |
|
142 | + $post_type, |
|
143 | + 'side' |
|
144 | + ); |
|
145 | + |
|
146 | + // Payment details. |
|
147 | + if ( ! $invoice->is_draft() ) { |
|
148 | + add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
149 | + } |
|
150 | + |
|
151 | + // Billing details. |
|
152 | + add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
153 | 153 | |
154 | - // Invoice items. |
|
155 | - add_meta_box( |
|
156 | - 'wpinv-items', |
|
157 | - sprintf( |
|
158 | - __( '%s Items', 'invoicing' ), |
|
159 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
160 | - ), |
|
161 | - 'GetPaid_Meta_Box_Invoice_Items::output', |
|
162 | - $post_type, |
|
163 | - 'normal', |
|
164 | - 'high' |
|
165 | - ); |
|
154 | + // Invoice items. |
|
155 | + add_meta_box( |
|
156 | + 'wpinv-items', |
|
157 | + sprintf( |
|
158 | + __( '%s Items', 'invoicing' ), |
|
159 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
160 | + ), |
|
161 | + 'GetPaid_Meta_Box_Invoice_Items::output', |
|
162 | + $post_type, |
|
163 | + 'normal', |
|
164 | + 'high' |
|
165 | + ); |
|
166 | 166 | |
167 | - // Invoice notes. |
|
168 | - add_meta_box( |
|
169 | - 'wpinv-notes', |
|
170 | - sprintf( |
|
171 | - __( '%s Notes', 'invoicing' ), |
|
172 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
173 | - ), |
|
174 | - 'WPInv_Meta_Box_Notes::output', |
|
175 | - $post_type, |
|
176 | - 'side', |
|
177 | - 'low' |
|
178 | - ); |
|
179 | - |
|
180 | - // Shipping Address. |
|
181 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
182 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
183 | - } |
|
184 | - |
|
185 | - // Payment form information. |
|
186 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
187 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
188 | - } |
|
189 | - |
|
190 | - } |
|
191 | - |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Remove some metaboxes. |
|
196 | - */ |
|
197 | - public static function remove_meta_boxes() { |
|
198 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * Rename other metaboxes. |
|
203 | - */ |
|
204 | - public static function rename_meta_boxes() { |
|
167 | + // Invoice notes. |
|
168 | + add_meta_box( |
|
169 | + 'wpinv-notes', |
|
170 | + sprintf( |
|
171 | + __( '%s Notes', 'invoicing' ), |
|
172 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
173 | + ), |
|
174 | + 'WPInv_Meta_Box_Notes::output', |
|
175 | + $post_type, |
|
176 | + 'side', |
|
177 | + 'low' |
|
178 | + ); |
|
179 | + |
|
180 | + // Shipping Address. |
|
181 | + if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
182 | + add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
183 | + } |
|
184 | + |
|
185 | + // Payment form information. |
|
186 | + if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
187 | + add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
188 | + } |
|
189 | + |
|
190 | + } |
|
191 | + |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Remove some metaboxes. |
|
196 | + */ |
|
197 | + public static function remove_meta_boxes() { |
|
198 | + remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * Rename other metaboxes. |
|
203 | + */ |
|
204 | + public static function rename_meta_boxes() { |
|
205 | 205 | |
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * Check if we're saving, then trigger an action based on the post type. |
|
210 | - * |
|
211 | - * @param int $post_id Post ID. |
|
212 | - * @param object $post Post object. |
|
213 | - */ |
|
214 | - public static function save_meta_boxes( $post_id, $post ) { |
|
215 | - $post_id = absint( $post_id ); |
|
216 | - $data = wp_unslash( $_POST ); |
|
217 | - |
|
218 | - // Do not save for ajax requests. |
|
219 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
220 | - return; |
|
221 | - } |
|
222 | - |
|
223 | - // $post_id and $post are required |
|
224 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
225 | - return; |
|
226 | - } |
|
227 | - |
|
228 | - // Dont' save meta boxes for revisions or autosaves. |
|
229 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
230 | - return; |
|
231 | - } |
|
232 | - |
|
233 | - // Check the nonce. |
|
234 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
235 | - return; |
|
236 | - } |
|
237 | - |
|
238 | - // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
239 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
240 | - return; |
|
241 | - } |
|
242 | - |
|
243 | - // Check user has permission to edit. |
|
244 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
245 | - return; |
|
246 | - } |
|
247 | - |
|
248 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
249 | - |
|
250 | - // We need this save event to run once to avoid potential endless loops. |
|
251 | - self::$saved_meta_boxes = true; |
|
252 | - |
|
253 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
254 | - |
|
255 | - } |
|
256 | - |
|
257 | - // Ensure this is our post type. |
|
258 | - $post_types_map = array( |
|
259 | - 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
260 | - 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
261 | - 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
262 | - ); |
|
263 | - |
|
264 | - // Is this our post type? |
|
265 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
266 | - return; |
|
267 | - } |
|
268 | - |
|
269 | - // We need this save event to run once to avoid potential endless loops. |
|
270 | - self::$saved_meta_boxes = true; |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * Check if we're saving, then trigger an action based on the post type. |
|
210 | + * |
|
211 | + * @param int $post_id Post ID. |
|
212 | + * @param object $post Post object. |
|
213 | + */ |
|
214 | + public static function save_meta_boxes( $post_id, $post ) { |
|
215 | + $post_id = absint( $post_id ); |
|
216 | + $data = wp_unslash( $_POST ); |
|
217 | + |
|
218 | + // Do not save for ajax requests. |
|
219 | + if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
220 | + return; |
|
221 | + } |
|
222 | + |
|
223 | + // $post_id and $post are required |
|
224 | + if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
225 | + return; |
|
226 | + } |
|
227 | + |
|
228 | + // Dont' save meta boxes for revisions or autosaves. |
|
229 | + if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
230 | + return; |
|
231 | + } |
|
232 | + |
|
233 | + // Check the nonce. |
|
234 | + if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
235 | + return; |
|
236 | + } |
|
237 | + |
|
238 | + // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
239 | + if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
240 | + return; |
|
241 | + } |
|
242 | + |
|
243 | + // Check user has permission to edit. |
|
244 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
245 | + return; |
|
246 | + } |
|
247 | + |
|
248 | + if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
249 | + |
|
250 | + // We need this save event to run once to avoid potential endless loops. |
|
251 | + self::$saved_meta_boxes = true; |
|
252 | + |
|
253 | + return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
254 | + |
|
255 | + } |
|
256 | + |
|
257 | + // Ensure this is our post type. |
|
258 | + $post_types_map = array( |
|
259 | + 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
260 | + 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
261 | + 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
262 | + ); |
|
263 | + |
|
264 | + // Is this our post type? |
|
265 | + if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
266 | + return; |
|
267 | + } |
|
268 | + |
|
269 | + // We need this save event to run once to avoid potential endless loops. |
|
270 | + self::$saved_meta_boxes = true; |
|
271 | 271 | |
272 | - // Save the post. |
|
273 | - $class = $post_types_map[ $post->post_type ]; |
|
274 | - $class::save( $post_id, $_POST, $post ); |
|
272 | + // Save the post. |
|
273 | + $class = $post_types_map[ $post->post_type ]; |
|
274 | + $class::save( $post_id, $_POST, $post ); |
|
275 | 275 | |
276 | - } |
|
276 | + } |
|
277 | 277 | |
278 | 278 | } |
@@ -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 | * Metaboxes Admin Class |
@@ -25,35 +25,35 @@ discard block |
||
25 | 25 | public static function init() { |
26 | 26 | |
27 | 27 | // Register metaboxes. |
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
28 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2); |
|
29 | 29 | |
30 | 30 | // Remove metaboxes. |
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
31 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30); |
|
32 | 32 | |
33 | 33 | // Rename metaboxes. |
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
34 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45); |
|
35 | 35 | |
36 | 36 | // Save metaboxes. |
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
37 | + add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Register core metaboxes. |
42 | 42 | */ |
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
43 | + public static function add_meta_boxes($post_type, $post) { |
|
44 | 44 | |
45 | 45 | // For invoices... |
46 | - self::add_invoice_meta_boxes( $post_type, $post ); |
|
46 | + self::add_invoice_meta_boxes($post_type, $post); |
|
47 | 47 | |
48 | 48 | // For payment forms. |
49 | - self::add_payment_form_meta_boxes( $post_type ); |
|
49 | + self::add_payment_form_meta_boxes($post_type); |
|
50 | 50 | |
51 | 51 | // For invoice items. |
52 | - self::add_item_meta_boxes( $post_type ); |
|
52 | + self::add_item_meta_boxes($post_type); |
|
53 | 53 | |
54 | 54 | // For invoice discounts. |
55 | - if ( $post_type == 'wpi_discount' ) { |
|
56 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
55 | + if ($post_type == 'wpi_discount') { |
|
56 | + add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | } |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * Register core metaboxes. |
63 | 63 | */ |
64 | - protected static function add_payment_form_meta_boxes( $post_type ) { |
|
64 | + protected static function add_payment_form_meta_boxes($post_type) { |
|
65 | 65 | |
66 | 66 | // For payment forms. |
67 | - if ( $post_type == 'wpi_payment_form' ) { |
|
67 | + if ($post_type == 'wpi_payment_form') { |
|
68 | 68 | |
69 | 69 | // Design payment form. |
70 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
70 | + add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal'); |
|
71 | 71 | |
72 | 72 | // Payment form information. |
73 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
73 | + add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side'); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
@@ -79,20 +79,20 @@ discard block |
||
79 | 79 | /** |
80 | 80 | * Register core metaboxes. |
81 | 81 | */ |
82 | - protected static function add_item_meta_boxes( $post_type ) { |
|
82 | + protected static function add_item_meta_boxes($post_type) { |
|
83 | 83 | |
84 | - if ( $post_type == 'wpi_item' ) { |
|
84 | + if ($post_type == 'wpi_item') { |
|
85 | 85 | |
86 | 86 | // Item details. |
87 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
87 | + add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high'); |
|
88 | 88 | |
89 | 89 | // If taxes are enabled, register the tax metabox. |
90 | - if ( wpinv_use_taxes() ) { |
|
91 | - add_meta_box( 'wpinv_item_vat', __( 'Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
90 | + if (wpinv_use_taxes()) { |
|
91 | + add_meta_box('wpinv_item_vat', __('Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // Item info. |
95 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
95 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core'); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * Register invoice metaboxes. |
103 | 103 | */ |
104 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
104 | + protected static function add_invoice_meta_boxes($post_type, $post) { |
|
105 | 105 | |
106 | 106 | // For invoices... |
107 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
108 | - $invoice = new WPInv_Invoice( $post ); |
|
107 | + if (getpaid_is_invoice_post_type($post_type)) { |
|
108 | + $invoice = new WPInv_Invoice($post); |
|
109 | 109 | |
110 | 110 | // Resend invoice. |
111 | - if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) { |
|
111 | + if (!$invoice->is_draft() && !$invoice->is_paid()) { |
|
112 | 112 | |
113 | 113 | add_meta_box( |
114 | 114 | 'wpinv-mb-resend-invoice', |
115 | 115 | sprintf( |
116 | - __( 'Resend %s', 'invoicing' ), |
|
117 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
116 | + __('Resend %s', 'invoicing'), |
|
117 | + ucfirst($invoice->get_invoice_quote_type()) |
|
118 | 118 | ), |
119 | 119 | 'GetPaid_Meta_Box_Resend_Invoice::output', |
120 | 120 | $post_type, |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | // Subscriptions. |
128 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
129 | - if ( ! empty( $subscription ) ) { |
|
130 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
131 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
128 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
129 | + if (!empty($subscription)) { |
|
130 | + add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced'); |
|
131 | + add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // Invoice details. |
135 | 135 | add_meta_box( |
136 | 136 | 'wpinv-details', |
137 | 137 | sprintf( |
138 | - __( '%s Details', 'invoicing' ), |
|
139 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
138 | + __('%s Details', 'invoicing'), |
|
139 | + ucfirst($invoice->get_invoice_quote_type()) |
|
140 | 140 | ), |
141 | 141 | 'GetPaid_Meta_Box_Invoice_Details::output', |
142 | 142 | $post_type, |
@@ -144,19 +144,19 @@ discard block |
||
144 | 144 | ); |
145 | 145 | |
146 | 146 | // Payment details. |
147 | - if ( ! $invoice->is_draft() ) { |
|
148 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
147 | + if (!$invoice->is_draft()) { |
|
148 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Billing details. |
152 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
152 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high'); |
|
153 | 153 | |
154 | 154 | // Invoice items. |
155 | 155 | add_meta_box( |
156 | 156 | 'wpinv-items', |
157 | 157 | sprintf( |
158 | - __( '%s Items', 'invoicing' ), |
|
159 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
158 | + __('%s Items', 'invoicing'), |
|
159 | + ucfirst($invoice->get_invoice_quote_type()) |
|
160 | 160 | ), |
161 | 161 | 'GetPaid_Meta_Box_Invoice_Items::output', |
162 | 162 | $post_type, |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | add_meta_box( |
169 | 169 | 'wpinv-notes', |
170 | 170 | sprintf( |
171 | - __( '%s Notes', 'invoicing' ), |
|
172 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
171 | + __('%s Notes', 'invoicing'), |
|
172 | + ucfirst($invoice->get_invoice_quote_type()) |
|
173 | 173 | ), |
174 | 174 | 'WPInv_Meta_Box_Notes::output', |
175 | 175 | $post_type, |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | ); |
179 | 179 | |
180 | 180 | // Shipping Address. |
181 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
182 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
181 | + if (get_post_meta($invoice->get_id(), 'shipping_address', true)) { |
|
182 | + add_meta_box('wpinv-invoice-shipping-details', __('Shipping Address', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high'); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | // Payment form information. |
186 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
187 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
186 | + if (get_post_meta($invoice->get_id(), 'payment_form_data', true)) { |
|
187 | + add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high'); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * Remove some metaboxes. |
196 | 196 | */ |
197 | 197 | public static function remove_meta_boxes() { |
198 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
198 | + remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -211,46 +211,46 @@ discard block |
||
211 | 211 | * @param int $post_id Post ID. |
212 | 212 | * @param object $post Post object. |
213 | 213 | */ |
214 | - public static function save_meta_boxes( $post_id, $post ) { |
|
215 | - $post_id = absint( $post_id ); |
|
216 | - $data = wp_unslash( $_POST ); |
|
214 | + public static function save_meta_boxes($post_id, $post) { |
|
215 | + $post_id = absint($post_id); |
|
216 | + $data = wp_unslash($_POST); |
|
217 | 217 | |
218 | 218 | // Do not save for ajax requests. |
219 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
219 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
220 | 220 | return; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // $post_id and $post are required |
224 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
224 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // Dont' save meta boxes for revisions or autosaves. |
229 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
229 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
230 | 230 | return; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // Check the nonce. |
234 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
234 | + if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) { |
|
235 | 235 | return; |
236 | 236 | } |
237 | 237 | |
238 | 238 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
239 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
239 | + if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | |
243 | 243 | // Check user has permission to edit. |
244 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
244 | + if (!current_user_can('edit_post', $post_id)) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | |
248 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
248 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
249 | 249 | |
250 | 250 | // We need this save event to run once to avoid potential endless loops. |
251 | 251 | self::$saved_meta_boxes = true; |
252 | 252 | |
253 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
253 | + return GetPaid_Meta_Box_Invoice_Address::save($post_id); |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | ); |
263 | 263 | |
264 | 264 | // Is this our post type? |
265 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
265 | + if (!isset($post_types_map[$post->post_type])) { |
|
266 | 266 | return; |
267 | 267 | } |
268 | 268 | |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | self::$saved_meta_boxes = true; |
271 | 271 | |
272 | 272 | // Save the post. |
273 | - $class = $post_types_map[ $post->post_type ]; |
|
274 | - $class::save( $post_id, $_POST, $post ); |
|
273 | + $class = $post_types_map[$post->post_type]; |
|
274 | + $class::save($post_id, $_POST, $post); |
|
275 | 275 | |
276 | 276 | } |
277 | 277 |