Completed
Push — master ( fe4649...9700bf )
by Stiofan
14s
created
templates/emails/wpinv-email-refunded_invoice.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 ?>
8 8
 
9 9
 <p><?php
10
-    if ( !empty( $partial_refund ) ) {
11
-        printf( __( 'Hi there. Your invoice on %s has been partially refunded.', 'invoicing' ), wpinv_get_business_name() );
10
+    if (!empty($partial_refund)) {
11
+        printf(__('Hi there. Your invoice on %s has been partially refunded.', 'invoicing'), wpinv_get_business_name());
12 12
     }
13 13
     else {
14
-        printf( __( 'Hi there. Your invoice on %s has been refunded.', 'invoicing' ), wpinv_get_business_name() );
14
+        printf(__('Hi there. Your invoice on %s has been refunded.', 'invoicing'), wpinv_get_business_name());
15 15
     }
16 16
 ?></p>
17 17
 
18 18
 <?php
19
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
19
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
20 20
 
21
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
21
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
22 22
 
23
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
23
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
24 24
 
25
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
26 25
\ No newline at end of file
26
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
7 8
 ?>
@@ -9,8 +10,7 @@  discard block
 block discarded – undo
9 10
 <p><?php
10 11
     if ( !empty( $partial_refund ) ) {
11 12
         printf( __( 'Hi there. Your invoice on %s has been partially refunded.', 'invoicing' ), wpinv_get_business_name() );
12
-    }
13
-    else {
13
+    } else {
14 14
         printf( __( 'Hi there. Your invoice on %s has been refunded.', 'invoicing' ), wpinv_get_business_name() );
15 15
     }
16 16
 ?></p>
Please login to merge, or discard this patch.
templates/emails/wpinv-email-invoice-details.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 global $wpinv_euvat;
7 8
 
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6 6
 global $wpinv_euvat;
7 7
 
8
-$sent_to_admin  = !empty( $sent_to_admin ) ? true : false;
9
-$invoice_url = $invoice->get_view_url( true );
8
+$sent_to_admin = !empty($sent_to_admin) ? true : false;
9
+$invoice_url = $invoice->get_view_url(true);
10 10
 $use_taxes = wpinv_use_taxes();
11 11
 $vat_name = $wpinv_euvat->get_vat_name();
12 12
 
13
-do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?>
13
+do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?>
14 14
 <div id="wpinv-email-details">
15
-    <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3>
15
+    <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3>
16 16
     <table class="table table-bordered table-sm">
17
-        <?php if ( $invoice_number = $invoice->get_number() ) { ?>
17
+        <?php if ($invoice_number = $invoice->get_number()) { ?>
18 18
             <tr>
19
-                <td><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td>
20
-                <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td>
19
+                <td><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></td>
20
+                <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td>
21 21
             </tr>
22 22
         <?php } ?>
23 23
         <tr>
24
-            <td><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td>
25
-            <td><?php echo $invoice->get_status( true ); ?></td>
24
+            <td><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></td>
25
+            <td><?php echo $invoice->get_status(true); ?></td>
26 26
         </tr>
27
-        <?php if ( $invoice->is_renewal() ) { ?>
27
+        <?php if ($invoice->is_renewal()) { ?>
28 28
         <tr>
29
-            <td><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></td>
30
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
29
+            <td><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></td>
30
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
31 31
         </tr>
32 32
         <?php } ?>
33
-        <?php if ( $gateway_title = $invoice->get_gateway_title() ) { ?>
34
-            <td><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></td>
33
+        <?php if ($gateway_title = $invoice->get_gateway_title()) { ?>
34
+            <td><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></td>
35 35
             <td><?php echo $gateway_title; ?></td>
36 36
         <?php } ?>
37
-        <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?>
37
+        <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?>
38 38
             <tr>
39
-                <td><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td>
40
-                <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td>
39
+                <td><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></td>
40
+                <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td>
41 41
             </tr>
42 42
         <?php } ?>
43
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?>
43
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?>
44 44
             <tr>
45
-                <td><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></td>
46
-                <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td>
45
+                <td><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></td>
46
+                <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td>
47 47
             </tr>
48 48
         <?php } ?>
49
-        <?php if ( empty( $sent_to_admin ) && $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
49
+        <?php if (empty($sent_to_admin) && $owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
50 50
             <tr>
51
-                <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
51
+                <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
52 52
                 <td><?php echo $owner_vat_number; ?></td>
53 53
             </tr>
54 54
         <?php } ?>
55
-        <?php if ( $use_taxes && $user_vat_number = $invoice->vat_number ) { ?>
55
+        <?php if ($use_taxes && $user_vat_number = $invoice->vat_number) { ?>
56 56
             <tr>
57
-                <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
57
+                <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
58 58
                 <td><?php echo $user_vat_number; ?></td>
59 59
             </tr>
60 60
         <?php } ?>
61 61
         <tr class="table-active">
62
-            <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td>
63
-            <td><strong><?php echo $invoice->get_total( true ); ?></strong></td>
62
+            <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td>
63
+            <td><strong><?php echo $invoice->get_total(true); ?></strong></td>
64 64
         </tr>
65 65
     </table>
66 66
 </div>
67
-<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?>
68 67
\ No newline at end of file
68
+<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?>
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
templates/wpinv-payment-processing.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
2 2
 global $wpi_invoice;
3 3
 
4 4
 $success_page_uri = wpinv_get_success_page_uri();
5
-if ( !empty( $wpi_invoice ) ) {
6
-    $success_page_uri = add_query_arg( 'invoice_key', $wpi_invoice->get_key(), $success_page_uri );
5
+if (!empty($wpi_invoice)) {
6
+    $success_page_uri = add_query_arg('invoice_key', $wpi_invoice->get_key(), $success_page_uri);
7 7
 }
8 8
 ?>
9 9
 <div id="wpinv-payment-processing">
10
-    <p><?php echo wp_sprintf( __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), $success_page_uri ); ?> <i class="fa fa-spin fa-refresh"></i></p>
10
+    <p><?php echo wp_sprintf(__('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), $success_page_uri); ?> <i class="fa fa-spin fa-refresh"></i></p>
11 11
     <script type="text/javascript">setTimeout(function(){ window.location = '<?php echo $success_page_uri; ?>'; }, 10000);</script>
12 12
 </div>
13 13
\ No newline at end of file
Please login to merge, or discard this patch.
templates/wpinv-invoice-receipt.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
  */
5 5
 global $wpinv_receipt_args;
6 6
 
7
-$invoice   = get_post( $wpinv_receipt_args['id'] );
7
+$invoice = get_post($wpinv_receipt_args['id']);
8 8
 
9
-if( empty( $invoice ) ) {
9
+if (empty($invoice)) {
10 10
     ?>
11 11
     <div class="wpinv_errors alert wpi-alert-error">
12
-        <?php _e( 'The specified receipt ID appears to be invalid', 'invoicing' ); ?>
12
+        <?php _e('The specified receipt ID appears to be invalid', 'invoicing'); ?>
13 13
     </div>
14 14
     <?php
15 15
     return;
16 16
 }
17
-$invoice = wpinv_get_invoice( $invoice->ID );
17
+$invoice = wpinv_get_invoice($invoice->ID);
18 18
 
19 19
 global $ajax_cart_details;
20 20
 $ajax_cart_details = $invoice->get_cart_details();
@@ -24,18 +24,18 @@  discard block
 block discarded – undo
24 24
 $quantities_enabled = wpinv_item_quantities_enabled();
25 25
 $use_taxes          = wpinv_use_taxes();
26 26
 $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
27
-$tax_label          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? __( '(Tax Incl.)', 'invoicing' ) : __( '(Tax Excl.)', 'invoicing' ) ) : '';
27
+$tax_label          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? __('(Tax Incl.)', 'invoicing') : __('(Tax Excl.)', 'invoicing')) : '';
28 28
 ?>
29
-<?php do_action( 'wpinv_before_receipt', $invoice ); ?>
29
+<?php do_action('wpinv_before_receipt', $invoice); ?>
30 30
 <div class="wpinv-receipt">
31
-    <?php do_action( 'wpinv_receipt_start', $invoice ); ?>
32
-    <div class="wpinv-receipt-message"><?php _e( 'Thank you for your payment!', 'invoicing' ); ?></div>
33
-    <?php do_action( 'wpinv_before_receipt_details', $invoice ); ?>
31
+    <?php do_action('wpinv_receipt_start', $invoice); ?>
32
+    <div class="wpinv-receipt-message"><?php _e('Thank you for your payment!', 'invoicing'); ?></div>
33
+    <?php do_action('wpinv_before_receipt_details', $invoice); ?>
34 34
     <div class="wpinv-receipt-details">
35
-        <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ) ); ?></h3>
36
-        <?php wpinv_display_invoice_details( $invoice ); ?>
35
+        <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing')); ?></h3>
36
+        <?php wpinv_display_invoice_details($invoice); ?>
37 37
     </div>
38
-    <?php do_action( 'wpinv_after_receipt_details', $invoice ); ?>
39
-    <?php do_action( 'wpinv_receipt_end', $invoice ); ?>
38
+    <?php do_action('wpinv_after_receipt_details', $invoice); ?>
39
+    <?php do_action('wpinv_receipt_end', $invoice); ?>
40 40
 </div>
41
-<?php do_action( 'wpinv_after_receipt', $invoice ); ?>
42 41
\ No newline at end of file
42
+<?php do_action('wpinv_after_receipt', $invoice); ?>
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-bp-core.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -348,7 +348,7 @@
 block discarded – undo
348 348
 
349 349
         $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
350 350
         if ( !empty( $status ) && $status != 'all' ) {
351
-           $query_args['status'] = $status;
351
+            $query_args['status'] = $status;
352 352
         }
353 353
         $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
354 354
         
Please login to merge, or discard this patch.
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -11,60 +11,60 @@  discard block
 block discarded – undo
11 11
     public function __construct() {
12 12
         global $bp;
13 13
         
14
-        if ( !defined( 'WPINV_BP_SLUG' ) ) {
15
-            define( 'WPINV_BP_SLUG', 'invoices' );
14
+        if (!defined('WPINV_BP_SLUG')) {
15
+            define('WPINV_BP_SLUG', 'invoices');
16 16
         }
17 17
         
18
-        $position       = wpinv_get_option( 'wpinv_menu_position' );
18
+        $position       = wpinv_get_option('wpinv_menu_position');
19 19
         $position       = $position !== '' && $position !== false ? $position : 91;
20
-        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
20
+        $this->position = apply_filters('wpinv_bp_nav_position', $position);
21 21
         $this->slug     = WPINV_BP_SLUG;
22 22
         
23 23
         parent::start(
24 24
             'invoicing',
25
-            _x( 'Invoices', 'Invoices screen page <title>', 'invoicing' ),
26
-            trailingslashit( dirname( __FILE__ ) ),
25
+            _x('Invoices', 'Invoices screen page <title>', 'invoicing'),
26
+            trailingslashit(dirname(__FILE__)),
27 27
             array(
28 28
                 'adminbar_myaccount_order' => $this->position
29 29
             )
30 30
         );
31 31
     }
32 32
     
33
-    public function includes( $includes = array() ) {
34
-        parent::includes( $includes );
33
+    public function includes($includes = array()) {
34
+        parent::includes($includes);
35 35
     }
36 36
     
37
-    public function setup_globals( $args = array() ) {
37
+    public function setup_globals($args = array()) {
38 38
         global $bp;
39 39
 
40 40
         $args = array(
41 41
             'slug' => $this->slug,
42 42
         );
43 43
 
44
-        parent::setup_globals( $args );
44
+        parent::setup_globals($args);
45 45
     }
46 46
     
47
-    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
48
-        if ( !bp_is_my_profile() ) {
47
+    public function setup_nav($main_nav = array(), $sub_nav = array()) {
48
+        if (!bp_is_my_profile()) {
49 49
             return;
50 50
         }
51 51
         
52
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
52
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
53 53
             return;
54 54
         }
55 55
         
56 56
         $this->setup_invoice_count();
57 57
 
58 58
         $user_domain    = bp_loggedin_user_domain();
59
-        $invoices_link  = trailingslashit( $user_domain . $this->slug );
60
-        $class          = ( 0 === $this->count ) ? 'no-count' : 'count';
59
+        $invoices_link  = trailingslashit($user_domain . $this->slug);
60
+        $class          = (0 === $this->count) ? 'no-count' : 'count';
61 61
 
62 62
         $main_nav_name = sprintf(
63
-            __( 'My Invoices %s', 'invoicing' ),
63
+            __('My Invoices %s', 'invoicing'),
64 64
             sprintf(
65 65
                 '<span class="%s">%s</span>',
66
-                esc_attr( $class ),
67
-                bp_core_number_format( $this->count )
66
+                esc_attr($class),
67
+                bp_core_number_format($this->count)
68 68
             )
69 69
         );
70 70
 
@@ -72,54 +72,54 @@  discard block
 block discarded – undo
72 72
             'name'                => $main_nav_name,
73 73
             'slug'                => $this->slug,
74 74
             'position'            => $this->position,
75
-            'screen_function'     => array( $this, 'invoices_screen' ),
75
+            'screen_function'     => array($this, 'invoices_screen'),
76 76
             'default_subnav_slug' => 'invoices',
77 77
             'item_css_id'         => $this->id
78 78
         );
79 79
         
80 80
         $sub_nav[] = array(
81
-            'name'            => _x( 'My Invoices', 'Invoices screen sub nav', 'invoicing' ),
81
+            'name'            => _x('My Invoices', 'Invoices screen sub nav', 'invoicing'),
82 82
             'slug'            => 'invoices',
83 83
             'parent_url'      => $invoices_link,
84 84
             'parent_slug'     => $this->slug,
85
-            'screen_function' => array( $this, 'invoices_screen' ),
85
+            'screen_function' => array($this, 'invoices_screen'),
86 86
             'position'        => 10,
87 87
             'item_css_id'     => 'invoices-my-invoices'
88 88
         );
89 89
 
90
-        parent::setup_nav( $main_nav, $sub_nav );
90
+        parent::setup_nav($main_nav, $sub_nav);
91 91
     }
92 92
     
93 93
     public function setup_title() {
94 94
         // Adjust title.
95
-        if ( (bool)bp_is_current_component( 'invoicing' ) ) {
95
+        if ((bool)bp_is_current_component('invoicing')) {
96 96
             global $bp;
97 97
             
98
-            $bp->bp_options_title = __( 'My Invoices', 'invoicing' );
98
+            $bp->bp_options_title = __('My Invoices', 'invoicing');
99 99
         }
100 100
 
101 101
         parent::setup_title();
102 102
     }
103 103
     
104 104
     public function invoices_screen() {
105
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
105
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
106 106
             return;
107 107
         }
108 108
         
109 109
         global $bp;
110 110
         
111
-        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
111
+        add_action('bp_template_content', array($this, 'invoices_content'));
112 112
 
113
-        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
113
+        $template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
114 114
         
115
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
115
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
116 116
     }
117 117
     
118 118
     public function invoices_content() {
119
-        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
119
+        if ($this->has_invoices(bp_ajax_querystring('invoices'))) {
120 120
             global $invoices_template;
121 121
             
122
-            do_action( 'wpinv_bp_invoices_before_content' );
122
+            do_action('wpinv_bp_invoices_before_content');
123 123
             ?>
124 124
             <div class="wpi-bp-invoices invoices invoicing" style="position:relative">
125 125
                 <div id="pag-top" class="pagination">
@@ -133,58 +133,58 @@  discard block
 block discarded – undo
133 133
                 <table class="table table-bordered table-hover wpi-user-invoices" style="margin:0">
134 134
                     <thead>
135 135
                         <tr>
136
-                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
137
-                                <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th>
136
+                            <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
137
+                                <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th>
138 138
                             <?php endforeach; ?>
139 139
                         </tr>
140 140
                     </thead>
141 141
                     <tbody>
142
-                        <?php foreach ( $invoices_template->invoices as $invoice ) {
142
+                        <?php foreach ($invoices_template->invoices as $invoice) {
143 143
                             ?>
144 144
                             <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
145
-                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
146
-                                    <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
147
-                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
148
-                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
149
-
150
-                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
151
-                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
152
-                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
145
+                                <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
146
+                                    <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>">
147
+                                        <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
148
+                                            <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
149
+
150
+                                        <?php elseif ('invoice-number' === $column_id) : ?>
151
+                                            <a href="<?php echo esc_url($invoice->get_view_url()); ?>">
152
+                                                <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
153 153
                                             </a>
154 154
 
155
-                                        <?php elseif ( 'invoice-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s' ); ?>
156
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
155
+                                        <?php elseif ('invoice-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s'); ?>
156
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
157 157
 
158
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
159
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
158
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
159
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
160 160
 
161
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
162
-                                            <?php echo $invoice->get_total( true ); ?>
161
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
162
+                                            <?php echo $invoice->get_total(true); ?>
163 163
 
164
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
164
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
165 165
                                             <?php
166 166
                                                 $actions = array(
167 167
                                                     'pay'    => array(
168 168
                                                         'url'  => $invoice->get_checkout_payment_url(),
169
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
169
+                                                        'name' => __('Pay Now', 'invoicing'),
170 170
                                                         'class' => 'btn-success'
171 171
                                                     ),
172 172
                                                     'print'   => array(
173 173
                                                         'url'  => $invoice->get_view_url(),
174
-                                                        'name' => __( 'Print', 'invoicing' ),
174
+                                                        'name' => __('Print', 'invoicing'),
175 175
                                                         'class' => 'btn-primary',
176 176
                                                         'attrs' => 'target="_blank"'
177 177
                                                     )
178 178
                                                 );
179 179
 
180
-                                                if ( ! $invoice->needs_payment() ) {
181
-                                                    unset( $actions['pay'] );
180
+                                                if (!$invoice->needs_payment()) {
181
+                                                    unset($actions['pay']);
182 182
                                                 }
183 183
 
184
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
185
-                                                    foreach ( $actions as $key => $action ) {
184
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
185
+                                                    foreach ($actions as $key => $action) {
186 186
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
187
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
187
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
188 188
                                                     }
189 189
                                                 }
190 190
                                             ?>
@@ -212,64 +212,64 @@  discard block
 block discarded – undo
212 212
             </div>
213 213
             <?php
214 214
         
215
-            do_action( 'wpinv_bp_invoices_after_content' );
215
+            do_action('wpinv_bp_invoices_after_content');
216 216
         } else {
217 217
             ?>
218 218
             <div id="message" class="info">
219
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
219
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
220 220
             </div>
221 221
             <?php
222 222
         }
223 223
         
224
-        if ( defined( 'DOING_AJAX' ) ) {
224
+        if (defined('DOING_AJAX')) {
225 225
             exit;
226 226
         }
227 227
     }
228 228
     
229
-    public function has_invoices( $args = '' ) {
229
+    public function has_invoices($args = '') {
230 230
         global $invoices_template;
231 231
 
232
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
232
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
233 233
         // Parse arguments.
234
-        $r = bp_parse_args( $args, array(
234
+        $r = bp_parse_args($args, array(
235 235
             'status'            => 'all',
236 236
             'page_arg'          => 'bpage',
237 237
             'page'              => 1,
238 238
             'per_page'          => $per_page > 0 ? $per_page : 20,
239 239
             'max'               => false,
240 240
             'user_id'           => bp_loggedin_user_id(),
241
-        ), 'has_invoices' );
241
+        ), 'has_invoices');
242 242
 
243 243
 
244
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
244
+        if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) {
245 245
             $r['per_page'] = (int)$r['max'];
246 246
         }
247 247
 
248 248
         // Get the invoices.
249
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
249
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
250 250
 
251
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
251
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
252 252
     }
253 253
     
254 254
     public function setup_invoice_count() {
255
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
256
-        $invoices   = wpinv_get_invoices( $query );
255
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
256
+        $invoices   = wpinv_get_invoices($query);
257 257
         
258
-        $this->count = !empty( $invoices ) ? count( $invoices ) : 0;
258
+        $this->count = !empty($invoices) ? count($invoices) : 0;
259 259
     }
260 260
     
261 261
     public function pagination_count() {
262 262
         global $invoices_template;
263 263
 
264
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
265
-        $from_num  = bp_core_number_format( $start_num );
266
-        $to_num    = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) );
267
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
264
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
265
+        $from_num  = bp_core_number_format($start_num);
266
+        $to_num    = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1));
267
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
268 268
 
269
-        if ( 1 == $invoices_template->total_invoice_count ) {
270
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
269
+        if (1 == $invoices_template->total_invoice_count) {
270
+            $message = __('Viewing 1 invoice', 'invoicing');
271 271
         } else {
272
-            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total );
272
+            $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total);
273 273
         }
274 274
 
275 275
         return $message;
@@ -278,32 +278,32 @@  discard block
 block discarded – undo
278 278
     function pagination_links() {
279 279
         global $invoices_template;
280 280
 
281
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
281
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
282 282
     }
283 283
     
284
-    public function bp_section( $settings = array() ) {
285
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
284
+    public function bp_section($settings = array()) {
285
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
286 286
         return $settings;
287 287
     }
288 288
     
289
-    public function bp_settings( $settings = array() ) {
289
+    public function bp_settings($settings = array()) {
290 290
         $settings['wpinv_bp'] = array(
291 291
             'wpinv_bp_labels' => array(
292 292
                 'id'   => 'wpinv_bp_settings',
293
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
293
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
294 294
                 'desc' => '',
295 295
                 'type' => 'header',
296 296
             ),
297 297
             'wpinv_bp_hide_menu' => array(
298 298
                 'id'   => 'wpinv_bp_hide_menu',
299
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
300
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
299
+                'name' => __('Hide Invoices link', 'invoicing'),
300
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
301 301
                 'type' => 'checkbox',
302 302
             ),
303 303
             'wpinv_menu_position' => array(
304 304
                 'id'   => 'wpinv_menu_position',
305
-                'name' => __( 'Menu position', 'invoicing' ),
306
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
305
+                'name' => __('Menu position', 'invoicing'),
306
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
307 307
                 'type' => 'number',
308 308
                 'size' => 'small',
309 309
                 'min'  => '1',
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
             ),
314 314
             'wpinv_bp_per_page' => array(
315 315
                 'id'   => 'wpinv_bp_per_page',
316
-                'name' => __( 'Max invoices per page', 'invoicing' ),
317
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
316
+                'name' => __('Max invoices per page', 'invoicing'),
317
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
318 318
                 'type' => 'number',
319 319
                 'size' => 'small',
320 320
                 'min'  => '1',
@@ -339,25 +339,25 @@  discard block
 block discarded – undo
339 339
     public $pag_links = '';
340 340
     public $total_invoice_count = 0;
341 341
     
342
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
343
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
342
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
343
+        $this->invoices = array('invoices' => array(), 'total' => 0);
344 344
         
345
-        $this->pag_arg  = sanitize_key( $page_arg );
346
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
347
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
345
+        $this->pag_arg  = sanitize_key($page_arg);
346
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
347
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
348 348
 
349
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
350
-        if ( !empty( $status ) && $status != 'all' ) {
349
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
350
+        if (!empty($status) && $status != 'all') {
351 351
            $query_args['status'] = $status;
352 352
         }
353
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
353
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
354 354
         
355
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
356
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
355
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
356
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
357 357
             $this->invoices['total']    = $invoices->found_posts;
358 358
         }
359 359
 
360
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
360
+        if (empty($max) || ($max >= (int)$this->invoices['total'])) {
361 361
             $this->total_invoice_count = (int)$this->invoices['total'];
362 362
         } else {
363 363
             $this->total_invoice_count = (int)$max;
@@ -365,52 +365,52 @@  discard block
 block discarded – undo
365 365
 
366 366
         $this->invoices = $this->invoices['invoices'];
367 367
 
368
-        $invoice_count = count( $this->invoices );
368
+        $invoice_count = count($this->invoices);
369 369
 
370
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
370
+        if (empty($max) || ($max >= (int)$invoice_count)) {
371 371
             $this->invoice_count = (int)$invoice_count;
372 372
         } else {
373 373
             $this->invoice_count = (int)$max;
374 374
         }
375 375
         
376
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
377
-            $this->pag_links = paginate_links( array(
378
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
376
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
377
+            $this->pag_links = paginate_links(array(
378
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
379 379
                 'format'    => '',
380
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
380
+                'total'     => ceil((int)$this->total_invoice_count / (int)$this->pag_num),
381 381
                 'current'   => (int)$this->pag_page,
382
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
383
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
382
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
383
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
384 384
                 'mid_size'  => 1,
385 385
                 'add_args'  => array(),
386
-            ) );
386
+            ));
387 387
         }
388 388
     }
389 389
 
390 390
     public function has_invoices() {
391
-        return (bool) ! empty( $this->invoice_count );
391
+        return (bool)!empty($this->invoice_count);
392 392
     }
393 393
 
394 394
     public function next_invoice() {
395 395
         $this->current_invoice++;
396
-        $this->invoice = $this->invoices[ $this->current_invoice ];
396
+        $this->invoice = $this->invoices[$this->current_invoice];
397 397
 
398 398
         return $this->invoice;
399 399
     }
400 400
 
401 401
     public function rewind_invoices() {
402 402
         $this->current_invoice = -1;
403
-        if ( $this->invoice_count > 0 ) {
403
+        if ($this->invoice_count > 0) {
404 404
             $this->invoice = $this->invoices[0];
405 405
         }
406 406
     }
407 407
 
408 408
     public function invoices() {
409
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
409
+        if (($this->current_invoice + 1) < $this->invoice_count) {
410 410
             return true;
411
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
411
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
412 412
 
413
-            do_action( 'wpinv_bp_invoice_loop_end' );
413
+            do_action('wpinv_bp_invoice_loop_end');
414 414
             
415 415
             $this->rewind_invoices();
416 416
         }
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
         $this->in_the_loop = true;
425 425
         $this->invoice     = $this->next_invoice();
426 426
 
427
-        if ( 0 === $this->current_invoice ) {
428
-            do_action( 'wpinv_bp_invoice_loop_start' );
427
+        if (0 === $this->current_invoice) {
428
+            do_action('wpinv_bp_invoice_loop_start');
429 429
         }
430 430
     }
431 431
 }
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 
436 436
     $bp->invoicing = new WPInv_BP_Component();
437 437
     
438
-    add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
439
-    add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
440
-    add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 );
441
-    add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 );
438
+    add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content'));
439
+    add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content'));
440
+    add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1);
441
+    add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1);
442 442
 }
443
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
444 443
\ No newline at end of file
444
+add_action('bp_loaded', 'wpinv_bp_setup_component');
445 445
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 3 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -30,40 +30,40 @@  discard block
 block discarded – undo
30 30
 }
31 31
 
32 32
 function wpinv_can_checkout() {
33
-	$can_checkout = true; // Always true for now
33
+    $can_checkout = true; // Always true for now
34 34
 
35
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
35
+    return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
36 36
 }
37 37
 
38 38
 function wpinv_get_success_page_uri() {
39
-	$page_id = wpinv_get_option( 'success_page', 0 );
40
-	$page_id = absint( $page_id );
39
+    $page_id = wpinv_get_option( 'success_page', 0 );
40
+    $page_id = absint( $page_id );
41 41
 
42
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
42
+    return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
43 43
 }
44 44
 
45 45
 function wpinv_get_history_page_uri() {
46
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
-	$page_id = absint( $page_id );
46
+    $page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
+    $page_id = absint( $page_id );
48 48
 
49
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
49
+    return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
50 50
 }
51 51
 
52 52
 function wpinv_is_success_page() {
53
-	$is_success_page = wpinv_get_option( 'success_page', false );
54
-	$is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
53
+    $is_success_page = wpinv_get_option( 'success_page', false );
54
+    $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
55 55
 
56
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
56
+    return apply_filters( 'wpinv_is_success_page', $is_success_page );
57 57
 }
58 58
 
59 59
 function wpinv_is_invoice_history_page() {
60
-	$ret = wpinv_get_option( 'invoice_history_page', false );
61
-	$ret = $ret ? is_page( $ret ) : false;
62
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
60
+    $ret = wpinv_get_option( 'invoice_history_page', false );
61
+    $ret = $ret ? is_page( $ret ) : false;
62
+    return apply_filters( 'wpinv_is_invoice_history_page', $ret );
63 63
 }
64 64
 
65 65
 function wpinv_send_to_success_page( $args = null ) {
66
-	$redirect = wpinv_get_success_page_uri();
66
+    $redirect = wpinv_get_success_page_uri();
67 67
     
68 68
     if ( !empty( $args ) ) {
69 69
         // Check for backward compatibility
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 }
84 84
 
85 85
 function wpinv_send_to_failed_page( $args = null ) {
86
-	$redirect = wpinv_get_failed_transaction_uri();
86
+    $redirect = wpinv_get_failed_transaction_uri();
87 87
     
88 88
     if ( !empty( $args ) ) {
89 89
         // Check for backward compatibility
@@ -103,72 +103,72 @@  discard block
 block discarded – undo
103 103
 }
104 104
 
105 105
 function wpinv_get_checkout_uri( $args = array() ) {
106
-	$uri = wpinv_get_option( 'checkout_page', false );
107
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
106
+    $uri = wpinv_get_option( 'checkout_page', false );
107
+    $uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
108 108
 
109
-	if ( !empty( $args ) ) {
110
-		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
109
+    if ( !empty( $args ) ) {
110
+        // Check for backward compatibility
111
+        if ( is_string( $args ) )
112
+            $args = str_replace( '?', '', $args );
113 113
 
114
-		$args = wp_parse_args( $args );
114
+        $args = wp_parse_args( $args );
115 115
 
116
-		$uri = add_query_arg( $args, $uri );
117
-	}
116
+        $uri = add_query_arg( $args, $uri );
117
+    }
118 118
 
119
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
119
+    $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
120 120
 
121
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
121
+    $ajax_url = admin_url( 'admin-ajax.php', $scheme );
122 122
 
123
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
125
-	}
123
+    if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
+        $uri = preg_replace( '/^http:/', 'https:', $uri );
125
+    }
126 126
 
127
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
127
+    return apply_filters( 'wpinv_get_checkout_uri', $uri );
128 128
 }
129 129
 
130 130
 function wpinv_send_back_to_checkout( $args = array() ) {
131
-	$redirect = wpinv_get_checkout_uri();
131
+    $redirect = wpinv_get_checkout_uri();
132 132
 
133
-	if ( ! empty( $args ) ) {
134
-		// Check for backward compatibility
135
-		if ( is_string( $args ) )
136
-			$args = str_replace( '?', '', $args );
133
+    if ( ! empty( $args ) ) {
134
+        // Check for backward compatibility
135
+        if ( is_string( $args ) )
136
+            $args = str_replace( '?', '', $args );
137 137
 
138
-		$args = wp_parse_args( $args );
138
+        $args = wp_parse_args( $args );
139 139
 
140
-		$redirect = add_query_arg( $args, $redirect );
141
-	}
140
+        $redirect = add_query_arg( $args, $redirect );
141
+    }
142 142
 
143
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
144
-	exit;
143
+    wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
144
+    exit;
145 145
 }
146 146
 
147 147
 function wpinv_get_success_page_url( $query_string = null ) {
148
-	$success_page = wpinv_get_option( 'success_page', 0 );
149
-	$success_page = get_permalink( $success_page );
148
+    $success_page = wpinv_get_option( 'success_page', 0 );
149
+    $success_page = get_permalink( $success_page );
150 150
 
151
-	if ( $query_string )
152
-		$success_page .= $query_string;
151
+    if ( $query_string )
152
+        $success_page .= $query_string;
153 153
 
154
-	return apply_filters( 'wpinv_success_page_url', $success_page );
154
+    return apply_filters( 'wpinv_success_page_url', $success_page );
155 155
 }
156 156
 
157 157
 function wpinv_get_failed_transaction_uri( $extras = false ) {
158
-	$uri = wpinv_get_option( 'failure_page', '' );
159
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
158
+    $uri = wpinv_get_option( 'failure_page', '' );
159
+    $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
160 160
 
161
-	if ( $extras )
162
-		$uri .= $extras;
161
+    if ( $extras )
162
+        $uri .= $extras;
163 163
 
164
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
164
+    return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
165 165
 }
166 166
 
167 167
 function wpinv_is_failed_transaction_page() {
168
-	$ret = wpinv_get_option( 'failure_page', false );
169
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
168
+    $ret = wpinv_get_option( 'failure_page', false );
169
+    $ret = isset( $ret ) ? is_page( $ret ) : false;
170 170
 
171
-	return apply_filters( 'wpinv_is_failure_page', $ret );
171
+    return apply_filters( 'wpinv_is_failure_page', $ret );
172 172
 }
173 173
 
174 174
 function wpinv_transaction_query( $type = 'start' ) {
Please login to merge, or discard this patch.
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -67,8 +67,9 @@  discard block
 block discarded – undo
67 67
     
68 68
     if ( !empty( $args ) ) {
69 69
         // Check for backward compatibility
70
-        if ( is_string( $args ) )
71
-            $args = str_replace( '?', '', $args );
70
+        if ( is_string( $args ) ) {
71
+                    $args = str_replace( '?', '', $args );
72
+        }
72 73
 
73 74
         $args = wp_parse_args( $args );
74 75
 
@@ -87,8 +88,9 @@  discard block
 block discarded – undo
87 88
     
88 89
     if ( !empty( $args ) ) {
89 90
         // Check for backward compatibility
90
-        if ( is_string( $args ) )
91
-            $args = str_replace( '?', '', $args );
91
+        if ( is_string( $args ) ) {
92
+                    $args = str_replace( '?', '', $args );
93
+        }
92 94
 
93 95
         $args = wp_parse_args( $args );
94 96
 
@@ -108,8 +110,9 @@  discard block
 block discarded – undo
108 110
 
109 111
 	if ( !empty( $args ) ) {
110 112
 		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
113
+		if ( is_string( $args ) ) {
114
+					$args = str_replace( '?', '', $args );
115
+		}
113 116
 
114 117
 		$args = wp_parse_args( $args );
115 118
 
@@ -132,8 +135,9 @@  discard block
 block discarded – undo
132 135
 
133 136
 	if ( ! empty( $args ) ) {
134 137
 		// Check for backward compatibility
135
-		if ( is_string( $args ) )
136
-			$args = str_replace( '?', '', $args );
138
+		if ( is_string( $args ) ) {
139
+					$args = str_replace( '?', '', $args );
140
+		}
137 141
 
138 142
 		$args = wp_parse_args( $args );
139 143
 
@@ -148,8 +152,9 @@  discard block
 block discarded – undo
148 152
 	$success_page = wpinv_get_option( 'success_page', 0 );
149 153
 	$success_page = get_permalink( $success_page );
150 154
 
151
-	if ( $query_string )
152
-		$success_page .= $query_string;
155
+	if ( $query_string ) {
156
+			$success_page .= $query_string;
157
+	}
153 158
 
154 159
 	return apply_filters( 'wpinv_success_page_url', $success_page );
155 160
 }
@@ -158,8 +163,9 @@  discard block
 block discarded – undo
158 163
 	$uri = wpinv_get_option( 'failure_page', '' );
159 164
 	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
160 165
 
161
-	if ( $extras )
162
-		$uri .= $extras;
166
+	if ( $extras ) {
167
+			$uri .= $extras;
168
+	}
163 169
 
164 170
 	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
165 171
 }
Please login to merge, or discard this patch.
Spacing   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -7,195 +7,195 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_is_checkout() {
15 15
     global $wp_query;
16 16
 
17
-    $is_object_set    = isset( $wp_query->queried_object );
18
-    $is_object_id_set = isset( $wp_query->queried_object_id );
19
-    $is_checkout      = is_page( wpinv_get_option( 'checkout_page' ) );
17
+    $is_object_set    = isset($wp_query->queried_object);
18
+    $is_object_id_set = isset($wp_query->queried_object_id);
19
+    $is_checkout      = is_page(wpinv_get_option('checkout_page'));
20 20
 
21
-    if ( !$is_object_set ) {
22
-        unset( $wp_query->queried_object );
21
+    if (!$is_object_set) {
22
+        unset($wp_query->queried_object);
23 23
     }
24 24
 
25
-    if ( !$is_object_id_set ) {
26
-        unset( $wp_query->queried_object_id );
25
+    if (!$is_object_id_set) {
26
+        unset($wp_query->queried_object_id);
27 27
     }
28 28
 
29
-    return apply_filters( 'wpinv_is_checkout', $is_checkout );
29
+    return apply_filters('wpinv_is_checkout', $is_checkout);
30 30
 }
31 31
 
32 32
 function wpinv_can_checkout() {
33 33
 	$can_checkout = true; // Always true for now
34 34
 
35
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
35
+	return (bool)apply_filters('wpinv_can_checkout', $can_checkout);
36 36
 }
37 37
 
38 38
 function wpinv_get_success_page_uri() {
39
-	$page_id = wpinv_get_option( 'success_page', 0 );
40
-	$page_id = absint( $page_id );
39
+	$page_id = wpinv_get_option('success_page', 0);
40
+	$page_id = absint($page_id);
41 41
 
42
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
42
+	return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id));
43 43
 }
44 44
 
45 45
 function wpinv_get_history_page_uri() {
46
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
-	$page_id = absint( $page_id );
46
+	$page_id = wpinv_get_option('invoice_history_page', 0);
47
+	$page_id = absint($page_id);
48 48
 
49
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
49
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id));
50 50
 }
51 51
 
52 52
 function wpinv_is_success_page() {
53
-	$is_success_page = wpinv_get_option( 'success_page', false );
54
-	$is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
53
+	$is_success_page = wpinv_get_option('success_page', false);
54
+	$is_success_page = isset($is_success_page) ? is_page($is_success_page) : false;
55 55
 
56
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
56
+	return apply_filters('wpinv_is_success_page', $is_success_page);
57 57
 }
58 58
 
59 59
 function wpinv_is_invoice_history_page() {
60
-	$ret = wpinv_get_option( 'invoice_history_page', false );
61
-	$ret = $ret ? is_page( $ret ) : false;
62
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
60
+	$ret = wpinv_get_option('invoice_history_page', false);
61
+	$ret = $ret ? is_page($ret) : false;
62
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
63 63
 }
64 64
 
65
-function wpinv_send_to_success_page( $args = null ) {
65
+function wpinv_send_to_success_page($args = null) {
66 66
 	$redirect = wpinv_get_success_page_uri();
67 67
     
68
-    if ( !empty( $args ) ) {
68
+    if (!empty($args)) {
69 69
         // Check for backward compatibility
70
-        if ( is_string( $args ) )
71
-            $args = str_replace( '?', '', $args );
70
+        if (is_string($args))
71
+            $args = str_replace('?', '', $args);
72 72
 
73
-        $args = wp_parse_args( $args );
73
+        $args = wp_parse_args($args);
74 74
 
75
-        $redirect = add_query_arg( $args, $redirect );
75
+        $redirect = add_query_arg($args, $redirect);
76 76
     }
77 77
 
78
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
78
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
79 79
     
80
-    $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args );
81
-    wp_redirect( $redirect );
80
+    $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args);
81
+    wp_redirect($redirect);
82 82
     exit;
83 83
 }
84 84
 
85
-function wpinv_send_to_failed_page( $args = null ) {
85
+function wpinv_send_to_failed_page($args = null) {
86 86
 	$redirect = wpinv_get_failed_transaction_uri();
87 87
     
88
-    if ( !empty( $args ) ) {
88
+    if (!empty($args)) {
89 89
         // Check for backward compatibility
90
-        if ( is_string( $args ) )
91
-            $args = str_replace( '?', '', $args );
90
+        if (is_string($args))
91
+            $args = str_replace('?', '', $args);
92 92
 
93
-        $args = wp_parse_args( $args );
93
+        $args = wp_parse_args($args);
94 94
 
95
-        $redirect = add_query_arg( $args, $redirect );
95
+        $redirect = add_query_arg($args, $redirect);
96 96
     }
97 97
 
98
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
98
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
99 99
     
100
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
101
-    wp_redirect( $redirect );
100
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
101
+    wp_redirect($redirect);
102 102
     exit;
103 103
 }
104 104
 
105
-function wpinv_get_checkout_uri( $args = array() ) {
106
-	$uri = wpinv_get_option( 'checkout_page', false );
107
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
105
+function wpinv_get_checkout_uri($args = array()) {
106
+	$uri = wpinv_get_option('checkout_page', false);
107
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
108 108
 
109
-	if ( !empty( $args ) ) {
109
+	if (!empty($args)) {
110 110
 		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
111
+		if (is_string($args))
112
+			$args = str_replace('?', '', $args);
113 113
 
114
-		$args = wp_parse_args( $args );
114
+		$args = wp_parse_args($args);
115 115
 
116
-		$uri = add_query_arg( $args, $uri );
116
+		$uri = add_query_arg($args, $uri);
117 117
 	}
118 118
 
119
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
119
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
120 120
 
121
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
121
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
122 122
 
123
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
123
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
124
+		$uri = preg_replace('/^http:/', 'https:', $uri);
125 125
 	}
126 126
 
127
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
127
+	return apply_filters('wpinv_get_checkout_uri', $uri);
128 128
 }
129 129
 
130
-function wpinv_send_back_to_checkout( $args = array() ) {
130
+function wpinv_send_back_to_checkout($args = array()) {
131 131
 	$redirect = wpinv_get_checkout_uri();
132 132
 
133
-	if ( ! empty( $args ) ) {
133
+	if (!empty($args)) {
134 134
 		// Check for backward compatibility
135
-		if ( is_string( $args ) )
136
-			$args = str_replace( '?', '', $args );
135
+		if (is_string($args))
136
+			$args = str_replace('?', '', $args);
137 137
 
138
-		$args = wp_parse_args( $args );
138
+		$args = wp_parse_args($args);
139 139
 
140
-		$redirect = add_query_arg( $args, $redirect );
140
+		$redirect = add_query_arg($args, $redirect);
141 141
 	}
142 142
 
143
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
143
+	wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args));
144 144
 	exit;
145 145
 }
146 146
 
147
-function wpinv_get_success_page_url( $query_string = null ) {
148
-	$success_page = wpinv_get_option( 'success_page', 0 );
149
-	$success_page = get_permalink( $success_page );
147
+function wpinv_get_success_page_url($query_string = null) {
148
+	$success_page = wpinv_get_option('success_page', 0);
149
+	$success_page = get_permalink($success_page);
150 150
 
151
-	if ( $query_string )
151
+	if ($query_string)
152 152
 		$success_page .= $query_string;
153 153
 
154
-	return apply_filters( 'wpinv_success_page_url', $success_page );
154
+	return apply_filters('wpinv_success_page_url', $success_page);
155 155
 }
156 156
 
157
-function wpinv_get_failed_transaction_uri( $extras = false ) {
158
-	$uri = wpinv_get_option( 'failure_page', '' );
159
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
157
+function wpinv_get_failed_transaction_uri($extras = false) {
158
+	$uri = wpinv_get_option('failure_page', '');
159
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
160 160
 
161
-	if ( $extras )
161
+	if ($extras)
162 162
 		$uri .= $extras;
163 163
 
164
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
164
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
165 165
 }
166 166
 
167 167
 function wpinv_is_failed_transaction_page() {
168
-	$ret = wpinv_get_option( 'failure_page', false );
169
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
168
+	$ret = wpinv_get_option('failure_page', false);
169
+	$ret = isset($ret) ? is_page($ret) : false;
170 170
 
171
-	return apply_filters( 'wpinv_is_failure_page', $ret );
171
+	return apply_filters('wpinv_is_failure_page', $ret);
172 172
 }
173 173
 
174
-function wpinv_transaction_query( $type = 'start' ) {
174
+function wpinv_transaction_query($type = 'start') {
175 175
     global $wpdb;
176 176
 
177 177
     $wpdb->hide_errors();
178 178
 
179
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
180
-        define( 'WPINV_USE_TRANSACTIONS', true );
179
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
180
+        define('WPINV_USE_TRANSACTIONS', true);
181 181
     }
182 182
 
183
-    if ( WPINV_USE_TRANSACTIONS ) {
184
-        switch ( $type ) {
183
+    if (WPINV_USE_TRANSACTIONS) {
184
+        switch ($type) {
185 185
             case 'commit' :
186
-                $wpdb->query( 'COMMIT' );
186
+                $wpdb->query('COMMIT');
187 187
                 break;
188 188
             case 'rollback' :
189
-                $wpdb->query( 'ROLLBACK' );
189
+                $wpdb->query('ROLLBACK');
190 190
                 break;
191 191
             default :
192
-                $wpdb->query( 'START TRANSACTION' );
192
+                $wpdb->query('START TRANSACTION');
193 193
             break;
194 194
         }
195 195
     }
196 196
 }
197 197
 
198
-function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) {
198
+function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) {
199 199
     $default_args = array(
200 200
         'status'        => '',
201 201
         'user_id'       => null,
@@ -205,63 +205,63 @@  discard block
 block discarded – undo
205 205
         'parent'        => 0
206 206
     );
207 207
 
208
-    $args           = wp_parse_args( $args, $default_args );
208
+    $args           = wp_parse_args($args, $default_args);
209 209
     $invoice_data   = array();
210 210
 
211
-    if ( $args['invoice_id'] > 0 ) {
212
-        $updating           = true;
211
+    if ($args['invoice_id'] > 0) {
212
+        $updating = true;
213 213
         $invoice_data['post_type']  = 'wpi_invoice';
214 214
         $invoice_data['ID']         = $args['invoice_id'];
215 215
     } else {
216 216
         $updating                       = false;
217 217
         $invoice_data['post_type']      = 'wpi_invoice';
218
-        $invoice_data['post_status']    = apply_filters( 'wpinv_default_invoice_status', 'wpi-pending' );
218
+        $invoice_data['post_status']    = apply_filters('wpinv_default_invoice_status', 'wpi-pending');
219 219
         $invoice_data['ping_status']    = 'closed';
220
-        $invoice_data['post_author']    = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
221
-        $invoice_data['post_title']     = wpinv_format_invoice_number( '0' );
222
-        $invoice_data['post_parent']    = absint( $args['parent'] );
223
-        if ( !empty( $args['created_date'] ) ) {
220
+        $invoice_data['post_author']    = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id();
221
+        $invoice_data['post_title']     = wpinv_format_invoice_number('0');
222
+        $invoice_data['post_parent']    = absint($args['parent']);
223
+        if (!empty($args['created_date'])) {
224 224
             $invoice_data['post_date']      = $args['created_date'];
225
-            $invoice_data['post_date_gmt']  = get_gmt_from_date( $args['created_date'] );
225
+            $invoice_data['post_date_gmt']  = get_gmt_from_date($args['created_date']);
226 226
         }
227 227
     }
228 228
 
229
-    if ( $args['status'] ) {
230
-        if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) {
231
-            return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) );
229
+    if ($args['status']) {
230
+        if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) {
231
+            return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status']));
232 232
         }
233
-        $invoice_data['post_status']    = $args['status'];
233
+        $invoice_data['post_status'] = $args['status'];
234 234
     }
235 235
 
236
-    if ( ! is_null( $args['user_note'] ) ) {
237
-        $invoice_data['post_excerpt']   = $args['user_note'];
236
+    if (!is_null($args['user_note'])) {
237
+        $invoice_data['post_excerpt'] = $args['user_note'];
238 238
     }
239 239
 
240
-    if ( $updating ) {
241
-        $invoice_id = wp_update_post( $invoice_data, true );
240
+    if ($updating) {
241
+        $invoice_id = wp_update_post($invoice_data, true);
242 242
     } else {
243
-        $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true );
243
+        $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true);
244 244
     }
245 245
 
246
-    if ( is_wp_error( $invoice_id ) ) {
246
+    if (is_wp_error($invoice_id)) {
247 247
         return $wp_error ? $invoice_id : 0;
248 248
     }
249 249
     
250
-    $invoice = wpinv_get_invoice( $invoice_id );
251
-
252
-    if ( !$updating ) {
253
-        update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) );
254
-        update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() );
255
-        update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) );
256
-        update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() );
257
-        update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() );
258
-        update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) );
250
+    $invoice = wpinv_get_invoice($invoice_id);
251
+
252
+    if (!$updating) {
253
+        update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_')));
254
+        update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency());
255
+        update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax'));
256
+        update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip());
257
+        update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent());
258
+        update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via']));
259 259
         
260 260
         // Add invoice note
261
-        $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
261
+        $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status)));
262 262
     }
