Completed
Push — master ( b0d50b...dd166b )
by Stiofan
12s
created
includes/admin/admin-pages.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,8 +196,9 @@
 block discarded – undo
196 196
             foreach ( $types as $name => $type ) {
197 197
                 echo '<option value="' . esc_attr( $name ) . '"';
198 198
 
199
-                if ( isset( $_GET['discount_type'] ) )
200
-                    selected( $name, $_GET['discount_type'] );
199
+                if ( isset( $_GET['discount_type'] ) ) {
200
+                                    selected( $name, $_GET['discount_type'] );
201
+                }
201 202
 
202 203
                 echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
203 204
             }
Please login to merge, or discard this patch.
Spacing   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'admin_menu', 'wpinv_add_options_link', 10 );
7
+add_action('admin_menu', 'wpinv_add_options_link', 10);
8 8
 function wpinv_add_options_link() {
9 9
     global $menu;
10 10
 
11
-    if ( current_user_can( 'manage_options' ) ) {
12
-        $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' );
11
+    if (current_user_can('manage_options')) {
12
+        $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv');
13 13
     }
14 14
     
15
-    $wpi_invoice            = get_post_type_object( 'wpi_invoice' );
15
+    $wpi_invoice = get_post_type_object('wpi_invoice');
16 16
 
17
-    add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' );
17
+    add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), 'manage_options', 'wpinv', null, $wpi_invoice->menu_icon, '54.123460');
18 18
     
19
-    $wpi_settings_page   = add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), 'manage_options', 'wpinv-settings', 'wpinv_options_page' );
19
+    $wpi_settings_page = add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), 'manage_options', 'wpinv-settings', 'wpinv_options_page');
20 20
 }
21 21
 
22
-add_action( 'admin_menu', 'wpinv_remove_admin_submenus', 999 );
22
+add_action('admin_menu', 'wpinv_remove_admin_submenus', 999);
23 23
 function wpinv_remove_admin_submenus() {
24
-    remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
24
+    remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
25 25
 }
26 26
 
