Passed
Push — master ( 5bc2fd...5f8ee6 )
by Stiofan
27s
created
templates/emails/wpinv-email-invoice-items.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, $ajax_cart_details;
7 8
 $ajax_cart_details = $invoice->get_cart_details();
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  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
 global $wpinv_euvat, $ajax_cart_details;
@@ -11,152 +11,152 @@  discard block
 block discarded – undo
11 11
 $quantities_enabled = wpinv_item_quantities_enabled();
12 12
 $use_taxes          = wpinv_use_taxes();
13 13
 $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
14
-$tax_label          = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
15
-$tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
14
+$tax_label          = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
15
+$tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
16 16
 
17
-do_action( 'wpinv_before_email_items', $invoice ); ?>
17
+do_action('wpinv_before_email_items', $invoice); ?>
18 18
 <div id="wpinv-email-items">
19
-    <h3 class="wpinv-items-t"><?php echo apply_filters( 'wpinv_email_items_title', __( 'Items', 'invoicing' ) ); ?></h3>
19
+    <h3 class="wpinv-items-t"><?php echo apply_filters('wpinv_email_items_title', __('Items', 'invoicing')); ?></h3>
20 20
     <table id="wpinv_checkout_cart" class="table table-bordered table-hover">
21 21
         <thead>
22 22
             <tr class="wpinv_cart_header_row">
23
-                <?php do_action( 'wpinv_email_items_table_header_first' ); ?>
24
-                <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th>
25
-                <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th>
26
-                <?php if ( $quantities_enabled ) { ?>
27
-                <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th>
23
+                <?php do_action('wpinv_email_items_table_header_first'); ?>
24
+                <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th>
25
+                <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th>
26
+                <?php if ($quantities_enabled) { ?>
27
+                <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th>
28 28
                 <?php } ?>
29
-                <?php if ( !$zero_tax && $use_taxes ) { ?>
29
+                <?php if (!$zero_tax && $use_taxes) { ?>
30 30
                 <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th>
31 31
                 <?php } ?>
32
-                <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
33
-                <?php do_action( 'wpinv_email_items_table_header_last' ); ?>
32
+                <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
33
+                <?php do_action('wpinv_email_items_table_header_last'); ?>
34 34
             </tr>
35 35
         </thead>
36 36
         <tbody>
37 37
             <?php
38
-                do_action( 'wpinv_email_items_before' );
39
-                if ( $cart_items ) {
40
-                    foreach ( $cart_items as $key => $item ) {
41
-                        $wpi_item = $item['id'] ? new WPInv_Item( $item['id'] ) : NULL;
38
+                do_action('wpinv_email_items_before');
39
+                if ($cart_items) {
40
+                    foreach ($cart_items as $key => $item) {
41
+                        $wpi_item = $item['id'] ? new WPInv_Item($item['id']) : NULL;
42 42
                     ?>
43
-                    <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>">
44
-                        <?php do_action( 'wpinv_email_items_table_body_first', $item ); ?>
43
+                    <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>">
44
+                        <?php do_action('wpinv_email_items_table_body_first', $item); ?>
45 45
                         <td class="wpinv_cart_item_name text-left">
46 46
                             <?php
47
-                                if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) {
47
+                                if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) {
48 48
                                     echo '<div class="wpinv_cart_item_image">';
49
-                                        echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) );
49
+                                        echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25)));
50 50
                                     echo '</div>';
51 51
                                 }
52
-                                $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item );
52
+                                $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item);
53 53
                                 echo '<span class="wpinv_email_cart_item_title">' . $item_title . '</span>';
54 54
                                 