263 263
 
264
-    update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION );
264
+    update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION);
265 265
 
266 266
     return $invoice;
267 267
 }
@@ -269,144 +269,144 @@  discard block
 block discarded – undo
269 269
 function wpinv_get_prefix() {
270 270
     $invoice_prefix = 'INV-';
271 271
     
272
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
272
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
273 273
 }
274 274
 
275 275
 function wpinv_get_business_logo() {
276
-    $business_logo = wpinv_get_option( 'logo' );
277
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
276
+    $business_logo = wpinv_get_option('logo');
277
+    return apply_filters('wpinv_get_business_logo', $business_logo);
278 278
 }
279 279
 
280 280
 function wpinv_get_business_name() {
281 281
     $business_name = wpinv_get_option('store_name');
282
-    return apply_filters( 'wpinv_get_business_name', $business_name );
282
+    return apply_filters('wpinv_get_business_name', $business_name);
283 283
 }
284 284
 
285 285
 function wpinv_get_blogname() {
286
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
286
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
287 287
 }
288 288
 
289 289
 function wpinv_get_admin_email() {
290
-    $admin_email = get_option( 'admin_email' );
291
-    return apply_filters( 'wpinv_admin_email', $admin_email );
290
+    $admin_email = get_option('admin_email');
291
+    return apply_filters('wpinv_admin_email', $admin_email);
292 292
 }
