Passed
Pull Request — master (#97)
by Kiran
04:00
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   +503 added lines, -503 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,21 +154,21 @@  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
     $due_payment_options       = array();
165
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
166
-    for ( $i = 1; $i <= 30; $i++ ) {
165
+    $due_payment_options[0]    = __('Now', 'invoicing');
166
+    for ($i = 1; $i <= 30; $i++) {
167 167
         $due_payment_options[$i] = $i;
168 168
     }
169 169
     
170 170
     $invoice_number_padd_options = array();
171
-    for ( $i = 0; $i <= 20; $i++ ) {
171
+    for ($i = 0; $i <= 20; $i++) {
172 172
         $invoice_number_padd_options[$i] = $i;
173 173
     }
174 174
     
@@ -177,141 +177,141 @@  discard block
 block discarded – undo
177 177
     $alert_wrapper_start = '<p style="color: #F00">';
178 178
     $alert_wrapper_close = '</p>';
179 179
     $wpinv_settings = array(
180
-        'general' => apply_filters( 'wpinv_settings_general',
180
+        'general' => apply_filters('wpinv_settings_general',
181 181
             array(
182 182
                 'main' => array(
183 183
                     'location_settings' => array(
184 184
                         'id'   => 'location_settings',
185
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
185
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
186 186
                         'desc' => '',
187 187
                         'type' => 'header',
188 188
                     ),
189 189
                     'default_country' => array(
190 190
                         'id'      => 'default_country',
191
-                        'name'    => __( 'Default Country', 'invoicing' ),
192
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
191
+                        'name'    => __('Default Country', 'invoicing'),
192
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
193 193
                         'type'    => 'select',
194 194
                         'options' => wpinv_get_country_list(),
195 195
                         'std'     => 'GB',
196 196
                         'chosen'  => true,
197
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
197
+                        'placeholder' => __('Select a country', 'invoicing'),
198 198
                     ),
199 199
                     'default_state' => array(
200 200
                         'id'      => 'default_state',
201
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
202
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
201
+                        'name'    => __('Default State / Province', 'invoicing'),
202
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
203 203
                         'type'    => 'country_states',
204
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
204
+                        'placeholder' => __('Select a state', 'invoicing'),
205 205
                     ),
206 206
                     'store_name' => array(
207 207
                         'id'   => 'store_name',
208
-                        'name' => __( 'Store Name', 'invoicing' ),
209
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
208
+                        'name' => __('Store Name', 'invoicing'),
209
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
210 210
                         'std'     => get_option('blogname'),
211 211
                         'type' => 'text',
212 212
                     ),
213 213
                     'logo' => array(
214 214
                         'id'   => 'logo',
215
-                        'name' => __( 'Logo URL', 'invoicing' ),
216
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
215
+                        'name' => __('Logo URL', 'invoicing'),
216
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
217 217
                         'type' => 'text',
218 218
                     ),
219 219
                     'store_address' => array(
220 220
                         'id'   => 'store_address',
221
-                        'name' => __( 'Store Address', 'invoicing' ),
222
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
221
+                        'name' => __('Store Address', 'invoicing'),
222
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
223 223
                         'type' => 'textarea',
224 224
                     ),
225 225
                     'page_settings' => array(
226 226
                         'id'   => 'page_settings',
227
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
227
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
228 228
                         'desc' => '',
229 229
                         'type' => 'header',
230 230
                     ),
231 231
                     'checkout_page' => array(
232 232
                         'id'          => 'checkout_page',
233
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
234
-                        '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' ),
233
+                        'name'        => __('Checkout Page', 'invoicing'),
234
+                        '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'),
235 235
                         'type'        => 'select',
236 236
                         'options'     => $pages,
237 237
                         'chosen'      => true,
238
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
238
+                        'placeholder' => __('Select a page', 'invoicing'),
239 239
                     ),
240 240
                     'success_page' => array(
241 241
                         'id'          => 'success_page',
242
-                        'name'        => __( 'Success Page', 'invoicing' ),
243
-                        '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' ),
242
+                        'name'        => __('Success Page', 'invoicing'),
243
+                        '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'),
244 244
                         'type'        => 'select',
245 245
                         'options'     => $pages,
246 246
                         'chosen'      => true,
247
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
247
+                        'placeholder' => __('Select a page', 'invoicing'),
248 248
                     ),
249 249
                     'failure_page' => array(
250 250
                         'id'          => 'failure_page',
251
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
252
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ),
251
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
252
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'),
253 253
                         'type'        => 'select',
254 254
                         'options'     => $pages,
255 255
                         'chosen'      => true,
256
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
256
+                        'placeholder' => __('Select a page', 'invoicing'),
257 257
                     ),
258 258
                     'invoice_history_page' => array(
259 259
                         'id'          => 'invoice_history_page',
260
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
261
-                        'desc'        => __( 'This page shows an invoice history for the current user', 'invoicing' ),
260
+                        'name'        => __('Invoice History Page', 'invoicing'),
261
+                        'desc'        => __('This page shows an invoice history for the current user', 'invoicing'),
262 262
                         'type'        => 'select',
263 263
                         'options'     => $pages,
264 264
                         'chosen'      => true,
265
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
265
+                        'placeholder' => __('Select a page', 'invoicing'),
266 266
                     )
267 267
                 ),
268 268
                 'currency_section' => array(
269 269
                     'currency_settings' => array(
270 270
                         'id'   => 'currency_settings',
271
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
271
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
272 272
                         'desc' => '',
273 273
                         'type' => 'header',
274 274
                     ),
275 275
                     'currency' => array(
276 276
                         'id'      => 'currency',
277
-                        'name'    => __( 'Currency', 'invoicing' ),
278
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
277
+                        'name'    => __('Currency', 'invoicing'),
278
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
279 279
                         'type'    => 'select',
280 280
                         'options' => wpinv_get_currencies(),
281 281
                         'chosen'  => true,
282 282
                     ),
283 283
                     'currency_position' => array(
284 284
                         'id'      => 'currency_position',
285
-                        'name'    => __( 'Currency Position', 'invoicing' ),
286
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
285
+                        'name'    => __('Currency Position', 'invoicing'),
286
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
287 287
                         'type'    => 'select',
288 288
                         'options'  => array(
289
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
290
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
291
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
292
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
289
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
290
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
291
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
292
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
293 293
                         )
294 294
                     ),
295 295
                     'thousands_separator' => array(
296 296
                         'id'   => 'thousands_separator',
297
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
298
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
297
+                        'name' => __('Thousands Separator', 'invoicing'),
298
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
299 299
                         'type' => 'text',
300 300
                         'size' => 'small',
301 301
                         'std'  => ',',
302 302
                     ),
303 303
                     'decimal_separator' => array(
304 304
                         'id'   => 'decimal_separator',
305
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
306
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
305
+                        'name' => __('Decimal Separator', 'invoicing'),
306
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
307 307
                         'type' => 'text',
308 308
                         'size' => 'small',
309 309
                         'std'  => '.',
310 310
                     ),
311 311
                     'decimals' => array(
312 312
                         'id'   => 'decimals',
313
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
314
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
313
+                        'name' => __('Number of Decimals', 'invoicing'),
314
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
315 315
                         'type' => 'number',
316 316
                         'size' => 'small',
317 317
                         'std'  => '2',
@@ -323,29 +323,29 @@  discard block
 block discarded – undo
323 323
                 'labels' => array(
324 324
                     'labels' => array(
325 325
                         'id'   => 'labels_settings',
326
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
326
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
327 327
                         'desc' => '',
328 328
                         'type' => 'header',
329 329
                     ),
330 330
                     'vat_name' => array(
331 331
                         'id' => 'vat_name',
332
-                        'name' => __( 'VAT Name', 'invoicing' ),
333
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
332
+                        'name' => __('VAT Name', 'invoicing'),
333
+                        'desc' => __('Enter the VAT name', 'invoicing'),
334 334
                         'type' => 'text',
335 335
                         'size' => 'regular',
336 336
                         'std' => 'VAT'
337 337
                     ),
338 338
                     'vat_invoice_notice_label' => array(
339 339
                         'id' => 'vat_invoice_notice_label',
340
-                        'name' => __( 'Invoice Notice Label', 'invoicing' ),
341
-                        'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
340
+                        'name' => __('Invoice Notice Label', 'invoicing'),
341
+                        'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
342 342
                         'type' => 'text',
343 343
                         'size' => 'regular',
344 344
                     ),
345 345
                     'vat_invoice_notice' => array(
346 346
                         'id' => 'vat_invoice_notice',
347
-                        'name' => __( 'Invoice notice', 'invoicing' ),
348
-                        'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
347
+                        'name' => __('Invoice notice', 'invoicing'),
348
+                        'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
349 349
                         'type' => 'text',
350 350
                         'size' => 'regular',
351 351
                     )
@@ -357,22 +357,22 @@  discard block
 block discarded – undo
357 357
                 'main' => array(
358 358
                     'gateway_settings' => array(
359 359
                         'id'   => 'api_header',
360
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
360
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
361 361
                         'desc' => '',
362 362
                         'type' => 'header',
363 363
                     ),
364 364
                     'gateways' => array(
365 365
                         'id'      => 'gateways',
366
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
367
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
366
+                        'name'    => __('Payment Gateways', 'invoicing'),
367
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
368 368
                         'type'    => 'gateways',
369 369
                         'std'     => array('manual'=>1),
370 370
                         'options' => wpinv_get_payment_gateways(),
371 371
                     ),
372 372
                     'default_gateway' => array(
373 373
                         'id'      => 'default_gateway',
374
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
375
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
374
+                        'name'    => __('Default Gateway', 'invoicing'),
375
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
376 376
                         'type'    => 'gateway_select',
377 377
                         'std'     => 'manual',
378 378
                         'options' => wpinv_get_payment_gateways(),
@@ -386,19 +386,19 @@  discard block
 block discarded – undo
386 386
                 'main' => array(
387 387
                     'tax_settings' => array(
388 388
                         'id'   => 'tax_settings',
389
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
389
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
390 390
                         'type' => 'header',
391 391
                     ),
392 392
                     'enable_taxes' => array(
393 393
                         'id'   => 'enable_taxes',
394
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
395
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
394
+                        'name' => __('Enable Taxes', 'invoicing'),
395
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
396 396
                         'type' => 'checkbox',
397 397
                     ),
398 398
                     'tax_rate' => array(
399 399
                         'id'   => 'tax_rate',
400
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
401
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
400
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
401
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
402 402
                         'type' => 'number',
403 403
                         'size' => 'small',
404 404
                         'min'  => '0',
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
                 'rates' => array(
411 411
                     'tax_rates' => array(
412 412
                         'id'   => 'tax_rates',
413
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
414
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
413
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
414
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
415 415
                         'type' => 'tax_rates',
416 416
                     ),
417 417
                 )
@@ -423,62 +423,62 @@  discard block
 block discarded – undo
423 423
                 'main' => array(
424 424
                     'email_settings_header' => array(
425 425
                         'id'   => 'email_settings_header',
426
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
426
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
427 427
                         'type' => 'header',
428 428
                     ),
429 429
                     'email_from_name' => array(
430 430
                         'id'   => 'email_from_name',
431
-                        'name' => __( 'From Name', 'invoicing' ),
432
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
433
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
431
+                        'name' => __('From Name', 'invoicing'),
432
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
433
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
434 434
                         'type' => 'text',
435 435
                     ),
436 436
                     'email_from' => array(
437 437
                         'id'   => 'email_from',
438
-                        'name' => __( 'From Email', 'invoicing' ),
439
-                        '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),
440
-                        'std' => get_option( 'admin_email' ),
438
+                        'name' => __('From Email', 'invoicing'),
439
+                        '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),
440
+                        'std' => get_option('admin_email'),
441 441
                         'type' => 'text',
442 442
                     ),
443 443
                     'overdue_settings_header' => array(
444 444
                         'id'   => 'overdue_settings_header',
445
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
445
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
446 446
                         'type' => 'header',
447 447
                     ),
448 448
                     'overdue_active' => array(
449 449
                         'id'   => 'overdue_active',
450
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
451
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
450
+                        'name' => __('Enable Due Date', 'invoicing'),
451
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
452 452
                         'type' => 'checkbox',
453 453
                         'std'  => false,
454 454
                     ),
455 455
                     'overdue_days' => array(
456 456
                         'id'          => 'overdue_days',
457
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
458
-                        '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' ),
457
+                        'name'        => __('Default Due Date', 'invoicing'),
458
+                        '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'),
459 459
                         'type'        => 'select',
460 460
                         'options'     => $due_payment_options,
461 461
                         'chosen'      => true,
462 462
                         'std'         => 0,
463
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
463
+                        'placeholder' => __('Select a page', 'invoicing'),
464 464
                     ),
465 465
                     'email_template_header' => array(
466 466
                         'id'   => 'email_template_header',
467
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
467
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
468 468
                         'type' => 'header',
469 469
                     ),
470 470
                     'email_header_image' => array(
471 471
                         'id'   => 'email_header_image',
472
-                        'name' => __( 'Header Image', 'invoicing' ),
473
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
472
+                        'name' => __('Header Image', 'invoicing'),
473
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
474 474
                         'std' => '',
475 475
                         'type' => 'text',
476 476
                     ),
477 477
                     'email_footer_text' => array(
478 478
                         'id'   => 'email_footer_text',
479
-                        'name' => __( 'Footer Text', 'invoicing' ),
480
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
481
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
479
+                        'name' => __('Footer Text', 'invoicing'),
480
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
481
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
482 482
                         'type' => 'textarea',
483 483
                         'class' => 'regular-text',
484 484
                         'rows' => 2,
@@ -486,29 +486,29 @@  discard block
 block discarded – undo
486 486
                     ),
487 487
                     'email_base_color' => array(
488 488
                         'id'   => 'email_base_color',
489
-                        'name' => __( 'Base Color', 'invoicing' ),
490
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
489
+                        'name' => __('Base Color', 'invoicing'),
490
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
491 491
                         'std' => '#557da2',
492 492
                         'type' => 'color',
493 493
                     ),
494 494
                     'email_background_color' => array(
495 495
                         'id'   => 'email_background_color',
496
-                        'name' => __( 'Background Color', 'invoicing' ),
497
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
496
+                        'name' => __('Background Color', 'invoicing'),
497
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
498 498
                         'std' => '#f5f5f5',
499 499
                         'type' => 'color',
500 500
                     ),
501 501
                     'email_body_background_color' => array(
502 502
                         'id'   => 'email_body_background_color',
503
-                        'name' => __( 'Body Background Color', 'invoicing' ),
504
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
503
+                        'name' => __('Body Background Color', 'invoicing'),
504
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
505 505
                         'std' => '#fdfdfd',
506 506
                         'type' => 'color',
507 507
                     ),
508 508
                     'email_text_color' => array(
509 509
                         'id'   => 'email_text_color',
510
-                        'name' => __( 'Body Text Color', 'invoicing' ),
511
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
510
+                        'name' => __('Body Text Color', 'invoicing'),
511
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
512 512
                         'std' => '#505050',
513 513
                         'type' => 'color',
514 514
                     ),
@@ -527,19 +527,19 @@  discard block
 block discarded – undo
527 527
                 'main' => array(
528 528
                     'invoice_number_format_settings' => array(
529 529
                         'id'   => 'invoice_number_format_settings',
530
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
530
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
531 531
                         'type' => 'header',
532 532
                     ),
533 533
                     'sequential_invoice_number' => array(
534 534
                         'id'   => 'sequential_invoice_number',
535
-                        'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
536
-                        'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ),
535
+                        'name' => __('Sequential Invoice Numbers', 'invoicing'),
536
+                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'),
537 537
                         'type' => 'checkbox',
538 538
                     ),
539 539
                     'invoice_sequence_start' => array(
540 540
                         'id'   => 'invoice_sequence_start',
541
-                        'name' => __( 'Sequential Starting Number', 'invoicing' ),
542
-                        'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ),
541
+                        'name' => __('Sequential Starting Number', 'invoicing'),
542
+                        'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing'),
543 543
                         'type' => 'number',
544 544
                         'size' => 'small',
545 545
                         'std'  => '1',
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
                     ),
548 548
                     'invoice_number_padd' => array(
549 549
                         'id'      => 'invoice_number_padd',
550
-                        'name'    => __( 'Minimum Digits', 'invoicing' ),
551
-                        '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' ),
550
+                        'name'    => __('Minimum Digits', 'invoicing'),
551
+                        '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'),
552 552
                         'type'    => 'select',
553 553
                         'options' => $invoice_number_padd_options,
554 554
                         'std'     => 5,
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
                     ),
557 557
                     'invoice_number_prefix' => array(
558 558
                         'id' => 'invoice_number_prefix',
559
-                        'name' => __( 'Invoice Number Prefix', 'invoicing' ),
560
-                        'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ),
559
+                        'name' => __('Invoice Number Prefix', 'invoicing'),
560
+                        'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'),
561 561
                         'type' => 'text',
562 562
                         'size' => 'regular',
563 563
                         'std' => 'WPINV-',
@@ -565,32 +565,32 @@  discard block
 block discarded – undo
565 565
                     ),
566 566
                     'invoice_number_postfix' => array(
567 567
                         'id' => 'invoice_number_postfix',
568
-                        'name' => __( 'Invoice Number Postfix', 'invoicing' ),
569
-                        'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
568
+                        'name' => __('Invoice Number Postfix', 'invoicing'),
569
+                        'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
570 570
                         'type' => 'text',
571 571
                         'size' => 'regular',
572 572
                         'std' => ''
573 573
                     ),
574 574
                     'checkout_settings' => array(
575 575
                         'id'   => 'checkout_settings',
576
-                        'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
576
+                        'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
577 577
                         'type' => 'header',
578 578
                     ),
579 579
                     'login_to_checkout' => array(
580 580
                         'id'   => 'login_to_checkout',
581
-                        'name' => __( 'Require Login To Checkout', 'invoicing' ),
582
-                        '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' ),
581
+                        'name' => __('Require Login To Checkout', 'invoicing'),
582
+                        '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'),
583 583
                         'type' => 'checkbox',
584 584
                     ),
585 585
                     'uninstall_settings' => array(
586 586
                         'id'   => 'uninstall_settings',
587
-                        'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
587
+                        'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
588 588
                         'type' => 'header',
589 589
                     ),
590 590
                     'remove_data_on_unistall' => array(
591 591
                         'id'   => 'remove_data_on_unistall',
592
-                        'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
593
-                        'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
592
+                        'name' => __('Remove Data on Uninstall?', 'invoicing'),
593
+                        'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
594 594
                         'type' => 'checkbox',
595 595
                         'std'  => ''
596 596
                     ),
@@ -598,74 +598,74 @@  discard block
 block discarded – undo
598 598
                 'fields' => array(
599 599
                     'fields_settings' => array(
600 600
                         'id'   => 'fields_settings',
601
-                        'name' => '<h3>' . __( 'Address Fields', 'invoicing' ) . '</h3>',
602
-                        'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ),
601
+                        'name' => '<h3>' . __('Address Fields', 'invoicing') . '</h3>',
602
+                        'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'),
603 603
                         'type' => 'header',
604 604
                     ),
605 605
                     'fname_mandatory' => array(
606 606
                         'id'   => 'fname_mandatory',
607
-                        'name' => __( 'First Name', 'invoicing' ),
607
+                        'name' => __('First Name', 'invoicing'),
608 608
                         'type' => 'checkbox',
609 609
                         'std'  => true,
610 610
                     ),
611 611
                     'lname_mandatory' => array(
612 612
                         'id'   => 'lname_mandatory',
613
-                        'name' => __( 'Last Name', 'invoicing' ),
613
+                        'name' => __('Last Name', 'invoicing'),
614 614
                         'type' => 'checkbox',
615 615
                         'std'  => true,
616 616
                     ),
617 617
                     'address_mandatory' => array(
618 618
                         'id'   => 'address_mandatory',
619
-                        'name' => __( 'Address', 'invoicing' ),
619
+                        'name' => __('Address', 'invoicing'),
620 620
                         'type' => 'checkbox',
621 621
                         'std'  => true,
622 622
                     ),
623 623
                     'city_mandatory' => array(
624 624
                         'id'   => 'city_mandatory',
625
-                        'name' => __( 'City', 'invoicing' ),
625
+                        'name' => __('City', 'invoicing'),
626 626
                         'type' => 'checkbox',
627 627
                         'std'  => true,
628 628
                     ),
629 629
                     'country_mandatory' => array(
630 630
                         'id'   => 'country_mandatory',
631
-                        'name' => __( 'Country', 'invoicing' ),
631
+                        'name' => __('Country', 'invoicing'),
632 632
                         'type' => 'checkbox',
633 633
                         'std'  => true,
634 634
                     ),
635 635
                     'state_mandatory' => array(
636 636
                         'id'   => 'state_mandatory',
637
-                        'name' => __( 'State / Province', 'invoicing' ),
637
+                        'name' => __('State / Province', 'invoicing'),
638 638
                         'type' => 'checkbox',
639 639
                         'std'  => true,
640 640
                     ),
641 641
                     'zip_mandatory' => array(
642 642
                         'id'   => 'zip_mandatory',
643
-                        'name' => __( 'ZIP / Postcode', 'invoicing' ),
643
+                        'name' => __('ZIP / Postcode', 'invoicing'),
644 644
                         'type' => 'checkbox',
645 645
                         'std'  => true,
646 646
                     ),
647 647
                     'phone_mandatory' => array(
648 648
                         'id'   => 'phone_mandatory',
649
-                        'name' => __( 'Phone Number', 'invoicing' ),
649
+                        'name' => __('Phone Number', 'invoicing'),
650 650
                         'type' => 'checkbox',
651 651
                         'std'  => true,
652 652
                     ),
653 653
                     'address_autofill_settings' => array(
654 654
                         'id'   => 'address_autofill_settings',
655
-                        'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>',
655
+                        'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>',
656 656
                         'type' => 'header',
657 657
                     ),
658 658
                     'address_autofill_active' => array(
659 659
                         'id'   => 'address_autofill_active',
660
-                        'name' => __( 'Enable/Disable', 'invoicing' ),
661
-                        'desc' => __( 'Enable google address auto complete', 'invoicing' ),
660
+                        'name' => __('Enable/Disable', 'invoicing'),
661
+                        'desc' => __('Enable google address auto complete', 'invoicing'),
662 662
                         'type' => 'checkbox',
663 663
                         'std'  => 0
664 664
                     ),
665 665
                     'address_autofill_api' => array(
666 666
                         'id' => 'address_autofill_api',
667
-                        'name' => __( 'Google Place API Key', 'invoicing' ),
668
-                        '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>' ),
667
+                        'name' => __('Google Place API Key', 'invoicing'),
668
+                        '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>'),
669 669
                         'type' => 'text',
670 670
                         'size' => 'regular',
671 671
                         'std' => ''
@@ -679,8 +679,8 @@  discard block
 block discarded – undo
679 679
                 'main' => array(
680 680
                     'tool_settings' => array(
681 681
                         'id'   => 'tool_settings',
682
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
683
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
682
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
683
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
684 684
                         'type' => 'tools',
685 685
                     ),
686 686
                 ),
@@ -688,135 +688,135 @@  discard block
 block discarded – undo
688 688
         )
689 689
     );