55
-                                $summary = apply_filters( 'wpinv_email_invoice_line_item_summary', '', $item, $wpi_item, $invoice );
56
-                                if ( !empty( $summary ) ) {
55
+                                $summary = apply_filters('wpinv_email_invoice_line_item_summary', '', $item, $wpi_item, $invoice);
56
+                                if (!empty($summary)) {
57 57
                                     echo '<p class="small">' . $summary . '</p>';
58 58
                                 }
59 59
     
60
-                                do_action( 'wpinv_email_cart_item_title_after', $item, $key );
60
+                                do_action('wpinv_email_cart_item_title_after', $item, $key);
61 61
                             ?>
62 62
                         </td>
63 63
                         <td class="wpinv_cart_item_price text-right">
64 64
                             <?php 
65
-                            echo wpinv_cart_item_price( $item );
66
-                            do_action( 'wpinv_email_cart_item_price_after', $item, $key );
65
+                            echo wpinv_cart_item_price($item);
66
+                            do_action('wpinv_email_cart_item_price_after', $item, $key);
67 67
                             ?>
68 68
                         </td>
69
-                        <?php if ( $quantities_enabled ) { ?>
69
+                        <?php if ($quantities_enabled) { ?>
70 70
                         <td class="wpinv_cart_item_qty text-right">
71 71
                             <?php
72
-                            echo wpinv_get_cart_item_quantity( $item );
73
-                            do_action( 'wpinv_email_item_quantitiy', $item, $key );
72
+                            echo wpinv_get_cart_item_quantity($item);
73
+                            do_action('wpinv_email_item_quantitiy', $item, $key);
74 74
                             ?>
75 75
                         </td>
76 76
                         <?php } ?>
77
-                        <?php if ( !$zero_tax && $use_taxes ) { ?>
77
+                        <?php if (!$zero_tax && $use_taxes) { ?>
78 78
                         <td class="wpinv_cart_item_tax text-right">
79 79
                             <?php
80
-                            echo wpinv_cart_item_tax( $item );
81
-                            do_action( 'wpinv_email_item_tax', $item, $key );
80
+                            echo wpinv_cart_item_tax($item);
81
+                            do_action('wpinv_email_item_tax', $item, $key);
82 82
                             ?>
83 83
                         </td>
84 84
                         <?php } ?>
85 85
                         <td class="wpinv_cart_item_subtotal text-right">
86 86
                             <?php
87
-                            echo wpinv_cart_item_subtotal( $item );
88
-                            do_action( 'wpinv_email_item_subtotal', $item, $key );
87
+                            echo wpinv_cart_item_subtotal($item);
88
+                            do_action('wpinv_email_item_subtotal', $item, $key);
89 89
                             ?>
90 90
                         </td>
91
-                        <?php do_action( 'wpinv_email_items_table_body_last', $item, $key ); ?>
91
+                        <?php do_action('wpinv_email_items_table_body_last', $item, $key); ?>
92 92
                     </tr>
93 93
                 <?php } ?>
94 94
             <?php } ?>
95
-            <?php do_action( 'wpinv_email_items_middle' ); ?>
96
-            <?php do_action( 'wpinv_email_items_after' ); ?>
95
+            <?php do_action('wpinv_email_items_middle'); ?>
96
+            <?php do_action('wpinv_email_items_after'); ?>
97 97
         </tbody>
98 98
         <tfoot>
99
-            <?php $cart_columns = wpinv_checkout_cart_columns(); if ( $zero_tax && $use_taxes ) { $cart_columns--; } ?>
100
-            <?php if ( has_action( 'wpinv_email_footer_buttons' ) ) { ?>
99
+            <?php $cart_columns = wpinv_checkout_cart_columns(); if ($zero_tax && $use_taxes) { $cart_columns--; } ?>
100
+            <?php if (has_action('wpinv_email_footer_buttons')) { ?>
101 101
                 <tr class="wpinv_cart_footer_row">
102
-                    <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?>
103
-                    <td colspan="<?php echo ( $cart_columns ); ?>">
104
-                        <?php do_action( 'wpinv_email_footer_buttons' ); ?>
102
+                    <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?>
103
+                    <td colspan="<?php echo ($cart_columns); ?>">
104
+                        <?php do_action('wpinv_email_footer_buttons'); ?>
105 105
                     </td>
106
-                    <?php do_action( 'wpinv_email_items_table_buttons_first', $cart_items ); ?>
106
+                    <?php do_action('wpinv_email_items_table_buttons_first', $cart_items); ?>
107 107
                 </tr>
108 108
             <?php } ?>
109 109
 
110
-            <?php if ( !$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed() ) { ?>
110
+            <?php if (!$zero_tax && $use_taxes && !wpinv_prices_include_tax() && wpinv_is_cart_taxed()) { ?>
111 111
                 <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row">
112
-                    <?php do_action( 'wpinv_email_items_table_subtotal_first', $cart_items ); ?>
113
-                    <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right">
114
-                        <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong>
112
+                    <?php do_action('wpinv_email_items_table_subtotal_first', $cart_items); ?>
113
+                    <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right">
114
+                        <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong>
115 115
                     </td>
116 116
                     <td class="wpinv_cart_subtotal text-right">
117
-                        <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal( true ); ?></span>
117
+                        <span class="wpinv_cart_subtotal_amount bold"><?php echo $invoice->get_subtotal(true); ?></span>
118 118
                     </td>
119
-                    <?php do_action( 'wpinv_email_items_table_subtotal_last', $cart_items, $invoice ); ?>
119
+                    <?php do_action('wpinv_email_items_table_subtotal_last', $cart_items, $invoice); ?>
120 120
                 </tr>
121 121
             <?php } ?>
122 122
             
123
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
123
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
124 124
                 <tr class="wpinv_cart_footer_row wpinv_cart_discount_row">
125
-                    <?php do_action( 'wpinv_receipt_items_table_discount_first', $cart_items, $invoice ); ?>
126
-                    <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_discount_label text-right">
127
-                        <strong><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</strong>
125
+                    <?php do_action('wpinv_receipt_items_table_discount_first', $cart_items, $invoice); ?>
126
+                    <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_discount_label text-right">
127
+                        <strong><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</strong>
128 128
                     </td>
129 129
                     <td class="wpinv_cart_discount text-right">
130
-                        <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount( $invoice_id, true, true ); ?></span>
130
+                        <span class="wpinv_cart_discount_amount"><?php echo wpinv_discount($invoice_id, true, true); ?></span>
131 131
                     </td>
132
-                    <?php do_action( 'wpinv_receipt_items_table_discount_last', $cart_items, $invoice ); ?>
132
+                    <?php do_action('wpinv_receipt_items_table_discount_last', $cart_items, $invoice); ?>
133 133
                 </tr>
134 134
             <?php } ?>
135 135
 
136
-            <?php if ( !$zero_tax && $use_taxes && wpinv_is_cart_taxed() ) { ?>
136
+            <?php if (!$zero_tax && $use_taxes && wpinv_is_cart_taxed()) { ?>
137 137
                 <tr class="wpinv_cart_footer_row wpinv_cart_tax_row">
138
-                    <?php do_action( 'wpinv_email_items_table_tax_first', $cart_items, $invoice ); ?>
139
-                    <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right">
138
+                    <?php do_action('wpinv_email_items_table_tax_first', $cart_items, $invoice); ?>
139
+                    <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right">
140 140
                         <strong><?php echo $tax_label; ?>:</strong>
141 141
                     </td>
142 142
                     <td class="wpinv_cart_tax text-right">
143
-                        <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax( true ); ?></span>
143
+                        <span class="wpinv_cart_tax_amount"><?php echo $invoice->get_tax(true); ?></span>
144 144
                     </td>
145
-                    <?php do_action( 'wpinv_email_items_table_tax_last', $cart_items, $invoice ); ?>
145
+                    <?php do_action('wpinv_email_items_table_tax_last', $cart_items, $invoice); ?>
146 146
                 </tr>
147 147
             <?php } ?>
148 148
 
149 149
             <tr class="wpinv_cart_footer_row">
150
-                <?php do_action( 'wpinv_email_items_table_footer_first', $cart_items, $invoice ); ?>
151
-                <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right">
152
-                    <?php echo apply_filters( 'wpinv_email_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?>
150
+                <?php do_action('wpinv_email_items_table_footer_first', $cart_items, $invoice); ?>
151
+                <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right">
152
+                    <?php echo apply_filters('wpinv_email_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?>
153 153
                 </td>
154 154
                 <td class="wpinv_cart_total text-right">
155
-                    <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total( true ); ?></span>
155
+                    <span class="wpinv_cart_amount bold"><?php echo $invoice->get_total(true); ?></span>
156 156
                 </td>
157
-                <?php do_action( 'wpinv_email_items_table_footer_last', $cart_items, $invoice ); ?>
157
+                <?php do_action('wpinv_email_items_table_footer_last', $cart_items, $invoice); ?>
158 158
             </tr>
159 159
         </tfoot>
160 160
     </table>
161 161
 </div>
162
-<?php do_action( 'wpinv_after_email_items', $invoice ); ?>
163 162
\ No newline at end of file
163
+<?php do_action('wpinv_after_email_items', $invoice); ?>
164 164
\ No newline at end of file
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   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,68 +1,68 @@
 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() ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
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()) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
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 do_action( 'wpinv_email_invoice_details_after_due_date', $invoice->ID ); ?>
50
-        <?php if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?>
49
+        <?php do_action('wpinv_email_invoice_details_after_due_date', $invoice->ID); ?>
50
+        <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?>
51 51
             <tr>
52
-                <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
52
+                <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
53 53
                 <td><?php echo $owner_vat_number; ?></td>
54 54
             </tr>
55 55
         <?php } ?>
56
-        <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?>
56
+        <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?>
57 57
             <tr>
58
-                <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
58
+                <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
59 59
                 <td><?php echo $user_vat_number; ?></td>
60 60
             </tr>
61 61
         <?php } ?>
62 62
         <tr class="table-active">
63
-            <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td>
64
-            <td><strong><?php echo $invoice->get_total( true ); ?></strong></td>
63
+            <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td>
64
+            <td><strong><?php echo $invoice->get_total(true); ?></strong></td>
65 65
         </tr>
66 66
     </table>
67 67
 </div>
68
-<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?>
69 68
\ No newline at end of file
69
+<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?>
70 70
\ 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   +122 added lines, -122 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,61 +133,61 @@  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 ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $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 ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($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 ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
159
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
158
+                                        <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?>
159
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
160 160
 
161
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
162
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
161
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
162
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
163 163
 
164
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
165
-                                            <?php echo $invoice->get_total( true ); ?>
164
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
165
+                                            <?php echo $invoice->get_total(true); ?>
166 166
 
167
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
167
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
168 168
                                             <?php
169 169
                                                 $actions = array(
170 170
                                                     'pay'    => array(
171 171
                                                         'url'  => $invoice->get_checkout_payment_url(),
172
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
172
+                                                        'name' => __('Pay Now', 'invoicing'),
173 173
                                                         'class' => 'btn-success'
174 174
                                                     ),
175 175
                                                     'print'   => array(
176 176
                                                         'url'  => $invoice->get_view_url(),
177
-                                                        'name' => __( 'Print', 'invoicing' ),
177
+                                                        'name' => __('Print', 'invoicing'),
178 178
                                                         'class' => 'btn-primary',
179 179
                                                         'attrs' => 'target="_blank"'
180 180
                                                     )
181 181
                                                 );
182 182
 
183
-                                                if ( ! $invoice->needs_payment() ) {
184
-                                                    unset( $actions['pay'] );
183
+                                                if (!$invoice->needs_payment()) {
184
+                                                    unset($actions['pay']);
185 185
                                                 }
186 186
 
187
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
188
-                                                    foreach ( $actions as $key => $action ) {
187
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
188
+                                                    foreach ($actions as $key => $action) {
189 189
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
190
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
190
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
191 191
                                                     }
192 192
                                                 }
193 193
                                             ?>
@@ -215,64 +215,64 @@  discard block
 block discarded – undo
215 215
             </div>
216 216
             <?php
217 217
         
218
-            do_action( 'wpinv_bp_invoices_after_content' );
218
+            do_action('wpinv_bp_invoices_after_content');
219 219
         } else {
220 220
             ?>
221 221
             <div id="message" class="info">
222
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
222
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
223 223
             </div>
224 224
             <?php
225 225
         }
226 226
         
227
-        if ( defined( 'DOING_AJAX' ) ) {
227
+        if (defined('DOING_AJAX')) {
228 228
             exit;
229 229
         }
230 230
     }
231 231
     
232
-    public function has_invoices( $args = '' ) {
232
+    public function has_invoices($args = '') {
233 233
         global $invoices_template;
234 234
 
235
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
235
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
236 236
         // Parse arguments.
237
-        $r = bp_parse_args( $args, array(
237
+        $r = bp_parse_args($args, array(
238 238
             'status'            => 'all',
239 239
             'page_arg'          => 'bpage',
240 240
             'page'              => 1,
241 241
             'per_page'          => $per_page > 0 ? $per_page : 20,
242 242
             'max'               => false,
243 243
             'user_id'           => bp_loggedin_user_id(),
244
-        ), 'has_invoices' );
244
+        ), 'has_invoices');
245 245
 
246 246
 
247
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
247
+        if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) {
248 248
             $r['per_page'] = (int)$r['max'];
249 249
         }
250 250
 
251 251
         // Get the invoices.
252
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
252
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
253 253
 
254
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
254
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
255 255
     }
256 256
     
257 257
     public function setup_invoice_count() {
258
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
259
-        $invoices   = wpinv_get_invoices( $query );
258
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('user' => bp_loggedin_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
259
+        $invoices   = wpinv_get_invoices($query);
260 260
         
261
-        $this->count = !empty( $invoices ) ? count( $invoices ) : 0;
261
+        $this->count = !empty($invoices) ? count($invoices) : 0;
262 262
     }
263 263
     
264 264
     public function pagination_count() {
265 265
         global $invoices_template;
266 266
 
267
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
268
-        $from_num  = bp_core_number_format( $start_num );
269
-        $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 ) );
270
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
267
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
268
+        $from_num  = bp_core_number_format($start_num);
269
+        $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));
270
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
271 271
 
272
-        if ( 1 == $invoices_template->total_invoice_count ) {
273
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
272
+        if (1 == $invoices_template->total_invoice_count) {
273
+            $message = __('Viewing 1 invoice', 'invoicing');
274 274
         } else {
275
-            $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 );
275
+            $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);
276 276
         }
277 277
 
278 278
         return $message;
@@ -281,32 +281,32 @@  discard block
 block discarded – undo
281 281
     function pagination_links() {
282 282
         global $invoices_template;
283 283
 
284
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
284
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
285 285
     }
286 286
     