293 293
 
294 294
 function wpinv_get_business_website() {
295
-    $business_website = home_url( '/' );
296
-    return apply_filters( 'wpinv_get_business_website', $business_website );
295
+    $business_website = home_url('/');
296
+    return apply_filters('wpinv_get_business_website', $business_website);
297 297
 }
298 298
 
299
-function wpinv_get_terms_text( $invoice_id = 0 ) {
299
+function wpinv_get_terms_text($invoice_id = 0) {
300 300
     $terms_text = '';
301
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
301
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
302 302
 }
303 303
 
304 304
 function wpinv_get_business_footer() {
305
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
306
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
307
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
305
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
306
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
307
+    return apply_filters('wpinv_get_business_footer', $business_footer);
308 308
 }
309 309
 
310 310
 function wpinv_checkout_required_fields() {
311 311
     $required_fields = array();
312 312
     
313 313
     // Let payment gateways and other extensions determine if address fields should be required
314
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
314
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
315 315
     
316
-    if ( $require_billing_details ) {
316
+    if ($require_billing_details) {
317 317
         ///$required_fields['email'] = array(
318 318
                 ///'error_id' => 'invalid_email',
319 319
                 ///'error_message' => __( 'Please enter a valid email address', 'invoicing' )
320 320
             ///);
321 321
         $required_fields['first_name'] = array(
322 322
                 'error_id' => 'invalid_first_name',
323
-                'error_message' => __( 'Please enter your first name', 'invoicing' )
323
+                'error_message' => __('Please enter your first name', 'invoicing')
324 324
             );
325 325
         $required_fields['address'] = array(
326 326
                 'error_id' => 'invalid_address',
327
-                'error_message' => __( 'Please enter your address', 'invoicing' )
327
+                'error_message' => __('Please enter your address', 'invoicing')
328 328
             );
329 329
         $required_fields['city'] = array(
330 330
                 'error_id' => 'invalid_city',
331
-                'error_message' => __( 'Please enter your billing city', 'invoicing' )
331
+                'error_message' => __('Please enter your billing city', 'invoicing')
332 332
             );
333 333
         $required_fields['state'] = array(
334 334
                 'error_id' => 'invalid_state',
335
-                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
335
+                'error_message' => __('Please enter billing state / province', 'invoicing')
336 336
             );
337 337
         $required_fields['country'] = array(
338 338
                 'error_id' => 'invalid_country',
339
-                'error_message' => __( 'Please select your billing country', 'invoicing' )
339
+                'error_message' => __('Please select your billing country', 'invoicing')
340 340
             );
341 341
     }
342 342
 
343
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
343
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
344 344
 }
345 345
 
346 346
 function wpinv_is_ssl_enforced() {
347
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
348
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
347
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
348
+    return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
349 349
 }
350 350
 
351
-function wpinv_user_can_view_invoice( $post ) {
351
+function wpinv_user_can_view_invoice($post) {
352 352
     $allow = false;
353 353
 
354
-    $post = get_post( $post );
354
+    $post = get_post($post);
355 355
 
356
-    if ( empty( $post->ID ) ) {
356
+    if (empty($post->ID)) {
357 357
         return $allow;
358 358
     }
359 359
 
360
-    $invoice = wpinv_get_invoice( $post->ID );
361
-    if ( empty( $invoice->ID ) ) {
360
+    $invoice = wpinv_get_invoice($post->ID);
361
+    if (empty($invoice->ID)) {
362 362
         return $allow;
363 363
     }
364 364
 
365 365
     // Don't allow trash, draft status
366
-    if ( $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
367
-        if ( current_user_can( 'manage_options' ) ) { // Admin user
366
+    if ($invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
367
+        if (current_user_can('manage_options')) { // Admin user
368 368
             $allow = true;
369 369
         } else {
370
-            if ( is_user_logged_in() ) {
371
-                if ( (int)$invoice->get_user_id() === (int)get_current_user_id() ) {
370
+            if (is_user_logged_in()) {
371
+                if ((int)$invoice->get_user_id() === (int)get_current_user_id()) {
372 372
                     $allow = true;
373
-                } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
373
+                } else if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
374 374
                     $allow = true;
375 375
                 }
376 376
             } else {
377
-                if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
377
+                if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
378 378
                     $allow = true;
379 379
                 }
380 380
             }
381 381
         }
382 382
     }
383 383
     
384
-    return apply_filters( 'wpinv_can_print_invoice', $allow, $post, $invoice );
384
+    return apply_filters('wpinv_can_print_invoice', $allow, $post, $invoice);
385 385
 }
386 386
 
387 387
 function wpinv_schedule_events() {
388 388
     // hourly, daily and twicedaily
389
-    if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) {
390
-        wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' );
389
+    if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) {
390
+        wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily');
391 391
     }
392 392
 }
393
-add_action( 'wp', 'wpinv_schedule_events' );
393
+add_action('wp', 'wpinv_schedule_events');
394 394
 
395 395
 function wpinv_schedule_event_twicedaily() {
396 396
     wpinv_email_payment_reminders();
397 397
 }
398
-add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' );
398
+add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily');
399 399
 
400 400
 function wpinv_require_login_to_checkout() {
401
-    $return = wpinv_get_option( 'login_to_checkout', false );
402
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
401
+    $return = wpinv_get_option('login_to_checkout', false);
402
+    return (bool)apply_filters('wpinv_require_login_to_checkout', $return);
403 403
 }
404 404
 
405
-function wpinv_sequential_number_active( $type = '' ) {
406
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
407
-    if ( null !== $check ) {
405
+function wpinv_sequential_number_active($type = '') {
406
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
407
+    if (null !== $check) {
408 408
         return $check;
409 409
     }
410 410
     
411
-    return wpinv_get_option( 'sequential_invoice_number' );
411
+    return wpinv_get_option('sequential_invoice_number');
412 412
 }
413 413
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-notes.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,39 +1,39 @@
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Notes {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $post;
10 10
 
11
-        $notes = wpinv_get_invoice_notes( $post->ID );
11
+        $notes = wpinv_get_invoice_notes($post->ID);
12 12
 
13 13
         echo '<ul class="invoice_notes">';
14 14
 
15
-        if ( $notes ) {
16
-            foreach( $notes as $note ) {
17
-                wpinv_get_invoice_note_line_item( $note );
15
+        if ($notes) {
16
+            foreach ($notes as $note) {
17
+                wpinv_get_invoice_note_line_item($note);
18 18
             }
19 19
 
20 20
         } else {
21
-            echo '<li>' . __( 'There are no notes yet.', 'invoicing' ) . '</li>';
21
+            echo '<li>' . __('There are no notes yet.', 'invoicing') . '</li>';
22 22
         }
23 23
 
24 24
         echo '</ul>';
25 25
         ?>
26 26
         <div class="add_note">
27
-            <h4><?php _e( 'Add note', 'invoicing' ); ?></h4>
27
+            <h4><?php _e('Add note', 'invoicing'); ?></h4>
28 28
             <p>
29 29
                 <textarea type="text" name="invoice_note" id="add_invoice_note" class="input-text" cols="20" rows="5"></textarea>
30 30
             </p>
31 31
             <p>
32 32
                 <select name="invoice_note_type" id="invoice_note_type">
33
-                    <option value=""><?php _e( 'Private note', 'invoicing' ); ?></option>
34
-                    <option value="customer"><?php _e( 'Note to customer', 'invoicing' ); ?></option>
33
+                    <option value=""><?php _e('Private note', 'invoicing'); ?></option>
34
+                    <option value="customer"><?php _e('Note to customer', 'invoicing'); ?></option>
35 35
                 </select>
36
-                <a href="#" class="add_note button"><?php _e( 'Add', 'invoicing' ); ?></a> <span class="description"><?php _e( 'Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing' ); ?></span>
36
+                <a href="#" class="add_note button"><?php _e('Add', 'invoicing'); ?></a> <span class="description"><?php _e('Add a note for your reference, or add a customer note (the user will be notified).', 'invoicing'); ?></span>
37 37
             </p>
38 38
         </div>
39 39
         <?php
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,8 +196,9 @@
 block discarded – undo
196 196
             foreach ( $types as $name => $type ) {
197 197
                 echo '<option value="' . esc_attr( $name ) . '"';
198 198
 
199
-                if ( isset( $_GET['discount_type'] ) )
200
-                    selected( $name, $_GET['discount_type'] );
199
+                if ( isset( $_GET['discount_type'] ) ) {
200
+                                    selected( $name, $_GET['discount_type'] );
201
+                }
201 202
 
202 203
                 echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
203 204
             }
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -1,72 +1,72 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'admin_menu', 'wpinv_add_options_link', 10 );
7
+add_action('admin_menu', 'wpinv_add_options_link', 10);
8 8
 function wpinv_add_options_link() {
9 9
     global $menu;
10 10
 
11
-    if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) {
11
+    if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) {
12 12
         return;
13 13
     }
14 14
 
15
-    $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' );
15
+    $capability = apply_filters('invoicing_capability', 'manage_invoicing');
16 16
 
17
-    if ( current_user_can( 'manage_options' ) ) {
18
-        $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' );
17
+    if (current_user_can('manage_options')) {
18
+        $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv');
19 19
     }
20 20
 
21
-    $wpi_invoice = get_post_type_object( 'wpi_invoice' );
21
+    $wpi_invoice = get_post_type_object('wpi_invoice');
22 22
 
23
-    add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' );
23
+    add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460');
24 24
 
25
-    $wpi_settings_page   = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', 'wpinv_options_page' );
25
+    $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', 'wpinv_options_page');
26 26
 }
27 27
 
28
-add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 );
28
+add_action('admin_menu', 'wpinv_remove_admin_submenus', 999);
29 29
 function wpinv_remove_admin_submenus() {
30
-    remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
30
+    remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
31 31
 }
32 32
 
33
-add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' );
34
-function wpinv_discount_columns( $existing_columns ) {
33
+add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns');
34
+function wpinv_discount_columns($existing_columns) {
35 35
     $columns                = array();
36 36
     $columns['cb']          = $existing_columns['cb'];
37
-    $columns['name']        = __( 'Name', 'invoicing' );
38
-    $columns['code']        = __( 'Code', 'invoicing' );
39
-    $columns['amount']      = __( 'Amount', 'invoicing' );
40
-    $columns['usage']       = __( 'Usage / Limit', 'invoicing' );
41
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
42
-    $columns['status']      = __( 'Status', 'invoicing' );
37
+    $columns['name']        = __('Name', 'invoicing');
38
+    $columns['code']        = __('Code', 'invoicing');
39
+    $columns['amount']      = __('Amount', 'invoicing');
40
+    $columns['usage']       = __('Usage / Limit', 'invoicing');
41
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
42
+    $columns['status']      = __('Status', 'invoicing');
43 43
 
44 44
     return $columns;
45 45
 }
46 46
 
47
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
48
-function wpinv_discount_custom_column( $column ) {
47
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
48
+function wpinv_discount_custom_column($column) {
49 49
     global $post;
50 50
     
51 51
     $discount = $post;
52 52
 
53
-    switch ( $column ) {
53
+    switch ($column) {
54 54
         case 'name' :
55
-            echo get_the_title( $discount->ID );
55
+            echo get_the_title($discount->ID);
56 56
         break;
57 57
         case 'code' :
58
-            echo wpinv_get_discount_code( $discount->ID );
58
+            echo wpinv_get_discount_code($discount->ID);
59 59
         break;
60 60
         case 'amount' :
61
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
61
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
62 62
         break;
63 63
         case 'usage_limit' :
64
-            echo wpinv_get_discount_uses( $discount->ID );
64
+            echo wpinv_get_discount_uses($discount->ID);
65 65
         break;
66 66
         case 'usage' :
67
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
68
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
69
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
67
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
68
+            if (wpinv_get_discount_max_uses($discount->ID)) {
69
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
70 70
             } else {
71 71
                 $usage .= ' &infin;';
72 72
             }
@@ -74,162 +74,162 @@  discard block
 block discarded – undo
74 74
             echo $usage;
75 75
         break;
76 76
         case 'expiry_date' :
77
-            if ( wpinv_get_discount_expiration( $discount->ID ) ) {
78
-                $expiration = date_i18n( get_option( 'date_format' ), strtotime( wpinv_get_discount_expiration( $discount->ID ) ) );
77
+            if (wpinv_get_discount_expiration($discount->ID)) {
78
+                $expiration = date_i18n(get_option('date_format'), strtotime(wpinv_get_discount_expiration($discount->ID)));
79 79
             } else {
80
-                $expiration = __( 'Never', 'invoicing' );
80
+                $expiration = __('Never', 'invoicing');
81 81
             }
82 82
                 
83 83
             echo $expiration;
84 84
         break;
85 85
         case 'description' :
86
-            echo wp_kses_post( $post->post_excerpt );
86
+            echo wp_kses_post($post->post_excerpt);
87 87
         break;
88 88
         case 'status' :
89
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
89
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
90 90
             
91
-            echo wpinv_discount_status( $status );
91
+            echo wpinv_discount_status($status);
92 92
         break;
93 93
     }
94 94
 }
95 95
 
96
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
97
-function wpinv_post_row_actions( $actions, $post ) {
98
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
96
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
97
+function wpinv_post_row_actions($actions, $post) {
98
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
99 99
     
100
-    if ( $post_type == 'wpi_invoice' ) {
100
+    if ($post_type == 'wpi_invoice') {
101 101
         $actions = array();
102 102
     }
103 103
     
104
-    if ( $post_type == 'wpi_discount' ) {
105
-        $actions = wpinv_discount_row_actions( $post, $actions );
104
+    if ($post_type == 'wpi_discount') {
105
+        $actions = wpinv_discount_row_actions($post, $actions);
106 106
     }
107 107
     
108 108
     return $actions;
109 109
 }
110 110
 
111
-function wpinv_discount_row_actions( $discount, $row_actions ) {
112
-    $row_actions  = array();
113
-    $edit_link = get_edit_post_link( $discount->ID );
114
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
111
+function wpinv_discount_row_actions($discount, $row_actions) {
112
+    $row_actions = array();
113
+    $edit_link = get_edit_post_link($discount->ID);
114
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
115 115
 
116
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
117
-        $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>';
118
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
119
-        $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>';
116
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
117
+        $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>';
118
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
119
+        $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>';
120 120
     }
121 121
 
122
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
123
-        if ( isset( $row_actions['delete'] ) ) {
124
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
122
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
123
+        if (isset($row_actions['delete'])) {
124
+            unset($row_actions['delete']); // Don't delete used discounts.
125 125
         }
126 126
     } else {
127
-        $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>';
127
+        $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>';
128 128
     }
129 129
     
130 130
 
131
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
131
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
132 132
 
133 133
     return $row_actions;
134 134
 }
135 135
 
136
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
137
-function wpinv_table_primary_column( $default, $screen_id ) {
138
-    if ( 'edit-wpi_invoice' === $screen_id ) {
136
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
137
+function wpinv_table_primary_column($default, $screen_id) {
138
+    if ('edit-wpi_invoice' === $screen_id) {
139 139
         return 'name';
140 140
     }
141 141
     
142 142
     return $default;
143 143
 }
144 144
 
145
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
146
-    if ( !$display ) {
145
+function wpinv_discount_bulk_actions($actions, $display = false) {    
146
+    if (!$display) {
147 147
         return array();
148 148
     }
149 149
     
150 150
     $actions = array(
151
-        'activate'   => __( 'Activate', 'invoicing' ),
152
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
153
-        'delete'     => __( 'Delete', 'invoicing' ),
151
+        'activate'   => __('Activate', 'invoicing'),
152
+        'deactivate' => __('Deactivate', 'invoicing'),
153
+        'delete'     => __('Delete', 'invoicing'),
154 154
     );
155 155
     $two = '';
156 156
     $which = 'top';
157 157
     echo '</div><div class="alignleft actions bulkactions">';
158
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
159
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
160
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
158
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
159
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
160
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
161 161
 
162
-    foreach ( $actions as $name => $title ) {
162
+    foreach ($actions as $name => $title) {
163 163
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
164 164
 
165 165
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
166 166
     }
167 167
     echo "</select>";
168 168
 
169
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
169
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
170 170
     
171 171
     echo '</div><div class="alignleft actions">';
172 172
 }
173
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
173
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
174 174
 
175
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
176
-    if ( $post_type == 'wpi_discount' ) {
175
+function wpinv_disable_months_dropdown($disable, $post_type) {
176
+    if ($post_type == 'wpi_discount') {
177 177
         $disable = true;
178 178
     }
179 179
     
180 180
     return $disable;
181 181
 }
182
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
182
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
183 183
 
184 184
 function wpinv_restrict_manage_posts() {
185 185
     global $typenow;
186 186
 
187
-    if( 'wpi_discount' == $typenow ) {
187
+    if ('wpi_discount' == $typenow) {
188 188
         wpinv_discount_filters();
189 189
     }
190 190
 }
191
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
191
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
192 192
 
193 193
 function wpinv_discount_filters() {
194
-    echo wpinv_discount_bulk_actions( array(), true );
194
+    echo wpinv_discount_bulk_actions(array(), true);
195 195
     
196 196
     ?>
197 197
     <select name="discount_type" id="dropdown_wpinv_discount_type">
198
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
198
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
199 199
         <?php
200 200
             $types = wpinv_get_discount_types();
201 201
 
202
-            foreach ( $types as $name => $type ) {
203
-                echo '<option value="' . esc_attr( $name ) . '"';
202
+            foreach ($types as $name => $type) {
203
+                echo '<option value="' . esc_attr($name) . '"';
204 204
 
205
-                if ( isset( $_GET['discount_type'] ) )
206
-                    selected( $name, $_GET['discount_type'] );
205
+                if (isset($_GET['discount_type']))
206
+                    selected($name, $_GET['discount_type']);
207 207
 
208
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
208
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
209 209
             }
210 210
         ?>
211 211
     </select>
212 212
     <?php
213 213
 }
214 214
 
215
-function wpinv_request( $vars ) {
215
+function wpinv_request($vars) {
216 216
     global $typenow, $wp_query, $wp_post_statuses;
217 217
 
218
-    if ( 'wpi_invoice' === $typenow ) {
219
-        if ( !isset( $vars['post_status'] ) ) {
218
+    if ('wpi_invoice' === $typenow) {
219
+        if (!isset($vars['post_status'])) {
220 220
             $post_statuses = wpinv_get_invoice_statuses();
221 221
 
222
-            foreach ( $post_statuses as $status => $value ) {
223
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
224
-                    unset( $post_statuses[ $status ] );
222
+            foreach ($post_statuses as $status => $value) {
223
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
224
+                    unset($post_statuses[$status]);
225 225
                 }
226 226
             }
227 227
 
228
-            $vars['post_status'] = array_keys( $post_statuses );
228
+            $vars['post_status'] = array_keys($post_statuses);
229 229
         }
230 230
         
231
-        if ( isset( $vars['orderby'] ) ) {
232
-            if ( 'amount' == $vars['orderby'] ) {
231
+        if (isset($vars['orderby'])) {
232
+            if ('amount' == $vars['orderby']) {
233 233
                 $vars = array_merge(
234 234
                     $vars,
235 235
                     array(
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                         'orderby'  => 'meta_value_num'
238 238
                     )
239 239
                 );
240
-            } else if ( 'customer' == $vars['orderby'] ) {
240
+            } else if ('customer' == $vars['orderby']) {
241 241
                 $vars = array_merge(
242 242
                     $vars,
243 243
                     array(
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                         'orderby'  => 'meta_value'
246 246
                     )
247 247
                 );
248
-            } else if ( 'number' == $vars['orderby'] ) {
248
+            } else if ('number' == $vars['orderby']) {
249 249
                 $vars = array_merge(
250 250
                     $vars,
251 251
                     array(
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
                 );
256 256
             }
257 257
         }
258
-    } else if ( 'wpi_item' == $typenow ) {
258
+    } else if ('wpi_item' == $typenow) {
259 259
         // Check if 'orderby' is set to "price"
260
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
260
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
261 261
             $vars = array_merge(
262 262
                 $vars,
263 263
                 array(
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         }
269 269
 
270 270
         // Check if "orderby" is set to "vat_rule"
271
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
271
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
272 272
             $vars = array_merge(
273 273
                 $vars,
274 274
                 array(
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         }
280 280
 
281 281
         // Check if "orderby" is set to "vat_class"
282
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
282
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
283 283
             $vars = array_merge(
284 284
                 $vars,
285 285
                 array(
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         }
291 291
         
292 292
         // Check if "orderby" is set to "type"
293
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
293
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
294 294
             $vars = array_merge(
295 295
                 $vars,
296 296
                 array(
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
         }
302 302
         
303 303
         // Check if "orderby" is set to "recurring"
304
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
304
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
305 305
             $vars = array_merge(
306 306
                 $vars,
307 307
                 array(
@@ -311,120 +311,120 @@  discard block
 block discarded – undo
311 311
             );
312 312
         }
313 313
 
314
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
314
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
315 315
         // Filter vat rule type
316
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
316
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
317 317
             $meta_query[] = array(
318 318
                     'key'   => '_wpinv_vat_rule',
319
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
319
+                    'value' => sanitize_text_field($_GET['vat_rule']),
320 320
                     'compare' => '='
321 321
                 );
322 322
         }
323 323
         
324 324
         // Filter vat class
325
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
325
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
326 326
             $meta_query[] = array(
327 327
                     'key'   => '_wpinv_vat_class',
328
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
328
+                    'value' => sanitize_text_field($_GET['vat_class']),
329 329
                     'compare' => '='
330 330
                 );
331 331
         }
332 332
         
333 333
         // Filter item type
334
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
334
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
335 335
             $meta_query[] = array(
336 336
                     'key'   => '_wpinv_type',
337
-                    'value' => sanitize_text_field( $_GET['type'] ),
337
+                    'value' => sanitize_text_field($_GET['type']),
338 338
                     'compare' => '='
339 339
                 );
340 340
         }
341 341
         
342
-        if ( !empty( $meta_query ) ) {
342
+        if (!empty($meta_query)) {
343 343
             $vars['meta_query'] = $meta_query;
344 344
         }
345
-    } else if ( 'wpi_discount' == $typenow ) {
346
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
345
+    } else if ('wpi_discount' == $typenow) {
346
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
347 347
         // Filter vat rule type
348
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
348
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
349 349
             $meta_query[] = array(
350 350
                     'key'   => '_wpi_discount_type',
351
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
351
+                    'value' => sanitize_text_field($_GET['discount_type']),
352 352
                     'compare' => '='
353 353
                 );
354 354
         }
355 355
         
356
-        if ( !empty( $meta_query ) ) {
356
+        if (!empty($meta_query)) {
357 357
             $vars['meta_query'] = $meta_query;
358 358
         }
359 359
     }
360 360
 
361 361
     return $vars;
362 362
 }
363
-add_filter( 'request', 'wpinv_request' );
363
+add_filter('request', 'wpinv_request');
364 364
 
365 365
 function wpinv_options_page() {
366
-    $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
366
+    $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
367 367
     
368
-    if ( $page !== 'wpinv-settings' ) {
368
+    if ($page !== 'wpinv-settings') {
369 369
         return;
370 370
     }
371 371
     
372 372
     $settings_tabs = wpinv_get_settings_tabs();
373 373
     $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
374
-    $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
375
-    $sections      = wpinv_get_settings_tab_sections( $active_tab );
374
+    $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
375
+    $sections      = wpinv_get_settings_tab_sections($active_tab);
376 376
     $key           = 'main';
377 377
 
378
-    if ( is_array( $sections ) ) {
379
-        $key = key( $sections );
378
+    if (is_array($sections)) {
379
+        $key = key($sections);
380 380
     }
381 381
 
382
-    $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
383
-    $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
382
+    $registered_sections = wpinv_get_settings_tab_sections($active_tab);
383
+    $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
384 384
     ob_start();
385 385
     ?>
386 386
     <div class="wrap">
387 387
         <h1 class="nav-tab-wrapper">
388 388
             <?php
389
-            foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
390
-                $tab_url = add_query_arg( array(
389
+            foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
390
+                $tab_url = add_query_arg(array(
391 391
                     'settings-updated' => false,
392 392
                     'tab' => $tab_id,
393
-                ) );
393
+                ));
394 394
 
395 395
                 // Remove the section from the tabs so we always end up at the main section
396
-                $tab_url = remove_query_arg( 'section', $tab_url );
397
-                $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
396
+                $tab_url = remove_query_arg('section', $tab_url);
397
+                $tab_url = remove_query_arg('wpi_sub', $tab_url);
398 398
 
399 399
                 $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
400 400
 
401
-                echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
402
-                    echo esc_html( $tab_name );
401
+                echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
402
+                    echo esc_html($tab_name);
403 403
                 echo '</a>';
404 404
             }
405 405
             ?>
406 406
         </h1>
407 407
         <?php
408
-        $number_of_sections = count( $sections );
408
+        $number_of_sections = count($sections);
409 409
         $number = 0;
410
-        if ( $number_of_sections > 1 ) {
410
+        if ($number_of_sections > 1) {
411 411
             echo '<div><ul class="subsubsub">';
412
-            foreach( $sections as $section_id => $section_name ) {
412
+            foreach ($sections as $section_id => $section_name) {
413 413
                 echo '<li>';
414 414
                 $number++;
415
-                $tab_url = add_query_arg( array(
415
+                $tab_url = add_query_arg(array(
416 416
                     'settings-updated' => false,
417 417
                     'tab' => $active_tab,
418 418
                     'section' => $section_id
419
-                ) );
420
-                $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
419
+                ));
420
+                $tab_url = remove_query_arg('wpi_sub', $tab_url);
421 421
                 $class = '';
422
-                if ( $section == $section_id ) {
422
+                if ($section == $section_id) {
423 423
                     $class = 'current';
424 424
                 }
425
-                echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
425
+                echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
426 426
 
427
-                if ( $number != $number_of_sections ) {
427
+                if ($number != $number_of_sections) {
428 428
                     echo ' | ';
429 429
                 }
430 430
                 echo '</li>';
@@ -436,19 +436,19 @@  discard block
 block discarded – undo
436 436
             <form method="post" action="options.php">
437 437
                 <table class="form-table">
438 438
                 <?php
439
-                settings_fields( 'wpinv_settings' );
439
+                settings_fields('wpinv_settings');
440 440
 
441
-                if ( 'main' === $section ) {
442
-                    do_action( 'wpinv_settings_tab_top', $active_tab );
441
+                if ('main' === $section) {
442
+                    do_action('wpinv_settings_tab_top', $active_tab);
443 443
                 }
444 444
 
445
-                do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section );
446
-                do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section );
447
-                do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section  );
445
+                do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section);
446
+                do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section);
447
+                do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section);
448 448
 
449 449
                 // For backwards compatibility
450
-                if ( 'main' === $section ) {
451
-                    do_action( 'wpinv_settings_tab_bottom', $active_tab );
450
+                if ('main' === $section) {
451
+                    do_action('wpinv_settings_tab_bottom', $active_tab);
452 452
                 }
453 453
                 ?>
454 454
                 </table>
@@ -461,53 +461,53 @@  discard block
 block discarded – undo
461 461
     echo $content;
462 462
 }
463 463
 
464
-function wpinv_item_type_class( $classes, $class, $post_id ) {
464
+function wpinv_item_type_class($classes, $class, $post_id) {
465 465
     global $pagenow, $typenow;
466 466
 
467
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
468
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
469
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
467
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
468
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
469
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
470 470
         }
471 471
         
472
-        if ( !wpinv_item_is_editable( $post_id ) ) {
472
+        if (!wpinv_item_is_editable($post_id)) {
473 473
             $classes[] = 'wpi-editable-n';
474 474
         }
475 475
     }
476 476
     return $classes;
477 477
 }
478
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
478
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
479 479
 
480 480
 function wpinv_check_quick_edit() {
481 481
     global $pagenow, $current_screen, $wpinv_item_screen;
482 482
 
483
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
484
-        if ( empty( $wpinv_item_screen ) ) {
485
-            if ( $current_screen->post_type == 'wpi_item' ) {
483
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
484
+        if (empty($wpinv_item_screen)) {
485
+            if ($current_screen->post_type == 'wpi_item') {
486 486
                 $wpinv_item_screen = 'y';
487 487
             } else {
488 488
                 $wpinv_item_screen = 'n';
489 489
             }
490 490
         }
491 491
 
492
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
493
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
494
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
492
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
493
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
494
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
495 495
         }
496 496
     }
497 497
 }
498
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
498
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
499 499
 
500
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
501
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
502
-        unset( $actions['inline hide-if-no-js'] );
500
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
501
+    if (isset($actions['inline hide-if-no-js'])) {
502
+        unset($actions['inline hide-if-no-js']);
503 503
     }
504 504
     
505
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
506
-        if ( isset( $actions['trash'] ) ) {
507
-            unset( $actions['trash'] );
505
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
506
+        if (isset($actions['trash'])) {
507
+            unset($actions['trash']);
508 508
         }
509
-        if ( isset( $actions['delete'] ) ) {
510
-            unset( $actions['delete'] );
509
+        if (isset($actions['delete'])) {
510
+            unset($actions['delete']);
511 511
         }
512 512
     }
513 513
 
@@ -524,19 +524,19 @@  discard block
 block discarded – undo
524 524
  * @param int $post_parent (default: 0) Parent for the new page
525 525
  * @return int page ID
526 526
  */
527
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
527
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
528 528
     global $wpdb;
529 529
 
530
-    $option_value = wpinv_get_option( $option );
530
+    $option_value = wpinv_get_option($option);
531 531
 
532
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
533
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
532
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
533
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
534 534
             // Valid page is already in place
535 535
             return $page_object->ID;
536 536
         }
537 537
     }
538 538
 
539
-    if(!empty($post_parent)){
539
+    if (!empty($post_parent)) {
540 540
         $page = get_page_by_path($post_parent);
541 541
         if ($page) {
542 542
             $post_parent = $page->ID;
@@ -545,40 +545,40 @@  discard block
 block discarded – undo
545 545
         }
546 546
     }
547 547
 
548
-    if ( strlen( $page_content ) > 0 ) {
548
+    if (strlen($page_content) > 0) {
549 549
         // Search for an existing page with the specified page content (typically a shortcode)
550
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
550
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
551 551
     } else {
552 552
         // Search for an existing page with the specified page slug
553
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
553
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
554 554
     }
555 555
 
556
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
556
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
557 557
 
558
-    if ( $valid_page_found ) {
559
-        if ( $option ) {
560
-            wpinv_update_option( $option, $valid_page_found );
558
+    if ($valid_page_found) {
559
+        if ($option) {
560
+            wpinv_update_option($option, $valid_page_found);
561 561
         }
562 562
         return $valid_page_found;
563 563
     }
564 564
 
565 565
     // Search for a matching valid trashed page
566
-    if ( strlen( $page_content ) > 0 ) {
566
+    if (strlen($page_content) > 0) {
567 567
         // Search for an existing page with the specified page content (typically a shortcode)
568
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
568
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
569 569
     } else {
570 570
         // Search for an existing page with the specified page slug
571
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
571
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
572 572
     }
573 573
 
574
-    if ( $trashed_page_found ) {
574
+    if ($trashed_page_found) {
575 575
         $page_id   = $trashed_page_found;
576 576
         $page_data = array(
577 577
             'ID'             => $page_id,
578 578
             'post_status'    => 'publish',
579 579
             'post_parent'    => $post_parent,
580 580
         );
581
-        wp_update_post( $page_data );
581
+        wp_update_post($page_data);
582 582
     } else {
583 583
         $page_data = array(
584 584
             'post_status'    => 'publish',
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
             'post_parent'    => $post_parent,
591 591
             'comment_status' => 'closed',
592 592
         );
593
-        $page_id = wp_insert_post( $page_data );
593
+        $page_id = wp_insert_post($page_data);
594 594
     }
595 595
 
596
-    if ( $option ) {
597
-        wpinv_update_option( $option, (int)$page_id );
596
+    if ($option) {
597
+        wpinv_update_option($option, (int)$page_id);
598 598
     }
599 599
 
600 600
     return $page_id;
Please login to merge, or discard this patch.
includes/admin/register-settings.php 3 patches
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -912,10 +912,11 @@  discard block
 block discarded – undo
912 912
         
913 913
         $checked = false;
914 914
 
915
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
916
-			$checked = true;
917
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
918
-			$checked = true;
915
+		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) {
916
+					$checked = true;
917
+		} elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) {
918
+					$checked = true;
919
+		}
919 920
 
920 921
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
921 922
 		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
@@ -932,10 +933,11 @@  discard block
 block discarded – undo
932 933
 	foreach ( $args['options'] as $key => $option ) :
933 934
 		$sanitize_key = wpinv_sanitize_key( $key );
934 935
         
935
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
936
-			$enabled = '1';
937
-		else
938
-			$enabled = null;
936
+        if ( isset( $wpinv_options['gateways'][ $key ] ) ) {
937
+        			$enabled = '1';
938
+        } else {
939
+					$enabled = null;
940
+		}
939 941
 
940 942
 		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) . '/>&nbsp;';
941 943
 		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
@@ -1302,7 +1304,8 @@  discard block
 block discarded – undo
1302 1304
 				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1303 1305
 			</tr>
1304 1306
 			<?php endforeach; ?>
1305
-		<?php else : ?>
1307
+		<?php else {
1308
+    : ?>
1306 1309
 			<tr>
1307 1310
 				<td class="wpinv_tax_country">
1308 1311
 					<?php
@@ -1314,7 +1317,9 @@  discard block
 block discarded – undo
1314 1317
 						'class'            => 'wpinv-tax-country',
1315 1318
 						'chosen'           => false,
1316 1319
 						'placeholder'      => __( 'Choose a country', 'invoicing' )
1317
-					) ); ?>
1320
+					) );
1321
+}
1322
+?>
1318 1323
 				</td>
1319 1324
 				<td class="wpinv_tax_state">
1320 1325
 					<?php echo wpinv_html_text( array(
Please login to merge, or discard this patch.
Indentation   +336 added lines, -336 removed lines patch added patch discarded remove patch
@@ -831,328 +831,328 @@  discard block
 block discarded – undo
831 831
 }
832 832
 
833 833
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
834
-	$pages_options = array();
834
+    $pages_options = array();
835 835
 
836
-	if( $default_label !== NULL && $default_label !== false ) {
837
-		$pages_options = array( '' => $default_label ); // Blank option
838
-	}
836
+    if( $default_label !== NULL && $default_label !== false ) {
837
+        $pages_options = array( '' => $default_label ); // Blank option
838
+    }
839 839
 
840
-	$pages = get_pages();
841
-	if ( $pages ) {
842
-		foreach ( $pages as $page ) {
843
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
840
+    $pages = get_pages();
841
+    if ( $pages ) {
842
+        foreach ( $pages as $page ) {
843
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
844 844
             $pages_options[ $page->ID ] = $title;
845
-		}
846
-	}
845
+        }
846
+    }
847 847
 
848
-	return $pages_options;
848
+    return $pages_options;
849 849
 }
850 850
 
851 851
 function wpinv_header_callback( $args ) {
852
-	if ( !empty( $args['desc'] ) ) {
852
+    if ( !empty( $args['desc'] ) ) {
853 853
         echo $args['desc'];
854 854
     }
855 855
 }
856 856
 
857 857
 function wpinv_hidden_callback( $args ) {
858
-	global $wpinv_options;
859
-
860
-	if ( isset( $args['set_value'] ) ) {
861
-		$value = $args['set_value'];
862
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
863
-		$value = $wpinv_options[ $args['id'] ];
864
-	} else {
865
-		$value = isset( $args['std'] ) ? $args['std'] : '';
866
-	}
867
-
868
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
869
-		$args['readonly'] = true;
870
-		$value = isset( $args['std'] ) ? $args['std'] : '';
871
-		$name  = '';
872
-	} else {
873
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
874
-	}
875
-
876
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
858
+    global $wpinv_options;
859
+
860
+    if ( isset( $args['set_value'] ) ) {
861
+        $value = $args['set_value'];
862
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
863
+        $value = $wpinv_options[ $args['id'] ];
864
+    } else {
865
+        $value = isset( $args['std'] ) ? $args['std'] : '';
866
+    }
867
+
868
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
869
+        $args['readonly'] = true;
870
+        $value = isset( $args['std'] ) ? $args['std'] : '';
871
+        $name  = '';
872
+    } else {
873
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
874
+    }
875
+
876
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
877 877
     
878
-	echo $html;
878
+    echo $html;
879 879
 }
880 880
 
881 881
 function wpinv_checkbox_callback( $args ) {
882
-	global $wpinv_options;
882
+    global $wpinv_options;
883 883
     
884 884
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
885 885
 
886
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
887
-		$name = '';
888
-	} else {
889
-		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
890
-	}
886
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
887
+        $name = '';
888
+    } else {
889
+        $name = 'name="wpinv_settings[' . $sanitize_id . ']"';
890
+    }
891 891
 
892
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
893
-	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
894
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+    $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
893
+    $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
894
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
895 895
 
896
-	echo $html;
896
+    echo $html;
897 897
 }
898 898
 
899 899
 function wpinv_multicheck_callback( $args ) {
900
-	global $wpinv_options;
900
+    global $wpinv_options;
901 901
 	
902
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
902
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
903 903
 	
904
-	if ( ! empty( $args['options'] ) ) {
905
-		foreach( $args['options'] as $key => $option ):
906
-			$sanitize_key = wpinv_sanitize_key( $key );
907
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
908
-				$enabled = $sanitize_key;
909
-			} else { 
910
-				$enabled = NULL; 
911
-			}
912
-			echo '<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 ) . '/>&nbsp;';
913
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
914
-		endforeach;
915
-		echo '<p class="description">' . $args['desc'] . '</p>';
916
-	}
904
+    if ( ! empty( $args['options'] ) ) {
905
+        foreach( $args['options'] as $key => $option ):
906
+            $sanitize_key = wpinv_sanitize_key( $key );
907
+            if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
908
+                $enabled = $sanitize_key;
909
+            } else { 
910
+                $enabled = NULL; 
911
+            }
912
+            echo '<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 ) . '/>&nbsp;';
913
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
914
+        endforeach;
915
+        echo '<p class="description">' . $args['desc'] . '</p>';
916
+    }
917 917
 }
918 918
 
919 919
 function wpinv_payment_icons_callback( $args ) {
920
-	global $wpinv_options;
920
+    global $wpinv_options;
921 921
     
922 922
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
923 923
 
924
-	if ( ! empty( $args['options'] ) ) {
925
-		foreach( $args['options'] as $key => $option ) {
924
+    if ( ! empty( $args['options'] ) ) {
925
+        foreach( $args['options'] as $key => $option ) {
926 926
             $sanitize_key = wpinv_sanitize_key( $key );
927 927
             
928
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
929
-				$enabled = $option;
930
-			} else {
931
-				$enabled = NULL;
932
-			}
933
-
934
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
935
-
936
-				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 ) . '/>&nbsp;';
937
-
938
-				if ( wpinv_string_is_image_url( $key ) ) {
939
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
940
-				} else {
941
-					$card = strtolower( str_replace( ' ', '', $option ) );
942
-
943
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
944
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
945
-					} else {
946
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
947
-						$content_dir = WP_CONTENT_DIR;
948
-
949
-						if ( function_exists( 'wp_normalize_path' ) ) {
950
-							// Replaces backslashes with forward slashes for Windows systems
951
-							$image = wp_normalize_path( $image );
952
-							$content_dir = wp_normalize_path( $content_dir );
953
-						}
954
-
955
-						$image = str_replace( $content_dir, content_url(), $image );
956
-					}
957
-
958
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
959
-				}
960
-			echo $option . '</label>';
961
-		}
962
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
963
-	}
928
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
929
+                $enabled = $option;
930
+            } else {
931
+                $enabled = NULL;
932
+            }
933
+
934
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
935
+
936
+                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 ) . '/>&nbsp;';
937
+
938
+                if ( wpinv_string_is_image_url( $key ) ) {
939
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
940
+                } else {
941
+                    $card = strtolower( str_replace( ' ', '', $option ) );
942
+
943
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
944
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
945
+                    } else {
946
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
947
+                        $content_dir = WP_CONTENT_DIR;
948
+
949
+                        if ( function_exists( 'wp_normalize_path' ) ) {
950
+                            // Replaces backslashes with forward slashes for Windows systems
951
+                            $image = wp_normalize_path( $image );
952
+                            $content_dir = wp_normalize_path( $content_dir );
953
+                        }
954
+
955
+                        $image = str_replace( $content_dir, content_url(), $image );
956
+                    }
957
+
958
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
959
+                }
960
+            echo $option . '</label>';
961
+        }
962
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
963
+    }
964 964
 }
965 965
 
966 966
 function wpinv_radio_callback( $args ) {
967
-	global $wpinv_options;
967
+    global $wpinv_options;
968 968
     
969 969
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
970 970
     
971 971
     foreach ( $args['options'] as $key => $option ) :
972
-		$sanitize_key = wpinv_sanitize_key( $key );
972
+        $sanitize_key = wpinv_sanitize_key( $key );
973 973
         
974 974
         $checked = false;
975 975
 
976
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
977
-			$checked = true;
978
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
979
-			$checked = true;
976
+        if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
977
+            $checked = true;
978
+        elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
979
+            $checked = true;
980 980
 
981
-		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
982
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
983
-	endforeach;
981
+        echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
982
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
983
+    endforeach;
984 984
 
985
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
985
+    echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
986 986
 }
987 987
 
988 988
 function wpinv_gateways_callback( $args ) {
989
-	global $wpinv_options;
989
+    global $wpinv_options;
990 990
     
991 991
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
992 992
 
993
-	foreach ( $args['options'] as $key => $option ) :
994
-		$sanitize_key = wpinv_sanitize_key( $key );
993
+    foreach ( $args['options'] as $key => $option ) :
994
+        $sanitize_key = wpinv_sanitize_key( $key );
995 995
         
996 996
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
997
-			$enabled = '1';
998
-		else
999
-			$enabled = null;
997
+            $enabled = '1';
998
+        else
999
+            $enabled = null;
1000 1000
 
1001
-		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) . '/>&nbsp;';
1002
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1003
-	endforeach;
1001
+        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) . '/>&nbsp;';
1002
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1003
+    endforeach;
1004 1004
 }
1005 1005
 
1006 1006
 function wpinv_gateway_select_callback($args) {
1007
-	global $wpinv_options;
1007
+    global $wpinv_options;
1008 1008
     
1009 1009
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1010 1010
 
1011
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1011
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1012 1012
 
1013
-	foreach ( $args['options'] as $key => $option ) :
1014
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1013
+    foreach ( $args['options'] as $key => $option ) :
1014
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1015 1015
             $selected = selected( $key, $args['selected'], false );
1016 1016
         } else {
1017 1017
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1018 1018
         }
1019
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1020
-	endforeach;
1019
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1020
+    endforeach;
1021 1021
 
1022
-	echo '</select>';
1023
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1022
+    echo '</select>';
1023
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1024 1024
 }
1025 1025
 
1026 1026
 function wpinv_text_callback( $args ) {
1027
-	global $wpinv_options;
1027
+    global $wpinv_options;
1028 1028
     
1029 1029
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1030 1030
 
1031
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1032
-		$value = $wpinv_options[ $args['id'] ];
1033
-	} else {
1034
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1035
-	}
1036
-
1037
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1038
-		$args['readonly'] = true;
1039
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1040
-		$name  = '';
1041
-	} else {
1042
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1043
-	}
1044
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1045
-
1046
-	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1047
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1048
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1049
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1050
-
1051
-	echo $html;
1031
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1032
+        $value = $wpinv_options[ $args['id'] ];
1033
+    } else {
1034
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1035
+    }
1036
+
1037
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1038
+        $args['readonly'] = true;
1039
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1040
+        $name  = '';
1041
+    } else {
1042
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1043
+    }
1044
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1045
+
1046
+    $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1047
+    $size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1048
+    $html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1049
+    $html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1050
+
1051
+    echo $html;
1052 1052
 }
1053 1053
 
1054 1054
 function wpinv_number_callback( $args ) {
1055
-	global $wpinv_options;
1055
+    global $wpinv_options;
1056 1056
     
1057 1057
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1058 1058
 
1059
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1060
-		$value = $wpinv_options[ $args['id'] ];
1061
-	} else {
1062
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1063
-	}
1064
-
1065
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1066
-		$args['readonly'] = true;
1067
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1068
-		$name  = '';
1069
-	} else {
1070
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1071
-	}
1072
-
1073
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1074
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1075
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1076
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1077
-
1078
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1079
-	$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 ) ) . '"/>';
1080
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1081
-
1082
-	echo $html;
1059
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1060
+        $value = $wpinv_options[ $args['id'] ];
1061
+    } else {
1062
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1063
+    }
1064
+
1065
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1066
+        $args['readonly'] = true;
1067
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1068
+        $name  = '';
1069
+    } else {
1070
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1071
+    }
1072
+
1073
+    $max  = isset( $args['max'] ) ? $args['max'] : 999999;
1074
+    $min  = isset( $args['min'] ) ? $args['min'] : 0;
1075
+    $step = isset( $args['step'] ) ? $args['step'] : 1;
1076
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1077
+
1078
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1079
+    $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 ) ) . '"/>';
1080
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1081
+
1082
+    echo $html;
1083 1083
 }
1084 1084
 
1085 1085
 function wpinv_textarea_callback( $args ) {
1086
-	global $wpinv_options;
1086
+    global $wpinv_options;
1087 1087
     
1088 1088
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1089 1089
 
1090
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1091
-		$value = $wpinv_options[ $args['id'] ];
1092
-	} else {
1093
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1094
-	}
1090
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1091
+        $value = $wpinv_options[ $args['id'] ];
1092
+    } else {
1093
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1094
+    }
1095 1095
     
1096 1096
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1097 1097
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1098 1098
 
1099
-	$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>';
1100
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1099
+    $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>';
1100
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1101 1101
 
1102
-	echo $html;
1102
+    echo $html;
1103 1103
 }
1104 1104
 
1105 1105
 function wpinv_password_callback( $args ) {
1106
-	global $wpinv_options;
1106
+    global $wpinv_options;
1107 1107
     
1108 1108
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1109 1109
 
1110
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1111
-		$value = $wpinv_options[ $args['id'] ];
1112
-	} else {
1113
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1114
-	}
1110
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1111
+        $value = $wpinv_options[ $args['id'] ];
1112
+    } else {
1113
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1114
+    }
1115 1115
 
1116
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1117
-	$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 ) . '"/>';
1118
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1116
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1117
+    $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 ) . '"/>';
1118
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1119 1119
 
1120
-	echo $html;
1120
+    echo $html;
1121 1121
 }