27
-add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' );
28
-function wpinv_discount_columns( $existing_columns ) {
27
+add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns');
28
+function wpinv_discount_columns($existing_columns) {
29 29
     $columns                = array();
30 30
     $columns['cb']          = $existing_columns['cb'];
31
-    $columns['name']        = __( 'Name', 'invoicing' );
32
-    $columns['code']        = __( 'Code', 'invoicing' );
33
-    $columns['amount']      = __( 'Amount', 'invoicing' );
34
-    $columns['usage']       = __( 'Usage / Limit', 'invoicing' );
35
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
36
-    $columns['status']      = __( 'Status', 'invoicing' );
31
+    $columns['name']        = __('Name', 'invoicing');
32
+    $columns['code']        = __('Code', 'invoicing');
33
+    $columns['amount']      = __('Amount', 'invoicing');
34
+    $columns['usage']       = __('Usage / Limit', 'invoicing');
35
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
36
+    $columns['status']      = __('Status', 'invoicing');
37 37
 
38 38
     return $columns;
39 39
 }
40 40
 
41
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
42
-function wpinv_discount_custom_column( $column ) {
41
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
42
+function wpinv_discount_custom_column($column) {
43 43
     global $post;
44 44
     
45 45
     $discount = $post;
46 46
 
47
-    switch ( $column ) {
47
+    switch ($column) {
48 48
         case 'name' :
49
-            echo get_the_title( $discount->ID );
49
+            echo get_the_title($discount->ID);
50 50
         break;
51 51
         case 'code' :
52
-            echo wpinv_get_discount_code( $discount->ID );
52
+            echo wpinv_get_discount_code($discount->ID);
53 53
         break;
54 54
         case 'amount' :
55
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
55
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
56 56
         break;
57 57
         case 'usage_limit' :
58
-            echo wpinv_get_discount_uses( $discount->ID );
58
+            echo wpinv_get_discount_uses($discount->ID);
59 59
         break;
60 60
         case 'usage' :
61
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
62
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
63
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
61
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
62
+            if (wpinv_get_discount_max_uses($discount->ID)) {
63
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
64 64
             } else {
65 65
                 $usage .= ' &infin;';
66 66
             }
@@ -68,162 +68,162 @@  discard block
 block discarded – undo
68 68
             echo $usage;
69 69
         break;
70 70
         case 'expiry_date' :
71
-            if ( wpinv_get_discount_expiration( $discount->ID ) ) {
72
-                $expiration = date_i18n( get_option( 'date_format' ), strtotime( wpinv_get_discount_expiration( $discount->ID ) ) );
71
+            if (wpinv_get_discount_expiration($discount->ID)) {
72
+                $expiration = date_i18n(get_option('date_format'), strtotime(wpinv_get_discount_expiration($discount->ID)));
73 73
             } else {
74
-                $expiration = __( 'Never', 'invoicing' );
74
+                $expiration = __('Never', 'invoicing');
75 75
             }
76 76
                 
77 77
             echo $expiration;
78 78
         break;
79 79
         case 'description' :
80
-            echo wp_kses_post( $post->post_excerpt );
80
+            echo wp_kses_post($post->post_excerpt);
81 81
         break;
82 82
         case 'status' :
83
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
83
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
84 84
             
85
-            echo wpinv_discount_status( $status );
85
+            echo wpinv_discount_status($status);
86 86
         break;
87 87
     }
88 88
 }
89 89
 
90
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
91
-function wpinv_post_row_actions( $actions, $post ) {
92
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
90
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
91
+function wpinv_post_row_actions($actions, $post) {
92
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
93 93
     
94
-    if ( $post_type == 'wpi_invoice' ) {
94
+    if ($post_type == 'wpi_invoice') {
95 95
         $actions = array();
96 96
     }
97 97
     
98
-    if ( $post_type == 'wpi_discount' ) {
99
-        $actions = wpinv_discount_row_actions( $post, $actions );
98
+    if ($post_type == 'wpi_discount') {
99
+        $actions = wpinv_discount_row_actions($post, $actions);
100 100
     }
101 101
     
102 102
     return $actions;
103 103
 }
104 104
 
105
-function wpinv_discount_row_actions( $discount, $row_actions ) {
106
-    $row_actions  = array();
107
-    $edit_link = get_edit_post_link( $discount->ID );
108
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
105
+function wpinv_discount_row_actions($discount, $row_actions) {
106
+    $row_actions = array();
107
+    $edit_link = get_edit_post_link($discount->ID);
108
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
109 109
 
110
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
111
-        $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>';
112
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
113
-        $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>';
110
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
111
+        $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>';
112
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
113
+        $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>';
114 114
     }
115 115
 
116
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
117
-        if ( isset( $row_actions['delete'] ) ) {
118
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
116
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
117
+        if (isset($row_actions['delete'])) {
118
+            unset($row_actions['delete']); // Don't delete used discounts.
119 119
         }
120 120
     } else {
121
-        $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>';
121
+        $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>';
122 122
     }
123 123
     
124 124
 
125
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
125
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
126 126
 
127 127
     return $row_actions;
128 128
 }
129 129
 
130
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
131
-function wpinv_table_primary_column( $default, $screen_id ) {
132
-    if ( 'edit-wpi_invoice' === $screen_id ) {
130
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
131
+function wpinv_table_primary_column($default, $screen_id) {
132
+    if ('edit-wpi_invoice' === $screen_id) {
133 133
         return 'name';
134 134
     }
135 135
     
136 136
     return $default;
137 137
 }
138 138
 
139
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
140
-    if ( !$display ) {
139
+function wpinv_discount_bulk_actions($actions, $display = false) {    
140
+    if (!$display) {
141 141
         return array();
142 142
     }
143 143
     
144 144
     $actions = array(
145
-        'activate'   => __( 'Activate', 'invoicing' ),
146
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
147
-        'delete'     => __( 'Delete', 'invoicing' ),
145
+        'activate'   => __('Activate', 'invoicing'),
146
+        'deactivate' => __('Deactivate', 'invoicing'),
147
+        'delete'     => __('Delete', 'invoicing'),
148 148
     );
149 149
     $two = '';
150 150
     $which = 'top';
151 151
     echo '</div><div class="alignleft actions bulkactions">';
152
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
153
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
154
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
152
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
153
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
154
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
155 155
 
156
-    foreach ( $actions as $name => $title ) {
156
+    foreach ($actions as $name => $title) {
157 157
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
158 158
 
159 159
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
160 160
     }
161 161
     echo "</select>";
162 162
 
163
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
163
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
164 164
     
165 165
     echo '</div><div class="alignleft actions">';
166 166
 }
167
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
167
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
168 168
 
169
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
170
-    if ( $post_type == 'wpi_discount' ) {
169
+function wpinv_disable_months_dropdown($disable, $post_type) {
170
+    if ($post_type == 'wpi_discount') {
171 171
         $disable = true;
172 172
     }
173 173
     
174 174
     return $disable;
175 175
 }
176
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
176
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
177 177
 
178 178
 function wpinv_restrict_manage_posts() {
179 179
     global $typenow;
180 180
 
181
-    if( 'wpi_discount' == $typenow ) {
181
+    if ('wpi_discount' == $typenow) {
182 182
         wpinv_discount_filters();
183 183
     }
184 184
 }
185
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
185
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
186 186
 
187 187
 function wpinv_discount_filters() {
188
-    echo wpinv_discount_bulk_actions( array(), true );
188
+    echo wpinv_discount_bulk_actions(array(), true);
189 189
     
190 190
     ?>
191 191
     <select name="discount_type" id="dropdown_wpinv_discount_type">
192
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
192
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
193 193
         <?php
194 194
             $types = wpinv_get_discount_types();
195 195
 
196
-            foreach ( $types as $name => $type ) {
197
-                echo '<option value="' . esc_attr( $name ) . '"';
196
+            foreach ($types as $name => $type) {
197
+                echo '<option value="' . esc_attr($name) . '"';
198 198
 
199
-                if ( isset( $_GET['discount_type'] ) )
200
-                    selected( $name, $_GET['discount_type'] );
199
+                if (isset($_GET['discount_type']))
200
+                    selected($name, $_GET['discount_type']);
201 201
 
202
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
202
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
203 203
             }
204 204
         ?>
205 205
     </select>
206 206
     <?php
207 207
 }
208 208
 
209
-function wpinv_request( $vars ) {
209
+function wpinv_request($vars) {
210 210
     global $typenow, $wp_query, $wp_post_statuses;
211 211
 
212
-    if ( 'wpi_invoice' === $typenow or 'wpi_quote' === $typenow ) {
213
-        if ( !isset( $vars['post_status'] ) ) {
212
+    if ('wpi_invoice' === $typenow or 'wpi_quote' === $typenow) {
213
+        if (!isset($vars['post_status'])) {
214 214
             $post_statuses = wpinv_get_invoice_statuses();
215 215
 
216
-            foreach ( $post_statuses as $status => $value ) {
217
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
218
-                    unset( $post_statuses[ $status ] );
216
+            foreach ($post_statuses as $status => $value) {
217
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
218
+                    unset($post_statuses[$status]);
219 219
                 }
220 220
             }
221 221
 
222
-            $vars['post_status'] = array_keys( $post_statuses );
222
+            $vars['post_status'] = array_keys($post_statuses);
223 223
         }
224 224
         
225
-        if ( isset( $vars['orderby'] ) ) {
226
-            if ( 'amount' == $vars['orderby'] ) {
225
+        if (isset($vars['orderby'])) {
226
+            if ('amount' == $vars['orderby']) {
227 227
                 $vars = array_merge(
228 228
                     $vars,
229 229
                     array(
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                         'orderby'  => 'meta_value_num'
232 232
                     )
233 233
                 );
234
-            } else if ( 'customer' == $vars['orderby'] ) {
234
+            } else if ('customer' == $vars['orderby']) {
235 235
                 $vars = array_merge(
236 236
                     $vars,
237 237
                     array(
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
                         'orderby'  => 'meta_value'
240 240
                     )
241 241
                 );
242
-            } else if ( 'number' == $vars['orderby'] ) {
242
+            } else if ('number' == $vars['orderby']) {
243 243
                 $vars = array_merge(
244 244
                     $vars,
245 245
                     array(
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
                 );
250 250
             }
251 251
         }
252
-    } else if ( 'wpi_item' == $typenow ) {
252
+    } else if ('wpi_item' == $typenow) {
253 253
         // Check if 'orderby' is set to "price"
254
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
254
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
255 255
             $vars = array_merge(
256 256
                 $vars,
257 257
                 array(
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         }
263 263
 
264 264
         // Check if "orderby" is set to "vat_rule"
265
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
265
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
266 266
             $vars = array_merge(
267 267
                 $vars,
268 268
                 array(
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         }
274 274
 
275 275
         // Check if "orderby" is set to "vat_class"
276
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
276
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
277 277
             $vars = array_merge(
278 278
                 $vars,
279 279
                 array(
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
         }
285 285
         
286 286
         // Check if "orderby" is set to "type"
287
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
287
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
288 288
             $vars = array_merge(
289 289
                 $vars,
290 290
                 array(
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         }
296 296
         
297 297
         // Check if "orderby" is set to "recurring"
298
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
298
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
299 299
             $vars = array_merge(
300 300
                 $vars,
301 301
                 array(
@@ -305,120 +305,120 @@  discard block
 block discarded – undo
305 305
             );
306 306
         }
307 307
 
308
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
308
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
309 309
         // Filter vat rule type
310
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
310
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
311 311
             $meta_query[] = array(
312 312
                     'key'   => '_wpinv_vat_rule',
313
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
313
+                    'value' => sanitize_text_field($_GET['vat_rule']),
314 314
                     'compare' => '='
315 315
                 );
316 316
         }
317 317
         
318 318
         // Filter vat class
319
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
319
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
320 320
             $meta_query[] = array(
321 321
                     'key'   => '_wpinv_vat_class',
322
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
322
+                    'value' => sanitize_text_field($_GET['vat_class']),
323 323
                     'compare' => '='
324 324
                 );
325 325
         }
326 326
         
327 327
         // Filter item type
328
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
328
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
329 329
             $meta_query[] = array(
330 330
                     'key'   => '_wpinv_type',
331
-                    'value' => sanitize_text_field( $_GET['type'] ),
331
+                    'value' => sanitize_text_field($_GET['type']),
332 332
                     'compare' => '='
333 333
                 );
334 334
         }
335 335
         
336
-        if ( !empty( $meta_query ) ) {
336
+        if (!empty($meta_query)) {
337 337
             $vars['meta_query'] = $meta_query;
338 338
         }
339
-    } else if ( 'wpi_discount' == $typenow ) {
340
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
339
+    } else if ('wpi_discount' == $typenow) {
340
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
341 341
         // Filter vat rule type
342
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
342
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
343 343
             $meta_query[] = array(
344 344
                     'key'   => '_wpi_discount_type',
345
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
345
+                    'value' => sanitize_text_field($_GET['discount_type']),
346 346
                     'compare' => '='
347 347
                 );
348 348
         }
349 349
         
350
-        if ( !empty( $meta_query ) ) {
350
+        if (!empty($meta_query)) {
351 351
             $vars['meta_query'] = $meta_query;
352 352
         }
353 353
     }
354 354
 
355 355
     return $vars;
356 356
 }
357
-add_filter( 'request', 'wpinv_request' );
357
+add_filter('request', 'wpinv_request');
358 358
 
359 359
 function wpinv_options_page() {
360
-    $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
360
+    $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
361 361
     
362
-    if ( $page !== 'wpinv-settings' ) {
362
+    if ($page !== 'wpinv-settings') {
363 363
         return;
364 364
     }
365 365
     
366 366
     $settings_tabs = wpinv_get_settings_tabs();
367 367
     $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
368
-    $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
369
-    $sections      = wpinv_get_settings_tab_sections( $active_tab );
368
+    $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
369
+    $sections      = wpinv_get_settings_tab_sections($active_tab);
370 370
     $key           = 'main';
371 371
 
372
-    if ( is_array( $sections ) ) {
373
-        $key = key( $sections );
372
+    if (is_array($sections)) {
373
+        $key = key($sections);
374 374
     }
375 375
 
376
-    $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
377
-    $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
376
+    $registered_sections = wpinv_get_settings_tab_sections($active_tab);
377
+    $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
378 378
     ob_start();
379 379
     ?>
380 380
     <div class="wrap">
381 381
         <h1 class="nav-tab-wrapper">
382 382
             <?php
383
-            foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
384
-                $tab_url = add_query_arg( array(
383
+            foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
384
+                $tab_url = add_query_arg(array(
385 385
                     'settings-updated' => false,
386 386
                     'tab' => $tab_id,
387
-                ) );
387
+                ));
388 388
 
389 389
                 // Remove the section from the tabs so we always end up at the main section
390
-                $tab_url = remove_query_arg( 'section', $tab_url );
391
-                $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
390
+                $tab_url = remove_query_arg('section', $tab_url);
391
+                $tab_url = remove_query_arg('wpi_sub', $tab_url);
392 392
 
393 393
                 $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
394 394
 
395
-                echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
396
-                    echo esc_html( $tab_name );
395
+                echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
396
+                    echo esc_html($tab_name);
397 397
                 echo '</a>';
398 398
             }
399 399
             ?>
400 400
         </h1>
401 401
         <?php
402
-        $number_of_sections = count( $sections );
402
+        $number_of_sections = count($sections);
403 403
         $number = 0;
404
-        if ( $number_of_sections > 1 ) {
404
+        if ($number_of_sections > 1) {
405 405
             echo '<div><ul class="subsubsub">';
406
-            foreach( $sections as $section_id => $section_name ) {
406
+            foreach ($sections as $section_id => $section_name) {
407 407
                 echo '<li>';
408 408
                 $number++;
409
-                $tab_url = add_query_arg( array(
409
+                $tab_url = add_query_arg(array(
410 410
                     'settings-updated' => false,
411 411
                     'tab' => $active_tab,
412 412
                     'section' => $section_id
413
-                ) );
414
-                $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
413
+                ));
414
+                $tab_url = remove_query_arg('wpi_sub', $tab_url);
415 415
                 $class = '';
416
-                if ( $section == $section_id ) {
416
+                if ($section == $section_id) {
417 417
                     $class = 'current';
418 418
                 }
419
-                echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
419
+                echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
420 420
 
421
-                if ( $number != $number_of_sections ) {
421
+                if ($number != $number_of_sections) {
422 422
                     echo ' | ';
423 423
                 }
424 424
                 echo '</li>';
@@ -430,19 +430,19 @@  discard block
 block discarded – undo
430 430
             <form method="post" action="options.php">
431 431
                 <table class="form-table">
432 432
                 <?php
433
-                settings_fields( 'wpinv_settings' );
433
+                settings_fields('wpinv_settings');
434 434
 
435
-                if ( 'main' === $section ) {
436
-                    do_action( 'wpinv_settings_tab_top', $active_tab );
435
+                if ('main' === $section) {
436
+                    do_action('wpinv_settings_tab_top', $active_tab);
437 437
                 }
438 438
 
439
-                do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section );
440
-                do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section );
441
-                do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section  );
439
+                do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section);
440
+                do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section);
441
+                do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section);
442 442
 
443 443
                 // For backwards compatibility
444
-                if ( 'main' === $section ) {
445
-                    do_action( 'wpinv_settings_tab_bottom', $active_tab );
444
+                if ('main' === $section) {
445
+                    do_action('wpinv_settings_tab_bottom', $active_tab);
446 446
                 }
447 447
                 ?>
448 448
                 </table>
@@ -455,53 +455,53 @@  discard block
 block discarded – undo
455 455
     echo $content;
456 456
 }
457 457
 
458
-function wpinv_item_type_class( $classes, $class, $post_id ) {
458
+function wpinv_item_type_class($classes, $class, $post_id) {
459 459
     global $pagenow, $typenow;
460 460
 
461
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
462
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
463
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
461
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
462
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
463
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
464 464
         }
465 465
         
466
-        if ( !wpinv_item_is_editable( $post_id ) ) {
466
+        if (!wpinv_item_is_editable($post_id)) {
467 467
             $classes[] = 'wpi-editable-n';
468 468
         }
469 469
     }
470 470
     return $classes;
471 471
 }
472
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
472
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
473 473
 
474 474
 function wpinv_check_quick_edit() {
475 475
     global $pagenow, $current_screen, $wpinv_item_screen;
476 476
 
477
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
478
-        if ( empty( $wpinv_item_screen ) ) {
479
-            if ( $current_screen->post_type == 'wpi_item' ) {
477
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
478
+        if (empty($wpinv_item_screen)) {
479
+            if ($current_screen->post_type == 'wpi_item') {
480 480
                 $wpinv_item_screen = 'y';
481 481
             } else {
482 482
                 $wpinv_item_screen = 'n';
483 483
             }
484 484
         }
485 485
 
486
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
487
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
488
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
486
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
487
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
488
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
489 489
         }
490 490
     }
491 491
 }
492
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
492
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
493 493
 
494
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
495
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
496
-        unset( $actions['inline hide-if-no-js'] );
494
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
495
+    if (isset($actions['inline hide-if-no-js'])) {
496
+        unset($actions['inline hide-if-no-js']);
497 497
     }
498 498
     
499
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
500
-        if ( isset( $actions['trash'] ) ) {
501
-            unset( $actions['trash'] );
499
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
500
+        if (isset($actions['trash'])) {
501
+            unset($actions['trash']);
502 502
         }
503
-        if ( isset( $actions['delete'] ) ) {
504
-            unset( $actions['delete'] );
503
+        if (isset($actions['delete'])) {
504
+            unset($actions['delete']);
505 505
         }
506 506
     }
507 507
 
Please login to merge, or discard this patch.
includes/admin/install.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2
-register_activation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_activation' );
3
-register_deactivation_hook( WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation' );
2
+register_activation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_activation');
3
+register_deactivation_hook(WPINV_PLUGIN_FILE, 'wpinv_plugin_deactivation');
4 4
 
5
-function wpinv_plugin_activation( $network_wide = false ) {
6
-    set_transient( '_wpinv_activation_redirect', true, 30 );
7
-    wpinv_install( $network_wide );
5
+function wpinv_plugin_activation($network_wide = false) {
6
+    set_transient('_wpinv_activation_redirect', true, 30);
7
+    wpinv_install($network_wide);
8 8
 }
9 9
 
10 10
 function wpinv_plugin_deactivation() {
11 11
     // plugin deactivation stuff
12 12
 }
13 13
     
14
-function wpinv_install( $network_wide = false ) {
14
+function wpinv_install($network_wide = false) {
15 15
     global $wpdb;
16 16
 
17
-    if ( is_multisite() && $network_wide ) {
18
-        foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
19
-            switch_to_blog( $blog_id );
17
+    if (is_multisite() && $network_wide) {
18
+        foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
19
+            switch_to_blog($blog_id);
20 20
             wpinv_run_install();
21 21
             restore_current_blog();
22 22
         }
@@ -32,75 +32,75 @@  discard block
 block discarded – undo
32 32
     wpinv_register_post_types();
33 33
     
34 34
     // Clear the permalinks
35
-    flush_rewrite_rules( false );
35
+    flush_rewrite_rules(false);
36 36
     
37 37
     // Add Upgraded From Option
38
-    $current_version = get_option( 'wpinv_version' );
39
-    if ( $current_version ) {
40
-        update_option( 'wpinv_version_upgraded_from', $current_version );
38
+    $current_version = get_option('wpinv_version');
39
+    if ($current_version) {
40
+        update_option('wpinv_version_upgraded_from', $current_version);
41 41
     }
42 42
         
43 43
     // Pull options from WP, not GD Invoice's global
44
-    $current_options = get_option( 'wpinv_settings', array() );
44
+    $current_options = get_option('wpinv_settings', array());
45 45
     
46 46
     // Setup some default options
47 47
     $options = wpinv_create_pages();
48 48
     
49 49
     // Populate some default values
50
-    foreach( wpinv_get_registered_settings() as $tab => $sections ) {
51
-        foreach( $sections as $section => $settings) {
50
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
51
+        foreach ($sections as $section => $settings) {
52 52
             // Check for backwards compatibility
53
-            $tab_sections = wpinv_get_settings_tab_sections( $tab );
54
-            if( ! is_array( $tab_sections ) || ! array_key_exists( $section, $tab_sections ) ) {
53
+            $tab_sections = wpinv_get_settings_tab_sections($tab);
54
+            if (!is_array($tab_sections) || !array_key_exists($section, $tab_sections)) {
55 55
                 $section = 'main';
56 56
                 $settings = $sections;
57 57
             }
58 58
 
59
-            foreach ( $settings as $option ) {
60
-                if ( !empty( $option['id'] ) && !isset( $wpinv_options[ $option['id'] ] ) ) {
61
-                    if ( 'checkbox' == $option['type'] && !empty( $option['std'] ) ) {
62
-                        $options[ $option['id'] ] = '1';
63
-                    } else if ( !empty( $option['std'] ) ) {
64
-                        $options[ $option['id'] ] = $option['std'];
59
+            foreach ($settings as $option) {
60
+                if (!empty($option['id']) && !isset($wpinv_options[$option['id']])) {
61
+                    if ('checkbox' == $option['type'] && !empty($option['std'])) {
62
+                        $options[$option['id']] = '1';
63
+                    } else if (!empty($option['std'])) {
64
+                        $options[$option['id']] = $option['std'];
65 65
                     }
66 66
                 }
67 67
             }
68 68
         }
69 69
     }
70 70
     
71
-    $merged_options     = array_merge( $wpinv_options, $options );
71
+    $merged_options     = array_merge($wpinv_options, $options);
72 72
     $wpinv_options      = $merged_options;
73 73
     
74
-    update_option( 'wpinv_settings', $merged_options );
75
-    update_option( 'wpinv_version', WPINV_VERSION );
74
+    update_option('wpinv_settings', $merged_options);
75
+    update_option('wpinv_version', WPINV_VERSION);
76 76
     
77 77
     // Check for PHP Session support, and enable if available
78 78
     $wpi_session->use_php_sessions();
79 79
     
80 80
     // Add a temporary option to note that GD Invoice pages have been created
81
-    set_transient( '_wpinv_installed', $merged_options, 30 );
81
+    set_transient('_wpinv_installed', $merged_options, 30);
82 82
     
83 83
     // Bail if activating from network, or bulk
84
-    if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
84
+    if (is_network_admin() || isset($_GET['activate-multi'])) {
85 85
         return;
86 86
     }
87 87
     
88 88
     // Add the transient to redirect
89
-    set_transient( '_wpinv_activation_redirect', true, 30 );
89
+    set_transient('_wpinv_activation_redirect', true, 30);
90 90
 }
91 91
 
92 92
 /**
93 93
  * When a new Blog is created in multisite, see if Invoicing is network activated, and run the installer.
94 94
  *
95 95
  */
96
-function wpinv_new_blog_created( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
97
-    if ( is_plugin_active_for_network( plugin_basename( WPINV_PLUGIN_FILE ) ) ) {
98
-        switch_to_blog( $blog_id );
96
+function wpinv_new_blog_created($blog_id, $user_id, $domain, $path, $site_id, $meta) {
97
+    if (is_plugin_active_for_network(plugin_basename(WPINV_PLUGIN_FILE))) {
98
+        switch_to_blog($blog_id);
99 99
         wpinv_run_install();
100 100
         restore_current_blog();
101 101
     }
102 102
 }
103
-add_action( 'wpmu_new_blog', 'wpinv_new_blog_created', 10, 6 );
103
+add_action('wpmu_new_blog', 'wpinv_new_blog_created', 10, 6);
104 104
 
105 105
 /**
106 106
  * Post-installation.
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
  * Runs just after plugin installation and exposes the wpinv_after_install hook.
109 109
  */
110 110
 function wpinv_after_install() {
111
-    if ( ! is_admin() ) {
111
+    if (!is_admin()) {
112 112
         return;
113 113
     }
114 114
 
115
-    $wpinv_options      = get_transient( '_wpinv_installed' );
116
-    $wpinv_table_check  = get_option( '_wpinv_table_check', false );
115
+    $wpinv_options      = get_transient('_wpinv_installed');
116
+    $wpinv_table_check  = get_option('_wpinv_table_check', false);
117 117
 
118
-    if ( false === $wpinv_table_check || current_time( 'timestamp' ) > $wpinv_table_check ) {
119
-        update_option( '_wpinv_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
118
+    if (false === $wpinv_table_check || current_time('timestamp') > $wpinv_table_check) {
119
+        update_option('_wpinv_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
120 120
     }
121 121
 
122
-    if ( false !== $wpinv_options ) {
122
+    if (false !== $wpinv_options) {
123 123
         // Delete the transient
124
-        delete_transient( '_wpinv_installed' );
124
+        delete_transient('_wpinv_installed');
125 125
     }
126 126
 }
127
-add_action( 'admin_init', 'wpinv_after_install' );
127
+add_action('admin_init', 'wpinv_after_install');
128 128
 
129 129
 function wpinv_create_pages() {
130 130
     global $wpinv_options;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
     $options = array();
133 133
     
134 134
     // Checks if the purchase page option exists
135
-    if ( ! array_key_exists( 'checkout_page', $wpinv_options ) ) {
135
+    if (!array_key_exists('checkout_page', $wpinv_options)) {
136 136
         // Checkout Page
137 137
         $checkout = wp_insert_post(
138 138
             array(
139
-                'post_title'     => __( 'Checkout', 'invoicing' ),
139
+                'post_title'     => __('Checkout', 'invoicing'),
140 140
                 'post_content'   => '[wpinv_checkout]',
141 141
                 'post_status'    => 'publish',
142 142
                 'post_author'    => 1,
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         // Invoice History (History) Page
151 151
         $history = wp_insert_post(
152 152
             array(
153
-                'post_title'     => __( 'Invoice History', 'invoicing' ),
153
+                'post_title'     => __('Invoice History', 'invoicing'),
154 154
                 'post_content'   => '[wpinv_history]',
155 155
                 'post_status'    => 'publish',
156 156
                 'post_author'    => 1,
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
         // Payment Confirmation (Success) Page
165 165
         $success = wp_insert_post(
166 166
             array(
167
-                'post_title'     => __( 'Payment Confirmation', 'invoicing' ),
168
-                'post_content'   => __( '[wpinv_receipt]', 'invoicing' ),
167
+                'post_title'     => __('Payment Confirmation', 'invoicing'),
168
+                'post_content'   => __('[wpinv_receipt]', 'invoicing'),
169 169
                 'post_status'    => 'publish',
170 170
                 'post_author'    => 1,
171 171
                 'post_parent'    => $checkout,
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
         // Failed Payment Page
179 179
         $failed = wp_insert_post(
180 180
             array(
181
-                'post_title'     => __( 'Transaction Failed', 'invoicing' ),
182
-                'post_content'   => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
181
+                'post_title'     => __('Transaction Failed', 'invoicing'),
182
+                'post_content'   => __('Your transaction failed, please try again or contact site support.', 'invoicing'),
183 183
                 'post_status'    => 'publish',
184 184
                 'post_author'    => 1,
185 185
                 'post_type'      => 'page',
Please login to merge, or discard this patch.
includes/admin/register-settings.php 3 patches
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -912,10 +912,11 @@  discard block
 block discarded – undo
912 912
         
913 913
         $checked = false;
914 914
 
915
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
916
-			$checked = true;
917
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
918
-			$checked = true;
915
+		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) {
916
+					$checked = true;
917
+		} elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) {
918
+					$checked = true;
919
+		}
919 920
 
920 921
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
921 922
 		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
@@ -932,10 +933,11 @@  discard block
 block discarded – undo
932 933
 	foreach ( $args['options'] as $key => $option ) :
933 934
 		$sanitize_key = wpinv_sanitize_key( $key );
934 935
         
935
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
936
-			$enabled = '1';
937
-		else
938
-			$enabled = null;
936
+        if ( isset( $wpinv_options['gateways'][ $key ] ) ) {
937
+        			$enabled = '1';
938
+        } else {
939
+					$enabled = null;
940
+		}
939 941
 
940 942
 		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
941 943
 		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
@@ -1302,7 +1304,8 @@  discard block
 block discarded – undo
1302 1304
 				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1303 1305
 			</tr>
1304 1306
 			<?php endforeach; ?>
1305
-		<?php else : ?>
1307
+		<?php else {
1308
+    : ?>
1306 1309
 			<tr>
1307 1310
 				<td class="wpinv_tax_country">
1308 1311
 					<?php
@@ -1314,7 +1317,9 @@  discard block
 block discarded – undo
1314 1317
 						'class'            => 'wpinv-tax-country',
1315 1318
 						'chosen'           => false,
1316 1319
 						'placeholder'      => __( 'Choose a country', 'invoicing' )
1317
-					) ); ?>
1320
+					) );
1321
+}
1322
+?>
1318 1323
 				</td>
1319 1324
 				<td class="wpinv_tax_state">
1320 1325
 					<?php echo wpinv_html_text( array(
Please login to merge, or discard this patch.
Indentation   +336 added lines, -336 removed lines patch added patch discarded remove patch
@@ -831,328 +831,328 @@  discard block
 block discarded – undo
831 831
 }
832 832
 
833 833
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
834
-	$pages_options = array();
834
+    $pages_options = array();
835 835
 
836
-	if( $default_label !== NULL && $default_label !== false ) {
837
-		$pages_options = array( '' => $default_label ); // Blank option
838
-	}
836
+    if( $default_label !== NULL && $default_label !== false ) {
837
+        $pages_options = array( '' => $default_label ); // Blank option
838
+    }
839 839
 
840
-	$pages = get_pages();
841
-	if ( $pages ) {
842
-		foreach ( $pages as $page ) {
843
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
840
+    $pages = get_pages();
841
+    if ( $pages ) {
842
+        foreach ( $pages as $page ) {
843
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
844 844
             $pages_options[ $page->ID ] = $title;
845
-		}
846
-	}
845
+        }
846
+    }
847 847
 
848
-	return $pages_options;
848
+    return $pages_options;
849 849
 }
850 850
 
851 851
 function wpinv_header_callback( $args ) {
852
-	if ( !empty( $args['desc'] ) ) {
852
+    if ( !empty( $args['desc'] ) ) {
853 853
         echo $args['desc'];
854 854
     }
855 855
 }
856 856
 
857 857
 function wpinv_hidden_callback( $args ) {
858
-	global $wpinv_options;
859
-
860
-	if ( isset( $args['set_value'] ) ) {
861
-		$value = $args['set_value'];
862
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
863
-		$value = $wpinv_options[ $args['id'] ];
864
-	} else {
865
-		$value = isset( $args['std'] ) ? $args['std'] : '';
866
-	}
867
-
868
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
869
-		$args['readonly'] = true;
870
-		$value = isset( $args['std'] ) ? $args['std'] : '';
871
-		$name  = '';
872
-	} else {
873
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
874
-	}
875
-
876
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
858
+    global $wpinv_options;
859
+
860
+    if ( isset( $args['set_value'] ) ) {
861
+        $value = $args['set_value'];
862
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
863
+        $value = $wpinv_options[ $args['id'] ];
864
+    } else {
865
+        $value = isset( $args['std'] ) ? $args['std'] : '';
866
+    }
867
+
868
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
869
+        $args['readonly'] = true;
870
+        $value = isset( $args['std'] ) ? $args['std'] : '';
871
+        $name  = '';
872
+    } else {
873
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
874
+    }
875
+
876
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
877 877
     
878
-	echo $html;
878
+    echo $html;
879 879
 }
880 880
 
881 881
 function wpinv_checkbox_callback( $args ) {
882
-	global $wpinv_options;
882
+    global $wpinv_options;
883 883
     
884 884
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
885 885
 
886
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
887
-		$name = '';
888
-	} else {
889
-		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
890
-	}
886
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
887
+        $name = '';
888
+    } else {
889
+        $name = 'name="wpinv_settings[' . $sanitize_id . ']"';
890
+    }
891 891
 
892
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
893
-	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
894
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+    $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
893
+    $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
894
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
895 895
 
896
-	echo $html;
896
+    echo $html;
897 897
 }
898 898
 
899 899
 function wpinv_multicheck_callback( $args ) {
900
-	global $wpinv_options;
900
+    global $wpinv_options;
901 901
 	
902
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
902
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
903 903
 	
904
-	if ( ! empty( $args['options'] ) ) {
905
-		foreach( $args['options'] as $key => $option ):
906
-			$sanitize_key = wpinv_sanitize_key( $key );
907
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
908
-				$enabled = $sanitize_key;
909
-			} else { 
910
-				$enabled = NULL; 
911
-			}
912
-			echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
913
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
914
-		endforeach;
915
-		echo '<p class="description">' . $args['desc'] . '</p>';
916
-	}
904
+    if ( ! empty( $args['options'] ) ) {
905
+        foreach( $args['options'] as $key => $option ):
906
+            $sanitize_key = wpinv_sanitize_key( $key );
907
+            if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
908
+                $enabled = $sanitize_key;
909
+            } else { 
910
+                $enabled = NULL; 
911
+            }
912
+            echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
913
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
914
+        endforeach;
915
+        echo '<p class="description">' . $args['desc'] . '</p>';
916
+    }
917 917
 }
918 918
 
919 919
 function wpinv_payment_icons_callback( $args ) {
920
-	global $wpinv_options;
920
+    global $wpinv_options;
921 921
     
922 922
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
923 923
 
924
-	if ( ! empty( $args['options'] ) ) {
925
-		foreach( $args['options'] as $key => $option ) {
924
+    if ( ! empty( $args['options'] ) ) {
925
+        foreach( $args['options'] as $key => $option ) {
926 926
             $sanitize_key = wpinv_sanitize_key( $key );
927 927
             
928
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
929
-				$enabled = $option;
930
-			} else {
931
-				$enabled = NULL;
932
-			}
933
-
934
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
935
-
936
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
937
-
938
-				if ( wpinv_string_is_image_url( $key ) ) {
939
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
940
-				} else {
941
-					$card = strtolower( str_replace( ' ', '', $option ) );
942
-
943
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
944
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
945
-					} else {
946
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
947
-						$content_dir = WP_CONTENT_DIR;
948
-
949
-						if ( function_exists( 'wp_normalize_path' ) ) {
950
-							// Replaces backslashes with forward slashes for Windows systems
951
-							$image = wp_normalize_path( $image );
952
-							$content_dir = wp_normalize_path( $content_dir );
953
-						}
954
-
955
-						$image = str_replace( $content_dir, content_url(), $image );
956
-					}
957
-
958
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
959
-				}
960
-			echo $option . '</label>';
961
-		}
962
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
963
-	}
928
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
929
+                $enabled = $option;
930
+            } else {
931
+                $enabled = NULL;
932
+            }
933
+
934
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
935
+
936
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
937
+
938
+                if ( wpinv_string_is_image_url( $key ) ) {
939
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
940
+                } else {
941
+                    $card = strtolower( str_replace( ' ', '', $option ) );
942
+
943
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
944
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
945
+                    } else {
946
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
947
+                        $content_dir = WP_CONTENT_DIR;
948
+
949
+                        if ( function_exists( 'wp_normalize_path' ) ) {
950
+                            // Replaces backslashes with forward slashes for Windows systems
951
+                            $image = wp_normalize_path( $image );
952
+                            $content_dir = wp_normalize_path( $content_dir );
953
+                        }
954
+
955
+                        $image = str_replace( $content_dir, content_url(), $image );
956
+                    }
957
+
958
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
959
+                }
960
+            echo $option . '</label>';
961
+        }
962
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
963
+    }
964 964
 }
965 965
 
966 966
 function wpinv_radio_callback( $args ) {
967
-	global $wpinv_options;
967
+    global $wpinv_options;
968 968
     
969 969
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
970 970
     
971 971
     foreach ( $args['options'] as $key => $option ) :
972
-		$sanitize_key = wpinv_sanitize_key( $key );
972
+        $sanitize_key = wpinv_sanitize_key( $key );
973 973
         
974 974
         $checked = false;
975 975
 
976
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
977
-			$checked = true;
978
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
979
-			$checked = true;
976
+        if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
977
+            $checked = true;
978
+        elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
979
+            $checked = true;
980 980
 
981
-		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
982
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
983
-	endforeach;
981
+        echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
982
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
983
+    endforeach;
984 984
 
985
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
985
+    echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
986 986
 }
987 987
 
988 988
 function wpinv_gateways_callback( $args ) {
989
-	global $wpinv_options;
989
+    global $wpinv_options;
990 990
     
991 991
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
992 992
 
993
-	foreach ( $args['options'] as $key => $option ) :
994
-		$sanitize_key = wpinv_sanitize_key( $key );
993
+    foreach ( $args['options'] as $key => $option ) :
994
+        $sanitize_key = wpinv_sanitize_key( $key );
995 995
         
996 996
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
997
-			$enabled = '1';
998
-		else
999
-			$enabled = null;
997
+            $enabled = '1';
998
+        else
999
+            $enabled = null;
1000 1000
 
1001
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1002
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1003
-	endforeach;
1001
+        echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1002
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1003
+    endforeach;
1004 1004
 }
1005 1005
 
1006 1006
 function wpinv_gateway_select_callback($args) {
1007
-	global $wpinv_options;
1007
+    global $wpinv_options;
1008 1008
     
1009 1009
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1010 1010
 
1011
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1011
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1012 1012
 
1013
-	foreach ( $args['options'] as $key => $option ) :
1014
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1013
+    foreach ( $args['options'] as $key => $option ) :
1014
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1015 1015
             $selected = selected( $key, $args['selected'], false );
1016 1016
         } else {
1017 1017
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1018 1018
         }
1019
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1020
-	endforeach;
1019
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1020
+    endforeach;
1021 1021
 
1022
-	echo '</select>';
1023
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1022
+    echo '</select>';
1023
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1024 1024
 }
1025 1025
 
1026 1026
 function wpinv_text_callback( $args ) {
1027
-	global $wpinv_options;
1027
+    global $wpinv_options;
1028 1028
     
1029 1029
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1030 1030
 
1031
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1032
-		$value = $wpinv_options[ $args['id'] ];
1033
-	} else {
1034
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1035
-	}
1036
-
1037
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1038
-		$args['readonly'] = true;
1039
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1040
-		$name  = '';
1041
-	} else {
1042
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1043
-	}
1044
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1045
-
1046
-	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1047
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1048
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1049
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1050
-
1051
-	echo $html;
1031
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1032
+        $value = $wpinv_options[ $args['id'] ];
1033
+    } else {
1034
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1035
+    }
1036
+
1037
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1038
+        $args['readonly'] = true;
1039
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1040
+        $name  = '';
1041
+    } else {
1042
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1043
+    }
1044
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1045
+
1046
+    $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1047
+    $size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1048
+    $html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1049
+    $html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1050
+
1051
+    echo $html;
1052 1052
 }
1053 1053
 
1054 1054
 function wpinv_number_callback( $args ) {
1055
-	global $wpinv_options;
1055
+    global $wpinv_options;
1056 1056
     
1057 1057
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1058 1058
 
1059
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1060
-		$value = $wpinv_options[ $args['id'] ];
1061
-	} else {
1062
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1063
-	}
1064
-
1065
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1066
-		$args['readonly'] = true;
1067
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1068
-		$name  = '';
1069
-	} else {
1070
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1071
-	}
1072
-
1073
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1074
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1075
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1076
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1077
-
1078
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1079
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1080
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1081
-
1082
-	echo $html;
1059
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1060
+        $value = $wpinv_options[ $args['id'] ];
1061
+    } else {
1062
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1063
+    }
1064
+
1065
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1066
+        $args['readonly'] = true;
1067
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1068
+        $name  = '';
1069
+    } else {
1070
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1071
+    }
1072
+
1073
+    $max  = isset( $args['max'] ) ? $args['max'] : 999999;
1074
+    $min  = isset( $args['min'] ) ? $args['min'] : 0;
1075
+    $step = isset( $args['step'] ) ? $args['step'] : 1;
1076
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1077
+
1078
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1079
+    $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1080
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1081
+
1082
+    echo $html;
1083 1083
 }
1084 1084
 
1085 1085
 function wpinv_textarea_callback( $args ) {
1086
-	global $wpinv_options;
1086
+    global $wpinv_options;
1087 1087
     
1088 1088
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1089 1089
 
1090
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1091
-		$value = $wpinv_options[ $args['id'] ];
1092
-	} else {
1093
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1094
-	}
1090
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1091
+        $value = $wpinv_options[ $args['id'] ];
1092
+    } else {
1093
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1094
+    }
1095 1095
     
1096 1096
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1097 1097
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1098 1098
 
1099
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1100
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1099
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1100
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1101 1101
 
1102
-	echo $html;
1102
+    echo $html;
1103 1103
 }
1104 1104
 
1105 1105
 function wpinv_password_callback( $args ) {
1106
-	global $wpinv_options;
1106
+    global $wpinv_options;
1107 1107
     
1108 1108
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1109 1109
 
1110
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1111
-		$value = $wpinv_options[ $args['id'] ];
1112
-	} else {
1113
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1114
-	}
1110
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1111
+        $value = $wpinv_options[ $args['id'] ];
1112
+    } else {
1113
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1114
+    }
1115 1115
 
1116
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1117
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
1118
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1116
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1117
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
1118
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1119 1119
 
1120
-	echo $html;
1120
+    echo $html;
1121 1121
 }
1122 1122
 
1123 1123
 function wpinv_missing_callback($args) {
1124
-	printf(
1125
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1126
-		'<strong>' . $args['id'] . '</strong>'
1127
-	);
1124
+    printf(
1125
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1126
+        '<strong>' . $args['id'] . '</strong>'
1127
+    );
1128 1128
 }
1129 1129
 
1130 1130
 function wpinv_select_callback($args) {
1131
-	global $wpinv_options;
1131
+    global $wpinv_options;
1132 1132
     
1133 1133
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1134 1134
 
1135
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1136
-		$value = $wpinv_options[ $args['id'] ];
1137
-	} else {
1138
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1139
-	}
1135
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1136
+        $value = $wpinv_options[ $args['id'] ];
1137
+    } else {
1138
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1139
+    }
1140 1140
     
1141 1141
     if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1142 1142
         $value = $args['selected'];
1143 1143
     }
1144 1144
 
1145
-	if ( isset( $args['placeholder'] ) ) {
1146
-		$placeholder = $args['placeholder'];
1147
-	} else {
1148
-		$placeholder = '';
1149
-	}
1150
-
1151
-	if ( isset( $args['chosen'] ) ) {
1152
-		$chosen = 'class="wpinv-chosen"';
1153
-	} else {
1154
-		$chosen = '';
1155
-	}
1145
+    if ( isset( $args['placeholder'] ) ) {
1146
+        $placeholder = $args['placeholder'];
1147
+    } else {
1148
+        $placeholder = '';
1149
+    }
1150
+
1151
+    if ( isset( $args['chosen'] ) ) {
1152
+        $chosen = 'class="wpinv-chosen"';
1153
+    } else {
1154
+        $chosen = '';
1155
+    }
1156 1156
     
1157 1157
     if( !empty( $args['onchange'] ) ) {
1158 1158
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
@@ -1160,143 +1160,143 @@  discard block
 block discarded – undo
1160 1160
         $onchange = '';
1161 1161
     }
1162 1162
 
1163
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1163
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1164 1164
 
1165
-	foreach ( $args['options'] as $option => $name ) {
1166
-		$selected = selected( $option, $value, false );
1167
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1168
-	}
1165
+    foreach ( $args['options'] as $option => $name ) {
1166
+        $selected = selected( $option, $value, false );
1167
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1168
+    }
1169 1169
 
1170
-	$html .= '</select>';
1171
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1170
+    $html .= '</select>';
1171
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1172 1172
 
1173
-	echo $html;
1173
+    echo $html;
1174 1174
 }
1175 1175
 
1176 1176
 function wpinv_color_select_callback( $args ) {
1177
-	global $wpinv_options;
1177
+    global $wpinv_options;
1178 1178
     
1179 1179
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1180 1180
 
1181
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1182
-		$value = $wpinv_options[ $args['id'] ];
1183
-	} else {
1184
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1185
-	}
1181
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1182
+        $value = $wpinv_options[ $args['id'] ];
1183
+    } else {
1184
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1185
+    }
1186 1186
 
1187
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1187
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1188 1188
 
1189
-	foreach ( $args['options'] as $option => $color ) {
1190
-		$selected = selected( $option, $value, false );
1191
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1192
-	}
1189
+    foreach ( $args['options'] as $option => $color ) {
1190
+        $selected = selected( $option, $value, false );
1191
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1192
+    }
1193 1193
 
1194
-	$html .= '</select>';
1195
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1194
+    $html .= '</select>';
1195
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1196 1196
 
1197
-	echo $html;
1197
+    echo $html;
1198 1198
 }
1199 1199
 
1200 1200
 function wpinv_rich_editor_callback( $args ) {
1201
-	global $wpinv_options, $wp_version;
1201
+    global $wpinv_options, $wp_version;
1202 1202
     
1203 1203
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1204 1204
 
1205
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1206
-		$value = $wpinv_options[ $args['id'] ];
1205
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1206
+        $value = $wpinv_options[ $args['id'] ];
1207 1207
 
1208
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1209
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1210
-		}
1211
-	} else {
1212
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1213
-	}
1208
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1209
+            $value = isset( $args['std'] ) ? $args['std'] : '';
1210
+        }
1211
+    } else {
1212
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1213
+    }
1214 1214
 
1215
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1215
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
1216 1216
 
1217
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1218
-		ob_start();
1219
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1220
-		$html = ob_get_clean();
1221
-	} else {
1222
-		$html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1223
-	}
1217
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1218
+        ob_start();
1219
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1220
+        $html = ob_get_clean();
1221
+    } else {
1222
+        $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1223
+    }
1224 1224
 
1225
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1225
+    $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1226 1226
 
1227
-	echo $html;
1227
+    echo $html;
1228 1228
 }
1229 1229
 
1230 1230
 function wpinv_upload_callback( $args ) {
1231
-	global $wpinv_options;
1231
+    global $wpinv_options;
1232 1232
     
1233 1233
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1234 1234
 
1235
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1236
-		$value = $wpinv_options[$args['id']];
1237
-	} else {
1238
-		$value = isset($args['std']) ? $args['std'] : '';
1239
-	}
1235
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1236
+        $value = $wpinv_options[$args['id']];
1237
+    } else {
1238
+        $value = isset($args['std']) ? $args['std'] : '';
1239
+    }
1240 1240
 
1241
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1242
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1243
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1244
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1241
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1242
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1243
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1244
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1245 1245
 
1246
-	echo $html;
1246
+    echo $html;
1247 1247
 }
1248 1248
 
1249 1249
 function wpinv_color_callback( $args ) {
1250
-	global $wpinv_options;
1250
+    global $wpinv_options;
1251 1251
     
1252 1252
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1253 1253
 
1254
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1255
-		$value = $wpinv_options[ $args['id'] ];
1256
-	} else {
1257
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1258
-	}
1254
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1255
+        $value = $wpinv_options[ $args['id'] ];
1256
+    } else {
1257
+        $value = isset( $args['std'] ) ? $args['std'] : '';
1258
+    }
1259 1259
 
1260
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1260
+    $default = isset( $args['std'] ) ? $args['std'] : '';
1261 1261
 
1262
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
1263
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1262
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
1263
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1264 1264
 
1265
-	echo $html;
1265
+    echo $html;
1266 1266
 }
1267 1267
 
1268 1268
 function wpinv_country_states_callback($args) {
1269
-	global $wpinv_options;
1269
+    global $wpinv_options;
1270 1270
     
1271 1271
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
1272 1272
 
1273
-	if ( isset( $args['placeholder'] ) ) {
1274
-		$placeholder = $args['placeholder'];
1275
-	} else {
1276
-		$placeholder = '';
1277
-	}
1273
+    if ( isset( $args['placeholder'] ) ) {
1274
+        $placeholder = $args['placeholder'];
1275
+    } else {
1276
+        $placeholder = '';
1277
+    }
1278 1278
 
1279
-	$states = wpinv_get_country_states();
1279
+    $states = wpinv_get_country_states();
1280 1280
 
1281
-	$chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1282
-	$class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1283
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1281
+    $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1282
+    $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1283
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1284 1284
 
1285
-	foreach ( $states as $option => $name ) {
1286
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1287
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1288
-	}
1285
+    foreach ( $states as $option => $name ) {
1286
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1287
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1288
+    }
1289 1289
 
1290
-	$html .= '</select>';
1291
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1290
+    $html .= '</select>';
1291
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1292 1292
 
1293
-	echo $html;
1293
+    echo $html;
1294 1294
 }
1295 1295
 
1296 1296
 function wpinv_tax_rates_callback($args) {
1297
-	global $wpinv_options;
1298
-	$rates = wpinv_get_tax_rates();
1299
-	ob_start(); ?>
1297
+    global $wpinv_options;
1298
+    $rates = wpinv_get_tax_rates();
1299
+    ob_start(); ?>
1300 1300
     </td><tr>
1301 1301
     <td colspan="2" class="wpinv_tax_tdbox">
1302 1302
 	<p><?php echo $args['desc']; ?></p>
@@ -1320,41 +1320,41 @@  discard block
 block discarded – undo
1320 1320
 			<tr>
1321 1321
 				<td class="wpinv_tax_country">
1322 1322
 					<?php
1323
-					echo wpinv_html_select( array(
1324
-						'options'          => wpinv_get_country_list( true ),
1325
-						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1323
+                    echo wpinv_html_select( array(
1324
+                        'options'          => wpinv_get_country_list( true ),
1325
+                        'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1326 1326
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1327
-						'selected'         => $rate['country'],
1328
-						'show_option_all'  => false,
1329
-						'show_option_none' => false,
1330
-						'class'            => 'wpinv-tax-country',
1331
-						'chosen'           => false,
1332
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1333
-					) );
1334
-					?>
1327
+                        'selected'         => $rate['country'],
1328
+                        'show_option_all'  => false,
1329
+                        'show_option_none' => false,
1330
+                        'class'            => 'wpinv-tax-country',
1331
+                        'chosen'           => false,
1332
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
1333
+                    ) );
1334
+                    ?>
1335 1335
 				</td>
1336 1336
 				<td class="wpinv_tax_state">
1337 1337
 					<?php
1338
-					$states = wpinv_get_country_states( $rate['country'] );
1339
-					if( !empty( $states ) ) {
1340
-						echo wpinv_html_select( array(
1341
-							'options'          => array_merge( array( '' => '' ), $states ),
1342
-							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1338
+                    $states = wpinv_get_country_states( $rate['country'] );
1339
+                    if( !empty( $states ) ) {
1340
+                        echo wpinv_html_select( array(
1341
+                            'options'          => array_merge( array( '' => '' ), $states ),
1342
+                            'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1343 1343
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1344
-							'selected'         => $rate['state'],
1345
-							'show_option_all'  => false,
1346
-							'show_option_none' => false,
1347
-							'chosen'           => false,
1348
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1349
-						) );
1350
-					} else {
1351
-						echo wpinv_html_text( array(
1352
-							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1353
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1344
+                            'selected'         => $rate['state'],
1345
+                            'show_option_all'  => false,
1346
+                            'show_option_none' => false,
1347
+                            'chosen'           => false,
1348
+                            'placeholder'      => __( 'Choose a state', 'invoicing' )
1349
+                        ) );
1350
+                    } else {
1351
+                        echo wpinv_html_text( array(
1352
+                            'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1353
+                            'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1354 1354
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1355
-						) );
1356
-					}
1357
-					?>
1355
+                        ) );
1356
+                    }
1357
+                    ?>
1358 1358
 				</td>
1359 1359
 				<td class="wpinv_tax_global">
1360 1360
 					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
@@ -1369,20 +1369,20 @@  discard block
 block discarded – undo
1369 1369
 			<tr>
1370 1370
 				<td class="wpinv_tax_country">
1371 1371
 					<?php
1372
-					echo wpinv_html_select( array(
1373
-						'options'          => wpinv_get_country_list( true ),
1374
-						'name'             => 'tax_rates[0][country]',
1375
-						'show_option_all'  => false,
1376
-						'show_option_none' => false,
1377
-						'class'            => 'wpinv-tax-country',
1378
-						'chosen'           => false,
1379
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1380
-					) ); ?>
1372
+                    echo wpinv_html_select( array(
1373
+                        'options'          => wpinv_get_country_list( true ),
1374
+                        'name'             => 'tax_rates[0][country]',
1375
+                        'show_option_all'  => false,
1376
+                        'show_option_none' => false,
1377
+                        'class'            => 'wpinv-tax-country',
1378
+                        'chosen'           => false,
1379
+                        'placeholder'      => __( 'Choose a country', 'invoicing' )
1380
+                    ) ); ?>
1381 1381
 				</td>
1382 1382
 				<td class="wpinv_tax_state">
1383 1383
 					<?php echo wpinv_html_text( array(
1384
-						'name' => 'tax_rates[0][state]'
1385
-					) ); ?>
1384
+                        'name' => 'tax_rates[0][state]'
1385
+                    ) ); ?>
1386 1386
 				</td>
1387 1387
 				<td class="wpinv_tax_global">
1388 1388
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
         <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1398 1398
 	</table>
1399 1399
 	<?php
1400
-	echo ob_get_clean();
1400
+    echo ob_get_clean();
1401 1401
 }
1402 1402
 
1403 1403
 function wpinv_tools_callback($args) {
@@ -1425,15 +1425,15 @@  discard block
 block discarded – undo
1425 1425
 }
1426 1426
 
1427 1427
 function wpinv_descriptive_text_callback( $args ) {
1428
-	echo wp_kses_post( $args['desc'] );
1428
+    echo wp_kses_post( $args['desc'] );
1429 1429
 }
1430 1430
 
1431 1431
 function wpinv_hook_callback( $args ) {
1432
-	do_action( 'wpinv_' . $args['id'], $args );
1432
+    do_action( 'wpinv_' . $args['id'], $args );
1433 1433
 }
1434 1434
 
1435 1435
 function wpinv_set_settings_cap() {
1436
-	return 'manage_options';
1436
+    return 'manage_options';
1437 1437
 }
1438 1438
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1439 1439
 
Please login to merge, or discard this patch.
Spacing   +490 added lines, -490 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_get_option( $key = '', $default = false ) {
7
+function wpinv_get_option($key = '', $default = false) {
8 8
     global $wpinv_options;
9 9
 
10
-    $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default;
11
-    $value = apply_filters( 'wpinv_get_option', $value, $key, $default );
10
+    $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default;
11
+    $value = apply_filters('wpinv_get_option', $value, $key, $default);
12 12
 
13
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
13
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
14 14
 }
15 15
 
16
-function wpinv_update_option( $key = '', $value = false ) {
16
+function wpinv_update_option($key = '', $value = false) {
17 17
     // If no key, exit
18
-    if ( empty( $key ) ) {
18
+    if (empty($key)) {
19 19
         return false;
20 20
     }
21 21
 
22
-    if ( empty( $value ) ) {
23
-        $remove_option = wpinv_delete_option( $key );
22
+    if (empty($value)) {
23
+        $remove_option = wpinv_delete_option($key);
24 24
         return $remove_option;
25 25
     }
26 26
 
27 27
     // First let's grab the current settings
28
-    $options = get_option( 'wpinv_settings' );
28
+    $options = get_option('wpinv_settings');
29 29
 
30 30
     // Let's let devs alter that value coming in
31
-    $value = apply_filters( 'wpinv_update_option', $value, $key );
31
+    $value = apply_filters('wpinv_update_option', $value, $key);
32 32
 
33 33
     // Next let's try to update the value
34
-    $options[ $key ] = $value;
35
-    $did_update = update_option( 'wpinv_settings', $options );
34
+    $options[$key] = $value;
35
+    $did_update = update_option('wpinv_settings', $options);
36 36
 
37 37
     // If it updated, let's update the global variable
38
-    if ( $did_update ) {
38
+    if ($did_update) {
39 39
         global $wpinv_options;
40
-        $wpinv_options[ $key ] = $value;
40
+        $wpinv_options[$key] = $value;
41 41
     }
42 42
 
43 43
     return $did_update;
44 44
 }
45 45
 
46
-function wpinv_delete_option( $key = '' ) {
46
+function wpinv_delete_option($key = '') {
47 47
     // If no key, exit
48
-    if ( empty( $key ) ) {
48
+    if (empty($key)) {
49 49
         return false;
50 50
     }
51 51
 
52 52
     // First let's grab the current settings
53
-    $options = get_option( 'wpinv_settings' );
53
+    $options = get_option('wpinv_settings');
54 54
 
55 55
     // Next let's try to update the value
56
-    if( isset( $options[ $key ] ) ) {
57
-        unset( $options[ $key ] );
56
+    if (isset($options[$key])) {
57
+        unset($options[$key]);
58 58
     }
59 59
 
60
-    $did_update = update_option( 'wpinv_settings', $options );
60
+    $did_update = update_option('wpinv_settings', $options);
61 61
 
62 62
     // If it updated, let's update the global variable
63
-    if ( $did_update ){
63
+    if ($did_update) {
64 64
         global $wpinv_options;
65 65
         $wpinv_options = $options;
66 66
     }
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_get_settings() {
72
-    $settings = get_option( 'wpinv_settings' );
72
+    $settings = get_option('wpinv_settings');
73 73
 
74
-    if ( empty( $settings ) ) {
74
+    if (empty($settings)) {
75 75
         // Update old settings with new single option
76
-        $general_settings   = is_array( get_option( 'wpinv_settings_general' ) )    ? get_option( 'wpinv_settings_general' )    : array();
77
-        $gateways_settings  = is_array( get_option( 'wpinv_settings_gateways' ) )   ? get_option( 'wpinv_settings_gateways' )   : array();
78
-        $email_settings     = is_array( get_option( 'wpinv_settings_emails' ) )     ? get_option( 'wpinv_settings_emails' )     : array();
79
-        $tax_settings       = is_array( get_option( 'wpinv_settings_taxes' ) )      ? get_option( 'wpinv_settings_taxes' )      : array();
80
-        $misc_settings      = is_array( get_option( 'wpinv_settings_misc' ) )       ? get_option( 'wpinv_settings_misc' )       : array();
81
-        $tool_settings      = is_array( get_option( 'wpinv_settings_tools' ) )      ? get_option( 'wpinv_settings_tools' )      : array();
76
+        $general_settings   = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array();
77
+        $gateways_settings  = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array();
78
+        $email_settings     = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array();
79
+        $tax_settings       = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array();
80
+        $misc_settings      = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array();
81
+        $tool_settings      = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array();
82 82
 
83
-        $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings );
83
+        $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings);
84 84
 
85
-        update_option( 'wpinv_settings', $settings );
85
+        update_option('wpinv_settings', $settings);
86 86
 
87 87
     }
88
-    return apply_filters( 'wpinv_get_settings', $settings );
88
+    return apply_filters('wpinv_get_settings', $settings);
89 89
 }
90 90
 
91 91
 function wpinv_register_settings() {
92
-    if ( false == get_option( 'wpinv_settings' ) ) {
93
-        add_option( 'wpinv_settings' );
92
+    if (false == get_option('wpinv_settings')) {
93
+        add_option('wpinv_settings');
94 94
     }
95 95
     
96 96
     $register_settings = wpinv_get_registered_settings();
97 97
     
98
-    foreach ( $register_settings as $tab => $sections ) {
99
-        foreach ( $sections as $section => $settings) {
98
+    foreach ($register_settings as $tab => $sections) {
99
+        foreach ($sections as $section => $settings) {
100 100
             // Check for backwards compatibility
101
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
102
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
101
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
102
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
103 103
                 $section = 'main';
104 104
                 $settings = $sections;
105 105
             }
@@ -111,42 +111,42 @@  discard block
 block discarded – undo
111 111
                 'wpinv_settings_' . $tab . '_' . $section
112 112
             );
113 113
 
114
-            foreach ( $settings as $option ) {
114
+            foreach ($settings as $option) {
115 115
                 // For backwards compatibility
116
-                if ( empty( $option['id'] ) ) {
116
+                if (empty($option['id'])) {
117 117
                     continue;
118 118
                 }
119 119
 
120
-                $name = isset( $option['name'] ) ? $option['name'] : '';
120
+                $name = isset($option['name']) ? $option['name'] : '';
121 121
 
122 122
                 add_settings_field(
123 123
                     'wpinv_settings[' . $option['id'] . ']',
124 124
                     $name,
125
-                    function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
125
+                    function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
126 126
                     'wpinv_settings_' . $tab . '_' . $section,
127 127
                     'wpinv_settings_' . $tab . '_' . $section,
128 128
                     array(
129 129
                         'section'     => $section,
130
-                        'id'          => isset( $option['id'] )          ? $option['id']          : null,
131
-                        'desc'        => ! empty( $option['desc'] )      ? $option['desc']        : '',
132
-                        'name'        => isset( $option['name'] )        ? $option['name']        : null,
133
-                        'size'        => isset( $option['size'] )        ? $option['size']        : null,
134
-                        'options'     => isset( $option['options'] )     ? $option['options']     : '',
135
-                        'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
136
-                        'std'         => isset( $option['std'] )         ? $option['std']         : '',
137
-                        'min'         => isset( $option['min'] )         ? $option['min']         : null,
138
-                        'max'         => isset( $option['max'] )         ? $option['max']         : null,
139
-                        'step'        => isset( $option['step'] )        ? $option['step']        : null,
140
-                        'chosen'      => isset( $option['chosen'] )      ? $option['chosen']      : null,
141
-                        'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
142
-                        'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
143
-                        'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
144
-                        'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
145
-                        'onchange'    => !empty( $option['onchange'] )   ? $option['onchange']    : '',
146
-                        'custom'      => !empty( $option['custom'] )     ? $option['custom']      : '',
147
-                        'class'       =>  !empty( $option['class'] )     ? $option['class']      : '',
148
-                        'cols'        => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
149
-                        'rows'        => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
130
+                        'id'          => isset($option['id']) ? $option['id'] : null,
131
+                        'desc'        => !empty($option['desc']) ? $option['desc'] : '',
132
+                        'name'        => isset($option['name']) ? $option['name'] : null,
133
+                        'size'        => isset($option['size']) ? $option['size'] : null,
134
+                        'options'     => isset($option['options']) ? $option['options'] : '',
135
+                        'selected'    => isset($option['selected']) ? $option['selected'] : null,
136
+                        'std'         => isset($option['std']) ? $option['std'] : '',
137
+                        'min'         => isset($option['min']) ? $option['min'] : null,
138
+                        'max'         => isset($option['max']) ? $option['max'] : null,
139
+                        'step'        => isset($option['step']) ? $option['step'] : null,
140
+                        'chosen'      => isset($option['chosen']) ? $option['chosen'] : null,
141
+                        'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
142
+                        'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
143
+                        'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
144
+                        'faux'        => isset($option['faux']) ? $option['faux'] : false,
145
+                        'onchange'    => !empty($option['onchange']) ? $option['onchange'] : '',
146
+                        'custom'      => !empty($option['custom']) ? $option['custom'] : '',
147
+                        'class'       =>  !empty($option['class']) ? $option['class'] : '',
148
+                        'cols'        => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
149
+                        'rows'        => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
150 150
                     )
151 151
                 );
152 152
             }
@@ -154,21 +154,21 @@  discard block
 block discarded – undo
154 154
     }
155 155
 
156 156
     // Creates our settings in the options table
157
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
157
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
158 158
 }
159
-add_action( 'admin_init', 'wpinv_register_settings' );
159
+add_action('admin_init', 'wpinv_register_settings');
160 160
 
161 161
 function wpinv_get_registered_settings() {
162
-    $pages = wpinv_get_pages( true );
162
+    $pages = wpinv_get_pages(true);
163 163
     
164 164
     $due_payment_options       = array();
165
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
166
-    for ( $i = 1; $i <= 30; $i++ ) {
165
+    $due_payment_options[0]    = __('Now', 'invoicing');
166
+    for ($i = 1; $i <= 30; $i++) {
167 167
         $due_payment_options[$i] = $i;
168 168
     }
169 169
     
170 170
     $invoice_number_padd_options = array();
171
-    for ( $i = 0; $i <= 20; $i++ ) {
171
+    for ($i = 0; $i <= 20; $i++) {
172 172
         $invoice_number_padd_options[$i] = $i;
173 173
     }
174 174
     
@@ -177,141 +177,141 @@  discard block
 block discarded – undo
177 177
     $alert_wrapper_start = '<p style="color: #F00">';
178 178
     $alert_wrapper_close = '</p>';
179 179
     $wpinv_settings = array(
180
-        'general' => apply_filters( 'wpinv_settings_general',
180
+        'general' => apply_filters('wpinv_settings_general',
181 181
             array(
182 182
                 'main' => array(
183 183
                     'location_settings' => array(
184 184
                         'id'   => 'location_settings',
185
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
185
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
186 186
                         'desc' => '',
187 187
                         'type' => 'header',
188 188
                     ),
189 189
                     'default_country' => array(
190 190
                         'id'      => 'default_country',
191
-                        'name'    => __( 'Default Country', 'invoicing' ),
192
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
191
+                        'name'    => __('Default Country', 'invoicing'),
192
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
193 193
                         'type'    => 'select',
194 194
                         'options' => wpinv_get_country_list(),
195 195
                         'std'     => 'GB',
196 196
                         'chosen'  => true,
197
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
197
+                        'placeholder' => __('Select a country', 'invoicing'),
198 198
                     ),
199 199
                     'default_state' => array(
200 200
                         'id'      => 'default_state',
201
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
202
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
201
+                        'name'    => __('Default State / Province', 'invoicing'),
202
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
203 203
                         'type'    => 'country_states',
204
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
204
+                        'placeholder' => __('Select a state', 'invoicing'),
205 205
                     ),
206 206
                     'store_name' => array(
207 207
                         'id'   => 'store_name',
208
-                        'name' => __( 'Store Name', 'invoicing' ),
209
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
208
+                        'name' => __('Store Name', 'invoicing'),
209
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
210 210
                         'std'     => get_option('blogname'),
211 211
                         'type' => 'text',
212 212
                     ),
213 213
                     'logo' => array(
214 214
                         'id'   => 'logo',
215
-                        'name' => __( 'Logo URL', 'invoicing' ),
216
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
215
+                        'name' => __('Logo URL', 'invoicing'),
216
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
217 217
                         'type' => 'text',
218 218
                     ),
219 219
                     'store_address' => array(
220 220
                         'id'   => 'store_address',
221
-                        'name' => __( 'Store Address', 'invoicing' ),
222
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
221
+                        'name' => __('Store Address', 'invoicing'),
222
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
223 223
                         'type' => 'textarea',
224 224
                     ),
225 225
                     'page_settings' => array(
226 226
                         'id'   => 'page_settings',
227
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
227
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
228 228
                         'desc' => '',
229 229
                         'type' => 'header',
230 230
                     ),
231 231
                     'checkout_page' => array(
232 232
                         'id'          => 'checkout_page',
233
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
234
-                        'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
233
+                        'name'        => __('Checkout Page', 'invoicing'),
234
+                        'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
235 235
                         'type'        => 'select',
236 236
                         'options'     => $pages,
237 237
                         'chosen'      => true,
238
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
238
+                        'placeholder' => __('Select a page', 'invoicing'),
239 239
                     ),
240 240
                     'success_page' => array(
241 241
                         'id'          => 'success_page',
242
-                        'name'        => __( 'Success Page', 'invoicing' ),
243
-                        'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
242
+                        'name'        => __('Success Page', 'invoicing'),
243
+                        'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
244 244
                         'type'        => 'select',
245 245
                         'options'     => $pages,
246 246
                         'chosen'      => true,
247
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
247
+                        'placeholder' => __('Select a page', 'invoicing'),
248 248
                     ),
249 249
                     'failure_page' => array(
250 250
                         'id'          => 'failure_page',
251
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
252
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ),
251
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
252
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'),
253 253
                         'type'        => 'select',
254 254
                         'options'     => $pages,
255 255
                         'chosen'      => true,
256
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
256
+                        'placeholder' => __('Select a page', 'invoicing'),
257 257
                     ),
258 258
                     'invoice_history_page' => array(
259 259
                         'id'          => 'invoice_history_page',
260
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
261
-                        'desc'        => __( 'This page shows an invoice history for the current user', 'invoicing' ),
260
+                        'name'        => __('Invoice History Page', 'invoicing'),
261
+                        'desc'        => __('This page shows an invoice history for the current user', 'invoicing'),
262 262
                         'type'        => 'select',
263 263
                         'options'     => $pages,
264 264
                         'chosen'      => true,
265
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
265
+                        'placeholder' => __('Select a page', 'invoicing'),
266 266
                     )
267 267
                 ),
268 268
                 'currency_section' => array(
269 269
                     'currency_settings' => array(
270 270
                         'id'   => 'currency_settings',
271
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
271
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
272 272
                         'desc' => '',
273 273
                         'type' => 'header',
274 274
                     ),
275 275
                     'currency' => array(
276 276
                         'id'      => 'currency',
277
-                        'name'    => __( 'Currency', 'invoicing' ),
278
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
277
+                        'name'    => __('Currency', 'invoicing'),
278
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
279 279
                         'type'    => 'select',
280 280
                         'options' => wpinv_get_currencies(),
281 281
                         'chosen'  => true,
282 282
                     ),
283 283
                     'currency_position' => array(
284 284
                         'id'      => 'currency_position',
285
-                        'name'    => __( 'Currency Position', 'invoicing' ),
286
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
285
+                        'name'    => __('Currency Position', 'invoicing'),
286
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
287 287
                         'type'    => 'select',
288 288
                         'options'  => array(
289
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
290
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
291
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
292
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
289
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
290
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
291
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
292
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
293 293
                         )
294 294
                     ),
295 295
                     'thousands_separator' => array(
296 296
                         'id'   => 'thousands_separator',
297
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
298
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
297
+                        'name' => __('Thousands Separator', 'invoicing'),
298
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
299 299
                         'type' => 'text',
300 300
                         'size' => 'small',
301 301
                         'std'  => ',',
302 302
                     ),
303 303
                     'decimal_separator' => array(
304 304
                         'id'   => 'decimal_separator',
305
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
306
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
305
+                        'name' => __('Decimal Separator', 'invoicing'),
306
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
307 307
                         'type' => 'text',
308 308
                         'size' => 'small',
309 309
                         'std'  => '.',
310 310
                     ),
311 311
                     'decimals' => array(
312 312
                         'id'   => 'decimals',
313
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
314
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
313
+                        'name' => __('Number of Decimals', 'invoicing'),
314
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
315 315
                         'type' => 'number',
316 316
                         'size' => 'small',
317 317
                         'std'  => '2',
@@ -323,29 +323,29 @@  discard block
 block discarded – undo
323 323
                 'labels' => array(
324 324
                     'labels' => array(
325 325
                         'id'   => 'labels_settings',
326
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
326
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
327 327
                         'desc' => '',
328 328
                         'type' => 'header',
329 329
                     ),
330 330
                     'vat_name' => array(
331 331
                         'id' => 'vat_name',
332
-                        'name' => __( 'VAT Name', 'invoicing' ),
333
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
332
+                        'name' => __('VAT Name', 'invoicing'),
333
+                        'desc' => __('Enter the VAT name', 'invoicing'),
334 334
                         'type' => 'text',
335 335
                         'size' => 'regular',
336 336
                         'std' => 'VAT'
337 337
                     ),
338 338
                     'vat_invoice_notice_label' => array(
339 339
                         'id' => 'vat_invoice_notice_label',
340
-                        'name' => __( 'Invoice Notice Label', 'invoicing' ),
341
-                        'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
340
+                        'name' => __('Invoice Notice Label', 'invoicing'),
341
+                        'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
342 342
                         'type' => 'text',
343 343
                         'size' => 'regular',
344 344
                     ),
345 345
                     'vat_invoice_notice' => array(
346 346
                         'id' => 'vat_invoice_notice',
347
-                        'name' => __( 'Invoice notice', 'invoicing' ),
348
-                        'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
347
+                        'name' => __('Invoice notice', 'invoicing'),
348
+                        'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
349 349
                         'type' => 'text',
350 350
                         'size' => 'regular',
351 351
                     )
@@ -357,22 +357,22 @@  discard block
 block discarded – undo
357 357
                 'main' => array(
358 358
                     'gateway_settings' => array(
359 359
                         'id'   => 'api_header',
360
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
360
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
361 361
                         'desc' => '',
362 362
                         'type' => 'header',
363 363
                     ),
364 364
                     'gateways' => array(
365 365
                         'id'      => 'gateways',
366
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
367
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
366
+                        'name'    => __('Payment Gateways', 'invoicing'),
367
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
368 368
                         'type'    => 'gateways',
369 369
                         'std'     => array('manual'=>1),
370 370
                         'options' => wpinv_get_payment_gateways(),
371 371
                     ),
372 372
                     'default_gateway' => array(
373 373
                         'id'      => 'default_gateway',
374
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
375
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
374
+                        'name'    => __('Default Gateway', 'invoicing'),
375
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
376 376
                         'type'    => 'gateway_select',
377 377
                         'std'     => 'manual',
378 378
                         'options' => wpinv_get_payment_gateways(),
@@ -386,19 +386,19 @@  discard block
 block discarded – undo
386 386
                 'main' => array(
387 387
                     'tax_settings' => array(
388 388
                         'id'   => 'tax_settings',
389
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
389
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
390 390
                         'type' => 'header',
391 391
                     ),
392 392
                     'enable_taxes' => array(
393 393
                         'id'   => 'enable_taxes',
394
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
395
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
394
+                        'name' => __('Enable Taxes', 'invoicing'),
395
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
396 396
                         'type' => 'checkbox',
397 397
                     ),
398 398
                     'tax_rate' => array(
399 399
                         'id'   => 'tax_rate',
400
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
401
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
400
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
401
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
402 402
                         'type' => 'number',
403 403
                         'size' => 'small',
404 404
                         'min'  => '0',
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
                 'rates' => array(
411 411
                     'tax_rates' => array(
412 412
                         'id'   => 'tax_rates',
413
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
414
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
413
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
414
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
415 415
                         'type' => 'tax_rates',
416 416
                     ),
417 417
                 )
@@ -423,62 +423,62 @@  discard block
 block discarded – undo
423 423
                 'main' => array(
424 424
                     'email_settings_header' => array(
425 425
                         'id'   => 'email_settings_header',
426
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
426
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
427 427
                         'type' => 'header',
428 428
                     ),
429 429
                     'email_from_name' => array(
430 430
                         'id'   => 'email_from_name',
431
-                        'name' => __( 'From Name', 'invoicing' ),
432
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
433
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
431
+                        'name' => __('From Name', 'invoicing'),
432
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
433
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
434 434
                         'type' => 'text',
435 435
                     ),
436 436
                     'email_from' => array(
437 437
                         'id'   => 'email_from',
438
-                        'name' => __( 'From Email', 'invoicing' ),
439
-                        'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
440
-                        'std' => get_option( 'admin_email' ),
438
+                        'name' => __('From Email', 'invoicing'),
439
+                        'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
440
+                        'std' => get_option('admin_email'),
441 441
                         'type' => 'text',
442 442
                     ),
443 443
                     'overdue_settings_header' => array(
444 444
                         'id'   => 'overdue_settings_header',
445
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
445
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
446 446
                         'type' => 'header',
447 447
                     ),
448 448
                     'overdue_active' => array(
449 449
                         'id'   => 'overdue_active',
450
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
451
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
450
+                        'name' => __('Enable Due Date', 'invoicing'),
451
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
452 452
                         'type' => 'checkbox',
453 453
                         'std'  => false,
454 454
                     ),
455 455
                     'overdue_days' => array(
456 456
                         'id'          => 'overdue_days',
457
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
458
-                        'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
457
+                        'name'        => __('Default Due Date', 'invoicing'),
458
+                        'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
459 459
                         'type'        => 'select',
460 460
                         'options'     => $due_payment_options,
461 461
                         'chosen'      => true,
462 462
                         'std'         => 0,
463
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
463
+                        'placeholder' => __('Select a page', 'invoicing'),
464 464
                     ),
465 465
                     'email_template_header' => array(
466 466
                         'id'   => 'email_template_header',
467
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
467
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
468 468
                         'type' => 'header',
469 469
                     ),
470 470
                     'email_header_image' => array(
471 471
                         'id'   => 'email_header_image',
472
-                        'name' => __( 'Header Image', 'invoicing' ),
473
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
472
+                        'name' => __('Header Image', 'invoicing'),
473
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
474 474
                         'std' => '',
475 475
                         'type' => 'text',
476 476
                     ),
477 477
                     'email_footer_text' => array(
478 478
                         'id'   => 'email_footer_text',
479
-                        'name' => __( 'Footer Text', 'invoicing' ),
480
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
481
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
479
+                        'name' => __('Footer Text', 'invoicing'),
480
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
481
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
482 482
                         'type' => 'textarea',
483 483
                         'class' => 'regular-text',
484 484
                         'rows' => 2,
@@ -486,29 +486,29 @@  discard block
 block discarded – undo
486 486
                     ),
487 487
                     'email_base_color' => array(
488 488
                         'id'   => 'email_base_color',
489
-                        'name' => __( 'Base Color', 'invoicing' ),
490
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
489
+                        'name' => __('Base Color', 'invoicing'),
490
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
491 491
                         'std' => '#557da2',
492 492
                         'type' => 'color',
493 493
                     ),
494 494
                     'email_background_color' => array(
495 495
                         'id'   => 'email_background_color',
496
-                        'name' => __( 'Background Color', 'invoicing' ),
497
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
496
+                        'name' => __('Background Color', 'invoicing'),
497
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
498 498
                         'std' => '#f5f5f5',
499 499
                         'type' => 'color',
500 500
                     ),
501 501
                     'email_body_background_color' => array(
502 502
                         'id'   => 'email_body_background_color',
503
-                        'name' => __( 'Body Background Color', 'invoicing' ),
504
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
503
+                        'name' => __('Body Background Color', 'invoicing'),
504
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
505 505
                         'std' => '#fdfdfd',
506 506
                         'type' => 'color',
507 507
                     ),
508 508
                     'email_text_color' => array(
509 509
                         'id'   => 'email_text_color',
510
-                        'name' => __( 'Body Text Color', 'invoicing' ),
511
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
510
+                        'name' => __('Body Text Color', 'invoicing'),
511
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
512 512
                         'std' => '#505050',
513 513
                         'type' => 'color',
514 514
                     ),
@@ -527,73 +527,73 @@  discard block
 block discarded – undo
527 527
                 'main' => array(
528 528
                     'fields_settings' => array(
529 529
                         'id'   => 'fields_settings',
530
-                        'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>',
531
-                        'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ),
530
+                        'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>',
531
+                        'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'),
532 532
                         'type' => 'header',
533 533
                     ),
534 534
                     'fname_mandatory' => array(
535 535
                         'id'   => 'fname_mandatory',
536
-                        'name' => __( 'First Name', 'invoicing' ),
536
+                        'name' => __('First Name', 'invoicing'),
537 537
                         'type' => 'checkbox',
538 538
                         'std'  => true,
539 539
                     ),
540 540
                     'lname_mandatory' => array(
541 541
                         'id'   => 'lname_mandatory',
542
-                        'name' => __( 'Last Name', 'invoicing' ),
542
+                        'name' => __('Last Name', 'invoicing'),
543 543
                         'type' => 'checkbox',
544 544
                         'std'  => true,
545 545
                     ),
546 546
                     'address_mandatory' => array(
547 547
                         'id'   => 'address_mandatory',
548
-                        'name' => __( 'Address', 'invoicing' ),
548
+                        'name' => __('Address', 'invoicing'),
549 549
                         'type' => 'checkbox',
550 550
                         'std'  => true,
551 551
                     ),
552 552
                     'city_mandatory' => array(
553 553
                         'id'   => 'city_mandatory',
554
-                        'name' => __( 'City', 'invoicing' ),
554
+                        'name' => __('City', 'invoicing'),
555 555
                         'type' => 'checkbox',
556 556
                         'std'  => true,
557 557
                     ),
558 558
                     'country_mandatory' => array(
559 559
                         'id'   => 'country_mandatory',
560
-                        'name' => __( 'Country', 'invoicing' ),
560
+                        'name' => __('Country', 'invoicing'),
561 561
                         'type' => 'checkbox',
562 562
                         'std'  => true,
563 563
                     ),
564 564
                     'state_mandatory' => array(
565 565
                         'id'   => 'state_mandatory',
566
-                        'name' => __( 'State / Province', 'invoicing' ),
566
+                        'name' => __('State / Province', 'invoicing'),
567 567
                         'type' => 'checkbox',
568 568
                         'std'  => true,
569 569
                     ),
570 570
                     'zip_mandatory' => array(
571 571
                         'id'   => 'zip_mandatory',
572
-                        'name' => __( 'ZIP / Postcode', 'invoicing' ),
572
+                        'name' => __('ZIP / Postcode', 'invoicing'),
573 573
                         'type' => 'checkbox',
574 574
                         'std'  => true,
575 575
                     ),
576 576
                     'phone_mandatory' => array(
577 577
                         'id'   => 'phone_mandatory',
578
-                        'name' => __( 'Phone Number', 'invoicing' ),
578
+                        'name' => __('Phone Number', 'invoicing'),
579 579
                         'type' => 'checkbox',
580 580
                         'std'  => true,
581 581
                     ),
582 582
                     'invoice_number_format_settings' => array(
583 583
                         'id'   => 'invoice_number_format_settings',
584
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
584
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
585 585
                         'type' => 'header',
586 586
                     ),
587 587
                     'sequential_invoice_number' => array(
588 588
                         'id'   => 'sequential_invoice_number',
589
-                        'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
590
-                        'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ),
589
+                        'name' => __('Sequential Invoice Numbers', 'invoicing'),
590
+                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'),
591 591
                         'type' => 'checkbox',
592 592
                     ),
593 593
                     'invoice_sequence_start' => array(
594 594
                         'id'   => 'invoice_sequence_start',
595
-                        'name' => __( 'Sequential Starting Number', 'easy-digital-downloads' ),
596
-                        'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ),
595
+                        'name' => __('Sequential Starting Number', 'easy-digital-downloads'),
596
+                        'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing'),
597 597
                         'type' => 'number',
598 598
                         'size' => 'small',
599 599
                         'std'  => '1',
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
                     ),
602 602
                     'invoice_number_padd' => array(
603 603
                         'id'      => 'invoice_number_padd',
604
-                        'name'    => __( 'Minimum Digits', 'invoicing' ),
605
-                        'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
604
+                        'name'    => __('Minimum Digits', 'invoicing'),
605
+                        'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
606 606
                         'type'    => 'select',
607 607
                         'options' => $invoice_number_padd_options,
608 608
                         'std'     => 5,
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
                     ),
611 611
                     'invoice_number_prefix' => array(
612 612
                         'id' => 'invoice_number_prefix',
613
-                        'name' => __( 'Invoice Number Prefix', 'invoicing' ),
614
-                        'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ),
613
+                        'name' => __('Invoice Number Prefix', 'invoicing'),
614
+                        'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'),
615 615
                         'type' => 'text',
616 616
                         'size' => 'regular',
617 617
                         'std' => 'WPINV-',
@@ -619,25 +619,25 @@  discard block
 block discarded – undo
619 619
                     ),
620 620
                     'invoice_number_postfix' => array(
621 621
                         'id' => 'invoice_number_postfix',
622
-                        'name' => __( 'Invoice Number Postfix', 'invoicing' ),
623
-                        'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
622
+                        'name' => __('Invoice Number Postfix', 'invoicing'),
623
+                        'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
624 624
                         'type' => 'text',
625 625
                         'size' => 'regular',
626 626
                         'std' => ''
627 627
                     ),
628 628
                     'guest_checkout_settings' => array(
629 629
                         'id'   => 'guest_checkout_settings',
630
-                        'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>',
630
+                        'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>',
631 631
                         'type' => 'header',
632 632
                     ),
633 633
                     'guest_checkout' => array(
634 634
                         'type'    => 'radio',
635 635
                         'id'      => 'guest_checkout',
636
-                        'name'    => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ),
637
-                        'desc'    => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing' ),
636
+                        'name'    => __('Pay via Invoice Link for non logged in user', 'invoicing'),
637
+                        'desc'    => __('Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing'),
638 638
                         'options' => array(
639
-                            0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ),
640
-                            1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ),
639
+                            0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'),
640
+                            1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'),
641 641
                         ),
642 642
                         'std'     => 0,
643 643
                     ),
@@ -650,8 +650,8 @@  discard block
 block discarded – undo
650 650
                 'main' => array(
651 651
                     'tool_settings' => array(
652 652
                         'id'   => 'tool_settings',
653
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
654
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
653
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
654
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
655 655
                         'type' => 'tools',
656 656
                     ),
657 657
                 ),
@@ -659,135 +659,135 @@  discard block
 block discarded – undo
659 659
         )
660 660
     );
661 661
 
662
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
662
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
663 663
 }
664 664
 
665
-function wpinv_settings_sanitize( $input = array() ) {
665
+function wpinv_settings_sanitize($input = array()) {
666 666
     global $wpinv_options;
667 667
 
668
-    if ( empty( $_POST['_wp_http_referer'] ) ) {
668
+    if (empty($_POST['_wp_http_referer'])) {
669 669
         return $input;
670 670
     }
671 671
 
672
-    parse_str( $_POST['_wp_http_referer'], $referrer );
672
+    parse_str($_POST['_wp_http_referer'], $referrer);
673 673
 
674 674
     $settings = wpinv_get_registered_settings();
675
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
676
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
675
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
676
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
677 677
 
678 678
     $input = $input ? $input : array();
679
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
680
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
679
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
680
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
681 681
 
682 682
     // Loop through each setting being saved and pass it through a sanitization filter
683
-    foreach ( $input as $key => $value ) {
683
+    foreach ($input as $key => $value) {
684 684
         // Get the setting type (checkbox, select, etc)
685
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
685
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
686 686
 
687
-        if ( $type ) {
687
+        if ($type) {
688 688
             // Field type specific filter
689
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
689
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
690 690
         }
691 691
 
692 692
         // General filter
693
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
693
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
694 694
     }
695 695
 
696 696
     // Loop through the whitelist and unset any that are empty for the tab being saved
697
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
698
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
697
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
698
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
699 699
 
700
-    $found_settings = array_merge( $main_settings, $section_settings );
700
+    $found_settings = array_merge($main_settings, $section_settings);
701 701
 
702
-    if ( ! empty( $found_settings ) ) {
703
-        foreach ( $found_settings as $key => $value ) {
702
+    if (!empty($found_settings)) {
703
+        foreach ($found_settings as $key => $value) {
704 704
 
705 705
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
706
-            if ( is_numeric( $key ) ) {
706
+            if (is_numeric($key)) {
707 707
                 $key = $value['id'];
708 708
             }
709 709
 
710
-            if ( empty( $input[ $key ] ) ) {
711
-                unset( $wpinv_options[ $key ] );
710
+            if (empty($input[$key])) {
711
+                unset($wpinv_options[$key]);
712 712
             }
713 713
         }
714 714
     }
715 715
 
716 716
     // Merge our new settings with the existing
717
-    $output = array_merge( $wpinv_options, $input );
717
+    $output = array_merge($wpinv_options, $input);
718 718
 
719
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
719
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
720 720
 
721 721
     return $output;
722 722
 }
723 723
 
724
-function wpinv_settings_sanitize_misc_accounting( $input ) {
724
+function wpinv_settings_sanitize_misc_accounting($input) {
725 725
     global $wpinv_options, $wpi_session;
726 726
 
727
-    if ( !current_user_can( 'manage_options' ) ) {
727
+    if (!current_user_can('manage_options')) {
728 728
         return $input;
729 729
     }
730 730
 
731
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
731
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
732 732
         // Shows an admin notice about upgrading previous order numbers
733
-        $wpi_session->set( 'upgrade_sequential', '1' );
733
+        $wpi_session->set('upgrade_sequential', '1');
734 734
     }
735 735
 
736 736
     return $input;
737 737
 }
738
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
738
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
739 739
 
740
-function wpinv_settings_sanitize_tax_rates( $input ) {
741
-    if( !current_user_can( 'manage_options' ) ) {
740
+function wpinv_settings_sanitize_tax_rates($input) {
741
+    if (!current_user_can('manage_options')) {
742 742
         return $input;
743 743
     }
744 744
 
745
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
745
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
746 746
 
747 747
     $tax_rates = array();
748 748
 
749
-    if ( !empty( $new_rates ) ) {
750
-        foreach ( $new_rates as $rate ) {
751
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
749
+    if (!empty($new_rates)) {
750
+        foreach ($new_rates as $rate) {
751
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
752 752
                 continue;
753 753
             }
754 754
             
755
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
755
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
756 756
             
757 757
             $tax_rates[] = $rate;
758 758
         }
759 759
     }
760 760
 
761
-    update_option( 'wpinv_tax_rates', $tax_rates );
761
+    update_option('wpinv_tax_rates', $tax_rates);
762 762
 
763 763
     return $input;
764 764
 }
765
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
765
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
766 766
 
767
-function wpinv_sanitize_text_field( $input ) {
768
-    return trim( $input );
767
+function wpinv_sanitize_text_field($input) {
768
+    return trim($input);
769 769
 }
770
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
770
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
771 771
 
772 772
 function wpinv_get_settings_tabs() {
773 773
     $tabs             = array();
774
-    $tabs['general']  = __( 'General', 'invoicing' );
775
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
776
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
777
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
778
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
779
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
780
-
781
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
774
+    $tabs['general']  = __('General', 'invoicing');
775
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
776
+    $tabs['taxes']    = __('Taxes', 'invoicing');
777
+    $tabs['emails']   = __('Emails', 'invoicing');
778
+    $tabs['misc']     = __('Misc', 'invoicing');
779
+    $tabs['tools']    = __('Tools', 'invoicing');
780
+
781
+    return apply_filters('wpinv_settings_tabs', $tabs);
782 782
 }
783 783
 
784
-function wpinv_get_settings_tab_sections( $tab = false ) {
784
+function wpinv_get_settings_tab_sections($tab = false) {
785 785
     $tabs     = false;
786 786
     $sections = wpinv_get_registered_settings_sections();
787 787
 
788
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
789
-        $tabs = $sections[ $tab ];
790
-    } else if ( $tab ) {
788
+    if ($tab && !empty($sections[$tab])) {
789
+        $tabs = $sections[$tab];
790
+    } else if ($tab) {
791 791
         $tabs = false;
792 792
     }
793 793
 
@@ -797,135 +797,135 @@  discard block
 block discarded – undo
797 797
 function wpinv_get_registered_settings_sections() {
798 798
     static $sections = false;
799 799
 
800
-    if ( false !== $sections ) {
800
+    if (false !== $sections) {
801 801
         return $sections;
802 802
     }
803 803
 
804 804
     $sections = array(
805
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
806
-            'main' => __( 'General Settings', 'invoicing' ),
807
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
808
-            'labels' => __( 'Label Texts', 'invoicing' ),
809
-        ) ),
810
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
811
-            'main' => __( 'Gateway Settings', 'invoicing' ),
812
-        ) ),
813
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
814
-            'main' => __( 'Tax Settings', 'invoicing' ),
815
-            'rates' => __( 'Tax Rates', 'invoicing' ),
816
-        ) ),
817
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
818
-            'main' => __( 'Email Settings', 'invoicing' ),
819
-        ) ),
820
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
821
-            'main' => __( 'Misc Settings', 'invoicing' ),
822
-        ) ),
823
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
824
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
825
-        ) ),
805
+        'general' => apply_filters('wpinv_settings_sections_general', array(
806
+            'main' => __('General Settings', 'invoicing'),
807
+            'currency_section' => __('Currency Settings', 'invoicing'),
808
+            'labels' => __('Label Texts', 'invoicing'),
809
+        )),
810
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
811
+            'main' => __('Gateway Settings', 'invoicing'),
812
+        )),
813
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
814
+            'main' => __('Tax Settings', 'invoicing'),
815
+            'rates' => __('Tax Rates', 'invoicing'),
816
+        )),
817
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
818
+            'main' => __('Email Settings', 'invoicing'),
819
+        )),
820
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
821
+            'main' => __('Misc Settings', 'invoicing'),
822
+        )),
823
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
824
+            'main' => __('Diagnostic Tools', 'invoicing'),
825
+        )),
826 826
     );
827 827
 
828
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
828
+    $sections = apply_filters('wpinv_settings_sections', $sections);
829 829
 
830 830
     return $sections;
831 831
 }
832 832
 
833
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
833
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
834 834
 	$pages_options = array();
835 835
 
836
-	if( $default_label !== NULL && $default_label !== false ) {
837
-		$pages_options = array( '' => $default_label ); // Blank option
836
+	if ($default_label !== NULL && $default_label !== false) {
837
+		$pages_options = array('' => $default_label); // Blank option
838 838
 	}
839 839
 
840 840
 	$pages = get_pages();
841
-	if ( $pages ) {
842
-		foreach ( $pages as $page ) {
841
+	if ($pages) {
842
+		foreach ($pages as $page) {
843 843
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
844
-            $pages_options[ $page->ID ] = $title;
844
+            $pages_options[$page->ID] = $title;
845 845
 		}
846 846
 	}
847 847
 
848 848
 	return $pages_options;
849 849
 }
850 850
 
851
-function wpinv_header_callback( $args ) {
852
-	if ( !empty( $args['desc'] ) ) {
851
+function wpinv_header_callback($args) {
852
+	if (!empty($args['desc'])) {
853 853
         echo $args['desc'];
854 854
     }
855 855
 }
856 856
 
857
-function wpinv_hidden_callback( $args ) {
857
+function wpinv_hidden_callback($args) {
858 858
 	global $wpinv_options;
859 859
 
860
-	if ( isset( $args['set_value'] ) ) {
860
+	if (isset($args['set_value'])) {
861 861
 		$value = $args['set_value'];
862
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
863
-		$value = $wpinv_options[ $args['id'] ];
862
+	} elseif (isset($wpinv_options[$args['id']])) {
863
+		$value = $wpinv_options[$args['id']];
864 864
 	} else {
865
-		$value = isset( $args['std'] ) ? $args['std'] : '';
865
+		$value = isset($args['std']) ? $args['std'] : '';
866 866
 	}
867 867
 
868
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
868
+	if (isset($args['faux']) && true === $args['faux']) {
869 869
 		$args['readonly'] = true;
870
-		$value = isset( $args['std'] ) ? $args['std'] : '';
870
+		$value = isset($args['std']) ? $args['std'] : '';
871 871
 		$name  = '';
872 872
 	} else {
873
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
873
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
874 874
 	}
875 875
 
876
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
876
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
877 877
     
878 878
 	echo $html;
879 879
 }
880 880
 
881
-function wpinv_checkbox_callback( $args ) {
881
+function wpinv_checkbox_callback($args) {
882 882
 	global $wpinv_options;
883 883
     
884
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
884
+    $sanitize_id = wpinv_sanitize_key($args['id']);
885 885
 
886
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
886
+	if (isset($args['faux']) && true === $args['faux']) {
887 887
 		$name = '';
888 888
 	} else {
889 889
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
890 890
 	}
891 891
 
892
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
892
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
893 893
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
894
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
894
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
895 895
 
896 896
 	echo $html;
897 897
 }
898 898
 
899
-function wpinv_multicheck_callback( $args ) {
899
+function wpinv_multicheck_callback($args) {
900 900
 	global $wpinv_options;
901 901
 	
902
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
902
+	$sanitize_id = wpinv_sanitize_key($args['id']);
903 903
 	
904
-	if ( ! empty( $args['options'] ) ) {
905
-		foreach( $args['options'] as $key => $option ):
906
-			$sanitize_key = wpinv_sanitize_key( $key );
907
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
904
+	if (!empty($args['options'])) {
905
+		foreach ($args['options'] as $key => $option):
906
+			$sanitize_key = wpinv_sanitize_key($key);
907
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
908 908
 				$enabled = $sanitize_key;
909 909
 			} else { 
910 910
 				$enabled = NULL; 
911 911
 			}
912
-			echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
913
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
912
+			echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
913
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>';
914 914
 		endforeach;
915 915
 		echo '<p class="description">' . $args['desc'] . '</p>';
916 916
 	}
917 917
 }
918 918
 
919
-function wpinv_payment_icons_callback( $args ) {
919
+function wpinv_payment_icons_callback($args) {
920 920
 	global $wpinv_options;
921 921
     
922
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
922
+    $sanitize_id = wpinv_sanitize_key($args['id']);
923 923
 
924
-	if ( ! empty( $args['options'] ) ) {
925
-		foreach( $args['options'] as $key => $option ) {
926
-            $sanitize_key = wpinv_sanitize_key( $key );
924
+	if (!empty($args['options'])) {
925
+		foreach ($args['options'] as $key => $option) {
926
+            $sanitize_key = wpinv_sanitize_key($key);
927 927
             
928
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
928
+			if (isset($wpinv_options[$args['id']][$key])) {
929 929
 				$enabled = $option;
930 930
 			} else {
931 931
 				$enabled = NULL;
@@ -933,196 +933,196 @@  discard block
 block discarded – undo
933 933
 
934 934
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
935 935
 
936
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
936
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
937 937
 
938
-				if ( wpinv_string_is_image_url( $key ) ) {
939
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
938
+				if (wpinv_string_is_image_url($key)) {
939
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
940 940
 				} else {
941
-					$card = strtolower( str_replace( ' ', '', $option ) );
941
+					$card = strtolower(str_replace(' ', '', $option));
942 942
 
943
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
944
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
943
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
944
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
945 945
 					} else {
946
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
946
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
947 947
 						$content_dir = WP_CONTENT_DIR;
948 948
 
949
-						if ( function_exists( 'wp_normalize_path' ) ) {
949
+						if (function_exists('wp_normalize_path')) {
950 950
 							// Replaces backslashes with forward slashes for Windows systems
951
-							$image = wp_normalize_path( $image );
952
-							$content_dir = wp_normalize_path( $content_dir );
951
+							$image = wp_normalize_path($image);
952
+							$content_dir = wp_normalize_path($content_dir);
953 953
 						}
954 954
 
955
-						$image = str_replace( $content_dir, content_url(), $image );
955
+						$image = str_replace($content_dir, content_url(), $image);
956 956
 					}
957 957
 
958
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
958
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
959 959
 				}
960 960
 			echo $option . '</label>';
961 961
 		}
962
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
962
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
963 963
 	}
964 964
 }
965 965
 
966
-function wpinv_radio_callback( $args ) {
966
+function wpinv_radio_callback($args) {
967 967
 	global $wpinv_options;
968 968
     
969
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
969
+    $sanitize_id = wpinv_sanitize_key($args['id']);
970 970
     
971
-    foreach ( $args['options'] as $key => $option ) :
972
-		$sanitize_key = wpinv_sanitize_key( $key );
971
+    foreach ($args['options'] as $key => $option) :
972
+		$sanitize_key = wpinv_sanitize_key($key);
973 973
         
974 974
         $checked = false;
975 975
 
976
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
976
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
977 977
 			$checked = true;
978
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
978
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
979 979
 			$checked = true;
980 980
 
981 981
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
982
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
982
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
983 983
 	endforeach;
984 984
 
985
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
985
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
986 986
 }
987 987
 
988
-function wpinv_gateways_callback( $args ) {
988
+function wpinv_gateways_callback($args) {
989 989
 	global $wpinv_options;
990 990
     
991
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
991
+    $sanitize_id = wpinv_sanitize_key($args['id']);
992 992
 
993
-	foreach ( $args['options'] as $key => $option ) :
994
-		$sanitize_key = wpinv_sanitize_key( $key );
993
+	foreach ($args['options'] as $key => $option) :
994
+		$sanitize_key = wpinv_sanitize_key($key);
995 995
         
996
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
996
+        if (isset($wpinv_options['gateways'][$key]))
997 997
 			$enabled = '1';
998 998
 		else
999 999
 			$enabled = null;
1000 1000
 
1001
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1002
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1001
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1002
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
1003 1003
 	endforeach;
1004 1004
 }
1005 1005
 
1006 1006
 function wpinv_gateway_select_callback($args) {
1007 1007
 	global $wpinv_options;
1008 1008
     
1009
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1009
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1010 1010
 
1011 1011
 	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1012 1012
 
1013
-	foreach ( $args['options'] as $key => $option ) :
1014
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1015
-            $selected = selected( $key, $args['selected'], false );
1013
+	foreach ($args['options'] as $key => $option) :
1014
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1015
+            $selected = selected($key, $args['selected'], false);
1016 1016
         } else {
1017
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1017
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
1018 1018
         }
1019
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1019
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
1020 1020
 	endforeach;
1021 1021
 
1022 1022
 	echo '</select>';
1023
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1023
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1024 1024
 }
1025 1025
 
1026
-function wpinv_text_callback( $args ) {
1026
+function wpinv_text_callback($args) {
1027 1027
 	global $wpinv_options;
1028 1028
     
1029
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1029
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1030 1030
 
1031
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1032
-		$value = $wpinv_options[ $args['id'] ];
1031
+	if (isset($wpinv_options[$args['id']])) {
1032
+		$value = $wpinv_options[$args['id']];
1033 1033
 	} else {
1034
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1034
+		$value = isset($args['std']) ? $args['std'] : '';
1035 1035
 	}
1036 1036
 
1037
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1037
+	if (isset($args['faux']) && true === $args['faux']) {
1038 1038
 		$args['readonly'] = true;
1039
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1039
+		$value = isset($args['std']) ? $args['std'] : '';
1040 1040
 		$name  = '';
1041 1041
 	} else {
1042
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1042
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1043 1043
 	}
1044
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1044
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1045 1045
 
1046 1046
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1047
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1048
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1049
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1047
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1048
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
1049
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1050 1050
 
1051 1051
 	echo $html;
1052 1052
 }
1053 1053
 
1054
-function wpinv_number_callback( $args ) {
1054
+function wpinv_number_callback($args) {
1055 1055
 	global $wpinv_options;
1056 1056
     
1057
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1057
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1058 1058
 
1059
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1060
-		$value = $wpinv_options[ $args['id'] ];
1059
+	if (isset($wpinv_options[$args['id']])) {
1060
+		$value = $wpinv_options[$args['id']];
1061 1061
 	} else {
1062
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1062
+		$value = isset($args['std']) ? $args['std'] : '';
1063 1063
 	}
1064 1064
 
1065
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1065
+	if (isset($args['faux']) && true === $args['faux']) {
1066 1066
 		$args['readonly'] = true;
1067
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1067
+		$value = isset($args['std']) ? $args['std'] : '';
1068 1068
 		$name  = '';
1069 1069
 	} else {
1070
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1070
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1071 1071
 	}
1072 1072
 
1073
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1074
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1075
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1076
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1073
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1074
+	$min  = isset($args['min']) ? $args['min'] : 0;
1075
+	$step = isset($args['step']) ? $args['step'] : 1;
1076
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1077 1077
 
1078
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1079
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1080
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1078
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1079
+	$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>';
1080
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1081 1081
 
1082 1082
 	echo $html;
1083 1083
 }
1084 1084
 
1085
-function wpinv_textarea_callback( $args ) {
1085
+function wpinv_textarea_callback($args) {
1086 1086
 	global $wpinv_options;
1087 1087
     
1088
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1088
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1089 1089
 
1090
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1091
-		$value = $wpinv_options[ $args['id'] ];
1090
+	if (isset($wpinv_options[$args['id']])) {
1091
+		$value = $wpinv_options[$args['id']];
1092 1092
 	} else {
1093
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1093
+		$value = isset($args['std']) ? $args['std'] : '';
1094 1094
 	}
1095 1095
     
1096
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1097
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1096
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1097
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1098 1098
 
1099
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1100
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1099
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
1100
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1101 1101
 
1102 1102
 	echo $html;
1103 1103
 }
1104 1104
 
1105
-function wpinv_password_callback( $args ) {
1105
+function wpinv_password_callback($args) {
1106 1106
 	global $wpinv_options;
1107 1107
     
1108
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1108
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1109 1109
 
1110
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1111
-		$value = $wpinv_options[ $args['id'] ];
1110
+	if (isset($wpinv_options[$args['id']])) {
1111
+		$value = $wpinv_options[$args['id']];
1112 1112
 	} else {
1113
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1113
+		$value = isset($args['std']) ? $args['std'] : '';
1114 1114
 	}
1115 1115
 
1116
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1117
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
1118
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1116
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1117
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
1118
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1119 1119
 
1120 1120
 	echo $html;
1121 1121
 }
1122 1122
 
1123 1123
 function wpinv_missing_callback($args) {
1124 1124
 	printf(
1125
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1125
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1126 1126
 		'<strong>' . $args['id'] . '</strong>'
1127 1127
 	);
1128 1128
 }
@@ -1130,137 +1130,137 @@  discard block
 block discarded – undo
1130 1130
 function wpinv_select_callback($args) {
1131 1131
 	global $wpinv_options;
1132 1132
     
1133
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1133
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1134 1134
 
1135
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1136
-		$value = $wpinv_options[ $args['id'] ];
1135
+	if (isset($wpinv_options[$args['id']])) {
1136
+		$value = $wpinv_options[$args['id']];
1137 1137
 	} else {
1138
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1138
+		$value = isset($args['std']) ? $args['std'] : '';
1139 1139
 	}
1140 1140
     
1141
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1141
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1142 1142
         $value = $args['selected'];
1143 1143
     }
1144 1144
 
1145
-	if ( isset( $args['placeholder'] ) ) {
1145
+	if (isset($args['placeholder'])) {
1146 1146
 		$placeholder = $args['placeholder'];
1147 1147
 	} else {
1148 1148
 		$placeholder = '';
1149 1149
 	}
1150 1150
 
1151
-	if ( isset( $args['chosen'] ) ) {
1151
+	if (isset($args['chosen'])) {
1152 1152
 		$chosen = 'class="wpinv-chosen"';
1153 1153
 	} else {
1154 1154
 		$chosen = '';
1155 1155
 	}
1156 1156
     
1157
-    if( !empty( $args['onchange'] ) ) {
1158
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1157
+    if (!empty($args['onchange'])) {
1158
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1159 1159
     } else {
1160 1160
         $onchange = '';
1161 1161
     }
1162 1162
 
1163
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1163
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1164 1164
 
1165
-	foreach ( $args['options'] as $option => $name ) {
1166
-		$selected = selected( $option, $value, false );
1167
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1165
+	foreach ($args['options'] as $option => $name) {
1166
+		$selected = selected($option, $value, false);
1167
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1168 1168
 	}
1169 1169
 
1170 1170
 	$html .= '</select>';
1171
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1171
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1172 1172
 
1173 1173
 	echo $html;
1174 1174
 }
1175 1175
 
1176
-function wpinv_color_select_callback( $args ) {
1176
+function wpinv_color_select_callback($args) {
1177 1177
 	global $wpinv_options;
1178 1178
     
1179
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1179
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1180 1180
 
1181
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1182
-		$value = $wpinv_options[ $args['id'] ];
1181
+	if (isset($wpinv_options[$args['id']])) {
1182
+		$value = $wpinv_options[$args['id']];
1183 1183
 	} else {
1184
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1184
+		$value = isset($args['std']) ? $args['std'] : '';
1185 1185
 	}
1186 1186
 
1187
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1187
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1188 1188
 
1189
-	foreach ( $args['options'] as $option => $color ) {
1190
-		$selected = selected( $option, $value, false );
1191
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1189
+	foreach ($args['options'] as $option => $color) {
1190
+		$selected = selected($option, $value, false);
1191
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1192 1192
 	}
1193 1193
 
1194 1194
 	$html .= '</select>';
1195
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1195
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1196 1196
 
1197 1197
 	echo $html;
1198 1198
 }
1199 1199
 
1200
-function wpinv_rich_editor_callback( $args ) {
1200
+function wpinv_rich_editor_callback($args) {
1201 1201
 	global $wpinv_options, $wp_version;
1202 1202
     
1203
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1203
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1204 1204
 
1205
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1206
-		$value = $wpinv_options[ $args['id'] ];
1205
+	if (isset($wpinv_options[$args['id']])) {
1206
+		$value = $wpinv_options[$args['id']];
1207 1207
 
1208
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1209
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1208
+		if (empty($args['allow_blank']) && empty($value)) {
1209
+			$value = isset($args['std']) ? $args['std'] : '';
1210 1210
 		}
1211 1211
 	} else {
1212
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1212
+		$value = isset($args['std']) ? $args['std'] : '';
1213 1213
 	}
1214 1214
 
1215
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1215
+	$rows = isset($args['size']) ? $args['size'] : 20;
1216 1216
 
1217
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1217
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1218 1218
 		ob_start();
1219
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1219
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows)));
1220 1220
 		$html = ob_get_clean();
1221 1221
 	} else {
1222
-		$html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1222
+		$html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
1223 1223
 	}
1224 1224
 
1225
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1225
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1226 1226
 
1227 1227
 	echo $html;
1228 1228
 }
1229 1229
 
1230
-function wpinv_upload_callback( $args ) {
1230
+function wpinv_upload_callback($args) {
1231 1231
 	global $wpinv_options;
1232 1232
     
1233
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1233
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1234 1234
 
1235
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1235
+	if (isset($wpinv_options[$args['id']])) {
1236 1236
 		$value = $wpinv_options[$args['id']];
1237 1237
 	} else {
1238 1238
 		$value = isset($args['std']) ? $args['std'] : '';
1239 1239
 	}
1240 1240
 
1241
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1242
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1243
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1244
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1241
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1242
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
1243
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1244
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1245 1245
 
1246 1246
 	echo $html;
1247 1247
 }
1248 1248
 
1249
-function wpinv_color_callback( $args ) {
1249
+function wpinv_color_callback($args) {
1250 1250
 	global $wpinv_options;
1251 1251
     
1252
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1252
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1253 1253
 
1254
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1255
-		$value = $wpinv_options[ $args['id'] ];
1254
+	if (isset($wpinv_options[$args['id']])) {
1255
+		$value = $wpinv_options[$args['id']];
1256 1256
 	} else {
1257
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1257
+		$value = isset($args['std']) ? $args['std'] : '';
1258 1258
 	}
1259 1259
 
1260
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1260
+	$default = isset($args['std']) ? $args['std'] : '';
1261 1261
 
1262
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
1263
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1262
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />';
1263
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1264 1264
 
1265 1265
 	echo $html;
1266 1266
 }
@@ -1268,9 +1268,9 @@  discard block
 block discarded – undo
1268 1268
 function wpinv_country_states_callback($args) {
1269 1269
 	global $wpinv_options;
1270 1270
     
1271
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1271
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1272 1272
 
1273
-	if ( isset( $args['placeholder'] ) ) {
1273
+	if (isset($args['placeholder'])) {
1274 1274
 		$placeholder = $args['placeholder'];
1275 1275
 	} else {
1276 1276
 		$placeholder = '';
@@ -1278,17 +1278,17 @@  discard block
 block discarded – undo
1278 1278
 
1279 1279
 	$states = wpinv_get_country_states();
1280 1280
 
1281
-	$chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1282
-	$class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1283
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1281
+	$chosen = ($args['chosen'] ? ' wpinv-chosen' : '');
1282
+	$class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1283
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1284 1284
 
1285
-	foreach ( $states as $option => $name ) {
1286
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1287
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1285
+	foreach ($states as $option => $name) {
1286
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1287
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1288 1288
 	}
1289 1289
 
1290 1290
 	$html .= '</select>';
1291
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1291
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1292 1292
 
1293 1293
 	echo $html;
1294 1294
 }
@@ -1303,25 +1303,25 @@  discard block
 block discarded – undo
1303 1303
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1304 1304
 		<thead>
1305 1305
 			<tr>
1306
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1307
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1308
-                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
1309
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1310
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1311
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1306
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1307
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1308
+                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
1309
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1310
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1311
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1312 1312
 			</tr>
1313 1313
 		</thead>
1314 1314
         <tbody>
1315
-		<?php if( !empty( $rates ) ) : ?>
1316
-			<?php foreach( $rates as $key => $rate ) : ?>
1315
+		<?php if (!empty($rates)) : ?>
1316
+			<?php foreach ($rates as $key => $rate) : ?>
1317 1317
             <?php 
1318
-            $sanitized_key = wpinv_sanitize_key( $key );
1318
+            $sanitized_key = wpinv_sanitize_key($key);
1319 1319
             ?>
1320 1320
 			<tr>
1321 1321
 				<td class="wpinv_tax_country">
1322 1322
 					<?php
1323
-					echo wpinv_html_select( array(
1324
-						'options'          => wpinv_get_country_list( true ),
1323
+					echo wpinv_html_select(array(
1324
+						'options'          => wpinv_get_country_list(true),
1325 1325
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1326 1326
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1327 1327
 						'selected'         => $rate['country'],
@@ -1329,72 +1329,72 @@  discard block
 block discarded – undo
1329 1329
 						'show_option_none' => false,
1330 1330
 						'class'            => 'wpinv-tax-country',
1331 1331
 						'chosen'           => false,
1332
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1333
-					) );
1332
+						'placeholder'      => __('Choose a country', 'invoicing')
1333
+					));
1334 1334
 					?>
1335 1335
 				</td>
1336 1336
 				<td class="wpinv_tax_state">
1337 1337
 					<?php
1338
-					$states = wpinv_get_country_states( $rate['country'] );
1339
-					if( !empty( $states ) ) {
1340
-						echo wpinv_html_select( array(
1341
-							'options'          => array_merge( array( '' => '' ), $states ),
1338
+					$states = wpinv_get_country_states($rate['country']);
1339
+					if (!empty($states)) {
1340
+						echo wpinv_html_select(array(
1341
+							'options'          => array_merge(array('' => ''), $states),
1342 1342
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1343 1343
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1344 1344
 							'selected'         => $rate['state'],
1345 1345
 							'show_option_all'  => false,
1346 1346
 							'show_option_none' => false,
1347 1347
 							'chosen'           => false,
1348
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1349
-						) );
1348
+							'placeholder'      => __('Choose a state', 'invoicing')
1349
+						));
1350 1350
 					} else {
1351
-						echo wpinv_html_text( array(
1351
+						echo wpinv_html_text(array(
1352 1352
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1353
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1353
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1354 1354
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1355
-						) );
1355
+						));
1356 1356
 					}
1357 1357
 					?>
1358 1358
 				</td>
1359 1359
 				<td class="wpinv_tax_global">
1360
-					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
1361
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1360
+					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/>
1361
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1362 1362
 				</td>
1363
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
1364
-                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td>
1365
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1363
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td>
1364
+                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td>
1365
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1366 1366
 			</tr>
1367 1367
 			<?php endforeach; ?>
1368 1368
 		<?php else : ?>
1369 1369
 			<tr>
1370 1370
 				<td class="wpinv_tax_country">
1371 1371
 					<?php
1372
-					echo wpinv_html_select( array(
1373
-						'options'          => wpinv_get_country_list( true ),
1372
+					echo wpinv_html_select(array(
1373
+						'options'          => wpinv_get_country_list(true),
1374 1374
 						'name'             => 'tax_rates[0][country]',
1375 1375
 						'show_option_all'  => false,
1376 1376
 						'show_option_none' => false,
1377 1377
 						'class'            => 'wpinv-tax-country',
1378 1378
 						'chosen'           => false,
1379
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1380
-					) ); ?>
1379
+						'placeholder'      => __('Choose a country', 'invoicing')
1380
+					)); ?>
1381 1381
 				</td>
1382 1382
 				<td class="wpinv_tax_state">
1383
-					<?php echo wpinv_html_text( array(
1383
+					<?php echo wpinv_html_text(array(
1384 1384
 						'name' => 'tax_rates[0][state]'
1385
-					) ); ?>
1385
+					)); ?>
1386 1386
 				</td>
1387 1387
 				<td class="wpinv_tax_global">
1388 1388
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1389
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1389
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1390 1390
 				</td>
1391
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td>
1391
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td>
1392 1392
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1393
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1393
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1394 1394
 			</tr>
1395 1395
 		<?php endif; ?>
1396 1396
         </tbody>
1397
-        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1397
+        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot>
1398 1398
 	</table>
1399 1399
 	<?php
1400 1400
 	echo ob_get_clean();
@@ -1405,44 +1405,44 @@  discard block
 block discarded – undo
1405 1405
     ob_start(); ?>
1406 1406
     </td><tr>
1407 1407
     <td colspan="2" class="wpinv_tools_tdbox">
1408
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1409
-    <?php do_action( 'wpinv_tools_before' ); ?>
1408
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1409
+    <?php do_action('wpinv_tools_before'); ?>
1410 1410
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1411 1411
         <thead>
1412 1412
             <tr>
1413
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1414
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1415
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1413
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1414
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1415
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1416 1416
             </tr>
1417 1417
         </thead>
1418
-            <?php do_action( 'wpinv_tools_row' ); ?>
1418
+            <?php do_action('wpinv_tools_row'); ?>
1419 1419
         <tbody>
1420 1420
         </tbody>
1421 1421
     </table>
1422
-    <?php do_action( 'wpinv_tools_after' ); ?>
1422
+    <?php do_action('wpinv_tools_after'); ?>
1423 1423
     <?php
1424 1424
     echo ob_get_clean();
1425 1425
 }
1426 1426
 
1427
-function wpinv_descriptive_text_callback( $args ) {
1428
-	echo wp_kses_post( $args['desc'] );
1427
+function wpinv_descriptive_text_callback($args) {
1428
+	echo wp_kses_post($args['desc']);
1429 1429
 }
1430 1430
 
1431
-function wpinv_hook_callback( $args ) {
1432
-	do_action( 'wpinv_' . $args['id'], $args );
1431
+function wpinv_hook_callback($args) {
1432
+	do_action('wpinv_' . $args['id'], $args);
1433 1433
 }
1434 1434
 
1435 1435
 function wpinv_set_settings_cap() {
1436 1436
 	return 'manage_options';
1437 1437
 }
1438
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1438
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1439 1439
 
1440
-function wpinv_settings_sanitize_input( $value, $key ) {
1441
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1442
-        $value = wpinv_sanitize_amount( $value, 4 );
1440
+function wpinv_settings_sanitize_input($value, $key) {
1441
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1442
+        $value = wpinv_sanitize_amount($value, 4);
1443 1443
         $value = $value >= 100 ? 99 : $value;
1444 1444
     }
1445 1445
         
1446 1446
     return $value;
1447 1447
 }
1448
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1449 1448
\ No newline at end of file
1449
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1450 1450
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-error-functions.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
         ) );
14 14
         echo '<div class="' . implode( ' ', $classes ) . '">';
15 15
             // Loop error codes and display errors
16
-           foreach ( $errors as $error_id => $error ) {
16
+            foreach ( $errors as $error_id => $error ) {
17 17
                 echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>';
18
-           }
18
+            }
19 19
         echo '</div>';
20 20
         wpinv_clear_errors();
21 21
     }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,61 +1,61 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 function wpinv_print_errors() {
8 8
     $errors = wpinv_get_errors();
9 9
 
10
-    if ( $errors ) {
11
-        $classes = apply_filters( 'wpinv_error_class', array(
10
+    if ($errors) {
11
+        $classes = apply_filters('wpinv_error_class', array(
12 12
             'wpinv_errors', 'wpinv-alert', 'wpinv-alert-error'
13
-        ) );
14
-        echo '<div class="' . implode( ' ', $classes ) . '">';
13
+        ));
14
+        echo '<div class="' . implode(' ', $classes) . '">';
15 15
             // Loop error codes and display errors
16
-           foreach ( $errors as $error_id => $error ) {
17
-                echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __( 'Error', 'invoicing' ) . '</strong>: ' . $error . '</p>';
16
+           foreach ($errors as $error_id => $error) {
17
+                echo '<p class="wpinv_error" id="wpinv_error_' . $error_id . '"><strong>' . __('Error', 'invoicing') . '</strong>: ' . $error . '</p>';
18 18
            }
19 19
         echo '</div>';
20 20
         wpinv_clear_errors();
21 21
     }
22 22
 }
23
-add_action( 'wpinv_purchase_form_before_submit', 'wpinv_print_errors' );
24
-add_action( 'wpinv_ajax_checkout_errors', 'wpinv_print_errors' );
23
+add_action('wpinv_purchase_form_before_submit', 'wpinv_print_errors');
24
+add_action('wpinv_ajax_checkout_errors', 'wpinv_print_errors');
25 25
 
26 26
 function wpinv_get_errors() {
27 27
     global $wpi_session;
28 28
     
29
-    return $wpi_session->get( 'wpinv_errors' );
29
+    return $wpi_session->get('wpinv_errors');
30 30
 }
31 31
 
32
-function wpinv_set_error( $error_id, $error_message ) {
32
+function wpinv_set_error($error_id, $error_message) {
33 33
     global $wpi_session;
34 34
     
35 35
     $errors = wpinv_get_errors();
36 36
 
37
-    if ( ! $errors ) {
37
+    if (!$errors) {
38 38
         $errors = array();
39 39
     }
40 40
 
41
-    $errors[ $error_id ] = $error_message;
42
-    $wpi_session->set( 'wpinv_errors', $errors );
41
+    $errors[$error_id] = $error_message;
42
+    $wpi_session->set('wpinv_errors', $errors);
43 43
 }
44 44
 
45 45
 function wpinv_clear_errors() {
46 46
     global $wpi_session;
47 47
     
48
-    $wpi_session->set( 'wpinv_errors', null );
48
+    $wpi_session->set('wpinv_errors', null);
49 49
 }
50 50
 
51
-function wpinv_unset_error( $error_id ) {
51
+function wpinv_unset_error($error_id) {
52 52
     global $wpi_session;
53 53
     
54 54
     $errors = wpinv_get_errors();
55 55
 
56
-    if ( $errors ) {
57
-        unset( $errors[ $error_id ] );
58
-        $wpi_session->set( 'wpinv_errors', $errors );
56
+    if ($errors) {
57
+        unset($errors[$error_id]);
58
+        $wpi_session->set('wpinv_errors', $errors);
59 59
     }
60 60
 }
61 61
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
     die();
64 64
 }
65 65
 
66
-function wpinv_die( $message = '', $title = '', $status = 400 ) {
67
-    add_filter( 'wp_die_ajax_handler', 'wpinv_die_handler', 10, 3 );
68
-    add_filter( 'wp_die_handler', 'wpinv_die_handler', 10, 3 );
69
-    wp_die( $message, $title, array( 'response' => $status ));
66
+function wpinv_die($message = '', $title = '', $status = 400) {
67
+    add_filter('wp_die_ajax_handler', 'wpinv_die_handler', 10, 3);
68
+    add_filter('wp_die_handler', 'wpinv_die_handler', 10, 3);
69
+    wp_die($message, $title, array('response' => $status));
70 70
 }
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 3 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -286,26 +286,26 @@  discard block
 block discarded – undo
286 286
 }
287 287
 
288 288
 function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
289
+    $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
290 290
 
291 291
     $chosen = false;
292 292
     if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+    $chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
300
-	}
298
+    if ( false !== $chosen ) {
299
+        $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
300
+    }
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
-		$enabled_gateway = 'manual';
306
-	} else {
307
-		$enabled_gateway = wpinv_get_default_gateway();
308
-	}
302
+    if ( ! empty ( $chosen ) ) {
303
+        $enabled_gateway = urldecode( $chosen );
304
+    } else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
+        $enabled_gateway = 'manual';
306
+    } else {
307
+        $enabled_gateway = wpinv_get_default_gateway();
308
+    }
309 309
     
310 310
     if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311 311
         if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+    return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
320 320
 }
321 321
 
322 322
 function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 }
325 325
 
326 326
 function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
327
-	$ret  = 0;
328
-	$args = array(
329
-		'meta_key'    => '_wpinv_gateway',
330
-		'meta_value'  => $gateway_id,
331
-		'nopaging'    => true,
332
-		'post_type'   => 'wpi_invoice',
333
-		'post_status' => $status,
334
-		'fields'      => 'ids'
335
-	);
336
-
337
-	$payments = new WP_Query( $args );
338
-
339
-	if( $payments )
340
-		$ret = $payments->post_count;
341
-	return $ret;
327
+    $ret  = 0;
328
+    $args = array(
329
+        'meta_key'    => '_wpinv_gateway',
330
+        'meta_value'  => $gateway_id,
331
+        'nopaging'    => true,
332
+        'post_type'   => 'wpi_invoice',
333
+        'post_status' => $status,
334
+        'fields'      => 'ids'
335
+    );
336
+
337
+    $payments = new WP_Query( $args );
338
+
339
+    if( $payments )
340
+        $ret = $payments->post_count;
341
+    return $ret;
342 342
 }
343 343
 
344 344
 function wpinv_settings_update_gateways( $input ) {
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311 311
         if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else{
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
@@ -336,8 +336,9 @@  discard block
 block discarded – undo
336 336
 
337 337
 	$payments = new WP_Query( $args );
338 338
 
339
-	if( $payments )
340
-		$ret = $payments->post_count;
339
+	if( $payments ) {
340
+			$ret = $payments->post_count;
341
+	}
341 342
 	return $ret;
342 343
 }
343 344
 
Please login to merge, or discard this patch.
Spacing   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -7,206 +7,206 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_get_payment_gateways() {
15 15
     // Default, built-in gateways
16 16
     $gateways = array(
17 17
         'paypal' => array(
18
-            'admin_label'    => __( 'PayPal Standard', 'invoicing' ),
19
-            'checkout_label' => __( 'PayPal Standard', 'invoicing' ),
18
+            'admin_label'    => __('PayPal Standard', 'invoicing'),
19
+            'checkout_label' => __('PayPal Standard', 'invoicing'),
20 20
             'ordering'       => 1,
21 21
         ),
22 22
         'authorizenet' => array(
23
-            'admin_label'    => __( 'Authorize.Net (AIM)', 'invoicing' ),
24
-            'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ),
23
+            'admin_label'    => __('Authorize.Net (AIM)', 'invoicing'),
24
+            'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'),
25 25
             'ordering'       => 4,
26 26
         ),
27 27
         'worldpay' => array(
28
-            'admin_label'    => __( 'Worldpay', 'invoicing' ),
29
-            'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ),
28
+            'admin_label'    => __('Worldpay', 'invoicing'),
29
+            'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'),
30 30
             'ordering'       => 5,
31 31
         ),
32 32
         'bank_transfer' => array(
33
-            'admin_label'    => __( 'Pre Bank Transfer', 'invoicing' ),
34
-            'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ),
33
+            'admin_label'    => __('Pre Bank Transfer', 'invoicing'),
34
+            'checkout_label' => __('Pre Bank Transfer', 'invoicing'),
35 35
             'ordering'       => 11,
36 36
         ),
37 37
         'manual' => array(
38
-            'admin_label'    => __( 'Test Payment', 'invoicing' ),
39
-            'checkout_label' => __( 'Test Payment', 'invoicing' ),
38
+            'admin_label'    => __('Test Payment', 'invoicing'),
39
+            'checkout_label' => __('Test Payment', 'invoicing'),
40 40
             'ordering'       => 12,
41 41
         ),
42 42
     );
43 43
 
44
-    return apply_filters( 'wpinv_payment_gateways', $gateways );
44
+    return apply_filters('wpinv_payment_gateways', $gateways);
45 45
 }
46 46
 
47
-function wpinv_payment_gateway_titles( $all_gateways ) {
47
+function wpinv_payment_gateway_titles($all_gateways) {
48 48
     global $wpinv_options;
49 49
     
50 50
     $gateways = array();
51
-    foreach ( $all_gateways as $key => $gateway ) {
52
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
53
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
51
+    foreach ($all_gateways as $key => $gateway) {
52
+        if (!empty($wpinv_options[$key . '_title'])) {
53
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
54 54
         }
55 55
         
56
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
56
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
57 57
     }
58 58
 
59
-    asort( $gateways );
59
+    asort($gateways);
60 60
     
61
-    foreach ( $gateways as $gateway => $key ) {
61
+    foreach ($gateways as $gateway => $key) {
62 62
         $gateways[$gateway] = $all_gateways[$gateway];
63 63
     }
64 64
     
65 65
     return $gateways;
66 66
 }
67
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
67
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
68 68
 
69
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
69
+function wpinv_get_enabled_payment_gateways($sort = false) {
70 70
     $gateways = wpinv_get_payment_gateways();
71
-    $enabled  = wpinv_get_option( 'gateways', false );
71
+    $enabled  = wpinv_get_option('gateways', false);
72 72
 
73 73
     $gateway_list = array();
74 74
 
75
-    foreach ( $gateways as $key => $gateway ) {
76
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
77
-            $gateway_list[ $key ] = $gateway;
75
+    foreach ($gateways as $key => $gateway) {
76
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
77
+            $gateway_list[$key] = $gateway;
78 78
         }
79 79
     }
80 80
 
81
-    if ( true === $sort ) {
82
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
81
+    if (true === $sort) {
82
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
83 83
         
84 84
         // Reorder our gateways so the default is first
85 85
         $default_gateway_id = wpinv_get_default_gateway();
86 86
 
87
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
88
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
89
-            unset( $gateway_list[ $default_gateway_id ] );
87
+        if (wpinv_is_gateway_active($default_gateway_id)) {
88
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
89
+            unset($gateway_list[$default_gateway_id]);
90 90
 
91
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
91
+            $gateway_list = array_merge($default_gateway, $gateway_list);
92 92
         }
93 93
     }
94 94
 
95
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
95
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
96 96
 }
97 97
 
98
-function wpinv_sort_gateway_order( $a, $b ) {
98
+function wpinv_sort_gateway_order($a, $b) {
99 99
     return $a['ordering'] - $b['ordering'];
100 100
 }
101 101
 
102
-function wpinv_is_gateway_active( $gateway ) {
102
+function wpinv_is_gateway_active($gateway) {
103 103
     $gateways = wpinv_get_enabled_payment_gateways();
104 104
 
105
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
105
+    $ret = is_array($gateways) && $gateway ? array_key_exists($gateway, $gateways) : false;
106 106
 
107
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
107
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
108 108
 }
109 109
 
110 110
 function wpinv_get_default_gateway() {
111
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
111
+    $default = wpinv_get_option('default_gateway', 'paypal');
112 112
 
113
-    if ( !wpinv_is_gateway_active( $default ) ) {
113
+    if (!wpinv_is_gateway_active($default)) {
114 114
         $gateways = wpinv_get_enabled_payment_gateways();
115
-        $gateways = array_keys( $gateways );
116
-        $default  = reset( $gateways );
115
+        $gateways = array_keys($gateways);
116
+        $default  = reset($gateways);
117 117
     }
118 118
 
119
-    return apply_filters( 'wpinv_default_gateway', $default );
119
+    return apply_filters('wpinv_default_gateway', $default);
120 120
 }
121 121
 
122
-function wpinv_get_gateway_admin_label( $gateway ) {
122
+function wpinv_get_gateway_admin_label($gateway) {
123 123
     $gateways = wpinv_get_payment_gateways();
124
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
125
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
124
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
125
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
126 126
 
127
-    if( $gateway == 'manual' && $payment ) {
128
-        if( wpinv_get_payment_amount( $payment ) == 0 ) {
129
-            $label = __( 'Manual Payment', 'invoicing' );
127
+    if ($gateway == 'manual' && $payment) {
128
+        if (wpinv_get_payment_amount($payment) == 0) {
129
+            $label = __('Manual Payment', 'invoicing');
130 130
         }
131 131
     }
132 132
 
133
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
133
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
134 134
 }
135 135
 
136
-function wpinv_get_gateway_description( $gateway ) {
136
+function wpinv_get_gateway_description($gateway) {
137 137
     global $wpinv_options;
138 138
 
139
-    $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
139
+    $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
140 140
 
141
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
141
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
142 142
 }
143 143
 
144
-function wpinv_get_gateway_button_label( $gateway ) {
145
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
144
+function wpinv_get_gateway_button_label($gateway) {
145
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
146 146
 }
147 147
 
148
-function wpinv_get_gateway_checkout_label( $gateway ) {
148
+function wpinv_get_gateway_checkout_label($gateway) {
149 149
     $gateways = wpinv_get_payment_gateways();
150
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
150
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
151 151
 
152
-    if( $gateway == 'manual' ) {
153
-        $label = __( 'Manual Payment', 'invoicing' );
152
+    if ($gateway == 'manual') {
153
+        $label = __('Manual Payment', 'invoicing');
154 154
     }
155 155
 
156
-    return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway );
156
+    return apply_filters('wpinv_gateway_checkout_label', $label, $gateway);
157 157
 }
158 158
 
159
-function wpinv_settings_sections_gateways( $settings ) {
159
+function wpinv_settings_sections_gateways($settings) {
160 160
     $gateways = wpinv_get_payment_gateways();
161 161
     
162 162
     if (!empty($gateways)) {
163
-        foreach  ($gateways as $key => $gateway) {
163
+        foreach ($gateways as $key => $gateway) {
164 164
             $settings[$key] = $gateway['admin_label'];
165 165
         }
166 166
     }
167 167
     
168 168
     return $settings;    
169 169
 }
170
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
170
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
171 171
 
172
-function wpinv_settings_gateways( $settings ) {
172
+function wpinv_settings_gateways($settings) {
173 173
     $gateways = wpinv_get_payment_gateways();
174 174
     
175 175
     if (!empty($gateways)) {
176
-        foreach  ($gateways as $key => $gateway) {
176
+        foreach ($gateways as $key => $gateway) {
177 177
             $setting = array();
178 178
             $setting[$key . '_header'] = array(
179 179
                     'id'   => 'gateway_header',
180
-                    'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
180
+                    'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
181 181
                     'custom' => $key,
182 182
                     'type' => 'gateway_header',
183 183
                 );
184 184
             $setting[$key . '_active'] = array(
185 185
                     'id'   => $key . '_active',
186
-                    'name' => __( 'Active', 'invoicing' ),
187
-                    'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
186
+                    'name' => __('Active', 'invoicing'),
187
+                    'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
188 188
                     'type' => 'checkbox',
189 189
                 );
190 190
                 
191 191
             $setting[$key . '_title'] = array(
192 192
                     'id'   => $key . '_title',
193
-                    'name' => __( 'Title', 'invoicing' ),
194
-                    'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ),
193
+                    'name' => __('Title', 'invoicing'),
194
+                    'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'),
195 195
                     'type' => 'text',
196 196
                     'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : ''
197 197
                 );
198 198
             
199 199
             $setting[$key . '_desc'] = array(
200 200
                     'id'   => $key . '_desc',
201
-                    'name' => __( 'Description', 'invoicing' ),
202
-                    'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ),
201
+                    'name' => __('Description', 'invoicing'),
202
+                    'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'),
203 203
                     'type' => 'text',
204 204
                     'size' => 'large'
205 205
                 );
206 206
                 
207 207
             $setting[$key . '_ordering'] = array(
208 208
                     'id'   => $key . '_ordering',
209
-                    'name' => __( 'Display Order', 'invoicing' ),
209
+                    'name' => __('Display Order', 'invoicing'),
210 210
                     'type' => 'number',
211 211
                     'size' => 'small',
212 212
                     'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
                     'step' => '1'
216 216
                 );
217 217
                 
218
-            $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key );
219
-            $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting );
218
+            $setting = apply_filters('wpinv_gateway_settings', $setting, $key);
219
+            $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting);
220 220
             
221 221
             $settings[$key] = $setting;
222 222
         }
@@ -224,106 +224,106 @@  discard block
 block discarded – undo
224 224
     
225 225
     return $settings;    
226 226
 }
227
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
227
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
228 228
 
229
-function wpinv_gateway_header_callback( $args ) {
230
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
229
+function wpinv_gateway_header_callback($args) {
230
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
231 231
 }
232 232
 
233
-function wpinv_get_gateway_supports( $gateway ) {
233
+function wpinv_get_gateway_supports($gateway) {
234 234
     $gateways = wpinv_get_enabled_payment_gateways();
235
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
236
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
235
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
236
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
237 237
 }
238 238
 
239
-function wpinv_gateway_supports_buy_now( $gateway ) {
240
-    $supports = wpinv_get_gateway_supports( $gateway );
241
-    $ret = in_array( 'buy_now', $supports );
242
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
239
+function wpinv_gateway_supports_buy_now($gateway) {
240
+    $supports = wpinv_get_gateway_supports($gateway);
241
+    $ret = in_array('buy_now', $supports);
242
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
243 243
 }
244 244
 
245 245
 function wpinv_shop_supports_buy_now() {
246 246
     $gateways = wpinv_get_enabled_payment_gateways();
247 247
     $ret      = false;
248 248
 
249
-    if ( !wpinv_use_taxes()  && $gateways ) {
250
-        foreach ( $gateways as $gateway_id => $gateway ) {
251
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
249
+    if (!wpinv_use_taxes() && $gateways) {
250
+        foreach ($gateways as $gateway_id => $gateway) {
251
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
252 252
                 $ret = true;
253 253
                 break;
254 254
             }
255 255
         }
256 256
     }
257 257
 
258
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
258
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
259 259
 }
260 260
 
261
-function wpinv_send_to_gateway( $gateway, $payment_data ) {
262
-    $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' );
261
+function wpinv_send_to_gateway($gateway, $payment_data) {
262
+    $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway');
263 263
 
264 264
     // $gateway must match the ID used when registering the gateway
265
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
265
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
266 266
 }
267 267
 
268 268
 function wpinv_show_gateways() {
269 269
     $gateways = wpinv_get_enabled_payment_gateways();
270 270
     $show_gateways = false;
271 271
 
272
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
272
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
273 273
 
274
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
274
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
275 275
         $show_gateways = true;
276
-        if ( wpinv_get_cart_total() <= 0 ) {
276
+        if (wpinv_get_cart_total() <= 0) {
277 277
             $show_gateways = false;
278 278
         }
279 279
     }
280 280
     
281
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
281
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
282 282
         $show_gateways = true;
283 283
     }
284 284
 
285
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
285
+    return apply_filters('wpinv_show_gateways', $show_gateways);
286 286
 }
287 287
 
288
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
288
+function wpinv_get_chosen_gateway($invoice_id = 0) {
289
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
290 290
 
291 291
     $chosen = false;
292
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
292
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
298
+	if (false !== $chosen) {
299
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
300 300
 	}
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
302
+	if (!empty ($chosen)) {
303
+		$enabled_gateway = urldecode($chosen);
304
+	} else if (!empty($invoice) && (float)$invoice->get_subtotal() <= 0) {
305 305
 		$enabled_gateway = 'manual';
306 306
 	} else {
307 307
 		$enabled_gateway = wpinv_get_default_gateway();
308 308
 	}
309 309
     
310
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
310
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
311
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else {
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
320 320
 }
321 321
 
322
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
323
-    return wpinv_error_log( $message, $title );
322
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
323
+    return wpinv_error_log($message, $title);
324 324
 }
325 325
 
326
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
326
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
327 327
 	$ret  = 0;
328 328
 	$args = array(
329 329
 		'meta_key'    => '_wpinv_gateway',
@@ -334,48 +334,48 @@  discard block
 block discarded – undo
334 334
 		'fields'      => 'ids'
335 335
 	);
336 336
 
337
-	$payments = new WP_Query( $args );
337
+	$payments = new WP_Query($args);
338 338
 
339
-	if( $payments )
339
+	if ($payments)
340 340
 		$ret = $payments->post_count;
341 341
 	return $ret;
342 342
 }
343 343
 
344
-function wpinv_settings_update_gateways( $input ) {
344
+function wpinv_settings_update_gateways($input) {
345 345
     global $wpinv_options;
346 346
     
347
-    if ( !empty( $input['save_gateway'] ) ) {
348
-        $gateways = wpinv_get_option( 'gateways', false );
347
+    if (!empty($input['save_gateway'])) {
348
+        $gateways = wpinv_get_option('gateways', false);
349 349
         $gateways = !empty($gateways) ? $gateways : array();
350 350
         $gateway = $input['save_gateway'];
351 351
         
352
-        if ( !empty( $input[$gateway . '_active'] ) ) {
352
+        if (!empty($input[$gateway . '_active'])) {
353 353
             $gateways[$gateway] = 1;
354 354
         } else {
355
-            if ( isset( $gateways[$gateway] ) ) {
356
-                unset( $gateways[$gateway] );
355
+            if (isset($gateways[$gateway])) {
356
+                unset($gateways[$gateway]);
357 357
             }
358 358
         }
359 359
         
360 360
         $input['gateways'] = $gateways;
361 361
     }
362 362
     
363
-    if ( !empty( $input['default_gateway'] ) ) {
363
+    if (!empty($input['default_gateway'])) {
364 364
         $gateways = wpinv_get_payment_gateways();
365 365
         
366
-        foreach ( $gateways as $key => $gateway ) {
367
-            $active   = 0;
368
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
366
+        foreach ($gateways as $key => $gateway) {
367
+            $active = 0;
368
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
369 369
                 $active = 1;
370 370
             }
371 371
             
372 372
             $input[$key . '_active'] = $active;
373 373
             
374
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
374
+            if (empty($wpinv_options[$key . '_title'])) {
375 375
                 $input[$key . '_title'] = $gateway['checkout_label'];
376 376
             }
377 377
             
378
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
378
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
379 379
                 $input[$key . '_ordering'] = $gateway['ordering'];
380 380
             }
381 381
         }
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
     
384 384
     return $input;
385 385
 }
386
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
386
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
387 387
 
388 388
 // PayPal Standard settings
389
-function wpinv_gateway_settings_paypal( $setting ) {    
390
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
389
+function wpinv_gateway_settings_paypal($setting) {    
390
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
391 391
     
392 392
     $setting['paypal_sandbox'] = array(
393 393
             'type' => 'checkbox',
394 394
             'id'   => 'paypal_sandbox',
395
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
396
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
395
+            'name' => __('PayPal Sandbox', 'invoicing'),
396
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
397 397
             'std'  => 1
398 398
         );
399 399
         
400 400
     $setting['paypal_email'] = array(
401 401
             'type' => 'text',
402 402
             'id'   => 'paypal_email',
403
-            'name' => __( 'PayPal Email', 'invoicing' ),
404
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
405
-            'std' => __( '[email protected]', 'invoicing' ),
403
+            'name' => __('PayPal Email', 'invoicing'),
404
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
405
+            'std' => __('[email protected]', 'invoicing'),
406 406
         );
407 407
     /*
408 408
     $setting['paypal_ipn_url'] = array(
@@ -416,116 +416,116 @@  discard block
 block discarded – undo
416 416
         
417 417
     return $setting;
418 418
 }
419
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
419
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
420 420
 
421 421
 // Pre Bank Transfer settings
422
-function wpinv_gateway_settings_bank_transfer( $setting ) {
423
-    $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' );
422
+function wpinv_gateway_settings_bank_transfer($setting) {
423
+    $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing');
424 424
     
425 425
     $setting['bank_transfer_ac_name'] = array(
426 426
             'type' => 'text',
427 427
             'id' => 'bank_transfer_ac_name',
428
-            'name' => __( 'Account Name', 'invoicing' ),
429
-            'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ),
430
-            'std'  =>  __( 'Mr. John Martin', 'invoicing' ),
428
+            'name' => __('Account Name', 'invoicing'),
429
+            'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'),
430
+            'std'  =>  __('Mr. John Martin', 'invoicing'),
431 431
         );
432 432
     
433 433
     $setting['bank_transfer_ac_no'] = array(
434 434
             'type' => 'text',
435 435
             'id' => 'bank_transfer_ac_no',
436
-            'name' => __( 'Account Number', 'invoicing' ),
437
-            'desc' => __( 'Enter your bank account number.', 'invoicing' ),
438
-            'std'  =>  __( 'TEST1234567890', 'invoicing' ),
436
+            'name' => __('Account Number', 'invoicing'),
437
+            'desc' => __('Enter your bank account number.', 'invoicing'),
438
+            'std'  =>  __('TEST1234567890', 'invoicing'),
439 439
         );
440 440
     
441 441
     $setting['bank_transfer_bank_name'] = array(
442 442
             'type' => 'text',
443 443
             'id'   => 'bank_transfer_bank_name',
444
-            'name' => __( 'Bank Name', 'invoicing' ),
445
-            'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ),
446
-            'std' => __( 'ICICI Bank', 'invoicing' ),
444
+            'name' => __('Bank Name', 'invoicing'),
445
+            'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'),
446
+            'std' => __('ICICI Bank', 'invoicing'),
447 447
         );
448 448
     
449 449
     $setting['bank_transfer_ifsc'] = array(
450 450
             'type' => 'text',
451 451
             'id'   => 'bank_transfer_ifsc',
452
-            'name' => __( 'IFSC code', 'invoicing' ),
453
-            'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ),
454
-            'std'  =>  __( 'ICIC0001234', 'invoicing' ),
452
+            'name' => __('IFSC code', 'invoicing'),
453
+            'desc' => __('Enter your bank IFSC code.', 'invoicing'),
454
+            'std'  =>  __('ICIC0001234', 'invoicing'),
455 455
         );
456 456
         
457 457
     $setting['bank_transfer_iban'] = array(
458 458
             'type' => 'text',
459 459
             'id'   => 'bank_transfer_iban',
460
-            'name' => __( 'IBAN', 'invoicing' ),
461
-            'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ),
462
-            'std'  =>  __( 'GB29NWBK60161331926819', 'invoicing' ),
460
+            'name' => __('IBAN', 'invoicing'),
461
+            'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'),
462
+            'std'  =>  __('GB29NWBK60161331926819', 'invoicing'),
463 463
         );
464 464
         
465 465
     $setting['bank_transfer_bic'] = array(
466 466
             'type' => 'text',
467 467
             'id'   => 'bank_transfer_bic',
468
-            'name' => __( 'BIC/Swift code', 'invoicing' ),
469
-            'std'  =>  __( 'ICICGB2L129', 'invoicing' ),
468
+            'name' => __('BIC/Swift code', 'invoicing'),
469
+            'std'  =>  __('ICICGB2L129', 'invoicing'),
470 470
         );
471 471
         
472 472
     $setting['bank_transfer_info'] = array(
473 473
             'id'   => 'bank_transfer_info',
474
-            'name' => __( 'Instructions', 'invoicing' ),
475
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
474
+            'name' => __('Instructions', 'invoicing'),
475
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
476 476
             'type' => 'textarea',
477
-            'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ),
477
+            'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'),
478 478
             'cols' => 37,
479 479
             'rows' => 5
480 480
         );
481 481
         
482 482
     return $setting;
483 483
 }
484
-add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 );
484
+add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1);
485 485
 
486 486
 // Authorize.Net settings
487
-function wpinv_gateway_settings_authorizenet( $setting ) {
488
-    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( currencies supported: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' );
489
-    $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing' );
487
+function wpinv_gateway_settings_authorizenet($setting) {
488
+    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( currencies supported: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing');
489
+    $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing');
490 490
     
491 491
     $setting['authorizenet_sandbox'] = array(
492 492
             'type' => 'checkbox',
493 493
             'id'   => 'authorizenet_sandbox',
494
-            'name' => __( 'Authorize.Net Test Mode', 'invoicing' ),
495
-            'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ),
494
+            'name' => __('Authorize.Net Test Mode', 'invoicing'),
495
+            'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'),
496 496
             'std'  => 1
497 497
         );
498 498
         
499 499
     $setting['authorizenet_login_id'] = array(
500 500
             'type' => 'text',
501 501
             'id'   => 'authorizenet_login_id',
502
-            'name' => __( 'API Login ID', 'invoicing' ),
503
-            'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ),
502
+            'name' => __('API Login ID', 'invoicing'),
503
+            'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'),
504 504
             'std' => '2j4rBekUnD',
505 505
         );
506 506
     
507 507
     $setting['authorizenet_transaction_key'] = array(
508 508
             'type' => 'text',
509 509
             'id'   => 'authorizenet_transaction_key',
510
-            'name' => __( 'Transaction Key', 'invoicing' ),
511
-            'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ),
510
+            'name' => __('Transaction Key', 'invoicing'),
511
+            'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'),
512 512
             'std' => '4vyBUOJgR74679xa',
513 513
         );
514 514
         
515 515
     $setting['authorizenet_md5_hash'] = array(
516 516
             'type' => 'text',
517 517
             'id'   => 'authorizenet_md5_hash',
518
-            'name' => __( 'MD5-Hash', 'invoicing' ),
519
-            'desc' => __( 'The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ),
518
+            'name' => __('MD5-Hash', 'invoicing'),
519
+            'desc' => __('The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'),
520 520
             'std' => '',
521 521
         );
522 522
         
523 523
     $setting['authorizenet_ipn_url'] = array(
524 524
             'type' => 'ipn_url',
525 525
             'id'   => 'authorizenet_ipn_url',
526
-            'name' => __( 'Silent Post URL', 'invoicing' ),
527
-            'std' => wpinv_get_ipn_url( 'authorizenet' ),
528
-            'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ),
526
+            'name' => __('Silent Post URL', 'invoicing'),
527
+            'std' => wpinv_get_ipn_url('authorizenet'),
528
+            'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'),
529 529
             'size' => 'large',
530 530
             'custom' => 'authorizenet',
531 531
             'readonly' => true
@@ -533,25 +533,25 @@  discard block
 block discarded – undo
533 533
         
534 534
     return $setting;
535 535
 }
536
-add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 );
536
+add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1);
537 537
 
538 538
 // Worldpay settings
539
-function wpinv_gateway_settings_worldpay( $setting ) {
540
-    $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing' );
539
+function wpinv_gateway_settings_worldpay($setting) {
540
+    $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing');
541 541
     
542 542
     $setting['worldpay_sandbox'] = array(
543 543
             'type' => 'checkbox',
544 544
             'id'   => 'worldpay_sandbox',
545
-            'name' => __( 'Worldpay Test Mode', 'invoicing' ),
546
-            'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ),
545
+            'name' => __('Worldpay Test Mode', 'invoicing'),
546
+            'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'),
547 547
             'std'  => 1
548 548
         );
549 549
         
550 550
     $setting['worldpay_instId'] = array(
551 551
             'type' => 'text',
552 552
             'id'   => 'worldpay_instId',
553
-            'name' => __( 'Installation Id', 'invoicing' ),
554
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
553
+            'name' => __('Installation Id', 'invoicing'),
554
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
555 555
             'std' => '211616',
556 556
         );
557 557
     /*
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
     $setting['worldpay_ipn_url'] = array(
568 568
             'type' => 'ipn_url',
569 569
             'id'   => 'worldpay_ipn_url',
570
-            'name' => __( 'Worldpay Callback Url', 'invoicing' ),
571
-            'std' => wpinv_get_ipn_url( 'worldpay' ),
572
-            'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>' ),
570
+            'name' => __('Worldpay Callback Url', 'invoicing'),
571
+            'std' => wpinv_get_ipn_url('worldpay'),
572
+            'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>'),
573 573
             'size' => 'large',
574 574
             'custom' => 'worldpay',
575 575
             'readonly' => true
@@ -577,94 +577,94 @@  discard block
 block discarded – undo
577 577
         
578 578
     return $setting;
579 579
 }
580
-add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 );
580
+add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1);
581 581
 
582
-function wpinv_ipn_url_callback( $args ) {    
583
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
582
+function wpinv_ipn_url_callback($args) {    
583
+    $sanitize_id = wpinv_sanitize_key($args['id']);
584 584
     
585 585
     $attrs = $args['readonly'] ? ' readonly' : '';
586 586
 
587
-    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
588
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
587
+    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
588
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
589 589
 
590 590
     echo $html;
591 591
 }
592 592
 
593
-function wpinv_is_test_mode( $gateway = '' ) {
594
-    if ( empty( $gateway ) ) {
593
+function wpinv_is_test_mode($gateway = '') {
594
+    if (empty($gateway)) {
595 595
         return false;
596 596
     }
597 597
     
598
-    $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false );
598
+    $is_test_mode = wpinv_get_option($gateway . '_sandbox', false);
599 599
     
600
-    return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway );
600
+    return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway);
601 601
 }
602 602
 
603
-function wpinv_get_ipn_url( $gateway = '', $args = array() ) {
604
-    $data = array( 'wpi-listener' => 'IPN' );
603
+function wpinv_get_ipn_url($gateway = '', $args = array()) {
604
+    $data = array('wpi-listener' => 'IPN');
605 605
     
606
-    if ( !empty( $gateway ) ) {
607
-        $data['wpi-gateway'] = wpinv_sanitize_key( $gateway );
606
+    if (!empty($gateway)) {
607
+        $data['wpi-gateway'] = wpinv_sanitize_key($gateway);
608 608
     }
609 609
     
610
-    $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data;
610
+    $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data;
611 611
     
612
-    $ipn_url = add_query_arg( $args,  home_url( 'index.php' ) );
612
+    $ipn_url = add_query_arg($args, home_url('index.php'));
613 613
     
614
-    return apply_filters( 'wpinv_ipn_url', $ipn_url );
614
+    return apply_filters('wpinv_ipn_url', $ipn_url);
615 615
 }
616 616
 
617 617
 function wpinv_listen_for_payment_ipn() {
618 618
     // Regular PayPal IPN
619
-    if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) {
620
-        do_action( 'wpinv_verify_payment_ipn' );
619
+    if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') {
620
+        do_action('wpinv_verify_payment_ipn');
621 621
         
622
-        if ( !empty( $_GET['wpi-gateway'] ) ) {
623
-            wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'wpinv_listen_for_payment_ipn()', __FILE__, __LINE__ );
624
-            do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' );
622
+        if (!empty($_GET['wpi-gateway'])) {
623
+            wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'wpinv_listen_for_payment_ipn()', __FILE__, __LINE__);
624
+            do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn');
625 625
         }
626 626
     }
627 627
 }
628
-add_action( 'init', 'wpinv_listen_for_payment_ipn' );
628
+add_action('init', 'wpinv_listen_for_payment_ipn');
629 629
 
630 630
 function wpinv_get_bank_instructions() {
631
-    $bank_instructions = wpinv_get_option( 'bank_transfer_info' );
631
+    $bank_instructions = wpinv_get_option('bank_transfer_info');
632 632
     
633
-    return apply_filters( 'wpinv_bank_instructions', $bank_instructions );
633
+    return apply_filters('wpinv_bank_instructions', $bank_instructions);
634 634
 }
635 635
 
636
-function wpinv_get_bank_info( $filtered = false ) {
636
+function wpinv_get_bank_info($filtered = false) {
637 637
     $bank_fields = array(
638
-        'bank_transfer_ac_name' => __( 'Account Name', 'invoicing' ),
639
-        'bank_transfer_ac_no' => __( 'Account Number', 'invoicing' ),
640
-        'bank_transfer_bank_name' => __( 'Bank Name', 'invoicing' ),
641
-        'bank_transfer_ifsc' => __( 'IFSC code', 'invoicing' ),
642
-        'bank_transfer_iban' => __( 'IBAN', 'invoicing' ),
643
-        'bank_transfer_bic' => __( 'BIC/Swift code', 'invoicing' )
638
+        'bank_transfer_ac_name' => __('Account Name', 'invoicing'),
639
+        'bank_transfer_ac_no' => __('Account Number', 'invoicing'),
640
+        'bank_transfer_bank_name' => __('Bank Name', 'invoicing'),
641
+        'bank_transfer_ifsc' => __('IFSC code', 'invoicing'),
642
+        'bank_transfer_iban' => __('IBAN', 'invoicing'),
643
+        'bank_transfer_bic' => __('BIC/Swift code', 'invoicing')
644 644
     );
645 645
     
646 646
     $bank_info = array();
647
-    foreach ( $bank_fields as $field => $label ) {
648
-        if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) {
647
+    foreach ($bank_fields as $field => $label) {
648
+        if ($filtered && !($value = wpinv_get_option($field))) {
649 649
             continue;
650 650
         }
651 651
         
652
-        $bank_info[$field] = array( 'label' => $label, 'value' => $value );
652
+        $bank_info[$field] = array('label' => $label, 'value' => $value);
653 653
     }
654 654
     
655
-    return apply_filters( 'wpinv_bank_info', $bank_info, $filtered );
655
+    return apply_filters('wpinv_bank_info', $bank_info, $filtered);
656 656
 }
657 657
 
658
-function wpinv_process_before_send_to_gateway( $invoice, $invoice_data = array() ) {
659
-    if ( !empty( $invoice ) && $invoice->is_recurring() && $subscription_item = $invoice->get_recurring( true ) ) {        
658
+function wpinv_process_before_send_to_gateway($invoice, $invoice_data = array()) {
659
+    if (!empty($invoice) && $invoice->is_recurring() && $subscription_item = $invoice->get_recurring(true)) {        
660 660
         $args                          = array();
661 661
         $args['item_id']               = $subscription_item->ID;
662
-        $args['initial_amount']        = wpinv_round_amount( $invoice->get_total() );
663
-        $args['recurring_amount']      = wpinv_round_amount( $invoice->get_recurring_details( 'total' ) );
662
+        $args['initial_amount']        = wpinv_round_amount($invoice->get_total());
663
+        $args['recurring_amount']      = wpinv_round_amount($invoice->get_recurring_details('total'));
664 664
         $args['currency']              = $invoice->get_currency();
665 665
         $args['period']                = $subscription_item->get_recurring_period();
666 666
         $args['interval']              = $subscription_item->get_recurring_interval();
667
-        if ( $subscription_item->has_free_trial() ) {
667
+        if ($subscription_item->has_free_trial()) {
668 668
             $args['trial_period']      = $subscription_item->get_trial_period();
669 669
             $args['trial_interval']    = $subscription_item->get_trial_interval();
670 670
         } else {
@@ -673,25 +673,25 @@  discard block
 block discarded – undo
673 673
         }
674 674
         $args['bill_times']            = (int)$subscription_item->get_recurring_limit();
675 675
         
676
-        $invoice->update_subscription( $args );
676
+        $invoice->update_subscription($args);
677 677
     }
678 678
 }
679
-add_action( 'wpinv_checkout_before_send_to_gateway', 'wpinv_process_before_send_to_gateway', 10, 2 );
679
+add_action('wpinv_checkout_before_send_to_gateway', 'wpinv_process_before_send_to_gateway', 10, 2);
680 680
 
681
-function wpinv_get_post_data( $method = 'request' ) {
681
+function wpinv_get_post_data($method = 'request') {
682 682
     $data       = array();
683 683
     $request    = $_REQUEST;
684 684
     
685
-    if ( $method == 'post' ) {
686
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
685
+    if ($method == 'post') {
686
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
687 687
             return $data;
688 688
         }
689 689
         
690 690
         $request = $_POST;
691 691
     }
692 692
     
693
-    if ( $method == 'get' ) {
694
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
693
+    if ($method == 'get') {
694
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
695 695
             return $data;
696 696
         }
697 697
         
@@ -702,11 +702,11 @@  discard block
 block discarded – undo
702 702
     $post_data = '';
703 703
     
704 704
     // Fallback just in case post_max_size is lower than needed
705
-    if ( ini_get( 'allow_url_fopen' ) ) {
706
-        $post_data = file_get_contents( 'php://input' );
705
+    if (ini_get('allow_url_fopen')) {
706
+        $post_data = file_get_contents('php://input');
707 707
     } else {
708 708
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
709
-        ini_set( 'post_max_size', '12M' );
709
+        ini_set('post_max_size', '12M');
710 710
     }
711 711
     // Start the encoded data collection with notification command
712 712
     $encoded_data = 'cmd=_notify-validate';
@@ -715,58 +715,58 @@  discard block
 block discarded – undo
715 715
     $arg_separator = wpinv_get_php_arg_separator_output();
716 716
 
717 717
     // Verify there is a post_data
718
-    if ( $post_data || strlen( $post_data ) > 0 ) {
718
+    if ($post_data || strlen($post_data) > 0) {
719 719
         // Append the data
720 720
         $encoded_data .= $arg_separator . $post_data;
721 721
     } else {
722 722
         // Check if POST is empty
723
-        if ( empty( $request ) ) {
723
+        if (empty($request)) {
724 724
             // Nothing to do
725 725
             return;
726 726
         } else {
727 727
             // Loop through each POST
728
-            foreach ( $request as $key => $value ) {
728
+            foreach ($request as $key => $value) {
729 729
                 // Encode the value and append the data
730
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
730
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
731 731
             }
732 732
         }
733 733
     }
734 734
 
735 735
     // Convert collected post data to an array
736
-    parse_str( $encoded_data, $data );
736
+    parse_str($encoded_data, $data);
737 737
 
738
-    foreach ( $data as $key => $value ) {
739
-        if ( false !== strpos( $key, 'amp;' ) ) {
740
-            $new_key = str_replace( '&amp;', '&', $key );
741
-            $new_key = str_replace( 'amp;', '&' , $new_key );
738
+    foreach ($data as $key => $value) {
739
+        if (false !== strpos($key, 'amp;')) {
740
+            $new_key = str_replace('&amp;', '&', $key);
741
+            $new_key = str_replace('amp;', '&', $new_key);
742 742
 
743
-            unset( $data[ $key ] );
744
-            $data[ $new_key ] = sanitize_text_field( $value );
743
+            unset($data[$key]);
744
+            $data[$new_key] = sanitize_text_field($value);
745 745
         }
746 746
     }
747 747
     
748 748
     return $data;
749 749
 }
750 750
 
751
-function wpinv_gateway_support_subscription( $gateway ) {
751
+function wpinv_gateway_support_subscription($gateway) {
752 752
     $return = false;
753 753
     
754
-    if ( wpinv_is_gateway_active( $gateway ) ) {
755
-        $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false );
754
+    if (wpinv_is_gateway_active($gateway)) {
755
+        $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false);
756 756
     }
757 757
     
758 758
     return $return;
759 759
 }
760 760
 
761
-function wpinv_payment_gateways_on_cart( $gateways = array() ) {
762
-    if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) {
763
-        foreach ( $gateways as $gateway => $info ) {
764
-            if ( !wpinv_gateway_support_subscription( $gateway ) ) {
765
-                unset( $gateways[$gateway] );
761
+function wpinv_payment_gateways_on_cart($gateways = array()) {
762
+    if (!empty($gateways) && wpinv_cart_has_recurring_item()) {
763
+        foreach ($gateways as $gateway => $info) {
764
+            if (!wpinv_gateway_support_subscription($gateway)) {
765
+                unset($gateways[$gateway]);
766 766
             }
767 767
         }
768 768
     }
769 769
     
770 770
     return $gateways;
771 771
 }
772
-add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 );
773 772
\ No newline at end of file
773
+add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1);
774 774
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -512,7 +512,7 @@
 block discarded – undo
512 512
             
513 513
             $response['success'] = true;
514 514
             $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
515
-        }  else {
515
+        } else {
516 516
             $errors = wpinv_get_errors();
517 517
             if ( !empty( $errors['wpinv-discount-error'] ) ) {
518 518
                 $response['msg'] = $errors['wpinv-discount-error'];
Please login to merge, or discard this patch.
Spacing   +191 added lines, -191 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() {
@@ -76,39 +76,39 @@  discard block
 block discarded – undo
76 76
             'remove_discount' => false,
77 77
         );
78 78
 
79
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
80
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
79
+        foreach ($ajax_events as $ajax_event => $nopriv) {
80
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
81 81
             
82
-            if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) {
83
-                define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 );
82
+            if (!defined('WPI_AJAX_' . strtoupper($nopriv))) {
83
+                define('WPI_AJAX_' . strtoupper($nopriv), 1);
84 84
             }
85 85
 
86
-            if ( $nopriv ) {
87
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
86
+            if ($nopriv) {
87
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
88 88
 
89
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
89
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
90 90
             }
91 91
         }
92 92
     }
93 93
     
94 94
     public static function add_note() {
95
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
95
+        check_ajax_referer('add-invoice-note', '_nonce');
96 96
 
97
-        if ( !current_user_can( 'manage_options' ) ) {
97
+        if (!current_user_can('manage_options')) {
98 98
             die(-1);
99 99
         }
100 100
 
101
-        $post_id   = absint( $_POST['post_id'] );
102
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
103
-        $note_type = sanitize_text_field( $_POST['note_type'] );
101
+        $post_id   = absint($_POST['post_id']);
102
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
103
+        $note_type = sanitize_text_field($_POST['note_type']);
104 104
 
105 105
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
106 106
 
107
-        if ( $post_id > 0 ) {
108
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
107
+        if ($post_id > 0) {
108
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
109 109
 
110
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
111
-                wpinv_get_invoice_note_line_item( $note_id );
110
+            if ($note_id > 0 && !is_wp_error($note_id)) {
111
+                wpinv_get_invoice_note_line_item($note_id);
112 112
             }
113 113
         }
114 114
 
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
     }
117 117
 
118 118
     public static function delete_note() {
119
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
119
+        check_ajax_referer('delete-invoice-note', '_nonce');
120 120
 
121
-        if ( !current_user_can( 'manage_options' ) ) {
121
+        if (!current_user_can('manage_options')) {
122 122
             die(-1);
123 123
         }
124 124
 
125 125
         $note_id = (int)$_POST['note_id'];
126 126
 
127
-        if ( $note_id > 0 ) {
128
-            wp_delete_comment( $note_id, true );
127
+        if ($note_id > 0) {
128
+            wp_delete_comment($note_id, true);
129 129
         }
130 130
 
131 131
         die();
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
     }
139 139
     
140 140
     public static function checkout() {
141
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
142
-            define( 'WPINV_CHECKOUT', true );
141
+        if (!defined('WPINV_CHECKOUT')) {
142
+            define('WPINV_CHECKOUT', true);
143 143
         }
144 144
 
145 145
         wpinv_process_checkout();
@@ -148,53 +148,53 @@  discard block
 block discarded – undo
148 148
     
149 149
     public static function add_invoice_item() {
150 150
         global $wpi_userID, $wpinv_ip_address_country;
151
-        check_ajax_referer( 'invoice-item', '_nonce' );
152
-        if ( !current_user_can( 'manage_options' ) ) {
151
+        check_ajax_referer('invoice-item', '_nonce');
152
+        if (!current_user_can('manage_options')) {
153 153
             die(-1);
154 154
         }
155 155
         
156
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
157
-        $invoice_id = absint( $_POST['invoice_id'] );
156
+        $item_id    = sanitize_text_field($_POST['item_id']);
157
+        $invoice_id = absint($_POST['invoice_id']);
158 158
         
159
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
159
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
160 160
             die();
161 161
         }
162 162
         
163
-        $invoice    = wpinv_get_invoice( $invoice_id );
164
-        if ( empty( $invoice ) ) {
163
+        $invoice = wpinv_get_invoice($invoice_id);
164
+        if (empty($invoice)) {
165 165
             die();
166 166
         }
167 167
         
168
-        if ( $invoice->is_paid() ) {
168
+        if ($invoice->is_paid()) {
169 169
             die(); // Don't allow modify items for paid invoice.
170 170
         }
171 171
         
172
-        if ( !empty( $_POST['user_id'] ) ) {
173
-            $wpi_userID = absint( $_POST['user_id'] ); 
172
+        if (!empty($_POST['user_id'])) {
173
+            $wpi_userID = absint($_POST['user_id']); 
174 174
         }
175 175
 
176
-        $item = new WPInv_Item( $item_id );
177
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
176
+        $item = new WPInv_Item($item_id);
177
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
178 178
             die();
179 179
         }
180 180
         
181 181
         // Validate item before adding to invoice because recurring item must be paid individually.
182
-        if ( !empty( $invoice->cart_details ) ) {
182
+        if (!empty($invoice->cart_details)) {
183 183
             $valid = true;
184 184
             
185
-            if ( $recurring_item = $invoice->get_recurring() ) {
186
-                if ( $recurring_item != $item_id ) {
185
+            if ($recurring_item = $invoice->get_recurring()) {
186
+                if ($recurring_item != $item_id) {
187 187
                     $valid = false;
188 188
                 }
189
-            } else if ( wpinv_is_recurring_item( $item_id ) ) {
189
+            } else if (wpinv_is_recurring_item($item_id)) {
190 190
                 $valid = false;
191 191
             }
192 192
             
193
-            if ( !$valid ) {
193
+            if (!$valid) {
194 194
                 $response               = array();
195 195
                 $response['success']    = false;
196
-                $response['msg']        = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' );
197
-                wp_send_json( $response );
196
+                $response['msg']        = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing');
197
+                wp_send_json($response);
198 198
             }
199 199
         }
200 200
         
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
         
203 203
         $data                   = array();
204 204
         $data['invoice_id']     = $invoice_id;
205
-        $data['cart_discounts'] = $invoice->get_discounts( true );
205
+        $data['cart_discounts'] = $invoice->get_discounts(true);
206 206
         
207
-        wpinv_set_checkout_session( $data );
207
+        wpinv_set_checkout_session($data);
208 208
         
209 209
         $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1;
210 210
 
@@ -219,21 +219,21 @@  discard block
 block discarded – undo
219 219
             'fees'          => array()
220 220
         );
221 221
 
222
-        $invoice->add_item( $item_id, $args );
222
+        $invoice->add_item($item_id, $args);
223 223
         $invoice->save();
224 224
         
225
-        if ( empty( $_POST['country'] ) ) {
225
+        if (empty($_POST['country'])) {
226 226
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
227 227
         }
228
-        if ( empty( $_POST['state'] ) ) {
228
+        if (empty($_POST['state'])) {
229 229
             $_POST['state'] = $invoice->state;
230 230
         }
231 231
          
232
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
233
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
232
+        $invoice->country   = sanitize_text_field($_POST['country']);
233
+        $invoice->state     = sanitize_text_field($_POST['state']);
234 234
         
235
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
236
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
235
+        $invoice->set('country', sanitize_text_field($_POST['country']));
236
+        $invoice->set('state', sanitize_text_field($_POST['state']));
237 237
         
238 238
         $wpinv_ip_address_country = $invoice->country;
239 239
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         
242 242
         $response                       = array();
243 243
         $response['success']            = true;
244
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
244
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
245 245
         $response['data']['subtotal']   = $invoice->get_subtotal();
246 246
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
247 247
         $response['data']['tax']        = $invoice->get_tax();
@@ -253,40 +253,40 @@  discard block
 block discarded – undo
253 253
         
254 254
         wpinv_set_checkout_session($checkout_session);
255 255
         
256
-        wp_send_json( $response );
256
+        wp_send_json($response);
257 257
     }
258 258
     
259 259
     public static function remove_invoice_item() {
260 260
         global $wpi_userID, $wpinv_ip_address_country;
261 261
         
262
-        check_ajax_referer( 'invoice-item', '_nonce' );
263
-        if ( !current_user_can( 'manage_options' ) ) {
262
+        check_ajax_referer('invoice-item', '_nonce');
263
+        if (!current_user_can('manage_options')) {
264 264
             die(-1);
265 265
         }
266 266
         
267
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
268
-        $invoice_id = absint( $_POST['invoice_id'] );
269
-        $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false;
267
+        $item_id    = sanitize_text_field($_POST['item_id']);
268
+        $invoice_id = absint($_POST['invoice_id']);
269
+        $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false;
270 270
         
271
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
271
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
272 272
             die();
273 273
         }
274 274
 
275
-        $invoice    = wpinv_get_invoice( $invoice_id );
276
-        if ( empty( $invoice ) ) {
275
+        $invoice = wpinv_get_invoice($invoice_id);
276
+        if (empty($invoice)) {
277 277
             die();
278 278
         }
279 279
         
280
-        if ( $invoice->is_paid() ) {
280
+        if ($invoice->is_paid()) {
281 281
             die(); // Don't allow modify items for paid invoice.
282 282
         }
283 283
         
284
-        if ( !empty( $_POST['user_id'] ) ) {
285
-            $wpi_userID = absint( $_POST['user_id'] ); 
284
+        if (!empty($_POST['user_id'])) {
285
+            $wpi_userID = absint($_POST['user_id']); 
286 286
         }
287 287
 
288
-        $item       = new WPInv_Item( $item_id );
289
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
288
+        $item = new WPInv_Item($item_id);
289
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
290 290
             die();
291 291
         }
292 292
         
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
         
295 295
         $data                   = array();
296 296
         $data['invoice_id']     = $invoice_id;
297
-        $data['cart_discounts'] = $invoice->get_discounts( true );
297
+        $data['cart_discounts'] = $invoice->get_discounts(true);
298 298
         
299
-        wpinv_set_checkout_session( $data );
299
+        wpinv_set_checkout_session($data);
300 300
 
301 301
         $args = array(
302 302
             'id'         => $item_id,
@@ -304,21 +304,21 @@  discard block
 block discarded – undo
304 304
             'cart_index' => $cart_index
305 305
         );
306 306
 
307
-        $invoice->remove_item( $item_id, $args );
307
+        $invoice->remove_item($item_id, $args);
308 308
         $invoice->save();
309 309
         
310
-        if ( empty( $_POST['country'] ) ) {
310
+        if (empty($_POST['country'])) {
311 311
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
312 312
         }
313
-        if ( empty( $_POST['state'] ) ) {
313
+        if (empty($_POST['state'])) {
314 314
             $_POST['state'] = $invoice->state;
315 315
         }
316 316
          
317
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
318
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
317
+        $invoice->country   = sanitize_text_field($_POST['country']);
318
+        $invoice->state     = sanitize_text_field($_POST['state']);
319 319
         
320
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
321
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
320
+        $invoice->set('country', sanitize_text_field($_POST['country']));
321
+        $invoice->set('state', sanitize_text_field($_POST['state']));
322 322
         
323 323
         $wpinv_ip_address_country = $invoice->country;
324 324
         
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         
327 327
         $response                       = array();
328 328
         $response['success']            = true;
329
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
329
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
330 330
         $response['data']['subtotal']   = $invoice->get_subtotal();
331 331
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
332 332
         $response['data']['tax']        = $invoice->get_tax();
@@ -338,40 +338,40 @@  discard block
 block discarded – undo
338 338
         
339 339
         wpinv_set_checkout_session($checkout_session);
340 340
         
341
-        wp_send_json( $response );
341
+        wp_send_json($response);
342 342
     }
343 343
     
344 344
     public static function create_invoice_item() {
345
-        check_ajax_referer( 'invoice-item', '_nonce' );
346
-        if ( !current_user_can( 'manage_options' ) ) {
345
+        check_ajax_referer('invoice-item', '_nonce');
346
+        if (!current_user_can('manage_options')) {
347 347
             die(-1);
348 348
         }
349 349
         
350
-        $invoice_id = absint( $_POST['invoice_id'] );
350
+        $invoice_id = absint($_POST['invoice_id']);
351 351
 
352 352
         // Find the item
353
-        if ( !is_numeric( $invoice_id ) ) {
353
+        if (!is_numeric($invoice_id)) {
354 354
             die();
355 355
         }        
356 356
         
357
-        $invoice     = wpinv_get_invoice( $invoice_id );
358
-        if ( empty( $invoice ) ) {
357
+        $invoice = wpinv_get_invoice($invoice_id);
358
+        if (empty($invoice)) {
359 359
             die();
360 360
         }
361 361
         
362 362
         // Validate item before adding to invoice because recurring item must be paid individually.
363
-        if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) {
363
+        if (!empty($invoice->cart_details) && $invoice->get_recurring()) {
364 364
             $response               = array();
365 365
             $response['success']    = false;
366
-            $response['msg']        = __( 'You can not add item to invoice because recurring item must be paid individually!', 'invoicing' );
367
-            wp_send_json( $response );
366
+            $response['msg']        = __('You can not add item to invoice because recurring item must be paid individually!', 'invoicing');
367
+            wp_send_json($response);
368 368
         }        
369 369
         
370 370
         $save_item = $_POST['_wpinv_quick'];
371 371
         
372 372
         $meta               = array();
373 373
         $meta['type']       = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom';
374
-        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0;
374
+        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0;
375 375
         $meta['vat_rule']   = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital';
376 376
         $meta['vat_class']  = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard';
377 377
         
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
         $data['meta']           = $meta;
382 382
         
383 383
         $item = new WPInv_Item();
384
-        $item->create( $data );
384
+        $item->create($data);
385 385
         
386
-        if ( !empty( $item ) ) {
386
+        if (!empty($item)) {
387 387
             $_POST['item_id']   = $item->ID;
388 388
             $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1;
389 389
             
@@ -393,15 +393,15 @@  discard block
 block discarded – undo
393 393
     }
394 394
     
395 395
     public static function get_billing_details() {
396
-        check_ajax_referer( 'get-billing-details', '_nonce' );
396
+        check_ajax_referer('get-billing-details', '_nonce');
397 397
         
398
-        if ( !current_user_can( 'manage_options' ) ) {
398
+        if (!current_user_can('manage_options')) {
399 399
             die(-1);
400 400
         }
401 401
 
402 402
         $user_id            = (int)$_POST['user_id'];
403 403
         $billing_details    = wpinv_get_user_address($user_id);
404
-        $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
404
+        $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
405 405
         
406 406
         if (isset($billing_details['user_id'])) {
407 407
             unset($billing_details['user_id']);
@@ -415,20 +415,20 @@  discard block
 block discarded – undo
415 415
         $response['success']                    = true;
416 416
         $response['data']['billing_details']    = $billing_details;
417 417
         
418
-        wp_send_json( $response );
418
+        wp_send_json($response);
419 419
     }
420 420
     
421 421
     public static function admin_recalculate_totals() {
422 422
         global $wpi_userID, $wpinv_ip_address_country;
423 423
         
424
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
425
-        if ( !current_user_can( 'manage_options' ) ) {
424
+        check_ajax_referer('wpinv-nonce', '_nonce');
425
+        if (!current_user_can('manage_options')) {
426 426
             die(-1);
427 427
         }
428 428
         
429
-        $invoice_id = absint( $_POST['invoice_id'] );        
430
-        $invoice    = wpinv_get_invoice( $invoice_id );
431
-        if ( empty( $invoice ) ) {
429
+        $invoice_id = absint($_POST['invoice_id']);        
430
+        $invoice    = wpinv_get_invoice($invoice_id);
431
+        if (empty($invoice)) {
432 432
             die();
433 433
         }
434 434
         
@@ -436,23 +436,23 @@  discard block
 block discarded – undo
436 436
         
437 437
         $data                   = array();
438 438
         $data['invoice_id']     = $invoice_id;
439
-        $data['cart_discounts'] = $invoice->get_discounts( true );
439
+        $data['cart_discounts'] = $invoice->get_discounts(true);
440 440
         
441
-        wpinv_set_checkout_session( $data );
441
+        wpinv_set_checkout_session($data);
442 442
         
443
-        if ( !empty( $_POST['user_id'] ) ) {
444
-            $wpi_userID = absint( $_POST['user_id'] ); 
443
+        if (!empty($_POST['user_id'])) {
444
+            $wpi_userID = absint($_POST['user_id']); 
445 445
         }
446 446
         
447
-        if ( empty( $_POST['country'] ) ) {
447
+        if (empty($_POST['country'])) {
448 448
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
449 449
         }
450 450
             
451
-        $invoice->country = sanitize_text_field( $_POST['country'] );
452
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
453
-        if ( isset( $_POST['state'] ) ) {
454
-            $invoice->state = sanitize_text_field( $_POST['state'] );
455
-            $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
451
+        $invoice->country = sanitize_text_field($_POST['country']);
452
+        $invoice->set('country', sanitize_text_field($_POST['country']));
453
+        if (isset($_POST['state'])) {
454
+            $invoice->state = sanitize_text_field($_POST['state']);
455
+            $invoice->set('state', sanitize_text_field($_POST['state']));
456 456
         }
457 457
         
458 458
         $wpinv_ip_address_country = $invoice->country;
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
         
462 462
         $response                       = array();
463 463
         $response['success']            = true;
464
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
464
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
465 465
         $response['data']['subtotal']   = $invoice->get_subtotal();
466 466
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
467 467
         $response['data']['tax']        = $invoice->get_tax();
@@ -473,25 +473,25 @@  discard block
 block discarded – undo
473 473
         
474 474
         wpinv_set_checkout_session($checkout_session);
475 475
         
476
-        wp_send_json( $response );
476
+        wp_send_json($response);
477 477
     }
478 478
     
479 479
     public static function admin_apply_discount() {
480 480
         global $wpi_userID;
481 481
         
482
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
483
-        if ( !current_user_can( 'manage_options' ) ) {
482
+        check_ajax_referer('wpinv-nonce', '_nonce');
483
+        if (!current_user_can('manage_options')) {
484 484
             die(-1);
485 485
         }
486 486
         
487
-        $invoice_id = absint( $_POST['invoice_id'] );
488
-        $discount_code = sanitize_text_field( $_POST['code'] );
489
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
487
+        $invoice_id = absint($_POST['invoice_id']);
488
+        $discount_code = sanitize_text_field($_POST['code']);
489
+        if (empty($invoice_id) || empty($discount_code)) {
490 490
             die();
491 491
         }
492 492
         
493
-        $invoice = wpinv_get_invoice( $invoice_id );
494
-        if ( empty( $invoice ) || ( !empty( $invoice ) && $invoice->is_paid() ) ) {
493
+        $invoice = wpinv_get_invoice($invoice_id);
494
+        if (empty($invoice) || (!empty($invoice) && $invoice->is_paid())) {
495 495
             die();
496 496
         }
497 497
         
@@ -499,49 +499,49 @@  discard block
 block discarded – undo
499 499
         
500 500
         $data                   = array();
501 501
         $data['invoice_id']     = $invoice_id;
502
-        $data['cart_discounts'] = $invoice->get_discounts( true );
502
+        $data['cart_discounts'] = $invoice->get_discounts(true);
503 503
         
504
-        wpinv_set_checkout_session( $data );
504
+        wpinv_set_checkout_session($data);
505 505
         
506 506
         $response               = array();
507 507
         $response['success']    = false;
508
-        $response['msg']        = __( 'This discount is invalid.', 'invoicing' );
508
+        $response['msg']        = __('This discount is invalid.', 'invoicing');
509 509
         $response['data']['code'] = $discount_code;
510 510
         
511
-        if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) {
512
-            $discounts = wpinv_set_cart_discount( $discount_code );
511
+        if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) {
512
+            $discounts = wpinv_set_cart_discount($discount_code);
513 513
             
514 514
             $response['success'] = true;
515
-            $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
516
-        }  else {
515
+            $response['msg'] = __('Discount has been applied successfully.', 'invoicing');
516
+        } else {
517 517
             $errors = wpinv_get_errors();
518
-            if ( !empty( $errors['wpinv-discount-error'] ) ) {
518
+            if (!empty($errors['wpinv-discount-error'])) {
519 519
                 $response['msg'] = $errors['wpinv-discount-error'];
520 520
             }
521
-            wpinv_unset_error( 'wpinv-discount-error' );
521
+            wpinv_unset_error('wpinv-discount-error');
522 522
         }
523 523
         
524 524
         wpinv_set_checkout_session($checkout_session);
525 525
         
526
-        wp_send_json( $response );
526
+        wp_send_json($response);
527 527
     }
528 528
     
529 529
     public static function admin_remove_discount() {
530 530
         global $wpi_userID;
531 531
         
532
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
533
-        if ( !current_user_can( 'manage_options' ) ) {
532
+        check_ajax_referer('wpinv-nonce', '_nonce');
533
+        if (!current_user_can('manage_options')) {
534 534
             die(-1);
535 535
         }
536 536
         
537
-        $invoice_id = absint( $_POST['invoice_id'] );
538
-        $discount_code = sanitize_text_field( $_POST['code'] );
539
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
537
+        $invoice_id = absint($_POST['invoice_id']);
538
+        $discount_code = sanitize_text_field($_POST['code']);
539
+        if (empty($invoice_id) || empty($discount_code)) {
540 540
             die();
541 541
         }
542 542
         
543
-        $invoice = wpinv_get_invoice( $invoice_id );
544
-        if ( empty( $invoice ) || ( !empty( $invoice ) && $invoice->is_paid() ) ) {
543
+        $invoice = wpinv_get_invoice($invoice_id);
544
+        if (empty($invoice) || (!empty($invoice) && $invoice->is_paid())) {
545 545
             die();
546 546
         }
547 547
         
@@ -549,38 +549,38 @@  discard block
 block discarded – undo
549 549
         
550 550
         $data                   = array();
551 551
         $data['invoice_id']     = $invoice_id;
552
-        $data['cart_discounts'] = $invoice->get_discounts( true );
552
+        $data['cart_discounts'] = $invoice->get_discounts(true);
553 553
         
554
-        wpinv_set_checkout_session( $data );
554
+        wpinv_set_checkout_session($data);
555 555
         
556 556
         $response               = array();
557 557
         $response['success']    = false;
558 558
         $response['msg']        = NULL;
559 559
         
560
-        $discounts  = wpinv_unset_cart_discount( $discount_code );
560
+        $discounts = wpinv_unset_cart_discount($discount_code);
561 561
         $response['success'] = true;
562
-        $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' );
562
+        $response['msg'] = __('Discount has been removed successfully.', 'invoicing');
563 563
         
564 564
         wpinv_set_checkout_session($checkout_session);
565 565
         
566
-        wp_send_json( $response );
566
+        wp_send_json($response);
567 567
     }
568 568
     
569 569
     public static function check_email() {
570
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
571
-        if ( !current_user_can( 'manage_options' ) ) {
570
+        check_ajax_referer('wpinv-nonce', '_nonce');
571
+        if (!current_user_can('manage_options')) {
572 572
             die(-1);
573 573
         }
574 574
         
575
-        $email = sanitize_text_field( $_POST['email'] );
575
+        $email = sanitize_text_field($_POST['email']);
576 576
         
577 577
         $response = array();
578
-        if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) {
578
+        if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) {
579 579
             $user_id            = $user_data->ID;
580 580
             $user_login         = $user_data->user_login;
581 581
             $display_name       = $user_data->display_name ? $user_data->display_name : $user_login;
582 582
             $billing_details    = wpinv_get_user_address($user_id);
583
-            $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
583
+            $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
584 584
             
585 585
             if (isset($billing_details['user_id'])) {
586 586
                 unset($billing_details['user_id']);
@@ -596,31 +596,31 @@  discard block
 block discarded – undo
596 596
             $response['data']['billing_details']    = $billing_details;
597 597
         }
598 598
         
599
-        wp_send_json( $response );
599
+        wp_send_json($response);
600 600
     }
601 601
     
602 602
     public static function run_tool() {
603
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
604
-        if ( !current_user_can( 'manage_options' ) ) {
603
+        check_ajax_referer('wpinv-nonce', '_nonce');
604
+        if (!current_user_can('manage_options')) {
605 605
             die(-1);
606 606
         }
607 607
         
608
-        $tool = sanitize_text_field( $_POST['tool'] );
608
+        $tool = sanitize_text_field($_POST['tool']);
609 609
         
610
-        do_action( 'wpinv_run_tool' );
610
+        do_action('wpinv_run_tool');
611 611
         
612
-        if ( !empty( $tool ) ) {
613
-            do_action( 'wpinv_tool_' . $tool );
612
+        if (!empty($tool)) {
613
+            do_action('wpinv_tool_' . $tool);
614 614
         }
615 615
     }
616 616
     
617 617
     public static function apply_discount() {
618
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
618
+        check_ajax_referer('wpinv-nonce', '_nonce');
619 619
         
620 620
         $response = array();
621 621
         
622
-        if ( isset( $_POST['code'] ) ) {
623
-            $discount_code = sanitize_text_field( $_POST['code'] );
622
+        if (isset($_POST['code'])) {
623
+            $discount_code = sanitize_text_field($_POST['code']);
624 624
 
625 625
             $response['success']        = false;
626 626
             $response['msg']            = '';
@@ -628,14 +628,14 @@  discard block
 block discarded – undo
628 628
             
629 629
             $user = is_user_logged_in() ? get_current_user_id() : '';
630 630
 
631
-            if ( wpinv_is_discount_valid( $discount_code, $user ) ) {
632
-                $discount       = wpinv_get_discount_by_code( $discount_code );
633
-                $discounts      = wpinv_set_cart_discount( $discount_code );
634
-                $amount         = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
635
-                $total          = wpinv_get_cart_total( null, $discounts );
636
-                $cart_totals    = wpinv_recalculate_tax( true );
631
+            if (wpinv_is_discount_valid($discount_code, $user)) {
632
+                $discount       = wpinv_get_discount_by_code($discount_code);
633
+                $discounts      = wpinv_set_cart_discount($discount_code);
634
+                $amount         = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
635
+                $total          = wpinv_get_cart_total(null, $discounts);
636
+                $cart_totals    = wpinv_recalculate_tax(true);
637 637
             
638
-                if ( !empty( $cart_totals ) ) {
638
+                if (!empty($cart_totals)) {
639 639
                     $response['success']        = true;
640 640
                     $response['data']           = $cart_totals;
641 641
                     $response['data']['code']   = $discount_code;
@@ -644,29 +644,29 @@  discard block
 block discarded – undo
644 644
                 }
645 645
             } else {
646 646
                 $errors = wpinv_get_errors();
647
-                $response['msg']  = $errors['wpinv-discount-error'];
648
-                wpinv_unset_error( 'wpinv-discount-error' );
647
+                $response['msg'] = $errors['wpinv-discount-error'];
648
+                wpinv_unset_error('wpinv-discount-error');
649 649
             }
650 650
 
651 651
             // Allow for custom discount code handling
652
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
652
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
653 653
         }
654 654
         
655
-        wp_send_json( $response );
655
+        wp_send_json($response);
656 656
     }
657 657
     
658 658
     public static function remove_discount() {
659
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
659
+        check_ajax_referer('wpinv-nonce', '_nonce');
660 660
         
661 661
         $response = array();
662 662
         
663
-        if ( isset( $_POST['code'] ) ) {
664
-            $discount_code  = sanitize_text_field( $_POST['code'] );
665
-            $discounts      = wpinv_unset_cart_discount( $discount_code );
666
-            $total          = wpinv_get_cart_total( null, $discounts );
667
-            $cart_totals    = wpinv_recalculate_tax( true );
663
+        if (isset($_POST['code'])) {
664
+            $discount_code  = sanitize_text_field($_POST['code']);
665
+            $discounts      = wpinv_unset_cart_discount($discount_code);
666
+            $total          = wpinv_get_cart_total(null, $discounts);
667
+            $cart_totals    = wpinv_recalculate_tax(true);
668 668
             
669
-            if ( !empty( $cart_totals ) ) {
669
+            if (!empty($cart_totals)) {
670 670
                 $response['success']        = true;
671 671
                 $response['data']           = $cart_totals;
672 672
                 $response['data']['code']   = $discount_code;
@@ -675,10 +675,10 @@  discard block
 block discarded – undo
675 675
             }
676 676
             
677 677
             // Allow for custom discount code handling
678
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
678
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
679 679
         }
680 680
         
681
-        wp_send_json( $response );
681
+        wp_send_json($response);
682 682
     }
683 683
 }
684 684
 
Please login to merge, or discard this patch.
includes/wpinv-post-types.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 
141 141
 function wpinv_get_default_labels() {
142 142
     $defaults = array(
143
-       'singular' => __( 'Invoice', 'invoicing' ),
144
-       'plural'   => __( 'Invoices', 'invoicing' )
143
+        'singular' => __( 'Invoice', 'invoicing' ),
144
+        'plural'   => __( 'Invoices', 'invoicing' )
145 145
     );
146 146
     
147 147
     return apply_filters( 'wpinv_default_invoices_name', $defaults );
@@ -160,20 +160,20 @@  discard block
 block discarded – undo
160 160
 }
161 161
 
162 162
 function wpinv_change_default_title( $title ) {
163
-     if ( !is_admin() ) {
163
+        if ( !is_admin() ) {
164 164
         $label = wpinv_get_label_singular();
165 165
         $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
166 166
         return $title;
167
-     }
167
+        }
168 168
 
169
-     $screen = get_current_screen();
169
+        $screen = get_current_screen();
170 170
 
171
-     if ( 'wpi_invoice' == $screen->post_type ) {
171
+        if ( 'wpi_invoice' == $screen->post_type ) {
172 172
         $label = wpinv_get_label_singular();
173 173
         $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
174
-     }
174
+        }
175 175
 
176
-     return $title;
176
+        return $title;
177 177
 }
178 178
 add_filter( 'enter_title_here', 'wpinv_change_default_title' );
179 179
 
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@  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
-add_action( 'init', 'wpinv_register_post_types', 1 );
14
+add_action('init', 'wpinv_register_post_types', 1);
15 15
 function wpinv_register_post_types() {    
16 16
     $labels = array(
17
-        'name'               => _x( 'Invoices', 'post type general name', 'invoicing' ),
18
-        'singular_name'      => _x( 'Invoice', 'post type singular name', 'invoicing' ),
19
-        'menu_name'          => _x( 'Invoices', 'admin menu', 'invoicing' ),
20
-        'name_admin_bar'     => _x( 'Invoice', 'add new on admin bar', 'invoicing' ),
21
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
22
-        'add_new_item'       => __( 'Add New Invoice', 'invoicing' ),
23
-        'new_item'           => __( 'New Invoice', 'invoicing' ),
24
-        'edit_item'          => __( 'Edit Invoice', 'invoicing' ),
25
-        'view_item'          => __( 'View Invoice', 'invoicing' ),
26
-        'all_items'          => __( 'Invoices', 'invoicing' ),
27
-        'search_items'       => __( 'Search Invoices', 'invoicing' ),
28
-        'parent_item_colon'  => __( 'Parent Invoices:', 'invoicing' ),
29
-        'not_found'          => __( 'No invoices found.', 'invoicing' ),
30
-        'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' )
17
+        'name'               => _x('Invoices', 'post type general name', 'invoicing'),
18
+        'singular_name'      => _x('Invoice', 'post type singular name', 'invoicing'),
19
+        'menu_name'          => _x('Invoices', 'admin menu', 'invoicing'),
20
+        'name_admin_bar'     => _x('Invoice', 'add new on admin bar', 'invoicing'),
21
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
22
+        'add_new_item'       => __('Add New Invoice', 'invoicing'),
23
+        'new_item'           => __('New Invoice', 'invoicing'),
24
+        'edit_item'          => __('Edit Invoice', 'invoicing'),
25
+        'view_item'          => __('View Invoice', 'invoicing'),
26
+        'all_items'          => __('Invoices', 'invoicing'),
27
+        'search_items'       => __('Search Invoices', 'invoicing'),
28
+        'parent_item_colon'  => __('Parent Invoices:', 'invoicing'),
29
+        'not_found'          => __('No invoices found.', 'invoicing'),
30
+        'not_found_in_trash' => __('No invoices found in trash.', 'invoicing')
31 31
     );
32
-    $labels = apply_filters( 'wpinv_labels', $labels );
32
+    $labels = apply_filters('wpinv_labels', $labels);
33 33
     
34 34
     $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico';
35
-    $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon );
35
+    $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon);
36 36
 
37 37
     $args = array(
38 38
         'labels'             => $labels,
39
-        'description'        => __( 'This is where invoices are stored.', 'invoicing' ),
39
+        'description'        => __('This is where invoices are stored.', 'invoicing'),
40 40
         'public'             => true,
41 41
         'can_export'         => true,
42 42
         '_builtin'           => false,
@@ -50,68 +50,68 @@  discard block
 block discarded – undo
50 50
         'has_archive'        => false,
51 51
         'hierarchical'       => false,
52 52
         'menu_position'      => null,
53
-        'supports'           => array( 'title', 'author' ),
53
+        'supports'           => array('title', 'author'),
54 54
         'menu_icon'          => $menu_icon,
55 55
     );
56 56
             
57
-    $args = apply_filters( 'wpinv_register_post_type_invoice', $args );
57
+    $args = apply_filters('wpinv_register_post_type_invoice', $args);
58 58
     
59
-    register_post_type( 'wpi_invoice', $args );
59
+    register_post_type('wpi_invoice', $args);
60 60
     
61 61
     $items_labels = array(
62
-        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
63
-        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
64
-        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
65
-        'add_new'            => _x( 'Add New', 'wpi_item', 'invoicing' ),
66
-        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
67
-        'new_item'           => __( 'New Item', 'invoicing' ),
68
-        'edit_item'          => __( 'Edit Item', 'invoicing' ),
69
-        'view_item'          => __( 'View Item', 'invoicing' ),
70
-        'all_items'          => __( 'Items', 'invoicing' ),
71
-        'search_items'       => __( 'Search Items', 'invoicing' ),
62
+        'name'               => _x('Items', 'post type general name', 'invoicing'),
63
+        'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
64
+        'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
65
+        'add_new'            => _x('Add New', 'wpi_item', 'invoicing'),
66
+        'add_new_item'       => __('Add New Item', 'invoicing'),
67
+        'new_item'           => __('New Item', 'invoicing'),
68
+        'edit_item'          => __('Edit Item', 'invoicing'),
69
+        'view_item'          => __('View Item', 'invoicing'),
70
+        'all_items'          => __('Items', 'invoicing'),
71
+        'search_items'       => __('Search Items', 'invoicing'),
72 72
         'parent_item_colon'  => '',
73
-        'not_found'          => __( 'No items found.', 'invoicing' ),
74
-        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
73
+        'not_found'          => __('No items found.', 'invoicing'),
74
+        'not_found_in_trash' => __('No items found in trash.', 'invoicing')
75 75
     );
76
-    $items_labels = apply_filters( 'wpinv_items_labels', $items_labels );
76
+    $items_labels = apply_filters('wpinv_items_labels', $items_labels);
77 77
     
78 78
     $invoice_item_args = array(
79 79
         'labels'                => $items_labels,
80 80
         'public'                => false,
81 81
         'show_ui'               => true,
82 82
         'show_in_menu'          => 'wpinv',
83
-        'supports'              => array( 'title', 'excerpt' ),
83
+        'supports'              => array('title', 'excerpt'),
84 84
         'register_meta_box_cb'  => 'wpinv_register_item_meta_boxes',
85 85
         'rewrite'               => false,
86 86
         'query_var'             => false,
87 87
         'map_meta_cap'          => true,
88 88
         'can_export'            => true,
89 89
     );
90
-    $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args );
90
+    $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args);
91 91
 
92
-    register_post_type( 'wpi_item', $invoice_item_args );
92
+    register_post_type('wpi_item', $invoice_item_args);
93 93
     
94 94
     $labels = array(
95
-        'name'               => _x( 'Discounts', 'post type general name', 'invoicing' ),
96
-        'singular_name'      => _x( 'Discount', 'post type singular name', 'invoicing' ),
97
-        'menu_name'          => _x( 'Discounts', 'admin menu', 'invoicing' ),
98
-        'name_admin_bar'     => _x( 'Discount', 'add new on admin bar', 'invoicing' ),
99
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
100
-        'add_new_item'       => __( 'Add New Discount', 'invoicing' ),
101
-        'new_item'           => __( 'New Discount', 'invoicing' ),
102
-        'edit_item'          => __( 'Edit Discount', 'invoicing' ),
103
-        'view_item'          => __( 'View Discount', 'invoicing' ),
104
-        'all_items'          => __( 'Discounts', 'invoicing' ),
105
-        'search_items'       => __( 'Search Discounts', 'invoicing' ),
106
-        'parent_item_colon'  => __( 'Parent Discounts:', 'invoicing' ),
107
-        'not_found'          => __( 'No discounts found.', 'invoicing' ),
108
-        'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' )
95
+        'name'               => _x('Discounts', 'post type general name', 'invoicing'),
96
+        'singular_name'      => _x('Discount', 'post type singular name', 'invoicing'),
97
+        'menu_name'          => _x('Discounts', 'admin menu', 'invoicing'),
98
+        'name_admin_bar'     => _x('Discount', 'add new on admin bar', 'invoicing'),
99
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
100
+        'add_new_item'       => __('Add New Discount', 'invoicing'),
101
+        'new_item'           => __('New Discount', 'invoicing'),
102
+        'edit_item'          => __('Edit Discount', 'invoicing'),
103
+        'view_item'          => __('View Discount', 'invoicing'),
104
+        'all_items'          => __('Discounts', 'invoicing'),
105
+        'search_items'       => __('Search Discounts', 'invoicing'),
106
+        'parent_item_colon'  => __('Parent Discounts:', 'invoicing'),
107
+        'not_found'          => __('No discounts found.', 'invoicing'),
108
+        'not_found_in_trash' => __('No discounts found in trash.', 'invoicing')
109 109
     );
110
-    $labels = apply_filters( 'wpinv_discounts_labels', $labels );
110
+    $labels = apply_filters('wpinv_discounts_labels', $labels);
111 111
     
112 112
     $args = array(
113 113
         'labels'             => $labels,
114
-        'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
114
+        'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
115 115
         'public'             => false,
116 116
         'can_export'         => true,
117 117
         '_builtin'           => false,
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         'map_meta_cap'       => true,
126 126
         'has_archive'        => false,
127 127
         'hierarchical'       => false,
128
-        'supports'           => array( 'title', 'excerpt' ),
128
+        'supports'           => array('title', 'excerpt'),
129 129
         'register_meta_box_cb'  => 'wpinv_register_discount_meta_boxes',
130 130
         'show_in_nav_menus'  => false,
131 131
         'show_in_admin_bar'  => true,
@@ -133,99 +133,99 @@  discard block
 block discarded – undo
133 133
         'menu_position'      => null,
134 134
     );
135 135
             
136
-    $args = apply_filters( 'wpinv_register_post_type_discount', $args );
136
+    $args = apply_filters('wpinv_register_post_type_discount', $args);
137 137
     
138
-    register_post_type( 'wpi_discount', $args );
138
+    register_post_type('wpi_discount', $args);
139 139
 }
140 140
 
141 141
 function wpinv_get_default_labels() {
142 142
     $defaults = array(
143
-       'singular' => __( 'Invoice', 'invoicing' ),
144
-       'plural'   => __( 'Invoices', 'invoicing' )
143
+       'singular' => __('Invoice', 'invoicing'),
144
+       'plural'   => __('Invoices', 'invoicing')
145 145
     );
146 146
     
147
-    return apply_filters( 'wpinv_default_invoices_name', $defaults );
147
+    return apply_filters('wpinv_default_invoices_name', $defaults);
148 148
 }
149 149
 
150
-function wpinv_get_label_singular( $lowercase = false ) {
150
+function wpinv_get_label_singular($lowercase = false) {
151 151
     $defaults = wpinv_get_default_labels();
152 152
     
153
-    return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
153
+    return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
154 154
 }
155 155
 
156
-function wpinv_get_label_plural( $lowercase = false ) {
156
+function wpinv_get_label_plural($lowercase = false) {
157 157
     $defaults = wpinv_get_default_labels();
158 158
     
159
-    return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
159
+    return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
160 160
 }
161 161
 
162
-function wpinv_change_default_title( $title ) {
163
-     if ( !is_admin() ) {
162
+function wpinv_change_default_title($title) {
163
+     if (!is_admin()) {
164 164
         $label = wpinv_get_label_singular();
165
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
165
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
166 166
         return $title;
167 167
      }
168 168
 
169 169
      $screen = get_current_screen();
170 170
 
171
-     if ( 'wpi_invoice' == $screen->post_type ) {
171
+     if ('wpi_invoice' == $screen->post_type) {
172 172
         $label = wpinv_get_label_singular();
173
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
173
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
174 174
      }
175 175
 
176 176
      return $title;
177 177
 }
178
-add_filter( 'enter_title_here', 'wpinv_change_default_title' );
178
+add_filter('enter_title_here', 'wpinv_change_default_title');
179 179
 
180 180
 function wpinv_register_post_status() {
181
-    register_post_status( 'wpi-processing', array(
182
-        'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
181
+    register_post_status('wpi-processing', array(
182
+        'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
183 183
         'public'                    => true,
184 184
         'exclude_from_search'       => true,
185 185
         'show_in_admin_all_list'    => true,
186 186
         'show_in_admin_status_list' => true,
187
-        'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
188
-    ) );
189
-    register_post_status( 'wpi-onhold', array(
190
-        'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
187
+        'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
188
+    ));
189
+    register_post_status('wpi-onhold', array(
190
+        'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
191 191
         'public'                    => true,
192 192
         'exclude_from_search'       => true,
193 193
         'show_in_admin_all_list'    => true,
194 194
         'show_in_admin_status_list' => true,
195
-        'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
196
-    ) );
197
-    register_post_status( 'wpi-cancelled', array(
198
-        'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
195
+        'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
196
+    ));
197
+    register_post_status('wpi-cancelled', array(
198
+        'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
199 199
         'public'                    => true,
200 200
         'exclude_from_search'       => true,
201 201
         'show_in_admin_all_list'    => true,
202 202
         'show_in_admin_status_list' => true,
203
-        'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
204
-    ) );
205
-    register_post_status( 'wpi-refunded', array(
206
-        'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
203
+        'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
204
+    ));
205
+    register_post_status('wpi-refunded', array(
206
+        'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
207 207
         'public'                    => true,
208 208
         'exclude_from_search'       => true,
209 209
         'show_in_admin_all_list'    => true,
210 210
         'show_in_admin_status_list' => true,
211
-        'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
212
-    ) );
213
-    register_post_status( 'wpi-failed', array(
214
-        'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
211
+        'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
212
+    ));
213
+    register_post_status('wpi-failed', array(
214
+        'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
215 215
         'public'                    => true,
216 216
         'exclude_from_search'       => true,
217 217
         'show_in_admin_all_list'    => true,
218 218
         'show_in_admin_status_list' => true,
219
-        'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
220
-    ) );
221
-    register_post_status( 'wpi-renewal', array(
222
-        'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
219
+        'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
220
+    ));
221
+    register_post_status('wpi-renewal', array(
222
+        'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
223 223
         'public'                    => true,
224 224
         'exclude_from_search'       => true,
225 225
         'show_in_admin_all_list'    => true,
226 226
         'show_in_admin_status_list' => true,
227
-        'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
228
-    ) );
227
+        'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
228
+    ));
229 229
 }
230
-add_action( 'init', 'wpinv_register_post_status', 10 );
230
+add_action('init', 'wpinv_register_post_status', 10);
231 231
 
Please login to merge, or discard this patch.
includes/class-wpinv-reports.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -166,13 +166,13 @@
 block discarded – undo
166 166
             $is_writeable   = $is_dir && is_writeable( $this->export_dir );
167 167
             
168 168
             if ( $is_dir && $is_writeable ) {
169
-               return true;
169
+                return true;
170 170
             } else if ( $is_dir && !$is_writeable ) {
171
-               if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
172
-                   return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
173
-               }
171
+                if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
172
+                    return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
173
+                }
174 174
                
175
-               return true;
175
+                return true;
176 176
             } else {
177 177
                 if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) {
178 178
                     return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir );
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -21,68 +21,68 @@  discard block
 block discarded – undo
21 21
     public function init() {
22 22
         global $wp_filesystem;
23 23
 
24
-        if ( empty( $wp_filesystem ) ) {
25
-            require_once( ABSPATH . '/wp-admin/includes/file.php' );
24
+        if (empty($wp_filesystem)) {
25
+            require_once(ABSPATH . '/wp-admin/includes/file.php');
26 26
             WP_Filesystem();
27 27
             global $wp_filesystem;
28 28
         }
29 29
         $this->wp_filesystem    = $wp_filesystem;
30 30
         
31 31
         $this->export_dir       = $this->export_location();
32
-        $this->export_url       = $this->export_location( true );
32
+        $this->export_url       = $this->export_location(true);
33 33
         $this->export           = 'invoicing';
34 34
         $this->filetype         = 'csv';
35 35
         $this->per_page         = 20;
36 36
         
37
-        do_action( 'wpinv_class_reports_init', $this );
37
+        do_action('wpinv_class_reports_init', $this);
38 38
     }
39 39
     
40 40
     public function includes() {
41
-        do_action( 'wpinv_class_reports_includes', $this );
41
+        do_action('wpinv_class_reports_includes', $this);
42 42
     }
43 43
     
44 44
     public function actions() {
45
-        if ( is_admin() ) {
46
-            add_action( 'admin_menu', array( $this, 'add_submenu' ), 10 );
47
-            add_action( 'wpinv_reports_tab_export', array( $this, 'export' ) );
48
-            add_action( 'wp_ajax_wpinv_ajax_export', array( $this, 'ajax_export' ) );
45
+        if (is_admin()) {
46
+            add_action('admin_menu', array($this, 'add_submenu'), 10);
47
+            add_action('wpinv_reports_tab_export', array($this, 'export'));
48
+            add_action('wp_ajax_wpinv_ajax_export', array($this, 'ajax_export'));
49 49
             
50 50
             // Export Invoices.
51
-            add_action( 'wpinv_export_set_params_invoices', array( $this, 'set_invoices_export' ) );
52
-            add_filter( 'wpinv_export_get_columns_invoices', array( $this, 'get_invoices_columns' ) );
53
-            add_filter( 'wpinv_export_get_data_invoices', array( $this, 'get_invoices_data' ) );
54
-            add_filter( 'wpinv_get_export_status_invoices', array( $this, 'invoices_export_status' ) );
51
+            add_action('wpinv_export_set_params_invoices', array($this, 'set_invoices_export'));
52
+            add_filter('wpinv_export_get_columns_invoices', array($this, 'get_invoices_columns'));
53
+            add_filter('wpinv_export_get_data_invoices', array($this, 'get_invoices_data'));
54
+            add_filter('wpinv_get_export_status_invoices', array($this, 'invoices_export_status'));
55 55
         }
56
-        do_action( 'wpinv_class_reports_actions', $this );
56
+        do_action('wpinv_class_reports_actions', $this);
57 57
     }
58 58
     
59 59
     public function add_submenu() {
60 60
         global $wpi_reports_page;
61
-        $wpi_reports_page = add_submenu_page( 'wpinv', __( 'Reports', 'invoicing' ), __( 'Reports', 'invoicing' ), 'manage_options', 'wpinv-reports', array( $this, 'reports_page' ) );
61
+        $wpi_reports_page = add_submenu_page('wpinv', __('Reports', 'invoicing'), __('Reports', 'invoicing'), 'manage_options', 'wpinv-reports', array($this, 'reports_page'));
62 62
     }
63 63
     
64 64
     public function reports_page() {
65
-        if ( !wp_script_is( 'postbox', 'enqueued' ) ) {
66
-            wp_enqueue_script( 'postbox' );
65
+        if (!wp_script_is('postbox', 'enqueued')) {
66
+            wp_enqueue_script('postbox');
67 67
         }
68
-        if ( !wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
69
-            wp_enqueue_script( 'jquery-ui-datepicker' );
68
+        if (!wp_script_is('jquery-ui-datepicker', 'enqueued')) {
69
+            wp_enqueue_script('jquery-ui-datepicker');
70 70
         }
71 71
         
72
-        $current_page = admin_url( 'admin.php?page=wpinv-reports' );
73
-        $active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'export';
72
+        $current_page = admin_url('admin.php?page=wpinv-reports');
73
+        $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'export';
74 74
         ?>
75 75
         <div class="wrap wpi-reports-wrap">
76
-            <h1><?php echo esc_html( __( 'Reports', 'invoicing' ) ); ?></h1>
76
+            <h1><?php echo esc_html(__('Reports', 'invoicing')); ?></h1>
77 77
             <h2 class="nav-tab-wrapper wp-clearfix">
78
-                <a href="<?php echo add_query_arg( array( 'tab' => 'export', 'settings-updated' => false ), $current_page ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Export', 'invoicing' ); ?></a>
79
-                <?php do_action( 'wpinv_reports_page_tabs' ); ;?>
78
+                <a href="<?php echo add_query_arg(array('tab' => 'export', 'settings-updated' => false), $current_page); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php _e('Export', 'invoicing'); ?></a>
79
+                <?php do_action('wpinv_reports_page_tabs'); ;?>
80 80
             </h2>
81 81
             <div class="wpi-reports-content wpi-reports-<?php echo $active_tab; ?>">
82 82
             <?php
83
-                do_action( 'wpinv_reports_page_top' );
84
-                do_action( 'wpinv_reports_tab_' . $active_tab );
85
-                do_action( 'wpinv_reports_page_bottom' );
83
+                do_action('wpinv_reports_page_top');
84
+                do_action('wpinv_reports_tab_' . $active_tab);
85
+                do_action('wpinv_reports_page_bottom');
86 86
             ?>
87 87
         </div>
88 88
         <?php
@@ -90,97 +90,97 @@  discard block
 block discarded – undo
90 90
     
91 91
     public function export() {
92 92
         $statuses = wpinv_get_invoice_statuses();
93
-        $statuses = array_merge( array( 'any' => __( 'All Statuses', 'invoicing' ) ), $statuses );
93
+        $statuses = array_merge(array('any' => __('All Statuses', 'invoicing')), $statuses);
94 94
         ?>
95 95
         <div class="metabox-holder">
96 96
             <div id="post-body">
97 97
                 <div id="post-body-content">
98
-                    <?php do_action( 'wpinv_reports_tab_export_content_top' ); ?>
98
+                    <?php do_action('wpinv_reports_tab_export_content_top'); ?>
99 99
                     
100 100
                     <div class="postbox wpi-export-invoices">
101
-                        <h2 class="hndle ui-sortabled-handle"><span><?php _e( 'Invoices','invoicing' ); ?></span></h2>
101
+                        <h2 class="hndle ui-sortabled-handle"><span><?php _e('Invoices', 'invoicing'); ?></span></h2>
102 102
                         <div class="inside">
103
-                            <p><?php _e( 'Download a CSV of all payment invoices.', 'invoicing' ); ?></p>
103
+                            <p><?php _e('Download a CSV of all payment invoices.', 'invoicing'); ?></p>
104 104
                             <form id="wpi-export-invoices" class="wpi-export-form" method="post">
105
-                                <?php echo wpinv_html_date_field( array( 
105
+                                <?php echo wpinv_html_date_field(array( 
106 106
                                     'id' => 'wpi_export_from_date', 
107 107
                                     'name' => 'from_date',
108 108
                                     'data' => array(
109 109
                                         'dateFormat' => 'yy-mm-dd'
110 110
                                     ),
111
-                                    'placeholder' => __( 'From date', 'invoicing' ) )
111
+                                    'placeholder' => __('From date', 'invoicing') )
112 112
                                 ); ?>
113
-                                <?php echo wpinv_html_date_field( array( 
113
+                                <?php echo wpinv_html_date_field(array( 
114 114
                                     'id' => 'wpi_export_to_date',
115 115
                                     'name' => 'to_date',
116 116
                                     'data' => array(
117 117
                                         'dateFormat' => 'yy-mm-dd'
118 118
                                     ),
119
-                                    'placeholder' => __( 'To date', 'invoicing' ) )
119
+                                    'placeholder' => __('To date', 'invoicing') )
120 120
                                 ); ?>
121 121
                                 <span id="wpinv-status-wrap">
122
-                                <?php echo wpinv_html_select( array(
122
+                                <?php echo wpinv_html_select(array(
123 123
                                     'options'          => $statuses,
124 124
                                     'name'             => 'status',
125 125
                                     'id'               => 'wpi_export_status',
126 126
                                     'show_option_all'  => false,
127 127
                                     'show_option_none' => false,
128 128
                                     'class'            => '',
129
-                                ) ); ?>
130
-                                <?php wp_nonce_field( 'wpi_ajax_export', 'wpi_ajax_export' ); ?>
129
+                                )); ?>
130
+                                <?php wp_nonce_field('wpi_ajax_export', 'wpi_ajax_export'); ?>
131 131
                                 </span>
132 132
                                 <span id="wpinv-submit-wrap">
133 133
                                     <input type="hidden" value="invoices" name="export" />
134
-                                    <input type="submit" value="<?php _e( 'Generate CSV', 'invoicing' ); ?>" class="button-primary" />
134
+                                    <input type="submit" value="<?php _e('Generate CSV', 'invoicing'); ?>" class="button-primary" />
135 135
                                 </span>
136 136
                             </form>
137 137
                         </div>
138 138
                     </div>
139 139
                     
140
-                    <?php do_action( 'wpinv_reports_tab_export_content_bottom' ); ?>
140
+                    <?php do_action('wpinv_reports_tab_export_content_bottom'); ?>
141 141
                 </div>
142 142
             </div>
143 143
         </div>
144 144
         <?php
145 145
     }
146 146
     
147
-    public function export_location( $relative = false ) {
147
+    public function export_location($relative = false) {
148 148
         $upload_dir         = wp_upload_dir();
149
-        $export_location    = $relative ? trailingslashit( $upload_dir['baseurl'] ) . 'cache' : trailingslashit( $upload_dir['basedir'] ) . 'cache';
150
-        $export_location    = apply_filters( 'wpinv_export_location', $export_location, $relative );
149
+        $export_location    = $relative ? trailingslashit($upload_dir['baseurl']) . 'cache' : trailingslashit($upload_dir['basedir']) . 'cache';
150
+        $export_location    = apply_filters('wpinv_export_location', $export_location, $relative);
151 151
         
152
-        return trailingslashit( $export_location );
152
+        return trailingslashit($export_location);
153 153
     }
154 154
     
155 155
     public function check_export_location() {
156 156
         try {
157
-            if ( empty( $this->wp_filesystem ) ) {
158
-                return __( 'Filesystem ERROR: Could not access filesystem.', 'invoicing' );
157
+            if (empty($this->wp_filesystem)) {
158
+                return __('Filesystem ERROR: Could not access filesystem.', 'invoicing');
159 159
             }
160 160
 
161
-            if ( is_wp_error( $this->wp_filesystem ) ) {
162
-                return __( 'Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing' );
161
+            if (is_wp_error($this->wp_filesystem)) {
162
+                return __('Filesystem ERROR: ' . $this->wp_filesystem->get_error_message(), 'invoicing');
163 163
             }
164 164
         
165
-            $is_dir         = $this->wp_filesystem->is_dir( $this->export_dir );
166
-            $is_writeable   = $is_dir && is_writeable( $this->export_dir );
165
+            $is_dir         = $this->wp_filesystem->is_dir($this->export_dir);
166
+            $is_writeable   = $is_dir && is_writeable($this->export_dir);
167 167
             
168
-            if ( $is_dir && $is_writeable ) {
168
+            if ($is_dir && $is_writeable) {
169 169
                return true;
170
-            } else if ( $is_dir && !$is_writeable ) {
171
-               if ( !$this->wp_filesystem->chmod( $this->export_dir, FS_CHMOD_DIR ) ) {
172
-                   return wp_sprintf( __( 'Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing' ), $this->export_dir );
170
+            } else if ($is_dir && !$is_writeable) {
171
+               if (!$this->wp_filesystem->chmod($this->export_dir, FS_CHMOD_DIR)) {
172
+                   return wp_sprintf(__('Filesystem ERROR: Export location %s is not writable, check your file permissions.', 'invoicing'), $this->export_dir);
173 173
                }
174 174
                
175 175
                return true;
176 176
             } else {
177
-                if ( !$this->wp_filesystem->mkdir( $this->export_dir, FS_CHMOD_DIR ) ) {
178
-                    return wp_sprintf( __( 'Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing' ), $this->export_dir );
177
+                if (!$this->wp_filesystem->mkdir($this->export_dir, FS_CHMOD_DIR)) {
178
+                    return wp_sprintf(__('Filesystem ERROR: Could not create directory %s. This is usually due to inconsistent file permissions.', 'invoicing'), $this->export_dir);
179 179
                 }
180 180
                 
181 181
                 return true;
182 182
             }
183
-        } catch ( Exception $e ) {
183
+        } catch (Exception $e) {
184 184
             return $e->getMessage();
185 185
         }
186 186
     }
@@ -188,130 +188,130 @@  discard block
 block discarded – undo
188 188
     public function ajax_export() {
189 189
         $response               = array();
190 190
         $response['success']    = false;
191
-        $response['msg']        = __( 'Invalid export request found.', 'invoicing' );
191
+        $response['msg']        = __('Invalid export request found.', 'invoicing');
192 192
         
193
-        if ( empty( $_POST['data'] ) || !current_user_can( 'manage_options' ) ) {
194
-            wp_send_json( $response );
193
+        if (empty($_POST['data']) || !current_user_can('manage_options')) {
194
+            wp_send_json($response);
195 195
         }
196 196
 
197
-        parse_str( $_POST['data'], $data );
197
+        parse_str($_POST['data'], $data);
198 198
         
199
-        $data['step']   = !empty( $_POST['step'] ) ? absint( $_POST['step'] ) : 1;
199
+        $data['step'] = !empty($_POST['step']) ? absint($_POST['step']) : 1;
200 200
 
201 201
         $_REQUEST = (array)$data;
202
-        if ( !( !empty( $_REQUEST['wpi_ajax_export'] ) && wp_verify_nonce( $_REQUEST['wpi_ajax_export'], 'wpi_ajax_export' ) ) ) {
203
-            $response['msg']    = __( 'Security check failed.', 'invoicing' );
204
-            wp_send_json( $response );
202
+        if (!(!empty($_REQUEST['wpi_ajax_export']) && wp_verify_nonce($_REQUEST['wpi_ajax_export'], 'wpi_ajax_export'))) {
203
+            $response['msg'] = __('Security check failed.', 'invoicing');
204
+            wp_send_json($response);
205 205
         }
206 206
         
207
-        if ( ( $error = $this->check_export_location( true ) ) !== true ) {
208
-            $response['msg'] = __( 'Filesystem ERROR: ' . $error, 'invoicing' );
209
-            wp_send_json( $response );
207
+        if (($error = $this->check_export_location(true)) !== true) {
208
+            $response['msg'] = __('Filesystem ERROR: ' . $error, 'invoicing');
209
+            wp_send_json($response);
210 210
         }
211 211
                         
212
-        $this->set_export_params( $_REQUEST );
212
+        $this->set_export_params($_REQUEST);
213 213
         
214 214
         $return = $this->process_export_step();
215 215
         $done   = $this->get_export_status();
216 216
         
217
-        if ( $return ) {
217
+        if ($return) {
218 218
             $this->step += 1;
219 219
             
220 220
             $response['success']    = true;
221 221
             $response['msg']        = '';
222 222
             
223
-            if ( $done >= 100 ) {
223
+            if ($done >= 100) {
224 224
                 $this->step     = 'done';
225
-                $new_filename   = 'wpi-' . $this->export . '-' . date( 'y-m-d-H-i' ) . '.' . $this->filetype;
225
+                $new_filename   = 'wpi-' . $this->export . '-' . date('y-m-d-H-i') . '.' . $this->filetype;
226 226
                 $new_file       = $this->export_dir . $new_filename;
227 227
                 
228
-                if ( file_exists( $this->file ) ) {
229
-                    $this->wp_filesystem->move( $this->file, $new_file, true );
228
+                if (file_exists($this->file)) {
229
+                    $this->wp_filesystem->move($this->file, $new_file, true);
230 230
                 }
231 231
                 
232
-                if ( file_exists( $new_file ) ) {
233
-                    $response['data']['file'] = array( 'u' => $this->export_url . $new_filename, 's' => size_format( filesize( $new_file ), 2 ) );
232
+                if (file_exists($new_file)) {
233
+                    $response['data']['file'] = array('u' => $this->export_url . $new_filename, 's' => size_format(filesize($new_file), 2));
234 234
                 }
235 235
             }
236 236
             
237 237
             $response['data']['step']   = $this->step;
238 238
             $response['data']['done']   = $done;
239 239
         } else {
240
-            $response['msg']    = __( 'No data found for export.', 'invoicing' );
240
+            $response['msg'] = __('No data found for export.', 'invoicing');
241 241
         }
242 242
 
243
-        wp_send_json( $response );
243
+        wp_send_json($response);
244 244
     }
245 245
     
246
-    public function set_export_params( $request ) {
246
+    public function set_export_params($request) {
247 247
         $this->empty    = false;
248
-        $this->step     = !empty( $request['step'] ) ? absint( $request['step'] ) : 1;
249
-        $this->export   = !empty( $request['export'] ) ? $request['export'] : $this->export;
248
+        $this->step     = !empty($request['step']) ? absint($request['step']) : 1;
249
+        $this->export   = !empty($request['export']) ? $request['export'] : $this->export;
250 250
         $this->filename = 'wpi-' . $this->export . '-' . $request['wpi_ajax_export'] . '.' . $this->filetype;
251 251
         $this->file     = $this->export_dir . $this->filename;
252 252
         
253
-        do_action( 'wpinv_export_set_params_' . $this->export, $request );
253
+        do_action('wpinv_export_set_params_' . $this->export, $request);
254 254
     }
255 255
     
256 256
     public function get_columns() {
257 257
         $columns = array(
258
-            'id'   => __( 'ID',   'invoicing' ),
259
-            'date' => __( 'Date', 'invoicing' )
258
+            'id'   => __('ID', 'invoicing'),
259
+            'date' => __('Date', 'invoicing')
260 260
         );
261 261
         
262
-        return apply_filters( 'wpinv_export_get_columns_' . $this->export, $columns );
262
+        return apply_filters('wpinv_export_get_columns_' . $this->export, $columns);
263 263
     }
264 264
     
265 265
     protected function get_export_file() {
266 266
         $file = '';
267 267
 
268
-        if ( $this->wp_filesystem->exists( $this->file ) ) {
269
-            $file = $this->wp_filesystem->get_contents( $this->file );
268
+        if ($this->wp_filesystem->exists($this->file)) {
269
+            $file = $this->wp_filesystem->get_contents($this->file);
270 270
         } else {
271
-            $this->wp_filesystem->put_contents( $this->file, '' );
271
+            $this->wp_filesystem->put_contents($this->file, '');
272 272
         }
273 273
 
274 274
         return $file;
275 275
     }
276 276
     
277
-    protected function attach_export_data( $data = '' ) {
278
-        $filedata   = $this->get_export_file();
279
-        $filedata   .= $data;
277
+    protected function attach_export_data($data = '') {
278
+        $filedata = $this->get_export_file();
279
+        $filedata .= $data;
280 280
         
281
-        $this->wp_filesystem->put_contents( $this->file, $filedata );
281
+        $this->wp_filesystem->put_contents($this->file, $filedata);
282 282
 
283
-        $rows       = file( $this->file, FILE_SKIP_EMPTY_LINES );
283
+        $rows       = file($this->file, FILE_SKIP_EMPTY_LINES);
284 284
         $columns    = $this->get_columns();
285
-        $columns    = empty( $columns ) ? 0 : 1;
285
+        $columns    = empty($columns) ? 0 : 1;
286 286
 
287
-        $this->empty = count( $rows ) == $columns ? true : false;
287
+        $this->empty = count($rows) == $columns ? true : false;
288 288
     }
289 289
     
290 290
     public function print_columns() {
291 291
         $column_data    = '';
292 292
         $columns        = $this->get_columns();
293 293
         $i              = 1;
294
-        foreach( $columns as $key => $column ) {
295
-            $column_data .= '"' . addslashes( $column ) . '"';
296
-            $column_data .= $i == count( $columns ) ? '' : ',';
294
+        foreach ($columns as $key => $column) {
295
+            $column_data .= '"' . addslashes($column) . '"';
296
+            $column_data .= $i == count($columns) ? '' : ',';
297 297
             $i++;
298 298
         }
299 299
         $column_data .= "\r\n";
300 300
 
301
-        $this->attach_export_data( $column_data );
301
+        $this->attach_export_data($column_data);
302 302
 
303 303
         return $column_data;
304 304
     }
305 305
     
306 306
     public function process_export_step() {
307
-        if ( $this->step < 2 ) {
308
-            @unlink( $this->file );
307
+        if ($this->step < 2) {
308
+            @unlink($this->file);
309 309
             $this->print_columns();
310 310
         }
311 311
         
312 312
         $return = $this->print_rows();
313 313
         
314
-        if ( $return ) {
314
+        if ($return) {
315 315
             return true;
316 316
         } else {
317 317
             return false;
@@ -320,23 +320,23 @@  discard block
 block discarded – undo
320 320
     
321 321
     public function get_export_status() {
322 322
         $status = 100;
323
-        return apply_filters( 'wpinv_get_export_status_' . $this->export, $status );
323
+        return apply_filters('wpinv_get_export_status_' . $this->export, $status);
324 324
     }
325 325
     
326 326
     public function get_export_data() {
327 327
         $data = array(
328 328
             0 => array(
329 329
                 'id'   => '',
330
-                'data' => date( 'F j, Y' )
330
+                'data' => date('F j, Y')
331 331
             ),
332 332
             1 => array(
333 333
                 'id'   => '',
334
-                'data' => date( 'F j, Y' )
334
+                'data' => date('F j, Y')
335 335
             )
336 336
         );
337 337
 
338
-        $data = apply_filters( 'wpinv_export_get_data', $data );
339
-        $data = apply_filters( 'wpinv_export_get_data_' . $this->export, $data );
338
+        $data = apply_filters('wpinv_export_get_data', $data);
339
+        $data = apply_filters('wpinv_export_get_data_' . $this->export, $data);
340 340
 
341 341
         return $data;
342 342
     }
@@ -346,20 +346,20 @@  discard block
 block discarded – undo
346 346
         $data       = $this->get_export_data();
347 347
         $columns    = $this->get_columns();
348 348
 
349
-        if ( $data ) {
350
-            foreach ( $data as $row ) {
349
+        if ($data) {
350
+            foreach ($data as $row) {
351 351
                 $i = 1;
352
-                foreach ( $row as $key => $column ) {
353
-                    if ( array_key_exists( $key, $columns ) ) {
354
-                        $row_data .= '"' . addslashes( preg_replace( "/\"/","'", $column ) ) . '"';
355
-                        $row_data .= $i == count( $columns ) ? '' : ',';
352
+                foreach ($row as $key => $column) {
353
+                    if (array_key_exists($key, $columns)) {
354
+                        $row_data .= '"' . addslashes(preg_replace("/\"/", "'", $column)) . '"';
355
+                        $row_data .= $i == count($columns) ? '' : ',';
356 356
                         $i++;
357 357
                     }
358 358
                 }
359 359
                 $row_data .= "\r\n";
360 360
             }
361 361
 
362
-            $this->attach_export_data( $row_data );
362
+            $this->attach_export_data($row_data);
363 363
 
364 364
             return $row_data;
365 365
         }
@@ -368,46 +368,46 @@  discard block
 block discarded – undo
368 368
     }
369 369
     
370 370
     // Export Invoices.
371
-    public function set_invoices_export( $request ) {
372
-        $this->from_date    = isset( $request['from_date'] ) ? sanitize_text_field( $request['from_date'] ) : '';
373
-        $this->to_date      = isset( $request['to_date'] ) ? sanitize_text_field( $request['to_date'] ) : '';
374
-        $this->status       = isset( $request['status'] ) ? sanitize_text_field( $request['status'] ) : 'publish';
371
+    public function set_invoices_export($request) {
372
+        $this->from_date    = isset($request['from_date']) ? sanitize_text_field($request['from_date']) : '';
373
+        $this->to_date      = isset($request['to_date']) ? sanitize_text_field($request['to_date']) : '';
374
+        $this->status       = isset($request['status']) ? sanitize_text_field($request['status']) : 'publish';
375 375
     }
376 376
     
377
-    public function get_invoices_columns( $columns = array() ) {
377
+    public function get_invoices_columns($columns = array()) {
378 378
         $columns = array(
379
-            'id'            => __( 'ID',   'invoicing' ),
380
-            'number'        => __( 'Number',   'invoicing' ),
381
-            'date'          => __( 'Date', 'invoicing' ),
382
-            'amount'        => __( 'Amount', 'invoicing' ),
383
-            'status_nicename'  => __( 'Status Nicename', 'invoicing' ),
384
-            'status'        => __( 'Status', 'invoicing' ),
385
-            'tax'           => __( 'Tax', 'invoicing' ),
386
-            'discount'      => __( 'Discount', 'invoicing' ),
387
-            'user_id'       => __( 'User ID', 'invoicing' ),
388
-            'email'         => __( 'Email', 'invoicing' ),
389
-            'first_name'    => __( 'First Name', 'invoicing' ),
390
-            'last_name'     => __( 'Last Name', 'invoicing' ),
391
-            'address'       => __( 'Address', 'invoicing' ),
392
-            'city'          => __( 'City', 'invoicing' ),
393
-            'state'         => __( 'State', 'invoicing' ),
394
-            'country'       => __( 'Country', 'invoicing' ),
395
-            'zip'           => __( 'Zipcode', 'invoicing' ),
396
-            'phone'         => __( 'Phone', 'invoicing' ),
397
-            'company'       => __( 'Company', 'invoicing' ),
398
-            'vat_number'    => __( 'Vat Number', 'invoicing' ),
399
-            'ip'            => __( 'IP', 'invoicing' ),
400
-            'gateway'       => __( 'Gateway', 'invoicing' ),
401
-            'gateway_nicename'       => __( 'Gateway Nicename', 'invoicing' ),
402
-            'transaction_id'=> __( 'Transaction ID', 'invoicing' ),
403
-            'currency'      => __( 'Currency', 'invoicing' ),
404
-            'due_date'      => __( 'Due Date', 'invoicing' ),
379
+            'id'            => __('ID', 'invoicing'),
380
+            'number'        => __('Number', 'invoicing'),
381
+            'date'          => __('Date', 'invoicing'),
382
+            'amount'        => __('Amount', 'invoicing'),
383
+            'status_nicename'  => __('Status Nicename', 'invoicing'),
384
+            'status'        => __('Status', 'invoicing'),
385
+            'tax'           => __('Tax', 'invoicing'),
386
+            'discount'      => __('Discount', 'invoicing'),
387
+            'user_id'       => __('User ID', 'invoicing'),
388
+            'email'         => __('Email', 'invoicing'),
389
+            'first_name'    => __('First Name', 'invoicing'),
390
+            'last_name'     => __('Last Name', 'invoicing'),
391
+            'address'       => __('Address', 'invoicing'),
392
+            'city'          => __('City', 'invoicing'),
393
+            'state'         => __('State', 'invoicing'),
394
+            'country'       => __('Country', 'invoicing'),
395
+            'zip'           => __('Zipcode', 'invoicing'),
396
+            'phone'         => __('Phone', 'invoicing'),
397
+            'company'       => __('Company', 'invoicing'),
398
+            'vat_number'    => __('Vat Number', 'invoicing'),
399
+            'ip'            => __('IP', 'invoicing'),
400
+            'gateway'       => __('Gateway', 'invoicing'),
401
+            'gateway_nicename'       => __('Gateway Nicename', 'invoicing'),
402
+            'transaction_id'=> __('Transaction ID', 'invoicing'),
403
+            'currency'      => __('Currency', 'invoicing'),
404
+            'due_date'      => __('Due Date', 'invoicing'),
405 405
         );
406 406
 
407 407
         return $columns;
408 408
     }
409 409
         
410
-    public function get_invoices_data( $response = array() ) {
410
+    public function get_invoices_data($response = array()) {
411 411
         $args = array(
412 412
             'limit'    => $this->per_page,
413 413
             'page'     => $this->step,
@@ -415,35 +415,35 @@  discard block
 block discarded – undo
415 415
             'orderby'  => 'date',
416 416
         );
417 417
         
418
-        if ( $this->status != 'any' ) {
418
+        if ($this->status != 'any') {
419 419
             $args['status'] = $this->status;
420 420
         }
421 421
 
422
-        if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) {
422
+        if (!empty($this->from_date) || !empty($this->to_date)) {
423 423
             $args['date_query'] = array(
424 424
                 array(
425
-                    'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ),
426
-                    'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ),
425
+                    'after'     => date('Y-n-d 00:00:00', strtotime($this->from_date)),
426
+                    'before'    => date('Y-n-d 23:59:59', strtotime($this->to_date)),
427 427
                     'inclusive' => true
428 428
                 )
429 429
             );
430 430
         }
431 431
 
432
-        $invoices = wpinv_get_invoices( $args );
432
+        $invoices = wpinv_get_invoices($args);
433 433
         
434 434
         $data = array();
435 435
         
436
-        if ( !empty( $invoices ) ) {
437
-            foreach ( $invoices as $invoice ) {
436
+        if (!empty($invoices)) {
437
+            foreach ($invoices as $invoice) {
438 438
                 $row = array(
439 439
                     'id'            => $invoice->ID,
440 440
                     'number'        => $invoice->get_number(),
441
-                    'date'          => $invoice->get_invoice_date( false ),
442
-                    'amount'        => wpinv_round_amount( $invoice->get_total() ),
443
-                    'status_nicename' => $invoice->get_status( true ),
441
+                    'date'          => $invoice->get_invoice_date(false),
442
+                    'amount'        => wpinv_round_amount($invoice->get_total()),
443
+                    'status_nicename' => $invoice->get_status(true),
444 444
                     'status'        => $invoice->get_status(),
445
-                    'tax'           => $invoice->get_tax() > 0 ? wpinv_round_amount( $invoice->get_tax() ) : '',
446
-                    'discount'      => $invoice->get_discount() > 0 ? wpinv_round_amount( $invoice->get_discount() ) : '',
445
+                    'tax'           => $invoice->get_tax() > 0 ? wpinv_round_amount($invoice->get_tax()) : '',
446
+                    'discount'      => $invoice->get_discount() > 0 ? wpinv_round_amount($invoice->get_discount()) : '',
447 447
                     'user_id'       => $invoice->get_user_id(),
448 448
                     'email'         => $invoice->get_email(),
449 449
                     'first_name'    => $invoice->get_first_name(),
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
                     'due_date'      => $invoice->needs_payment() ? $invoice->get_due_date() : '',
465 465
                 );
466 466
                 
467
-                $data[] = apply_filters( 'wpinv_export_invoice_row', $row, $invoice );
467
+                $data[] = apply_filters('wpinv_export_invoice_row', $row, $invoice);
468 468
             }
469 469
 
470 470
             return $data;
@@ -480,29 +480,29 @@  discard block
 block discarded – undo
480 480
             'return'   => 'ids',
481 481
         );
482 482
         
483
-        if ( $this->status != 'any' ) {
483
+        if ($this->status != 'any') {
484 484
             $args['status'] = $this->status;
485 485
         }
486 486
 
487
-        if ( !empty( $this->from_date ) || !empty( $this->to_date ) ) {
487
+        if (!empty($this->from_date) || !empty($this->to_date)) {
488 488
             $args['date_query'] = array(
489 489
                 array(
490
-                    'after'     => date( 'Y-n-d 00:00:00', strtotime( $this->from_date ) ),
491
-                    'before'    => date( 'Y-n-d 23:59:59', strtotime( $this->to_date ) ),
490
+                    'after'     => date('Y-n-d 00:00:00', strtotime($this->from_date)),
491
+                    'before'    => date('Y-n-d 23:59:59', strtotime($this->to_date)),
492 492
                     'inclusive' => true
493 493
                 )
494 494
             );
495 495
         }
496 496
 
497
-        $invoices   = wpinv_get_invoices( $args );
498
-        $total      = !empty( $invoices ) ? count( $invoices ) : 0;
497
+        $invoices   = wpinv_get_invoices($args);
498
+        $total      = !empty($invoices) ? count($invoices) : 0;
499 499
         $status     = 100;
500 500
 
501
-        if ( $total > 0 ) {
502
-            $status = ( ( $this->per_page * $this->step ) / $total ) * 100;
501
+        if ($total > 0) {
502
+            $status = (($this->per_page * $this->step) / $total) * 100;
503 503
         }
504 504
 
505
-        if ( $status > 100 ) {
505
+        if ($status > 100) {
506 506
             $status = 100;
507 507
         }
508 508
 
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -437,7 +437,7 @@
 block discarded – undo
437 437
 }
438 438
 
439 439
 function wpinv_get_php_arg_separator_output() {
440
-	return ini_get( 'arg_separator.output' );
440
+    return ini_get( 'arg_separator.output' );
441 441
 }
442 442
 
443 443
 function wpinv_rgb_from_hex( $color ) {
Please login to merge, or discard this patch.
Doc Comments   +28 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,6 +31,9 @@  discard block
 block discarded – undo
31 31
     return apply_filters( 'wpinv_get_ip', $ip );
32 32
 }
33 33
 
34
+/**
35
+ * @return string
36
+ */
34 37
 function wpinv_get_user_agent() {
35 38
     if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
36 39
         $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
@@ -41,6 +44,9 @@  discard block
 block discarded – undo
41 44
     return apply_filters( 'wpinv_get_user_agent', $user_agent );
42 45
 }
43 46
 
47
+/**
48
+ * @param integer $decimals
49
+ */
44 50
 function wpinv_sanitize_amount( $amount, $decimals = NULL ) {
45 51
     $is_negative   = false;
46 52
     $thousands_sep = wpinv_thousands_separator();
@@ -79,6 +85,9 @@  discard block
 block discarded – undo
79 85
 }
80 86
 add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
81 87
 
88
+/**
89
+ * @param integer $decimals
90
+ */
82 91
 function wpinv_round_amount( $amount, $decimals = NULL ) {
83 92
     if ( $decimals === NULL ) {
84 93
         $decimals = wpinv_decimals();
@@ -117,6 +126,9 @@  discard block
 block discarded – undo
117 126
     return $status;
118 127
 }
119 128
 
129
+/**
130
+ * @return string
131
+ */
120 132
 function wpinv_get_currency() {
121 133
     $currency = wpinv_get_option( 'currency', 'USD' );
122 134
     
@@ -187,6 +199,9 @@  discard block
 block discarded – undo
187 199
     return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
188 200
 }
189 201
 
202
+/**
203
+ * @return string
204
+ */
190 205
 function wpinv_currency_position() {
191 206
     $position = wpinv_get_option( 'currency_position', 'left' );
192 207
     
@@ -315,6 +330,9 @@  discard block
 block discarded – undo
315 330
     return $price;
316 331
 }
317 332
 
333
+/**
334
+ * @return string
335
+ */
318 336
 function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) {
319 337
     $thousands_sep = wpinv_thousands_separator();
320 338
     $decimal_sep   = wpinv_decimal_separator();
@@ -365,6 +383,9 @@  discard block
 block discarded – undo
365 383
     return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
366 384
 }
367 385
 
386
+/**
387
+ * @return string
388
+ */
368 389
 function wpinv_get_file_extension( $str ) {
369 390
     $parts = explode( '.', $str );
370 391
     return end( $parts );
@@ -569,6 +590,9 @@  discard block
 block discarded – undo
569 590
     return strlen( $str );
570 591
 }
571 592
 
593
+/**
594
+ * @param string $str
595
+ */
572 596
 function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
573 597
     if ( function_exists( 'mb_strtolower' ) ) {
574 598
         return mb_strtolower( $str, $encoding );
@@ -577,6 +601,9 @@  discard block
 block discarded – undo
577 601
     return strtolower( $str );
578 602
 }
579 603
 
604
+/**
605
+ * @param string $str
606
+ */
580 607
 function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
581 608
     if ( function_exists( 'mb_strtoupper' ) ) {
582 609
         return mb_strtoupper( $str, $encoding );
@@ -654,7 +681,7 @@  discard block
 block discarded – undo
654 681
  *
655 682
  * @param string $str The string being decoded.
656 683
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
657
- * @return string The width of string.
684
+ * @return integer The width of string.
658 685
  */
659 686
 function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
660 687
     if ( function_exists( 'mb_strwidth' ) ) {
Please login to merge, or discard this patch.
Spacing   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -7,89 +7,89 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_item_quantities_enabled() {
15
-    $ret = wpinv_get_option( 'item_quantities', true );
15
+    $ret = wpinv_get_option('item_quantities', true);
16 16
     
17
-    return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret );
17
+    return (bool)apply_filters('wpinv_item_quantities_enabled', $ret);
18 18
 }
19 19
 
20 20
 function wpinv_get_ip() {
21 21
     $ip = '127.0.0.1';
22 22
 
23
-    if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
24
-        $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
25
-    } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
26
-        $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
27
-    } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) {
28
-        $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
23
+    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
24
+        $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']);
25
+    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
26
+        $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']);
27
+    } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
28
+        $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']);
29 29
     }
30 30
     
31
-    return apply_filters( 'wpinv_get_ip', $ip );
31
+    return apply_filters('wpinv_get_ip', $ip);
32 32
 }
33 33
 
34 34
 function wpinv_get_user_agent() {
35
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
36
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
35
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
36
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
37 37
     } else {
38 38
         $user_agent = '';
39 39
     }
40 40
     
41
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
41
+    return apply_filters('wpinv_get_user_agent', $user_agent);
42 42
 }
43 43
 
44
-function wpinv_sanitize_amount( $amount, $decimals = NULL ) {
44
+function wpinv_sanitize_amount($amount, $decimals = NULL) {
45 45
     $is_negative   = false;
46 46
     $thousands_sep = wpinv_thousands_separator();
47 47
     $decimal_sep   = wpinv_decimal_separator();
48
-    if ( $decimals === NULL ) {
48
+    if ($decimals === NULL) {
49 49
         $decimals = wpinv_decimals();
50 50
     }
51 51
 
52 52
     // Sanitize the amount
53
-    if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) {
54
-        if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
55
-            $amount = str_replace( $thousands_sep, '', $amount );
56
-        } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) {
57
-            $amount = str_replace( '.', '', $amount );
53
+    if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) {
54
+        if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) {
55
+            $amount = str_replace($thousands_sep, '', $amount);
56
+        } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) {
57
+            $amount = str_replace('.', '', $amount);
58 58
         }
59 59
 
60
-        $amount = str_replace( $decimal_sep, '.', $amount );
61
-    } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
62
-        $amount = str_replace( $thousands_sep, '', $amount );
60
+        $amount = str_replace($decimal_sep, '.', $amount);
61
+    } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
62
+        $amount = str_replace($thousands_sep, '', $amount);
63 63
     }
64 64
 
65
-    if( $amount < 0 ) {
65
+    if ($amount < 0) {
66 66
         $is_negative = true;
67 67
     }
68 68
 
69
-    $amount   = preg_replace( '/[^0-9\.]/', '', $amount );
69
+    $amount   = preg_replace('/[^0-9\.]/', '', $amount);
70 70
 
71
-    $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount );
72
-    $amount   = number_format( (double) $amount, absint( $decimals ), '.', '' );
71
+    $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount);
72
+    $amount   = number_format((double)$amount, absint($decimals), '.', '');
73 73
 
74
-    if( $is_negative ) {
74
+    if ($is_negative) {
75 75
         $amount *= -1;
76 76
     }
77 77
 
78
-    return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals );
78
+    return apply_filters('wpinv_sanitize_amount', $amount, $decimals);
79 79
 }
80
-add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
80
+add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1);
81 81
 
82
-function wpinv_round_amount( $amount, $decimals = NULL ) {
83
-    if ( $decimals === NULL ) {
82
+function wpinv_round_amount($amount, $decimals = NULL) {
83
+    if ($decimals === NULL) {
84 84
         $decimals = wpinv_decimals();
85 85
     }
86 86
     
87
-    $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) );
87
+    $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals)));
88 88
 
89
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
89
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
90 90
 }
91 91
 
92
-function wpinv_get_invoice_statuses( $trashed = false ) {
92
+function wpinv_get_invoice_statuses($trashed = false) {
93 93
     global $post;
94 94
     $invoice_statuses = array();
95 95
     $invoice_statuses = array(
@@ -103,32 +103,32 @@  discard block
 block discarded – undo
103 103
         'wpi-renewal' => __('Renewal Payment', 'invoicing')
104 104
     );
105 105
     
106
-    if ( $trashed ) {
107
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
106
+    if ($trashed) {
107
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
108 108
     }
109 109
 
110
-    return apply_filters( 'wpinv_statuses', $invoice_statuses );
110
+    return apply_filters('wpinv_statuses', $invoice_statuses);
111 111
 }
112 112
 
113
-function wpinv_status_nicename( $status ) {
113
+function wpinv_status_nicename($status) {
114 114
     $statuses = wpinv_get_invoice_statuses();
115
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' );
115
+    $status   = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing');
116 116
 
117 117
     return $status;
118 118
 }
119 119
 
120 120
 function wpinv_get_currency() {
121
-    $currency = wpinv_get_option( 'currency', 'USD' );
121
+    $currency = wpinv_get_option('currency', 'USD');
122 122
     
123
-    return apply_filters( 'wpinv_currency', $currency );
123
+    return apply_filters('wpinv_currency', $currency);
124 124
 }
125 125
 
126
-function wpinv_currency_symbol( $currency = '' ) {
127
-    if ( empty( $currency ) ) {
126
+function wpinv_currency_symbol($currency = '') {
127
+    if (empty($currency)) {
128 128
         $currency = wpinv_get_currency();
129 129
     }
130 130
     
131
-    $symbols = apply_filters( 'wpinv_currency_symbols', array(
131
+    $symbols = apply_filters('wpinv_currency_symbols', array(
132 132
         'AED' => 'د.إ',
133 133
         'ARS' => '&#36;',
134 134
         'AUD' => '&#36;',
@@ -180,78 +180,78 @@  discard block
 block discarded – undo
180 180
         'USD' => '&#36;',
181 181
         'VND' => '&#8363;',
182 182
         'ZAR' => '&#82;',
183
-    ) );
183
+    ));
184 184
 
185
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : '&#36;';
185
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : '&#36;';
186 186
 
187
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
187
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
188 188
 }
189 189
 
190 190
 function wpinv_currency_position() {
191
-    $position = wpinv_get_option( 'currency_position', 'left' );
191
+    $position = wpinv_get_option('currency_position', 'left');
192 192
     
193
-    return apply_filters( 'wpinv_currency_position', $position );
193
+    return apply_filters('wpinv_currency_position', $position);
194 194
 }
195 195
 
196 196
 function wpinv_thousands_separator() {
197
-    $thousand_sep = wpinv_get_option( 'thousands_separator', ',' );
197
+    $thousand_sep = wpinv_get_option('thousands_separator', ',');
198 198
     
199
-    return apply_filters( 'wpinv_thousands_separator', $thousand_sep );
199
+    return apply_filters('wpinv_thousands_separator', $thousand_sep);
200 200
 }
201 201
 
202 202
 function wpinv_decimal_separator() {
203
-    $decimal_sep = wpinv_get_option( 'decimal_separator', '.' );
203
+    $decimal_sep = wpinv_get_option('decimal_separator', '.');
204 204
     
205
-    return apply_filters( 'wpinv_decimal_separator', $decimal_sep );
205
+    return apply_filters('wpinv_decimal_separator', $decimal_sep);
206 206
 }
207 207
 
208 208
 function wpinv_decimals() {
209
-    $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) );
209
+    $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2));
210 210
     
211
-    return absint( $decimals );
211
+    return absint($decimals);
212 212
 }
213 213
 
214 214
 function wpinv_get_currencies() {
215 215
     $currencies = array(
216
-        'USD'  => __( 'US Dollars (&#36;)', 'invoicing' ),
217
-        'EUR'  => __( 'Euros (&euro;)', 'invoicing' ),
218
-        'GBP'  => __( 'Pounds Sterling (&pound;)', 'invoicing' ),
219
-        'AUD'  => __( 'Australian Dollars (&#36;)', 'invoicing' ),
220
-        'BRL'  => __( 'Brazilian Real (R&#36;)', 'invoicing' ),
221
-        'CAD'  => __( 'Canadian Dollars (&#36;)', 'invoicing' ),
222
-        'CLP'  => __( 'Chilean Peso (&#36;)', 'invoicing' ),
223
-        'CNY'  => __( 'Chinese Yuan (&yen;)', 'invoicing' ),
224
-        'CZK'  => __( 'Czech Koruna (&#75;&#269;)', 'invoicing' ),
225
-        'DKK'  => __( 'Danish Krone (DKK)', 'invoicing' ),
226
-        'HKD'  => __( 'Hong Kong Dollar (&#36;)', 'invoicing' ),
227
-        'HUF'  => __( 'Hungarian Forint (&#70;&#116;)', 'invoicing' ),
228
-        'INR'  => __( 'Indian Rupee (&#8377;)', 'invoicing' ),
229
-        'ILS'  => __( 'Israeli Shekel (&#8362;)', 'invoicing' ),
230
-        'JPY'  => __( 'Japanese Yen (&yen;)', 'invoicing' ),
231
-        'MYR'  => __( 'Malaysian Ringgit (&#82;&#77;)', 'invoicing' ),
232
-        'MXN'  => __( 'Mexican Peso (&#36;)', 'invoicing' ),
233
-        'NZD'  => __( 'New Zealand Dollar (&#36;)', 'invoicing' ),
234
-        'NOK'  => __( 'Norwegian Krone (&#107;&#114;)', 'invoicing' ),
235
-        'PHP'  => __( 'Philippine Peso (&#8369;)', 'invoicing' ),
236
-        'PLN'  => __( 'Polish Zloty (&#122;&#322;)', 'invoicing' ),
237
-        'SGD'  => __( 'Singapore Dollar (&#36;)', 'invoicing' ),
238
-        'SEK'  => __( 'Swedish Krona (&#107;&#114;)', 'invoicing' ),
239
-        'CHF'  => __( 'Swiss Franc (&#67;&#72;&#70;)', 'invoicing' ),
240
-        'TWD'  => __( 'Taiwan New Dollar (&#78;&#84;&#36;)', 'invoicing' ),
241
-        'THB'  => __( 'Thai Baht (&#3647;)', 'invoicing' ),
242
-        'TRY'  => __( 'Turkish Lira (&#8378;)', 'invoicing' ),
243
-        'RIAL' => __( 'Iranian Rial (&#65020;)', 'invoicing' ),
244
-        'RUB'  => __( 'Russian Ruble (&#8381;)', 'invoicing' ),
245
-        'ZAR'  => __( 'South African Rand (&#82;)', 'invoicing' )
216
+        'USD'  => __('US Dollars (&#36;)', 'invoicing'),
217
+        'EUR'  => __('Euros (&euro;)', 'invoicing'),
218
+        'GBP'  => __('Pounds Sterling (&pound;)', 'invoicing'),
219
+        'AUD'  => __('Australian Dollars (&#36;)', 'invoicing'),
220
+        'BRL'  => __('Brazilian Real (R&#36;)', 'invoicing'),
221
+        'CAD'  => __('Canadian Dollars (&#36;)', 'invoicing'),
222
+        'CLP'  => __('Chilean Peso (&#36;)', 'invoicing'),
223
+        'CNY'  => __('Chinese Yuan (&yen;)', 'invoicing'),
224
+        'CZK'  => __('Czech Koruna (&#75;&#269;)', 'invoicing'),
225
+        'DKK'  => __('Danish Krone (DKK)', 'invoicing'),
226
+        'HKD'  => __('Hong Kong Dollar (&#36;)', 'invoicing'),
227
+        'HUF'  => __('Hungarian Forint (&#70;&#116;)', 'invoicing'),
228
+        'INR'  => __('Indian Rupee (&#8377;)', 'invoicing'),
229
+        'ILS'  => __('Israeli Shekel (&#8362;)', 'invoicing'),
230
+        'JPY'  => __('Japanese Yen (&yen;)', 'invoicing'),
231
+        'MYR'  => __('Malaysian Ringgit (&#82;&#77;)', 'invoicing'),
232
+        'MXN'  => __('Mexican Peso (&#36;)', 'invoicing'),
233
+        'NZD'  => __('New Zealand Dollar (&#36;)', 'invoicing'),
234
+        'NOK'  => __('Norwegian Krone (&#107;&#114;)', 'invoicing'),
235
+        'PHP'  => __('Philippine Peso (&#8369;)', 'invoicing'),
236
+        'PLN'  => __('Polish Zloty (&#122;&#322;)', 'invoicing'),
237
+        'SGD'  => __('Singapore Dollar (&#36;)', 'invoicing'),
238
+        'SEK'  => __('Swedish Krona (&#107;&#114;)', 'invoicing'),
239
+        'CHF'  => __('Swiss Franc (&#67;&#72;&#70;)', 'invoicing'),
240
+        'TWD'  => __('Taiwan New Dollar (&#78;&#84;&#36;)', 'invoicing'),
241
+        'THB'  => __('Thai Baht (&#3647;)', 'invoicing'),
242
+        'TRY'  => __('Turkish Lira (&#8378;)', 'invoicing'),
243
+        'RIAL' => __('Iranian Rial (&#65020;)', 'invoicing'),
244
+        'RUB'  => __('Russian Ruble (&#8381;)', 'invoicing'),
245
+        'ZAR'  => __('South African Rand (&#82;)', 'invoicing')
246 246
     );
247 247
     
248
-    asort( $currencies );
248
+    asort($currencies);
249 249
 
250
-    return apply_filters( 'wpinv_currencies', $currencies );
250
+    return apply_filters('wpinv_currencies', $currencies);
251 251
 }
252 252
 
253
-function wpinv_price( $amount = '', $currency = '' ) {
254
-    if( empty( $currency ) ) {
253
+function wpinv_price($amount = '', $currency = '') {
254
+    if (empty($currency)) {
255 255
         $currency = wpinv_get_currency();
256 256
     }
257 257
 
@@ -259,14 +259,14 @@  discard block
 block discarded – undo
259 259
 
260 260
     $negative = $amount < 0;
261 261
 
262
-    if ( $negative ) {
263
-        $amount = substr( $amount, 1 );
262
+    if ($negative) {
263
+        $amount = substr($amount, 1);
264 264
     }
265 265
 
266
-    $symbol = wpinv_currency_symbol( $currency );
266
+    $symbol = wpinv_currency_symbol($currency);
267 267
 
268
-    if ( $position == 'left' || $position == 'left_space' ) {
269
-        switch ( $currency ) {
268
+    if ($position == 'left' || $position == 'left_space') {
269
+        switch ($currency) {
270 270
             case "GBP" :
271 271
             case "BRL" :
272 272
             case "EUR" :
@@ -278,15 +278,15 @@  discard block
 block discarded – undo
278 278
             case "NZD" :
279 279
             case "SGD" :
280 280
             case "JPY" :
281
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
281
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
282 282
                 break;
283 283
             default :
284 284
                 //$price = $currency . ' ' . $amount;
285
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
285
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
286 286
                 break;
287 287
         }
288 288
     } else {
289
-        switch ( $currency ) {
289
+        switch ($currency) {
290 290
             case "GBP" :
291 291
             case "BRL" :
292 292
             case "EUR" :
@@ -297,83 +297,83 @@  discard block
 block discarded – undo
297 297
             case "MXN" :
298 298
             case "SGD" :
299 299
             case "JPY" :
300
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
300
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
301 301
                 break;
302 302
             default :
303 303
                 //$price = $amount . ' ' . $currency;
304
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
304
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
305 305
                 break;
306 306
         }
307 307
     }
308 308
     
309
-    if ( $negative ) {
309
+    if ($negative) {
310 310
         $price = '-' . $price;
311 311
     }
312 312
     
313
-    $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount );
313
+    $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount);
314 314
 
315 315
     return $price;
316 316
 }
317 317
 
318
-function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) {
318
+function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) {
319 319
     $thousands_sep = wpinv_thousands_separator();
320 320
     $decimal_sep   = wpinv_decimal_separator();
321 321
 
322
-    if ( $decimals === NULL ) {
322
+    if ($decimals === NULL) {
323 323
         $decimals = wpinv_decimals();
324 324
     }
325 325
 
326
-    if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) {
327
-        $whole = substr( $amount, 0, $sep_found );
328
-        $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
326
+    if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) {
327
+        $whole = substr($amount, 0, $sep_found);
328
+        $part = substr($amount, $sep_found + 1, (strlen($amount) - 1));
329 329
         $amount = $whole . '.' . $part;
330 330
     }
331 331
 
332
-    if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
333
-        $amount = str_replace( ',', '', $amount );
332
+    if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
333
+        $amount = str_replace(',', '', $amount);
334 334
     }
335 335
 
336
-    if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
337
-        $amount = str_replace( ' ', '', $amount );
336
+    if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) {
337
+        $amount = str_replace(' ', '', $amount);
338 338
     }
339 339
 
340
-    if ( empty( $amount ) ) {
340
+    if (empty($amount)) {
341 341
         $amount = 0;
342 342
     }
343 343
     
344
-    $decimals  = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate );
345
-    $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep );
344
+    $decimals  = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate);
345
+    $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep);
346 346
     
347
-    if ( $calculate ) {
348
-        if ( $thousands_sep === "," ) {
349
-            $formatted = str_replace( ",", "", $formatted );
347
+    if ($calculate) {
348
+        if ($thousands_sep === ",") {
349
+            $formatted = str_replace(",", "", $formatted);
350 350
         }
351 351
         
352
-        if ( $decimal_sep === "," ) {
353
-            $formatted = str_replace( ",", ".", $formatted );
352
+        if ($decimal_sep === ",") {
353
+            $formatted = str_replace(",", ".", $formatted);
354 354
         }
355 355
     }
356 356
 
357
-    return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate );
357
+    return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate);
358 358
 }
359
-add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
359
+add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1);
360 360
 
361
-function wpinv_sanitize_key( $key ) {
361
+function wpinv_sanitize_key($key) {
362 362
     $raw_key = $key;
363
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
363
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
364 364
 
365
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
365
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
366 366
 }
367 367
 
368
-function wpinv_get_file_extension( $str ) {
369
-    $parts = explode( '.', $str );
370
-    return end( $parts );
368
+function wpinv_get_file_extension($str) {
369
+    $parts = explode('.', $str);
370
+    return end($parts);
371 371
 }
372 372
 
373
-function wpinv_string_is_image_url( $str ) {
374
-    $ext = wpinv_get_file_extension( $str );
373
+function wpinv_string_is_image_url($str) {
374
+    $ext = wpinv_get_file_extension($str);
375 375
 
376
-    switch ( strtolower( $ext ) ) {
376
+    switch (strtolower($ext)) {
377 377
         case 'jpeg';
378 378
         case 'jpg';
379 379
             $return = true;
@@ -389,32 +389,32 @@  discard block
 block discarded – undo
389 389
             break;
390 390
     }
391 391
 
392
-    return (bool)apply_filters( 'wpinv_string_is_image', $return, $str );
392
+    return (bool)apply_filters('wpinv_string_is_image', $return, $str);
393 393
 }
394 394
 
395
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
396
-    $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG );
395
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
396
+    $should_log = apply_filters('wpinv_log_errors', WP_DEBUG);
397 397
     
398
-    if ( true === $should_log ) {
398
+    if (true === $should_log) {
399 399
         $label = '';
400
-        if ( $file && $file !== '' ) {
401
-            $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' );
400
+        if ($file && $file !== '') {
401
+            $label .= basename($file) . ($line ? '(' . $line . ')' : '');
402 402
         }
403 403
         
404
-        if ( $title && $title !== '' ) {
404
+        if ($title && $title !== '') {
405 405
             $label = $label !== '' ? $label . ' ' : '';
406 406
             $label .= $title . ' ';
407 407
         }
408 408
         
409
-        $label = $label !== '' ? trim( $label ) . ' : ' : '';
409
+        $label = $label !== '' ? trim($label) . ' : ' : '';
410 410
         
411
-        if ( is_array( $log ) || is_object( $log ) ) {
412
-            error_log( $label . print_r( $log, true ) );
411
+        if (is_array($log) || is_object($log)) {
412
+            error_log($label . print_r($log, true));
413 413
         } else {
414
-            error_log( $label . $log );
414
+            error_log($label . $log);
415 415
         }
416 416
         
417
-        if ( $exit ) {
417
+        if ($exit) {
418 418
             exit;
419 419
         }
420 420
     }
@@ -422,65 +422,65 @@  discard block
 block discarded – undo
422 422
 
423 423
 function wpinv_is_ajax_disabled() {
424 424
     $retval = false;
425
-    return apply_filters( 'wpinv_is_ajax_disabled', $retval );
425
+    return apply_filters('wpinv_is_ajax_disabled', $retval);
426 426
 }
427 427
 
428
-function wpinv_get_current_page_url( $nocache = false ) {
428
+function wpinv_get_current_page_url($nocache = false) {
429 429
     global $wp;
430 430
 
431
-    if ( get_option( 'permalink_structure' ) ) {
432
-        $base = trailingslashit( home_url( $wp->request ) );
431
+    if (get_option('permalink_structure')) {
432
+        $base = trailingslashit(home_url($wp->request));
433 433
     } else {
434
-        $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
435
-        $base = remove_query_arg( array( 'post_type', 'name' ), $base );
434
+        $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
435
+        $base = remove_query_arg(array('post_type', 'name'), $base);
436 436
     }
437 437
 
438 438
     $scheme = is_ssl() ? 'https' : 'http';
439
-    $uri    = set_url_scheme( $base, $scheme );
439
+    $uri    = set_url_scheme($base, $scheme);
440 440
 
441
-    if ( is_front_page() ) {
442
-        $uri = home_url( '/' );
443
-    } elseif ( wpinv_is_checkout( array(), false ) ) {
441
+    if (is_front_page()) {
442
+        $uri = home_url('/');
443
+    } elseif (wpinv_is_checkout(array(), false)) {
444 444
         $uri = wpinv_get_checkout_uri();
445 445
     }
446 446
 
447
-    $uri = apply_filters( 'wpinv_get_current_page_url', $uri );
447
+    $uri = apply_filters('wpinv_get_current_page_url', $uri);
448 448
 
449
-    if ( $nocache ) {
450
-        $uri = wpinv_add_cache_busting( $uri );
449
+    if ($nocache) {
450
+        $uri = wpinv_add_cache_busting($uri);
451 451
     }
452 452
 
453 453
     return $uri;
454 454
 }
455 455
 
456 456
 function wpinv_get_php_arg_separator_output() {
457
-	return ini_get( 'arg_separator.output' );
457
+	return ini_get('arg_separator.output');
458 458
 }
459 459
 
460
-function wpinv_rgb_from_hex( $color ) {
461
-    $color = str_replace( '#', '', $color );
460
+function wpinv_rgb_from_hex($color) {
461
+    $color = str_replace('#', '', $color);
462 462
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
463
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
463
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
464 464
 
465 465
     $rgb      = array();
466
-    $rgb['R'] = hexdec( $color{0}.$color{1} );
467
-    $rgb['G'] = hexdec( $color{2}.$color{3} );
468
-    $rgb['B'] = hexdec( $color{4}.$color{5} );
466
+    $rgb['R'] = hexdec($color{0} . $color{1} );
467
+    $rgb['G'] = hexdec($color{2} . $color{3} );
468
+    $rgb['B'] = hexdec($color{4} . $color{5} );
469 469
 
470 470
     return $rgb;
471 471
 }
472 472
 
473
-function wpinv_hex_darker( $color, $factor = 30 ) {
474
-    $base  = wpinv_rgb_from_hex( $color );
473
+function wpinv_hex_darker($color, $factor = 30) {
474
+    $base  = wpinv_rgb_from_hex($color);
475 475
     $color = '#';
476 476
 
477
-    foreach ( $base as $k => $v ) {
477
+    foreach ($base as $k => $v) {
478 478
         $amount      = $v / 100;
479
-        $amount      = round( $amount * $factor );
479
+        $amount      = round($amount * $factor);
480 480
         $new_decimal = $v - $amount;
481 481
 
482
-        $new_hex_component = dechex( $new_decimal );
483
-        if ( strlen( $new_hex_component ) < 2 ) {
482
+        $new_hex_component = dechex($new_decimal);
483
+        if (strlen($new_hex_component) < 2) {
484 484
             $new_hex_component = "0" . $new_hex_component;
485 485
         }
486 486
         $color .= $new_hex_component;
@@ -489,18 +489,18 @@  discard block
 block discarded – undo
489 489
     return $color;
490 490
 }
491 491
 
492
-function wpinv_hex_lighter( $color, $factor = 30 ) {
493
-    $base  = wpinv_rgb_from_hex( $color );
492
+function wpinv_hex_lighter($color, $factor = 30) {
493
+    $base  = wpinv_rgb_from_hex($color);
494 494
     $color = '#';
495 495
 
496
-    foreach ( $base as $k => $v ) {
496
+    foreach ($base as $k => $v) {
497 497
         $amount      = 255 - $v;
498 498
         $amount      = $amount / 100;
499
-        $amount      = round( $amount * $factor );
499
+        $amount      = round($amount * $factor);
500 500
         $new_decimal = $v + $amount;
501 501
 
502
-        $new_hex_component = dechex( $new_decimal );
503
-        if ( strlen( $new_hex_component ) < 2 ) {
502
+        $new_hex_component = dechex($new_decimal);
503
+        if (strlen($new_hex_component) < 2) {
504 504
             $new_hex_component = "0" . $new_hex_component;
505 505
         }
506 506
         $color .= $new_hex_component;
@@ -509,22 +509,22 @@  discard block
 block discarded – undo
509 509
     return $color;
510 510
 }
511 511
 
512
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
513
-    $hex = str_replace( '#', '', $color );
512
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
513
+    $hex = str_replace('#', '', $color);
514 514
 
515
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
516
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
517
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
515
+    $c_r = hexdec(substr($hex, 0, 2));
516
+    $c_g = hexdec(substr($hex, 2, 2));
517
+    $c_b = hexdec(substr($hex, 4, 2));
518 518
 
519
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
519
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
520 520
 
521 521
     return $brightness > 155 ? $dark : $light;
522 522
 }
523 523
 
524
-function wpinv_format_hex( $hex ) {
525
-    $hex = trim( str_replace( '#', '', $hex ) );
524
+function wpinv_format_hex($hex) {
525
+    $hex = trim(str_replace('#', '', $hex));
526 526
 
527
-    if ( strlen( $hex ) == 3 ) {
527
+    if (strlen($hex) == 3) {
528 528
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
529 529
     }
530 530
 
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
545 545
  * @return string
546 546
  */
547
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
548
-    if ( function_exists( 'mb_strimwidth' ) ) {
549
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
547
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
548
+    if (function_exists('mb_strimwidth')) {
549
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
550 550
     }
551 551
     
552
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
552
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
553 553
 }
554 554
 
555 555
 /**
@@ -561,28 +561,28 @@  discard block
 block discarded – undo
561 561
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
562 562
  * @return int Returns the number of characters in string.
563 563
  */
564
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
565
-    if ( function_exists( 'mb_strlen' ) ) {
566
-        return mb_strlen( $str, $encoding );
564
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
565
+    if (function_exists('mb_strlen')) {
566
+        return mb_strlen($str, $encoding);
567 567
     }
568 568
         
569
-    return strlen( $str );
569
+    return strlen($str);
570 570
 }
571 571
 
572
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
573
-    if ( function_exists( 'mb_strtolower' ) ) {
574
-        return mb_strtolower( $str, $encoding );
572
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
573
+    if (function_exists('mb_strtolower')) {
574
+        return mb_strtolower($str, $encoding);
575 575
     }
576 576
     
577
-    return strtolower( $str );
577
+    return strtolower($str);
578 578
 }
579 579
 
580
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
581
-    if ( function_exists( 'mb_strtoupper' ) ) {
582
-        return mb_strtoupper( $str, $encoding );
580
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
581
+    if (function_exists('mb_strtoupper')) {
582
+        return mb_strtoupper($str, $encoding);
583 583
     }
584 584
     
585
-    return strtoupper( $str );
585
+    return strtoupper($str);
586 586
 }
587 587
 
588 588
 /**
@@ -596,12 +596,12 @@  discard block
 block discarded – undo
596 596
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
597 597
  * @return int Returns the position of the first occurrence of search in the string.
598 598
  */
599
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
600
-    if ( function_exists( 'mb_strpos' ) ) {
601
-        return mb_strpos( $str, $find, $offset, $encoding );
599
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
600
+    if (function_exists('mb_strpos')) {
601
+        return mb_strpos($str, $find, $offset, $encoding);
602 602
     }
603 603
         
604
-    return strpos( $str, $find, $offset );
604
+    return strpos($str, $find, $offset);
605 605
 }
606 606
 
607 607
 /**
@@ -615,12 +615,12 @@  discard block
 block discarded – undo
615 615
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
616 616
  * @return int Returns the position of the last occurrence of search.
617 617
  */
618
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
619
-    if ( function_exists( 'mb_strrpos' ) ) {
620
-        return mb_strrpos( $str, $find, $offset, $encoding );
618
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
619
+    if (function_exists('mb_strrpos')) {
620
+        return mb_strrpos($str, $find, $offset, $encoding);
621 621
     }
622 622
         
623
-    return strrpos( $str, $find, $offset );
623
+    return strrpos($str, $find, $offset);
624 624
 }
625 625
 
626 626
 /**
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
636 636
  * @return string
637 637
  */
638
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
639
-    if ( function_exists( 'mb_substr' ) ) {
640
-        if ( $length === null ) {
641
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
638
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
639
+    if (function_exists('mb_substr')) {
640
+        if ($length === null) {
641
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
642 642
         } else {
643
-            return mb_substr( $str, $start, $length, $encoding );
643
+            return mb_substr($str, $start, $length, $encoding);
644 644
         }
645 645
     }
646 646
         
647
-    return substr( $str, $start, $length );
647
+    return substr($str, $start, $length);
648 648
 }
649 649
 
650 650
 /**
@@ -656,48 +656,48 @@  discard block
 block discarded – undo
656 656
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
657 657
  * @return string The width of string.
658 658
  */
659
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
660
-    if ( function_exists( 'mb_strwidth' ) ) {
661
-        return mb_strwidth( $str, $encoding );
659
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
660
+    if (function_exists('mb_strwidth')) {
661
+        return mb_strwidth($str, $encoding);
662 662
     }
663 663
     
664
-    return wpinv_utf8_strlen( $str, $encoding );
664
+    return wpinv_utf8_strlen($str, $encoding);
665 665
 }
666 666
 
667
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
668
-    if ( function_exists( 'mb_strlen' ) ) {
669
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
667
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
668
+    if (function_exists('mb_strlen')) {
669
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
670 670
         $str_end = "";
671 671
         
672
-        if ( $lower_str_end ) {
673
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
672
+        if ($lower_str_end) {
673
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
674 674
         } else {
675
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
675
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
676 676
         }
677 677
 
678 678
         return $first_letter . $str_end;
679 679
     }
680 680
     
681
-    return ucfirst( $str );
681
+    return ucfirst($str);
682 682
 }
683 683
 
684
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
685
-    if ( function_exists( 'mb_convert_case' ) ) {
686
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
684
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
685
+    if (function_exists('mb_convert_case')) {
686
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
687 687
     }
688 688
     
689
-    return ucwords( $str );
689
+    return ucwords($str);
690 690
 }
691 691
 
692
-function wpinv_period_in_days( $period, $unit ) {
693
-    $period = absint( $period );
692
+function wpinv_period_in_days($period, $unit) {
693
+    $period = absint($period);
694 694
     
695
-    if ( $period > 0 ) {
696
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
695
+    if ($period > 0) {
696
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
697 697
             $period = $period * 7;
698
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
698
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
699 699
             $period = $period * 30;
700
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
700
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
701 701
             $period = $period * 365;
702 702
         }
703 703
     }
Please login to merge, or discard this patch.