287
-    public function bp_section( $settings = array() ) {
288
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
287
+    public function bp_section($settings = array()) {
288
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
289 289
         return $settings;
290 290
     }
291 291
     
292
-    public function bp_settings( $settings = array() ) {
292
+    public function bp_settings($settings = array()) {
293 293
         $settings['wpinv_bp'] = array(
294 294
             'wpinv_bp_labels' => array(
295 295
                 'id'   => 'wpinv_bp_settings',
296
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
296
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
297 297
                 'desc' => '',
298 298
                 'type' => 'header',
299 299
             ),
300 300
             'wpinv_bp_hide_menu' => array(
301 301
                 'id'   => 'wpinv_bp_hide_menu',
302
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
303
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
302
+                'name' => __('Hide Invoices link', 'invoicing'),
303
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
304 304
                 'type' => 'checkbox',
305 305
             ),
306 306
             'wpinv_menu_position' => array(
307 307
                 'id'   => 'wpinv_menu_position',
308
-                'name' => __( 'Menu position', 'invoicing' ),
309
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
308
+                'name' => __('Menu position', 'invoicing'),
309
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
310 310
                 'type' => 'number',
311 311
                 'size' => 'small',
312 312
                 'min'  => '1',
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
             ),
317 317
             'wpinv_bp_per_page' => array(
318 318
                 'id'   => 'wpinv_bp_per_page',
319
-                'name' => __( 'Max invoices per page', 'invoicing' ),
320
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
319
+                'name' => __('Max invoices per page', 'invoicing'),
320
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
321 321
                 'type' => 'number',
322 322
                 'size' => 'small',
323 323
                 'min'  => '1',
@@ -342,25 +342,25 @@  discard block
 block discarded – undo
342 342
     public $pag_links = '';
343 343
     public $total_invoice_count = 0;
344 344
     
345
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
346
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
345
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
346
+        $this->invoices = array('invoices' => array(), 'total' => 0);
347 347
         
348
-        $this->pag_arg  = sanitize_key( $page_arg );
349
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
350
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
348
+        $this->pag_arg  = sanitize_key($page_arg);
349
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
350
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
351 351
 
352
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
353
-        if ( !empty( $status ) && $status != 'all' ) {
352
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
353
+        if (!empty($status) && $status != 'all') {
354 354
            $query_args['status'] = $status;
355 355
         }
356
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
356
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
357 357
         
358
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
359
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
358
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
359
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
360 360
             $this->invoices['total']    = $invoices->found_posts;
361 361
         }
362 362
 
363
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
363
+        if (empty($max) || ($max >= (int)$this->invoices['total'])) {
364 364
             $this->total_invoice_count = (int)$this->invoices['total'];
365 365
         } else {
366 366
             $this->total_invoice_count = (int)$max;
@@ -368,52 +368,52 @@  discard block
 block discarded – undo
368 368
 
369 369
         $this->invoices = $this->invoices['invoices'];
370 370
 
371
-        $invoice_count = count( $this->invoices );
371
+        $invoice_count = count($this->invoices);
372 372
 
373
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
373
+        if (empty($max) || ($max >= (int)$invoice_count)) {
374 374
             $this->invoice_count = (int)$invoice_count;
375 375
         } else {
376 376
             $this->invoice_count = (int)$max;
377 377
         }
378 378
         
379
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
380
-            $this->pag_links = paginate_links( array(
381
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
379
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
380
+            $this->pag_links = paginate_links(array(
381
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
382 382
                 'format'    => '',
383
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
383
+                'total'     => ceil((int)$this->total_invoice_count / (int)$this->pag_num),
384 384
                 'current'   => (int)$this->pag_page,
385
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
386
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
385
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
386
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
387 387
                 'mid_size'  => 1,
388 388
                 'add_args'  => array(),
389
-            ) );
389
+            ));
390 390
         }
391 391
     }
392 392
 
393 393
     public function has_invoices() {
394
-        return (bool) ! empty( $this->invoice_count );
394
+        return (bool)!empty($this->invoice_count);
395 395
     }
396 396
 
397 397
     public function next_invoice() {
398 398
         $this->current_invoice++;
399
-        $this->invoice = $this->invoices[ $this->current_invoice ];
399
+        $this->invoice = $this->invoices[$this->current_invoice];
400 400
 
401 401
         return $this->invoice;
402 402
     }
403 403
 
404 404
     public function rewind_invoices() {
405 405
         $this->current_invoice = -1;
406
-        if ( $this->invoice_count > 0 ) {
406
+        if ($this->invoice_count > 0) {
407 407
             $this->invoice = $this->invoices[0];
408 408
         }
409 409
     }
410 410
 
411 411
     public function invoices() {
412
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
412
+        if (($this->current_invoice + 1) < $this->invoice_count) {
413 413
             return true;
414
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
414
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
415 415
 
416
-            do_action( 'wpinv_bp_invoice_loop_end' );
416
+            do_action('wpinv_bp_invoice_loop_end');
417 417
             
418 418
             $this->rewind_invoices();
419 419
         }
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
         $this->in_the_loop = true;
428 428
         $this->invoice     = $this->next_invoice();
429 429
 
430
-        if ( 0 === $this->current_invoice ) {
431
-            do_action( 'wpinv_bp_invoice_loop_start' );
430
+        if (0 === $this->current_invoice) {
431
+            do_action('wpinv_bp_invoice_loop_start');
432 432
         }
433 433
     }
434 434
 }
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 
439 439
     $bp->invoicing = new WPInv_BP_Component();
440 440
     
441
-    add_action( 'wp_ajax_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
442
-    add_action( 'wp_ajax_nopriv_invoicing_filter', array( $bp->invoicing, 'invoices_content' ) );
443
-    add_filter( 'wpinv_settings_sections_general', array( $bp->invoicing, 'bp_section' ), 10, 1 );
444
-    add_filter( 'wpinv_settings_general', array( $bp->invoicing, 'bp_settings' ), 10, 1 );
441
+    add_action('wp_ajax_invoicing_filter', array($bp->invoicing, 'invoices_content'));
442
+    add_action('wp_ajax_nopriv_invoicing_filter', array($bp->invoicing, 'invoices_content'));
443
+    add_filter('wpinv_settings_sections_general', array($bp->invoicing, 'bp_section'), 10, 1);
444
+    add_filter('wpinv_settings_general', array($bp->invoicing, 'bp_settings'), 10, 1);
445 445
 }
446
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
447 446
\ No newline at end of file
447
+add_action('bp_loaded', 'wpinv_bp_setup_component');
448 448
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 3 patches
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.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -30,36 +30,36 @@  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_is_subscriptions_history_page() {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_send_to_success_page( $args = null ) {
72
-	$redirect = wpinv_get_success_page_uri();
72
+    $redirect = wpinv_get_success_page_uri();
73 73
     
74 74
     if ( !empty( $args ) ) {
75 75
         // Check for backward compatibility
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 }
90 90
 
91 91
 function wpinv_send_to_failed_page( $args = null ) {
92
-	$redirect = wpinv_get_failed_transaction_uri();
92
+    $redirect = wpinv_get_failed_transaction_uri();
93 93
     
94 94
     if ( !empty( $args ) ) {
95 95
         // Check for backward compatibility
@@ -109,72 +109,72 @@  discard block
 block discarded – undo
109 109
 }
110 110
 
111 111
 function wpinv_get_checkout_uri( $args = array() ) {
112
-	$uri = wpinv_get_option( 'checkout_page', false );
113
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
112
+    $uri = wpinv_get_option( 'checkout_page', false );
113
+    $uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
114 114
 
115
-	if ( !empty( $args ) ) {
116
-		// Check for backward compatibility
117
-		if ( is_string( $args ) )
118
-			$args = str_replace( '?', '', $args );
115
+    if ( !empty( $args ) ) {
116
+        // Check for backward compatibility
117
+        if ( is_string( $args ) )
118
+            $args = str_replace( '?', '', $args );
119 119
 
120
-		$args = wp_parse_args( $args );
120
+        $args = wp_parse_args( $args );
121 121
 
122
-		$uri = add_query_arg( $args, $uri );
123
-	}
122
+        $uri = add_query_arg( $args, $uri );
123
+    }
124 124
 
125
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
125
+    $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
126 126
 
127
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
127
+    $ajax_url = admin_url( 'admin-ajax.php', $scheme );
128 128
 
129
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
130
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
131
-	}
129
+    if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
130
+        $uri = preg_replace( '/^http:/', 'https:', $uri );
131
+    }
132 132
 
133
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
133
+    return apply_filters( 'wpinv_get_checkout_uri', $uri );
134 134
 }
135 135
 
136 136
 function wpinv_send_back_to_checkout( $args = array() ) {
137
-	$redirect = wpinv_get_checkout_uri();
137
+    $redirect = wpinv_get_checkout_uri();
138 138
 
139
-	if ( ! empty( $args ) ) {
140
-		// Check for backward compatibility
141
-		if ( is_string( $args ) )
142
-			$args = str_replace( '?', '', $args );
139
+    if ( ! empty( $args ) ) {
140
+        // Check for backward compatibility
141
+        if ( is_string( $args ) )
142
+            $args = str_replace( '?', '', $args );
143 143
 
144
-		$args = wp_parse_args( $args );
144
+        $args = wp_parse_args( $args );
145 145
 
146
-		$redirect = add_query_arg( $args, $redirect );
147
-	}
146
+        $redirect = add_query_arg( $args, $redirect );
147
+    }
148 148
 
149
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
150
-	exit;
149
+    wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
150
+    exit;
151 151
 }
152 152
 
153 153
 function wpinv_get_success_page_url( $query_string = null ) {
154
-	$success_page = wpinv_get_option( 'success_page', 0 );
155
-	$success_page = get_permalink( $success_page );
154
+    $success_page = wpinv_get_option( 'success_page', 0 );
155
+    $success_page = get_permalink( $success_page );
156 156
 
157
-	if ( $query_string )
158
-		$success_page .= $query_string;
157
+    if ( $query_string )
158
+        $success_page .= $query_string;
159 159
 
160
-	return apply_filters( 'wpinv_success_page_url', $success_page );
160
+    return apply_filters( 'wpinv_success_page_url', $success_page );
161 161
 }
162 162
 
163 163
 function wpinv_get_failed_transaction_uri( $extras = false ) {
164
-	$uri = wpinv_get_option( 'failure_page', '' );
165
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
164
+    $uri = wpinv_get_option( 'failure_page', '' );
165
+    $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
166 166
 
167
-	if ( $extras )
168
-		$uri .= $extras;
167
+    if ( $extras )
168
+        $uri .= $extras;
169 169
 
170
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
170
+    return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
171 171
 }
172 172
 
173 173
 function wpinv_is_failed_transaction_page() {
174
-	$ret = wpinv_get_option( 'failure_page', false );
175
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
174
+    $ret = wpinv_get_option( 'failure_page', false );
175
+    $ret = isset( $ret ) ? is_page( $ret ) : false;
176 176
 
177
-	return apply_filters( 'wpinv_is_failure_page', $ret );
177
+    return apply_filters( 'wpinv_is_failure_page', $ret );
178 178
 }
179 179
 
180 180
 function wpinv_transaction_query( $type = 'start' ) {
Please login to merge, or discard this patch.
Spacing   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -7,201 +7,201 @@  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 65
 function wpinv_is_subscriptions_history_page() {
66
-    $ret = wpinv_get_option( 'invoice_subscription_page', false );
67
-    $ret = $ret ? is_page( $ret ) : false;
68
-    return apply_filters( 'wpinv_is_subscriptions_history_page', $ret );
66
+    $ret = wpinv_get_option('invoice_subscription_page', false);
67
+    $ret = $ret ? is_page($ret) : false;
68
+    return apply_filters('wpinv_is_subscriptions_history_page', $ret);
69 69
 }
70 70
 
71
-function wpinv_send_to_success_page( $args = null ) {
71
+function wpinv_send_to_success_page($args = null) {
72 72
 	$redirect = wpinv_get_success_page_uri();
73 73
     
74
-    if ( !empty( $args ) ) {
74
+    if (!empty($args)) {
75 75
         // Check for backward compatibility
76
-        if ( is_string( $args ) )
77
-            $args = str_replace( '?', '', $args );
76
+        if (is_string($args))
77
+            $args = str_replace('?', '', $args);
78 78
 
79
-        $args = wp_parse_args( $args );
79
+        $args = wp_parse_args($args);
80 80
 
81
-        $redirect = add_query_arg( $args, $redirect );
81
+        $redirect = add_query_arg($args, $redirect);
82 82
     }
83 83
 
84
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
84
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
85 85
     
86
-    $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args );
87
-    wp_redirect( $redirect );
86
+    $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args);
87
+    wp_redirect($redirect);
88 88
     exit;
89 89
 }
90 90
 
91
-function wpinv_send_to_failed_page( $args = null ) {
91
+function wpinv_send_to_failed_page($args = null) {
92 92
 	$redirect = wpinv_get_failed_transaction_uri();
93 93
     
94
-    if ( !empty( $args ) ) {
94
+    if (!empty($args)) {
95 95
         // Check for backward compatibility
96
-        if ( is_string( $args ) )
97
-            $args = str_replace( '?', '', $args );
96
+        if (is_string($args))
97
+            $args = str_replace('?', '', $args);
98 98
 
99
-        $args = wp_parse_args( $args );
99
+        $args = wp_parse_args($args);
100 100
 
101
-        $redirect = add_query_arg( $args, $redirect );
101
+        $redirect = add_query_arg($args, $redirect);
102 102
     }
103 103
 
104
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
104
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
105 105
     
106
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
107
-    wp_redirect( $redirect );
106
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
107
+    wp_redirect($redirect);
108 108
     exit;
109 109
 }
110 110
 
111
-function wpinv_get_checkout_uri( $args = array() ) {
112
-	$uri = wpinv_get_option( 'checkout_page', false );
113
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
111
+function wpinv_get_checkout_uri($args = array()) {
112
+	$uri = wpinv_get_option('checkout_page', false);
113
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
114 114
 
115
-	if ( !empty( $args ) ) {
115
+	if (!empty($args)) {
116 116
 		// Check for backward compatibility
117
-		if ( is_string( $args ) )
118
-			$args = str_replace( '?', '', $args );
117
+		if (is_string($args))
118
+			$args = str_replace('?', '', $args);
119 119
 
120
-		$args = wp_parse_args( $args );
120
+		$args = wp_parse_args($args);
121 121
 
122
-		$uri = add_query_arg( $args, $uri );
122
+		$uri = add_query_arg($args, $uri);
123 123
 	}
124 124
 
125
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
125
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
126 126
 
127
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
127
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
128 128
 
129
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
130
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
129
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
130
+		$uri = preg_replace('/^http:/', 'https:', $uri);
131 131
 	}
132 132
 
133
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
133
+	return apply_filters('wpinv_get_checkout_uri', $uri);
134 134
 }
135 135
 
136
-function wpinv_send_back_to_checkout( $args = array() ) {
136
+function wpinv_send_back_to_checkout($args = array()) {
137 137
 	$redirect = wpinv_get_checkout_uri();
138 138
 
139
-	if ( ! empty( $args ) ) {
139
+	if (!empty($args)) {
140 140
 		// Check for backward compatibility
141
-		if ( is_string( $args ) )
142
-			$args = str_replace( '?', '', $args );
141
+		if (is_string($args))
142
+			$args = str_replace('?', '', $args);
143 143
 
144
-		$args = wp_parse_args( $args );
144
+		$args = wp_parse_args($args);
145 145
 
146
-		$redirect = add_query_arg( $args, $redirect );
146
+		$redirect = add_query_arg($args, $redirect);
147 147
 	}
148 148
 
149
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
149
+	wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args));
150 150
 	exit;
151 151
 }
152 152
 
153
-function wpinv_get_success_page_url( $query_string = null ) {
154
-	$success_page = wpinv_get_option( 'success_page', 0 );
155
-	$success_page = get_permalink( $success_page );
153
+function wpinv_get_success_page_url($query_string = null) {
154
+	$success_page = wpinv_get_option('success_page', 0);
155
+	$success_page = get_permalink($success_page);
156 156
 
157
-	if ( $query_string )
157
+	if ($query_string)
158 158
 		$success_page .= $query_string;
159 159
 
160
-	return apply_filters( 'wpinv_success_page_url', $success_page );
160
+	return apply_filters('wpinv_success_page_url', $success_page);
161 161
 }
162 162
 
163
-function wpinv_get_failed_transaction_uri( $extras = false ) {
164
-	$uri = wpinv_get_option( 'failure_page', '' );
165
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
163
+function wpinv_get_failed_transaction_uri($extras = false) {
164
+	$uri = wpinv_get_option('failure_page', '');
165
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
166 166
 
167
-	if ( $extras )
167
+	if ($extras)
168 168
 		$uri .= $extras;
169 169
 
170
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
170
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
171 171
 }
172 172
 
173 173
 function wpinv_is_failed_transaction_page() {
174
-	$ret = wpinv_get_option( 'failure_page', false );
175
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
174
+	$ret = wpinv_get_option('failure_page', false);
175
+	$ret = isset($ret) ? is_page($ret) : false;
176 176
 
177
-	return apply_filters( 'wpinv_is_failure_page', $ret );
177
+	return apply_filters('wpinv_is_failure_page', $ret);
178 178
 }
179 179
 
180
-function wpinv_transaction_query( $type = 'start' ) {
180
+function wpinv_transaction_query($type = 'start') {
181 181
     global $wpdb;
182 182
 
183 183
     $wpdb->hide_errors();
184 184
 
185
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
186
-        define( 'WPINV_USE_TRANSACTIONS', true );
185
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
186
+        define('WPINV_USE_TRANSACTIONS', true);
187 187
     }
188 188
 
189
-    if ( WPINV_USE_TRANSACTIONS ) {
190
-        switch ( $type ) {
189
+    if (WPINV_USE_TRANSACTIONS) {
190
+        switch ($type) {
191 191
             case 'commit' :
192
-                $wpdb->query( 'COMMIT' );
192
+                $wpdb->query('COMMIT');
193 193
                 break;
194 194
             case 'rollback' :
195
-                $wpdb->query( 'ROLLBACK' );
195
+                $wpdb->query('ROLLBACK');
196 196
                 break;
197 197
             default :
198
-                $wpdb->query( 'START TRANSACTION' );
198
+                $wpdb->query('START TRANSACTION');
199 199
             break;
200 200
         }
201 201
     }
202 202
 }
203 203
 
204
-function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) {
204
+function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) {
205 205
     $default_args = array(
206 206
         'status'        => '',
207 207
         'user_id'       => null,
@@ -211,63 +211,63 @@  discard block
 block discarded – undo
211 211
         'parent'        => 0
212 212
     );
213 213
 
214
-    $args           = wp_parse_args( $args, $default_args );
214
+    $args           = wp_parse_args($args, $default_args);
215 215
     $invoice_data   = array();
216 216
 
217
-    if ( $args['invoice_id'] > 0 ) {
218
-        $updating           = true;
217
+    if ($args['invoice_id'] > 0) {
218
+        $updating = true;
219 219
         $invoice_data['post_type']  = 'wpi_invoice';
220 220
         $invoice_data['ID']         = $args['invoice_id'];
221 221
     } else {
222 222
         $updating                       = false;
223 223
         $invoice_data['post_type']      = 'wpi_invoice';
224
-        $invoice_data['post_status']    = apply_filters( 'wpinv_default_invoice_status', 'wpi-pending' );
224
+        $invoice_data['post_status']    = apply_filters('wpinv_default_invoice_status', 'wpi-pending');
225 225
         $invoice_data['ping_status']    = 'closed';
226
-        $invoice_data['post_author']    = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
227
-        $invoice_data['post_title']     = wpinv_format_invoice_number( '0' );
228
-        $invoice_data['post_parent']    = absint( $args['parent'] );
229
-        if ( !empty( $args['created_date'] ) ) {
226
+        $invoice_data['post_author']    = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id();
227
+        $invoice_data['post_title']     = wpinv_format_invoice_number('0');
228
+        $invoice_data['post_parent']    = absint($args['parent']);
229
+        if (!empty($args['created_date'])) {
230 230
             $invoice_data['post_date']      = $args['created_date'];
231
-            $invoice_data['post_date_gmt']  = get_gmt_from_date( $args['created_date'] );
231
+            $invoice_data['post_date_gmt']  = get_gmt_from_date($args['created_date']);
232 232
         }
233 233
     }
234 234
 
235
-    if ( $args['status'] ) {
236
-        if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) {
237
-            return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) );
235
+    if ($args['status']) {
236
+        if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) {
237
+            return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status']));
238 238
         }
239
-        $invoice_data['post_status']    = $args['status'];
239
+        $invoice_data['post_status'] = $args['status'];
240 240
     }
241 241
 
242
-    if ( ! is_null( $args['user_note'] ) ) {
243
-        $invoice_data['post_excerpt']   = $args['user_note'];
242
+    if (!is_null($args['user_note'])) {
243
+        $invoice_data['post_excerpt'] = $args['user_note'];
244 244
     }
245 245
 
246
-    if ( $updating ) {
247
-        $invoice_id = wp_update_post( $invoice_data, true );
246
+    if ($updating) {
247
+        $invoice_id = wp_update_post($invoice_data, true);
248 248
     } else {
249
-        $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true );
249
+        $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true);
250 250
     }
251 251
 
252
-    if ( is_wp_error( $invoice_id ) ) {
252
+    if (is_wp_error($invoice_id)) {
253 253
         return $wp_error ? $invoice_id : 0;
254 254
     }
255 255
     
256
-    $invoice = wpinv_get_invoice( $invoice_id );
257
-
258
-    if ( !$updating ) {
259
-        update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) );
260
-        update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() );
261
-        update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) );
262
-        update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() );
263
-        update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() );
264
-        update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) );
256
+    $invoice = wpinv_get_invoice($invoice_id);
257
+
258
+    if (!$updating) {
259
+        update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_')));
260
+        update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency());
261
+        update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax'));
262
+        update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip());
263
+        update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent());
264
+        update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via']));
265 265
         
266 266
         // Add invoice note
267
-        $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
267
+        $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status)));
268 268
     }
269 269
 
270
-    update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION );
270
+    update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION);
271 271
 