1122 1122
 
1123 1123
 function wpinv_missing_callback($args) {
1124
-	printf(
1125
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1126
-		'<strong>' . $args['id'] . '</strong>'
1127
-	);
1124
+    printf(
1125
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1126
+        '<strong>' . $args['id'] . '</strong>'
1127
+    );
1128 1128
 }
1129 1129
 
1130 1130
 function wpinv_select_callback($args) {
1131
-	global $wpinv_options;
1131
+    global $wpinv_options;
1132 1132
     
1133 1133
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1134 1134
 
1135
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1136
-		$value = $wpinv_options[ $args['id'] ];
1137
-	} else {
1138
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1139
-	}
1135
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1136
+        $value = $wpinv_options[ $args['id'] ];
1137
+    } else {
1138
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1139
+    }
1140 1140
     
1141 1141
     if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1142 1142
         $value = $args['selected'];
1143 1143
     }
1144 1144
 
1145
-	if ( isset( $args['placeholder'] ) ) {
1146
-		$placeholder = $args['placeholder'];
1147
-	} else {
1148
-		$placeholder = '';
1149
-	}
1150
-
1151
-	if ( isset( $args['chosen'] ) ) {
1152
-		$chosen = 'class="wpinv-chosen"';
1153
-	} else {
1154
-		$chosen = '';
1155
-	}
1145
+    if ( isset( $args['placeholder'] ) ) {
1146
+        $placeholder = $args['placeholder'];
1147
+    } else {
1148
+        $placeholder = '';
1149
+    }
1150
+
1151
+    if ( isset( $args['chosen'] ) ) {
1152
+        $chosen = 'class="wpinv-chosen"';
1153
+    } else {
1154
+        $chosen = '';
1155
+    }
1156 1156
     
