Completed
Push — master ( 6296d1...46c666 )
by Stiofan
12s
created
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  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
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {        
8
+    public static function output($post) {        
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
         
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22 22
         $item_types         = wpinv_get_item_types();
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
         }
30 30
         
31 31
         $cols = 5;
32
-        if ( $item_quantities ) {
32
+        if ($item_quantities) {
33 33
             $cols++;
34 34
         }
35
-        if ( $use_taxes ) {
35
+        if ($use_taxes) {
36 36
             $cols++;
37 37
         }
38 38
         $class = '';
39
-        if ( $invoice->is_paid() ) {
39
+        if ($invoice->is_paid()) {
40 40
             $class .= ' wpinv-paid';
41 41
         }
42
-        if ( $invoice->is_refunded() ) {
42
+        if ($invoice->is_refunded()) {
43 43
             $class .= ' wpinv-refunded';
44 44
         }
45
-        if ( $is_recurring ) {
45
+        if ($is_recurring) {
46 46
             $class .= ' wpi-recurring';
47 47
         }
48 48
         ?>
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
51 51
                 <thead>
52 52
                     <tr>
53
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
54
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
55
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
56
-                        <?php if ( $item_quantities ) { ?>
57
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
53
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
54
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
55
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
56
+                        <?php if ($item_quantities) { ?>
57
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
58 58
                         <?php } ?>
59
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
60
-                        <?php if ( $use_taxes ) { ?>
61
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
59
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
60
+                        <?php if ($use_taxes) { ?>
61
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
62 62
                         <?php } ?>
63 63
                         <th class="action"></th>
64 64
                     </tr>
65 65
                 </thead>
66 66
                 <tbody class="wpinv-line-items">
67
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
67
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
68 68
                 </tbody>
69 69
                 <tfoot class="wpinv-totals">
70 70
                     <tr>
@@ -76,44 +76,44 @@  discard block
 block discarded – undo
76 76
                                         </td>
77 77
                                         <td class="title">
78 78
                                             <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]">
79
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
79
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
80 80
                                             <div class="wp-clearfix">
81 81
                                                 <label class="wpi-vat-rule">
82
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
82
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
83 83
                                                     <span class="input-text-wrap">
84
-                                                        <?php echo wpinv_html_select( array(
84
+                                                        <?php echo wpinv_html_select(array(
85 85
                                                             'options'          => $wpinv_euvat->get_rules(),
86 86
                                                             'name'             => '_wpinv_quick[vat_rule]',
87 87
                                                             'id'               => '_wpinv_quick_vat_rule',
88 88
                                                             'show_option_all'  => false,
89 89
                                                             'show_option_none' => false,
90 90
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
91
-                                                        ) ); ?>
91
+                                                        )); ?>
92 92
                                                     </span>
93 93
                                                 </label>
94 94
                                             </div>
95
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
95
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
96 96
                                             <div class="wp-clearfix">
97 97
                                                 <label class="wpi-vat-class">
98
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
98
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
99 99
                                                     <span class="input-text-wrap">
100
-                                                        <?php echo wpinv_html_select( array(
100
+                                                        <?php echo wpinv_html_select(array(
101 101
                                                             'options'          => $wpinv_euvat->get_all_classes(),
102 102
                                                             'name'             => '_wpinv_quick[vat_class]',
103 103
                                                             'id'               => '_wpinv_quick_vat_class',
104 104
                                                             'show_option_all'  => false,
105 105
                                                             'show_option_none' => false,
106 106
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
107
-                                                        ) ); ?>
107
+                                                        )); ?>
108 108
                                                     </span>
109 109
                                                 </label>
110 110
                                             </div>
111 111
                                             <?php } ?>
112 112
                                             <div class="wp-clearfix">
113 113
                                                 <label class="wpi-item-type">
114
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
114
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
115 115
                                                     <span class="input-text-wrap">
116
-                                                        <?php echo wpinv_html_select( array(
116
+                                                        <?php echo wpinv_html_select(array(
117 117
                                                             'options'          => $item_types,
118 118
                                                             'name'             => '_wpinv_quick[type]',
119 119
                                                             'id'               => '_wpinv_quick_type',
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                                                             'show_option_all'  => false,
122 122
                                                             'show_option_none' => false,
123 123
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
124
-                                                        ) ); ?>
124
+                                                        )); ?>
125 125
                                                     </span>
126 126
                                                 </label>
127 127
                                             </div>
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
                                             </div>
135 135
                                         </td>
136 136
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
137
-                                        <?php if ( $item_quantities ) { ?>
137
+                                        <?php if ($item_quantities) { ?>
138 138
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
139 139
                                         <?php } ?>
140 140
                                         <td class="total"></td>
141
-                                        <?php if ( $use_taxes ) { ?>
141
+                                        <?php if ($use_taxes) { ?>
142 142
                                         <td class="tax"></td>
143 143
                                         <?php } ?>
144 144
                                         <td class="action"></td>
@@ -151,29 +151,29 @@  discard block
 block discarded – undo
151 151
                         <td colspan="<?php echo $cols; ?>"></td>
152 152
                     </tr>
153 153
                     <tr class="totals">
154
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
154
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
155 155
                         <td colspan="4">
156 156
                             <table cellspacing="0" cellpadding="0">
157 157
                                 <tr class="subtotal">
158
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
159
-                                    <td class="total"><?php echo $subtotal;?></td>
158
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
159
+                                    <td class="total"><?php echo $subtotal; ?></td>
160 160
                                     <td class="action"></td>
161 161
                                 </tr>
162 162
                                 <tr class="discount">
163
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
164
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
163
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
164
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
165 165
                                     <td class="action"></td>
166 166
                                 </tr>
167
-                                <?php if ( $use_taxes ) { ?>
167
+                                <?php if ($use_taxes) { ?>
168 168
                                 <tr class="tax">
169
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
170
-                                    <td class="total"><?php echo $tax;?></td>
169
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
170
+                                    <td class="total"><?php echo $tax; ?></td>
171 171
                                     <td class="action"></td>
172 172
                                 </tr>
173 173
                                 <?php } ?>
174 174
                                 <tr class="total">
175
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
176
-                                    <td class="total"><?php echo $total;?></td>
175
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
176
+                                    <td class="total"><?php echo $total; ?></td>
177 177
                                     <td class="action"></td>
178 178
                                 </tr>
179 179
                             </table>
@@ -183,89 +183,89 @@  discard block
 block discarded – undo
183 183
             </table>
184 184
             <div class="wpinv-actions">
185 185
                 <?php
186
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
187
-                    if ( !$invoice->is_recurring() ) {
188
-                    echo wpinv_item_dropdown( array(
186
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
187
+                    if (!$invoice->is_recurring()) {
188
+                    echo wpinv_item_dropdown(array(
189 189
                         'name'             => 'wpinv_invoice_item',
190 190
                         'id'               => 'wpinv_invoice_item',
191 191
                         'with_packages'    => false,
192 192
                         'show_recurring'   => true,
193
-                    ) );
193
+                    ));
194 194
                     ?>
195
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
195
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
196 196
                     <?php } ?>
197
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
197
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
198 198
             </div>
199 199
         </div>
200 200
         <?php
201 201
     }
202 202
     
203
-    public static function prices( $post ) {        
203
+    public static function prices($post) {        
204 204
         $symbol         = wpinv_currency_symbol();
205 205
         $position       = wpinv_currency_position();
206
-        $item           = new WPInv_Item( $post->ID );
206
+        $item           = new WPInv_Item($post->ID);
207 207
         
208 208
         $price          = $item->get_price();
209 209
         $is_recurring   = $item->is_recurring();
210 210
         $period         = $item->get_recurring_period();
211
-        $interval       = absint( $item->get_recurring_interval() );
212
-        $times          = absint( $item->get_recurring_limit() );
211
+        $interval       = absint($item->get_recurring_interval());
212
+        $times          = absint($item->get_recurring_limit());
213 213
         $free_trial     = $item->has_free_trial();
214 214
         $trial_interval = $item->get_trial_interval();
215 215
         $trial_period   = $item->get_trial_period();
216 216
         
217 217
         $intervals      = array();
218
-        for ( $i = 1; $i <= 90; $i++ ) {
218
+        for ($i = 1; $i <= 90; $i++) {
219 219
             $intervals[$i] = $i;
220 220
         }
221 221
         
222
-        $interval       = $interval > 0 ? $interval : 1;
222
+        $interval = $interval > 0 ? $interval : 1;
223 223
         
224 224
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
225 225
         ?>
226
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_package(), true ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
227
-        <?php if ( $item->is_package() ) { ?>
228
-        <span class="description"><?php _e( 'GD package item price can be edited only from GD payment manager.', 'invoicing' ); ?></span>
226
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_package(), true); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
227
+        <?php if ($item->is_package()) { ?>
228
+        <span class="description"><?php _e('GD package item price can be edited only from GD payment manager.', 'invoicing'); ?></span>
229 229
         <?php } ?>
230 230
         </p>
231 231
         <p class="wpinv-row-is-recurring">
232 232
             <label for="wpinv_is_recurring">
233
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
234
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
233
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
234
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
235 235
             </label>
236 236
         </p>
237
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
238
-                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
239
-                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
237
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
238
+                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
239
+                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
240 240
                     'options'          => $intervals,
241 241
                     'name'             => 'wpinv_recurring_interval',
242 242
                     'id'               => 'wpinv_recurring_interval',
243 243
                     'selected'         => $interval,
244 244
                     'show_option_all'  => false,
245 245
                     'show_option_none' => false
246
-                ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
247
-                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
246
+                )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
247
+                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
248 248
                 <span class="clear wpi-trial-clr"></span>
249 249
                 <label class="wpinv-free-trial" for="wpinv_free_trial">
250
-                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
251
-                    <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
250
+                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
251
+                    <?php echo __('Offer free trial for', 'invoicing'); ?>
252 252
                 </label>
253 253
                 <label class="wpinv-trial-interval" for="wpinv_trial_interval">
254
-                    <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
254
+                    <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
255 255
                 </label>
256 256
         </p>
257
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
258
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
257
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
258
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
259 259
         <?php
260 260
     }
261 261
     
262
-    public static function vat_rules( $post ) {
262
+    public static function vat_rules($post) {
263 263
         global $wpinv_euvat;
264 264
         
265
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
265
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
266 266
         ?>
267
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
268
-        <?php echo wpinv_html_select( array(
267
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
268
+        <?php echo wpinv_html_select(array(
269 269
                     'options'          => $wpinv_euvat->get_rules(),
270 270
                     'name'             => 'wpinv_vat_rules',
271 271
                     'id'               => 'wpinv_vat_rules',
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
                     'show_option_all'  => false,
274 274
                     'show_option_none' => false,
275 275
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
276
-                ) ); ?>
276
+                )); ?>
277 277
         </p>
278
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
279
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
278
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
279
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
280 280
         <?php
281 281
     }
282 282
     
283
-    public static function vat_classes( $post ) {
283
+    public static function vat_classes($post) {
284 284
         global $wpinv_euvat;
285 285
         
286
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
286
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
287 287
         ?>
288
-        <p><?php echo wpinv_html_select( array(
288
+        <p><?php echo wpinv_html_select(array(
289 289
                     'options'          => $wpinv_euvat->get_all_classes(),
290 290
                     'name'             => 'wpinv_vat_class',
291 291
                     'id'               => 'wpinv_vat_class',
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
                     'show_option_all'  => false,
294 294
                     'show_option_none' => false,
295 295
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
296
-                ) ); ?>
296
+                )); ?>
297 297
         </p>
298
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
298
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
299 299
         <?php
300 300
     }
301 301
     
302
-    public static function item_info( $post ) {
303
-        $item_type = wpinv_get_item_type( $post->ID );
304
-        do_action( 'wpinv_item_info_metabox_before', $post );
302
+    public static function item_info($post) {
303
+        $item_type = wpinv_get_item_type($post->ID);
304
+        do_action('wpinv_item_info_metabox_before', $post);
305 305
         ?>
306
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
307
-        <?php echo wpinv_html_select( array(
306
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
307
+        <?php echo wpinv_html_select(array(
308 308
                     'options'          => wpinv_get_item_types(),
309 309
                     'name'             => 'wpinv_item_type',
310 310
                     'id'               => 'wpinv_item_type',
@@ -313,114 +313,114 @@  discard block
 block discarded – undo
313 313
                     'show_option_none' => false,
314 314
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
315 315
                     //'disabled'         => $item_type == 'package' ? true : false,
316
-                ) ); ?>
316
+                )); ?>
317 317
         </p>
318
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
318
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
319 319
         <?php
320
-        do_action( 'wpinv_item_info_metabox_after', $post );
320
+        do_action('wpinv_item_info_metabox_after', $post);
321 321
     }
322 322
     
323
-    public static function meta_values( $post ) {
324
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
323
+    public static function meta_values($post) {
324
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
325 325
             'type',
326 326
             'custom_id'
327
-        ) );
327
+        ));
328 328
         
329
-        if ( empty( $meta_keys ) ) {
329
+        if (empty($meta_keys)) {
330 330
             return;
331 331
         }
332 332
         
333
-        do_action( 'wpinv_meta_values_metabox_before', $post );
333
+        do_action('wpinv_meta_values_metabox_before', $post);
334 334
         
335
-        foreach ( $meta_keys as $meta_key ) {
335
+        foreach ($meta_keys as $meta_key) {
336 336
             ?>
337
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
337
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
338 338
             <?php 
339 339
         }
340 340
         
341
-        do_action( 'wpinv_meta_values_metabox_after', $post );
341
+        do_action('wpinv_meta_values_metabox_after', $post);
342 342
     }
343 343
     
344
-    public static function save( $post_id, $data, $post ) {
345
-        $invoice        = new WPInv_Invoice( $post_id );
344
+    public static function save($post_id, $data, $post) {
345
+        $invoice        = new WPInv_Invoice($post_id);
346 346
         
347 347
         // Billing
348
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
349
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
350
-        $company        = sanitize_text_field( $data['wpinv_company'] );
351
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
352
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
353
-        $address        = sanitize_text_field( $data['wpinv_address'] );
354
-        $city           = sanitize_text_field( $data['wpinv_city'] );
355
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
356
-        $country        = sanitize_text_field( $data['wpinv_country'] );
357
-        $state          = sanitize_text_field( $data['wpinv_state'] );
348
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
349
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
350
+        $company        = sanitize_text_field($data['wpinv_company']);
351
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
352
+        $phone          = sanitize_text_field($data['wpinv_phone']);
353
+        $address        = sanitize_text_field($data['wpinv_address']);
354
+        $city           = sanitize_text_field($data['wpinv_city']);
355
+        $zip            = sanitize_text_field($data['wpinv_zip']);
356
+        $country        = sanitize_text_field($data['wpinv_country']);
357
+        $state          = sanitize_text_field($data['wpinv_state']);
358 358
         
359 359
         // Details
360
-        $status         = sanitize_text_field( $data['wpinv_status'] );
361
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
362
-        $number         = sanitize_text_field( $data['wpinv_number'] );
363
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
360
+        $status         = sanitize_text_field($data['wpinv_status']);
361
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
362
+        $number         = sanitize_text_field($data['wpinv_number']);
363
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
364 364
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
365 365
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
366 366
         
367
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
367
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
368 368
         
369
-        $invoice->set( 'due_date', $due_date );
370
-        $invoice->set( 'first_name', $first_name );
371
-        $invoice->set( 'last_name', $last_name );
372
-        $invoice->set( 'company', $company );
373
-        $invoice->set( 'vat_number', $vat_number );
374
-        $invoice->set( 'phone', $phone );
375
-        $invoice->set( 'address', $address );
376
-        $invoice->set( 'city', $city );
377
-        $invoice->set( 'zip', $zip );
378
-        $invoice->set( 'country', $country );
379
-        $invoice->set( 'state', $state );
380
-        $invoice->set( 'status', $status );
369
+        $invoice->set('due_date', $due_date);
370
+        $invoice->set('first_name', $first_name);
371
+        $invoice->set('last_name', $last_name);
372
+        $invoice->set('company', $company);
373
+        $invoice->set('vat_number', $vat_number);
374
+        $invoice->set('phone', $phone);
375
+        $invoice->set('address', $address);
376
+        $invoice->set('city', $city);
377
+        $invoice->set('zip', $zip);
378
+        $invoice->set('country', $country);
379
+        $invoice->set('state', $state);
380
+        $invoice->set('status', $status);
381 381
         //$invoice->set( 'number', $number );
382 382
         //$invoice->set( 'discounts', $discounts );
383 383
         //$invoice->set( 'discount', $discount );
384
-        $invoice->set( 'ip', $ip );
384
+        $invoice->set('ip', $ip);
385 385
         $invoice->old_status = $_POST['original_post_status'];
386 386
         $invoice->currency = wpinv_get_currency();
387
-        if ( !empty( $data['wpinv_gateway'] ) ) {
388
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
387
+        if (!empty($data['wpinv_gateway'])) {
388
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
389 389
         }
390 390
         $saved = $invoice->save();
391 391
         
392 392
         // Check for payment notes
393
-        if ( !empty( $data['invoice_note'] ) ) {
394
-            $note               = wp_kses( $data['invoice_note'], array() );
395
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
393
+        if (!empty($data['invoice_note'])) {
394
+            $note               = wp_kses($data['invoice_note'], array());
395
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
396 396
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
397 397
         
398
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
398
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
399 399
         }
400 400
         
401 401
         // Update user address if empty.
402
-        if ( $saved && !empty( $invoice ) ) {
403
-            if ( $user_id = $invoice->get_user_id() ) {
404
-                $user_address = wpinv_get_user_address( $user_id, false );
402
+        if ($saved && !empty($invoice)) {
403
+            if ($user_id = $invoice->get_user_id()) {
404
+                $user_address = wpinv_get_user_address($user_id, false);
405 405
                 
406 406
                 if (empty($user_address['first_name'])) {
407
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
408
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
407
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
408
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
409 409
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
410
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
410
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
411 411
                 }
412 412
                 
413 413
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
414
-                    update_user_meta( $user_id, '_wpinv_address', $address );
415
-                    update_user_meta( $user_id, '_wpinv_city', $city );
416
-                    update_user_meta( $user_id, '_wpinv_state', $state );
417
-                    update_user_meta( $user_id, '_wpinv_country', $country );
418
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
419
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
414
+                    update_user_meta($user_id, '_wpinv_address', $address);
415
+                    update_user_meta($user_id, '_wpinv_city', $city);
416
+                    update_user_meta($user_id, '_wpinv_state', $state);
417
+                    update_user_meta($user_id, '_wpinv_country', $country);
418
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
419
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
420 420
                 }
421 421
             }
422 422
             
423
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
423
+            do_action('wpinv_invoice_metabox_saved', $invoice);
424 424
         }
425 425
         
426 426
         return $saved;
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 2 patches
Spacing   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -7,28 +7,28 @@  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
 class WPInv_Ajax {
15 15
     public static function init() {
16
-        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
17
-        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
16
+        add_action('init', array(__CLASS__, 'define_ajax'), 0);
17
+        add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
18 18
         self::add_ajax_events();
19 19
     }
20 20
 
21 21
     public static function define_ajax() {
22
-        if ( !empty( $_GET['wpinv-ajax'] ) ) {
23
-            if ( ! defined( 'DOING_AJAX' ) ) {
24
-                define( 'DOING_AJAX', true );
22
+        if (!empty($_GET['wpinv-ajax'])) {
23
+            if (!defined('DOING_AJAX')) {
24
+                define('DOING_AJAX', true);
25 25
             }
26
-            if ( ! defined( 'WC_DOING_AJAX' ) ) {
27
-                define( 'WC_DOING_AJAX', true );
26
+            if (!defined('WC_DOING_AJAX')) {
27
+                define('WC_DOING_AJAX', true);
28 28
             }
29 29
             // Turn off display_errors during AJAX events to prevent malformed JSON
30
-            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
31
-                @ini_set( 'display_errors', 0 );
30
+            if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
31
+                @ini_set('display_errors', 0);
32 32
             }
33 33
             $GLOBALS['wpdb']->hide_errors();
34 34
         }
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
     public static function do_wpinv_ajax() {
38 38
         global $wp_query;
39 39
 
40
-        if ( !empty( $_GET['wpinv-ajax'] ) ) {
41
-            $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) );
40
+        if (!empty($_GET['wpinv-ajax'])) {
41
+            $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax']));
42 42
         }
43 43
 
44
-        if ( $action = $wp_query->get( 'wpinv-ajax' ) ) {
44
+        if ($action = $wp_query->get('wpinv-ajax')) {
45 45
             self::wpinv_ajax_headers();
46
-            do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) );
46
+            do_action('wpinv_ajax_' . sanitize_text_field($action));
47 47
             die();
48 48
         }
49 49
     }
50 50
     
51 51
     private static function wpinv_ajax_headers() {
52 52
         send_origin_headers();
53
-        @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
54
-        @header( 'X-Robots-Tag: noindex' );
53
+        @header('Content-Type: text/html; charset=' . get_option('blog_charset'));
54
+        @header('X-Robots-Tag: noindex');
55 55
         send_nosniff_header();
56 56
         nocache_headers();
57
-        status_header( 200 );
57
+        status_header(200);
58 58
     }
59 59
     
60 60
     public static function add_ajax_events() {
@@ -77,39 +77,39 @@  discard block
 block discarded – undo
77 77
             'buy_items' => true,
78 78
         );
79 79
 
80
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
81
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
80
+        foreach ($ajax_events as $ajax_event => $nopriv) {
81
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
82 82
             
83
-            if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) {
84
-                define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 );
83
+            if (!defined('WPI_AJAX_' . strtoupper($nopriv))) {
84
+                define('WPI_AJAX_' . strtoupper($nopriv), 1);
85 85
             }
86 86
 
87
-            if ( $nopriv ) {
88
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
87
+            if ($nopriv) {
88
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
89 89
 
90
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
90
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
91 91
             }
92 92
         }
93 93
     }
94 94
     
95 95
     public static function add_note() {
96
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
96
+        check_ajax_referer('add-invoice-note', '_nonce');
97 97
 
98
-        if ( !current_user_can( 'manage_options' ) ) {
98
+        if (!current_user_can('manage_options')) {
99 99
             die(-1);
100 100
         }
101 101
 
102
-        $post_id   = absint( $_POST['post_id'] );
103
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
104
-        $note_type = sanitize_text_field( $_POST['note_type'] );
102
+        $post_id   = absint($_POST['post_id']);
103
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
104
+        $note_type = sanitize_text_field($_POST['note_type']);
105 105
 
106 106
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
107 107
 
108
-        if ( $post_id > 0 ) {
109
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
108
+        if ($post_id > 0) {
109
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
110 110
 
111
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
112
-                wpinv_get_invoice_note_line_item( $note_id );
111
+            if ($note_id > 0 && !is_wp_error($note_id)) {
112
+                wpinv_get_invoice_note_line_item($note_id);
113 113
             }
114 114
         }
115 115
 
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
     }
118 118
 
119 119
     public static function delete_note() {
120
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
120
+        check_ajax_referer('delete-invoice-note', '_nonce');
121 121
 
122
-        if ( !current_user_can( 'manage_options' ) ) {
122
+        if (!current_user_can('manage_options')) {
123 123
             die(-1);
124 124
         }
125 125
 
126 126
         $note_id = (int)$_POST['note_id'];
127 127
 
128
-        if ( $note_id > 0 ) {
129
-            wp_delete_comment( $note_id, true );
128
+        if ($note_id > 0) {
129
+            wp_delete_comment($note_id, true);
130 130
         }
131 131
 
132 132
         die();
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
     }
140 140
     
141 141
     public static function checkout() {
142
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
143
-            define( 'WPINV_CHECKOUT', true );
142
+        if (!defined('WPINV_CHECKOUT')) {
143
+            define('WPINV_CHECKOUT', true);
144 144
         }
145 145
 
146 146
         wpinv_process_checkout();
@@ -149,53 +149,53 @@  discard block
 block discarded – undo
149 149
     
150 150
     public static function add_invoice_item() {
151 151
         global $wpi_userID, $wpinv_ip_address_country;
152
-        check_ajax_referer( 'invoice-item', '_nonce' );
153
-        if ( !current_user_can( 'manage_options' ) ) {
152
+        check_ajax_referer('invoice-item', '_nonce');
153
+        if (!current_user_can('manage_options')) {
154 154
             die(-1);
155 155
         }
156 156
         
157
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
158
-        $invoice_id = absint( $_POST['invoice_id'] );
157
+        $item_id    = sanitize_text_field($_POST['item_id']);
158
+        $invoice_id = absint($_POST['invoice_id']);
159 159
         
160
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
160
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
161 161
             die();
162 162
         }
163 163
         
164
-        $invoice    = wpinv_get_invoice( $invoice_id );
165
-        if ( empty( $invoice ) ) {
164
+        $invoice = wpinv_get_invoice($invoice_id);
165
+        if (empty($invoice)) {
166 166
             die();
167 167
         }
168 168
         
169
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
169
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
170 170
             die(); // Don't allow modify items for paid invoice.
171 171
         }
172 172
         
173
-        if ( !empty( $_POST['user_id'] ) ) {
174
-            $wpi_userID = absint( $_POST['user_id'] ); 
173
+        if (!empty($_POST['user_id'])) {
174
+            $wpi_userID = absint($_POST['user_id']); 
175 175
         }
176 176
 
177
-        $item = new WPInv_Item( $item_id );
178
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
177
+        $item = new WPInv_Item($item_id);
178
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
179 179
             die();
180 180
         }
181 181
         
182 182
         // Validate item before adding to invoice because recurring item must be paid individually.
183
-        if ( !empty( $invoice->cart_details ) ) {
183
+        if (!empty($invoice->cart_details)) {
184 184
             $valid = true;
185 185
             
186
-            if ( $recurring_item = $invoice->get_recurring() ) {
187
-                if ( $recurring_item != $item_id ) {
186
+            if ($recurring_item = $invoice->get_recurring()) {
187
+                if ($recurring_item != $item_id) {
188 188
                     $valid = false;
189 189
                 }
190
-            } else if ( wpinv_is_recurring_item( $item_id ) ) {
190
+            } else if (wpinv_is_recurring_item($item_id)) {
191 191
                 $valid = false;
192 192
             }
193 193
             
194
-            if ( !$valid ) {
194
+            if (!$valid) {
195 195
                 $response               = array();
196 196
                 $response['success']    = false;
197
-                $response['msg']        = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' );
198
-                wp_send_json( $response );
197
+                $response['msg']        = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing');
198
+                wp_send_json($response);
199 199
             }
200 200
         }
201 201
         
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
         
204 204
         $data                   = array();
205 205
         $data['invoice_id']     = $invoice_id;
206
-        $data['cart_discounts'] = $invoice->get_discounts( true );
206
+        $data['cart_discounts'] = $invoice->get_discounts(true);
207 207
         
208
-        wpinv_set_checkout_session( $data );
208
+        wpinv_set_checkout_session($data);
209 209
         
210 210
         $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1;
211 211
 
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
             'fees'          => array()
221 221
         );
222 222
 
223
-        $invoice->add_item( $item_id, $args );
223
+        $invoice->add_item($item_id, $args);
224 224
         $invoice->save();
225 225
         
226
-        if ( empty( $_POST['country'] ) ) {
226
+        if (empty($_POST['country'])) {
227 227
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
228 228
         }
229
-        if ( empty( $_POST['state'] ) ) {
229
+        if (empty($_POST['state'])) {
230 230
             $_POST['state'] = $invoice->state;
231 231
         }
232 232
          
233
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
234
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
233
+        $invoice->country   = sanitize_text_field($_POST['country']);
234
+        $invoice->state     = sanitize_text_field($_POST['state']);
235 235
         
236
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
237
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
236
+        $invoice->set('country', sanitize_text_field($_POST['country']));
237
+        $invoice->set('state', sanitize_text_field($_POST['state']));
238 238
         
239 239
         $wpinv_ip_address_country = $invoice->country;
240 240
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
         
243 243
         $response                       = array();
244 244
         $response['success']            = true;
245
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
245
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
246 246
         $response['data']['subtotal']   = $invoice->get_subtotal();
247 247
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
248 248
         $response['data']['tax']        = $invoice->get_tax();
@@ -254,40 +254,40 @@  discard block
 block discarded – undo
254 254
         
255 255
         wpinv_set_checkout_session($checkout_session);
256 256
         
257
-        wp_send_json( $response );
257
+        wp_send_json($response);
258 258
     }
259 259
     
260 260
     public static function remove_invoice_item() {
261 261
         global $wpi_userID, $wpinv_ip_address_country;
262 262
         
263
-        check_ajax_referer( 'invoice-item', '_nonce' );
264
-        if ( !current_user_can( 'manage_options' ) ) {
263
+        check_ajax_referer('invoice-item', '_nonce');
264
+        if (!current_user_can('manage_options')) {
265 265
             die(-1);
266 266
         }
267 267
         
268
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
269
-        $invoice_id = absint( $_POST['invoice_id'] );
270
-        $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false;
268
+        $item_id    = sanitize_text_field($_POST['item_id']);
269
+        $invoice_id = absint($_POST['invoice_id']);
270
+        $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false;
271 271
         
272
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
272
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
273 273
             die();
274 274
         }
275 275
 
276
-        $invoice    = wpinv_get_invoice( $invoice_id );
277
-        if ( empty( $invoice ) ) {
276
+        $invoice = wpinv_get_invoice($invoice_id);
277
+        if (empty($invoice)) {
278 278
             die();
279 279
         }
280 280
         
281
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
281
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
282 282
             die(); // Don't allow modify items for paid invoice.
283 283
         }
284 284
         
285
-        if ( !empty( $_POST['user_id'] ) ) {
286
-            $wpi_userID = absint( $_POST['user_id'] ); 
285
+        if (!empty($_POST['user_id'])) {
286
+            $wpi_userID = absint($_POST['user_id']); 
287 287
         }
288 288
 
289
-        $item       = new WPInv_Item( $item_id );
290
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
289
+        $item = new WPInv_Item($item_id);
290
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
291 291
             die();
292 292
         }
293 293
         
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
         
296 296
         $data                   = array();
297 297
         $data['invoice_id']     = $invoice_id;
298
-        $data['cart_discounts'] = $invoice->get_discounts( true );
298
+        $data['cart_discounts'] = $invoice->get_discounts(true);
299 299
         
300
-        wpinv_set_checkout_session( $data );
300
+        wpinv_set_checkout_session($data);
301 301
 
302 302
         $args = array(
303 303
             'id'         => $item_id,
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
             'cart_index' => $cart_index
306 306
         );
307 307
 
308
-        $invoice->remove_item( $item_id, $args );
308
+        $invoice->remove_item($item_id, $args);
309 309
         $invoice->save();
310 310
         
311
-        if ( empty( $_POST['country'] ) ) {
311
+        if (empty($_POST['country'])) {
312 312
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
313 313
         }
314
-        if ( empty( $_POST['state'] ) ) {
314
+        if (empty($_POST['state'])) {
315 315
             $_POST['state'] = $invoice->state;
316 316
         }
317 317
          
318
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
319
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
318
+        $invoice->country   = sanitize_text_field($_POST['country']);
319
+        $invoice->state     = sanitize_text_field($_POST['state']);
320 320
         
321
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
322
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
321
+        $invoice->set('country', sanitize_text_field($_POST['country']));
322
+        $invoice->set('state', sanitize_text_field($_POST['state']));
323 323
         
324 324
         $wpinv_ip_address_country = $invoice->country;
325 325
         
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
         
328 328
         $response                       = array();
329 329
         $response['success']            = true;
330
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
330
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
331 331
         $response['data']['subtotal']   = $invoice->get_subtotal();
332 332
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
333 333
         $response['data']['tax']        = $invoice->get_tax();
@@ -339,40 +339,40 @@  discard block
 block discarded – undo
339 339
         
340 340
         wpinv_set_checkout_session($checkout_session);
341 341
         
342
-        wp_send_json( $response );
342
+        wp_send_json($response);
343 343
     }
344 344
     
345 345
     public static function create_invoice_item() {
346
-        check_ajax_referer( 'invoice-item', '_nonce' );
347
-        if ( !current_user_can( 'manage_options' ) ) {
346
+        check_ajax_referer('invoice-item', '_nonce');
347
+        if (!current_user_can('manage_options')) {
348 348
             die(-1);
349 349
         }
350 350
         
351
-        $invoice_id = absint( $_POST['invoice_id'] );
351
+        $invoice_id = absint($_POST['invoice_id']);
352 352
 
353 353
         // Find the item
354
-        if ( !is_numeric( $invoice_id ) ) {
354
+        if (!is_numeric($invoice_id)) {
355 355
             die();
356 356
         }        
357 357
         
358
-        $invoice     = wpinv_get_invoice( $invoice_id );
359
-        if ( empty( $invoice ) ) {
358
+        $invoice = wpinv_get_invoice($invoice_id);
359
+        if (empty($invoice)) {
360 360
             die();
361 361
         }
362 362
         
363 363
         // Validate item before adding to invoice because recurring item must be paid individually.
364
-        if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) {
364
+        if (!empty($invoice->cart_details) && $invoice->get_recurring()) {
365 365
             $response               = array();
366 366
             $response['success']    = false;
367
-            $response['msg']        = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' );
368
-            wp_send_json( $response );
367
+            $response['msg']        = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing');
368
+            wp_send_json($response);
369 369
         }        
370 370
         
371 371
         $save_item = $_POST['_wpinv_quick'];
372 372
         
373 373
         $meta               = array();
374 374
         $meta['type']       = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom';
375
-        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0;
375
+        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0;
376 376
         $meta['vat_rule']   = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital';
377 377
         $meta['vat_class']  = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard';
378 378
         
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
         $data['meta']           = $meta;
383 383
         
384 384
         $item = new WPInv_Item();
385
-        $item->create( $data );
385
+        $item->create($data);
386 386
         
387
-        if ( !empty( $item ) ) {
387
+        if (!empty($item)) {
388 388
             $_POST['item_id']   = $item->ID;
389 389
             $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1;
390 390
             
@@ -394,15 +394,15 @@  discard block
 block discarded – undo
394 394
     }
395 395
     
396 396
     public static function get_billing_details() {
397
-        check_ajax_referer( 'get-billing-details', '_nonce' );
397
+        check_ajax_referer('get-billing-details', '_nonce');
398 398
         
399
-        if ( !current_user_can( 'manage_options' ) ) {
399
+        if (!current_user_can('manage_options')) {
400 400
             die(-1);
401 401
         }
402 402
 
403 403
         $user_id            = (int)$_POST['user_id'];
404 404
         $billing_details    = wpinv_get_user_address($user_id);
405
-        $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
405
+        $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
406 406
         
407 407
         if (isset($billing_details['user_id'])) {
408 408
             unset($billing_details['user_id']);
@@ -416,20 +416,20 @@  discard block
 block discarded – undo
416 416
         $response['success']                    = true;
417 417
         $response['data']['billing_details']    = $billing_details;
418 418
         
419
-        wp_send_json( $response );
419
+        wp_send_json($response);
420 420
     }
421 421
     
422 422
     public static function admin_recalculate_totals() {
423 423
         global $wpi_userID, $wpinv_ip_address_country;
424 424
         
425
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
426
-        if ( !current_user_can( 'manage_options' ) ) {
425
+        check_ajax_referer('wpinv-nonce', '_nonce');
426
+        if (!current_user_can('manage_options')) {
427 427
             die(-1);
428 428
         }
429 429
         
430
-        $invoice_id = absint( $_POST['invoice_id'] );        
431
-        $invoice    = wpinv_get_invoice( $invoice_id );
432
-        if ( empty( $invoice ) ) {
430
+        $invoice_id = absint($_POST['invoice_id']);        
431
+        $invoice    = wpinv_get_invoice($invoice_id);
432
+        if (empty($invoice)) {
433 433
             die();
434 434
         }
435 435
         
@@ -437,23 +437,23 @@  discard block
 block discarded – undo
437 437
         
438 438
         $data                   = array();
439 439
         $data['invoice_id']     = $invoice_id;
440
-        $data['cart_discounts'] = $invoice->get_discounts( true );
440
+        $data['cart_discounts'] = $invoice->get_discounts(true);
441 441
         
442
-        wpinv_set_checkout_session( $data );
442
+        wpinv_set_checkout_session($data);
443 443
         
444
-        if ( !empty( $_POST['user_id'] ) ) {
445
-            $wpi_userID = absint( $_POST['user_id'] ); 
444
+        if (!empty($_POST['user_id'])) {
445
+            $wpi_userID = absint($_POST['user_id']); 
446 446
         }
447 447
         
448
-        if ( empty( $_POST['country'] ) ) {
448
+        if (empty($_POST['country'])) {
449 449
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
450 450
         }
451 451
             
452
-        $invoice->country = sanitize_text_field( $_POST['country'] );
453
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
454
-        if ( isset( $_POST['state'] ) ) {
455
-            $invoice->state = sanitize_text_field( $_POST['state'] );
456
-            $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
452
+        $invoice->country = sanitize_text_field($_POST['country']);
453
+        $invoice->set('country', sanitize_text_field($_POST['country']));
454
+        if (isset($_POST['state'])) {
455
+            $invoice->state = sanitize_text_field($_POST['state']);
456
+            $invoice->set('state', sanitize_text_field($_POST['state']));
457 457
         }
458 458
         
459 459
         $wpinv_ip_address_country = $invoice->country;
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         
463 463
         $response                       = array();
464 464
         $response['success']            = true;
465
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
465
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
466 466
         $response['data']['subtotal']   = $invoice->get_subtotal();
467 467
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
468 468
         $response['data']['tax']        = $invoice->get_tax();
@@ -474,25 +474,25 @@  discard block
 block discarded – undo
474 474
         
475 475
         wpinv_set_checkout_session($checkout_session);
476 476
         
477
-        wp_send_json( $response );
477
+        wp_send_json($response);
478 478
     }
479 479
     
480 480
     public static function admin_apply_discount() {
481 481
         global $wpi_userID;
482 482
         
483
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
484
-        if ( !current_user_can( 'manage_options' ) ) {
483
+        check_ajax_referer('wpinv-nonce', '_nonce');
484
+        if (!current_user_can('manage_options')) {
485 485
             die(-1);
486 486
         }
487 487
         
488
-        $invoice_id = absint( $_POST['invoice_id'] );
489
-        $discount_code = sanitize_text_field( $_POST['code'] );
490
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
488
+        $invoice_id = absint($_POST['invoice_id']);
489
+        $discount_code = sanitize_text_field($_POST['code']);
490
+        if (empty($invoice_id) || empty($discount_code)) {
491 491
             die();
492 492
         }
493 493
         
494
-        $invoice = wpinv_get_invoice( $invoice_id );
495
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
494
+        $invoice = wpinv_get_invoice($invoice_id);
495
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
496 496
             die();
497 497
         }
498 498
         
@@ -500,49 +500,49 @@  discard block
 block discarded – undo
500 500
         
501 501
         $data                   = array();
502 502
         $data['invoice_id']     = $invoice_id;
503
-        $data['cart_discounts'] = $invoice->get_discounts( true );
503
+        $data['cart_discounts'] = $invoice->get_discounts(true);
504 504
         
505
-        wpinv_set_checkout_session( $data );
505
+        wpinv_set_checkout_session($data);
506 506
         
507 507
         $response               = array();
508 508
         $response['success']    = false;
509
-        $response['msg']        = __( 'This discount is invalid.', 'invoicing' );
509
+        $response['msg']        = __('This discount is invalid.', 'invoicing');
510 510
         $response['data']['code'] = $discount_code;
511 511
         
512
-        if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) {
513
-            $discounts = wpinv_set_cart_discount( $discount_code );
512
+        if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) {
513
+            $discounts = wpinv_set_cart_discount($discount_code);
514 514
             
515 515
             $response['success'] = true;
516
-            $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
517
-        }  else {
516
+            $response['msg'] = __('Discount has been applied successfully.', 'invoicing');
517
+        } else {
518 518
             $errors = wpinv_get_errors();
519
-            if ( !empty( $errors['wpinv-discount-error'] ) ) {
519
+            if (!empty($errors['wpinv-discount-error'])) {
520 520
                 $response['msg'] = $errors['wpinv-discount-error'];
521 521
             }
522
-            wpinv_unset_error( 'wpinv-discount-error' );
522
+            wpinv_unset_error('wpinv-discount-error');
523 523
         }
524 524
         
525 525
         wpinv_set_checkout_session($checkout_session);
526 526
         
527
-        wp_send_json( $response );
527
+        wp_send_json($response);
528 528
     }
529 529
     
530 530
     public static function admin_remove_discount() {
531 531
         global $wpi_userID;
532 532
         
533
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
534
-        if ( !current_user_can( 'manage_options' ) ) {
533
+        check_ajax_referer('wpinv-nonce', '_nonce');
534
+        if (!current_user_can('manage_options')) {
535 535
             die(-1);
536 536
         }
537 537
         
538
-        $invoice_id = absint( $_POST['invoice_id'] );
539
-        $discount_code = sanitize_text_field( $_POST['code'] );
540
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
538
+        $invoice_id = absint($_POST['invoice_id']);
539
+        $discount_code = sanitize_text_field($_POST['code']);
540
+        if (empty($invoice_id) || empty($discount_code)) {
541 541
             die();
542 542
         }
543 543
         
544
-        $invoice = wpinv_get_invoice( $invoice_id );
545
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
544
+        $invoice = wpinv_get_invoice($invoice_id);
545
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
546 546
             die();
547 547
         }
548 548
         
@@ -550,38 +550,38 @@  discard block
 block discarded – undo
550 550
         
551 551
         $data                   = array();
552 552
         $data['invoice_id']     = $invoice_id;
553
-        $data['cart_discounts'] = $invoice->get_discounts( true );
553
+        $data['cart_discounts'] = $invoice->get_discounts(true);
554 554
         
555
-        wpinv_set_checkout_session( $data );
555
+        wpinv_set_checkout_session($data);
556 556
         
557 557
         $response               = array();
558 558
         $response['success']    = false;
559 559
         $response['msg']        = NULL;
560 560
         
561
-        $discounts  = wpinv_unset_cart_discount( $discount_code );
561
+        $discounts = wpinv_unset_cart_discount($discount_code);
562 562
         $response['success'] = true;
563
-        $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' );
563
+        $response['msg'] = __('Discount has been removed successfully.', 'invoicing');
564 564
         
565 565
         wpinv_set_checkout_session($checkout_session);
566 566
         
567
-        wp_send_json( $response );
567
+        wp_send_json($response);
568 568
     }
569 569
     
570 570
     public static function check_email() {
571
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
572
-        if ( !current_user_can( 'manage_options' ) ) {
571
+        check_ajax_referer('wpinv-nonce', '_nonce');
572
+        if (!current_user_can('manage_options')) {
573 573
             die(-1);
574 574
         }
575 575
         
576
-        $email = sanitize_text_field( $_POST['email'] );
576
+        $email = sanitize_text_field($_POST['email']);
577 577
         
578 578
         $response = array();
579
-        if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) {
579
+        if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) {
580 580
             $user_id            = $user_data->ID;
581 581
             $user_login         = $user_data->user_login;
582 582
             $display_name       = $user_data->display_name ? $user_data->display_name : $user_login;
583 583
             $billing_details    = wpinv_get_user_address($user_id);
584
-            $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
584
+            $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
585 585
             
586 586
             if (isset($billing_details['user_id'])) {
587 587
                 unset($billing_details['user_id']);
@@ -597,54 +597,54 @@  discard block
 block discarded – undo
597 597
             $response['data']['billing_details']    = $billing_details;
598 598
         }
599 599
         
600
-        wp_send_json( $response );
600
+        wp_send_json($response);
601 601
     }
602 602
     
603 603
     public static function run_tool() {
604
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
605
-        if ( !current_user_can( 'manage_options' ) ) {
604
+        check_ajax_referer('wpinv-nonce', '_nonce');
605
+        if (!current_user_can('manage_options')) {
606 606
             die(-1);
607 607
         }
608 608
         
609
-        $tool = sanitize_text_field( $_POST['tool'] );
609
+        $tool = sanitize_text_field($_POST['tool']);
610 610
         
611
-        do_action( 'wpinv_run_tool' );
611
+        do_action('wpinv_run_tool');
612 612
         
613
-        if ( !empty( $tool ) ) {
614
-            do_action( 'wpinv_tool_' . $tool );
613
+        if (!empty($tool)) {
614
+            do_action('wpinv_tool_' . $tool);
615 615
         }
616 616
     }
617 617
     
618 618
     public static function apply_discount() {
619 619
         global $wpi_userID;
620 620
         
621
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
621
+        check_ajax_referer('wpinv-nonce', '_nonce');
622 622
         
623 623
         $response = array();
624 624
         
625
-        if ( isset( $_POST['code'] ) ) {
626
-            $discount_code = sanitize_text_field( $_POST['code'] );
625
+        if (isset($_POST['code'])) {
626
+            $discount_code = sanitize_text_field($_POST['code']);
627 627
 
628 628
             $response['success']        = false;
629 629
             $response['msg']            = '';
630 630
             $response['data']['code']   = $discount_code;
631 631
             
632 632
             $invoice = wpinv_get_invoice_cart();
633
-            if ( empty( $invoice->ID ) ) {
634
-                $response['msg'] = __( 'Invalid checkout request.', 'invoicing' );
635
-                wp_send_json( $response );
633
+            if (empty($invoice->ID)) {
634
+                $response['msg'] = __('Invalid checkout request.', 'invoicing');
635
+                wp_send_json($response);
636 636
             }
637 637
 
638 638
             $wpi_userID = $invoice->get_user_id();
639 639
 
640
-            if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) {
641
-                $discount       = wpinv_get_discount_by_code( $discount_code );
642
-                $discounts      = wpinv_set_cart_discount( $discount_code );
643
-                $amount         = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
644
-                $total          = wpinv_get_cart_total( null, $discounts );
645
-                $cart_totals    = wpinv_recalculate_tax( true );
640
+            if (wpinv_is_discount_valid($discount_code, $wpi_userID)) {
641
+                $discount       = wpinv_get_discount_by_code($discount_code);
642
+                $discounts      = wpinv_set_cart_discount($discount_code);
643
+                $amount         = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
644
+                $total          = wpinv_get_cart_total(null, $discounts);
645
+                $cart_totals    = wpinv_recalculate_tax(true);
646 646
             
647
-                if ( !empty( $cart_totals ) ) {
647
+                if (!empty($cart_totals)) {
648 648
                     $response['success']        = true;
649 649
                     $response['data']           = $cart_totals;
650 650
                     $response['data']['code']   = $discount_code;
@@ -653,29 +653,29 @@  discard block
 block discarded – undo
653 653
                 }
654 654
             } else {
655 655
                 $errors = wpinv_get_errors();
656
-                $response['msg']  = $errors['wpinv-discount-error'];
657
-                wpinv_unset_error( 'wpinv-discount-error' );
656
+                $response['msg'] = $errors['wpinv-discount-error'];
657
+                wpinv_unset_error('wpinv-discount-error');
658 658
             }
659 659
 
660 660
             // Allow for custom discount code handling
661
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
661
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
662 662
         }
663 663
         
664
-        wp_send_json( $response );
664
+        wp_send_json($response);
665 665
     }
666 666
     
667 667
     public static function remove_discount() {
668
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
668
+        check_ajax_referer('wpinv-nonce', '_nonce');
669 669
         
670 670
         $response = array();
671 671
         
672
-        if ( isset( $_POST['code'] ) ) {
673
-            $discount_code  = sanitize_text_field( $_POST['code'] );
674
-            $discounts      = wpinv_unset_cart_discount( $discount_code );
675
-            $total          = wpinv_get_cart_total( null, $discounts );
676
-            $cart_totals    = wpinv_recalculate_tax( true );
672
+        if (isset($_POST['code'])) {
673
+            $discount_code  = sanitize_text_field($_POST['code']);
674
+            $discounts      = wpinv_unset_cart_discount($discount_code);
675
+            $total          = wpinv_get_cart_total(null, $discounts);
676
+            $cart_totals    = wpinv_recalculate_tax(true);
677 677
             
678
-            if ( !empty( $cart_totals ) ) {
678
+            if (!empty($cart_totals)) {
679 679
                 $response['success']        = true;
680 680
                 $response['data']           = $cart_totals;
681 681
                 $response['data']['code']   = $discount_code;
@@ -684,10 +684,10 @@  discard block
 block discarded – undo
684 684
             }
685 685
             
686 686
             // Allow for custom discount code handling
687
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
687
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
688 688
         }
689 689
         
690
-        wp_send_json( $response );
690
+        wp_send_json($response);
691 691
     }
692 692
 
693 693
 
@@ -696,20 +696,20 @@  discard block
 block discarded – undo
696 696
      *
697 697
      * @since 1.0.0
698 698
      */
699
-    public function buy_items(){
699
+    public function buy_items() {
700 700
 
701 701
         $user_id = get_current_user_id();
702
-        if(!$user_id ){ // if not logged in then lets redirect to the login page
702
+        if (!$user_id) { // if not logged in then lets redirect to the login page
703 703
 
704 704
             wp_send_json(array(
705
-                'success' => wp_login_url( wp_get_referer() )
705
+                'success' => wp_login_url(wp_get_referer())
706 706
             ));
707
-        }else{
707
+        } else {
708 708
 
709 709
             // only check nonce if logged in as it could be cached when logged out.
710
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
710
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
711 711
                 wp_send_json(array(
712
-                    'error' => __('Security checks failed.','invoicing')
712
+                    'error' => __('Security checks failed.', 'invoicing')
713 713
                 ));
714 714
                 wp_die();
715 715
             }
@@ -717,36 +717,36 @@  discard block
 block discarded – undo
717 717
             // allow to set a custom price through post_id
718 718
             $items = $_POST['items'];
719 719
             $related_post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : 0;
720
-            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id,'_wpi_custom_price',true)) : 0;
720
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
721 721
 
722 722
 
723 723
             $cart_items = array();
724
-            if($items){
725
-                $items = explode(',',$items);
726
-                foreach($items as $item){
724
+            if ($items) {
725
+                $items = explode(',', $items);
726
+                foreach ($items as $item) {
727 727
                     $item_id = $item;
728 728
                     $quantity = 1;
729 729
                     if (strpos($item, '|') !== false) {
730
-                        $item_parts = explode('|',$item);
730
+                        $item_parts = explode('|', $item);
731 731
                         $item_id = $item_parts[0];
732 732
                         $quantity = $item_parts[1];
733 733
                     }
734 734
 
735
-                    if($item_id && $quantity){
735
+                    if ($item_id && $quantity) {
736 736
                         $cart_items_arr = array(
737 737
                             'id'            => (int)$item_id,
738 738
                             'quantity'      => (int)$quantity
739 739
                         );
740 740
 
741 741
                         // if there is a related post id then add it to meta
742
-                        if($related_post_id){
742
+                        if ($related_post_id) {
743 743
                             $cart_items_arr['meta'] = array(
744 744
                                 'post_id'   => $related_post_id
745 745
                             );
746 746
                         }
747 747
 
748 748
                         // if there is a custom price then set it.
749
-                        if($custom_item_price){
749
+                        if ($custom_item_price) {
750 750
                             $cart_items_arr['custom_price'] = $custom_item_price;
751 751
 
752 752
                         }
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
              * @param int $related_post_id The related post id if any.
766 766
              * @since 1.0.0
767 767
              */
768
-            $cart_items = apply_filters('wpinv_buy_cart_items',$cart_items,$related_post_id);
768
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
769 769
 
770 770
 
771 771
             //make sure its not in the cart already, if it is then redirect to checkout.
772 772
             $cart_invoice = wpinv_get_invoice_cart();
773
-            if(isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items)==serialize($cart_items) ){
773
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
774 774
                 wp_send_json(array(
775 775
                     'success' =>  $cart_invoice->get_checkout_payment_url()
776 776
                 ));
@@ -779,25 +779,25 @@  discard block
 block discarded – undo
779 779
 
780 780
 
781 781
             // check if user has invoice with same items waiting to be paid.
782
-            $user_invoices = wpinv_get_users_invoices( $user_id , 1 , false , 'pending' );
783
-            if(!empty($user_invoices)){
782
+            $user_invoices = wpinv_get_users_invoices($user_id, 1, false, 'pending');
783
+            if (!empty($user_invoices)) {
784 784
 
785
-                foreach($user_invoices as $user_invoice){
785
+                foreach ($user_invoices as $user_invoice) {
786 786
                     $user_cart_details = array();
787
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
787
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
788 788
                     $cart_details = $invoice->get_cart_details();
789
-                    if(!empty($cart_details)){
790
-                        foreach($cart_details as $invoice_item){
789
+                    if (!empty($cart_details)) {
790
+                        foreach ($cart_details as $invoice_item) {
791 791
 
792 792
                             $ii_arr = array();
793 793
                             $ii_arr['id'] = (int)$invoice_item['id'];
794 794
                             $ii_arr['quantity'] = (int)$invoice_item['quantity'];
795 795
 
796
-                            if(isset($invoice_item['meta']) && !empty($invoice_item['meta'])){
796
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
797 797
                                 $ii_arr['meta'] = $invoice_item['meta'];
798 798
                             }
799 799
 
800
-                            if(isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])){
800
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
801 801
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
802 802
                             }
803 803
 
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
                         }
807 807
                     }
808 808
 
809
-                    if(!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)){
809
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
810 810
                         wp_send_json(array(
811 811
                             'success' =>  $invoice->get_checkout_payment_url()
812 812
                         ));
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 
820 820
 
821 821
             // Create invoice and send user to checkout
822
-            if(!empty($cart_items)){
822
+            if (!empty($cart_items)) {
823 823
 
824 824
                 $invoice_data = array(
825 825
                     'status'        =>  'wpi-pending',
@@ -829,26 +829,26 @@  discard block
 block discarded – undo
829 829
                 );
830 830
 
831 831
                 // default invoice args
832
-                $invoice_data['status']  = !empty( $invoice_data['status'] ) ? $invoice_data['status'] : 'pending';
833
-                $invoice_data['user_id'] = !empty( $invoice_data['user_id'] ) ? (int)$invoice_data['user_id'] : get_current_user_id();
832
+                $invoice_data['status']  = !empty($invoice_data['status']) ? $invoice_data['status'] : 'pending';
833
+                $invoice_data['user_id'] = !empty($invoice_data['user_id']) ? (int)$invoice_data['user_id'] : get_current_user_id();
834 834
 
835
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
835
+                $invoice = wpinv_insert_invoice($invoice_data, true);
836 836
 
837
-                if(isset($invoice->ID)){
837
+                if (isset($invoice->ID)) {
838 838
 
839 839
                     wp_send_json(array(
840 840
                         'success' =>  $invoice->get_checkout_payment_url()
841 841
                     ));
842 842
 
843
-                }else{
843
+                } else {
844 844
                     wp_send_json(array(
845
-                        'error' => __('Invoice failed to create','invoicing')
845
+                        'error' => __('Invoice failed to create', 'invoicing')
846 846
                     ));
847 847
                 }
848 848
 
849
-            }else{
849
+            } else {
850 850
                 wp_send_json(array(
851
-                    'error' => __('Items not valid.','invoicing')
851
+                    'error' => __('Items not valid.', 'invoicing')
852 852
                 ));
853 853
             }
854 854
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             
515 515
             $response['success'] = true;
516 516
             $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
517
-        }  else {
517
+        } else {
518 518
             $errors = wpinv_get_errors();
519 519
             if ( !empty( $errors['wpinv-discount-error'] ) ) {
520 520
                 $response['msg'] = $errors['wpinv-discount-error'];
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
             wp_send_json(array(
705 705
                 'success' => wp_login_url( wp_get_referer() )
706 706
             ));
707
-        }else{
707
+        } else{
708 708
 
709 709
             // only check nonce if logged in as it could be cached when logged out.
710 710
             if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
@@ -840,13 +840,13 @@  discard block
 block discarded – undo
840 840
                         'success' =>  $invoice->get_checkout_payment_url()
841 841
                     ));
842 842
 
843
-                }else{
843
+                } else{
844 844
                     wp_send_json(array(
845 845
                         'error' => __('Invoice failed to create','invoicing')
846 846
                     ));
847 847
                 }
848 848
 
849
-            }else{
849
+            } else{
850 850
                 wp_send_json(array(
851 851
                     'error' => __('Items not valid.','invoicing')
852 852
                 ));
Please login to merge, or discard this patch.
invoicing.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 */
12 12
 
13 13
 // MUST have WordPress.
14
-if ( !defined( 'WPINC' ) ) {
15
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
14
+if (!defined('WPINC')) {
15
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
16 16
 }
17 17
 
18
-if ( !defined( 'WPINV_VERSION' ) ) {
19
-    define( 'WPINV_VERSION', '0.0.41' );
18
+if (!defined('WPINV_VERSION')) {
19
+    define('WPINV_VERSION', '0.0.41');
20 20
 }
21 21
 
22
-if ( !defined( 'WPINV_PLUGIN_FILE' ) ) {
23
-    define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+if (!defined('WPINV_PLUGIN_FILE')) {
23
+    define('WPINV_PLUGIN_FILE', __FILE__);
24 24
 }
25 25
 
26
-require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php';
26
+require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php';
27 27
 
28 28
 function wpinv_run() {
29 29
     global $invoicing;
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 /**
41 41
  * Show update plugin admin notification.
42 42
  */
43
-if(is_admin()){
43
+if (is_admin()) {
44 44
     if (!function_exists('ayecode_show_update_plugin_requirement')) {//only load the update file if needed
45 45
         function ayecode_show_update_plugin_requirement() {
46
-            if ( !defined( 'WP_EASY_UPDATES_ACTIVE' ) ) {
46
+            if (!defined('WP_EASY_UPDATES_ACTIVE')) {
47 47
                 ?>
48 48
                 <div class="notice notice-warning is-dismissible">
49 49
                     <p>
50 50
                         <strong>
51 51
                             <?php
52
-                            echo sprintf( __( 'The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory' ), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>' );
52
+                            echo sprintf(__('The plugin %sWP Easy Updates%s is required to check for and update some installed plugins, please install it now.', 'geodirectory'), '<a href="https://wpeasyupdates.com/" target="_blank" title="WP Easy Updates">', '</a>');
53 53
                             ?>
54 54
                         </strong>
55 55
                     </p>
@@ -58,6 +58,6 @@  discard block
 block discarded – undo
58 58
             }
59 59
         }
60 60
 
61
-        add_action( 'admin_notices', 'ayecode_show_update_plugin_requirement' );
61
+        add_action('admin_notices', 'ayecode_show_update_plugin_requirement');
62 62
     }
63 63
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  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
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             self::$instance->reports    = new WPInv_Reports();
24 24
         }
25 25
         
26
-        do_action( 'wpinv_loaded' );
26
+        do_action('wpinv_loaded');
27 27
         
28 28
         return self::$instance;
29 29
     }
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
48
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array('WPInv_Shortcodes', 'init'));
48
+        add_action('init', array(&$this, 'wpinv_actions'));
49 49
         
50
-        if ( class_exists( 'BuddyPress' ) ) {
51
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
50
+        if (class_exists('BuddyPress')) {
51
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
52 52
         }
53 53
 
54
-        add_filter( 'geodir_googlemap_script_extra', array( &$this,'add_google_maps_places_lib'), 101, 1 );
54
+        add_filter('geodir_googlemap_script_extra', array(&$this, 'add_google_maps_places_lib'), 101, 1);
55 55
 
56
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
56
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
57 57
         
58
-        if ( is_admin() ) {
59
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
60
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
58
+        if (is_admin()) {
59
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
60
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
61 61
         } else {
62
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
62
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
63 63
         }
64 64
         
65 65
         /**
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
          *
70 70
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
71 71
          */
72
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
72
+        do_action_ref_array('wpinv_actions', array(&$this));
73 73
 
74
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
74
+        add_action('admin_init', array(&$this, 'activation_redirect'));
75 75
     }
76 76
     
77 77
     public function plugins_loaded() {
@@ -85,157 +85,157 @@  discard block
 block discarded – undo
85 85
      * @since 1.0
86 86
      */
87 87
     public function load_textdomain() {
88
-        $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' );
88
+        $locale = apply_filters('plugin_locale', get_locale(), 'invoicing');
89 89
         
90
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
91
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
90
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
91
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
92 92
         
93 93
         /**
94 94
          * Define language constants.
95 95
          */
96
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
96
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
97 97
     }
98 98
         
99 99
     public function includes() {
100 100
         global $wpinv_options;
101 101
         
102
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
102
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
103 103
         $wpinv_options = wpinv_get_settings();
104 104
         
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
106
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
107
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
106
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
107
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
120 120
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
121 121
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
123 123
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
129
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
130
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
131
-        if ( !class_exists( 'Geodir_EUVat' ) ) {
132
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
129
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
130
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
131
+        if (!class_exists('Geodir_EUVat')) {
132
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
133 133
         }
134 134
         
135
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
136
-        if ( !empty( $gateways ) ) {
137
-            foreach ( $gateways as $gateway ) {
138
-                if ( $gateway == 'manual' ) {
135
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
136
+        if (!empty($gateways)) {
137
+            foreach ($gateways as $gateway) {
138
+                if ($gateway == 'manual') {
139 139
                     continue;
140 140
                 }
141 141
                 
142 142
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
143 143
                 
144
-                if ( file_exists( $gateway_file ) ) {
145
-                    require_once( $gateway_file );
144
+                if (file_exists($gateway_file)) {
145
+                    require_once($gateway_file);
146 146
                 }
147 147
             }
148 148
         }
149
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
149
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
150 150
         
151
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
153
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
154
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
151
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
153
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
154
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
155 155
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
156
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
157
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
158
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
159
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
160
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
156
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
157
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
158
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
159
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
160
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
161 161
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
162 162
         }
163 163
         
164 164
         // include css inliner
165
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
166
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
165
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
166
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
167 167
         }
168 168
         
169
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
169
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
170 170
     }
171 171
     
172 172
     public function init() {
173 173
     }
174 174
     
175 175
     public function admin_init() {
176
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
176
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
177 177
         }
178 178
         
179
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
179
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
180 180
     }
181 181
 
182 182
     public function activation_redirect() {
183 183
         // Bail if no activation redirect
184
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
184
+        if (!get_transient('_wpinv_activation_redirect')) {
185 185
             return;
186 186
         }
187 187
 
188 188
         // Delete the redirect transient
189
-        delete_transient( '_wpinv_activation_redirect' );
189
+        delete_transient('_wpinv_activation_redirect');
190 190
 
191 191
         // Bail if activating from network, or bulk
192
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
192
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
193 193
             return;
194 194
         }
195 195
 
196
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
196
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
197 197
         exit;
198 198
     }
199 199
     
200 200
     public function enqueue_scripts() {
201
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
201
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
202 202
         
203
-        wp_deregister_style( 'font-awesome' );
204
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
205
-        wp_enqueue_style( 'font-awesome' );
203
+        wp_deregister_style('font-awesome');
204
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
205
+        wp_enqueue_style('font-awesome');
206 206
         
207
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
208
-        wp_enqueue_style( 'wpinv_front_style' );
207
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
208
+        wp_enqueue_style('wpinv_front_style');
209 209
                
210 210
         // Register scripts
211
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
212
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
211
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
212
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
213 213
         
214 214
         $localize                         = array();
215
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
216
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
215
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
216
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
217 217
         $localize['currency_symbol']      = wpinv_currency_symbol();
218 218
         $localize['currency_pos']         = wpinv_currency_position();
219 219
         $localize['thousand_sep']         = wpinv_thousands_separator();
220 220
         $localize['decimal_sep']          = wpinv_decimal_separator();
221 221
         $localize['decimals']             = wpinv_decimals();
222 222
         
223
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
223
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
224 224
         
225
-        wp_enqueue_script( 'jquery-blockui' );
225
+        wp_enqueue_script('jquery-blockui');
226 226
         $autofill_api = wpinv_get_option('address_autofill_api');
227 227
         $autofill_active = wpinv_get_option('address_autofill_active');
228 228
         if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
229 229
 
230 230
             // we don't need this if GD is installed.
231
-            if(!function_exists('geodir_templates_scripts')){
231
+            if (!function_exists('geodir_templates_scripts')) {
232 232
                 wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
233 233
             }
234
-            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery','google-maps-api'), '', true);
234
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
235 235
             
236 236
         }
237
-        wp_enqueue_script( 'wpinv-front-script' );
238
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
237
+        wp_enqueue_script('wpinv-front-script');
238
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
239 239
     }
240 240
 
241 241
     /**
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
      * @since 1.0.0
246 246
      * @return string
247 247
      */
248
-    public function add_google_maps_places_lib( $extra ) {
248
+    public function add_google_maps_places_lib($extra) {
249 249
 
250
-        if ( wpinv_is_checkout() && ! str_replace( 'libraries=places', '', $extra ) ) {
250
+        if (wpinv_is_checkout() && !str_replace('libraries=places', '', $extra)) {
251 251
             $extra .= "&amp;libraries=places";
252 252
         }
253 253
 
@@ -258,35 +258,35 @@  discard block
 block discarded – undo
258 258
         global $post, $pagenow;
259 259
         
260 260
         $post_type  = wpinv_admin_post_type();
261
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
261
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
262 262
         
263
-        wp_deregister_style( 'font-awesome' );
264
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
265
-        wp_enqueue_style( 'font-awesome' );
263
+        wp_deregister_style('font-awesome');
264
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
265
+        wp_enqueue_style('font-awesome');
266 266
         
267
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
268
-        wp_enqueue_style( 'jquery-ui-css' );
267
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
268
+        wp_enqueue_style('jquery-ui-css');
269 269
         
270
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
271
-        wp_enqueue_style( 'jquery-chosen' );
270
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
271
+        wp_enqueue_style('jquery-chosen');
272 272
 
273
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
274
-        wp_enqueue_script( 'jquery-chosen' );
273
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
274
+        wp_enqueue_script('jquery-chosen');
275 275
         
276
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
277
-        wp_enqueue_style( 'wpinv_meta_box_style' );
276
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
277
+        wp_enqueue_style('wpinv_meta_box_style');
278 278
         
279
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
280
-        wp_enqueue_style( 'wpinv_admin_style' );
279
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
280
+        wp_enqueue_style('wpinv_admin_style');
281 281
         
282
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
283
-            wp_enqueue_script( 'jquery-ui-datepicker' );
282
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
283
+            wp_enqueue_script('jquery-ui-datepicker');
284 284
         }
285 285
 
286
-        wp_enqueue_style( 'wp-color-picker' );
287
-        wp_enqueue_script( 'wp-color-picker' );
286
+        wp_enqueue_style('wp-color-picker');
287
+        wp_enqueue_script('wp-color-picker');
288 288
         
289
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
289
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
290 290
 
291 291
         if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
292 292
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
             }
298 298
         }
299 299
 
300
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
301
-        wp_enqueue_script( 'wpinv-admin-script' );
300
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
301
+        wp_enqueue_script('wpinv-admin-script');
302 302
         
303 303
         $localize                               = array();
304
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
305
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
306
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
307
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
308
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
309
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
310
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
304
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
305
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
306
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
307
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
308
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
309
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
310
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
311 311
         $localize['tax']                        = wpinv_tax_amount();
312 312
         $localize['discount']                   = wpinv_discount_amount();
313 313
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -315,65 +315,65 @@  discard block
 block discarded – undo
315 315
         $localize['thousand_sep']               = wpinv_thousands_separator();
316 316
         $localize['decimal_sep']                = wpinv_decimal_separator();
317 317
         $localize['decimals']                   = wpinv_decimals();
318
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
319
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
320
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
321
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
322
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
323
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
324
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
325
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
326
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
318
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
319
+        $localize['status_publish']             = wpinv_status_nicename('publish');
320
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
321
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
322
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
323
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
324
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
325
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
326
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
327 327
         $localize['hasGD']                      = wpinv_gd_active();
328 328
         $localize['hasPM']                      = wpinv_pm_active();
329
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
330
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
331
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
332
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
329
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
330
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
331
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
332
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
333 333
 
334
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
334
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
335 335
 
336
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
336
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
337 337
     }
338 338
     
339
-    public function admin_body_class( $classes ) {
339
+    public function admin_body_class($classes) {
340 340
         global $pagenow, $post, $current_screen;
341 341
         
342
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
342
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
343 343
             $classes .= ' wpinv-cpt';
344 344
         }
345 345
         
346
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
346
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
347 347
 
348 348
         $add_class = false;
349
-        if ( $pagenow == 'admin.php' && $page ) {
350
-            $add_class = strpos( $page, 'wpinv-' );
349
+        if ($pagenow == 'admin.php' && $page) {
350
+            $add_class = strpos($page, 'wpinv-');
351 351
         }
352 352
         
353 353
         $settings_class = array();
354
-        if ( $page == 'wpinv-settings' ) {
355
-            if ( !empty( $_REQUEST['tab'] ) ) {
356
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
354
+        if ($page == 'wpinv-settings') {
355
+            if (!empty($_REQUEST['tab'])) {
356
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
357 357
             }
358 358
             
359
-            if ( !empty( $_REQUEST['section'] ) ) {
360
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
359
+            if (!empty($_REQUEST['section'])) {
360
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
361 361
             }
362 362
             
363
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
363
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
364 364
         }
365 365
         
366
-        if ( !empty( $settings_class ) ) {
367
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
366
+        if (!empty($settings_class)) {
367
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
368 368
         }
369 369
         
370 370
         $post_type = wpinv_admin_post_type();
371 371
 
372
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
372
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
373 373
             return $classes .= ' wpinv';
374 374
         }
375 375
         
376
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
376
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
377 377
             $classes .= ' wpi-editable-n';
378 378
         }
379 379
 
@@ -385,20 +385,20 @@  discard block
 block discarded – undo
385 385
     }
386 386
     
387 387
     public function wpinv_actions() {
388
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
389
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
+        if (isset($_REQUEST['wpi_action'])) {
389
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
390 390
         }
391 391
     }
392 392
     
393
-    public function pre_get_posts( $wp_query ) {
394
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
395
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
393
+    public function pre_get_posts($wp_query) {
394
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
395
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
396 396
         }
397 397
         
398 398
         return $wp_query;
399 399
     }
400 400
     
401 401
     public function bp_invoicing_init() {
402
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
402
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
403 403
     }
404 404
 }
405 405
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/install.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
     set_transient('_wpinv_activation_redirect', true, 30);
8 8
     wpinv_install($network_wide);
9 9
 
10
-    if(!wpinv_get_option('address_autofill_api') && $api_key = get_option('geodir_google_api_key')){
11
-        wpinv_update_option( 'address_autofill_api', $api_key);
10
+    if (!wpinv_get_option('address_autofill_api') && $api_key = get_option('geodir_google_api_key')) {
11
+        wpinv_update_option('address_autofill_api', $api_key);
12 12
     }
13 13
 
14 14
 }
Please login to merge, or discard this patch.
templates/wpinv-invalid-access.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,56 +1,56 @@
 block discarded – undo
1 1
 <?php 
2
-if ( !defined('ABSPATH') ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5
-do_action( 'wpinv_invalid_invoice_before_display' ); ?><!DOCTYPE html>
5
+do_action('wpinv_invalid_invoice_before_display'); ?><!DOCTYPE html>
6 6
 <html <?php language_attributes(); ?>>
7 7
 <head>
8 8
     <meta charset="UTF-8">
9 9
     <title><?php wp_title() ?></title>
10
-    <meta charset="<?php bloginfo( 'charset' ); ?>" />
10
+    <meta charset="<?php bloginfo('charset'); ?>" />
11 11
     <meta name="viewport" content="width=device-width,initial-scale=1">
12 12
     <meta name="robots" content="noindex,nofollow">
13
-    <?php do_action( 'wpinv_invalid_invoice_head' ); ?>
13
+    <?php do_action('wpinv_invalid_invoice_head'); ?>
14 14
 </head>
15 15
 <body class="body wpinv wpinv-print wpinv-invalid-invoice">
16
-    <?php do_action( 'wpinv_invalid_invoice_body_start' ); ?>
16
+    <?php do_action('wpinv_invalid_invoice_body_start'); ?>
17 17
     <div class="container wpinv-wrap">
18 18
         <!-- ///// Start Header -->
19 19
         <htmlpageheader name="wpinv-pdf-header">
20
-            <?php do_action( 'wpinv_invalid_invoice_before_header' ); ?>
20
+            <?php do_action('wpinv_invalid_invoice_before_header'); ?>
21 21
             <div class="row wpinv-header">
22 22
                 <div class="col-xs-12 wpinv-business">
23
-                    <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
24
-                        <?php if ( $logo = wpinv_get_business_logo() ) { ?>
25
-                        <img class="logo" src="<?php echo esc_url( $logo ); ?>">
23
+                    <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
24
+                        <?php if ($logo = wpinv_get_business_logo()) { ?>
25
+                        <img class="logo" src="<?php echo esc_url($logo); ?>">
26 26
                         <?php } else { ?>
27
-                        <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1>
27
+                        <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1>
28 28
                         <?php } ?>
29 29
                     </a>
30 30
                 </div>
31 31
             </div>
32
-            <?php do_action( 'wpinv_invalid_invoice_after_header' ); ?>
32
+            <?php do_action('wpinv_invalid_invoice_after_header'); ?>
33 33
         </htmlpageheader>
34 34
         <!-- End Header ///// -->
35 35
         
36
-        <?php do_action( 'wpinv_invalid_invoice_before_content' ); ?>
36
+        <?php do_action('wpinv_invalid_invoice_before_content'); ?>
37 37
 
38
-        <?php do_action( 'wpinv_invalid_invoice_content' ); ?>
38
+        <?php do_action('wpinv_invalid_invoice_content'); ?>
39 39
         
40
-        <?php do_action( 'wpinv_invalid_invoice_after_content' ); ?>
40
+        <?php do_action('wpinv_invalid_invoice_after_content'); ?>
41 41
         
42 42
         <!-- ///// Start Footer -->
43 43
         <htmlpagefooter name="wpinv-pdf-footer">
44
-            <?php do_action( 'wpinv_invalid_invoice_before_footer' ); ?>
44
+            <?php do_action('wpinv_invalid_invoice_before_footer'); ?>
45 45
             <div class="row wpinv-footer">
46 46
                 <div class="col-sm-12">
47 47
                     <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div>
48 48
                 </div>
49 49
             </div>
50
-            <?php do_action( 'wpinv_invalid_invoice_after_footer' ); ?>
50
+            <?php do_action('wpinv_invalid_invoice_after_footer'); ?>
51 51
         </htmlpagefooter>
52 52
         <!-- End Footer ///// -->
53 53
     </div>
54
-    <?php do_action( 'wpinv_invalid_invoice_body_end' ); ?>
54
+    <?php do_action('wpinv_invalid_invoice_body_end'); ?>
55 55
 </body>
56 56
 </html>
57 57
\ No newline at end of file
Please login to merge, or discard this patch.