272 272
     return $invoice;
273 273
 }
@@ -275,178 +275,178 @@  discard block
 block discarded – undo
275 275
 function wpinv_get_prefix() {
276 276
     $invoice_prefix = 'INV-';
277 277
     
278
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
278
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
279 279
 }
280 280
 
281 281
 function wpinv_get_business_logo() {
282
-    $business_logo = wpinv_get_option( 'logo' );
283
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
282
+    $business_logo = wpinv_get_option('logo');
283
+    return apply_filters('wpinv_get_business_logo', $business_logo);
284 284
 }
285 285
 
286 286
 function wpinv_get_business_name() {
287 287
     $business_name = wpinv_get_option('store_name');
288
-    return apply_filters( 'wpinv_get_business_name', $business_name );
288
+    return apply_filters('wpinv_get_business_name', $business_name);
289 289
 }
290 290
 
291 291
 function wpinv_get_blogname() {
292
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
292
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
293 293
 }
294 294
 
295 295
 function wpinv_get_admin_email() {
296
-    $admin_email = get_option( 'admin_email' );
297
-    return apply_filters( 'wpinv_admin_email', $admin_email );
296
+    $admin_email = get_option('admin_email');
297
+    return apply_filters('wpinv_admin_email', $admin_email);
298 298
 }