1157 1157
     if( !empty( $args['onchange'] ) ) {
1158 1158
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
@@ -1160,143 +1160,143 @@  discard block
 block discarded – undo
1160 1160
         $onchange = '';
1161 1161
     }
1162 1162
 
1163
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1163
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1164 1164
 
1165
-	foreach ( $args['options'] as $option => $name ) {
1166
-		$selected = selected( $option, $value, false );
1167
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1168
-	}
1165
+    foreach ( $args['options'] as $option => $name ) {
1166
+        $selected = selected( $option, $value, false );
1167
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1168
+    }
1169 1169
 
1170
-	$html .= '</select>';
1171
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1170
+    $html .= '</select>';
1171
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1172 1172
 
1173
-	echo $html;
1173
+    echo $html;
1174 1174
 }
1175 1175
 
1176 1176
 function wpinv_color_select_callback( $args ) {
1177
-	global $wpinv_options;
1177
+    global $wpinv_options;
1178 1178
     
1179 1179
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1180 1180
 
1181
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1182
-		$value = $wpinv_options[ $args['id'] ];
1183
-	} else {
1184
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1185
-	}
1181
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1182
+        $value = $wpinv_options[ $args['id'] ];
1183
+    } else {
1184
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1185
+    }
1186 1186
 
1187
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1187
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1188 1188
 
1189
-	foreach ( $args['options'] as $option => $color ) {
1190
-		$selected = selected( $option, $value, false );
1191
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1192
-	}
1189
+    foreach ( $args['options'] as $option => $color ) {
1190
+        $selected = selected( $option, $value, false );
1191
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1192
+    }
1193 1193
 
1194
-	$html .= '</select>';
1195
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1194
+    $html .= '</select>';
1195
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1196 1196
 
1197
-	echo $html;
1197
+    echo $html;
1198 1198
 }
1199 1199
 
1200 1200
 function wpinv_rich_editor_callback( $args ) {
1201
-	global $wpinv_options, $wp_version;
1201
+    global $wpinv_options, $wp_version;
1202 1202
     
1203 1203
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1204 1204
 
1205
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1206
-		$value = $wpinv_options[ $args['id'] ];
1205
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1206
+        $value = $wpinv_options[ $args['id'] ];
1207 1207
 
1208
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1209
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1210
-		}
1211
-	} else {
1212
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1213
-	}
1208
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1209
+            $value = isset( $args['std'] ) ? $args['std'] : '';
1210
+        }
1211
+    } else {
1212
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1213
+    }
1214 1214
 
1215
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1215
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
1216 1216
 
1217
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1218
-		ob_start();
1219
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1220
-		$html = ob_get_clean();
1221
-	} else {
1222
-		$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>';
1223
-	}
1217
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1218
+        ob_start();
1219
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1220
+        $html = ob_get_clean();
1221
+    } else {
1222
+        $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>';
1223
+    }
1224 1224
 
1225
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1225
+    $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1226 1226
 
1227
-	echo $html;
1227
+    echo $html;
1228 1228
 }
1229 1229
 
1230 1230
 function wpinv_upload_callback( $args ) {
1231
-	global $wpinv_options;
1231
+    global $wpinv_options;
1232 1232
     
1233 1233
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1234 1234
 
1235
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1236
-		$value = $wpinv_options[$args['id']];
1237
-	} else {
1238
-		$value = isset($args['std']) ? $args['std'] : '';
1239
-	}
1235
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1236
+        $value = $wpinv_options[$args['id']];
1237
+    } else {
1238
+        $value = isset($args['std']) ? $args['std'] : '';
1239
+    }
1240 1240
 
1241
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1242
-	$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 ) ) . '"/>';
1243
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1244
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1241
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1242
+    $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 ) ) . '"/>';
1243
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1244
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1245 1245
 
1246
-	echo $html;
1246
+    echo $html;
1247 1247
 }
1248 1248
 
1249 1249
 function wpinv_color_callback( $args ) {
1250
-	global $wpinv_options;
1250
+    global $wpinv_options;
1251 1251
     
1252 1252
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1253 1253
 
1254
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1255
-		$value = $wpinv_options[ $args['id'] ];
1256
-	} else {
1257
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1258
-	}
1254
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1255
+        $value = $wpinv_options[ $args['id'] ];
1256
+    } else {
1257
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1258
+    }
1259 1259
 
1260
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1260
+    $default = isset( $args['std'] ) ? $args['std'] : '';
1261 1261
 
1262
-	$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 ) . '" />';
1263
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1262
+    $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 ) . '" />';
1263
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1264 1264
 
1265
-	echo $html;
1265
+    echo $html;
1266 1266
 }
1267 1267
 
1268 1268
 function wpinv_country_states_callback($args) {
1269
-	global $wpinv_options;
1269
+    global $wpinv_options;
1270 1270
     
1271 1271
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1272 1272
 
1273
-	if ( isset( $args['placeholder'] ) ) {
1274
-		$placeholder = $args['placeholder'];
1275
-	} else {
1276
-		$placeholder = '';
1277
-	}
1273
+    if ( isset( $args['placeholder'] ) ) {
1274
+        $placeholder = $args['placeholder'];
1275
+    } else {
1276
+        $placeholder = '';
1277
+    }
1278 1278
 
1279
-	$states = wpinv_get_country_states();
1279
+    $states = wpinv_get_country_states();
1280 1280
 
1281
-	$chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1282
-	$class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1283
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1281
+    $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1282
+    $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1283
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1284 1284
 
1285
-	foreach ( $states as $option => $name ) {
1286
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1287
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1288
-	}
1285
+    foreach ( $states as $option => $name ) {
1286
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1287
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1288
+    }
1289 1289
 
1290
-	$html .= '</select>';
1291
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1290
+    $html .= '</select>';
1291
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1292 1292
 
1293
-	echo $html;
1293
+    echo $html;
1294 1294
 }
1295 1295
 
1296 1296
 function wpinv_tax_rates_callback($args) {
1297
-	global $wpinv_options;
1298
-	$rates = wpinv_get_tax_rates();
1299
-	ob_start(); ?>
1297
+    global $wpinv_options;
1298
+    $rates = wpinv_get_tax_rates();
1299
+    ob_start(); ?>
1300 1300
     </td><tr>
1301 1301
     <td colspan="2" class="wpinv_tax_tdbox">
1302 1302
 	<p><?php echo $args['desc']; ?></p>
@@ -1320,41 +1320,41 @@  discard block
 block discarded – undo
1320 1320
 			<tr>
1321 1321
 				<td class="wpinv_tax_country">
1322 1322
 					<?php
1323
-					echo wpinv_html_select( array(
1324
-						'options'          => wpinv_get_country_list( true ),
1325
-						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1323
+                    echo wpinv_html_select( array(
1324
+                        'options'          => wpinv_get_country_list( true ),
1325
+                        'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1326 1326
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1327
-						'selected'         => $rate['country'],
1328
-						'show_option_all'  => false,
1329
-						'show_option_none' => false,
1330
-						'class'            => 'wpinv-tax-country',
1331
-						'chosen'           => false,
1332
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1333
-					) );
1334
-					?>
1327
+                        'selected'         => $rate['country'],
1328
+                        'show_option_all'  => false,
1329
+                        'show_option_none' => false,
1330
+                        'class'            => 'wpinv-tax-country',
1331
+                        'chosen'           => false,
1332
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
1333
+                    ) );
1334
+                    ?>
1335 1335
 				</td>
1336 1336
 				<td class="wpinv_tax_state">
1337 1337
 					<?php
1338
-					$states = wpinv_get_country_states( $rate['country'] );
1339
-					if( !empty( $states ) ) {
1340
-						echo wpinv_html_select( array(
1341
-							'options'          => array_merge( array( '' => '' ), $states ),
1342
-							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1338
+                    $states = wpinv_get_country_states( $rate['country'] );
1339
+                    if( !empty( $states ) ) {
1340
+                        echo wpinv_html_select( array(
1341
+                            'options'          => array_merge( array( '' => '' ), $states ),
1342
+                            'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1343 1343
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1344
-							'selected'         => $rate['state'],
1345
-							'show_option_all'  => false,
1346
-							'show_option_none' => false,
1347
-							'chosen'           => false,
1348
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1349
-						) );
1350
-					} else {
1351
-						echo wpinv_html_text( array(
1352
-							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1353
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1344
+                            'selected'         => $rate['state'],
1345
+                            'show_option_all'  => false,
1346
+                            'show_option_none' => false,
1347
+                            'chosen'           => false,
1348
+                            'placeholder'      => __( 'Choose a state', 'invoicing' )
1349
+                        ) );
1350
+                    } else {
1351
+                        echo wpinv_html_text( array(
1352
+                            'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1353
+                            'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1354 1354
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1355
-						) );
1356
-					}
1357
-					?>
1355
+                        ) );
1356
+                    }
1357
+                    ?>
1358 1358
 				</td>
1359 1359
 				<td class="wpinv_tax_global">
1360 1360
 					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
@@ -1369,20 +1369,20 @@  discard block
 block discarded – undo
1369 1369
 			<tr>
1370 1370
 				<td class="wpinv_tax_country">
1371 1371
 					<?php
1372
-					echo wpinv_html_select( array(
1373
-						'options'          => wpinv_get_country_list( true ),
1374
-						'name'             => 'tax_rates[0][country]',
1375
-						'show_option_all'  => false,
1376
-						'show_option_none' => false,
1377
-						'class'            => 'wpinv-tax-country',
1378
-						'chosen'           => false,
1379
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1380
-					) ); ?>
1372
+                    echo wpinv_html_select( array(
1373
+                        'options'          => wpinv_get_country_list( true ),
1374
+                        'name'             => 'tax_rates[0][country]',
1375
+                        'show_option_all'  => false,
1376
+                        'show_option_none' => false,
1377
+                        'class'            => 'wpinv-tax-country',
1378
+                        'chosen'           => false,
1379
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
1380
+                    ) ); ?>
1381 1381
 				</td>
1382 1382
 				<td class="wpinv_tax_state">
1383 1383
 					<?php echo wpinv_html_text( array(
1384
-						'name' => 'tax_rates[0][state]'
1385
-					) ); ?>
1384
+                        'name' => 'tax_rates[0][state]'
1385
+                    ) ); ?>
1386 1386
 				</td>
1387 1387
 				<td class="wpinv_tax_global">
1388 1388
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
         <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1398 1398
 	</table>
1399 1399
 	<?php
1400
-	echo ob_get_clean();
1400
+    echo ob_get_clean();
1401 1401
 }
1402 1402
 
1403 1403
 function wpinv_tools_callback($args) {
@@ -1425,15 +1425,15 @@  discard block
 block discarded – undo
1425 1425
 }
1426 1426
 
1427 1427
 function wpinv_descriptive_text_callback( $args ) {
1428
-	echo wp_kses_post( $args['desc'] );
1428
+    echo wp_kses_post( $args['desc'] );
1429 1429
 }
1430 1430
 
1431 1431
 function wpinv_hook_callback( $args ) {
1432
-	do_action( 'wpinv_' . $args['id'], $args );
1432
+    do_action( 'wpinv_' . $args['id'], $args );
1433 1433
 }
1434 1434
 
1435 1435
 function wpinv_set_settings_cap() {
1436
-	return 'manage_options';
1436
+    return 'manage_options';
1437 1437
 }
1438 1438
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1439 1439
 