690 690
 
691
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
691
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
692 692
 }
693 693
 
694
-function wpinv_settings_sanitize( $input = array() ) {
694
+function wpinv_settings_sanitize($input = array()) {
695 695
     global $wpinv_options;
696 696
 
697
-    if ( empty( $_POST['_wp_http_referer'] ) ) {
697
+    if (empty($_POST['_wp_http_referer'])) {
698 698
         return $input;
699 699
     }
700 700
 
701
-    parse_str( $_POST['_wp_http_referer'], $referrer );
701
+    parse_str($_POST['_wp_http_referer'], $referrer);
702 702
 
703 703
     $settings = wpinv_get_registered_settings();
704
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
705
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
704
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
705
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
706 706
 
707 707
     $input = $input ? $input : array();
708
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
709
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
708
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
709
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
710 710
 
711 711
     // Loop through each setting being saved and pass it through a sanitization filter
712
-    foreach ( $input as $key => $value ) {
712
+    foreach ($input as $key => $value) {
713 713
         // Get the setting type (checkbox, select, etc)
714
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
714
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
715 715
 
716
-        if ( $type ) {
716
+        if ($type) {
717 717
             // Field type specific filter
718
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
718
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
719 719
         }
720 720
 
721 721
         // General filter
722
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
722
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
723 723
     }
724 724
 
725 725
     // Loop through the whitelist and unset any that are empty for the tab being saved
726
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
727
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
726
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
727
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
728 728
 
729
-    $found_settings = array_merge( $main_settings, $section_settings );
729
+    $found_settings = array_merge($main_settings, $section_settings);
730 730
 
731
-    if ( ! empty( $found_settings ) ) {
732
-        foreach ( $found_settings as $key => $value ) {
731
+    if (!empty($found_settings)) {
732
+        foreach ($found_settings as $key => $value) {
733 733
 
734 734
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
735
-            if ( is_numeric( $key ) ) {
735
+            if (is_numeric($key)) {
736 736
                 $key = $value['id'];
737 737
             }
738 738
 
739
-            if ( empty( $input[ $key ] ) ) {
740
-                unset( $wpinv_options[ $key ] );
739
+            if (empty($input[$key])) {
740
+                unset($wpinv_options[$key]);
741 741
             }
742 742
         }
743 743
     }
744 744
 
745 745
     // Merge our new settings with the existing
746
-    $output = array_merge( $wpinv_options, $input );
746
+    $output = array_merge($wpinv_options, $input);
747 747
 
748
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
748
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
749 749
 
750 750
     return $output;
751 751
 }
752 752
 
753
-function wpinv_settings_sanitize_misc_accounting( $input ) {
753
+function wpinv_settings_sanitize_misc_accounting($input) {
754 754
     global $wpinv_options, $wpi_session;
755 755
 
756
-    if ( !current_user_can( 'manage_options' ) ) {
756
+    if (!current_user_can('manage_options')) {
757 757
         return $input;
758 758
     }
759 759
 
760
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
760
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
761 761
         // Shows an admin notice about upgrading previous order numbers
762
-        $wpi_session->set( 'upgrade_sequential', '1' );
762
+        $wpi_session->set('upgrade_sequential', '1');
763 763
     }
764 764
 
765 765
     return $input;
766 766
 }
767
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
767
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
768 768
 
769
-function wpinv_settings_sanitize_tax_rates( $input ) {
770
-    if( !current_user_can( 'manage_options' ) ) {
769
+function wpinv_settings_sanitize_tax_rates($input) {
770
+    if (!current_user_can('manage_options')) {
771 771
         return $input;
772 772
     }
773 773
 
774
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
774
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
775 775
 
776 776
     $tax_rates = array();
777 777
 
778
-    if ( !empty( $new_rates ) ) {
779
-        foreach ( $new_rates as $rate ) {
780
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
778
+    if (!empty($new_rates)) {
779
+        foreach ($new_rates as $rate) {
780
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
781 781
                 continue;
782 782
             }
783 783
             
784
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
784
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
785 785
             
786 786
             $tax_rates[] = $rate;
787 787
         }
788 788
     }
789 789
 
790
-    update_option( 'wpinv_tax_rates', $tax_rates );
790
+    update_option('wpinv_tax_rates', $tax_rates);
791 791
 
792 792
     return $input;
793 793
 }
794
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
794
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
795 795
 
796
-function wpinv_sanitize_text_field( $input ) {
797
-    return trim( $input );
796
+function wpinv_sanitize_text_field($input) {
797
+    return trim($input);
798 798
 }
799
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
799
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
800 800
 
801 801
 function wpinv_get_settings_tabs() {
802 802
     $tabs             = array();
803
-    $tabs['general']  = __( 'General', 'invoicing' );
804
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
805
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
806
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
807
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
808
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
809
-
810
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
803
+    $tabs['general']  = __('General', 'invoicing');
804
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
805
+    $tabs['taxes']    = __('Taxes', 'invoicing');
806
+    $tabs['emails']   = __('Emails', 'invoicing');
807
+    $tabs['misc']     = __('Misc', 'invoicing');
808
+    $tabs['tools']    = __('Tools', 'invoicing');
809
+
810
+    return apply_filters('wpinv_settings_tabs', $tabs);
811 811
 }
812 812
 
813
-function wpinv_get_settings_tab_sections( $tab = false ) {
813
+function wpinv_get_settings_tab_sections($tab = false) {
814 814
     $tabs     = false;
815 815
     $sections = wpinv_get_registered_settings_sections();
816 816
 
817
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
818
-        $tabs = $sections[ $tab ];
819
-    } else if ( $tab ) {
817
+    if ($tab && !empty($sections[$tab])) {
818
+        $tabs = $sections[$tab];
819
+    } else if ($tab) {
820 820
         $tabs = false;
821 821
     }
822 822
 
@@ -826,136 +826,136 @@  discard block
 block discarded – undo
826 826
 function wpinv_get_registered_settings_sections() {
827 827
     static $sections = false;
828 828
 
829
-    if ( false !== $sections ) {
829
+    if (false !== $sections) {
830 830
         return $sections;
831 831
     }
832 832
 
833 833
     $sections = array(
834
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
835
-            'main' => __( 'General Settings', 'invoicing' ),
836
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
837
-            'labels' => __( 'Label Texts', 'invoicing' ),
838
-        ) ),
839
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
840
-            'main' => __( 'Gateway Settings', 'invoicing' ),
841
-        ) ),
842
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
843
-            'main' => __( 'Tax Settings', 'invoicing' ),
844
-            'rates' => __( 'Tax Rates', 'invoicing' ),
845
-        ) ),
846
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
847
-            'main' => __( 'Email Settings', 'invoicing' ),
848
-        ) ),
849
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
850
-            'main' => __( 'Miscellaneous', 'invoicing' ),
851
-            'fields' => __( 'Fields Settings', 'invoicing' ),
852
-        ) ),
853
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
854
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
855
-        ) ),
834
+        'general' => apply_filters('wpinv_settings_sections_general', array(
835
+            'main' => __('General Settings', 'invoicing'),
836
+            'currency_section' => __('Currency Settings', 'invoicing'),
837
+            'labels' => __('Label Texts', 'invoicing'),
838
+        )),
839
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
840
+            'main' => __('Gateway Settings', 'invoicing'),
841
+        )),
842
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
843
+            'main' => __('Tax Settings', 'invoicing'),
844
+            'rates' => __('Tax Rates', 'invoicing'),
845
+        )),
846
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
847
+            'main' => __('Email Settings', 'invoicing'),
848
+        )),
849
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
850
+            'main' => __('Miscellaneous', 'invoicing'),
851
+            'fields' => __('Fields Settings', 'invoicing'),
852
+        )),
853
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
854
+            'main' => __('Diagnostic Tools', 'invoicing'),
855
+        )),
856 856
     );