299 299
 
300 300
 function wpinv_get_business_website() {
301
-    $business_website = home_url( '/' );
302
-    return apply_filters( 'wpinv_get_business_website', $business_website );
301
+    $business_website = home_url('/');
302
+    return apply_filters('wpinv_get_business_website', $business_website);
303 303
 }
304 304
 
305
-function wpinv_get_terms_text( $invoice_id = 0 ) {
305
+function wpinv_get_terms_text($invoice_id = 0) {
306 306
     $terms_text = '';
307
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
307
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
308 308
 }
309 309
 
310 310
 function wpinv_get_business_footer() {
311
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
312
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
313
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
311
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
312
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
313
+    return apply_filters('wpinv_get_business_footer', $business_footer);
314 314
 }
315 315
 
316 316
 function wpinv_checkout_required_fields() {
317 317
     $required_fields = array();
318 318
     
319 319
     // Let payment gateways and other extensions determine if address fields should be required
320
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
320
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
321 321
     
322
-    if ( $require_billing_details ) {
322
+    if ($require_billing_details) {
323 323
         ///$required_fields['email'] = array(
324 324
                 ///'error_id' => 'invalid_email',
325 325
                 ///'error_message' => __( 'Please enter a valid email address', 'invoicing' )
326 326
             ///);
327 327
         $required_fields['first_name'] = array(
328 328
                 'error_id' => 'invalid_first_name',
329
-                'error_message' => __( 'Please enter your first name', 'invoicing' )
329
+                'error_message' => __('Please enter your first name', 'invoicing')
330 330
             );
331 331
         $required_fields['address'] = array(
332 332
                 'error_id' => 'invalid_address',
333
-                'error_message' => __( 'Please enter your address', 'invoicing' )
333
+                'error_message' => __('Please enter your address', 'invoicing')
334 334
             );
335 335
         $required_fields['city'] = array(
336 336
                 'error_id' => 'invalid_city',
337
-                'error_message' => __( 'Please enter your billing city', 'invoicing' )
337
+                'error_message' => __('Please enter your billing city', 'invoicing')
338 338
             );
339 339
         $required_fields['state'] = array(
340 340
                 'error_id' => 'invalid_state',
341
-                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
341
+                'error_message' => __('Please enter billing state / province', 'invoicing')
342 342
             );
343 343
         $required_fields['country'] = array(
344 344
                 'error_id' => 'invalid_country',
345
-                'error_message' => __( 'Please select your billing country', 'invoicing' )
345
+                'error_message' => __('Please select your billing country', 'invoicing')
346 346
             );
347 347
     }
348 348
 
349
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
349
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
350 350
 }
351 351
 
352 352
 function wpinv_is_ssl_enforced() {
353
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
354
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
353
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
354
+    return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
355 355
 }
356 356
 
357
-function wpinv_user_can_view_invoice( $post ) {
357
+function wpinv_user_can_view_invoice($post) {
358 358
     $allow = false;
359 359
 
360
-    $post = get_post( $post );
360
+    $post = get_post($post);
361 361
 
362
-    if ( empty( $post->ID ) ) {
362
+    if (empty($post->ID)) {
363 363
         return $allow;
364 364
     }
365 365
 
366
-    $invoice = wpinv_get_invoice( $post->ID );
367
-    if ( empty( $invoice->ID ) ) {
366
+    $invoice = wpinv_get_invoice($post->ID);
367
+    if (empty($invoice->ID)) {
368 368
         return $allow;
369 369
     }
370 370
 
371 371
     // Don't allow trash, draft status
372
-    if ( $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
373
-        if ( current_user_can( 'manage_options' ) ) { // Admin user
372
+    if ($invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
373
+        if (current_user_can('manage_options')) { // Admin user
374 374
             $allow = true;
375 375
         } else {
376
-            if ( is_user_logged_in() ) {
377
-                if ( (int)$invoice->get_user_id() === (int)get_current_user_id() ) {
376
+            if (is_user_logged_in()) {
377
+                if ((int)$invoice->get_user_id() === (int)get_current_user_id()) {
378 378
                     $allow = true;
379
-                } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
379
+                } else if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
380 380
                     $allow = true;
381 381
                 }
382 382
             } else {
383
-                if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
383
+                if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
384 384
                     $allow = true;
385 385
                 }
386 386
             }
387 387
         }
388 388
     }
389 389
     
390
-    return apply_filters( 'wpinv_can_print_invoice', $allow, $post, $invoice );
390
+    return apply_filters('wpinv_can_print_invoice', $allow, $post, $invoice);
391 391
 }
392 392
 
393 393
 function wpinv_schedule_events() {
394 394
     // hourly, daily and twicedaily
395
-    if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) {
396
-        wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' );
395
+    if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) {
396
+        wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily');
397 397
     }
398 398
 }
399
-add_action( 'wp', 'wpinv_schedule_events' );
399
+add_action('wp', 'wpinv_schedule_events');
400 400
 
401 401
 function wpinv_schedule_event_twicedaily() {
402 402
     wpinv_email_payment_reminders();
403 403
 }
404
-add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' );
404
+add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily');
405 405
 
406 406
 function wpinv_require_login_to_checkout() {
407
-    $return = wpinv_get_option( 'login_to_checkout', false );
408
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
407
+    $return = wpinv_get_option('login_to_checkout', false);
408
+    return (bool)apply_filters('wpinv_require_login_to_checkout', $return);
409 409
 }
410 410
 
411
-function wpinv_sequential_number_active( $type = '' ) {
412
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
413
-    if ( null !== $check ) {
411
+function wpinv_sequential_number_active($type = '') {
412
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
413
+    if (null !== $check) {
414 414
         return $check;
415 415
     }
416 416
     
417
-    return wpinv_get_option( 'sequential_invoice_number' );
417
+    return wpinv_get_option('sequential_invoice_number');
418 418
 }
419 419
 
420
-function wpinv_switch_to_locale( $locale = NULL ) {
420
+function wpinv_switch_to_locale($locale = NULL) {
421 421
     global $invoicing, $wpi_switch_locale;
422 422
 
423
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
424
-        $locale = empty( $locale ) ? get_locale() : $locale;
423
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
424
+        $locale = empty($locale) ? get_locale() : $locale;
425 425
 
426
-        switch_to_locale( $locale );
426
+        switch_to_locale($locale);
427 427
 
428 428
         $wpi_switch_locale = $locale;
429 429
 
430
-        add_filter( 'plugin_locale', 'get_locale' );
430
+        add_filter('plugin_locale', 'get_locale');
431 431
 
432 432
         $invoicing->load_textdomain();
433 433
 
434
-        do_action( 'wpinv_switch_to_locale', $locale );
434
+        do_action('wpinv_switch_to_locale', $locale);
435 435
     }
436 436
 }
437 437
 
438 438
 function wpinv_restore_locale() {
439 439
     global $invoicing, $wpi_switch_locale;
440 440
     
441
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
441
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
442 442
         restore_previous_locale();
443 443
 
444 444
         $wpi_switch_locale = NULL;
445 445
 
446
-        remove_filter( 'plugin_locale', 'get_locale' );
446
+        remove_filter('plugin_locale', 'get_locale');
447 447
 
448 448
         $invoicing->load_textdomain();
449 449
 
450
-        do_action( 'wpinv_restore_locale' );
450
+        do_action('wpinv_restore_locale');
451 451
     }
452 452
 }
453 453
\ 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   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -1,73 +1,73 @@  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['start_date']  = __( 'Start Date', 'invoicing' );
42
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
43
-    $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['start_date']  = __('Start Date', 'invoicing');
42
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
43
+    $columns['status']      = __('Status', 'invoicing');
44 44
 
45 45
     return $columns;
46 46
 }
47 47
 
48
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
49
-function wpinv_discount_custom_column( $column ) {
48
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
49
+function wpinv_discount_custom_column($column) {
50 50
     global $post;
51 51
     
52 52
     $discount = $post;
53 53
 
54
-    switch ( $column ) {
54
+    switch ($column) {
55 55
         case 'name' :
56
-            echo get_the_title( $discount->ID );
56
+            echo get_the_title($discount->ID);
57 57
         break;
58 58
         case 'code' :
59
-            echo wpinv_get_discount_code( $discount->ID );
59
+            echo wpinv_get_discount_code($discount->ID);
60 60
         break;
61 61
         case 'amount' :
62
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
62
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
63 63
         break;
64 64
         case 'usage_limit' :
65
-            echo wpinv_get_discount_uses( $discount->ID );
65
+            echo wpinv_get_discount_uses($discount->ID);
66 66
         break;
67 67
         case 'usage' :
68
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
69
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
70
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
68
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
69
+            if (wpinv_get_discount_max_uses($discount->ID)) {
70
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
71 71
             } else {
72 72
                 $usage .= ' &infin;';
73 73
             }
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
             echo $usage;
76 76
         break;
77 77
         case 'start_date' :
78
-            if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) {
79
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) );
78
+            if ($start_date = wpinv_get_discount_start_date($discount->ID)) {
79
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date));
80 80
             } else {
81 81
                 $value = '-';
82 82
             }
@@ -84,163 +84,163 @@  discard block
 block discarded – undo
84 84
             echo $value;
85 85
         break;
86 86
         case 'expiry_date' :
87
-            if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) {
88
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) );
87
+            if ($expiration = wpinv_get_discount_expiration($discount->ID)) {
88
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration));
89 89
             } else {
90
-                $value = __( 'Never', 'invoicing' );
90
+                $value = __('Never', 'invoicing');
91 91
             }
92 92
                 
93 93
             echo $value;
94 94
         break;
95 95
         break;
96 96
         case 'description' :
97
-            echo wp_kses_post( $post->post_excerpt );
97
+            echo wp_kses_post($post->post_excerpt);
98 98
         break;
99 99
         case 'status' :
100
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
100
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
101 101
             
102
-            echo wpinv_discount_status( $status );
102
+            echo wpinv_discount_status($status);
103 103
         break;
104 104
     }