Please login to merge, or discard this patch.
Spacing   +509 added lines, -509 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_get_option( $key = '', $default = false ) {
7
+function wpinv_get_option($key = '', $default = false) {
8 8
     global $wpinv_options;
9 9
 
10
-    $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default;
11
-    $value = apply_filters( 'wpinv_get_option', $value, $key, $default );
10
+    $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default;
11
+    $value = apply_filters('wpinv_get_option', $value, $key, $default);
12 12
 
13
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
13
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
14 14
 }
15 15
 
16
-function wpinv_update_option( $key = '', $value = false ) {
16
+function wpinv_update_option($key = '', $value = false) {
17 17
     // If no key, exit
18
-    if ( empty( $key ) ) {
18
+    if (empty($key)) {
19 19
         return false;
20 20
     }
21 21
 
22
-    if ( empty( $value ) ) {
23
-        $remove_option = wpinv_delete_option( $key );
22
+    if (empty($value)) {
23
+        $remove_option = wpinv_delete_option($key);
24 24
         return $remove_option;
25 25
     }
26 26
 
27 27
     // First let's grab the current settings
28
-    $options = get_option( 'wpinv_settings' );
28
+    $options = get_option('wpinv_settings');
29 29
 
30 30
     // Let other plugin alter the value
31
-    $value = apply_filters( 'wpinv_update_option', $value, $key );
31
+    $value = apply_filters('wpinv_update_option', $value, $key);
32 32
 
33 33
     // Next let's try to update the value
34
-    $options[ $key ] = $value;
35
-    $did_update = update_option( 'wpinv_settings', $options );
34
+    $options[$key] = $value;
35
+    $did_update = update_option('wpinv_settings', $options);
36 36
 
37 37
     // If it's updated, let's update the global variable
38
-    if ( $did_update ) {
38
+    if ($did_update) {
39 39
         global $wpinv_options;
40
-        $wpinv_options[ $key ] = $value;
40
+        $wpinv_options[$key] = $value;
41 41
     }
42 42
 
43 43
     return $did_update;
44 44
 }
45 45
 
46
-function wpinv_delete_option( $key = '' ) {
46
+function wpinv_delete_option($key = '') {
47 47
     // If no key, exit
48
-    if ( empty( $key ) ) {
48
+    if (empty($key)) {
49 49
         return false;
50 50
     }
51 51
 
52 52
     // First let's grab the current settings
53
-    $options = get_option( 'wpinv_settings' );
53
+    $options = get_option('wpinv_settings');
54 54
 
55 55
     // Next let's try to update the value
56
-    if( isset( $options[ $key ] ) ) {
57
-        unset( $options[ $key ] );
56
+    if (isset($options[$key])) {
57
+        unset($options[$key]);
58 58
     }
59 59
 
60
-    $did_update = update_option( 'wpinv_settings', $options );
60
+    $did_update = update_option('wpinv_settings', $options);
61 61
 
62 62
     // If it updated, let's update the global variable
63
-    if ( $did_update ){
63
+    if ($did_update) {
64 64
         global $wpinv_options;
65 65
         $wpinv_options = $options;
66 66
     }
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_get_settings() {
72
-    $settings = get_option( 'wpinv_settings' );
72
+    $settings = get_option('wpinv_settings');
73 73
 
74
-    if ( empty( $settings ) ) {
74
+    if (empty($settings)) {
75 75
         // Update old settings with new single option
76
-        $general_settings   = is_array( get_option( 'wpinv_settings_general' ) )    ? get_option( 'wpinv_settings_general' )    : array();
77
-        $gateways_settings  = is_array( get_option( 'wpinv_settings_gateways' ) )   ? get_option( 'wpinv_settings_gateways' )   : array();
78
-        $email_settings     = is_array( get_option( 'wpinv_settings_emails' ) )     ? get_option( 'wpinv_settings_emails' )     : array();
79
-        $tax_settings       = is_array( get_option( 'wpinv_settings_taxes' ) )      ? get_option( 'wpinv_settings_taxes' )      : array();
80
-        $misc_settings      = is_array( get_option( 'wpinv_settings_misc' ) )       ? get_option( 'wpinv_settings_misc' )       : array();
81
-        $tool_settings      = is_array( get_option( 'wpinv_settings_tools' ) )      ? get_option( 'wpinv_settings_tools' )      : array();
76
+        $general_settings   = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array();
77
+        $gateways_settings  = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array();
78
+        $email_settings     = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array();
79
+        $tax_settings       = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array();
80
+        $misc_settings      = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array();
81
+        $tool_settings      = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array();
82 82
 
83
-        $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings );
83
+        $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings);
84 84
 
85
-        update_option( 'wpinv_settings', $settings );
85
+        update_option('wpinv_settings', $settings);
86 86
 
87 87
     }
88
-    return apply_filters( 'wpinv_get_settings', $settings );
88
+    return apply_filters('wpinv_get_settings', $settings);
89 89
 }
90 90
 
91 91
 function wpinv_register_settings() {
92
-    if ( false == get_option( 'wpinv_settings' ) ) {
93
-        add_option( 'wpinv_settings' );
92
+    if (false == get_option('wpinv_settings')) {
93
+        add_option('wpinv_settings');
94 94
     }
95 95
     
96 96
     $register_settings = wpinv_get_registered_settings();
97 97
     
98
-    foreach ( $register_settings as $tab => $sections ) {
99
-        foreach ( $sections as $section => $settings) {
98
+    foreach ($register_settings as $tab => $sections) {
99
+        foreach ($sections as $section => $settings) {
100 100
             // Check for backwards compatibility
101
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
102
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
101
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
102
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
103 103
                 $section = 'main';
104 104
                 $settings = $sections;
105 105
             }
@@ -111,42 +111,42 @@  discard block
 block discarded – undo
111 111
                 'wpinv_settings_' . $tab . '_' . $section
112 112
             );
113 113
 
114
-            foreach ( $settings as $option ) {
114
+            foreach ($settings as $option) {
115 115
                 // For backwards compatibility
116
-                if ( empty( $option['id'] ) ) {
116
+                if (empty($option['id'])) {
117 117
                     continue;
118 118
                 }
119 119
 
120
-                $name = isset( $option['name'] ) ? $option['name'] : '';
120
+                $name = isset($option['name']) ? $option['name'] : '';
121 121
 
122 122
                 add_settings_field(
123 123
                     'wpinv_settings[' . $option['id'] . ']',
124 124
                     $name,
125
-                    function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
125
+                    function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
126 126
                     'wpinv_settings_' . $tab . '_' . $section,
127 127
                     'wpinv_settings_' . $tab . '_' . $section,
128 128
                     array(
129 129
                         'section'     => $section,
130
-                        'id'          => isset( $option['id'] )          ? $option['id']          : null,
131
-                        'desc'        => ! empty( $option['desc'] )      ? $option['desc']        : '',
132
-                        'name'        => isset( $option['name'] )        ? $option['name']        : null,
133
-                        'size'        => isset( $option['size'] )        ? $option['size']        : null,
134
-                        'options'     => isset( $option['options'] )     ? $option['options']     : '',
135
-                        'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
136
-                        'std'         => isset( $option['std'] )         ? $option['std']         : '',
137
-                        'min'         => isset( $option['min'] )         ? $option['min']         : null,
138
-                        'max'         => isset( $option['max'] )         ? $option['max']         : null,
139
-                        'step'        => isset( $option['step'] )        ? $option['step']        : null,
140
-                        'chosen'      => isset( $option['chosen'] )      ? $option['chosen']      : null,
141
-                        'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
142
-                        'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
143
-                        'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
144
-                        'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
145
-                        'onchange'    => !empty( $option['onchange'] )   ? $option['onchange']    : '',
146
-                        'custom'      => !empty( $option['custom'] )     ? $option['custom']      : '',
147
-                        'class'       =>  !empty( $option['class'] )     ? $option['class']      : '',
148
-                        'cols'        => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
149
-                        'rows'        => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
130
+                        'id'          => isset($option['id']) ? $option['id'] : null,
131
+                        'desc'        => !empty($option['desc']) ? $option['desc'] : '',
132
+                        'name'        => isset($option['name']) ? $option['name'] : null,
133
+                        'size'        => isset($option['size']) ? $option['size'] : null,
134
+                        'options'     => isset($option['options']) ? $option['options'] : '',
135
+                        'selected'    => isset($option['selected']) ? $option['selected'] : null,
136
+                        'std'         => isset($option['std']) ? $option['std'] : '',
137
+                        'min'         => isset($option['min']) ? $option['min'] : null,
138
+                        'max'         => isset($option['max']) ? $option['max'] : null,
139
+                        'step'        => isset($option['step']) ? $option['step'] : null,
140
+                        'chosen'      => isset($option['chosen']) ? $option['chosen'] : null,
141
+                        'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
142
+                        'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
143
+                        'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
144
+                        'faux'        => isset($option['faux']) ? $option['faux'] : false,
145
+                        'onchange'    => !empty($option['onchange']) ? $option['onchange'] : '',
146
+                        'custom'      => !empty($option['custom']) ? $option['custom'] : '',
147
+                        'class'       =>  !empty($option['class']) ? $option['class'] : '',
148
+                        'cols'        => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
149
+                        'rows'        => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
150 150
                     )
151 151
                 );
152 152
             }
@@ -154,180 +154,180 @@  discard block
 block discarded – undo
154 154
     }
155 155
 
156 156
     // Creates our settings in the options table
157
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
157
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
158 158
 }
159
-add_action( 'admin_init', 'wpinv_register_settings' );
159
+add_action('admin_init', 'wpinv_register_settings');
160 160
 
161 161
 function wpinv_get_registered_settings() {
162
-    $pages = wpinv_get_pages( true );
162
+    $pages = wpinv_get_pages(true);
163 163
     
164 164
     $currencies = wpinv_get_currencies();
165 165
     
166 166
     $currency_code_options = array();
167
-    foreach ( $currencies as $code => $name ) {
168
-        $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
167
+    foreach ($currencies as $code => $name) {
168
+        $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
169 169
     }
170 170
     
171 171
     $due_payment_options       = array();
172
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
173
-    for ( $i = 1; $i <= 30; $i++ ) {
172
+    $due_payment_options[0]    = __('Now', 'invoicing');
173
+    for ($i = 1; $i <= 30; $i++) {
174 174
         $due_payment_options[$i] = $i;
175 175
     }
176 176
     
177 177
     $invoice_number_padd_options = array();
178
-    for ( $i = 0; $i <= 20; $i++ ) {
178
+    for ($i = 0; $i <= 20; $i++) {
179 179
         $invoice_number_padd_options[$i] = $i;
180 180
     }
181 181
     
182 182
     $currency_symbol = wpinv_currency_symbol();
183 183
     
184 184
     $last_number = '';
185
-    if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
186
-        $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number );
185
+    if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
186
+        $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number);
187 187
 
188
-        if ( !empty( $last_invoice_number ) ) {
189
-            $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
188
+        if (!empty($last_invoice_number)) {
189
+            $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
190 190
         }
191 191
     }
192 192
     
193 193
     $alert_wrapper_start = '<p style="color: #F00">';
194 194
     $alert_wrapper_close = '</p>';
195 195
     $wpinv_settings = array(
196
-        'general' => apply_filters( 'wpinv_settings_general',
196
+        'general' => apply_filters('wpinv_settings_general',
197 197
             array(
198 198
                 'main' => array(
199 199
                     'location_settings' => array(
200 200
                         'id'   => 'location_settings',
201
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
201
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
202 202
                         'desc' => '',
203 203
                         'type' => 'header',
204 204
                     ),
205 205
                     'default_country' => array(
206 206
                         'id'      => 'default_country',
207
-                        'name'    => __( 'Default Country', 'invoicing' ),
208
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
207
+                        'name'    => __('Default Country', 'invoicing'),
208
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
209 209
                         'type'    => 'select',
210 210
                         'options' => wpinv_get_country_list(),
211 211
                         'std'     => 'GB',
212 212
                         'chosen'  => true,
213
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
213
+                        'placeholder' => __('Select a country', 'invoicing'),
214 214
                     ),
215 215
                     'default_state' => array(
216 216
                         'id'      => 'default_state',
217
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
218
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
217
+                        'name'    => __('Default State / Province', 'invoicing'),
218
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
219 219
                         'type'    => 'country_states',
220
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
220
+                        'placeholder' => __('Select a state', 'invoicing'),
221 221
                     ),
222 222
                     'store_name' => array(
223 223
                         'id'   => 'store_name',
224
-                        'name' => __( 'Store Name', 'invoicing' ),
225
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
224
+                        'name' => __('Store Name', 'invoicing'),
225
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
226 226
                         'std'     => get_option('blogname'),
227 227
                         'type' => 'text',
228 228
                     ),
229 229
                     'logo' => array(
230 230
                         'id'   => 'logo',
231
-                        'name' => __( 'Logo URL', 'invoicing' ),
232
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
231
+                        'name' => __('Logo URL', 'invoicing'),
232
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
233 233
                         'type' => 'text',
234 234
                     ),
235 235
                     'store_address' => array(
236 236
                         'id'   => 'store_address',
237
-                        'name' => __( 'Store Address', 'invoicing' ),
238
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
237
+                        'name' => __('Store Address', 'invoicing'),
238
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
239 239
                         'type' => 'textarea',
240 240
                     ),
241 241
                     'page_settings' => array(
242 242
                         'id'   => 'page_settings',
243
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
243
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
244 244
                         'desc' => '',
245 245
                         'type' => 'header',
246 246
                     ),
247 247
                     'checkout_page' => array(
248 248
                         'id'          => 'checkout_page',
249
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
250
-                        'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
249
+                        'name'        => __('Checkout Page', 'invoicing'),
250
+                        'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
251 251
                         'type'        => 'select',
252 252
                         'options'     => $pages,
253 253
                         'chosen'      => true,
254
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
254
+                        'placeholder' => __('Select a page', 'invoicing'),
255 255
                     ),
256 256
                     'success_page' => array(
257 257
                         'id'          => 'success_page',
258
-                        'name'        => __( 'Success Page', 'invoicing' ),
259
-                        'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
258
+                        'name'        => __('Success Page', 'invoicing'),
259
+                        'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
260 260
                         'type'        => 'select',
261 261
                         'options'     => $pages,
262 262
                         'chosen'      => true,
263
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
263
+                        'placeholder' => __('Select a page', 'invoicing'),
264 264
                     ),
265 265
                     'failure_page' => array(
266 266
                         'id'          => 'failure_page',
267
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
268
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ),
267
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
268
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'),
269 269
                         'type'        => 'select',
270 270
                         'options'     => $pages,
271 271
                         'chosen'      => true,
272
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
272
+                        'placeholder' => __('Select a page', 'invoicing'),
273 273
                     ),
274 274
                     'invoice_history_page' => array(
275 275
                         'id'          => 'invoice_history_page',
276
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
277
-                        'desc'        => __( 'This page shows an invoice history for the current user', 'invoicing' ),
276
+                        'name'        => __('Invoice History Page', 'invoicing'),
277
+                        'desc'        => __('This page shows an invoice history for the current user', 'invoicing'),
278 278
                         'type'        => 'select',
279 279
                         'options'     => $pages,
280 280
                         'chosen'      => true,
281
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
281
+                        'placeholder' => __('Select a page', 'invoicing'),
282 282
                     )
283 283
                 ),
284 284
                 'currency_section' => array(
285 285
                     'currency_settings' => array(
286 286
                         'id'   => 'currency_settings',
287
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
287
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
288 288
                         'desc' => '',
289 289
                         'type' => 'header',
290 290
                     ),
291 291
                     'currency' => array(
292 292
                         'id'      => 'currency',
293
-                        'name'    => __( 'Currency', 'invoicing' ),
294
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
293
+                        'name'    => __('Currency', 'invoicing'),
294
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
295 295
                         'type'    => 'select',
296 296
                         'options' => $currency_code_options,
297 297
                         'chosen'  => true,
298 298
                     ),
299 299
                     'currency_position' => array(
300 300
                         'id'      => 'currency_position',
301
-                        'name'    => __( 'Currency Position', 'invoicing' ),
302
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
301
+                        'name'    => __('Currency Position', 'invoicing'),
302
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
303 303
                         'type'    => 'select',
304 304
                         'options'  => array(
305
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
306
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
307
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
308
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
305
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
306
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
307
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
308
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
309 309
                         )
310 310
                     ),
311 311
                     'thousands_separator' => array(
312 312
                         'id'   => 'thousands_separator',
313
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
314
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
313
+                        'name' => __('Thousands Separator', 'invoicing'),
314
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
315 315
                         'type' => 'text',
316 316
                         'size' => 'small',
317 317
                         'std'  => ',',
318 318
                     ),
319 319
                     'decimal_separator' => array(
320 320
                         'id'   => 'decimal_separator',
321
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
322
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
321
+                        'name' => __('Decimal Separator', 'invoicing'),
322
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
323 323
                         'type' => 'text',
324 324
                         'size' => 'small',
325 325
                         'std'  => '.',
326 326
                     ),
327 327
                     'decimals' => array(
328 328
                         'id'   => 'decimals',
329
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
330
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
329
+                        'name' => __('Number of Decimals', 'invoicing'),
330
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
331 331
                         'type' => 'number',
332 332
                         'size' => 'small',
333 333
                         'std'  => '2',
@@ -339,29 +339,29 @@  discard block
 block discarded – undo
339 339
                 'labels' => array(
340 340
                     'labels' => array(
341 341
                         'id'   => 'labels_settings',
342
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
342
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
343 343
                         'desc' => '',
344 344
                         'type' => 'header',
345 345
                     ),
346 346
                     'vat_name' => array(
347 347
                         'id' => 'vat_name',
348
-                        'name' => __( 'VAT Name', 'invoicing' ),
349
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
348
+                        'name' => __('VAT Name', 'invoicing'),
349
+                        'desc' => __('Enter the VAT name', 'invoicing'),
350 350
                         'type' => 'text',
351 351
                         'size' => 'regular',
352 352
                         'std' => 'VAT'
353 353
                     ),
354 354
                     'vat_invoice_notice_label' => array(
355 355
                         'id' => 'vat_invoice_notice_label',
356
-                        'name' => __( 'Invoice Notice Label', 'invoicing' ),
357
-                        'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
356
+                        'name' => __('Invoice Notice Label', 'invoicing'),
357
+                        'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
358 358
                         'type' => 'text',
359 359
                         'size' => 'regular',
360 360
                     ),
361 361
                     'vat_invoice_notice' => array(
362 362
                         'id' => 'vat_invoice_notice',
363
-                        'name' => __( 'Invoice notice', 'invoicing' ),
364
-                        'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
363
+                        'name' => __('Invoice notice', 'invoicing'),
364
+                        'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
365 365
                         'type' => 'text',
366 366
                         'size' => 'regular',
367 367
                     )
@@ -373,22 +373,22 @@  discard block
 block discarded – undo
373 373
                 'main' => array(
374 374
                     'gateway_settings' => array(
375 375
                         'id'   => 'api_header',
376
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
376
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
377 377
                         'desc' => '',
378 378
                         'type' => 'header',
379 379
                     ),
380 380
                     'gateways' => array(
381 381
                         'id'      => 'gateways',
382
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
383
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
382
+                        'name'    => __('Payment Gateways', 'invoicing'),
383
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
384 384
                         'type'    => 'gateways',
385 385
                         'std'     => array('manual'=>1),
386 386
                         'options' => wpinv_get_payment_gateways(),
387 387
                     ),
388 388
                     'default_gateway' => array(
389 389
                         'id'      => 'default_gateway',
390
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
391
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
390
+                        'name'    => __('Default Gateway', 'invoicing'),
391
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
392 392
                         'type'    => 'gateway_select',
393 393
                         'std'     => 'manual',
394 394
                         'options' => wpinv_get_payment_gateways(),
@@ -402,19 +402,19 @@  discard block
 block discarded – undo
402 402
                 'main' => array(
403 403
                     'tax_settings' => array(
404 404
                         'id'   => 'tax_settings',
405
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
405
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
406 406
                         'type' => 'header',
407 407
                     ),
408 408
                     'enable_taxes' => array(
409 409
                         'id'   => 'enable_taxes',
410
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
411
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
410
+                        'name' => __('Enable Taxes', 'invoicing'),
411
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
412 412
                         'type' => 'checkbox',
413 413
                     ),
414 414
                     'tax_rate' => array(
415 415
                         'id'   => 'tax_rate',
416
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
417
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
416
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
417
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
418 418
                         'type' => 'number',
419 419
                         'size' => 'small',
420 420
                         'min'  => '0',
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
                 'rates' => array(
427 427
                     'tax_rates' => array(
428 428
                         'id'   => 'tax_rates',
429
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
430
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
429
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
430
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
431 431
                         'type' => 'tax_rates',
432 432
                     ),
433 433
                 )
@@ -439,62 +439,62 @@  discard block
 block discarded – undo
439 439
                 'main' => array(
440 440
                     'email_settings_header' => array(
441 441
                         'id'   => 'email_settings_header',
442
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
442
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
443 443
                         'type' => 'header',
444 444
                     ),
445 445
                     'email_from_name' => array(
446 446
                         'id'   => 'email_from_name',
447
-                        'name' => __( 'From Name', 'invoicing' ),
448
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
449
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
447
+                        'name' => __('From Name', 'invoicing'),
448
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
449
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
450 450
                         'type' => 'text',
451 451
                     ),
452 452
                     'email_from' => array(
453 453
                         'id'   => 'email_from',
454
-                        'name' => __( 'From Email', 'invoicing' ),
455
-                        'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
456
-                        'std' => get_option( 'admin_email' ),
454
+                        'name' => __('From Email', 'invoicing'),
455
+                        'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
456
+                        'std' => get_option('admin_email'),
457 457
                         'type' => 'text',
458 458
                     ),
459 459
                     'overdue_settings_header' => array(
460 460
                         'id'   => 'overdue_settings_header',
461
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
461
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
462 462
                         'type' => 'header',
463 463
                     ),
464 464
                     'overdue_active' => array(
465 465
                         'id'   => 'overdue_active',
466
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
467
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
466
+                        'name' => __('Enable Due Date', 'invoicing'),
467
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
468 468
                         'type' => 'checkbox',
469 469
                         'std'  => false,
470 470
                     ),
471 471
                     'overdue_days' => array(
472 472
                         'id'          => 'overdue_days',
473
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
474
-                        'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
473
+                        'name'        => __('Default Due Date', 'invoicing'),
474
+                        'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
475 475
                         'type'        => 'select',
476 476
                         'options'     => $due_payment_options,
477 477
                         'chosen'      => true,
478 478
                         'std'         => 0,
479
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
479
+                        'placeholder' => __('Select a page', 'invoicing'),
480 480
                     ),
481 481
                     'email_template_header' => array(
482 482
                         'id'   => 'email_template_header',
483
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
483
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
484 484
                         'type' => 'header',
485 485
                     ),
486 486
                     'email_header_image' => array(
487 487
                         'id'   => 'email_header_image',
488
-                        'name' => __( 'Header Image', 'invoicing' ),
489
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
488
+                        'name' => __('Header Image', 'invoicing'),
489
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
490 490
                         'std' => '',
491 491
                         'type' => 'text',
492 492
                     ),
493 493
                     'email_footer_text' => array(
494 494
                         'id'   => 'email_footer_text',
495
-                        'name' => __( 'Footer Text', 'invoicing' ),
496
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
497
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
495
+                        'name' => __('Footer Text', 'invoicing'),
496
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
497
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
498 498
                         'type' => 'textarea',
499 499
                         'class' => 'regular-text',
500 500
                         'rows' => 2,
@@ -502,29 +502,29 @@  discard block
 block discarded – undo
502 502
                     ),
503 503
                     'email_base_color' => array(
504 504
                         'id'   => 'email_base_color',
505
-                        'name' => __( 'Base Color', 'invoicing' ),
506
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
505
+                        'name' => __('Base Color', 'invoicing'),
506
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
507 507
                         'std' => '#557da2',
508 508
                         'type' => 'color',
509 509
                     ),
510 510
                     'email_background_color' => array(
511 511
                         'id'   => 'email_background_color',
512
-                        'name' => __( 'Background Color', 'invoicing' ),
513
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
512
+                        'name' => __('Background Color', 'invoicing'),
513
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
514 514
                         'std' => '#f5f5f5',
515 515
                         'type' => 'color',
516 516
                     ),
517 517
                     'email_body_background_color' => array(
518 518
                         'id'   => 'email_body_background_color',
519
-                        'name' => __( 'Body Background Color', 'invoicing' ),
520
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
519
+                        'name' => __('Body Background Color', 'invoicing'),
520
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
521 521
                         'std' => '#fdfdfd',
522 522
                         'type' => 'color',
523 523
                     ),
524 524
                     'email_text_color' => array(
525 525
                         'id'   => 'email_text_color',
526
-                        'name' => __( 'Body Text Color', 'invoicing' ),
527
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
526
+                        'name' => __('Body Text Color', 'invoicing'),
527
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
528 528
                         'std' => '#505050',
529 529
                         'type' => 'color',
530 530
                     ),
@@ -543,19 +543,19 @@  discard block
 block discarded – undo
543 543
                 'main' => array(
544 544
                     'invoice_number_format_settings' => array(
545 545
                         'id'   => 'invoice_number_format_settings',
546
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
546
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
547 547
                         'type' => 'header',
548 548
                     ),
549 549
                     'sequential_invoice_number' => array(
550 550
                         'id'   => 'sequential_invoice_number',
551
-                        'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
552
-                        'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ),
551
+                        'name' => __('Sequential Invoice Numbers', 'invoicing'),
552
+                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'),
553 553
                         'type' => 'checkbox',
554 554
                     ),
555 555
                     'invoice_sequence_start' => array(
556 556
                         'id'   => 'invoice_sequence_start',
557
-                        'name' => __( 'Sequential Starting Number', 'invoicing' ),
558
-                        'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
557
+                        'name' => __('Sequential Starting Number', 'invoicing'),
558
+                        'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
559 559
                         'type' => 'number',
560 560
                         'size' => 'small',
561 561
                         'std'  => '1',
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
                     ),
564 564
                     'invoice_number_padd' => array(
565 565
                         'id'      => 'invoice_number_padd',
566
-                        'name'    => __( 'Minimum Digits', 'invoicing' ),
567
-                        'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
566
+                        'name'    => __('Minimum Digits', 'invoicing'),
567
+                        'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
568 568
                         'type'    => 'select',
569 569
                         'options' => $invoice_number_padd_options,
570 570
                         'std'     => 5,
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
                     ),
573 573
                     'invoice_number_prefix' => array(
574 574
                         'id' => 'invoice_number_prefix',
575
-                        'name' => __( 'Invoice Number Prefix', 'invoicing' ),
576
-                        'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ),
575
+                        'name' => __('Invoice Number Prefix', 'invoicing'),
576
+                        'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'),
577 577
                         'type' => 'text',
578 578
                         'size' => 'regular',
579 579
                         'std' => 'WPINV-',
@@ -581,32 +581,32 @@  discard block
 block discarded – undo
581 581
                     ),
582 582
                     'invoice_number_postfix' => array(
583 583
                         'id' => 'invoice_number_postfix',
584
-                        'name' => __( 'Invoice Number Postfix', 'invoicing' ),
585
-                        'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
584
+                        'name' => __('Invoice Number Postfix', 'invoicing'),
585
+                        'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
586 586
                         'type' => 'text',
587 587
                         'size' => 'regular',
588 588
                         'std' => ''
589 589
                     ),
590 590
                     'checkout_settings' => array(
591 591
                         'id'   => 'checkout_settings',
592
-                        'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
592
+                        'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
593 593
                         'type' => 'header',
594 594
                     ),
595 595
                     'login_to_checkout' => array(
596 596
                         'id'   => 'login_to_checkout',
597
-                        'name' => __( 'Require Login To Checkout', 'invoicing' ),
598
-                        'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
597
+                        'name' => __('Require Login To Checkout', 'invoicing'),
598
+                        'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
599 599
                         'type' => 'checkbox',
600 600
                     ),
601 601
                     'uninstall_settings' => array(
602 602
                         'id'   => 'uninstall_settings',
603
-                        'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
603
+                        'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
604 604
                         'type' => 'header',
605 605
                     ),
606 606
                     'remove_data_on_unistall' => array(
607 607
                         'id'   => 'remove_data_on_unistall',
608
-                        'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
609
-                        'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
608
+                        'name' => __('Remove Data on Uninstall?', 'invoicing'),
609
+                        'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
610 610
                         'type' => 'checkbox',
611 611
                         'std'  => ''
612 612
                     ),
@@ -614,74 +614,74 @@  discard block
 block discarded – undo
614 614
                 'fields' => array(
615 615
                     'fields_settings' => array(
616 616
                         'id'   => 'fields_settings',
617
-                        'name' => '<h3>' . __( 'Address Fields', 'invoicing' ) . '</h3>',
618
-                        'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ),
617
+                        'name' => '<h3>' . __('Address Fields', 'invoicing') . '</h3>',
618
+                        'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'),
619 619
                         'type' => 'header',
620 620
                     ),
621 621
                     'fname_mandatory' => array(
622 622
                         'id'   => 'fname_mandatory',
623
-                        'name' => __( 'First Name', 'invoicing' ),
623
+                        'name' => __('First Name', 'invoicing'),
624 624
                         'type' => 'checkbox',
625 625
                         'std'  => true,
626 626
                     ),
627 627
                     'lname_mandatory' => array(
628 628
                         'id'   => 'lname_mandatory',
629
-                        'name' => __( 'Last Name', 'invoicing' ),
629
+                        'name' => __('Last Name', 'invoicing'),
630 630
                         'type' => 'checkbox',
631 631
                         'std'  => true,
632 632
                     ),
633 633
                     'address_mandatory' => array(
634 634
                         'id'   => 'address_mandatory',
635
-                        'name' => __( 'Address', 'invoicing' ),
635
+                        'name' => __('Address', 'invoicing'),
636 636
                         'type' => 'checkbox',
637 637
                         'std'  => true,
638 638
                     ),
639 639
                     'city_mandatory' => array(
640 640
                         'id'   => 'city_mandatory',
641
-                        'name' => __( 'City', 'invoicing' ),
641
+                        'name' => __('City', 'invoicing'),
642 642
                         'type' => 'checkbox',
643 643
                         'std'  => true,
644 644
                     ),
645 645
                     'country_mandatory' => array(
646 646
                         'id'   => 'country_mandatory',
647
-                        'name' => __( 'Country', 'invoicing' ),
647
+                        'name' => __('Country', 'invoicing'),
648 648
                         'type' => 'checkbox',
649 649
                         'std'  => true,
650 650
                     ),
651 651
                     'state_mandatory' => array(
652 652
                         'id'   => 'state_mandatory',
653
-                        'name' => __( 'State / Province', 'invoicing' ),
653
+                        'name' => __('State / Province', 'invoicing'),
654 654
                         'type' => 'checkbox',
655 655
                         'std'  => true,
656 656
                     ),
657 657
                     'zip_mandatory' => array(
658 658
                         'id'   => 'zip_mandatory',
659
-                        'name' => __( 'ZIP / Postcode', 'invoicing' ),
659
+                        'name' => __('ZIP / Postcode', 'invoicing'),
660 660
                         'type' => 'checkbox',
661 661
                         'std'  => true,
662 662
                     ),
663 663
                     'phone_mandatory' => array(
664 664
                         'id'   => 'phone_mandatory',
665
-                        'name' => __( 'Phone Number', 'invoicing' ),
665
+                        'name' => __('Phone Number', 'invoicing'),
666 666
                         'type' => 'checkbox',
667 667
                         'std'  => true,
668 668
                     ),
669 669
                     'address_autofill_settings' => array(
670 670
                         'id'   => 'address_autofill_settings',
671
-                        'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>',
671
+                        'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>',
672 672
                         'type' => 'header',
673 673
                     ),
674 674
                     'address_autofill_active' => array(
675 675
                         'id'   => 'address_autofill_active',
676
-                        'name' => __( 'Enable/Disable', 'invoicing' ),
677
-                        'desc' => __( 'Enable google address auto complete', 'invoicing' ),
676
+                        'name' => __('Enable/Disable', 'invoicing'),
677
+                        'desc' => __('Enable google address auto complete', 'invoicing'),
678 678
                         'type' => 'checkbox',
679 679
                         'std'  => 0
680 680
                     ),
681 681
                     'address_autofill_api' => array(
682 682
                         'id' => 'address_autofill_api',
683
-                        'name' => __( 'Google Place API Key', 'invoicing' ),
684
-                        'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ),
683
+                        'name' => __('Google Place API Key', 'invoicing'),
684
+                        'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'),
685 685
                         'type' => 'text',
686 686
                         'size' => 'regular',
687 687
                         'std' => ''
@@ -695,8 +695,8 @@  discard block
 block discarded – undo
695 695
                 'main' => array(
696 696
                     'tool_settings' => array(
697 697
                         'id'   => 'tool_settings',
698
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
699
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
698
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
699
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
700 700
                         'type' => 'tools',
701 701
                     ),
702 702
                 ),
@@ -704,135 +704,135 @@  discard block
 block discarded – undo
704 704
         )
705 705
     );
706 706
 
707
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
707
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
708 708
 }
709 709
 
710
-function wpinv_settings_sanitize( $input = array() ) {
710
+function wpinv_settings_sanitize($input = array()) {
711 711
     global $wpinv_options;
712 712
 
713
-    if ( empty( $_POST['_wp_http_referer'] ) ) {
713
+    if (empty($_POST['_wp_http_referer'])) {
714 714
         return $input;
715 715
     }
716 716
 
717
-    parse_str( $_POST['_wp_http_referer'], $referrer );
717
+    parse_str($_POST['_wp_http_referer'], $referrer);
718 718
 
719 719
     $settings = wpinv_get_registered_settings();
720
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
721
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
720
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
721
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
722 722
 
723 723
     $input = $input ? $input : array();
724
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
725
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
724
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
725
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
726 726
 
727 727
     // Loop through each setting being saved and pass it through a sanitization filter
728
-    foreach ( $input as $key => $value ) {
728
+    foreach ($input as $key => $value) {
729 729
         // Get the setting type (checkbox, select, etc)
730
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
730
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
731 731
 
732
-        if ( $type ) {
732
+        if ($type) {
733 733
             // Field type specific filter
734
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
734
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
735 735
         }
736 736
 
737 737
         // General filter
738
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
738
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
739 739
     }
740 740
 
741 741
     // Loop through the whitelist and unset any that are empty for the tab being saved
742
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
743
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
742
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
743
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
744 744
 
745
-    $found_settings = array_merge( $main_settings, $section_settings );
745
+    $found_settings = array_merge($main_settings, $section_settings);
746 746
 
747
-    if ( ! empty( $found_settings ) ) {
748
-        foreach ( $found_settings as $key => $value ) {
747
+    if (!empty($found_settings)) {
748
+        foreach ($found_settings as $key => $value) {
749 749
 
750 750
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
751
-            if ( is_numeric( $key ) ) {
751
+            if (is_numeric($key)) {
752 752
                 $key = $value['id'];
753 753
             }
754 754
 
755
-            if ( empty( $input[ $key ] ) ) {
756
-                unset( $wpinv_options[ $key ] );
755
+            if (empty($input[$key])) {
756
+                unset($wpinv_options[$key]);
757 757
             }
758 758
         }
759 759
     }
760 760
 
761 761
     // Merge our new settings with the existing
762
-    $output = array_merge( $wpinv_options, $input );
762
+    $output = array_merge($wpinv_options, $input);
763 763
 
764
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
764
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
765 765
 
766 766
     return $output;
767 767
 }
768 768
 
769
-function wpinv_settings_sanitize_misc_accounting( $input ) {
769
+function wpinv_settings_sanitize_misc_accounting($input) {
770 770
     global $wpinv_options, $wpi_session;
771 771
 
772
-    if ( !current_user_can( 'manage_options' ) ) {
772
+    if (!current_user_can('manage_options')) {
773 773
         return $input;
774 774
     }
775 775
 
776
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
776
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
777 777
         // Shows an admin notice about upgrading previous order numbers
778
-        $wpi_session->set( 'upgrade_sequential', '1' );
778
+        $wpi_session->set('upgrade_sequential', '1');
779 779
     }
780 780
 
781 781
     return $input;
782 782
 }
783
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
783
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
784 784
 
785
-function wpinv_settings_sanitize_tax_rates( $input ) {
786
-    if( !current_user_can( 'manage_options' ) ) {
785
+function wpinv_settings_sanitize_tax_rates($input) {
786
+    if (!current_user_can('manage_options')) {
787 787
         return $input;
788 788
     }
789 789
 
790
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
790
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
791 791
 
792 792
     $tax_rates = array();
793 793
 
794
-    if ( !empty( $new_rates ) ) {
795
-        foreach ( $new_rates as $rate ) {
796
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
794
+    if (!empty($new_rates)) {
795
+        foreach ($new_rates as $rate) {
796
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
797 797
                 continue;
798 798
             }
799 799
             
800
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
800
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
801 801
             
802 802
             $tax_rates[] = $rate;
803 803
         }
804 804
     }
805 805
 
806
-    update_option( 'wpinv_tax_rates', $tax_rates );
806
+    update_option('wpinv_tax_rates', $tax_rates);
807 807
 
808 808
     return $input;
809 809
 }
810
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
810
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
811 811
 
812
-function wpinv_sanitize_text_field( $input ) {
813
-    return trim( $input );
812
+function wpinv_sanitize_text_field($input) {
813
+    return trim($input);
814 814
 }
815
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
815
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
816 816
 
817 817
 function wpinv_get_settings_tabs() {
818 818
     $tabs             = array();
819
-    $tabs['general']  = __( 'General', 'invoicing' );
820
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
821
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
822
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
823
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
824
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
825
-
826
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
819
+    $tabs['general']  = __('General', 'invoicing');
820
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
821
+    $tabs['taxes']    = __('Taxes', 'invoicing');
822
+    $tabs['emails']   = __('Emails', 'invoicing');
823
+    $tabs['misc']     = __('Misc', 'invoicing');
824
+    $tabs['tools']    = __('Tools', 'invoicing');
825
+
826
+    return apply_filters('wpinv_settings_tabs', $tabs);
827 827
 }
828 828
 
829
-function wpinv_get_settings_tab_sections( $tab = false ) {
829
+function wpinv_get_settings_tab_sections($tab = false) {
830 830
     $tabs     = false;
831 831
     $sections = wpinv_get_registered_settings_sections();
832 832
 
833
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
834
-        $tabs = $sections[ $tab ];
835
-    } else if ( $tab ) {
833
+    if ($tab && !empty($sections[$tab])) {
834
+        $tabs = $sections[$tab];
835
+    } else if ($tab) {
836 836
         $tabs = false;
837 837
     }
838 838
 
@@ -842,136 +842,136 @@  discard block
 block discarded – undo
842 842
 function wpinv_get_registered_settings_sections() {
843 843
     static $sections = false;
844 844
 
845
-    if ( false !== $sections ) {
845
+    if (false !== $sections) {
846 846
         return $sections;
847 847
     }
848 848
 
849 849
     $sections = array(
850
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
851
-            'main' => __( 'General Settings', 'invoicing' ),
852
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
853
-            'labels' => __( 'Label Texts', 'invoicing' ),
854
-        ) ),
855
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
856
-            'main' => __( 'Gateway Settings', 'invoicing' ),
857
-        ) ),
858
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
859
-            'main' => __( 'Tax Settings', 'invoicing' ),
860
-            'rates' => __( 'Tax Rates', 'invoicing' ),
861
-        ) ),
862
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
863
-            'main' => __( 'Email Settings', 'invoicing' ),
864
-        ) ),
865
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
866
-            'main' => __( 'Miscellaneous', 'invoicing' ),
867
-            'fields' => __( 'Fields Settings', 'invoicing' ),
868
-        ) ),
869
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
870
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
871
-        ) ),
850
+        'general' => apply_filters('wpinv_settings_sections_general', array(
851
+            'main' => __('General Settings', 'invoicing'),
852
+            'currency_section' => __('Currency Settings', 'invoicing'),
853
+            'labels' => __('Label Texts', 'invoicing'),
854
+        )),
855
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
856
+            'main' => __('Gateway Settings', 'invoicing'),
857
+        )),
858
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
859
+            'main' => __('Tax Settings', 'invoicing'),
860
+            'rates' => __('Tax Rates', 'invoicing'),
861
+        )),
862
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
863
+            'main' => __('Email Settings', 'invoicing'),
864
+        )),
865
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
866
+            'main' => __('Miscellaneous', 'invoicing'),
867
+            'fields' => __('Fields Settings', 'invoicing'),
868
+        )),
869
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
870
+            'main' => __('Diagnostic Tools', 'invoicing'),
871
+        )),
872 872
     );
873 873
 
874
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
874
+    $sections = apply_filters('wpinv_settings_sections', $sections);
875 875
 
876 876
     return $sections;
877 877
 }
878 878
 
879
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
879
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
880 880
 	$pages_options = array();
881 881
 
882
-	if( $default_label !== NULL && $default_label !== false ) {
883
-		$pages_options = array( '' => $default_label ); // Blank option
882
+	if ($default_label !== NULL && $default_label !== false) {
883
+		$pages_options = array('' => $default_label); // Blank option
884 884
 	}
885 885
 
886 886
 	$pages = get_pages();
887
-	if ( $pages ) {
888
-		foreach ( $pages as $page ) {
887
+	if ($pages) {
888
+		foreach ($pages as $page) {
889 889
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
890
-            $pages_options[ $page->ID ] = $title;
890
+            $pages_options[$page->ID] = $title;
891 891
 		}
892 892
 	}
893 893
 
894 894
 	return $pages_options;
895 895
 }
896 896
 
897
-function wpinv_header_callback( $args ) {
898
-	if ( !empty( $args['desc'] ) ) {
897
+function wpinv_header_callback($args) {
898
+	if (!empty($args['desc'])) {
899 899
         echo $args['desc'];
900 900
     }
901 901
 }
902 902
 
903
-function wpinv_hidden_callback( $args ) {
903
+function wpinv_hidden_callback($args) {
904 904
 	global $wpinv_options;
905 905
 
906
-	if ( isset( $args['set_value'] ) ) {
906
+	if (isset($args['set_value'])) {
907 907
 		$value = $args['set_value'];
908
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
909
-		$value = $wpinv_options[ $args['id'] ];
908
+	} elseif (isset($wpinv_options[$args['id']])) {
909
+		$value = $wpinv_options[$args['id']];
910 910
 	} else {
911
-		$value = isset( $args['std'] ) ? $args['std'] : '';
911
+		$value = isset($args['std']) ? $args['std'] : '';
912 912
 	}
913 913
 
914
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
914
+	if (isset($args['faux']) && true === $args['faux']) {
915 915
 		$args['readonly'] = true;
916
-		$value = isset( $args['std'] ) ? $args['std'] : '';
916
+		$value = isset($args['std']) ? $args['std'] : '';
917 917
 		$name  = '';
918 918
 	} else {
919
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
919
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
920 920
 	}
921 921
 
922
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
922
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
923 923
     
924 924
 	echo $html;
925 925
 }
926 926
 
927
-function wpinv_checkbox_callback( $args ) {
927
+function wpinv_checkbox_callback($args) {
928 928
 	global $wpinv_options;
929 929
     
930
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
930
+    $sanitize_id = wpinv_sanitize_key($args['id']);
931 931
 
932
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
932
+	if (isset($args['faux']) && true === $args['faux']) {
933 933
 		$name = '';
934 934
 	} else {
935 935
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
936 936
 	}
937 937
 
938
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
938
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
939 939
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
940
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
940
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
941 941
 
942 942
 	echo $html;
943 943
 }
944 944
 
945
-function wpinv_multicheck_callback( $args ) {
945
+function wpinv_multicheck_callback($args) {
946 946
 	global $wpinv_options;
947 947
 	
948
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
948
+	$sanitize_id = wpinv_sanitize_key($args['id']);
949 949
 	
950
-	if ( ! empty( $args['options'] ) ) {
951
-		foreach( $args['options'] as $key => $option ):
952
-			$sanitize_key = wpinv_sanitize_key( $key );
953
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
950
+	if (!empty($args['options'])) {
951
+		foreach ($args['options'] as $key => $option):
952
+			$sanitize_key = wpinv_sanitize_key($key);
953
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
954 954
 				$enabled = $sanitize_key;
955 955
 			} else { 
956 956
 				$enabled = NULL; 
957 957
 			}
958
-			echo '<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 ) . '/>&nbsp;';
959
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
958
+			echo '<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) . '/>&nbsp;';
959
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>';
960 960
 		endforeach;
961 961
 		echo '<p class="description">' . $args['desc'] . '</p>';
962 962
 	}
963 963
 }
964 964
 
965
-function wpinv_payment_icons_callback( $args ) {
965
+function wpinv_payment_icons_callback($args) {
966 966
 	global $wpinv_options;
967 967
     
968
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
968
+    $sanitize_id = wpinv_sanitize_key($args['id']);
969 969
 
970
-	if ( ! empty( $args['options'] ) ) {
971
-		foreach( $args['options'] as $key => $option ) {
972
-            $sanitize_key = wpinv_sanitize_key( $key );
970
+	if (!empty($args['options'])) {
971
+		foreach ($args['options'] as $key => $option) {
972
+            $sanitize_key = wpinv_sanitize_key($key);
973 973
             
974
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
974
+			if (isset($wpinv_options[$args['id']][$key])) {
975 975
 				$enabled = $option;
976 976
 			} else {
977 977
 				$enabled = NULL;
@@ -979,196 +979,196 @@  discard block
 block discarded – undo
979 979
 
980 980
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
981 981
 
982
-				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 ) . '/>&nbsp;';
982
+				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) . '/>&nbsp;';
983 983
 
984
-				if ( wpinv_string_is_image_url( $key ) ) {
985
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
984
+				if (wpinv_string_is_image_url($key)) {
985
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
986 986
 				} else {
987
-					$card = strtolower( str_replace( ' ', '', $option ) );
987
+					$card = strtolower(str_replace(' ', '', $option));
988 988
 
989
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
990
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
989
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
990
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
991 991
 					} else {
992
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
992
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
993 993
 						$content_dir = WP_CONTENT_DIR;
994 994
 
995
-						if ( function_exists( 'wp_normalize_path' ) ) {
995
+						if (function_exists('wp_normalize_path')) {
996 996
 							// Replaces backslashes with forward slashes for Windows systems
997
-							$image = wp_normalize_path( $image );
998
-							$content_dir = wp_normalize_path( $content_dir );
997
+							$image = wp_normalize_path($image);
998
+							$content_dir = wp_normalize_path($content_dir);
999 999
 						}
1000 1000
 
1001
-						$image = str_replace( $content_dir, content_url(), $image );
1001
+						$image = str_replace($content_dir, content_url(), $image);
1002 1002
 					}
1003 1003
 
1004
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1004
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1005 1005
 				}
1006 1006
 			echo $option . '</label>';
1007 1007
 		}
1008
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
1008
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
1009 1009
 	}
1010 1010
 }
1011 1011
 
1012
-function wpinv_radio_callback( $args ) {
1012
+function wpinv_radio_callback($args) {
1013 1013
 	global $wpinv_options;
1014 1014
     
1015
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1015
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1016 1016
     
1017
-    foreach ( $args['options'] as $key => $option ) :
1018
-		$sanitize_key = wpinv_sanitize_key( $key );
1017
+    foreach ($args['options'] as $key => $option) :
1018
+		$sanitize_key = wpinv_sanitize_key($key);
1019 1019
         
1020 1020
         $checked = false;
1021 1021
 
1022
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
1022
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
1023 1023
 			$checked = true;
1024
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
1024
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
1025 1025
 			$checked = true;
1026 1026
 
1027 1027
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
1028
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
1028
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
1029 1029
 	endforeach;
1030 1030
 
1031
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
1031
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
1032 1032
 }
1033 1033
 
1034
-function wpinv_gateways_callback( $args ) {
1034
+function wpinv_gateways_callback($args) {
1035 1035
 	global $wpinv_options;
1036 1036
     
1037
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1037
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1038 1038
 
1039
-	foreach ( $args['options'] as $key => $option ) :
1040
-		$sanitize_key = wpinv_sanitize_key( $key );
1039
+	foreach ($args['options'] as $key => $option) :
1040
+		$sanitize_key = wpinv_sanitize_key($key);
1041 1041
         
1042
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
1042
+        if (isset($wpinv_options['gateways'][$key]))
1043 1043
 			$enabled = '1';
1044 1044
 		else
1045 1045
 			$enabled = null;
1046 1046
 
1047
-		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) . '/>&nbsp;';
1048
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1047
+		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) . '/>&nbsp;';
1048
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
1049 1049
 	endforeach;
1050 1050
 }
1051 1051
 
1052 1052
 function wpinv_gateway_select_callback($args) {
1053 1053
 	global $wpinv_options;
1054 1054
     
1055
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1055
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1056 1056
 
1057 1057
 	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1058 1058
 
1059
-	foreach ( $args['options'] as $key => $option ) :
1060
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1061
-            $selected = selected( $key, $args['selected'], false );
1059
+	foreach ($args['options'] as $key => $option) :
1060
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1061
+            $selected = selected($key, $args['selected'], false);
1062 1062
         } else {
1063
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1063
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
1064 1064
         }
1065
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1065
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
1066 1066
 	endforeach;
1067 1067
 
1068 1068
 	echo '</select>';
1069
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1069
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1070 1070
 }
1071 1071
 
1072
-function wpinv_text_callback( $args ) {
1072
+function wpinv_text_callback($args) {
1073 1073
 	global $wpinv_options;
1074 1074
     
1075
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1075
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1076 1076
 
1077
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1078
-		$value = $wpinv_options[ $args['id'] ];
1077
+	if (isset($wpinv_options[$args['id']])) {
1078
+		$value = $wpinv_options[$args['id']];
1079 1079
 	} else {
1080
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1080
+		$value = isset($args['std']) ? $args['std'] : '';
1081 1081
 	}
1082 1082
 
1083
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1083
+	if (isset($args['faux']) && true === $args['faux']) {
1084 1084
 		$args['readonly'] = true;
1085
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1085
+		$value = isset($args['std']) ? $args['std'] : '';
1086 1086
 		$name  = '';
1087 1087
 	} else {
1088
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1088
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1089 1089
 	}
1090
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1090
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1091 1091
 
1092 1092
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1093
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1094
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1095
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1093
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1094
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
1095
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1096 1096
 
1097 1097
 	echo $html;
1098 1098
 }
1099 1099
 
1100
-function wpinv_number_callback( $args ) {
1100
+function wpinv_number_callback($args) {
1101 1101
 	global $wpinv_options;
1102 1102
     
1103
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1103
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1104 1104
 
1105
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1106
-		$value = $wpinv_options[ $args['id'] ];
1105
+	if (isset($wpinv_options[$args['id']])) {
1106
+		$value = $wpinv_options[$args['id']];
1107 1107
 	} else {
1108
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1108
+		$value = isset($args['std']) ? $args['std'] : '';
1109 1109
 	}
1110 1110
 
1111
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1111
+	if (isset($args['faux']) && true === $args['faux']) {
1112 1112
 		$args['readonly'] = true;
1113
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1113
+		$value = isset($args['std']) ? $args['std'] : '';
1114 1114
 		$name  = '';
1115 1115
 	} else {
1116
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1116
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1117 1117
 	}
1118 1118
 
1119
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1120
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1121
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1122
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1119
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1120
+	$min  = isset($args['min']) ? $args['min'] : 0;
1121
+	$step = isset($args['step']) ? $args['step'] : 1;
1122
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1123 1123
 
1124
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1125
-	$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 ) ) . '"/>';
1126
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1124
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1125
+	$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)) . '"/>';
1126
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1127 1127
 
1128 1128
 	echo $html;
1129 1129
 }
1130 1130
 
1131
-function wpinv_textarea_callback( $args ) {
1131
+function wpinv_textarea_callback($args) {
1132 1132
 	global $wpinv_options;
1133 1133
     
1134
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1134
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1135 1135
 
1136
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1137
-		$value = $wpinv_options[ $args['id'] ];
1136
+	if (isset($wpinv_options[$args['id']])) {
1137
+		$value = $wpinv_options[$args['id']];
1138 1138
 	} else {
1139
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1139
+		$value = isset($args['std']) ? $args['std'] : '';
1140 1140
 	}
1141 1141
     
1142
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1143
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1142
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1143
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1144 1144
 
1145
-	$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>';
1146
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1145
+	$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>';
1146
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1147 1147
 
1148 1148
 	echo $html;
1149 1149
 }
1150 1150
 
1151
-function wpinv_password_callback( $args ) {
1151
+function wpinv_password_callback($args) {
1152 1152
 	global $wpinv_options;
1153 1153
     
1154
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1154
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1155 1155
 
1156
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1157
-		$value = $wpinv_options[ $args['id'] ];
1156
+	if (isset($wpinv_options[$args['id']])) {
1157
+		$value = $wpinv_options[$args['id']];
1158 1158
 	} else {
1159
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1159
+		$value = isset($args['std']) ? $args['std'] : '';
1160 1160
 	}
1161 1161
 
1162
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1163
-	$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 ) . '"/>';
1164
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1162
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1163
+	$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) . '"/>';
1164
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1165 1165
 
1166 1166
 	echo $html;
1167 1167
 }
1168 1168
 
1169 1169
 function wpinv_missing_callback($args) {
1170 1170
 	printf(
1171
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1171
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1172 1172
 		'<strong>' . $args['id'] . '</strong>'
1173 1173
 	);
1174 1174
 }
@@ -1176,137 +1176,137 @@  discard block
 block discarded – undo
1176 1176
 function wpinv_select_callback($args) {
1177 1177
 	global $wpinv_options;
1178 1178
     
1179
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1179
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1180 1180
 
1181
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1182
-		$value = $wpinv_options[ $args['id'] ];
1181
+	if (isset($wpinv_options[$args['id']])) {
1182
+		$value = $wpinv_options[$args['id']];
1183 1183
 	} else {
1184
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1184
+		$value = isset($args['std']) ? $args['std'] : '';
1185 1185
 	}
1186 1186
     
1187
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1187
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1188 1188
         $value = $args['selected'];
1189 1189
     }
1190 1190
 
1191
-	if ( isset( $args['placeholder'] ) ) {
1191
+	if (isset($args['placeholder'])) {
1192 1192
 		$placeholder = $args['placeholder'];
1193 1193
 	} else {
1194 1194
 		$placeholder = '';
1195 1195
 	}
1196 1196
 
1197
-	if ( isset( $args['chosen'] ) ) {
1197
+	if (isset($args['chosen'])) {
1198 1198
 		$chosen = 'class="wpinv-chosen"';
1199 1199
 	} else {
1200 1200
 		$chosen = '';
1201 1201
 	}
1202 1202
     
1203
-    if( !empty( $args['onchange'] ) ) {
1204
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1203
+    if (!empty($args['onchange'])) {
1204
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1205 1205
     } else {
1206 1206
         $onchange = '';
1207 1207
     }
1208 1208
 
1209
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1209
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1210 1210
 
1211
-	foreach ( $args['options'] as $option => $name ) {
1212
-		$selected = selected( $option, $value, false );
1213
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1211
+	foreach ($args['options'] as $option => $name) {
1212
+		$selected = selected($option, $value, false);
1213
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1214 1214
 	}
1215 1215
 
1216 1216
 	$html .= '</select>';
1217
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1217
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1218 1218
 
1219 1219
 	echo $html;
1220 1220
 }
1221 1221
 
1222
-function wpinv_color_select_callback( $args ) {
1222
+function wpinv_color_select_callback($args) {
1223 1223
 	global $wpinv_options;
1224 1224
     
1225
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1225
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1226 1226
 
1227
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1228
-		$value = $wpinv_options[ $args['id'] ];
1227
+	if (isset($wpinv_options[$args['id']])) {
1228
+		$value = $wpinv_options[$args['id']];
1229 1229
 	} else {
1230
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1230
+		$value = isset($args['std']) ? $args['std'] : '';
1231 1231
 	}
1232 1232
 
1233
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1233
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1234 1234
 
1235
-	foreach ( $args['options'] as $option => $color ) {
1236
-		$selected = selected( $option, $value, false );
1237
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1235
+	foreach ($args['options'] as $option => $color) {
1236
+		$selected = selected($option, $value, false);
1237
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1238 1238
 	}
1239 1239
 
1240 1240
 	$html .= '</select>';
1241
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1241
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1242 1242
 
1243 1243
 	echo $html;
1244 1244
 }
1245 1245
 
1246
-function wpinv_rich_editor_callback( $args ) {
1246
+function wpinv_rich_editor_callback($args) {
1247 1247
 	global $wpinv_options, $wp_version;
1248 1248
     
1249
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1249
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1250 1250
 
1251
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1252
-		$value = $wpinv_options[ $args['id'] ];
1251
+	if (isset($wpinv_options[$args['id']])) {
1252
+		$value = $wpinv_options[$args['id']];
1253 1253
 
1254
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1255
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1254
+		if (empty($args['allow_blank']) && empty($value)) {
1255
+			$value = isset($args['std']) ? $args['std'] : '';
1256 1256
 		}
1257 1257
 	} else {
1258
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1258
+		$value = isset($args['std']) ? $args['std'] : '';
1259 1259
 	}
1260 1260
 
1261
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1261
+	$rows = isset($args['size']) ? $args['size'] : 20;
1262 1262
 
1263
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1263
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1264 1264
 		ob_start();
1265
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1265
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows)));
1266 1266
 		$html = ob_get_clean();
1267 1267
 	} else {
1268
-		$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>';
1268
+		$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>';
1269 1269
 	}
1270 1270
 
1271
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1271
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1272 1272
 
1273 1273
 	echo $html;
1274 1274
 }
1275 1275
 
1276
-function wpinv_upload_callback( $args ) {
1276
+function wpinv_upload_callback($args) {
1277 1277
 	global $wpinv_options;
1278 1278
     
1279
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1279
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1280 1280
 
1281
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1281
+	if (isset($wpinv_options[$args['id']])) {
1282 1282
 		$value = $wpinv_options[$args['id']];
1283 1283
 	} else {
1284 1284
 		$value = isset($args['std']) ? $args['std'] : '';
1285 1285
 	}
1286 1286
 
1287
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1288
-	$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 ) ) . '"/>';
1289
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1290
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1287
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1288
+	$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)) . '"/>';
1289
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1290
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1291 1291
 
1292 1292
 	echo $html;
1293 1293
 }
1294 1294
 
1295
-function wpinv_color_callback( $args ) {
1295
+function wpinv_color_callback($args) {
1296 1296
 	global $wpinv_options;
1297 1297
     
1298
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1298
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1299 1299
 
1300
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1301
-		$value = $wpinv_options[ $args['id'] ];
1300
+	if (isset($wpinv_options[$args['id']])) {
1301
+		$value = $wpinv_options[$args['id']];
1302 1302
 	} else {
1303
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1303
+		$value = isset($args['std']) ? $args['std'] : '';
1304 1304
 	}
1305 1305
 
1306
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1306
+	$default = isset($args['std']) ? $args['std'] : '';
1307 1307
 
1308
-	$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 ) . '" />';
1309
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1308
+	$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) . '" />';
1309
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1310 1310
 
1311 1311
 	echo $html;
1312 1312
 }
@@ -1314,9 +1314,9 @@  discard block
 block discarded – undo
1314 1314
 function wpinv_country_states_callback($args) {
1315 1315
 	global $wpinv_options;
1316 1316
     
1317
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1317
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1318 1318
 
1319
-	if ( isset( $args['placeholder'] ) ) {
1319
+	if (isset($args['placeholder'])) {
1320 1320
 		$placeholder = $args['placeholder'];
1321 1321
 	} else {
1322 1322
 		$placeholder = '';
@@ -1324,17 +1324,17 @@  discard block
 block discarded – undo
1324 1324
 
1325 1325
 	$states = wpinv_get_country_states();
1326 1326
 
1327
-	$chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1328
-	$class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1329
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1327
+	$chosen = ($args['chosen'] ? ' wpinv-chosen' : '');
1328
+	$class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1329
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1330 1330
 
1331
-	foreach ( $states as $option => $name ) {
1332
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1333
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1331
+	foreach ($states as $option => $name) {
1332
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1333
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1334 1334
 	}
1335 1335
 
1336 1336
 	$html .= '</select>';
1337
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1337
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1338 1338
 
1339 1339
 	echo $html;
1340 1340
 }
@@ -1349,25 +1349,25 @@  discard block
 block discarded – undo
1349 1349
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1350 1350
 		<thead>
1351 1351
 			<tr>
1352
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1353
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1354
-                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
1355
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1356
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1357
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1352
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1353
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1354
+                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
1355
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1356
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1357
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1358 1358
 			</tr>
1359 1359
 		</thead>
1360 1360
         <tbody>
1361
-		<?php if( !empty( $rates ) ) : ?>
1362
-			<?php foreach( $rates as $key => $rate ) : ?>
1361
+		<?php if (!empty($rates)) : ?>
1362
+			<?php foreach ($rates as $key => $rate) : ?>
1363 1363
             <?php 
1364
-            $sanitized_key = wpinv_sanitize_key( $key );
1364
+            $sanitized_key = wpinv_sanitize_key($key);
1365 1365
             ?>
1366 1366
 			<tr>
1367 1367
 				<td class="wpinv_tax_country">
1368 1368
 					<?php
1369
-					echo wpinv_html_select( array(
1370
-						'options'          => wpinv_get_country_list( true ),
1369
+					echo wpinv_html_select(array(
1370
+						'options'          => wpinv_get_country_list(true),
1371 1371
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1372 1372
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1373 1373
 						'selected'         => $rate['country'],
@@ -1375,72 +1375,72 @@  discard block
 block discarded – undo
1375 1375
 						'show_option_none' => false,
1376 1376
 						'class'            => 'wpinv-tax-country',
1377 1377
 						'chosen'           => false,
1378
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1379
-					) );
1378
+						'placeholder'      => __('Choose a country', 'invoicing')
1379
+					));
1380 1380
 					?>
1381 1381
 				</td>
1382 1382
 				<td class="wpinv_tax_state">
1383 1383
 					<?php
1384
-					$states = wpinv_get_country_states( $rate['country'] );
1385
-					if( !empty( $states ) ) {
1386
-						echo wpinv_html_select( array(
1387
-							'options'          => array_merge( array( '' => '' ), $states ),
1384
+					$states = wpinv_get_country_states($rate['country']);
1385
+					if (!empty($states)) {
1386
+						echo wpinv_html_select(array(
1387
+							'options'          => array_merge(array('' => ''), $states),
1388 1388
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1389 1389
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1390 1390
 							'selected'         => $rate['state'],
1391 1391
 							'show_option_all'  => false,
1392 1392
 							'show_option_none' => false,
1393 1393
 							'chosen'           => false,
1394
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1395
-						) );
1394
+							'placeholder'      => __('Choose a state', 'invoicing')
1395
+						));
1396 1396
 					} else {
1397
-						echo wpinv_html_text( array(
1397
+						echo wpinv_html_text(array(
1398 1398
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1399
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1399
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1400 1400
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1401
-						) );
1401
+						));
1402 1402
 					}
1403 1403
 					?>
1404 1404
 				</td>
1405 1405
 				<td class="wpinv_tax_global">
1406
-					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
1407
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1406
+					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/>
1407
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1408 1408
 				</td>
1409
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
1410
-                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td>
1411
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1409
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td>
1410
+                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td>
1411
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1412 1412
 			</tr>
1413 1413
 			<?php endforeach; ?>
1414 1414
 		<?php else : ?>
1415 1415
 			<tr>
1416 1416
 				<td class="wpinv_tax_country">
1417 1417
 					<?php
1418
-					echo wpinv_html_select( array(
1419
-						'options'          => wpinv_get_country_list( true ),
1418
+					echo wpinv_html_select(array(
1419
+						'options'          => wpinv_get_country_list(true),
1420 1420
 						'name'             => 'tax_rates[0][country]',
1421 1421
 						'show_option_all'  => false,
1422 1422
 						'show_option_none' => false,
1423 1423
 						'class'            => 'wpinv-tax-country',
1424 1424
 						'chosen'           => false,
1425
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1426
-					) ); ?>
1425
+						'placeholder'      => __('Choose a country', 'invoicing')
1426
+					)); ?>
1427 1427
 				</td>
1428 1428
 				<td class="wpinv_tax_state">
1429
-					<?php echo wpinv_html_text( array(
1429
+					<?php echo wpinv_html_text(array(
1430 1430
 						'name' => 'tax_rates[0][state]'
1431
-					) ); ?>
1431
+					)); ?>
1432 1432
 				</td>
1433 1433
 				<td class="wpinv_tax_global">
1434 1434
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1435
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1435
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1436 1436
 				</td>
1437
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td>
1437
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td>
1438 1438
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1439
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1439
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1440 1440
 			</tr>
1441 1441
 		<?php endif; ?>
1442 1442
         </tbody>
1443
-        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1443
+        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot>
1444 1444
 	</table>
1445 1445
 	<?php
1446 1446
 	echo ob_get_clean();
@@ -1451,54 +1451,54 @@  discard block
 block discarded – undo
1451 1451
     ob_start(); ?>
1452 1452
     </td><tr>
1453 1453
     <td colspan="2" class="wpinv_tools_tdbox">
1454
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1455
-    <?php do_action( 'wpinv_tools_before' ); ?>
1454
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1455
+    <?php do_action('wpinv_tools_before'); ?>
1456 1456
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1457 1457
         <thead>
1458 1458
             <tr>
1459
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1460
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1461
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1459
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1460
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1461
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1462 1462
             </tr>
1463 1463
         </thead>
1464
-            <?php do_action( 'wpinv_tools_row' ); ?>
1464
+            <?php do_action('wpinv_tools_row'); ?>
1465 1465
         <tbody>
1466 1466
         </tbody>
1467 1467
     </table>
1468
-    <?php do_action( 'wpinv_tools_after' ); ?>
1468
+    <?php do_action('wpinv_tools_after'); ?>
1469 1469
     <?php
1470 1470
     echo ob_get_clean();
1471 1471
 }
1472 1472
 
1473
-function wpinv_descriptive_text_callback( $args ) {
1474
-	echo wp_kses_post( $args['desc'] );
1473
+function wpinv_descriptive_text_callback($args) {
1474
+	echo wp_kses_post($args['desc']);
1475 1475
 }
1476 1476
 
1477
-function wpinv_hook_callback( $args ) {
1478
-	do_action( 'wpinv_' . $args['id'], $args );
1477
+function wpinv_hook_callback($args) {
1478
+	do_action('wpinv_' . $args['id'], $args);
1479 1479
 }
1480 1480
 
1481 1481
 function wpinv_set_settings_cap() {
1482 1482
 	return 'manage_options';
1483 1483
 }
1484
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1484
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1485 1485
 
1486
-function wpinv_settings_sanitize_input( $value, $key ) {
1487
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1488
-        $value = wpinv_sanitize_amount( $value, 4 );
1486
+function wpinv_settings_sanitize_input($value, $key) {
1487
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1488
+        $value = wpinv_sanitize_amount($value, 4);
1489 1489
         $value = $value >= 100 ? 99 : $value;
1490 1490
     }
1491 1491
         
1492 1492
     return $value;
1493 1493
 }
1494
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1494
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1495 1495
 
1496
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1497
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1498
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1496
+function wpinv_on_update_settings($old_value, $value, $option) {
1497
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1498
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1499 1499
     
1500
-    if ( $old != $new ) {
1501
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1500
+    if ($old != $new) {
1501
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1502 1502
     }
1503 1503
 }
1504
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1505 1504
\ No newline at end of file
1505
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1506 1506
\ No newline at end of file
Please login to merge, or discard this patch.