857 857
 
858
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
858
+    $sections = apply_filters('wpinv_settings_sections', $sections);
859 859
 
860 860
     return $sections;
861 861
 }
862 862
 
863
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
863
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
864 864
 	$pages_options = array();
865 865
 
866
-	if( $default_label !== NULL && $default_label !== false ) {
867
-		$pages_options = array( '' => $default_label ); // Blank option
866
+	if ($default_label !== NULL && $default_label !== false) {
867
+		$pages_options = array('' => $default_label); // Blank option
868 868
 	}
869 869
 
870 870
 	$pages = get_pages();
871
-	if ( $pages ) {
872
-		foreach ( $pages as $page ) {
871
+	if ($pages) {
872
+		foreach ($pages as $page) {
873 873
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
874
-            $pages_options[ $page->ID ] = $title;
874
+            $pages_options[$page->ID] = $title;
875 875
 		}
876 876
 	}
877 877
 
878 878
 	return $pages_options;
879 879
 }
880 880
 
881
-function wpinv_header_callback( $args ) {
882
-	if ( !empty( $args['desc'] ) ) {
881
+function wpinv_header_callback($args) {
882
+	if (!empty($args['desc'])) {
883 883
         echo $args['desc'];
884 884
     }
885 885
 }
886 886
 
887
-function wpinv_hidden_callback( $args ) {
887
+function wpinv_hidden_callback($args) {
888 888
 	global $wpinv_options;
889 889
 
890
-	if ( isset( $args['set_value'] ) ) {
890
+	if (isset($args['set_value'])) {
891 891
 		$value = $args['set_value'];
892
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
893
-		$value = $wpinv_options[ $args['id'] ];
892
+	} elseif (isset($wpinv_options[$args['id']])) {
893
+		$value = $wpinv_options[$args['id']];
894 894
 	} else {
895
-		$value = isset( $args['std'] ) ? $args['std'] : '';
895
+		$value = isset($args['std']) ? $args['std'] : '';
896 896
 	}
897 897
 
898
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
898
+	if (isset($args['faux']) && true === $args['faux']) {
899 899
 		$args['readonly'] = true;
900
-		$value = isset( $args['std'] ) ? $args['std'] : '';
900
+		$value = isset($args['std']) ? $args['std'] : '';
901 901
 		$name  = '';
902 902
 	} else {
903
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
903
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
904 904
 	}
905 905
 
906
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
906
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
907 907
     
908 908
 	echo $html;
909 909
 }
910 910
 
911
-function wpinv_checkbox_callback( $args ) {
911
+function wpinv_checkbox_callback($args) {
912 912
 	global $wpinv_options;
913 913
     
914
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
914
+    $sanitize_id = wpinv_sanitize_key($args['id']);
915 915
 
916
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
916
+	if (isset($args['faux']) && true === $args['faux']) {
917 917
 		$name = '';
918 918
 	} else {
919 919
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
920 920
 	}
921 921
 
922
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
922
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
923 923
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
924
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
924
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
925 925
 
926 926
 	echo $html;
927 927
 }
928 928
 
929
-function wpinv_multicheck_callback( $args ) {
929
+function wpinv_multicheck_callback($args) {
930 930
 	global $wpinv_options;
931 931
 	
932
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
932
+	$sanitize_id = wpinv_sanitize_key($args['id']);
933 933
 	
934
-	if ( ! empty( $args['options'] ) ) {
935
-		foreach( $args['options'] as $key => $option ):
936
-			$sanitize_key = wpinv_sanitize_key( $key );
937
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
934
+	if (!empty($args['options'])) {
935
+		foreach ($args['options'] as $key => $option):
936
+			$sanitize_key = wpinv_sanitize_key($key);
937
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
938 938
 				$enabled = $sanitize_key;
939 939
 			} else { 
940 940
 				$enabled = NULL; 
941 941
 			}
942
-			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;';
943
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
942
+			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;';
943
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>';
944 944
 		endforeach;
945 945
 		echo '<p class="description">' . $args['desc'] . '</p>';
946 946
 	}
947 947
 }
948 948
 
949
-function wpinv_payment_icons_callback( $args ) {
949
+function wpinv_payment_icons_callback($args) {
950 950
 	global $wpinv_options;
951 951
     
952
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
952
+    $sanitize_id = wpinv_sanitize_key($args['id']);
953 953
 
954
-	if ( ! empty( $args['options'] ) ) {
955
-		foreach( $args['options'] as $key => $option ) {
956
-            $sanitize_key = wpinv_sanitize_key( $key );
954
+	if (!empty($args['options'])) {
955
+		foreach ($args['options'] as $key => $option) {
956
+            $sanitize_key = wpinv_sanitize_key($key);
957 957
             
958
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
958
+			if (isset($wpinv_options[$args['id']][$key])) {
959 959
 				$enabled = $option;
960 960
 			} else {
961 961
 				$enabled = NULL;
@@ -963,196 +963,196 @@  discard block
 block discarded – undo
963 963
 
964 964
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
965 965
 
966
-				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;';
966
+				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;';
967 967
 
968
-				if ( wpinv_string_is_image_url( $key ) ) {
969
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
968
+				if (wpinv_string_is_image_url($key)) {
969
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
970 970
 				} else {
971
-					$card = strtolower( str_replace( ' ', '', $option ) );
971
+					$card = strtolower(str_replace(' ', '', $option));
972 972
 
973
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
974
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
973
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
974
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
975 975
 					} else {
976
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
976
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
977 977
 						$content_dir = WP_CONTENT_DIR;
978 978
 
979
-						if ( function_exists( 'wp_normalize_path' ) ) {
979
+						if (function_exists('wp_normalize_path')) {
980 980
 							// Replaces backslashes with forward slashes for Windows systems
981
-							$image = wp_normalize_path( $image );
982
-							$content_dir = wp_normalize_path( $content_dir );
981
+							$image = wp_normalize_path($image);
982
+							$content_dir = wp_normalize_path($content_dir);
983 983
 						}
984 984
 
985
-						$image = str_replace( $content_dir, content_url(), $image );
985
+						$image = str_replace($content_dir, content_url(), $image);
986 986
 					}
987 987
 
988
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
988
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
989 989
 				}
990 990
 			echo $option . '</label>';
991 991
 		}
992
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
992
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
993 993
 	}
994 994
 }
995 995
 
996
-function wpinv_radio_callback( $args ) {
996
+function wpinv_radio_callback($args) {
997 997
 	global $wpinv_options;
998 998
     
999
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
999
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1000 1000
     
1001
-    foreach ( $args['options'] as $key => $option ) :
1002
-		$sanitize_key = wpinv_sanitize_key( $key );
1001
+    foreach ($args['options'] as $key => $option) :
1002
+		$sanitize_key = wpinv_sanitize_key($key);
1003 1003
         
1004 1004
         $checked = false;
1005 1005
 
1006
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
1006
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
1007 1007
 			$checked = true;
1008
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
1008
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
1009 1009
 			$checked = true;
1010 1010
 
1011 1011
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
1012
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
1012
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
1013 1013
 	endforeach;
1014 1014
 
1015
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
1015
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
1016 1016
 }
1017 1017
 
1018
-function wpinv_gateways_callback( $args ) {
1018
+function wpinv_gateways_callback($args) {
1019 1019
 	global $wpinv_options;
1020 1020
     
1021
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1021
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1022 1022
 
1023
-	foreach ( $args['options'] as $key => $option ) :
1024
-		$sanitize_key = wpinv_sanitize_key( $key );
1023
+	foreach ($args['options'] as $key => $option) :
1024
+		$sanitize_key = wpinv_sanitize_key($key);
1025 1025
         
1026
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
1026
+        if (isset($wpinv_options['gateways'][$key]))
1027 1027
 			$enabled = '1';
1028 1028
 		else
1029 1029
 			$enabled = null;
1030 1030
 
1031
-		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;';
1032
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1031
+		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;';
1032
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
1033 1033
 	endforeach;
1034 1034
 }
1035 1035
 
1036 1036
 function wpinv_gateway_select_callback($args) {
1037 1037
 	global $wpinv_options;
1038 1038
     
1039
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1039
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1040 1040
 
1041 1041
 	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1042 1042
 
1043
-	foreach ( $args['options'] as $key => $option ) :
1044
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1045
-            $selected = selected( $key, $args['selected'], false );
1043
+	foreach ($args['options'] as $key => $option) :
1044
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1045
+            $selected = selected($key, $args['selected'], false);
1046 1046
         } else {
1047
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1047
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
1048 1048
         }
1049
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1049
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
1050 1050
 	endforeach;
1051 1051
 
1052 1052
 	echo '</select>';
1053
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1053
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1054 1054
 }
1055 1055
 
1056
-function wpinv_text_callback( $args ) {
1056
+function wpinv_text_callback($args) {
1057 1057
 	global $wpinv_options;
1058 1058
     
1059
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1059
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1060 1060
 
1061
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1062
-		$value = $wpinv_options[ $args['id'] ];
1061
+	if (isset($wpinv_options[$args['id']])) {
1062
+		$value = $wpinv_options[$args['id']];
1063 1063
 	} else {
1064
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1064
+		$value = isset($args['std']) ? $args['std'] : '';
1065 1065
 	}
1066 1066
 
1067
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1067
+	if (isset($args['faux']) && true === $args['faux']) {
1068 1068
 		$args['readonly'] = true;
1069
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1069
+		$value = isset($args['std']) ? $args['std'] : '';
1070 1070
 		$name  = '';
1071 1071
 	} else {
1072
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1072
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1073 1073
 	}
1074
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1074
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1075 1075
 
1076 1076
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1077
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1078
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1079
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1077
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1078
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
1079
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1080 1080
 
1081 1081
 	echo $html;
1082 1082
 }
1083 1083
 
1084
-function wpinv_number_callback( $args ) {
1084
+function wpinv_number_callback($args) {
1085 1085
 	global $wpinv_options;
1086 1086
     
1087
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1087
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1088 1088
 
1089
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1090
-		$value = $wpinv_options[ $args['id'] ];
1089
+	if (isset($wpinv_options[$args['id']])) {
1090
+		$value = $wpinv_options[$args['id']];
1091 1091
 	} else {
1092
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1092
+		$value = isset($args['std']) ? $args['std'] : '';
1093 1093
 	}
1094 1094
 
1095
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1095
+	if (isset($args['faux']) && true === $args['faux']) {
1096 1096
 		$args['readonly'] = true;
1097
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1097
+		$value = isset($args['std']) ? $args['std'] : '';
1098 1098
 		$name  = '';
1099 1099
 	} else {
1100
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1100
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1101 1101
 	}
1102 1102
 
1103
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1104
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1105
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1106
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1103
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1104
+	$min  = isset($args['min']) ? $args['min'] : 0;
1105
+	$step = isset($args['step']) ? $args['step'] : 1;
1106
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1107 1107
 
1108
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1109
-	$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 ) ) . '"/>';
1110
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1108
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1109
+	$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)) . '"/>';
1110
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1111 1111
 
1112 1112
 	echo $html;
1113 1113
 }
1114 1114
 
1115
-function wpinv_textarea_callback( $args ) {
1115
+function wpinv_textarea_callback($args) {
1116 1116
 	global $wpinv_options;
1117 1117
     
1118
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1118
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1119 1119
 
1120
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1121
-		$value = $wpinv_options[ $args['id'] ];
1120
+	if (isset($wpinv_options[$args['id']])) {
1121
+		$value = $wpinv_options[$args['id']];
1122 1122
 	} else {
1123
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1123
+		$value = isset($args['std']) ? $args['std'] : '';
1124 1124
 	}
1125 1125
     
1126
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1127
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1126
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1127
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1128 1128
 
1129
-	$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>';
1130
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1129
+	$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>';
1130
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1131 1131
 
1132 1132
 	echo $html;
1133 1133
 }
1134 1134
 
1135
-function wpinv_password_callback( $args ) {
1135
+function wpinv_password_callback($args) {
1136 1136
 	global $wpinv_options;
1137 1137
     
1138
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1138
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1139 1139
 
1140
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1141
-		$value = $wpinv_options[ $args['id'] ];
1140
+	if (isset($wpinv_options[$args['id']])) {
1141
+		$value = $wpinv_options[$args['id']];
1142 1142
 	} else {
1143
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1143
+		$value = isset($args['std']) ? $args['std'] : '';
1144 1144
 	}
1145 1145
 
1146
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1147
-	$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 ) . '"/>';
1148
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1146
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1147
+	$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) . '"/>';
1148
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1149 1149
 
1150 1150
 	echo $html;
1151 1151
 }
1152 1152
 
1153 1153
 function wpinv_missing_callback($args) {
1154 1154
 	printf(
1155
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1155
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1156 1156
 		'<strong>' . $args['id'] . '</strong>'
1157 1157
 	);
1158 1158
 }
@@ -1160,137 +1160,137 @@  discard block
 block discarded – undo
1160 1160
 function wpinv_select_callback($args) {
1161 1161
 	global $wpinv_options;
1162 1162
     
1163
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1163
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1164 1164
 
1165
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1166
-		$value = $wpinv_options[ $args['id'] ];
1165
+	if (isset($wpinv_options[$args['id']])) {
1166
+		$value = $wpinv_options[$args['id']];
1167 1167
 	} else {
1168
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1168
+		$value = isset($args['std']) ? $args['std'] : '';
1169 1169
 	}
1170 1170
     
1171
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1171
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1172 1172
         $value = $args['selected'];
1173 1173
     }
1174 1174
 
1175
-	if ( isset( $args['placeholder'] ) ) {
1175
+	if (isset($args['placeholder'])) {
1176 1176
 		$placeholder = $args['placeholder'];
1177 1177
 	} else {
1178 1178
 		$placeholder = '';
1179 1179
 	}
1180 1180
 
1181
-	if ( isset( $args['chosen'] ) ) {
1181
+	if (isset($args['chosen'])) {
1182 1182
 		$chosen = 'class="wpinv-chosen"';
1183 1183
 	} else {
1184 1184
 		$chosen = '';
1185 1185
 	}
1186 1186
     
1187
-    if( !empty( $args['onchange'] ) ) {
1188
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1187
+    if (!empty($args['onchange'])) {
1188
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1189 1189
     } else {
1190 1190
         $onchange = '';
1191 1191
     }
1192 1192
 
1193
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1193
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1194 1194
 
1195
-	foreach ( $args['options'] as $option => $name ) {
1196
-		$selected = selected( $option, $value, false );
1197
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1195
+	foreach ($args['options'] as $option => $name) {
1196
+		$selected = selected($option, $value, false);
1197
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1198 1198
 	}
1199 1199
 
1200 1200
 	$html .= '</select>';
1201
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1201
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1202 1202
 
1203 1203
 	echo $html;
1204 1204
 }
1205 1205
 
1206
-function wpinv_color_select_callback( $args ) {
1206
+function wpinv_color_select_callback($args) {
1207 1207
 	global $wpinv_options;
1208 1208
     
1209
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1209
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1210 1210
 
1211
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1212
-		$value = $wpinv_options[ $args['id'] ];
1211
+	if (isset($wpinv_options[$args['id']])) {
1212
+		$value = $wpinv_options[$args['id']];
1213 1213
 	} else {
1214
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1214
+		$value = isset($args['std']) ? $args['std'] : '';
1215 1215
 	}
1216 1216
 
1217
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1217
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1218 1218
 
1219
-	foreach ( $args['options'] as $option => $color ) {
1220
-		$selected = selected( $option, $value, false );
1221
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1219
+	foreach ($args['options'] as $option => $color) {
1220
+		$selected = selected($option, $value, false);
1221
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1222 1222
 	}
1223 1223
 
1224 1224
 	$html .= '</select>';
1225
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1225
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1226 1226
 
1227 1227
 	echo $html;
1228 1228
 }
1229 1229
 
1230
-function wpinv_rich_editor_callback( $args ) {
1230
+function wpinv_rich_editor_callback($args) {
1231 1231
 	global $wpinv_options, $wp_version;
1232 1232
     
1233
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1233
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1234 1234
 
1235
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1236
-		$value = $wpinv_options[ $args['id'] ];
1235
+	if (isset($wpinv_options[$args['id']])) {
1236
+		$value = $wpinv_options[$args['id']];
1237 1237
 
1238
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1239
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1238
+		if (empty($args['allow_blank']) && empty($value)) {
1239
+			$value = isset($args['std']) ? $args['std'] : '';
1240 1240
 		}
1241 1241
 	} else {
1242
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1242
+		$value = isset($args['std']) ? $args['std'] : '';
1243 1243
 	}
1244 1244
 
1245
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1245
+	$rows = isset($args['size']) ? $args['size'] : 20;
1246 1246
 
1247
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1247
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1248 1248
 		ob_start();
1249
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1249
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows)));
1250 1250
 		$html = ob_get_clean();
1251 1251
 	} else {
1252
-		$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>';
1252
+		$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>';
1253 1253
 	}
1254 1254
 
1255
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1255
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1256 1256
 
1257 1257
 	echo $html;
1258 1258
 }
1259 1259
 
1260
-function wpinv_upload_callback( $args ) {
1260
+function wpinv_upload_callback($args) {
1261 1261
 	global $wpinv_options;
1262 1262
     
1263
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1263
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1264 1264
 
1265
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1265
+	if (isset($wpinv_options[$args['id']])) {
1266 1266
 		$value = $wpinv_options[$args['id']];
1267 1267
 	} else {
1268 1268
 		$value = isset($args['std']) ? $args['std'] : '';
1269 1269
 	}
1270 1270
 
1271
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1272
-	$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 ) ) . '"/>';
1273
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1274
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1271
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1272
+	$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)) . '"/>';
1273
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1274
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1275 1275
 
1276 1276
 	echo $html;
1277 1277
 }
1278 1278
 
1279
-function wpinv_color_callback( $args ) {
1279
+function wpinv_color_callback($args) {
1280 1280
 	global $wpinv_options;
1281 1281
     
1282
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1282
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1283 1283
 
1284
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1285
-		$value = $wpinv_options[ $args['id'] ];
1284
+	if (isset($wpinv_options[$args['id']])) {
1285
+		$value = $wpinv_options[$args['id']];
1286 1286
 	} else {
1287
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1287
+		$value = isset($args['std']) ? $args['std'] : '';
1288 1288
 	}
1289 1289
 
1290
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1290
+	$default = isset($args['std']) ? $args['std'] : '';
1291 1291
 
1292
-	$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 ) . '" />';
1293
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1292
+	$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) . '" />';
1293
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1294 1294
 
1295 1295
 	echo $html;
1296 1296
 }
@@ -1298,9 +1298,9 @@  discard block
 block discarded – undo
1298 1298
 function wpinv_country_states_callback($args) {
1299 1299
 	global $wpinv_options;
1300 1300
     
1301
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1301
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1302 1302
 
1303
-	if ( isset( $args['placeholder'] ) ) {
1303
+	if (isset($args['placeholder'])) {
1304 1304
 		$placeholder = $args['placeholder'];
1305 1305
 	} else {
1306 1306
 		$placeholder = '';
@@ -1308,17 +1308,17 @@  discard block
 block discarded – undo
1308 1308
 
1309 1309
 	$states = wpinv_get_country_states();
1310 1310
 
1311
-	$chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1312
-	$class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1313
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1311
+	$chosen = ($args['chosen'] ? ' wpinv-chosen' : '');
1312
+	$class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1313
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1314 1314
 
1315
-	foreach ( $states as $option => $name ) {
1316
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1317
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1315
+	foreach ($states as $option => $name) {
1316
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1317
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1318 1318
 	}
1319 1319
 
1320 1320
 	$html .= '</select>';
1321
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1321
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1322 1322
 
1323 1323
 	echo $html;
1324 1324
 }
@@ -1333,25 +1333,25 @@  discard block
 block discarded – undo
1333 1333
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1334 1334
 		<thead>
1335 1335
 			<tr>
1336
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1337
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1338
-                <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>
1339
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1340
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1341
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1336
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1337
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1338
+                <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>
1339
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1340
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1341
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1342 1342
 			</tr>
1343 1343
 		</thead>
1344 1344
         <tbody>
1345
-		<?php if( !empty( $rates ) ) : ?>
1346
-			<?php foreach( $rates as $key => $rate ) : ?>
1345
+		<?php if (!empty($rates)) : ?>
1346
+			<?php foreach ($rates as $key => $rate) : ?>
1347 1347
             <?php 
1348
-            $sanitized_key = wpinv_sanitize_key( $key );
1348
+            $sanitized_key = wpinv_sanitize_key($key);
1349 1349
             ?>
1350 1350
 			<tr>
1351 1351
 				<td class="wpinv_tax_country">
1352 1352
 					<?php
1353
-					echo wpinv_html_select( array(
1354
-						'options'          => wpinv_get_country_list( true ),
1353
+					echo wpinv_html_select(array(
1354
+						'options'          => wpinv_get_country_list(true),
1355 1355
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1356 1356
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1357 1357
 						'selected'         => $rate['country'],
@@ -1359,72 +1359,72 @@  discard block
 block discarded – undo
1359 1359
 						'show_option_none' => false,
1360 1360
 						'class'            => 'wpinv-tax-country',
1361 1361
 						'chosen'           => false,
1362
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1363
-					) );
1362
+						'placeholder'      => __('Choose a country', 'invoicing')
1363
+					));
1364 1364
 					?>
1365 1365
 				</td>
1366 1366
 				<td class="wpinv_tax_state">
1367 1367
 					<?php
1368
-					$states = wpinv_get_country_states( $rate['country'] );
1369
-					if( !empty( $states ) ) {
1370
-						echo wpinv_html_select( array(
1371
-							'options'          => array_merge( array( '' => '' ), $states ),
1368
+					$states = wpinv_get_country_states($rate['country']);
1369
+					if (!empty($states)) {
1370
+						echo wpinv_html_select(array(
1371
+							'options'          => array_merge(array('' => ''), $states),
1372 1372
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1373 1373
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1374 1374
 							'selected'         => $rate['state'],
1375 1375
 							'show_option_all'  => false,
1376 1376
 							'show_option_none' => false,
1377 1377
 							'chosen'           => false,
1378
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1379
-						) );
1378
+							'placeholder'      => __('Choose a state', 'invoicing')
1379
+						));
1380 1380
 					} else {
1381
-						echo wpinv_html_text( array(
1381
+						echo wpinv_html_text(array(
1382 1382
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1383
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1383
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1384 1384
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1385
-						) );
1385
+						));
1386 1386
 					}
1387 1387
 					?>
1388 1388
 				</td>
1389 1389
 				<td class="wpinv_tax_global">
1390
-					<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'] ) ); ?>/>
1391
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1390
+					<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'])); ?>/>
1391
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1392 1392
 				</td>
1393
-				<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>
1394
-                <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>
1395
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1393
+				<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>
1394
+                <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>
1395
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1396 1396
 			</tr>
1397 1397
 			<?php endforeach; ?>
1398 1398
 		<?php else : ?>
1399 1399
 			<tr>
1400 1400
 				<td class="wpinv_tax_country">
1401 1401
 					<?php
1402
-					echo wpinv_html_select( array(
1403
-						'options'          => wpinv_get_country_list( true ),
1402
+					echo wpinv_html_select(array(
1403
+						'options'          => wpinv_get_country_list(true),
1404 1404
 						'name'             => 'tax_rates[0][country]',
1405 1405
 						'show_option_all'  => false,
1406 1406
 						'show_option_none' => false,
1407 1407
 						'class'            => 'wpinv-tax-country',
1408 1408
 						'chosen'           => false,
1409
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1410
-					) ); ?>
1409
+						'placeholder'      => __('Choose a country', 'invoicing')
1410
+					)); ?>
1411 1411
 				</td>
1412 1412
 				<td class="wpinv_tax_state">
1413
-					<?php echo wpinv_html_text( array(
1413
+					<?php echo wpinv_html_text(array(
1414 1414
 						'name' => 'tax_rates[0][state]'
1415
-					) ); ?>
1415
+					)); ?>
1416 1416
 				</td>
1417 1417
 				<td class="wpinv_tax_global">
1418 1418
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1419
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1419
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1420 1420
 				</td>
1421
-				<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>
1421
+				<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>
1422 1422
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1423
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1423
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1424 1424
 			</tr>
1425 1425
 		<?php endif; ?>
1426 1426
         </tbody>
1427
-        <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>
1427
+        <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>
1428 1428
 	</table>
1429 1429
 	<?php
1430 1430
 	echo ob_get_clean();
@@ -1435,54 +1435,54 @@  discard block
 block discarded – undo
1435 1435
     ob_start(); ?>
1436 1436
     </td><tr>
1437 1437
     <td colspan="2" class="wpinv_tools_tdbox">
1438
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1439
-    <?php do_action( 'wpinv_tools_before' ); ?>
1438
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1439
+    <?php do_action('wpinv_tools_before'); ?>
1440 1440
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1441 1441
         <thead>
1442 1442
             <tr>
1443
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1444
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1445
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1443
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1444
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1445
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1446 1446
             </tr>
1447 1447
         </thead>
1448
-            <?php do_action( 'wpinv_tools_row' ); ?>
1448
+            <?php do_action('wpinv_tools_row'); ?>
1449 1449
         <tbody>
1450 1450
         </tbody>
1451 1451
     </table>
1452
-    <?php do_action( 'wpinv_tools_after' ); ?>
1452
+    <?php do_action('wpinv_tools_after'); ?>
1453 1453
     <?php
1454 1454
     echo ob_get_clean();
1455 1455
 }
1456 1456
 
1457
-function wpinv_descriptive_text_callback( $args ) {
1458
-	echo wp_kses_post( $args['desc'] );
1457
+function wpinv_descriptive_text_callback($args) {
1458
+	echo wp_kses_post($args['desc']);
1459 1459
 }
1460 1460
 
1461
-function wpinv_hook_callback( $args ) {
1462
-	do_action( 'wpinv_' . $args['id'], $args );
1461
+function wpinv_hook_callback($args) {
1462
+	do_action('wpinv_' . $args['id'], $args);
1463 1463
 }
1464 1464
 
1465 1465
 function wpinv_set_settings_cap() {
1466 1466
 	return 'manage_options';
1467 1467
 }
1468
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1468
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1469 1469
 
1470
-function wpinv_settings_sanitize_input( $value, $key ) {
1471
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1472
-        $value = wpinv_sanitize_amount( $value, 4 );
1470
+function wpinv_settings_sanitize_input($value, $key) {
1471
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1472
+        $value = wpinv_sanitize_amount($value, 4);
1473 1473
         $value = $value >= 100 ? 99 : $value;
1474 1474
     }
1475 1475
         
1476 1476
     return $value;
1477 1477
 }
1478
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1478
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1479 1479
 
1480
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1481
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1482
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1480
+function wpinv_on_update_settings($old_value, $value, $option) {
1481
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1482
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1483 1483
     
1484
-    if ( $old != $new ) {
1485
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1484
+    if ($old != $new) {
1485
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1486 1486
     }
1487 1487
 }
1488
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1489 1488
\ No newline at end of file
1489
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1490 1490
\ No newline at end of file
Please login to merge, or discard this patch.