105 105
 }
106 106
 
107
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
108
-function wpinv_post_row_actions( $actions, $post ) {
109
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
107
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
108
+function wpinv_post_row_actions($actions, $post) {
109
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
110 110
     
111
-    if ( $post_type == 'wpi_invoice' ) {
111
+    if ($post_type == 'wpi_invoice') {
112 112
         $actions = array();
113 113
     }
114 114
     
115
-    if ( $post_type == 'wpi_discount' ) {
116
-        $actions = wpinv_discount_row_actions( $post, $actions );
115
+    if ($post_type == 'wpi_discount') {
116
+        $actions = wpinv_discount_row_actions($post, $actions);
117 117
     }
118 118
     
119 119
     return $actions;
120 120
 }
121 121
 
122
-function wpinv_discount_row_actions( $discount, $row_actions ) {
123
-    $row_actions  = array();
124
-    $edit_link = get_edit_post_link( $discount->ID );
125
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
122
+function wpinv_discount_row_actions($discount, $row_actions) {
123
+    $row_actions = array();
124
+    $edit_link = get_edit_post_link($discount->ID);
125
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
126 126
 
127
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
128
-        $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>';
129
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
130
-        $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>';
127
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
128
+        $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>';
129
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
130
+        $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>';
131 131
     }
132 132
 
133
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
134
-        if ( isset( $row_actions['delete'] ) ) {
135
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
133
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
134
+        if (isset($row_actions['delete'])) {
135
+            unset($row_actions['delete']); // Don't delete used discounts.
136 136
         }
137 137
     } else {
138
-        $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>';
138
+        $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>';
139 139
     }
140 140
     
141 141
 
142
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
142
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
143 143
 
144 144
     return $row_actions;
145 145
 }
146 146
 
147
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
148
-function wpinv_table_primary_column( $default, $screen_id ) {
149
-    if ( 'edit-wpi_invoice' === $screen_id ) {
147
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
148
+function wpinv_table_primary_column($default, $screen_id) {
149
+    if ('edit-wpi_invoice' === $screen_id) {
150 150
         return 'name';
151 151
     }
152 152
     
153 153
     return $default;
154 154
 }
155 155
 
156
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
157
-    if ( !$display ) {
156
+function wpinv_discount_bulk_actions($actions, $display = false) {    
157
+    if (!$display) {
158 158
         return array();
159 159
     }
160 160
     
161 161
     $actions = array(
162
-        'activate'   => __( 'Activate', 'invoicing' ),
163
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
164
-        'delete'     => __( 'Delete', 'invoicing' ),
162
+        'activate'   => __('Activate', 'invoicing'),
163
+        'deactivate' => __('Deactivate', 'invoicing'),
164
+        'delete'     => __('Delete', 'invoicing'),
165 165
     );
166 166
     $two = '';
167 167
     $which = 'top';
168 168
     echo '</div><div class="alignleft actions bulkactions">';
169
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
170
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
171
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
169
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
170
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
171
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
172 172
 
173
-    foreach ( $actions as $name => $title ) {
173
+    foreach ($actions as $name => $title) {
174 174
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
175 175
 
176 176
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
177 177
     }
178 178
     echo "</select>";
179 179
 
180
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
180
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
181 181
     
182 182
     echo '</div><div class="alignleft actions">';
183 183
 }
184
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
184
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
185 185
 
186
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
187
-    if ( $post_type == 'wpi_discount' ) {
186
+function wpinv_disable_months_dropdown($disable, $post_type) {
187
+    if ($post_type == 'wpi_discount') {
188 188
         $disable = true;
189 189
     }
190 190
     
191 191
     return $disable;
192 192
 }
193
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
193
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
194 194
 
195 195
 function wpinv_restrict_manage_posts() {
196 196
     global $typenow;
197 197
 
198
-    if( 'wpi_discount' == $typenow ) {
198
+    if ('wpi_discount' == $typenow) {
199 199
         wpinv_discount_filters();
200 200
     }
201 201
 }
202
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
202
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
203 203
 
204 204
 function wpinv_discount_filters() {
205
-    echo wpinv_discount_bulk_actions( array(), true );
205
+    echo wpinv_discount_bulk_actions(array(), true);
206 206
     
207 207
     ?>
208 208
     <select name="discount_type" id="dropdown_wpinv_discount_type">
209
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
209
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
210 210
         <?php
211 211
             $types = wpinv_get_discount_types();
212 212
 
213
-            foreach ( $types as $name => $type ) {
214
-                echo '<option value="' . esc_attr( $name ) . '"';
213
+            foreach ($types as $name => $type) {
214
+                echo '<option value="' . esc_attr($name) . '"';
215 215
 
216
-                if ( isset( $_GET['discount_type'] ) )
217
-                    selected( $name, $_GET['discount_type'] );
216
+                if (isset($_GET['discount_type']))
217
+                    selected($name, $_GET['discount_type']);
218 218
 
219
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
219
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
220 220
             }
221 221
         ?>
222 222
     </select>
223 223
     <?php
224 224
 }
225 225
 
226
-function wpinv_request( $vars ) {
226
+function wpinv_request($vars) {
227 227
     global $typenow, $wp_query, $wp_post_statuses;
228 228
 
229
-    if ( 'wpi_invoice' === $typenow ) {
230
-        if ( !isset( $vars['post_status'] ) ) {
229
+    if ('wpi_invoice' === $typenow) {
230
+        if (!isset($vars['post_status'])) {
231 231
             $post_statuses = wpinv_get_invoice_statuses();
232 232
 
233
-            foreach ( $post_statuses as $status => $value ) {
234
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
235
-                    unset( $post_statuses[ $status ] );
233
+            foreach ($post_statuses as $status => $value) {
234
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
235
+                    unset($post_statuses[$status]);
236 236
                 }
237 237
             }
238 238
 
239
-            $vars['post_status'] = array_keys( $post_statuses );
239
+            $vars['post_status'] = array_keys($post_statuses);
240 240
         }
241 241
         
242
-        if ( isset( $vars['orderby'] ) ) {
243
-            if ( 'amount' == $vars['orderby'] ) {
242
+        if (isset($vars['orderby'])) {
243
+            if ('amount' == $vars['orderby']) {
244 244
                 $vars = array_merge(
245 245
                     $vars,
246 246
                     array(
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                         'orderby'  => 'meta_value_num'
249 249
                     )
250 250
                 );
251
-            } else if ( 'customer' == $vars['orderby'] ) {
251
+            } else if ('customer' == $vars['orderby']) {
252 252
                 $vars = array_merge(
253 253
                     $vars,
254 254
                     array(
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
                         'orderby'  => 'meta_value'
257 257
                     )
258 258
                 );
259
-            } else if ( 'number' == $vars['orderby'] ) {
259
+            } else if ('number' == $vars['orderby']) {
260 260
                 $vars = array_merge(
261 261
                     $vars,
262 262
                     array(
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
                         'orderby'  => 'meta_value'
265 265
                     )
266 266
                 );
267
-            } else if ( 'payment_date' == $vars['orderby'] ) {
267
+            } else if ('payment_date' == $vars['orderby']) {
268 268
                 $vars = array_merge(
269 269
                     $vars,
270 270
                     array(
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
                 );
275 275
             }
276 276
         }
277
-    } else if ( 'wpi_item' == $typenow ) {
277
+    } else if ('wpi_item' == $typenow) {
278 278
         // Check if 'orderby' is set to "price"
279
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
279
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
280 280
             $vars = array_merge(
281 281
                 $vars,
282 282
                 array(
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         }
288 288
 
289 289
         // Check if "orderby" is set to "vat_rule"
290
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
290
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
291 291
             $vars = array_merge(
292 292
                 $vars,
293 293
                 array(
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
         }
299 299
 
300 300
         // Check if "orderby" is set to "vat_class"
301
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
301
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
302 302
             $vars = array_merge(
303 303
                 $vars,
304 304
                 array(
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
         }
310 310
         
311 311
         // Check if "orderby" is set to "type"
312
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
312
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
313 313
             $vars = array_merge(
314 314
                 $vars,
315 315
                 array(
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         }
321 321
         
322 322
         // Check if "orderby" is set to "recurring"
323
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
323
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
324 324
             $vars = array_merge(
325 325
                 $vars,
326 326
                 array(
@@ -330,120 +330,120 @@  discard block
 block discarded – undo
330 330
             );
331 331
         }
332 332
 
333
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
333
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
334 334
         // Filter vat rule type
335
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
335
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
336 336
             $meta_query[] = array(
337 337
                     'key'   => '_wpinv_vat_rule',
338
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
338
+                    'value' => sanitize_text_field($_GET['vat_rule']),
339 339
                     'compare' => '='
340 340
                 );
341 341
         }
342 342
         
343 343
         // Filter vat class
344
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
344
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
345 345
             $meta_query[] = array(
346 346
                     'key'   => '_wpinv_vat_class',
347
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
347
+                    'value' => sanitize_text_field($_GET['vat_class']),
348 348
                     'compare' => '='
349 349
                 );
350 350
         }
351 351
         
352 352
         // Filter item type
353
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
353
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
354 354
             $meta_query[] = array(
355 355
                     'key'   => '_wpinv_type',
356
-                    'value' => sanitize_text_field( $_GET['type'] ),
356
+                    'value' => sanitize_text_field($_GET['type']),
357 357
                     'compare' => '='
358 358
                 );
359 359
         }
360 360
         
361
-        if ( !empty( $meta_query ) ) {
361
+        if (!empty($meta_query)) {
362 362
             $vars['meta_query'] = $meta_query;
363 363
         }
364
-    } else if ( 'wpi_discount' == $typenow ) {
365
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
364
+    } else if ('wpi_discount' == $typenow) {
365
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
366 366
         // Filter vat rule type
367
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
367
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
368 368
             $meta_query[] = array(
369 369
                     'key'   => '_wpi_discount_type',
370
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
370
+                    'value' => sanitize_text_field($_GET['discount_type']),
371 371
                     'compare' => '='
372 372
                 );
373 373
         }
374 374
         
375
-        if ( !empty( $meta_query ) ) {
375
+        if (!empty($meta_query)) {
376 376
             $vars['meta_query'] = $meta_query;
377 377
         }
378 378
     }
379 379
 
380 380
     return $vars;
381 381
 }
382
-add_filter( 'request', 'wpinv_request' );
382
+add_filter('request', 'wpinv_request');
383 383
 
384 384
 function wpinv_options_page() {
385
-    $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
385
+    $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
386 386
     
387
-    if ( $page !== 'wpinv-settings' ) {
387
+    if ($page !== 'wpinv-settings') {
388 388
         return;
389 389
     }
390 390
     
391 391
     $settings_tabs = wpinv_get_settings_tabs();
392 392
     $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
393
-    $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
394
-    $sections      = wpinv_get_settings_tab_sections( $active_tab );
393
+    $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
394
+    $sections      = wpinv_get_settings_tab_sections($active_tab);
395 395
     $key           = 'main';
396 396
 
397
-    if ( is_array( $sections ) ) {
398
-        $key = key( $sections );
397
+    if (is_array($sections)) {
398
+        $key = key($sections);
399 399
     }
400 400
 
401
-    $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
402
-    $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
401
+    $registered_sections = wpinv_get_settings_tab_sections($active_tab);
402
+    $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
403 403
     ob_start();
404 404
     ?>
405 405
     <div class="wrap">
406 406
         <h1 class="nav-tab-wrapper">
407 407
             <?php
408
-            foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
409
-                $tab_url = add_query_arg( array(
408
+            foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
409
+                $tab_url = add_query_arg(array(
410 410
                     'settings-updated' => false,
411 411
                     'tab' => $tab_id,
412
-                ) );
412
+                ));
413 413
 
414 414
                 // Remove the section from the tabs so we always end up at the main section
415
-                $tab_url = remove_query_arg( 'section', $tab_url );
416
-                $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
415
+                $tab_url = remove_query_arg('section', $tab_url);
416
+                $tab_url = remove_query_arg('wpi_sub', $tab_url);
417 417
 
418 418
                 $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
419 419
 
420
-                echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
421
-                    echo esc_html( $tab_name );
420
+                echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
421
+                    echo esc_html($tab_name);
422 422
                 echo '</a>';
423 423
             }
424 424
             ?>
425 425
         </h1>
426 426
         <?php
427
-        $number_of_sections = count( $sections );
427
+        $number_of_sections = count($sections);
428 428
         $number = 0;
429
-        if ( $number_of_sections > 1 ) {
429
+        if ($number_of_sections > 1) {
430 430
             echo '<div><ul class="subsubsub">';
431
-            foreach( $sections as $section_id => $section_name ) {
431
+            foreach ($sections as $section_id => $section_name) {
432 432
                 echo '<li>';
433 433
                 $number++;
434
-                $tab_url = add_query_arg( array(
434
+                $tab_url = add_query_arg(array(
435 435
                     'settings-updated' => false,
436 436
                     'tab' => $active_tab,
437 437
                     'section' => $section_id
438
-                ) );
439
-                $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
438
+                ));
439
+                $tab_url = remove_query_arg('wpi_sub', $tab_url);
440 440
                 $class = '';
441
-                if ( $section == $section_id ) {
441
+                if ($section == $section_id) {
442 442
                     $class = 'current';
443 443
                 }
444
-                echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
444
+                echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
445 445
 
446
-                if ( $number != $number_of_sections ) {
446
+                if ($number != $number_of_sections) {
447 447
                     echo ' | ';
448 448
                 }
449 449
                 echo '</li>';
@@ -455,19 +455,19 @@  discard block
 block discarded – undo
455 455
             <form method="post" action="options.php">
456 456
                 <table class="form-table">
457 457
                 <?php
458
-                settings_fields( 'wpinv_settings' );
458
+                settings_fields('wpinv_settings');
459 459
 
460
-                if ( 'main' === $section ) {
461
-                    do_action( 'wpinv_settings_tab_top', $active_tab );
460
+                if ('main' === $section) {
461
+                    do_action('wpinv_settings_tab_top', $active_tab);
462 462
                 }
463 463
 
464
-                do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
465
-                do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
466
-                do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
464
+                do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
465
+                do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
466
+                do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
467 467
 
468 468
                 // For backwards compatibility
469
-                if ( 'main' === $section ) {
470
-                    do_action( 'wpinv_settings_tab_bottom', $active_tab );
469
+                if ('main' === $section) {
470
+                    do_action('wpinv_settings_tab_bottom', $active_tab);
471 471
                 }
472 472
                 ?>
473 473
                 </table>
@@ -480,53 +480,53 @@  discard block
 block discarded – undo
480 480
     echo $content;
481 481
 }
482 482
 
483
-function wpinv_item_type_class( $classes, $class, $post_id ) {
483
+function wpinv_item_type_class($classes, $class, $post_id) {
484 484
     global $pagenow, $typenow;
485 485
 
486
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
487
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
488
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
486
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
487
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
488
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
489 489
         }
490 490
         
491
-        if ( !wpinv_item_is_editable( $post_id ) ) {
491
+        if (!wpinv_item_is_editable($post_id)) {
492 492
             $classes[] = 'wpi-editable-n';
493 493
         }
494 494
     }
495 495
     return $classes;
496 496
 }
497
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
497
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
498 498
 
499 499
 function wpinv_check_quick_edit() {
500 500
     global $pagenow, $current_screen, $wpinv_item_screen;
501 501
 
502
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
503
-        if ( empty( $wpinv_item_screen ) ) {
504
-            if ( $current_screen->post_type == 'wpi_item' ) {
502
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
503
+        if (empty($wpinv_item_screen)) {
504
+            if ($current_screen->post_type == 'wpi_item') {
505 505
                 $wpinv_item_screen = 'y';
506 506
             } else {
507 507
                 $wpinv_item_screen = 'n';
508 508
             }
509 509
         }
510 510
 
511
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
512
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
513
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
511
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
512
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
513
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
514 514
         }
515 515
     }
516 516
 }
517
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
517
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
518 518
 
519
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
520
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
521
-        unset( $actions['inline hide-if-no-js'] );
519
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
520
+    if (isset($actions['inline hide-if-no-js'])) {
521
+        unset($actions['inline hide-if-no-js']);
522 522
     }
523 523
     
524
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
525
-        if ( isset( $actions['trash'] ) ) {
526
-            unset( $actions['trash'] );
524
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
525
+        if (isset($actions['trash'])) {
526
+            unset($actions['trash']);
527 527
         }
528
-        if ( isset( $actions['delete'] ) ) {
529
-            unset( $actions['delete'] );
528
+        if (isset($actions['delete'])) {
529
+            unset($actions['delete']);
530 530
         }
531 531
     }
532 532
 
@@ -543,19 +543,19 @@  discard block
 block discarded – undo
543 543
  * @param int $post_parent (default: 0) Parent for the new page
544 544
  * @return int page ID
545 545
  */
546
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
546
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
547 547
     global $wpdb;
548 548
 
549
-    $option_value = wpinv_get_option( $option );
549
+    $option_value = wpinv_get_option($option);
550 550
 
551
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
552
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
551
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
552
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
553 553
             // Valid page is already in place
554 554
             return $page_object->ID;
555 555
         }
556 556
     }
557 557
 
558
-    if(!empty($post_parent)){
558
+    if (!empty($post_parent)) {
559 559
         $page = get_page_by_path($post_parent);
560 560
         if ($page) {
561 561
             $post_parent = $page->ID;
@@ -564,40 +564,40 @@  discard block
 block discarded – undo
564 564
         }
565 565
     }
566 566
 
567
-    if ( strlen( $page_content ) > 0 ) {
567
+    if (strlen($page_content) > 0) {
568 568
         // Search for an existing page with the specified page content (typically a shortcode)
569
-        $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}%" ) );
569
+        $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}%"));
570 570
     } else {
571 571
         // Search for an existing page with the specified page slug
572
-        $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 ) );
572
+        $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));
573 573
     }
574 574
 
575
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
575
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
576 576
 
577
-    if ( $valid_page_found ) {
578
-        if ( $option ) {
579
-            wpinv_update_option( $option, $valid_page_found );
577
+    if ($valid_page_found) {
578
+        if ($option) {
579
+            wpinv_update_option($option, $valid_page_found);
580 580
         }
581 581
         return $valid_page_found;
582 582
     }
583 583
 
584 584
     // Search for a matching valid trashed page
585
-    if ( strlen( $page_content ) > 0 ) {
585
+    if (strlen($page_content) > 0) {
586 586
         // Search for an existing page with the specified page content (typically a shortcode)
587
-        $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}%" ) );
587
+        $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}%"));
588 588
     } else {
589 589
         // Search for an existing page with the specified page slug
590
-        $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 ) );
590
+        $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));
591 591
     }
592 592
 
593
-    if ( $trashed_page_found ) {
593
+    if ($trashed_page_found) {
594 594
         $page_id   = $trashed_page_found;
595 595
         $page_data = array(
596 596
             'ID'             => $page_id,
597 597
             'post_status'    => 'publish',
598 598
             'post_parent'    => $post_parent,
599 599
         );
600
-        wp_update_post( $page_data );
600
+        wp_update_post($page_data);
601 601
     } else {
602 602
         $page_data = array(
603 603
             'post_status'    => 'publish',
@@ -609,11 +609,11 @@  discard block
 block discarded – undo
609 609
             'post_parent'    => $post_parent,
610 610
             'comment_status' => 'closed',
611 611
         );
612
-        $page_id = wp_insert_post( $page_data );
612
+        $page_id = wp_insert_post($page_data);
613 613
     }
614 614
 
615
-    if ( $option ) {
616
-        wpinv_update_option( $option, (int)$page_id );
615
+    if ($option) {
616
+        wpinv_update_option($option, (int)$page_id);
617 617
     }
618 618
 
619 619
     return $page_id;
Please login to merge, or discard this patch.
includes/wpinv-error-functions.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
         ) );
14 14
         echo '<div class="' . implode( ' ', $classes ) . '">';
15 15
             // Loop error codes and display errors
16
-           foreach ( $errors as $error_id => $error ) {
16
+            foreach ( $errors as $error_id => $error ) {
17 17
                 echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>';
18
-           }
18
+            }
19 19
         echo '</div>';
20 20
         wpinv_clear_errors();
21 21
     }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,61 +1,61 @@  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 7
 function wpinv_print_errors() {
8 8
     $errors = wpinv_get_errors();
9 9
 
10
-    if ( $errors ) {
11
-        $classes = apply_filters( 'wpinv_error_class', array(
10
+    if ($errors) {
11
+        $classes = apply_filters('wpinv_error_class', array(
12 12
             'wpinv_errors', 'wpinv-alert', 'wpinv-alert-error'
13
-        ) );
14
-        echo '<div class="' . implode( ' ', $classes ) . '">';
13
+        ));
14
+        echo '<div class="' . implode(' ', $classes) . '">';
15 15
             // Loop error codes and display errors
16
-           foreach ( $errors as $error_id => $error ) {
17
-                echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>';
16
+           foreach ($errors as $error_id => $error) {
17
+                echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __('Error', 'invoicing') . '</strong>: ' . $error . '</p>';
18 18
            }
19 19
         echo '</div>';
20 20
         wpinv_clear_errors();
21 21
     }
22 22
 }
23
-add_action( 'wpinv_purchase_form_before_submit', 'wpinv_print_errors' );
24
-add_action( 'wpinv_ajax_checkout_errors', 'wpinv_print_errors' );
23
+add_action('wpinv_purchase_form_before_submit', 'wpinv_print_errors');
24
+add_action('wpinv_ajax_checkout_errors', 'wpinv_print_errors');
25 25
 
26 26
 function wpinv_get_errors() {
27 27
     global $wpi_session;
28 28
     
29
-    return $wpi_session->get( 'wpinv_errors' );
29
+    return $wpi_session->get('wpinv_errors');
30 30
 }
31 31
 
32
-function wpinv_set_error( $error_id, $error_message ) {
32
+function wpinv_set_error($error_id, $error_message) {
33 33
     global $wpi_session;
34 34
     
35 35
     $errors = wpinv_get_errors();
36 36
 
37
-    if ( ! $errors ) {
37
+    if (!$errors) {
38 38
         $errors = array();
39 39
     }
40 40
 
41
-    $errors[ $error_id ] = $error_message;
42
-    $wpi_session->set( 'wpinv_errors', $errors );
41
+    $errors[$error_id] = $error_message;
42
+    $wpi_session->set('wpinv_errors', $errors);
43 43
 }
44 44
 
45 45
 function wpinv_clear_errors() {
46 46
     global $wpi_session;
47 47
     
48
-    $wpi_session->set( 'wpinv_errors', null );
48
+    $wpi_session->set('wpinv_errors', null);
49 49
 }
50 50
 
51
-function wpinv_unset_error( $error_id ) {
51
+function wpinv_unset_error($error_id) {
52 52
     global $wpi_session;
53 53
     
54 54
     $errors = wpinv_get_errors();
55 55
 
56
-    if ( $errors ) {
57
-        unset( $errors[ $error_id ] );
58
-        $wpi_session->set( 'wpinv_errors', $errors );
56
+    if ($errors) {
57
+        unset($errors[$error_id]);
58
+        $wpi_session->set('wpinv_errors', $errors);
59 59
     }
60 60
 }
61 61
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
     die();
64 64
 }
65 65
 
66
-function wpinv_die( $message = '', $title = '', $status = 400 ) {
67
-    add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 );
68
-    add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 );
69
-    wp_die( $message, $title, array( 'response' => $status ));
66
+function wpinv_die($message = '', $title = '', $status = 400) {
67
+    add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3);
68
+    add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3);
69
+    wp_die($message, $title, array('response' => $status));
70 70
 }
Please login to merge, or discard this patch.