Passed
Branch master (50908e)
by Stiofan
07:01
created
includes/admin/admin-pages.php 1 patch
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  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_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' );
8
-function wpinv_discount_columns( $existing_columns ) {
7
+add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns');
8
+function wpinv_discount_columns($existing_columns) {
9 9
     $columns                = array();
10 10
     $columns['cb']          = $existing_columns['cb'];
11
-    $columns['name']        = __( 'Name', 'invoicing' );
12
-    $columns['code']        = __( 'Code', 'invoicing' );
13
-    $columns['amount']      = __( 'Amount', 'invoicing' );
14
-    $columns['usage']       = __( 'Usage / Limit', 'invoicing' );
15
-    $columns['start_date']  = __( 'Start Date', 'invoicing' );
16
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
17
-    $columns['status']      = __( 'Status', 'invoicing' );
11
+    $columns['name']        = __('Name', 'invoicing');
12
+    $columns['code']        = __('Code', 'invoicing');
13
+    $columns['amount']      = __('Amount', 'invoicing');
14
+    $columns['usage']       = __('Usage / Limit', 'invoicing');
15
+    $columns['start_date']  = __('Start Date', 'invoicing');
16
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
17
+    $columns['status']      = __('Status', 'invoicing');
18 18
 
19 19
     return $columns;
20 20
 }
21 21
 
22
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
23
-function wpinv_discount_custom_column( $column ) {
22
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
23
+function wpinv_discount_custom_column($column) {
24 24
     global $post;
25 25
     
26 26
     $discount = $post;
27 27
 
28
-    switch ( $column ) {
28
+    switch ($column) {
29 29
         case 'name' :
30
-            echo get_the_title( $discount->ID );
30
+            echo get_the_title($discount->ID);
31 31
         break;
32 32
         case 'code' :
33
-            echo wpinv_get_discount_code( $discount->ID );
33
+            echo wpinv_get_discount_code($discount->ID);
34 34
         break;
35 35
         case 'amount' :
36
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
36
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
37 37
         break;
38 38
         case 'usage_limit' :
39
-            echo wpinv_get_discount_uses( $discount->ID );
39
+            echo wpinv_get_discount_uses($discount->ID);
40 40
         break;
41 41
         case 'usage' :
42
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
43
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
44
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
42
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
43
+            if (wpinv_get_discount_max_uses($discount->ID)) {
44
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
45 45
             } else {
46 46
                 $usage .= ' &infin;';
47 47
             }
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
             echo $usage;
50 50
         break;
51 51
         case 'start_date' :
52
-            if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) {
53
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) );
52
+            if ($start_date = wpinv_get_discount_start_date($discount->ID)) {
53
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date));
54 54
             } else {
55 55
                 $value = '-';
56 56
             }
@@ -58,163 +58,163 @@  discard block
 block discarded – undo
58 58
             echo $value;
59 59
         break;
60 60
         case 'expiry_date' :
61
-            if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) {
62
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) );
61
+            if ($expiration = wpinv_get_discount_expiration($discount->ID)) {
62
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration));
63 63
             } else {
64
-                $value = __( 'Never', 'invoicing' );
64
+                $value = __('Never', 'invoicing');
65 65
             }
66 66
                 
67 67
             echo $value;
68 68
         break;
69 69
         break;
70 70
         case 'description' :
71
-            echo wp_kses_post( $post->post_excerpt );
71
+            echo wp_kses_post($post->post_excerpt);
72 72
         break;
73 73
         case 'status' :
74
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
74
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
75 75
             
76
-            echo wpinv_discount_status( $status );
76
+            echo wpinv_discount_status($status);
77 77
         break;
78 78
     }
79 79
 }
80 80
 
81
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
82
-function wpinv_post_row_actions( $actions, $post ) {
83
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
81
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
82
+function wpinv_post_row_actions($actions, $post) {
83
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
84 84
     
85
-    if ( $post_type == 'wpi_invoice' ) {
85
+    if ($post_type == 'wpi_invoice') {
86 86
         $actions = array();
87 87
     }
88 88
     
89
-    if ( $post_type == 'wpi_discount' ) {
90
-        $actions = wpinv_discount_row_actions( $post, $actions );
89
+    if ($post_type == 'wpi_discount') {
90
+        $actions = wpinv_discount_row_actions($post, $actions);
91 91
     }
92 92
     
93 93
     return $actions;
94 94
 }
95 95
 
96
-function wpinv_discount_row_actions( $discount, $row_actions ) {
97
-    $row_actions  = array();
98
-    $edit_link = get_edit_post_link( $discount->ID );
99
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
96
+function wpinv_discount_row_actions($discount, $row_actions) {
97
+    $row_actions = array();
98
+    $edit_link = get_edit_post_link($discount->ID);
99
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
100 100
 
101
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
102
-        $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>';
103
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
104
-        $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>';
101
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
102
+        $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>';
103
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
104
+        $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>';
105 105
     }
106 106
 
107
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
108
-        if ( isset( $row_actions['delete'] ) ) {
109
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
107
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
108
+        if (isset($row_actions['delete'])) {
109
+            unset($row_actions['delete']); // Don't delete used discounts.
110 110
         }
111 111
     } else {
112
-        $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>';
112
+        $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>';
113 113
     }
114 114
     
115 115
 
116
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
116
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
117 117
 
118 118
     return $row_actions;
119 119
 }
120 120
 
121
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
122
-function wpinv_table_primary_column( $default, $screen_id ) {
123
-    if ( 'edit-wpi_invoice' === $screen_id ) {
121
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
122
+function wpinv_table_primary_column($default, $screen_id) {
123
+    if ('edit-wpi_invoice' === $screen_id) {
124 124
         return 'name';
125 125
     }
126 126
     
127 127
     return $default;
128 128
 }
129 129
 
130
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
131
-    if ( !$display ) {
130
+function wpinv_discount_bulk_actions($actions, $display = false) {    
131
+    if (!$display) {
132 132
         return array();
133 133
     }
134 134
     
135 135
     $actions = array(
136
-        'activate'   => __( 'Activate', 'invoicing' ),
137
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
138
-        'delete'     => __( 'Delete', 'invoicing' ),
136
+        'activate'   => __('Activate', 'invoicing'),
137
+        'deactivate' => __('Deactivate', 'invoicing'),
138
+        'delete'     => __('Delete', 'invoicing'),
139 139
     );
140 140
     $two = '';
141 141
     $which = 'top';
142 142
     echo '</div><div class="alignleft actions bulkactions">';
143
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
144
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
145
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
143
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
144
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
145
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
146 146
 
147
-    foreach ( $actions as $name => $title ) {
147
+    foreach ($actions as $name => $title) {
148 148
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
149 149
 
150 150
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
151 151
     }
152 152
     echo "</select>";
153 153
 
154
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
154
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
155 155
     
156 156
     echo '</div><div class="alignleft actions">';
157 157
 }
158
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
158
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
159 159
 
160
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
161
-    if ( $post_type == 'wpi_discount' ) {
160
+function wpinv_disable_months_dropdown($disable, $post_type) {
161
+    if ($post_type == 'wpi_discount') {
162 162
         $disable = true;
163 163
     }
164 164
     
165 165
     return $disable;
166 166
 }
167
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
167
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
168 168
 
169 169
 function wpinv_restrict_manage_posts() {
170 170
     global $typenow;
171 171
 
172
-    if( 'wpi_discount' == $typenow ) {
172
+    if ('wpi_discount' == $typenow) {
173 173
         wpinv_discount_filters();
174 174
     }
175 175
 }
176
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
176
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
177 177
 
178 178
 function wpinv_discount_filters() {
179
-    echo wpinv_discount_bulk_actions( array(), true );
179
+    echo wpinv_discount_bulk_actions(array(), true);
180 180
     
181 181
     ?>
182 182
     <select name="discount_type" id="dropdown_wpinv_discount_type">
183
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
183
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
184 184
         <?php
185 185
             $types = wpinv_get_discount_types();
186 186
 
187
-            foreach ( $types as $name => $type ) {
188
-                echo '<option value="' . esc_attr( $name ) . '"';
187
+            foreach ($types as $name => $type) {
188
+                echo '<option value="' . esc_attr($name) . '"';
189 189
 
190
-                if ( isset( $_GET['discount_type'] ) )
191
-                    selected( $name, $_GET['discount_type'] );
190
+                if (isset($_GET['discount_type']))
191
+                    selected($name, $_GET['discount_type']);
192 192
 
193
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
193
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
194 194
             }
195 195
         ?>
196 196
     </select>
197 197
     <?php
198 198
 }
199 199
 
200
-function wpinv_request( $vars ) {
200
+function wpinv_request($vars) {
201 201
     global $typenow, $wp_query, $wp_post_statuses;
202 202
 
203
-    if ( 'wpi_invoice' === $typenow ) {
204
-        if ( !isset( $vars['post_status'] ) ) {
203
+    if ('wpi_invoice' === $typenow) {
204
+        if (!isset($vars['post_status'])) {
205 205
             $post_statuses = wpinv_get_invoice_statuses();
206 206
 
207
-            foreach ( $post_statuses as $status => $value ) {
208
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
209
-                    unset( $post_statuses[ $status ] );
207
+            foreach ($post_statuses as $status => $value) {
208
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
209
+                    unset($post_statuses[$status]);
210 210
                 }
211 211
             }
212 212
 
213
-            $vars['post_status'] = array_keys( $post_statuses );
213
+            $vars['post_status'] = array_keys($post_statuses);
214 214
         }
215 215
         
216
-        if ( isset( $vars['orderby'] ) ) {
217
-            if ( 'amount' == $vars['orderby'] ) {
216
+        if (isset($vars['orderby'])) {
217
+            if ('amount' == $vars['orderby']) {
218 218
                 $vars = array_merge(
219 219
                     $vars,
220 220
                     array(
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                         'orderby'  => 'meta_value_num'
223 223
                     )
224 224
                 );
225
-            } else if ( 'customer' == $vars['orderby'] ) {
225
+            } else if ('customer' == $vars['orderby']) {
226 226
                 $vars = array_merge(
227 227
                     $vars,
228 228
                     array(
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                         'orderby'  => 'meta_value'
231 231
                     )
232 232
                 );
233
-            } else if ( 'number' == $vars['orderby'] ) {
233
+            } else if ('number' == $vars['orderby']) {
234 234
                 $vars = array_merge(
235 235
                     $vars,
236 236
                     array(
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                         'orderby'  => 'meta_value'
239 239
                     )
240 240
                 );
241
-            } else if ( 'payment_date' == $vars['orderby'] ) {
241
+            } else if ('payment_date' == $vars['orderby']) {
242 242
                 $vars = array_merge(
243 243
                     $vars,
244 244
                     array(
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
                 );
249 249
             }
250 250
         }
251
-    } else if ( 'wpi_item' == $typenow ) {
251
+    } else if ('wpi_item' == $typenow) {
252 252
         // Check if 'orderby' is set to "price"
253
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
253
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
254 254
             $vars = array_merge(
255 255
                 $vars,
256 256
                 array(
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         }
262 262
 
263 263
         // Check if "orderby" is set to "vat_rule"
264
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
264
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
265 265
             $vars = array_merge(
266 266
                 $vars,
267 267
                 array(
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         }
273 273
 
274 274
         // Check if "orderby" is set to "vat_class"
275
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
275
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
276 276
             $vars = array_merge(
277 277
                 $vars,
278 278
                 array(
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         }
284 284
         
285 285
         // Check if "orderby" is set to "type"
286
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
286
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
287 287
             $vars = array_merge(
288 288
                 $vars,
289 289
                 array(
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
         }
295 295
         
296 296
         // Check if "orderby" is set to "recurring"
297
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
297
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
298 298
             $vars = array_merge(
299 299
                 $vars,
300 300
                 array(
@@ -304,104 +304,104 @@  discard block
 block discarded – undo
304 304
             );
305 305
         }
306 306
 
307
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
307
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
308 308
         // Filter vat rule type
309
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
309
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
310 310
             $meta_query[] = array(
311 311
                     'key'   => '_wpinv_vat_rule',
312
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
312
+                    'value' => sanitize_text_field($_GET['vat_rule']),
313 313
                     'compare' => '='
314 314
                 );
315 315
         }
316 316
         
317 317
         // Filter vat class
318
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
318
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
319 319
             $meta_query[] = array(
320 320
                     'key'   => '_wpinv_vat_class',
321
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
321
+                    'value' => sanitize_text_field($_GET['vat_class']),
322 322
                     'compare' => '='
323 323
                 );
324 324
         }
325 325
         
326 326
         // Filter item type
327
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
327
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
328 328
             $meta_query[] = array(
329 329
                     'key'   => '_wpinv_type',
330
-                    'value' => sanitize_text_field( $_GET['type'] ),
330
+                    'value' => sanitize_text_field($_GET['type']),
331 331
                     'compare' => '='
332 332
                 );
333 333
         }
334 334
         
335
-        if ( !empty( $meta_query ) ) {
335
+        if (!empty($meta_query)) {
336 336
             $vars['meta_query'] = $meta_query;
337 337
         }
338
-    } else if ( 'wpi_discount' == $typenow ) {
339
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
338
+    } else if ('wpi_discount' == $typenow) {
339
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
340 340
         // Filter vat rule type
341
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
341
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
342 342
             $meta_query[] = array(
343 343
                     'key'   => '_wpi_discount_type',
344
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
344
+                    'value' => sanitize_text_field($_GET['discount_type']),
345 345
                     'compare' => '='
346 346
                 );
347 347
         }
348 348
         
349
-        if ( !empty( $meta_query ) ) {
349
+        if (!empty($meta_query)) {
350 350
             $vars['meta_query'] = $meta_query;
351 351
         }
352 352
     }
353 353
 
354 354
     return $vars;
355 355
 }
356
-add_filter( 'request', 'wpinv_request' );
356
+add_filter('request', 'wpinv_request');
357 357
 
358
-function wpinv_item_type_class( $classes, $class, $post_id ) {
358
+function wpinv_item_type_class($classes, $class, $post_id) {
359 359
     global $pagenow, $typenow;
360 360
 
361
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
362
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
363
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
361
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
362
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
363
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
364 364
         }
365 365
         
366
-        if ( !wpinv_item_is_editable( $post_id ) ) {
366
+        if (!wpinv_item_is_editable($post_id)) {
367 367
             $classes[] = 'wpi-editable-n';
368 368
         }
369 369
     }
370 370
     return $classes;
371 371
 }
372
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
372
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
373 373
 
374 374
 function wpinv_check_quick_edit() {
375 375
     global $pagenow, $current_screen, $wpinv_item_screen;
376 376
 
377
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
378
-        if ( empty( $wpinv_item_screen ) ) {
379
-            if ( $current_screen->post_type == 'wpi_item' ) {
377
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
378
+        if (empty($wpinv_item_screen)) {
379
+            if ($current_screen->post_type == 'wpi_item') {
380 380
                 $wpinv_item_screen = 'y';
381 381
             } else {
382 382
                 $wpinv_item_screen = 'n';
383 383
             }
384 384
         }
385 385
 
386
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
387
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
388
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
386
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
387
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
388
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
389 389
         }
390 390
     }
391 391
 }
392
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
392
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
393 393
 
394
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
395
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
396
-        unset( $actions['inline hide-if-no-js'] );
394
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
395
+    if (isset($actions['inline hide-if-no-js'])) {
396
+        unset($actions['inline hide-if-no-js']);
397 397
     }
398 398
     
399
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
400
-        if ( isset( $actions['trash'] ) ) {
401
-            unset( $actions['trash'] );
399
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
400
+        if (isset($actions['trash'])) {
401
+            unset($actions['trash']);
402 402
         }
403
-        if ( isset( $actions['delete'] ) ) {
404
-            unset( $actions['delete'] );
403
+        if (isset($actions['delete'])) {
404
+            unset($actions['delete']);
405 405
         }
406 406
     }
407 407
 
@@ -418,19 +418,19 @@  discard block
 block discarded – undo
418 418
  * @param int $post_parent (default: 0) Parent for the new page
419 419
  * @return int page ID
420 420
  */
421
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
421
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
422 422
     global $wpdb;
423 423
 
424
-    $option_value = wpinv_get_option( $option );
424
+    $option_value = wpinv_get_option($option);
425 425
 
426
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
427
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
426
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
427
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
428 428
             // Valid page is already in place
429 429
             return $page_object->ID;
430 430
         }
431 431
     }
432 432
 
433
-    if(!empty($post_parent)){
433
+    if (!empty($post_parent)) {
434 434
         $page = get_page_by_path($post_parent);
435 435
         if ($page) {
436 436
             $post_parent = $page->ID;
@@ -439,40 +439,40 @@  discard block
 block discarded – undo
439 439
         }
440 440
     }
441 441
 
442
-    if ( strlen( $page_content ) > 0 ) {
442
+    if (strlen($page_content) > 0) {
443 443
         // Search for an existing page with the specified page content (typically a shortcode)
444
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
444
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
445 445
     } else {
446 446
         // Search for an existing page with the specified page slug
447
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
447
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
448 448
     }
449 449
 
450
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
450
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
451 451
 
452
-    if ( $valid_page_found ) {
453
-        if ( $option ) {
454
-            wpinv_update_option( $option, $valid_page_found );
452
+    if ($valid_page_found) {
453
+        if ($option) {
454
+            wpinv_update_option($option, $valid_page_found);
455 455
         }
456 456
         return $valid_page_found;
457 457
     }
458 458
 
459 459
     // Search for a matching valid trashed page
460
-    if ( strlen( $page_content ) > 0 ) {
460
+    if (strlen($page_content) > 0) {
461 461
         // Search for an existing page with the specified page content (typically a shortcode)
462
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
462
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
463 463
     } else {
464 464
         // Search for an existing page with the specified page slug
465
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
465
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
466 466
     }
467 467
 
468
-    if ( $trashed_page_found ) {
468
+    if ($trashed_page_found) {
469 469
         $page_id   = $trashed_page_found;
470 470
         $page_data = array(
471 471
             'ID'             => $page_id,
472 472
             'post_status'    => 'publish',
473 473
             'post_parent'    => $post_parent,
474 474
         );
475
-        wp_update_post( $page_data );
475
+        wp_update_post($page_data);
476 476
     } else {
477 477
         $page_data = array(
478 478
             'post_status'    => 'publish',
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
             'post_parent'    => $post_parent,
485 485
             'comment_status' => 'closed',
486 486
         );
487
-        $page_id = wp_insert_post( $page_data );
487
+        $page_id = wp_insert_post($page_data);
488 488
     }
489 489
 
490
-    if ( $option ) {
491
-        wpinv_update_option( $option, (int)$page_id );
490
+    if ($option) {
491
+        wpinv_update_option($option, (int) $page_id);
492 492
     }
493 493
 
494 494
     return $page_id;
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@  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_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
    
28
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
29
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
30
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
28
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
29
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
30
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
31 31
 
32 32
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
33 33
 }
34
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
34
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
35 35
 
36
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
37
-    remove_action( 'save_post', __FUNCTION__ );
36
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
37
+    remove_action('save_post', __FUNCTION__);
38 38
     
39 39
     // $post_id and $post are required
40
-    if ( empty( $post_id ) || empty( $post ) ) {
40
+    if (empty($post_id) || empty($post)) {
41 41
         return;
42 42
     }
43 43
         
44
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
44
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
45 45
         return;
46 46
     }
47 47
     
48 48
     // Dont' save meta boxes for revisions or autosaves
49
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
49
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
50 50
         return;
51 51
     }
52 52
         
53
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
54
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
53
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
54
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
55 55
             return;
56 56
         }
57 57
     
58
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
59
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
58
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
59
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
60 60
         }
61
-    } else if ( $post->post_type == 'wpi_item' ) {
61
+    } else if ($post->post_type == 'wpi_item') {
62 62
         // verify nonce
63
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
64
-            $fields                                 = array();
63
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
64
+            $fields = array();
65 65
             $fields['_wpinv_price']              = 'wpinv_item_price';
66 66
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
67 67
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -76,96 +76,96 @@  discard block
 block discarded – undo
76 76
             $fields['_wpinv_dynamic_pricing']    = 'wpinv_name_your_price';
77 77
             $fields['_minimum_price']            = 'wpinv_minimum_price';
78 78
             
79
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
79
+            if (!isset($_POST['wpinv_is_recurring'])) {
80 80
                 $_POST['wpinv_is_recurring'] = 0;
81 81
             }
82 82
 
83
-            if ( !isset( $_POST['wpinv_name_your_price'] ) ) {
83
+            if (!isset($_POST['wpinv_name_your_price'])) {
84 84
                 $_POST['wpinv_name_your_price'] = 0;
85 85
             }
86 86
             
87
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
87
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
88 88
                 $_POST['wpinv_free_trial'] = 0;
89 89
             }
90 90
             
91
-            foreach ( $fields as $field => $name ) {
92
-                if ( isset( $_POST[ $name ] ) ) {
93
-                    $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id );
91
+            foreach ($fields as $field => $name) {
92
+                if (isset($_POST[$name])) {
93
+                    $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id);
94 94
 
95
-                    if ( !$allowed ) {
95
+                    if (!$allowed) {
96 96
                         continue;
97 97
                     }
98 98
 
99
-                    if ( $field == '_wpinv_price' ) {
100
-                        $value = wpinv_sanitize_amount( $_POST[ $name ] );
99
+                    if ($field == '_wpinv_price') {
100
+                        $value = wpinv_sanitize_amount($_POST[$name]);
101 101
                     } else {
102
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
102
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
103 103
                     }
104 104
                     
105
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
106
-                    update_post_meta( $post_id, $field, $value );
105
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
106
+                    update_post_meta($post_id, $field, $value);
107 107
                 }
108 108
             }
109 109
             
110
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
111
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
110
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
111
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
112 112
             }
113 113
         }
114 114
     }
115 115
 }
116
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
116
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
117 117
 
118 118
 function wpinv_register_item_meta_boxes() {    
119 119
     global $wpinv_euvat;
120 120
     
121
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
121
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
122 122
 
123
-    if ( $wpinv_euvat->allow_vat_rules() ) {
124
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
123
+    if ($wpinv_euvat->allow_vat_rules()) {
124
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
125 125
     }
126 126
     
127
-    if ( $wpinv_euvat->allow_vat_classes() ) {
128
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
127
+    if ($wpinv_euvat->allow_vat_classes()) {
128
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
129 129
     }
130 130
     
131
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
132
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
131
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
132
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
133 133
 }
134 134
 
135 135
 function wpinv_register_discount_meta_boxes() {
136
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
136
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
137 137
 }
138 138
 
139
-function wpinv_discount_metabox_details( $post ) {
139
+function wpinv_discount_metabox_details($post) {
140 140
     $discount_id    = $post->ID;
141
-    $discount       = wpinv_get_discount( $discount_id );
141
+    $discount       = wpinv_get_discount($discount_id);
142 142
     
143
-    $type               = wpinv_get_discount_type( $discount_id );
144
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
145
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
146
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
147
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
148
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
149
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
150
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
151
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
152
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
143
+    $type               = wpinv_get_discount_type($discount_id);
144
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
145
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
146
+    $min_total          = wpinv_get_discount_min_total($discount_id);
147
+    $max_total          = wpinv_get_discount_max_total($discount_id);
148
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
149
+    $single_use         = wpinv_discount_is_single_use($discount_id);
150
+    $recurring          = (bool) wpinv_discount_is_recurring($discount_id);
151
+    $start_date         = wpinv_get_discount_start_date($discount_id);
152
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
153 153
     
154
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
155
-        $start_time         = strtotime( $start_date );
156
-        $start_h            = date_i18n( 'H', $start_time );
157
-        $start_m            = date_i18n( 'i', $start_time );
158
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
154
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
155
+        $start_time         = strtotime($start_date);
156
+        $start_h            = date_i18n('H', $start_time);
157
+        $start_m            = date_i18n('i', $start_time);
158
+        $start_date         = date_i18n('Y-m-d', $start_time);
159 159
     } else {
160 160
         $start_h            = '00';
161 161
         $start_m            = '00';
162 162
     }
163 163
 
164
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
165
-        $expiration_time    = strtotime( $expiration_date );
166
-        $expiration_h       = date_i18n( 'H', $expiration_time );
167
-        $expiration_m       = date_i18n( 'i', $expiration_time );
168
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
164
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
165
+        $expiration_time    = strtotime($expiration_date);
166
+        $expiration_h       = date_i18n('H', $expiration_time);
167
+        $expiration_m       = date_i18n('i', $expiration_time);
168
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
169 169
     } else {
170 170
         $expiration_h       = '23';
171 171
         $expiration_m       = '59';
@@ -175,207 +175,207 @@  discard block
 block discarded – undo
175 175
     $max_total          = $max_total > 0 ? $max_total : '';
176 176
     $max_uses           = $max_uses > 0 ? $max_uses : '';
177 177
 ?>
178
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
179
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
178
+<?php do_action('wpinv_discount_form_top', $post); ?>
179
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
180 180
 <table class="form-table wpi-form-table">
181 181
     <tbody>
182
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
183
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
182
+        <?php do_action('wpinv_discount_form_first', $post); ?>
183
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
184 184
         <tr>
185 185
             <th valign="top" scope="row">
186
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
186
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
187 187
             </th>
188 188
             <td>
189
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
190
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
189
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
190
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
191 191
             </td>
192 192
         </tr>
193
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
193
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
194 194
         <tr>
195 195
             <th valign="top" scope="row">
196
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
196
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
197 197
             </th>
198 198
             <td>
199 199
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
200
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
201
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
200
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
201
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
202 202
                     <?php } ?>
203 203
                 </select>
204
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
204
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
205 205
             </td>
206 206
         </tr>
207
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
207
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
208 208
         <tr>
209 209
             <th valign="top" scope="row">
210
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
210
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
211 211
             </th>
212 212
             <td>
213
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
214
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
215
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
213
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
214
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
215
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
216 216
             </td>
217 217
         </tr>
218
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
218
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
219 219
         <tr>
220 220
             <th valign="top" scope="row">
221
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
221
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
222 222
             </th>
223 223
             <td>
224
-                <p><?php echo wpinv_item_dropdown( array(
224
+                <p><?php echo wpinv_item_dropdown(array(
225 225
                         'name'              => 'items[]',
226 226
                         'id'                => 'items',
227 227
                         'selected'          => $item_reqs,
228 228
                         'multiple'          => true,
229 229
                         'class'             => 'medium-text wpi_select2',
230
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
230
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
231 231
                         'show_recurring'    => true,
232
-                    ) ); ?>
232
+                    )); ?>
233 233
                 </p>
234
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
234
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
235 235
             </td>
236 236
         </tr>
237
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
237
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
238 238
         <tr>
239 239
             <th valign="top" scope="row">
240
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
240
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
241 241
             </th>
242 242
             <td>
243
-                <p><?php echo wpinv_item_dropdown( array(
243
+                <p><?php echo wpinv_item_dropdown(array(
244 244
                         'name'              => 'excluded_items[]',
245 245
                         'id'                => 'excluded_items',
246 246
                         'selected'          => $excluded_items,
247 247
                         'multiple'          => true,
248 248
                         'class'             => 'medium-text wpi_select2',
249
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
249
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
250 250
                         'show_recurring'    => true,
251
-                    ) ); ?>
251
+                    )); ?>
252 252
                 </p>
253
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
253
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
254 254
             </td>
255 255
         </tr>
256
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
256
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
257 257
         <tr>
258 258
             <th valign="top" scope="row">
259
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
259
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
260 260
             </th>
261 261
             <td>
262
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
263
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
264
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
262
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
263
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
264
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
265 265
                     <?php } ?>
266 266
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
267
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
268
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
267
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
268
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
269 269
                     <?php } ?>
270 270
                 </select>
271
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
271
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
272 272
             </td>
273 273
         </tr>
274
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
274
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
275 275
         <tr>
276 276
             <th valign="top" scope="row">
277
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
277
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
278 278
             </th>
279 279
             <td>
280
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
281
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
282
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
280
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
281
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
282
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
283 283
                     <?php } ?>
284 284
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
285
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
286
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
285
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
286
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
287 287
                     <?php } ?>
288 288
                 </select>
289
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
289
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
290 290
             </td>
291 291
         </tr>
292
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
292
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
293 293
         <tr>
294 294
             <th valign="top" scope="row">
295
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
295
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
296 296
             </th>
297 297
             <td>
298 298
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
299
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
299
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
300 300
             </td>
301 301
         </tr>
302
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
302
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
303 303
         <tr>
304 304
             <th valign="top" scope="row">
305
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
305
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
306 306
             </th>
307 307
             <td>
308 308
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
309
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
309
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
310 310
             </td>
311 311
         </tr>
312
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
312
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
313 313
         <tr>
314 314
             <th valign="top" scope="row">
315
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
315
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
316 316
             </th>
317 317
             <td>
318 318
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
319
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
320
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
319
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
320
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
321 321
                 </select>
322
-                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
322
+                <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
323 323
             </td>
324 324
         </tr>
325
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
325
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
326 326
         <tr>
327 327
             <th valign="top" scope="row">
328
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
328
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
329 329
             </th>
330 330
             <td>
331 331
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
332
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
332
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
333 333
             </td>
334 334
         </tr>
335
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
335
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
336 336
         <tr>
337 337
             <th valign="top" scope="row">
338
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
338
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
339 339
             </th>
340 340
             <td>
341
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
342
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
341
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
342
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
343 343
             </td>
344 344
         </tr>
345
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
345
+        <?php do_action('wpinv_discount_form_last', $post); ?>
346 346
     </tbody>
347 347
 </table>
348
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
348
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
349 349
     <?php
350 350
 }
351 351
 
352
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
353
-    $post_type = !empty( $post ) ? $post->post_type : '';
352
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
353
+    $post_type = !empty($post) ? $post->post_type : '';
354 354
     
355
-    if ( $post_type != 'wpi_discount' ) {
355
+    if ($post_type != 'wpi_discount') {
356 356
         return;
357 357
     }
358 358
     
359
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
359
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
360 360
         return;
361 361
     }
362 362
     
363
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
363
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
364 364
         return;
365 365
     }
366 366
     
367
-    if ( !current_user_can( wpinv_get_capability(), $post_id ) ) {
367
+    if (!current_user_can(wpinv_get_capability(), $post_id)) {
368 368
         return;
369 369
     }
370 370
     
371
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
371
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
372 372
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
373 373
     }
374 374
 
375
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
375
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
376 376
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
377 377
     }
378 378
     
379
-    return wpinv_store_discount( $post_id, $_POST, $post, $update );
379
+    return wpinv_store_discount($post_id, $_POST, $post, $update);
380 380
 }
381
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
382 381
\ No newline at end of file
382
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
383 383
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
 
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22
-        if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
22
+        if (!$use_taxes && (float) $invoice->get_tax() > 0) {
23 23
             $use_taxes = true;
24 24
         }
25
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
25
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
26 26
         $is_recurring       = $invoice->is_recurring();
27 27
         $post_type_object   = get_post_type_object($invoice->post_type);
28 28
         $type_title         = $post_type_object->labels->singular_name;
29 29
 
30 30
         $cols = 5;
31
-        if ( $item_quantities ) {
31
+        if ($item_quantities) {
32 32
             $cols++;
33 33
         }
34
-        if ( $use_taxes ) {
34
+        if ($use_taxes) {
35 35
             $cols++;
36 36
         }
37 37
         $class = '';
38
-        if ( $invoice->is_paid() ) {
38
+        if ($invoice->is_paid()) {
39 39
             $class .= ' wpinv-paid';
40 40
         }
41
-        if ( $invoice->is_refunded() ) {
41
+        if ($invoice->is_refunded()) {
42 42
             $class .= ' wpinv-refunded';
43 43
         }
44
-        if ( $is_recurring ) {
44
+        if ($is_recurring) {
45 45
             $class .= ' wpi-recurring';
46 46
         }
47 47
         ?>
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
50 50
                 <thead>
51 51
                     <tr>
52
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
53
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
54
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
55
-                        <?php if ( $item_quantities ) { ?>
56
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
52
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
53
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
54
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
55
+                        <?php if ($item_quantities) { ?>
56
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
57 57
                         <?php } ?>
58
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
59
-                        <?php if ( $use_taxes ) { ?>
60
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
58
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
59
+                        <?php if ($use_taxes) { ?>
60
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
61 61
                         <?php } ?>
62 62
                         <th class="action"></th>
63 63
                     </tr>
64 64
                 </thead>
65 65
                 <tbody class="wpinv-line-items">
66
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
66
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
67 67
                 </tbody>
68 68
                 <tfoot class="wpinv-totals">
69 69
                     <tr>
@@ -74,45 +74,45 @@  discard block
 block discarded – undo
74 74
                                         <td class="id">
75 75
                                         </td>
76 76
                                         <td class="title">
77
-                                            <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]">
78
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
77
+                                            <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]">
78
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
79 79
                                             <div class="wp-clearfix">
80 80
                                                 <label class="wpi-vat-rule">
81
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
81
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
82 82
                                                     <span class="input-text-wrap">
83
-                                                        <?php echo wpinv_html_select( array(
83
+                                                        <?php echo wpinv_html_select(array(
84 84
                                                             'options'          => $wpinv_euvat->get_rules(),
85 85
                                                             'name'             => '_wpinv_quick[vat_rule]',
86 86
                                                             'id'               => '_wpinv_quick_vat_rule',
87 87
                                                             'show_option_all'  => false,
88 88
                                                             'show_option_none' => false,
89 89
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2',
90
-                                                        ) ); ?>
90
+                                                        )); ?>
91 91
                                                     </span>
92 92
                                                 </label>
93 93
                                             </div>
94
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
94
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
95 95
                                             <div class="wp-clearfix">
96 96
                                                 <label class="wpi-vat-class">
97
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
97
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
98 98
                                                     <span class="input-text-wrap">
99
-                                                        <?php echo wpinv_html_select( array(
99
+                                                        <?php echo wpinv_html_select(array(
100 100
                                                             'options'          => $wpinv_euvat->get_all_classes(),
101 101
                                                             'name'             => '_wpinv_quick[vat_class]',
102 102
                                                             'id'               => '_wpinv_quick_vat_class',
103 103
                                                             'show_option_all'  => false,
104 104
                                                             'show_option_none' => false,
105 105
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2',
106
-                                                        ) ); ?>
106
+                                                        )); ?>
107 107
                                                     </span>
108 108
                                                 </label>
109 109
                                             </div>
110 110
                                             <?php } ?>
111 111
                                             <div class="wp-clearfix">
112 112
                                                 <label class="wpi-item-type">
113
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
113
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
114 114
                                                     <span class="input-text-wrap">
115
-                                                        <?php echo wpinv_html_select( array(
115
+                                                        <?php echo wpinv_html_select(array(
116 116
                                                             'options'          => $item_types,
117 117
                                                             'name'             => '_wpinv_quick[type]',
118 118
                                                             'id'               => '_wpinv_quick_type',
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
                                                             'show_option_all'  => false,
121 121
                                                             'show_option_none' => false,
122 122
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type wpi_select2',
123
-                                                        ) ); ?>
123
+                                                        )); ?>
124 124
                                                     </span>
125 125
                                                 </label>
126 126
                                             </div>
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
                                             </div>
134 134
                                         </td>
135 135
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
136
-                                        <?php if ( $item_quantities ) { ?>
136
+                                        <?php if ($item_quantities) { ?>
137 137
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
138 138
                                         <?php } ?>
139 139
                                         <td class="total"></td>
140
-                                        <?php if ( $use_taxes ) { ?>
140
+                                        <?php if ($use_taxes) { ?>
141 141
                                         <td class="tax"></td>
142 142
                                         <?php } ?>
143 143
                                         <td class="action"></td>
@@ -150,29 +150,29 @@  discard block
 block discarded – undo
150 150
                         <td colspan="<?php echo $cols; ?>"></td>
151 151
                     </tr>
152 152
                     <tr class="totals">
153
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
153
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
154 154
                         <td colspan="4">
155 155
                             <table cellspacing="0" cellpadding="0">
156 156
                                 <tr class="subtotal">
157
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
158
-                                    <td class="total"><?php echo $subtotal;?></td>
157
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
158
+                                    <td class="total"><?php echo $subtotal; ?></td>
159 159
                                     <td class="action"></td>
160 160
                                 </tr>
161 161
                                 <tr class="discount">
162
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
163
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
162
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
163
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
164 164
                                     <td class="action"></td>
165 165
                                 </tr>
166
-                                <?php if ( $use_taxes ) { ?>
166
+                                <?php if ($use_taxes) { ?>
167 167
                                 <tr class="tax">
168
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
169
-                                    <td class="total"><?php echo $tax;?></td>
168
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
169
+                                    <td class="total"><?php echo $tax; ?></td>
170 170
                                     <td class="action"></td>
171 171
                                 </tr>
172 172
                                 <?php } ?>
173 173
                                 <tr class="total">
174
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
175
-                                    <td class="total"><?php echo $total;?></td>
174
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
175
+                                    <td class="total"><?php echo $total; ?></td>
176 176
                                     <td class="action"></td>
177 177
                                 </tr>
178 178
                             </table>
@@ -183,90 +183,90 @@  discard block
 block discarded – undo
183 183
             <div class="wpinv-actions">
184 184
                 <?php ob_start(); ?>
185 185
                 <?php
186
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
187
-                        if ( !$invoice->is_recurring() ) {
188
-                            echo wpinv_item_dropdown( array(
186
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
187
+                        if (!$invoice->is_recurring()) {
188
+                            echo wpinv_item_dropdown(array(
189 189
                                 'name'             => 'wpinv_invoice_item',
190 190
                                 'id'               => 'wpinv_invoice_item',
191 191
                                 'show_recurring'   => true,
192 192
                                 'class'            => 'wpi_select2',
193
-                            ) );
193
+                            ));
194 194
                     ?>
195
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
195
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
196 196
                     <?php } ?>
197
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
198
-                <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?>
197
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
198
+                <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?>
199 199
             </div>
200 200
         </div>
201 201
         <?php
202 202
     }
203 203
 
204
-    public static function prices( $post ) {        
204
+    public static function prices($post) {        
205 205
         $symbol         = wpinv_currency_symbol();
206 206
         $position       = wpinv_currency_position();
207
-        $item           = new WPInv_Item( $post->ID );
207
+        $item           = new WPInv_Item($post->ID);
208 208
 
209 209
         $price                = $item->get_price();
210 210
         $is_dynamic_pricing   = $item->get_is_dynamic_pricing();
211 211
         $minimum_price        = $item->get_minimum_price();
212 212
         $is_recurring         = $item->is_recurring();
213 213
         $period               = $item->get_recurring_period();
214
-        $interval             = absint( $item->get_recurring_interval() );
215
-        $times                = absint( $item->get_recurring_limit() );
214
+        $interval             = absint($item->get_recurring_interval());
215
+        $times                = absint($item->get_recurring_limit());
216 216
         $free_trial           = $item->has_free_trial();
217 217
         $trial_interval       = $item->get_trial_interval();
218 218
         $trial_period         = $item->get_trial_period();
219 219
 
220 220
         $intervals            = array();
221
-        for ( $i = 1; $i <= 90; $i++ ) {
221
+        for ($i = 1; $i <= 90; $i++) {
222 222
             $intervals[$i] = $i;
223 223
         }
224 224
 
225
-        $interval       = $interval > 0 ? $interval : 1;
225
+        $interval = $interval > 0 ? $interval : 1;
226 226
 
227 227
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
228 228
 
229 229
         $minimum_price_style = 'margin-left: 24px;';
230
-        if(! $is_dynamic_pricing ) {
230
+        if (!$is_dynamic_pricing) {
231 231
             $minimum_price_style .= 'display: none;';
232 232
         }
233 233
 
234 234
         ?>
235
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
236
-        <?php do_action( 'wpinv_prices_metabox_price', $item ); ?>
235
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
236
+        <?php do_action('wpinv_prices_metabox_price', $item); ?>
237 237
         </p>
238 238
 
239
-    <?php if( $item->supports_dynamic_pricing() ) { ?>
239
+    <?php if ($item->supports_dynamic_pricing()) { ?>
240 240
 
241 241
         <p class="wpinv-row-name-your-price">
242 242
             <label>
243
-                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked( 1, $is_dynamic_pricing ); ?> />
244
-                <?php echo apply_filters( 'wpinv_name_your_price_toggle_text', __( 'User can set a custom price', 'invoicing' ) ); ?>
243
+                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked(1, $is_dynamic_pricing); ?> />
244
+                <?php echo apply_filters('wpinv_name_your_price_toggle_text', __('User can set a custom price', 'invoicing')); ?>
245 245
             </label>
246
-            <?php do_action( 'wpinv_prices_metabox_name_your_price_field', $item ); ?>
246
+            <?php do_action('wpinv_prices_metabox_name_your_price_field', $item); ?>
247 247
         </p>
248 248
 
249 249
         <p class="wpinv-row-minimum-price" style="<?php echo $minimum_price_style; ?>">
250 250
             <label>
251
-                <?php _e( 'Minimum Price', 'invoicing' ); ?>
252
-                <?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $minimum_price;?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?>
251
+                <?php _e('Minimum Price', 'invoicing'); ?>
252
+                <?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $minimum_price; ?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?>
253 253
             </label>
254 254
 
255
-            <?php do_action( 'wpinv_prices_metabox_minimum_price_field', $item ); ?>
255
+            <?php do_action('wpinv_prices_metabox_minimum_price_field', $item); ?>
256 256
         </p>
257 257
 
258 258
     <?php } ?>
259 259
 
260 260
         <p class="wpinv-row-is-recurring">
261 261
             <label for="wpinv_is_recurring">
262
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
263
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
262
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
263
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
264 264
             </label>
265
-            <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?>
265
+            <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?>
266 266
         </p>
267
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
268
-            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
269
-            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
267
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
268
+            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
269
+            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
270 270
                 'options'          => $intervals,
271 271
                 'name'             => 'wpinv_recurring_interval',
272 272
                 'id'               => 'wpinv_recurring_interval',
@@ -274,30 +274,30 @@  discard block
 block discarded – undo
274 274
                 'show_option_all'  => false,
275 275
                 'show_option_none' => false,
276 276
                 'class'            => 'wpi_select2',
277
-            ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
278
-            <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
277
+            )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
278
+            <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
279 279
             <span class="clear wpi-trial-clr"></span>
280 280
             <label class="wpinv-free-trial" for="wpinv_free_trial">
281
-                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
282
-                <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
281
+                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool) $free_trial); ?> /> 
282
+                <?php echo __('Offer free trial for', 'invoicing'); ?>
283 283
             </label>
284 284
             <label class="wpinv-trial-interval" for="wpinv_trial_interval">
285
-                <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
285
+                <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select wpi_select2" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
286 286
             </label>
287
-            <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?>
287
+            <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?>
288 288
         </p>
289
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
290
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
289
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
290
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
291 291
         <?php
292 292
     }
293 293
 
294
-    public static function vat_rules( $post ) {
294
+    public static function vat_rules($post) {
295 295
         global $wpinv_euvat;
296 296
 
297
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
297
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
298 298
         ?>
299
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
300
-        <?php echo wpinv_html_select( array(
299
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
300
+        <?php echo wpinv_html_select(array(
301 301
                     'options'          => $wpinv_euvat->get_rules(),
302 302
                     'name'             => 'wpinv_vat_rules',
303 303
                     'id'               => 'wpinv_vat_rules',
@@ -305,19 +305,19 @@  discard block
 block discarded – undo
305 305
                     'show_option_all'  => false,
306 306
                     'show_option_none' => false,
307 307
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2',
308
-                ) ); ?>
308
+                )); ?>
309 309
         </p>
310
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
311
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
310
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
311
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
312 312
         <?php
313 313
     }
314 314
 
315
-    public static function vat_classes( $post ) {
315
+    public static function vat_classes($post) {
316 316
         global $wpinv_euvat;
317 317
         
318
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
318
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
319 319
         ?>
320
-        <p><?php echo wpinv_html_select( array(
320
+        <p><?php echo wpinv_html_select(array(
321 321
                     'options'          => $wpinv_euvat->get_all_classes(),
322 322
                     'name'             => 'wpinv_vat_class',
323 323
                     'id'               => 'wpinv_vat_class',
@@ -325,18 +325,18 @@  discard block
 block discarded – undo
325 325
                     'show_option_all'  => false,
326 326
                     'show_option_none' => false,
327 327
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class wpi_select2',
328
-                ) ); ?>
328
+                )); ?>
329 329
         </p>
330
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
330
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
331 331
         <?php
332 332
     }
333 333
 
334
-    public static function item_info( $post ) {
335
-        $item_type = wpinv_get_item_type( $post->ID );
336
-        do_action( 'wpinv_item_info_metabox_before', $post );
334
+    public static function item_info($post) {
335
+        $item_type = wpinv_get_item_type($post->ID);
336
+        do_action('wpinv_item_info_metabox_before', $post);
337 337
         ?>
338
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
339
-        <?php echo wpinv_html_select( array(
338
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
339
+        <?php echo wpinv_html_select(array(
340 340
                     'options'          => wpinv_get_item_types(),
341 341
                     'name'             => 'wpinv_item_type',
342 342
                     'id'               => 'wpinv_item_type',
@@ -344,114 +344,114 @@  discard block
 block discarded – undo
344 344
                     'show_option_all'  => false,
345 345
                     'show_option_none' => false,
346 346
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
347
-                ) ); ?>
347
+                )); ?>
348 348
         </p>
349
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
349
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
350 350
         <?php
351
-        do_action( 'wpinv_item_info_metabox_after', $post );
351
+        do_action('wpinv_item_info_metabox_after', $post);
352 352
     }
353 353
 
354
-    public static function meta_values( $post ) {
355
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
354
+    public static function meta_values($post) {
355
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
356 356
             'type',
357 357
             'custom_id'
358
-        ) );
358
+        ));
359 359
 
360
-        if ( empty( $meta_keys ) ) {
360
+        if (empty($meta_keys)) {
361 361
             return;
362 362
         }
363 363
 
364
-        do_action( 'wpinv_meta_values_metabox_before', $post );
364
+        do_action('wpinv_meta_values_metabox_before', $post);
365 365
 
366
-        foreach ( $meta_keys as $meta_key ) {
366
+        foreach ($meta_keys as $meta_key) {
367 367
             ?>
368
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
368
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
369 369
             <?php 
370 370
         }
371 371
 
372
-        do_action( 'wpinv_meta_values_metabox_after', $post );
372
+        do_action('wpinv_meta_values_metabox_after', $post);
373 373
     }
374 374
 
375
-    public static function save( $post_id, $data, $post ) {
376
-        $invoice        = new WPInv_Invoice( $post_id );
375
+    public static function save($post_id, $data, $post) {
376
+        $invoice        = new WPInv_Invoice($post_id);
377 377
 
378 378
         // Billing
379
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
380
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
381
-        $company        = sanitize_text_field( $data['wpinv_company'] );
382
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
383
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
384
-        $address        = sanitize_text_field( $data['wpinv_address'] );
385
-        $city           = sanitize_text_field( $data['wpinv_city'] );
386
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
387
-        $country        = sanitize_text_field( $data['wpinv_country'] );
388
-        $state          = sanitize_text_field( $data['wpinv_state'] );
379
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
380
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
381
+        $company        = sanitize_text_field($data['wpinv_company']);
382
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
383
+        $phone          = sanitize_text_field($data['wpinv_phone']);
384
+        $address        = sanitize_text_field($data['wpinv_address']);
385
+        $city           = sanitize_text_field($data['wpinv_city']);
386
+        $zip            = sanitize_text_field($data['wpinv_zip']);
387
+        $country        = sanitize_text_field($data['wpinv_country']);
388
+        $state          = sanitize_text_field($data['wpinv_state']);
389 389
 
390 390
         // Details
391
-        $status         = sanitize_text_field( $data['wpinv_status'] );
392
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
393
-        $number         = sanitize_text_field( $data['wpinv_number'] );
394
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
391
+        $status         = sanitize_text_field($data['wpinv_status']);
392
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
393
+        $number         = sanitize_text_field($data['wpinv_number']);
394
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
395 395
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
396 396
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
397 397
 
398
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
399
-
400
-        $invoice->set( 'due_date', $due_date );
401
-        $invoice->set( 'first_name', $first_name );
402
-        $invoice->set( 'last_name', $last_name );
403
-        $invoice->set( 'company', $company );
404
-        $invoice->set( 'vat_number', $vat_number );
405
-        $invoice->set( 'phone', $phone );
406
-        $invoice->set( 'address', $address );
407
-        $invoice->set( 'city', $city );
408
-        $invoice->set( 'zip', $zip );
409
-        $invoice->set( 'country', $country );
410
-        $invoice->set( 'state', $state );
411
-        $invoice->set( 'status', $status );
398
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
399
+
400
+        $invoice->set('due_date', $due_date);
401
+        $invoice->set('first_name', $first_name);
402
+        $invoice->set('last_name', $last_name);
403
+        $invoice->set('company', $company);
404
+        $invoice->set('vat_number', $vat_number);
405
+        $invoice->set('phone', $phone);
406
+        $invoice->set('address', $address);
407
+        $invoice->set('city', $city);
408
+        $invoice->set('zip', $zip);
409
+        $invoice->set('country', $country);
410
+        $invoice->set('state', $state);
411
+        $invoice->set('status', $status);
412 412
         //$invoice->set( 'number', $number );
413 413
         //$invoice->set( 'discounts', $discounts );
414 414
         //$invoice->set( 'discount', $discount );
415
-        $invoice->set( 'ip', $ip );
415
+        $invoice->set('ip', $ip);
416 416
         $invoice->old_status = $_POST['original_post_status'];
417 417
         $invoice->currency = wpinv_get_currency();
418
-        if ( !empty( $data['wpinv_gateway'] ) ) {
419
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
418
+        if (!empty($data['wpinv_gateway'])) {
419
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
420 420
         }
421 421
         $saved = $invoice->save();
422 422
 
423 423
         // Check for payment notes
424
-        if ( !empty( $data['invoice_note'] ) ) {
425
-            $note               = wp_kses( $data['invoice_note'], array() );
426
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
424
+        if (!empty($data['invoice_note'])) {
425
+            $note               = wp_kses($data['invoice_note'], array());
426
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
427 427
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
428 428
 
429
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
429
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
430 430
         }
431 431
 
432 432
         // Update user address if empty.
433
-        if ( $saved && !empty( $invoice ) ) {
434
-            if ( $user_id = $invoice->get_user_id() ) {
435
-                $user_address = wpinv_get_user_address( $user_id, false );
433
+        if ($saved && !empty($invoice)) {
434
+            if ($user_id = $invoice->get_user_id()) {
435
+                $user_address = wpinv_get_user_address($user_id, false);
436 436
 
437 437
                 if (empty($user_address['first_name'])) {
438
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
439
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
438
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
439
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
440 440
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
441
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
441
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
442 442
                 }
443 443
 
444 444
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
445
-                    update_user_meta( $user_id, '_wpinv_address', $address );
446
-                    update_user_meta( $user_id, '_wpinv_city', $city );
447
-                    update_user_meta( $user_id, '_wpinv_state', $state );
448
-                    update_user_meta( $user_id, '_wpinv_country', $country );
449
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
450
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
445
+                    update_user_meta($user_id, '_wpinv_address', $address);
446
+                    update_user_meta($user_id, '_wpinv_city', $city);
447
+                    update_user_meta($user_id, '_wpinv_state', $state);
448
+                    update_user_meta($user_id, '_wpinv_country', $country);
449
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
450
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
451 451
                 }
452 452
             }
453 453
 
454
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
454
+            do_action('wpinv_invoice_metabox_saved', $invoice);
455 455
         }
456 456
 
457 457
         return $saved;
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -11,49 +11,49 @@  discard block
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
 
16
-    if ( $wpi_version == WPINV_VERSION ) {
16
+    if ($wpi_version == WPINV_VERSION) {
17 17
         return;
18 18
     }
19 19
     
20
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
20
+    if (version_compare($wpi_version, '0.0.5', '<')) {
21 21
         wpinv_v005_upgrades();
22 22
     }
23 23
     
24
-    if ( version_compare( $wpi_version, '1.0.3', '<' ) ) {
24
+    if (version_compare($wpi_version, '1.0.3', '<')) {
25 25
         wpinv_v110_upgrades();
26 26
     }
27 27
     
28
-    update_option( 'wpinv_version', WPINV_VERSION );
28
+    update_option('wpinv_version', WPINV_VERSION);
29 29
 }
30
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
30
+add_action('admin_init', 'wpinv_automatic_upgrade');
31 31
 
32 32
 function wpinv_v005_upgrades() {
33 33
     global $wpdb;
34 34
     
35 35
     // Invoices status
36
-    $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
37
-    if ( !empty( $results ) ) {
38
-        $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
36
+    $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
37
+    if (!empty($results)) {
38
+        $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
39 39
         
40 40
         // Clean post cache
41
-        foreach ( $results as $row ) {
42
-            clean_post_cache( $row->ID );
41
+        foreach ($results as $row) {
42
+            clean_post_cache($row->ID);
43 43
         }
44 44
     }
45 45
     
46 46
     // Item meta key changes
47 47
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
48
-    $results = $wpdb->get_results( $query );
48
+    $results = $wpdb->get_results($query);
49 49
     
50
-    if ( !empty( $results ) ) {
51
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
52
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
53
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
50
+    if (!empty($results)) {
51
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
52
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
53
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
54 54
         
55
-        foreach ( $results as $row ) {
56
-            clean_post_cache( $row->post_id );
55
+        foreach ($results as $row) {
56
+            clean_post_cache($row->post_id);
57 57
         }
58 58
     }
59 59
 
@@ -74,79 +74,79 @@  discard block
 block discarded – undo
74 74
 function wpinv_convert_old_subscriptions() {
75 75
     global $wpdb;
76 76
 
77
-    $query = "SELECT ". $wpdb->posts .".ID FROM ". $wpdb->posts ." INNER JOIN ". $wpdb->postmeta ." ON ( ". $wpdb->posts .".ID = ". $wpdb->postmeta .".post_id ) WHERE 1=1  AND ". $wpdb->postmeta .".meta_key = '_wpinv_subscr_status' AND (". $wpdb->postmeta .".meta_value = 'pending' OR ". $wpdb->postmeta .".meta_value = 'active' OR ". $wpdb->postmeta .".meta_value = 'cancelled' OR ". $wpdb->postmeta .".meta_value = 'completed' OR ". $wpdb->postmeta .".meta_value = 'expired' OR ". $wpdb->postmeta .".meta_value = 'trialling' OR ". $wpdb->postmeta .".meta_value = 'failing') AND ". $wpdb->posts .".post_type = 'wpi_invoice' GROUP BY ". $wpdb->posts .".ID ORDER BY ". $wpdb->posts .".ID ASC";
77
+    $query = "SELECT " . $wpdb->posts . ".ID FROM " . $wpdb->posts . " INNER JOIN " . $wpdb->postmeta . " ON ( " . $wpdb->posts . ".ID = " . $wpdb->postmeta . ".post_id ) WHERE 1=1  AND " . $wpdb->postmeta . ".meta_key = '_wpinv_subscr_status' AND (" . $wpdb->postmeta . ".meta_value = 'pending' OR " . $wpdb->postmeta . ".meta_value = 'active' OR " . $wpdb->postmeta . ".meta_value = 'cancelled' OR " . $wpdb->postmeta . ".meta_value = 'completed' OR " . $wpdb->postmeta . ".meta_value = 'expired' OR " . $wpdb->postmeta . ".meta_value = 'trialling' OR " . $wpdb->postmeta . ".meta_value = 'failing') AND " . $wpdb->posts . ".post_type = 'wpi_invoice' GROUP BY " . $wpdb->posts . ".ID ORDER BY " . $wpdb->posts . ".ID ASC";
78 78
 
79
-    $results = $wpdb->get_results( $query );
79
+    $results = $wpdb->get_results($query);
80 80
 
81
-    if ( empty( $results ) ) {
81
+    if (empty($results)) {
82 82
         return;
83 83
     }
84 84
 
85
-    foreach ( $results as $row ) {
86
-        $invoice = new WPInv_Invoice( $row->ID );
85
+    foreach ($results as $row) {
86
+        $invoice = new WPInv_Invoice($row->ID);
87 87
 
88
-        if ( empty( $invoice->ID ) ) {
88
+        if (empty($invoice->ID)) {
89 89
             continue;
90 90
         }
91 91
 
92
-        if ( $invoice->has_status( 'wpi-renewal' ) ) {
92
+        if ($invoice->has_status('wpi-renewal')) {
93 93
             continue;
94 94
         }
95 95
         
96
-        $item = $invoice->get_recurring( true );
96
+        $item = $invoice->get_recurring(true);
97 97
 
98
-        if ( empty( $item ) ) {
98
+        if (empty($item)) {
99 99
             continue;
100 100
         }
101 101
 
102 102
         $is_free_trial          = $invoice->is_free_trial();
103
-        $profile_id             = get_post_meta( $invoice->ID, '_wpinv_subscr_profile_id', true );
104
-        $subscription_status    = get_post_meta( $invoice->ID, '_wpinv_subscr_status', true );
103
+        $profile_id             = get_post_meta($invoice->ID, '_wpinv_subscr_profile_id', true);
104
+        $subscription_status    = get_post_meta($invoice->ID, '_wpinv_subscr_status', true);
105 105
         $transaction_id         = $invoice->get_transaction_id();
106 106
 
107 107
         // Last invoice
108
-        $query          = "SELECT ID, post_date FROM ". $wpdb->posts ." WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1";
109
-        $last_payment   = $wpdb->get_row( $query );
108
+        $query          = "SELECT ID, post_date FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_parent = '" . $invoice->ID . "' ORDER BY ID DESC LIMIT 1";
109
+        $last_payment   = $wpdb->get_row($query);
110 110
 
111
-        if ( !empty( $last_payment ) ) {
112
-            $invoice_date       = $last_payment->post_date;
111
+        if (!empty($last_payment)) {
112
+            $invoice_date = $last_payment->post_date;
113 113
             
114
-            $meta_profile_id     = get_post_meta( $last_payment->ID, '_wpinv_subscr_profile_id', true );
115
-            $meta_transaction_id = get_post_meta( $last_payment->ID, '_wpinv_transaction_id', true );
114
+            $meta_profile_id     = get_post_meta($last_payment->ID, '_wpinv_subscr_profile_id', true);
115
+            $meta_transaction_id = get_post_meta($last_payment->ID, '_wpinv_transaction_id', true);
116 116
 
117
-            if ( !empty( $meta_profile_id ) ) {
118
-                $profile_id  = $meta_profile_id;
117
+            if (!empty($meta_profile_id)) {
118
+                $profile_id = $meta_profile_id;
119 119
             }
120 120
 
121
-            if ( !empty( $meta_transaction_id ) ) {
122
-                $transaction_id  = $meta_transaction_id;
121
+            if (!empty($meta_transaction_id)) {
122
+                $transaction_id = $meta_transaction_id;
123 123
             }
124 124
         } else {
125
-            $invoice_date       = $invoice->get_invoice_date( false );
125
+            $invoice_date       = $invoice->get_invoice_date(false);
126 126
         }
127 127
         
128
-        $profile_id             = empty( $profile_id ) ? $invoice->ID : $profile_id;
129
-        $status                 = empty( $subscription_status ) ? 'pending' : $subscription_status;
128
+        $profile_id             = empty($profile_id) ? $invoice->ID : $profile_id;
129
+        $status                 = empty($subscription_status) ? 'pending' : $subscription_status;
130 130
         
131
-        $period                 = $item->get_recurring_period( true );
131
+        $period                 = $item->get_recurring_period(true);
132 132
         $interval               = $item->get_recurring_interval();
133
-        $bill_times             = (int)$item->get_recurring_limit();
133
+        $bill_times             = (int) $item->get_recurring_limit();
134 134
         $add_period             = $interval . ' ' . $period;
135 135
         $trial_period           = '';
136 136
 
137
-        if ( $invoice->is_free_trial() ) {
138
-            $trial_period       = $item->get_trial_period( true );
137
+        if ($invoice->is_free_trial()) {
138
+            $trial_period       = $item->get_trial_period(true);
139 139
             $free_interval      = $item->get_trial_interval();
140 140
             $trial_period       = $free_interval . ' ' . $trial_period;
141 141
 
142
-            if ( empty( $last_payment ) ) {
142
+            if (empty($last_payment)) {
143 143
                 $add_period     = $trial_period;
144 144
             }
145 145
         }
146 146
 
147
-        $expiration             = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period  . ' 23:59:59', strtotime( $invoice_date ) ) );
148
-        if ( strtotime( $expiration ) <  strtotime( date_i18n( 'Y-m-d' ) ) ) {
149
-            if ( $status == 'active' || $status == 'trialling' || $status == 'pending' ) {
147
+        $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date)));
148
+        if (strtotime($expiration) < strtotime(date_i18n('Y-m-d'))) {
149
+            if ($status == 'active' || $status == 'trialling' || $status == 'pending') {
150 150
                 $status = 'expired';
151 151
             }
152 152
         }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             'frequency'         => $interval,
160 160
             'period'            => $period,
161 161
             'initial_amount'    => $invoice->get_total(),
162
-            'recurring_amount'  => $invoice->get_recurring_details( 'total' ),
162
+            'recurring_amount'  => $invoice->get_recurring_details('total'),
163 163
             'bill_times'        => $bill_times,
164 164
             'created'           => $invoice_date,
165 165
             'expiration'        => $expiration,
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
         );
170 170
 
171 171
         $subs_db      = new WPInv_Subscriptions_DB;
172
-        $subs         = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice->ID, 'number' => 1 ) );
173
-        $subscription = reset( $subs );
172
+        $subs         = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice->ID, 'number' => 1));
173
+        $subscription = reset($subs);
174 174
 
175
-        if ( empty( $subscription ) || $subscription->id <= 0 ) {
175
+        if (empty($subscription) || $subscription->id <= 0) {
176 176
             $subscription = new WPInv_Subscription();
177
-            $new_sub = $subscription->create( $args );
177
+            $new_sub = $subscription->create($args);
178 178
 
179
-            if ( !empty( $bill_times ) && $new_sub->get_times_billed() >= $bill_times && ( 'active' == $new_sub->status || 'trialling' == $new_sub->status ) ) {
179
+            if (!empty($bill_times) && $new_sub->get_times_billed() >= $bill_times && ('active' == $new_sub->status || 'trialling' == $new_sub->status)) {
180 180
                 $new_sub->complete(); // Mark completed if all times billed
181 181
             }
182 182
         }
@@ -186,20 +186,20 @@  discard block
 block discarded – undo
186 186
 function wpinv_update_new_email_settings() {
187 187
     global $wpinv_options;
188 188
 
189
-    $current_options = get_option( 'wpinv_settings', array() );
189
+    $current_options = get_option('wpinv_settings', array());
190 190
     $options = array(
191
-        'email_new_invoice_body' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
192
-        'email_cancelled_invoice_body' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
193
-        'email_failed_invoice_body' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
194
-        'email_onhold_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
195
-        'email_processing_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
196
-        'email_refunded_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
197
-        'email_user_invoice_body' => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
198
-        'email_user_note_body' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
199
-        'email_overdue_body' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
191
+        'email_new_invoice_body' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
192
+        'email_cancelled_invoice_body' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
193
+        'email_failed_invoice_body' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
194
+        'email_onhold_invoice_body' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
195
+        'email_processing_invoice_body' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
196
+        'email_refunded_invoice_body' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
197
+        'email_user_invoice_body' => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
198
+        'email_user_note_body' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
199
+        'email_overdue_body' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
200 200
     );
201 201
 
202
-    foreach ($options as $option => $value){
202
+    foreach ($options as $option => $value) {
203 203
         if (!isset($current_options[$option])) {
204 204
             $current_options[$option] = $value;
205 205
         }
@@ -207,5 +207,5 @@  discard block
 block discarded – undo
207 207
 
208 208
     $wpinv_options = $current_options;
209 209
 
210
-    update_option( 'wpinv_settings', $current_options );
210
+    update_option('wpinv_settings', $current_options);
211 211
 }
212 212
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +559 added lines, -559 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_get_option( $key = '', $default = false ) {
7
+function wpinv_get_option($key = '', $default = false) {
8 8
     global $wpinv_options;
9 9
 
10
-    $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default;
11
-    $value = apply_filters( 'wpinv_get_option', $value, $key, $default );
10
+    $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default;
11
+    $value = apply_filters('wpinv_get_option', $value, $key, $default);
12 12
 
13
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
13
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
14 14
 }
15 15
 
16
-function wpinv_update_option( $key = '', $value = false ) {
16
+function wpinv_update_option($key = '', $value = false) {
17 17
     // If no key, exit
18
-    if ( empty( $key ) ) {
18
+    if (empty($key)) {
19 19
         return false;
20 20
     }
21 21
 
22
-    if ( empty( $value ) ) {
23
-        $remove_option = wpinv_delete_option( $key );
22
+    if (empty($value)) {
23
+        $remove_option = wpinv_delete_option($key);
24 24
         return $remove_option;
25 25
     }
26 26
 
27 27
     // First let's grab the current settings
28
-    $options = get_option( 'wpinv_settings' );
28
+    $options = get_option('wpinv_settings');
29 29
 
30 30
     // Let other plugin alter the value
31
-    $value = apply_filters( 'wpinv_update_option', $value, $key );
31
+    $value = apply_filters('wpinv_update_option', $value, $key);
32 32
 
33 33
     // Next let's try to update the value
34
-    $options[ $key ] = $value;
35
-    $did_update = update_option( 'wpinv_settings', $options );
34
+    $options[$key] = $value;
35
+    $did_update = update_option('wpinv_settings', $options);
36 36
 
37 37
     // If it's updated, let's update the global variable
38
-    if ( $did_update ) {
38
+    if ($did_update) {
39 39
         global $wpinv_options;
40
-        $wpinv_options[ $key ] = $value;
40
+        $wpinv_options[$key] = $value;
41 41
     }
42 42
 
43 43
     return $did_update;
44 44
 }
45 45
 
46
-function wpinv_delete_option( $key = '' ) {
46
+function wpinv_delete_option($key = '') {
47 47
     // If no key, exit
48
-    if ( empty( $key ) ) {
48
+    if (empty($key)) {
49 49
         return false;
50 50
     }
51 51
 
52 52
     // First let's grab the current settings
53
-    $options = get_option( 'wpinv_settings' );
53
+    $options = get_option('wpinv_settings');
54 54
 
55 55
     // Next let's try to update the value
56
-    if( isset( $options[ $key ] ) ) {
57
-        unset( $options[ $key ] );
56
+    if (isset($options[$key])) {
57
+        unset($options[$key]);
58 58
     }
59 59
 
60
-    $did_update = update_option( 'wpinv_settings', $options );
60
+    $did_update = update_option('wpinv_settings', $options);
61 61
 
62 62
     // If it updated, let's update the global variable
63
-    if ( $did_update ){
63
+    if ($did_update) {
64 64
         global $wpinv_options;
65 65
         $wpinv_options = $options;
66 66
     }
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_get_settings() {
72
-    $settings = get_option( 'wpinv_settings' );
72
+    $settings = get_option('wpinv_settings');
73 73
 
74
-    if ( empty( $settings ) ) {
74
+    if (empty($settings)) {
75 75
         // Update old settings with new single option
76
-        $general_settings   = is_array( get_option( 'wpinv_settings_general' ) )    ? get_option( 'wpinv_settings_general' )    : array();
77
-        $gateways_settings  = is_array( get_option( 'wpinv_settings_gateways' ) )   ? get_option( 'wpinv_settings_gateways' )   : array();
78
-        $email_settings     = is_array( get_option( 'wpinv_settings_emails' ) )     ? get_option( 'wpinv_settings_emails' )     : array();
79
-        $tax_settings       = is_array( get_option( 'wpinv_settings_taxes' ) )      ? get_option( 'wpinv_settings_taxes' )      : array();
80
-        $misc_settings      = is_array( get_option( 'wpinv_settings_misc' ) )       ? get_option( 'wpinv_settings_misc' )       : array();
81
-        $tool_settings      = is_array( get_option( 'wpinv_settings_tools' ) )      ? get_option( 'wpinv_settings_tools' )      : array();
76
+        $general_settings   = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array();
77
+        $gateways_settings  = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array();
78
+        $email_settings     = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array();
79
+        $tax_settings       = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array();
80
+        $misc_settings      = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array();
81
+        $tool_settings      = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array();
82 82
 
83
-        $settings = array_merge( $general_settings, $gateways_settings, $email_settings, $tax_settings, $misc_settings, $tool_settings );
83
+        $settings = array_merge($general_settings, $gateways_settings, $email_settings, $tax_settings, $misc_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,41 +111,41 @@  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
-                        'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
141
-                        'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
142
-                        'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
143
-                        'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
144
-                        'onchange'    => !empty( $option['onchange'] )   ? $option['onchange']    : '',
145
-                        'custom'      => !empty( $option['custom'] )     ? $option['custom']      : '',
146
-                        'class'       =>  !empty( $option['class'] )     ? $option['class']      : '',
147
-                        'cols'        => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
148
-                        '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
+                        'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
141
+                        'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
142
+                        'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
143
+                        'faux'        => isset($option['faux']) ? $option['faux'] : false,
144
+                        'onchange'    => !empty($option['onchange']) ? $option['onchange'] : '',
145
+                        'custom'      => !empty($option['custom']) ? $option['custom'] : '',
146
+                        'class'       =>  !empty($option['class']) ? $option['class'] : '',
147
+                        'cols'        => !empty($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
148
+                        'rows'        => !empty($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
149 149
                     )
150 150
                 );
151 151
             }
@@ -153,203 +153,203 @@  discard block
 block discarded – undo
153 153
     }
154 154
 
155 155
     // Creates our settings in the options table
156
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
156
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
157 157
 }
158
-add_action( 'admin_init', 'wpinv_register_settings' );
158
+add_action('admin_init', 'wpinv_register_settings');
159 159
 
160 160
 function wpinv_get_registered_settings() {
161
-    $pages = wpinv_get_pages( true );
161
+    $pages = wpinv_get_pages(true);
162 162
     
163 163
     $currencies = wpinv_get_currencies();
164 164
     
165 165
     $currency_code_options = array();
166
-    foreach ( $currencies as $code => $name ) {
167
-        $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
166
+    foreach ($currencies as $code => $name) {
167
+        $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
168 168
     }
169 169
     
170 170
     $due_payment_options       = array();
171
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
172
-    for ( $i = 1; $i <= 30; $i++ ) {
171
+    $due_payment_options[0]    = __('Now', 'invoicing');
172
+    for ($i = 1; $i <= 30; $i++) {
173 173
         $due_payment_options[$i] = $i;
174 174
     }
175 175
     
176 176
     $invoice_number_padd_options = array();
177
-    for ( $i = 0; $i <= 20; $i++ ) {
177
+    for ($i = 0; $i <= 20; $i++) {
178 178
         $invoice_number_padd_options[$i] = $i;
179 179
     }
180 180
     
181 181
     $currency_symbol = wpinv_currency_symbol();
182 182
     
183 183
     $last_number = $reset_number = '';
184
-    if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
185
-        $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number );
184
+    if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
185
+        $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number);
186 186
 
187
-        if ( !empty( $last_invoice_number ) ) {
188
-            $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
187
+        if (!empty($last_invoice_number)) {
188
+            $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
189 189
         }
190 190
 
191 191
         $nonce = wp_create_nonce('reset_invoice_count');
192
-        $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
192
+        $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
193 193
     }
194 194
     
195 195
     $alert_wrapper_start = '<p style="color: #F00">';
196 196
     $alert_wrapper_close = '</p>';
197 197
     $wpinv_settings = array(
198
-        'general' => apply_filters( 'wpinv_settings_general',
198
+        'general' => apply_filters('wpinv_settings_general',
199 199
             array(
200 200
                 'main' => array(
201 201
                     'location_settings' => array(
202 202
                         'id'   => 'location_settings',
203
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
203
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
204 204
                         'desc' => '',
205 205
                         'type' => 'header',
206 206
                     ),
207 207
                     'default_country' => array(
208 208
                         'id'      => 'default_country',
209
-                        'name'    => __( 'Default Country', 'invoicing' ),
210
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
209
+                        'name'    => __('Default Country', 'invoicing'),
210
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
211 211
                         'type'    => 'select',
212 212
                         'options' => wpinv_get_country_list(),
213 213
                         'std'     => 'GB',
214 214
                         'class'   => 'wpi_select2',
215
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
215
+                        'placeholder' => __('Select a country', 'invoicing'),
216 216
                     ),
217 217
                     'default_state' => array(
218 218
                         'id'      => 'default_state',
219
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
220
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
219
+                        'name'    => __('Default State / Province', 'invoicing'),
220
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
221 221
                         'type'    => 'country_states',
222 222
                         'class'   => 'wpi_select2',
223
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
223
+                        'placeholder' => __('Select a state', 'invoicing'),
224 224
                     ),
225 225
                     'store_name' => array(
226 226
                         'id'   => 'store_name',
227
-                        'name' => __( 'Store Name', 'invoicing' ),
228
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
227
+                        'name' => __('Store Name', 'invoicing'),
228
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
229 229
                         'std'     => get_option('blogname'),
230 230
                         'type' => 'text',
231 231
                     ),
232 232
                     'logo' => array(
233 233
                         'id'   => 'logo',
234
-                        'name' => __( 'Logo URL', 'invoicing' ),
235
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
234
+                        'name' => __('Logo URL', 'invoicing'),
235
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
236 236
                         'type' => 'text',
237 237
                     ),
238 238
                     'store_address' => array(
239 239
                         'id'   => 'store_address',
240
-                        'name' => __( 'Store Address', 'invoicing' ),
241
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
240
+                        'name' => __('Store Address', 'invoicing'),
241
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
242 242
                         'type' => 'textarea',
243 243
                     ),
244 244
                     'page_settings' => array(
245 245
                         'id'   => 'page_settings',
246
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
246
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
247 247
                         'desc' => '',
248 248
                         'type' => 'header',
249 249
                     ),
250 250
                     'checkout_page' => array(
251 251
                         'id'          => 'checkout_page',
252
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
253
-                        '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' ),
252
+                        'name'        => __('Checkout Page', 'invoicing'),
253
+                        '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'),
254 254
                         'type'        => 'select',
255 255
                         'options'     => $pages,
256 256
                         'class'       => 'wpi_select2',
257
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
257
+                        'placeholder' => __('Select a page', 'invoicing'),
258 258
                     ),
259 259
                     'tandc_page' => array(
260 260
                         'id'          => 'tandc_page',
261
-                        'name'        => __( 'Terms & Conditions', 'invoicing' ),
262
-                        'desc'        => __( 'If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing' ),
261
+                        'name'        => __('Terms & Conditions', 'invoicing'),
262
+                        'desc'        => __('If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing'),
263 263
                         'type'        => 'select',
264
-                        'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
264
+                        'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
265 265
                         'class'       => 'wpi_select2',
266
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
266
+                        'placeholder' => __('Select a page', 'invoicing'),
267 267
                     ),
268 268
                     'success_page' => array(
269 269
                         'id'          => 'success_page',
270
-                        'name'        => __( 'Success Page', 'invoicing' ),
271
-                        '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' ),
270
+                        'name'        => __('Success Page', 'invoicing'),
271
+                        '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'),
272 272
                         'type'        => 'select',
273 273
                         'options'     => $pages,
274 274
                         'class'       => 'wpi_select2',
275
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
275
+                        'placeholder' => __('Select a page', 'invoicing'),
276 276
                     ),
277 277
                     'failure_page' => array(
278 278
                         'id'          => 'failure_page',
279
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
280
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
279
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
280
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
281 281
                         'type'        => 'select',
282 282
                         'options'     => $pages,
283 283
                         'class'       => 'wpi_select2',
284
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
284
+                        'placeholder' => __('Select a page', 'invoicing'),
285 285
                     ),
286 286
                     'invoice_history_page' => array(
287 287
                         'id'          => 'invoice_history_page',
288
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
289
-                        'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
288
+                        'name'        => __('Invoice History Page', 'invoicing'),
289
+                        'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
290 290
                         'type'        => 'select',
291 291
                         'options'     => $pages,
292 292
                         'class'       => 'wpi_select2',
293
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
293
+                        'placeholder' => __('Select a page', 'invoicing'),
294 294
                     ),
295 295
                     'invoice_subscription_page' => array(
296 296
                         'id'          => 'invoice_subscription_page',
297
-                        'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
298
-                        'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
297
+                        'name'        => __('Invoice Subscriptions Page', 'invoicing'),
298
+                        'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
299 299
                         'type'        => 'select',
300 300
                         'options'     => $pages,
301 301
                         'class'       => 'wpi_select2',
302
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
302
+                        'placeholder' => __('Select a page', 'invoicing'),
303 303
                     ),
304 304
                 ),
305 305
                 'currency_section' => array(
306 306
                     'currency_settings' => array(
307 307
                         'id'   => 'currency_settings',
308
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
308
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
309 309
                         'desc' => '',
310 310
                         'type' => 'header',
311 311
                     ),
312 312
                     'currency' => array(
313 313
                         'id'      => 'currency',
314
-                        'name'    => __( 'Currency', 'invoicing' ),
315
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
314
+                        'name'    => __('Currency', 'invoicing'),
315
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
316 316
                         'type'    => 'select',
317 317
                         'class'       => 'wpi_select2',
318 318
                         'options' => $currency_code_options,
319 319
                     ),
320 320
                     'currency_position' => array(
321 321
                         'id'      => 'currency_position',
322
-                        'name'    => __( 'Currency Position', 'invoicing' ),
323
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
322
+                        'name'    => __('Currency Position', 'invoicing'),
323
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
324 324
                         'type'    => 'select',
325 325
                         'class'   => 'wpi_select2',
326 326
                         'options'  => array(
327
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
328
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
329
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
330
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
327
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
328
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
329
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
330
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
331 331
                         )
332 332
                     ),
333 333
                     'thousands_separator' => array(
334 334
                         'id'   => 'thousands_separator',
335
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
336
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
335
+                        'name' => __('Thousands Separator', 'invoicing'),
336
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
337 337
                         'type' => 'text',
338 338
                         'size' => 'small',
339 339
                         'std'  => ',',
340 340
                     ),
341 341
                     'decimal_separator' => array(
342 342
                         'id'   => 'decimal_separator',
343
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
344
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
343
+                        'name' => __('Decimal Separator', 'invoicing'),
344
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
345 345
                         'type' => 'text',
346 346
                         'size' => 'small',
347 347
                         'std'  => '.',
348 348
                     ),
349 349
                     'decimals' => array(
350 350
                         'id'   => 'decimals',
351
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
352
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
351
+                        'name' => __('Number of Decimals', 'invoicing'),
352
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
353 353
                         'type' => 'number',
354 354
                         'size' => 'small',
355 355
                         'std'  => '2',
@@ -361,60 +361,60 @@  discard block
 block discarded – undo
361 361
                 'labels' => array(
362 362
                     'labels' => array(
363 363
                         'id'   => 'labels_settings',
364
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
364
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
365 365
                         'desc' => '',
366 366
                         'type' => 'header',
367 367
                     ),
368 368
                     'vat_name' => array(
369 369
                         'id' => 'vat_name',
370
-                        'name' => __( 'VAT Name', 'invoicing' ),
371
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
370
+                        'name' => __('VAT Name', 'invoicing'),
371
+                        'desc' => __('Enter the VAT name', 'invoicing'),
372 372
                         'type' => 'text',
373 373
                         'size' => 'regular',
374 374
                         'std' => 'VAT'
375 375
                     ),
376 376
                     'vat_invoice_notice_label' => array(
377 377
                         'id' => 'vat_invoice_notice_label',
378
-                        'name' => __( 'Invoice Notice Label', 'invoicing' ),
379
-                        'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
378
+                        'name' => __('Invoice Notice Label', 'invoicing'),
379
+                        'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
380 380
                         'type' => 'text',
381 381
                         'size' => 'regular',
382 382
                     ),
383 383
                     'vat_invoice_notice' => array(
384 384
                         'id' => 'vat_invoice_notice',
385
-                        'name' => __( 'Invoice notice', 'invoicing' ),
386
-                        'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
385
+                        'name' => __('Invoice notice', 'invoicing'),
386
+                        'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
387 387
                         'type' => 'text',
388 388
                         'size' => 'regular',
389 389
                     ),
390 390
                     'name_your_price' => array(
391 391
                         'id'   => 'name_your_price_settings',
392
-                        'name' => '<h3>' . __( 'Name Your Price', 'invoicing' ) . '</h3>',
392
+                        'name' => '<h3>' . __('Name Your Price', 'invoicing') . '</h3>',
393 393
                         'desc' => '',
394 394
                         'type' => 'header',
395 395
                     ),
396 396
                     'suggested_price_text' => array(
397 397
                         'id'   => 'suggested_price_text',
398
-                        'name' => __( 'Suggested Price Text', 'invoicing' ),
399
-                        'desc' => __( "The label used to indicate an item's suggested price", 'invoicing' ),
398
+                        'name' => __('Suggested Price Text', 'invoicing'),
399
+                        'desc' => __("The label used to indicate an item's suggested price", 'invoicing'),
400 400
                         'type' => 'text',
401 401
                         'size' => 'regular',
402
-                        'std'  => __( 'Suggested Price:', 'invoicing' ),
402
+                        'std'  => __('Suggested Price:', 'invoicing'),
403 403
                     ),
404 404
                     'minimum_price_text' => array(
405 405
                         'id'   => 'minimum_price_text',
406
-                        'name' => __( 'Minimum Price Text', 'invoicing' ),
407
-                        'desc' => __( "The label used to indicate an item's minimum price", 'invoicing' ),
406
+                        'name' => __('Minimum Price Text', 'invoicing'),
407
+                        'desc' => __("The label used to indicate an item's minimum price", 'invoicing'),
408 408
                         'type' => 'text',
409 409
                         'size' => 'regular',
410
-                        'std'  => __( 'Minimum Price:', 'invoicing' ),
410
+                        'std'  => __('Minimum Price:', 'invoicing'),
411 411
                     ),
412 412
                     'name_your_price_text' => array(
413 413
                         'id'   => 'name_your_price_text',
414
-                        'name' => __( 'Name Your Price Text', 'invoicing' ),
414
+                        'name' => __('Name Your Price Text', 'invoicing'),
415 415
                         'type' => 'text',
416 416
                         'size' => 'regular',
417
-                        'std'  => __( 'Name Your Price', 'invoicing' ),
417
+                        'std'  => __('Name Your Price', 'invoicing'),
418 418
                     ),
419 419
                 )
420 420
             )
@@ -424,22 +424,22 @@  discard block
 block discarded – undo
424 424
                 'main' => array(
425 425
                     'gateway_settings' => array(
426 426
                         'id'   => 'api_header',
427
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
427
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
428 428
                         'desc' => '',
429 429
                         'type' => 'header',
430 430
                     ),
431 431
                     'gateways' => array(
432 432
                         'id'      => 'gateways',
433
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
434
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
433
+                        'name'    => __('Payment Gateways', 'invoicing'),
434
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
435 435
                         'type'    => 'gateways',
436 436
                         'std'     => array('manual'=>1),
437 437
                         'options' => wpinv_get_payment_gateways(),
438 438
                     ),
439 439
                     'default_gateway' => array(
440 440
                         'id'      => 'default_gateway',
441
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
442
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
441
+                        'name'    => __('Default Gateway', 'invoicing'),
442
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
443 443
                         'type'    => 'gateway_select',
444 444
                         'std'     => 'manual',
445 445
                         'class'   => 'wpi_select2',
@@ -454,19 +454,19 @@  discard block
 block discarded – undo
454 454
                 'main' => array(
455 455
                     'tax_settings' => array(
456 456
                         'id'   => 'tax_settings',
457
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
457
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
458 458
                         'type' => 'header',
459 459
                     ),
460 460
                     'enable_taxes' => array(
461 461
                         'id'   => 'enable_taxes',
462
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
463
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
462
+                        'name' => __('Enable Taxes', 'invoicing'),
463
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
464 464
                         'type' => 'checkbox',
465 465
                     ),
466 466
                     'tax_rate' => array(
467 467
                         'id'   => 'tax_rate',
468
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
469
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
468
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
469
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
470 470
                         'type' => 'number',
471 471
                         'size' => 'small',
472 472
                         'min'  => '0',
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
                 'rates' => array(
479 479
                     'tax_rates' => array(
480 480
                         'id'   => 'tax_rates',
481
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
482
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
481
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
482
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
483 483
                         'type' => 'tax_rates',
484 484
                     ),
485 485
                 )
@@ -491,61 +491,61 @@  discard block
 block discarded – undo
491 491
                 'main' => array(
492 492
                     'email_settings_header' => array(
493 493
                         'id'   => 'email_settings_header',
494
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
494
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
495 495
                         'type' => 'header',
496 496
                     ),
497 497
                     'email_from_name' => array(
498 498
                         'id'   => 'email_from_name',
499
-                        'name' => __( 'From Name', 'invoicing' ),
500
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
501
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
499
+                        'name' => __('From Name', 'invoicing'),
500
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
501
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
502 502
                         'type' => 'text',
503 503
                     ),
504 504
                     'email_from' => array(
505 505
                         'id'   => 'email_from',
506
-                        'name' => __( 'From Email', 'invoicing' ),
507
-                        '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),
508
-                        'std' => get_option( 'admin_email' ),
506
+                        'name' => __('From Email', 'invoicing'),
507
+                        '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),
508
+                        'std' => get_option('admin_email'),
509 509
                         'type' => 'text',
510 510
                     ),
511 511
                     'overdue_settings_header' => array(
512 512
                         'id'   => 'overdue_settings_header',
513
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
513
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
514 514
                         'type' => 'header',
515 515
                     ),
516 516
                     'overdue_active' => array(
517 517
                         'id'   => 'overdue_active',
518
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
519
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
518
+                        'name' => __('Enable Due Date', 'invoicing'),
519
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
520 520
                         'type' => 'checkbox',
521 521
                         'std'  => false,
522 522
                     ),
523 523
                     'overdue_days' => array(
524 524
                         'id'          => 'overdue_days',
525
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
526
-                        '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' ),
525
+                        'name'        => __('Default Due Date', 'invoicing'),
526
+                        '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'),
527 527
                         'type'        => 'select',
528 528
                         'options'     => $due_payment_options,
529 529
                         'std'         => 0,
530
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
530
+                        'placeholder' => __('Select a page', 'invoicing'),
531 531
                     ),
532 532
                     'email_template_header' => array(
533 533
                         'id'   => 'email_template_header',
534
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
534
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
535 535
                         'type' => 'header',
536 536
                     ),
537 537
                     'email_header_image' => array(
538 538
                         'id'   => 'email_header_image',
539
-                        'name' => __( 'Header Image', 'invoicing' ),
540
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
539
+                        'name' => __('Header Image', 'invoicing'),
540
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
541 541
                         'std' => '',
542 542
                         'type' => 'text',
543 543
                     ),
544 544
                     'email_footer_text' => array(
545 545
                         'id'   => 'email_footer_text',
546
-                        'name' => __( 'Footer Text', 'invoicing' ),
547
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
548
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
546
+                        'name' => __('Footer Text', 'invoicing'),
547
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
548
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
549 549
                         'type' => 'textarea',
550 550
                         'class' => 'regular-text',
551 551
                         'rows' => 2,
@@ -553,29 +553,29 @@  discard block
 block discarded – undo
553 553
                     ),
554 554
                     'email_base_color' => array(
555 555
                         'id'   => 'email_base_color',
556
-                        'name' => __( 'Base Color', 'invoicing' ),
557
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
556
+                        'name' => __('Base Color', 'invoicing'),
557
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
558 558
                         'std' => '#557da2',
559 559
                         'type' => 'color',
560 560
                     ),
561 561
                     'email_background_color' => array(
562 562
                         'id'   => 'email_background_color',
563
-                        'name' => __( 'Background Color', 'invoicing' ),
564
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
563
+                        'name' => __('Background Color', 'invoicing'),
564
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
565 565
                         'std' => '#f5f5f5',
566 566
                         'type' => 'color',
567 567
                     ),
568 568
                     'email_body_background_color' => array(
569 569
                         'id'   => 'email_body_background_color',
570
-                        'name' => __( 'Body Background Color', 'invoicing' ),
571
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
570
+                        'name' => __('Body Background Color', 'invoicing'),
571
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
572 572
                         'std' => '#fdfdfd',
573 573
                         'type' => 'color',
574 574
                     ),
575 575
                     'email_text_color' => array(
576 576
                         'id'   => 'email_text_color',
577
-                        'name' => __( 'Body Text Color', 'invoicing' ),
578
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
577
+                        'name' => __('Body Text Color', 'invoicing'),
578
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
579 579
                         'std' => '#505050',
580 580
                         'type' => 'color',
581 581
                     ),
@@ -594,26 +594,26 @@  discard block
 block discarded – undo
594 594
                 'main' => array(
595 595
                     'invoicing_privacy_policy_settings' => array(
596 596
                         'id'   => 'invoicing_privacy_policy_settings',
597
-                        'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
597
+                        'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
598 598
                         'type' => 'header',
599 599
                     ),
600 600
                     'privacy_page' => array(
601 601
                         'id'          => 'privacy_page',
602
-                        'name'        => __( 'Privacy Page', 'invoicing' ),
603
-                        'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
602
+                        'name'        => __('Privacy Page', 'invoicing'),
603
+                        'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
604 604
                         'type'        => 'select',
605
-                        'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
605
+                        'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
606 606
                         'class'       => 'wpi_select2',
607
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
607
+                        'placeholder' => __('Select a page', 'invoicing'),
608 608
                     ),
609 609
                     'invoicing_privacy_checkout_message' => array(
610 610
                         'id' => 'invoicing_privacy_checkout_message',
611
-                        'name' => __( 'Checkout privacy policy', 'invoicing' ),
612
-                        'desc' => __( 'Optionally add privacy policy message which will display on checkout page.', 'invoicing' ),
611
+                        'name' => __('Checkout privacy policy', 'invoicing'),
612
+                        'desc' => __('Optionally add privacy policy message which will display on checkout page.', 'invoicing'),
613 613
                         'type' => 'textarea',
614 614
                         'class'=> 'regular-text',
615 615
                         'rows' => 4,
616
-                        'std'  => sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ),
616
+                        'std'  => sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'),
617 617
                     ),
618 618
                 ),
619 619
             )
@@ -624,19 +624,19 @@  discard block
 block discarded – undo
624 624
                 'main' => array(
625 625
                     'invoice_number_format_settings' => array(
626 626
                         'id'   => 'invoice_number_format_settings',
627
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
627
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
628 628
                         'type' => 'header',
629 629
                     ),
630 630
                     'sequential_invoice_number' => array(
631 631
                         'id'   => 'sequential_invoice_number',
632
-                        'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
633
-                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
632
+                        'name' => __('Sequential Invoice Numbers', 'invoicing'),
633
+                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
634 634
                         'type' => 'checkbox',
635 635
                     ),
636 636
                     'invoice_sequence_start' => array(
637 637
                         'id'   => 'invoice_sequence_start',
638
-                        'name' => __( 'Sequential Starting Number', 'invoicing' ),
639
-                        'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
638
+                        'name' => __('Sequential Starting Number', 'invoicing'),
639
+                        'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
640 640
                         'type' => 'number',
641 641
                         'size' => 'small',
642 642
                         'std'  => '1',
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
                     ),
645 645
                     'invoice_number_padd' => array(
646 646
                         'id'      => 'invoice_number_padd',
647
-                        'name'    => __( 'Minimum Digits', 'invoicing' ),
648
-                        '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' ),
647
+                        'name'    => __('Minimum Digits', 'invoicing'),
648
+                        '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'),
649 649
                         'type'    => 'select',
650 650
                         'options' => $invoice_number_padd_options,
651 651
                         'std'     => 5,
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
                     ),
654 654
                     'invoice_number_prefix' => array(
655 655
                         'id' => 'invoice_number_prefix',
656
-                        'name' => __( 'Invoice Number Prefix', 'invoicing' ),
657
-                        'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ),
656
+                        'name' => __('Invoice Number Prefix', 'invoicing'),
657
+                        'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'),
658 658
                         'type' => 'text',
659 659
                         'size' => 'regular',
660 660
                         'std' => 'WPINV-',
@@ -662,32 +662,32 @@  discard block
 block discarded – undo
662 662
                     ),
663 663
                     'invoice_number_postfix' => array(
664 664
                         'id' => 'invoice_number_postfix',
665
-                        'name' => __( 'Invoice Number Postfix', 'invoicing' ),
666
-                        'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
665
+                        'name' => __('Invoice Number Postfix', 'invoicing'),
666
+                        'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
667 667
                         'type' => 'text',
668 668
                         'size' => 'regular',
669 669
                         'std' => ''
670 670
                     ),
671 671
                     'checkout_settings' => array(
672 672
                         'id'   => 'checkout_settings',
673
-                        'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
673
+                        'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
674 674
                         'type' => 'header',
675 675
                     ),
676 676
                     'login_to_checkout' => array(
677 677
                         'id'   => 'login_to_checkout',
678
-                        'name' => __( 'Require Login To Checkout', 'invoicing' ),
679
-                        'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
678
+                        'name' => __('Require Login To Checkout', 'invoicing'),
679
+                        'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
680 680
                         'type' => 'checkbox',
681 681
                     ),
682 682
                     'uninstall_settings' => array(
683 683
                         'id'   => 'uninstall_settings',
684
-                        'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
684
+                        'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
685 685
                         'type' => 'header',
686 686
                     ),
687 687
                     'remove_data_on_unistall' => array(
688 688
                         'id'   => 'remove_data_on_unistall',
689
-                        'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
690
-                        'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
689
+                        'name' => __('Remove Data on Uninstall?', 'invoicing'),
690
+                        'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
691 691
                         'type' => 'checkbox',
692 692
                         'std'  => ''
693 693
                     ),
@@ -695,80 +695,80 @@  discard block
 block discarded – undo
695 695
                 'fields' => array(
696 696
                     'fields_settings' => array(
697 697
                         'id'   => 'fields_settings',
698
-                        'name' => '<h3>' . __( 'Address Fields', 'invoicing' ) . '</h3>',
699
-                        'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ),
698
+                        'name' => '<h3>' . __('Address Fields', 'invoicing') . '</h3>',
699
+                        'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'),
700 700
                         'type' => 'header',
701 701
                     ),
702 702
                     'fname_mandatory' => array(
703 703
                         'id'   => 'fname_mandatory',
704
-                        'name' => __( 'First Name', 'invoicing' ),
704
+                        'name' => __('First Name', 'invoicing'),
705 705
                         'type' => 'checkbox',
706 706
                         'std'  => true,
707 707
                     ),
708 708
                     'lname_mandatory' => array(
709 709
                         'id'   => 'lname_mandatory',
710
-                        'name' => __( 'Last Name', 'invoicing' ),
710
+                        'name' => __('Last Name', 'invoicing'),
711 711
                         'type' => 'checkbox',
712 712
                         'std'  => true,
713 713
                     ),
714 714
                     'address_mandatory' => array(
715 715
                         'id'   => 'address_mandatory',
716
-                        'name' => __( 'Address', 'invoicing' ),
716
+                        'name' => __('Address', 'invoicing'),
717 717
                         'type' => 'checkbox',
718 718
                         'std'  => true,
719 719
                     ),
720 720
                     'city_mandatory' => array(
721 721
                         'id'   => 'city_mandatory',
722
-                        'name' => __( 'City', 'invoicing' ),
722
+                        'name' => __('City', 'invoicing'),
723 723
                         'type' => 'checkbox',
724 724
                         'std'  => true,
725 725
                     ),
726 726
                     'country_mandatory' => array(
727 727
                         'id'   => 'country_mandatory',
728
-                        'name' => __( 'Country', 'invoicing' ),
728
+                        'name' => __('Country', 'invoicing'),
729 729
                         'type' => 'checkbox',
730 730
                         'std'  => true,
731 731
                     ),
732 732
                     'state_mandatory' => array(
733 733
                         'id'   => 'state_mandatory',
734
-                        'name' => __( 'State / Province', 'invoicing' ),
734
+                        'name' => __('State / Province', 'invoicing'),
735 735
                         'type' => 'checkbox',
736 736
                         'std'  => true,
737 737
                     ),
738 738
                     'zip_mandatory' => array(
739 739
                         'id'   => 'zip_mandatory',
740
-                        'name' => __( 'ZIP / Postcode', 'invoicing' ),
740
+                        'name' => __('ZIP / Postcode', 'invoicing'),
741 741
                         'type' => 'checkbox',
742 742
                         'std'  => true,
743 743
                     ),
744 744
                     'phone_mandatory' => array(
745 745
                         'id'   => 'phone_mandatory',
746
-                        'name' => __( 'Phone Number', 'invoicing' ),
746
+                        'name' => __('Phone Number', 'invoicing'),
747 747
                         'type' => 'checkbox',
748 748
                         'std'  => true,
749 749
                     ),
750 750
                     'force_show_company' => array(
751 751
                         'id'   => 'force_show_company',
752
-                        'name' => __( 'Force show company name at checkout.', 'invoicing' ),
752
+                        'name' => __('Force show company name at checkout.', 'invoicing'),
753 753
                         'type' => 'checkbox',
754 754
                         'std'  => false,
755 755
                     ),
756 756
                     'address_autofill_settings' => array(
757 757
                         'id'   => 'address_autofill_settings',
758
-                        'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>',
758
+                        'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>',
759 759
                         'type' => 'header',
760 760
                     ),
761 761
                     'address_autofill_active' => array(
762 762
                         'id'   => 'address_autofill_active',
763
-                        'name' => __( 'Enable/Disable', 'invoicing' ),
764
-                        'desc' => __( 'Enable google address auto complete', 'invoicing' ),
763
+                        'name' => __('Enable/Disable', 'invoicing'),
764
+                        'desc' => __('Enable google address auto complete', 'invoicing'),
765 765
                         'type' => 'checkbox',
766 766
                         'std'  => 0
767 767
                     ),
768 768
                     'address_autofill_api' => array(
769 769
                         'id' => 'address_autofill_api',
770
-                        'name' => __( 'Google Place API Key', 'invoicing' ),
771
-                        'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ),
770
+                        'name' => __('Google Place API Key', 'invoicing'),
771
+                        'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'),
772 772
                         'type' => 'text',
773 773
                         'size' => 'regular',
774 774
                         'std' => ''
@@ -777,13 +777,13 @@  discard block
 block discarded – undo
777 777
                 'custom-css' => array(
778 778
                     'css_settings' => array(
779 779
                         'id'   => 'css_settings',
780
-                        'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
780
+                        'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
781 781
                         'type' => 'header',
782 782
                     ),
783 783
                     'template_custom_css' => array(
784 784
                         'id' => 'template_custom_css',
785
-                        'name' => __( 'Invoice Template CSS', 'invoicing' ),
786
-                        'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
785
+                        'name' => __('Invoice Template CSS', 'invoicing'),
786
+                        'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
787 787
                         'type' => 'textarea',
788 788
                         'class'=> 'regular-text',
789 789
                         'rows' => 10,
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
                 'main' => array(
798 798
                     'tool_settings' => array(
799 799
                         'id'   => 'tool_settings',
800
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
801
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
800
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
801
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
802 802
                         'type' => 'tools',
803 803
                     ),
804 804
                 ),
@@ -806,136 +806,136 @@  discard block
 block discarded – undo
806 806
         )
807 807
     );
808 808
 
809
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
809
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
810 810
 }
811 811
 
812
-function wpinv_settings_sanitize( $input = array() ) {
812
+function wpinv_settings_sanitize($input = array()) {
813 813
     global $wpinv_options;
814 814
 
815
-    if ( empty( $_POST['_wp_http_referer'] ) ) {
815
+    if (empty($_POST['_wp_http_referer'])) {
816 816
         return $input;
817 817
     }
818 818
 
819
-    parse_str( $_POST['_wp_http_referer'], $referrer );
819
+    parse_str($_POST['_wp_http_referer'], $referrer);
820 820
 
821 821
     $settings = wpinv_get_registered_settings();
822
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
823
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
822
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
823
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
824 824
 
825 825
     $input = $input ? $input : array();
826
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
827
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
826
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
827
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
828 828
 
829 829
     // Loop through each setting being saved and pass it through a sanitization filter
830
-    foreach ( $input as $key => $value ) {
830
+    foreach ($input as $key => $value) {
831 831
         // Get the setting type (checkbox, select, etc)
832
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
832
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
833 833
 
834
-        if ( $type ) {
834
+        if ($type) {
835 835
             // Field type specific filter
836
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
836
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
837 837
         }
838 838
 
839 839
         // General filter
840
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
840
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
841 841
     }
842 842
 
843 843
     // Loop through the whitelist and unset any that are empty for the tab being saved
844
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
845
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
844
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
845
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
846 846
 
847
-    $found_settings = array_merge( $main_settings, $section_settings );
847
+    $found_settings = array_merge($main_settings, $section_settings);
848 848
 
849
-    if ( ! empty( $found_settings ) ) {
850
-        foreach ( $found_settings as $key => $value ) {
849
+    if (!empty($found_settings)) {
850
+        foreach ($found_settings as $key => $value) {
851 851
 
852 852
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
853
-            if ( is_numeric( $key ) ) {
853
+            if (is_numeric($key)) {
854 854
                 $key = $value['id'];
855 855
             }
856 856
 
857
-            if ( empty( $input[ $key ] ) ) {
858
-                unset( $wpinv_options[ $key ] );
857
+            if (empty($input[$key])) {
858
+                unset($wpinv_options[$key]);
859 859
             }
860 860
         }
861 861
     }
862 862
 
863 863
     // Merge our new settings with the existing
864
-    $output = array_merge( $wpinv_options, $input );
864
+    $output = array_merge($wpinv_options, $input);
865 865
 
866
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
866
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
867 867
 
868 868
     return $output;
869 869
 }
870 870
 
871
-function wpinv_settings_sanitize_misc_accounting( $input ) {
871
+function wpinv_settings_sanitize_misc_accounting($input) {
872 872
     global $wpi_session;
873 873
 
874
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
874
+    if (!wpinv_current_user_can_manage_invoicing()) {
875 875
         return $input;
876 876
     }
877 877
 
878
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
878
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
879 879
         // Shows an admin notice about upgrading previous order numbers
880
-        $wpi_session->set( 'upgrade_sequential', '1' );
880
+        $wpi_session->set('upgrade_sequential', '1');
881 881
     }
882 882
 
883 883
     return $input;
884 884
 }
885
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
885
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
886 886
 
887
-function wpinv_settings_sanitize_tax_rates( $input ) {
888
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
887
+function wpinv_settings_sanitize_tax_rates($input) {
888
+    if (!wpinv_current_user_can_manage_invoicing()) {
889 889
         return $input;
890 890
     }
891 891
 
892
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
892
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
893 893
 
894 894
     $tax_rates = array();
895 895
 
896
-    if ( !empty( $new_rates ) ) {
897
-        foreach ( $new_rates as $rate ) {
898
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
896
+    if (!empty($new_rates)) {
897
+        foreach ($new_rates as $rate) {
898
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
899 899
                 continue;
900 900
             }
901 901
             
902
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
902
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
903 903
             
904 904
             $tax_rates[] = $rate;
905 905
         }
906 906
     }
907 907
 
908
-    update_option( 'wpinv_tax_rates', $tax_rates );
908
+    update_option('wpinv_tax_rates', $tax_rates);
909 909
 
910 910
     return $input;
911 911
 }
912
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
912
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
913 913
 
914
-function wpinv_sanitize_text_field( $input ) {
915
-    return trim( $input );
914
+function wpinv_sanitize_text_field($input) {
915
+    return trim($input);
916 916
 }
917
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
917
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
918 918
 
919 919
 function wpinv_get_settings_tabs() {
920 920
     $tabs             = array();
921
-    $tabs['general']  = __( 'General', 'invoicing' );
922
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
923
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
924
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
925
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
926
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
927
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
928
-
929
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
921
+    $tabs['general']  = __('General', 'invoicing');
922
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
923
+    $tabs['taxes']    = __('Taxes', 'invoicing');
924
+    $tabs['emails']   = __('Emails', 'invoicing');
925
+    $tabs['privacy']  = __('Privacy', 'invoicing');
926
+    $tabs['misc']     = __('Misc', 'invoicing');
927
+    $tabs['tools']    = __('Tools', 'invoicing');
928
+
929
+    return apply_filters('wpinv_settings_tabs', $tabs);
930 930
 }
931 931
 
932
-function wpinv_get_settings_tab_sections( $tab = false ) {
932
+function wpinv_get_settings_tab_sections($tab = false) {
933 933
     $tabs     = false;
934 934
     $sections = wpinv_get_registered_settings_sections();
935 935
 
936
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
937
-        $tabs = $sections[ $tab ];
938
-    } else if ( $tab ) {
936
+    if ($tab && !empty($sections[$tab])) {
937
+        $tabs = $sections[$tab];
938
+    } else if ($tab) {
939 939
         $tabs = false;
940 940
     }
941 941
 
@@ -945,143 +945,143 @@  discard block
 block discarded – undo
945 945
 function wpinv_get_registered_settings_sections() {
946 946
     static $sections = false;
947 947
 
948
-    if ( false !== $sections ) {
948
+    if (false !== $sections) {
949 949
         return $sections;
950 950
     }
951 951
 
952 952
     $sections = array(
953
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
954
-            'main' => __( 'General Settings', 'invoicing' ),
955
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
956
-            'labels' => __( 'Label Texts', 'invoicing' ),
957
-        ) ),
958
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
959
-            'main' => __( 'Gateway Settings', 'invoicing' ),
960
-        ) ),
961
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
962
-            'main' => __( 'Tax Settings', 'invoicing' ),
963
-            'rates' => __( 'Tax Rates', 'invoicing' ),
964
-        ) ),
965
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
966
-            'main' => __( 'Email Settings', 'invoicing' ),
967
-        ) ),
968
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
969
-            'main' => __( 'Privacy policy', 'invoicing' ),
970
-        ) ),
971
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
972
-            'main' => __( 'Miscellaneous', 'invoicing' ),
973
-            'fields' => __( 'Fields Settings', 'invoicing' ),
974
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
975
-        ) ),
976
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
977
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
978
-        ) ),
953
+        'general' => apply_filters('wpinv_settings_sections_general', array(
954
+            'main' => __('General Settings', 'invoicing'),
955
+            'currency_section' => __('Currency Settings', 'invoicing'),
956
+            'labels' => __('Label Texts', 'invoicing'),
957
+        )),
958
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
959
+            'main' => __('Gateway Settings', 'invoicing'),
960
+        )),
961
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
962
+            'main' => __('Tax Settings', 'invoicing'),
963
+            'rates' => __('Tax Rates', 'invoicing'),
964
+        )),
965
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
966
+            'main' => __('Email Settings', 'invoicing'),
967
+        )),
968
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
969
+            'main' => __('Privacy policy', 'invoicing'),
970
+        )),
971
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
972
+            'main' => __('Miscellaneous', 'invoicing'),
973
+            'fields' => __('Fields Settings', 'invoicing'),
974
+            'custom-css' => __('Custom CSS', 'invoicing'),
975
+        )),
976
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
977
+            'main' => __('Diagnostic Tools', 'invoicing'),
978
+        )),
979 979
     );
980 980
 
981
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
981
+    $sections = apply_filters('wpinv_settings_sections', $sections);
982 982
 
983 983
     return $sections;
984 984
 }
985 985
 
986
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
986
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
987 987
 	$pages_options = array();
988 988
 
989
-	if( $default_label !== NULL && $default_label !== false ) {
990
-		$pages_options = array( '' => $default_label ); // Blank option
989
+	if ($default_label !== NULL && $default_label !== false) {
990
+		$pages_options = array('' => $default_label); // Blank option
991 991
 	}
992 992
 
993 993
 	$pages = get_pages();
994
-	if ( $pages ) {
995
-		foreach ( $pages as $page ) {
994
+	if ($pages) {
995
+		foreach ($pages as $page) {
996 996
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
997
-            $pages_options[ $page->ID ] = $title;
997
+            $pages_options[$page->ID] = $title;
998 998
 		}
999 999
 	}
1000 1000
 
1001 1001
 	return $pages_options;
1002 1002
 }
1003 1003
 
1004
-function wpinv_header_callback( $args ) {
1005
-	if ( !empty( $args['desc'] ) ) {
1004
+function wpinv_header_callback($args) {
1005
+	if (!empty($args['desc'])) {
1006 1006
         echo $args['desc'];
1007 1007
     }
1008 1008
 }
1009 1009
 
1010
-function wpinv_hidden_callback( $args ) {
1010
+function wpinv_hidden_callback($args) {
1011 1011
 	global $wpinv_options;
1012 1012
 
1013
-	if ( isset( $args['set_value'] ) ) {
1013
+	if (isset($args['set_value'])) {
1014 1014
 		$value = $args['set_value'];
1015
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
1016
-		$value = $wpinv_options[ $args['id'] ];
1015
+	} elseif (isset($wpinv_options[$args['id']])) {
1016
+		$value = $wpinv_options[$args['id']];
1017 1017
 	} else {
1018
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1018
+		$value = isset($args['std']) ? $args['std'] : '';
1019 1019
 	}
1020 1020
 
1021
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1021
+	if (isset($args['faux']) && true === $args['faux']) {
1022 1022
 		$args['readonly'] = true;
1023
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1023
+		$value = isset($args['std']) ? $args['std'] : '';
1024 1024
 		$name  = '';
1025 1025
 	} else {
1026
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1026
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1027 1027
 	}
1028 1028
 
1029
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
1029
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
1030 1030
     
1031 1031
 	echo $html;
1032 1032
 }
1033 1033
 
1034
-function wpinv_checkbox_callback( $args ) {
1034
+function wpinv_checkbox_callback($args) {
1035 1035
 	global $wpinv_options;
1036 1036
     
1037
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1037
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1038 1038
 
1039
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1039
+	if (isset($args['faux']) && true === $args['faux']) {
1040 1040
 		$name = '';
1041 1041
 	} else {
1042 1042
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
1043 1043
 	}
1044 1044
 
1045
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
1045
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
1046 1046
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
1047
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1047
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1048 1048
 
1049 1049
 	echo $html;
1050 1050
 }
1051 1051
 
1052
-function wpinv_multicheck_callback( $args ) {
1052
+function wpinv_multicheck_callback($args) {
1053 1053
 	global $wpinv_options;
1054 1054
 
1055
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
1056
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
1055
+	$sanitize_id = wpinv_sanitize_key($args['id']);
1056
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
1057 1057
 
1058
-	if ( ! empty( $args['options'] ) ) {
1058
+	if (!empty($args['options'])) {
1059 1059
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
1060
-        foreach( $args['options'] as $key => $option ):
1061
-			$sanitize_key = wpinv_sanitize_key( $key );
1062
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
1060
+        foreach ($args['options'] as $key => $option):
1061
+			$sanitize_key = wpinv_sanitize_key($key);
1062
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
1063 1063
 				$enabled = $sanitize_key;
1064 1064
 			} else { 
1065 1065
 				$enabled = NULL; 
1066 1066
 			}
1067
-			echo '<div class="wpi-mcheck-row"><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;';
1068
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
1067
+			echo '<div class="wpi-mcheck-row"><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;';
1068
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
1069 1069
 		endforeach;
1070 1070
 		echo '</div>';
1071 1071
 		echo '<p class="description">' . $args['desc'] . '</p>';
1072 1072
 	}
1073 1073
 }
1074 1074
 
1075
-function wpinv_payment_icons_callback( $args ) {
1075
+function wpinv_payment_icons_callback($args) {
1076 1076
 	global $wpinv_options;
1077 1077
     
1078
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1078
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1079 1079
 
1080
-	if ( ! empty( $args['options'] ) ) {
1081
-		foreach( $args['options'] as $key => $option ) {
1082
-            $sanitize_key = wpinv_sanitize_key( $key );
1080
+	if (!empty($args['options'])) {
1081
+		foreach ($args['options'] as $key => $option) {
1082
+            $sanitize_key = wpinv_sanitize_key($key);
1083 1083
             
1084
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
1084
+			if (isset($wpinv_options[$args['id']][$key])) {
1085 1085
 				$enabled = $option;
1086 1086
 			} else {
1087 1087
 				$enabled = NULL;
@@ -1089,197 +1089,197 @@  discard block
 block discarded – undo
1089 1089
 
1090 1090
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
1091 1091
 
1092
-				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;';
1092
+				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;';
1093 1093
 
1094
-				if ( wpinv_string_is_image_url( $key ) ) {
1095
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1094
+				if (wpinv_string_is_image_url($key)) {
1095
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1096 1096
 				} else {
1097
-					$card = strtolower( str_replace( ' ', '', $option ) );
1097
+					$card = strtolower(str_replace(' ', '', $option));
1098 1098
 
1099
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
1100
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
1099
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
1100
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
1101 1101
 					} else {
1102
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
1102
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
1103 1103
 						$content_dir = WP_CONTENT_DIR;
1104 1104
 
1105
-						if ( function_exists( 'wp_normalize_path' ) ) {
1105
+						if (function_exists('wp_normalize_path')) {
1106 1106
 							// Replaces backslashes with forward slashes for Windows systems
1107
-							$image = wp_normalize_path( $image );
1108
-							$content_dir = wp_normalize_path( $content_dir );
1107
+							$image = wp_normalize_path($image);
1108
+							$content_dir = wp_normalize_path($content_dir);
1109 1109
 						}
1110 1110
 
1111
-						$image = str_replace( $content_dir, content_url(), $image );
1111
+						$image = str_replace($content_dir, content_url(), $image);
1112 1112
 					}
1113 1113
 
1114
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1114
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1115 1115
 				}
1116 1116
 			echo $option . '</label>';
1117 1117
 		}
1118
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
1118
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
1119 1119
 	}
1120 1120
 }
1121 1121
 
1122
-function wpinv_radio_callback( $args ) {
1122
+function wpinv_radio_callback($args) {
1123 1123
 	global $wpinv_options;
1124 1124
     
1125
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1125
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1126 1126
     
1127
-    foreach ( $args['options'] as $key => $option ) :
1128
-		$sanitize_key = wpinv_sanitize_key( $key );
1127
+    foreach ($args['options'] as $key => $option) :
1128
+		$sanitize_key = wpinv_sanitize_key($key);
1129 1129
         
1130 1130
         $checked = false;
1131 1131
 
1132
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
1132
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
1133 1133
 			$checked = true;
1134
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
1134
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
1135 1135
 			$checked = true;
1136 1136
 
1137 1137
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
1138
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
1138
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
1139 1139
 	endforeach;
1140 1140
 
1141
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
1141
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
1142 1142
 }
1143 1143
 
1144
-function wpinv_gateways_callback( $args ) {
1144
+function wpinv_gateways_callback($args) {
1145 1145
 	global $wpinv_options;
1146 1146
     
1147
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1147
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1148 1148
 
1149
-	foreach ( $args['options'] as $key => $option ) :
1150
-		$sanitize_key = wpinv_sanitize_key( $key );
1149
+	foreach ($args['options'] as $key => $option) :
1150
+		$sanitize_key = wpinv_sanitize_key($key);
1151 1151
         
1152
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
1152
+        if (isset($wpinv_options['gateways'][$key]))
1153 1153
 			$enabled = '1';
1154 1154
 		else
1155 1155
 			$enabled = null;
1156 1156
 
1157
-		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;';
1158
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1157
+		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;';
1158
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
1159 1159
 	endforeach;
1160 1160
 }
1161 1161
 
1162 1162
 function wpinv_gateway_select_callback($args) {
1163 1163
 	global $wpinv_options;
1164 1164
     
1165
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1166
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
1165
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1166
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
1167 1167
 
1168
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
1168
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
1169 1169
 
1170
-	foreach ( $args['options'] as $key => $option ) :
1171
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1172
-            $selected = selected( $key, $args['selected'], false );
1170
+	foreach ($args['options'] as $key => $option) :
1171
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1172
+            $selected = selected($key, $args['selected'], false);
1173 1173
         } else {
1174
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1174
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
1175 1175
         }
1176
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1176
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
1177 1177
 	endforeach;
1178 1178
 
1179 1179
 	echo '</select>';
1180
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1180
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1181 1181
 }
1182 1182
 
1183
-function wpinv_text_callback( $args ) {
1183
+function wpinv_text_callback($args) {
1184 1184
 	global $wpinv_options;
1185 1185
     
1186
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1186
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1187 1187
 
1188
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1189
-		$value = $wpinv_options[ $args['id'] ];
1188
+	if (isset($wpinv_options[$args['id']])) {
1189
+		$value = $wpinv_options[$args['id']];
1190 1190
 	} else {
1191
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1191
+		$value = isset($args['std']) ? $args['std'] : '';
1192 1192
 	}
1193 1193
 
1194
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1194
+	if (isset($args['faux']) && true === $args['faux']) {
1195 1195
 		$args['readonly'] = true;
1196
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1196
+		$value = isset($args['std']) ? $args['std'] : '';
1197 1197
 		$name  = '';
1198 1198
 	} else {
1199
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1199
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1200 1200
 	}
1201
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1201
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1202 1202
 
1203 1203
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1204
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1205
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1206
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1204
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1205
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
1206
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1207 1207
 
1208 1208
 	echo $html;
1209 1209
 }
1210 1210
 
1211
-function wpinv_number_callback( $args ) {
1211
+function wpinv_number_callback($args) {
1212 1212
 	global $wpinv_options;
1213 1213
     
1214
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1214
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1215 1215
 
1216
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1217
-		$value = $wpinv_options[ $args['id'] ];
1216
+	if (isset($wpinv_options[$args['id']])) {
1217
+		$value = $wpinv_options[$args['id']];
1218 1218
 	} else {
1219
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1219
+		$value = isset($args['std']) ? $args['std'] : '';
1220 1220
 	}
1221 1221
 
1222
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1222
+	if (isset($args['faux']) && true === $args['faux']) {
1223 1223
 		$args['readonly'] = true;
1224
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1224
+		$value = isset($args['std']) ? $args['std'] : '';
1225 1225
 		$name  = '';
1226 1226
 	} else {
1227
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1227
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1228 1228
 	}
1229 1229
 
1230
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1231
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1232
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1233
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1230
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1231
+	$min  = isset($args['min']) ? $args['min'] : 0;
1232
+	$step = isset($args['step']) ? $args['step'] : 1;
1233
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1234 1234
 
1235
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1236
-	$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 ) ) . '"/>';
1237
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1235
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1236
+	$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)) . '"/>';
1237
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1238 1238
 
1239 1239
 	echo $html;
1240 1240
 }
1241 1241
 
1242
-function wpinv_textarea_callback( $args ) {
1242
+function wpinv_textarea_callback($args) {
1243 1243
 	global $wpinv_options;
1244 1244
     
1245
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1245
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1246 1246
 
1247
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1248
-		$value = $wpinv_options[ $args['id'] ];
1247
+	if (isset($wpinv_options[$args['id']])) {
1248
+		$value = $wpinv_options[$args['id']];
1249 1249
 	} else {
1250
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1250
+		$value = isset($args['std']) ? $args['std'] : '';
1251 1251
 	}
1252 1252
     
1253
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1254
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1253
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1254
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1255 1255
 
1256
-	$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>';
1257
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1256
+	$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>';
1257
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1258 1258
 
1259 1259
 	echo $html;
1260 1260
 }
1261 1261
 
1262
-function wpinv_password_callback( $args ) {
1262
+function wpinv_password_callback($args) {
1263 1263
 	global $wpinv_options;
1264 1264
     
1265
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1265
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1266 1266
 
1267
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1268
-		$value = $wpinv_options[ $args['id'] ];
1267
+	if (isset($wpinv_options[$args['id']])) {
1268
+		$value = $wpinv_options[$args['id']];
1269 1269
 	} else {
1270
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1270
+		$value = isset($args['std']) ? $args['std'] : '';
1271 1271
 	}
1272 1272
 
1273
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1274
-	$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 ) . '"/>';
1275
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1273
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1274
+	$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) . '"/>';
1275
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1276 1276
 
1277 1277
 	echo $html;
1278 1278
 }
1279 1279
 
1280 1280
 function wpinv_missing_callback($args) {
1281 1281
 	printf(
1282
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1282
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1283 1283
 		'<strong>' . $args['id'] . '</strong>'
1284 1284
 	);
1285 1285
 }
@@ -1287,133 +1287,133 @@  discard block
 block discarded – undo
1287 1287
 function wpinv_select_callback($args) {
1288 1288
 	global $wpinv_options;
1289 1289
     
1290
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1290
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1291 1291
 
1292
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1293
-		$value = $wpinv_options[ $args['id'] ];
1292
+	if (isset($wpinv_options[$args['id']])) {
1293
+		$value = $wpinv_options[$args['id']];
1294 1294
 	} else {
1295
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1295
+		$value = isset($args['std']) ? $args['std'] : '';
1296 1296
 	}
1297 1297
     
1298
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1298
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1299 1299
         $value = $args['selected'];
1300 1300
     }
1301 1301
 
1302
-	if ( isset( $args['placeholder'] ) ) {
1302
+	if (isset($args['placeholder'])) {
1303 1303
 		$placeholder = $args['placeholder'];
1304 1304
 	} else {
1305 1305
 		$placeholder = '';
1306 1306
 	}
1307 1307
     
1308
-    if( !empty( $args['onchange'] ) ) {
1309
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1308
+    if (!empty($args['onchange'])) {
1309
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1310 1310
     } else {
1311 1311
         $onchange = '';
1312 1312
     }
1313 1313
 
1314
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
1314
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
1315 1315
 
1316
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1316
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '"  name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1317 1317
 
1318
-	foreach ( $args['options'] as $option => $name ) {
1319
-		$selected = selected( $option, $value, false );
1320
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1318
+	foreach ($args['options'] as $option => $name) {
1319
+		$selected = selected($option, $value, false);
1320
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1321 1321
 	}
1322 1322
 
1323 1323
 	$html .= '</select>';
1324
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1324
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1325 1325
 
1326 1326
 	echo $html;
1327 1327
 }
1328 1328
 
1329
-function wpinv_color_select_callback( $args ) {
1329
+function wpinv_color_select_callback($args) {
1330 1330
 	global $wpinv_options;
1331 1331
     
1332
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1332
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1333 1333
 
1334
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1335
-		$value = $wpinv_options[ $args['id'] ];
1334
+	if (isset($wpinv_options[$args['id']])) {
1335
+		$value = $wpinv_options[$args['id']];
1336 1336
 	} else {
1337
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1337
+		$value = isset($args['std']) ? $args['std'] : '';
1338 1338
 	}
1339 1339
 
1340
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1340
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1341 1341
 
1342
-	foreach ( $args['options'] as $option => $color ) {
1343
-		$selected = selected( $option, $value, false );
1344
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1342
+	foreach ($args['options'] as $option => $color) {
1343
+		$selected = selected($option, $value, false);
1344
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1345 1345
 	}
1346 1346
 
1347 1347
 	$html .= '</select>';
1348
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1348
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1349 1349
 
1350 1350
 	echo $html;
1351 1351
 }
1352 1352
 
1353
-function wpinv_rich_editor_callback( $args ) {
1353
+function wpinv_rich_editor_callback($args) {
1354 1354
 	global $wpinv_options, $wp_version;
1355 1355
     
1356
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1356
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1357 1357
 
1358
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1359
-		$value = $wpinv_options[ $args['id'] ];
1358
+	if (isset($wpinv_options[$args['id']])) {
1359
+		$value = $wpinv_options[$args['id']];
1360 1360
 
1361
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1362
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1361
+		if (empty($args['allow_blank']) && empty($value)) {
1362
+			$value = isset($args['std']) ? $args['std'] : '';
1363 1363
 		}
1364 1364
 	} else {
1365
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1365
+		$value = isset($args['std']) ? $args['std'] : '';
1366 1366
 	}
1367 1367
 
1368
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1368
+	$rows = isset($args['size']) ? $args['size'] : 20;
1369 1369
 
1370
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1370
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1371 1371
 		ob_start();
1372
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
1372
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
1373 1373
 		$html = ob_get_clean();
1374 1374
 	} else {
1375
-		$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>';
1375
+		$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>';
1376 1376
 	}
1377 1377
 
1378
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1378
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1379 1379
 
1380 1380
 	echo $html;
1381 1381
 }
1382 1382
 
1383
-function wpinv_upload_callback( $args ) {
1383
+function wpinv_upload_callback($args) {
1384 1384
 	global $wpinv_options;
1385 1385
     
1386
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1386
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1387 1387
 
1388
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1388
+	if (isset($wpinv_options[$args['id']])) {
1389 1389
 		$value = $wpinv_options[$args['id']];
1390 1390
 	} else {
1391 1391
 		$value = isset($args['std']) ? $args['std'] : '';
1392 1392
 	}
1393 1393
 
1394
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1395
-	$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 ) ) . '"/>';
1396
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1397
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1394
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1395
+	$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)) . '"/>';
1396
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1397
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1398 1398
 
1399 1399
 	echo $html;
1400 1400
 }
1401 1401
 
1402
-function wpinv_color_callback( $args ) {
1402
+function wpinv_color_callback($args) {
1403 1403
 	global $wpinv_options;
1404 1404
     
1405
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1405
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1406 1406
 
1407
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1408
-		$value = $wpinv_options[ $args['id'] ];
1407
+	if (isset($wpinv_options[$args['id']])) {
1408
+		$value = $wpinv_options[$args['id']];
1409 1409
 	} else {
1410
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1410
+		$value = isset($args['std']) ? $args['std'] : '';
1411 1411
 	}
1412 1412
 
1413
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1413
+	$default = isset($args['std']) ? $args['std'] : '';
1414 1414
 
1415
-	$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 ) . '" />';
1416
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1415
+	$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) . '" />';
1416
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1417 1417
 
1418 1418
 	echo $html;
1419 1419
 }
@@ -1421,9 +1421,9 @@  discard block
 block discarded – undo
1421 1421
 function wpinv_country_states_callback($args) {
1422 1422
 	global $wpinv_options;
1423 1423
     
1424
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1424
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1425 1425
 
1426
-	if ( isset( $args['placeholder'] ) ) {
1426
+	if (isset($args['placeholder'])) {
1427 1427
 		$placeholder = $args['placeholder'];
1428 1428
 	} else {
1429 1429
 		$placeholder = '';
@@ -1431,16 +1431,16 @@  discard block
 block discarded – undo
1431 1431
 
1432 1432
 	$states = wpinv_get_country_states();
1433 1433
 
1434
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
1435
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1434
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
1435
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1436 1436
 
1437
-	foreach ( $states as $option => $name ) {
1438
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1439
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1437
+	foreach ($states as $option => $name) {
1438
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1439
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1440 1440
 	}
1441 1441
 
1442 1442
 	$html .= '</select>';
1443
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1443
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1444 1444
 
1445 1445
 	echo $html;
1446 1446
 }
@@ -1455,96 +1455,96 @@  discard block
 block discarded – undo
1455 1455
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1456 1456
 		<thead>
1457 1457
 			<tr>
1458
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1459
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1460
-                <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>
1461
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1462
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1463
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1458
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1459
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1460
+                <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>
1461
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1462
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1463
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1464 1464
 			</tr>
1465 1465
 		</thead>
1466 1466
         <tbody>
1467
-		<?php if( !empty( $rates ) ) : ?>
1468
-			<?php foreach( $rates as $key => $rate ) : ?>
1467
+		<?php if (!empty($rates)) : ?>
1468
+			<?php foreach ($rates as $key => $rate) : ?>
1469 1469
             <?php 
1470
-            $sanitized_key = wpinv_sanitize_key( $key );
1470
+            $sanitized_key = wpinv_sanitize_key($key);
1471 1471
             ?>
1472 1472
 			<tr>
1473 1473
 				<td class="wpinv_tax_country">
1474 1474
 					<?php
1475
-					echo wpinv_html_select( array(
1476
-						'options'          => wpinv_get_country_list( true ),
1475
+					echo wpinv_html_select(array(
1476
+						'options'          => wpinv_get_country_list(true),
1477 1477
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1478 1478
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1479 1479
 						'selected'         => $rate['country'],
1480 1480
 						'show_option_all'  => false,
1481 1481
 						'show_option_none' => false,
1482 1482
 						'class'            => 'wpinv-tax-country wpi_select2',
1483
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1484
-					) );
1483
+						'placeholder'      => __('Choose a country', 'invoicing')
1484
+					));
1485 1485
 					?>
1486 1486
 				</td>
1487 1487
 				<td class="wpinv_tax_state">
1488 1488
 					<?php
1489
-					$states = wpinv_get_country_states( $rate['country'] );
1490
-					if( !empty( $states ) ) {
1491
-						echo wpinv_html_select( array(
1492
-							'options'          => array_merge( array( '' => '' ), $states ),
1489
+					$states = wpinv_get_country_states($rate['country']);
1490
+					if (!empty($states)) {
1491
+						echo wpinv_html_select(array(
1492
+							'options'          => array_merge(array('' => ''), $states),
1493 1493
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1494 1494
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1495 1495
 							'selected'         => $rate['state'],
1496 1496
 							'show_option_all'  => false,
1497 1497
 							'show_option_none' => false,
1498 1498
                             'class'            => 'wpi_select2',
1499
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1500
-						) );
1499
+							'placeholder'      => __('Choose a state', 'invoicing')
1500
+						));
1501 1501
 					} else {
1502
-						echo wpinv_html_text( array(
1502
+						echo wpinv_html_text(array(
1503 1503
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1504
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1504
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1505 1505
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1506
-						) );
1506
+						));
1507 1507
 					}
1508 1508
 					?>
1509 1509
 				</td>
1510 1510
 				<td class="wpinv_tax_global">
1511
-					<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'] ) ); ?>/>
1512
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1511
+					<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'])); ?>/>
1512
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1513 1513
 				</td>
1514
-				<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>
1515
-                <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>
1516
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1514
+				<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>
1515
+                <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>
1516
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1517 1517
 			</tr>
1518 1518
 			<?php endforeach; ?>
1519 1519
 		<?php else : ?>
1520 1520
 			<tr>
1521 1521
 				<td class="wpinv_tax_country">
1522 1522
 					<?php
1523
-					echo wpinv_html_select( array(
1524
-						'options'          => wpinv_get_country_list( true ),
1523
+					echo wpinv_html_select(array(
1524
+						'options'          => wpinv_get_country_list(true),
1525 1525
 						'name'             => 'tax_rates[0][country]',
1526 1526
 						'show_option_all'  => false,
1527 1527
 						'show_option_none' => false,
1528 1528
 						'class'            => 'wpinv-tax-country wpi_select2',
1529
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1530
-					) ); ?>
1529
+						'placeholder'      => __('Choose a country', 'invoicing')
1530
+					)); ?>
1531 1531
 				</td>
1532 1532
 				<td class="wpinv_tax_state">
1533
-					<?php echo wpinv_html_text( array(
1533
+					<?php echo wpinv_html_text(array(
1534 1534
 						'name' => 'tax_rates[0][state]'
1535
-					) ); ?>
1535
+					)); ?>
1536 1536
 				</td>
1537 1537
 				<td class="wpinv_tax_global">
1538 1538
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1539
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1539
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1540 1540
 				</td>
1541
-				<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>
1541
+				<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>
1542 1542
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1543
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1543
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1544 1544
 			</tr>
1545 1545
 		<?php endif; ?>
1546 1546
         </tbody>
1547
-        <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>
1547
+        <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>
1548 1548
 	</table>
1549 1549
 	<?php
1550 1550
 	echo ob_get_clean();
@@ -1555,76 +1555,76 @@  discard block
 block discarded – undo
1555 1555
     ob_start(); ?>
1556 1556
     </td><tr>
1557 1557
     <td colspan="2" class="wpinv_tools_tdbox">
1558
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1559
-    <?php do_action( 'wpinv_tools_before' ); ?>
1558
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1559
+    <?php do_action('wpinv_tools_before'); ?>
1560 1560
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1561 1561
         <thead>
1562 1562
             <tr>
1563
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1564
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1565
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1563
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1564
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1565
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1566 1566
             </tr>
1567 1567
         </thead>
1568
-            <?php do_action( 'wpinv_tools_row' ); ?>
1568
+            <?php do_action('wpinv_tools_row'); ?>
1569 1569
         <tbody>
1570 1570
         </tbody>
1571 1571
     </table>
1572
-    <?php do_action( 'wpinv_tools_after' ); ?>
1572
+    <?php do_action('wpinv_tools_after'); ?>
1573 1573
     <?php
1574 1574
     echo ob_get_clean();
1575 1575
 }
1576 1576
 
1577
-function wpinv_descriptive_text_callback( $args ) {
1578
-	echo wp_kses_post( $args['desc'] );
1577
+function wpinv_descriptive_text_callback($args) {
1578
+	echo wp_kses_post($args['desc']);
1579 1579
 }
1580 1580
 
1581
-function wpinv_hook_callback( $args ) {
1582
-	do_action( 'wpinv_' . $args['id'], $args );
1581
+function wpinv_hook_callback($args) {
1582
+	do_action('wpinv_' . $args['id'], $args);
1583 1583
 }
1584 1584
 
1585 1585
 function wpinv_set_settings_cap() {
1586 1586
 	return wpinv_get_capability();
1587 1587
 }
1588
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1588
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1589 1589
 
1590
-function wpinv_settings_sanitize_input( $value, $key ) {
1591
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1592
-        $value = wpinv_sanitize_amount( $value, 4 );
1590
+function wpinv_settings_sanitize_input($value, $key) {
1591
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1592
+        $value = wpinv_sanitize_amount($value, 4);
1593 1593
         $value = $value >= 100 ? 99 : $value;
1594 1594
     }
1595 1595
         
1596 1596
     return $value;
1597 1597
 }
1598
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1598
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1599 1599
 
1600
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1601
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1602
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1600
+function wpinv_on_update_settings($old_value, $value, $option) {
1601
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1602
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1603 1603
     
1604
-    if ( $old != $new ) {
1605
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1604
+    if ($old != $new) {
1605
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1606 1606
     }
1607 1607
 }
1608
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1609
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1610
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1611
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1612
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1613
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1614
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1615
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1616
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1617
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1618
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1619
-
1620
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1608
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1609
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1610
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1611
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1612
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1613
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1614
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1615
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1616
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1617
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1618
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1619
+
1620
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1621 1621
     ?>
1622 1622
     <div class="wpinv-email-wc-row ">
1623 1623
         <div class="wpinv-email-wc-td">
1624
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1624
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1625 1625
             <p class="wpinv-email-wc-description">
1626 1626
                 <?php
1627
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1627
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1628 1628
                     <strong>{site_title} :</strong> Site Title<br>
1629 1629
                     <strong>{name} :</strong> Customer\'s full name<br>
1630 1630
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1638,7 +1638,7 @@  discard block
 block discarded – undo
1638 1638
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1639 1639
                     <strong>{date} :</strong> Today\'s date.<br>
1640 1640
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1641
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1641
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1642 1642
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1643 1643
                 ?>
1644 1644
             </p>
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,40 +13,40 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
17
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 99 );
18
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
19
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
17
+        add_action('admin_menu', array($this, 'add_addons_menu'), 99);
18
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
19
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
20 20
     }
21 21
 
22 22
     public function admin_menu() {
23 23
         global $menu, $submenu;
24 24
 
25
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
25
+        if (!wpinv_current_user_can_manage_invoicing()) {
26 26
             return;
27 27
         }
28 28
 
29
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
29
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
30 30
 
31
-        if ( wpinv_current_user_can_manage_invoicing() ) {
32
-            $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' );
31
+        if (wpinv_current_user_can_manage_invoicing()) {
32
+            $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv');
33 33
 
34 34
             // Allow users with 'manage_invocing' capability to create new invoices
35
-            $submenu['post-new.php?post_type=wpi_invoice'][] = array( '', '', 'post-new.php?post_type=wpi_invoice', '' );
36
-            $submenu['post-new.php?post_type=wpi_item'][] = array( '', '', 'post-new.php?post_type=wpi_item', '' );
37
-            $submenu['post-new.php?post_type=wpi_discount'][] = array( '', '', 'post-new.php?post_type=wpi_discount', '' );
35
+            $submenu['post-new.php?post_type=wpi_invoice'][] = array('', '', 'post-new.php?post_type=wpi_invoice', '');
36
+            $submenu['post-new.php?post_type=wpi_item'][] = array('', '', 'post-new.php?post_type=wpi_item', '');
37
+            $submenu['post-new.php?post_type=wpi_discount'][] = array('', '', 'post-new.php?post_type=wpi_discount', '');
38 38
 
39 39
         }
40 40
 
41
-        $wpi_invoice = get_post_type_object( 'wpi_invoice' );
41
+        $wpi_invoice = get_post_type_object('wpi_invoice');
42 42
 
43
-        add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' );
43
+        add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460');
44 44
 
45
-        add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', array( $this, 'options_page' ));
45
+        add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', array($this, 'options_page'));
46 46
     }
47 47
 
48
-    public function add_addons_menu(){
49
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
48
+    public function add_addons_menu() {
49
+        if (!apply_filters('wpi_show_addons_page', true)) {
50 50
             return;
51 51
         }
52 52
 
@@ -56,78 +56,78 @@  discard block
 block discarded – undo
56 56
             __('Extensions', 'invoicing'),
57 57
             'manage_options',
58 58
             'wpi-addons',
59
-            array( $this, 'addons_page' )
59
+            array($this, 'addons_page')
60 60
         );
61 61
     }
62 62
 
63
-    public function addons_page(){
63
+    public function addons_page() {
64 64
         $addon_obj = new WPInv_Admin_Addons();
65 65
         $addon_obj->output();
66 66
     }
67 67
 
68 68
     function options_page() {
69
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
69
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
70 70
 
71
-        if ( $page !== 'wpinv-settings' ) {
71
+        if ($page !== 'wpinv-settings') {
72 72
             return;
73 73
         }
74 74
 
75 75
         $settings_tabs = wpinv_get_settings_tabs();
76 76
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
77
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
78
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
77
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
78
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
79 79
         $key           = 'main';
80 80
 
81
-        if ( is_array( $sections ) ) {
82
-            $key = key( $sections );
81
+        if (is_array($sections)) {
82
+            $key = key($sections);
83 83
         }
84 84
 
85
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
86
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
85
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
86
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
87 87
         ob_start();
88 88
         ?>
89 89
         <div class="wrap">
90 90
             <h1 class="nav-tab-wrapper">
91 91
                 <?php
92
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
93
-                    $tab_url = add_query_arg( array(
92
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
93
+                    $tab_url = add_query_arg(array(
94 94
                         'settings-updated' => false,
95 95
                         'tab' => $tab_id,
96
-                    ) );
96
+                    ));
97 97
 
98 98
                     // Remove the section from the tabs so we always end up at the main section
99
-                    $tab_url = remove_query_arg( 'section', $tab_url );
100
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
99
+                    $tab_url = remove_query_arg('section', $tab_url);
100
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
101 101
 
102 102
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
103 103
 
104
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
105
-                    echo esc_html( $tab_name );
104
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
105
+                    echo esc_html($tab_name);
106 106
                     echo '</a>';
107 107
                 }
108 108
                 ?>
109 109
             </h1>
110 110
             <?php
111
-            $number_of_sections = count( $sections );
111
+            $number_of_sections = count($sections);
112 112
             $number = 0;
113
-            if ( $number_of_sections > 1 ) {
113
+            if ($number_of_sections > 1) {
114 114
                 echo '<div><ul class="subsubsub">';
115
-                foreach( $sections as $section_id => $section_name ) {
115
+                foreach ($sections as $section_id => $section_name) {
116 116
                     echo '<li>';
117 117
                     $number++;
118
-                    $tab_url = add_query_arg( array(
118
+                    $tab_url = add_query_arg(array(
119 119
                         'settings-updated' => false,
120 120
                         'tab' => $active_tab,
121 121
                         'section' => $section_id
122
-                    ) );
123
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
122
+                    ));
123
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
124 124
                     $class = '';
125
-                    if ( $section == $section_id ) {
125
+                    if ($section == $section_id) {
126 126
                         $class = 'current';
127 127
                     }
128
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
128
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
129 129
 
130
-                    if ( $number != $number_of_sections ) {
130
+                    if ($number != $number_of_sections) {
131 131
                         echo ' | ';
132 132
                     }
133 133
                     echo '</li>';
@@ -139,19 +139,19 @@  discard block
 block discarded – undo
139 139
                 <form method="post" action="options.php">
140 140
                     <table class="form-table">
141 141
                         <?php
142
-                        settings_fields( 'wpinv_settings' );
142
+                        settings_fields('wpinv_settings');
143 143
 
144
-                        if ( 'main' === $section ) {
145
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
144
+                        if ('main' === $section) {
145
+                            do_action('wpinv_settings_tab_top', $active_tab);
146 146
                         }
147 147
 
148
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
149
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
150
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
148
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
149
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
150
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
151 151
 
152 152
                         // For backwards compatibility
153
-                        if ( 'main' === $section ) {
154
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
153
+                        if ('main' === $section) {
154
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
155 155
                         }
156 156
                         ?>
157 157
                     </table>
@@ -165,18 +165,18 @@  discard block
 block discarded – undo
165 165
     }
166 166
 
167 167
     public function remove_admin_submenus() {
168
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
168
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
169 169
     }
170 170
 
171
-    public function add_nav_menu_meta_boxes(){
172
-        add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
171
+    public function add_nav_menu_meta_boxes() {
172
+        add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low');
173 173
     }
174 174
 
175
-    public function nav_menu_links(){
175
+    public function nav_menu_links() {
176 176
         $endpoints = $this->get_menu_items();
177 177
         ?>
178 178
         <div id="invoicing-endpoints" class="posttypediv">
179
-        <?php if(!empty($endpoints['pages'])){ ?>
179
+        <?php if (!empty($endpoints['pages'])) { ?>
180 180
             <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
181 181
                 <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
182 182
                     <?php
@@ -188,29 +188,29 @@  discard block
 block discarded – undo
188 188
         <?php } ?>
189 189
         <p class="button-controls">
190 190
         <span class="list-controls">
191
-            <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a>
191
+            <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a>
192 192
         </span>
193 193
             <span class="add-to-menu">
194
-            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
194
+            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
195 195
             <span class="spinner"></span>
196 196
         </span>
197 197
         </p>
198 198
         <?php
199 199
     }
200 200
 
201
-    public function get_menu_items(){
201
+    public function get_menu_items() {
202 202
         $items = array();
203 203
 
204
-        $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' );
205
-        if($wpinv_history_page_id > 0){
204
+        $wpinv_history_page_id = (int) wpinv_get_option('invoice_history_page');
205
+        if ($wpinv_history_page_id > 0) {
206 206
             $item = new stdClass();
207 207
             $item->object_id = $wpinv_history_page_id;
208 208
             $item->db_id = 0;
209
-            $item->object =  'page';
209
+            $item->object = 'page';
210 210
             $item->menu_item_parent = 0;
211 211
             $item->type = 'post_type';
212
-            $item->title = __('Invoice History Page','invoicing');
213
-            $item->url = get_permalink( $wpinv_history_page_id );
212
+            $item->title = __('Invoice History Page', 'invoicing');
213
+            $item->url = get_permalink($wpinv_history_page_id);
214 214
             $item->target = '';
215 215
             $item->attr_title = '';
216 216
             $item->classes = array('wpinv-menu-item');
@@ -219,16 +219,16 @@  discard block
 block discarded – undo
219 219
             $items['pages'][] = $item;
220 220
         }
221 221
 
222
-        $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' );
223
-        if($wpinv_sub_history_page_id > 0){
222
+        $wpinv_sub_history_page_id = (int) wpinv_get_option('invoice_subscription_page');
223
+        if ($wpinv_sub_history_page_id > 0) {
224 224
             $item = new stdClass();
225 225
             $item->object_id = $wpinv_sub_history_page_id;
226 226
             $item->db_id = 0;
227
-            $item->object =  'page';
227
+            $item->object = 'page';
228 228
             $item->menu_item_parent = 0;
229 229
             $item->type = 'post_type';
230
-            $item->title = __('Invoice Subscriptions Page','invoicing');
231
-            $item->url = get_permalink( $wpinv_sub_history_page_id );
230
+            $item->title = __('Invoice Subscriptions Page', 'invoicing');
231
+            $item->url = get_permalink($wpinv_sub_history_page_id);
232 232
             $item->target = '';
233 233
             $item->attr_title = '';
234 234
             $item->classes = array('wpinv-menu-item');
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
             $items['pages'][] = $item;
238 238
         }
239 239
 
240
-        $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' );
241
-        if($wpinv_checkout_page_id > 0){
240
+        $wpinv_checkout_page_id = (int) wpinv_get_option('checkout_page');
241
+        if ($wpinv_checkout_page_id > 0) {
242 242
             $item = new stdClass();
243 243
             $item->object_id = $wpinv_checkout_page_id;
244 244
             $item->db_id = 0;
245
-            $item->object =  'page';
245
+            $item->object = 'page';
246 246
             $item->menu_item_parent = 0;
247 247
             $item->type = 'post_type';
248
-            $item->title = __('Checkout Page','invoicing');
249
-            $item->url = get_permalink( $wpinv_checkout_page_id );
248
+            $item->title = __('Checkout Page', 'invoicing');
249
+            $item->url = get_permalink($wpinv_checkout_page_id);
250 250
             $item->target = '';
251 251
             $item->attr_title = '';
252 252
             $item->classes = array('wpinv-menu-item');
@@ -255,16 +255,16 @@  discard block
 block discarded – undo
255 255
             $items['pages'][] = $item;
256 256
         }
257 257
 
258
-        $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' );
259
-        if($wpinv_tandc_page_id > 0){
258
+        $wpinv_tandc_page_id = (int) wpinv_get_option('tandc_page');
259
+        if ($wpinv_tandc_page_id > 0) {
260 260
             $item = new stdClass();
261 261
             $item->object_id = $wpinv_tandc_page_id;
262 262
             $item->db_id = 0;
263
-            $item->object =  'page';
263
+            $item->object = 'page';
264 264
             $item->menu_item_parent = 0;
265 265
             $item->type = 'post_type';
266
-            $item->title = __('Terms & Conditions','invoicing');
267
-            $item->url = get_permalink( $wpinv_tandc_page_id );
266
+            $item->title = __('Terms & Conditions', 'invoicing');
267
+            $item->url = get_permalink($wpinv_tandc_page_id);
268 268
             $item->target = '';
269 269
             $item->attr_title = '';
270 270
             $item->classes = array('wpinv-menu-item');
@@ -273,16 +273,16 @@  discard block
 block discarded – undo
273 273
             $items['pages'][] = $item;
274 274
         }
275 275
 
276
-        $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' );
277
-        if($wpinv_success_page_id > 0){
276
+        $wpinv_success_page_id = (int) wpinv_get_option('success_page');
277
+        if ($wpinv_success_page_id > 0) {
278 278
             $item = new stdClass();
279 279
             $item->object_id = $wpinv_success_page_id;
280 280
             $item->db_id = 0;
281
-            $item->object =  'page';
281
+            $item->object = 'page';
282 282
             $item->menu_item_parent = 0;
283 283
             $item->type = 'post_type';
284
-            $item->title = __('Success Page','invoicing');
285
-            $item->url = get_permalink( $wpinv_success_page_id );
284
+            $item->title = __('Success Page', 'invoicing');
285
+            $item->url = get_permalink($wpinv_success_page_id);
286 286
             $item->target = '';
287 287
             $item->attr_title = '';
288 288
             $item->classes = array('wpinv-menu-item');
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
             $items['pages'][] = $item;
292 292
         }
293 293
 
294
-        $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' );
295
-        if($wpinv_failure_page_id > 0){
294
+        $wpinv_failure_page_id = (int) wpinv_get_option('failure_page');
295
+        if ($wpinv_failure_page_id > 0) {
296 296
             $item = new stdClass();
297 297
             $item->object_id = $wpinv_failure_page_id;
298 298
             $item->db_id = 0;
299
-            $item->object =  'page';
299
+            $item->object = 'page';
300 300
             $item->menu_item_parent = 0;
301 301
             $item->type = 'post_type';
302
-            $item->title = __('Failed Transaction Page','invoicing');
303
-            $item->url = get_permalink( $wpinv_failure_page_id );
302
+            $item->title = __('Failed Transaction Page', 'invoicing');
303
+            $item->url = get_permalink($wpinv_failure_page_id);
304 304
             $item->target = '';
305 305
             $item->attr_title = '';
306 306
             $item->classes = array('wpinv-menu-item');
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
             $items['pages'][] = $item;
310 310
         }
311 311
 
312
-        return apply_filters( 'wpinv_menu_items', $items );
312
+        return apply_filters('wpinv_menu_items', $items);
313 313
     }
314 314
 
315 315
 }
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 1 patch
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly
4
-if ( ! defined( 'ABSPATH' ) ) {
4
+if (!defined('ABSPATH')) {
5 5
 	exit;
6 6
 }
7 7
 
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @since  1.0.0
39 39
 	 * @return void
40 40
 	 */
41
-	function __construct( $_id_or_object = 0, $_by_profile_id = false ) {
41
+	function __construct($_id_or_object = 0, $_by_profile_id = false) {
42 42
 
43 43
 		$this->subs_db = new WPInv_Subscriptions_DB;
44 44
 
45
-		if( $_by_profile_id ) {
45
+		if ($_by_profile_id) {
46 46
 
47
-			$_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object );
47
+			$_sub = $this->subs_db->get_by('profile_id', $_id_or_object);
48 48
 
49
-			if( empty( $_sub ) ) {
49
+			if (empty($_sub)) {
50 50
 				return false;
51 51
 			}
52 52
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 		}
56 56
 
57
-		return $this->setup_subscription( $_id_or_object );
57
+		return $this->setup_subscription($_id_or_object);
58 58
 	}
59 59
 
60 60
 	/**
@@ -63,34 +63,34 @@  discard block
 block discarded – undo
63 63
 	 * @since  1.0.0
64 64
 	 * @return void
65 65
 	 */
66
-	private function setup_subscription( $id_or_object = 0 ) {
66
+	private function setup_subscription($id_or_object = 0) {
67 67
 
68
-		if( empty( $id_or_object ) ) {
68
+		if (empty($id_or_object)) {
69 69
 			return false;
70 70
 		}
71 71
 
72
-		if( is_numeric( $id_or_object ) ) {
72
+		if (is_numeric($id_or_object)) {
73 73
 
74
-			$sub = $this->subs_db->get( $id_or_object );
74
+			$sub = $this->subs_db->get($id_or_object);
75 75
 
76
-		} elseif( is_object( $id_or_object ) ) {
76
+		} elseif (is_object($id_or_object)) {
77 77
 
78 78
 			$sub = $id_or_object;
79 79
 
80 80
 		}
81 81
 
82
-		if( empty( $sub ) ) {
82
+		if (empty($sub)) {
83 83
 			return false;
84 84
 		}
85 85
 
86
-		foreach( $sub as $key => $value ) {
86
+		foreach ($sub as $key => $value) {
87 87
 			$this->$key = $value;
88 88
 		}
89 89
 
90
-		$this->customer = get_userdata( $this->customer_id );
91
-		$this->gateway  = wpinv_get_payment_gateway( $this->parent_payment_id );
90
+		$this->customer = get_userdata($this->customer_id);
91
+		$this->gateway  = wpinv_get_payment_gateway($this->parent_payment_id);
92 92
 
93
-		do_action( 'wpinv_recurring_setup_subscription', $this );
93
+		do_action('wpinv_recurring_setup_subscription', $this);
94 94
 
95 95
 		return $this;
96 96
 	}
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @since 1.0.0
102 102
 	 */
103
-	public function __get( $key ) {
103
+	public function __get($key) {
104 104
 
105
-		if( method_exists( $this, 'get_' . $key ) ) {
105
+		if (method_exists($this, 'get_' . $key)) {
106 106
 
107
-			return call_user_func( array( $this, 'get_' . $key ) );
107
+			return call_user_func(array($this, 'get_' . $key));
108 108
 
109 109
 		} else {
110 110
 
111
-			return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
111
+			return new WP_Error('wpinv-subscription-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key));
112 112
 
113 113
 		}
114 114
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	 * @param  array  $data Array of attributes for a subscription
122 122
 	 * @return mixed  false if data isn't passed and class not instantiated for creation
123 123
 	 */
124
-	public function create( $data = array() ) {
124
+	public function create($data = array()) {
125 125
 
126
-		if ( $this->id != 0 ) {
126
+		if ($this->id != 0) {
127 127
 			return false;
128 128
 		}
129 129
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 			'profile_id'        => '',
143 143
 		);
144 144
 
145
-		$args = wp_parse_args( $data, $defaults );
145
+		$args = wp_parse_args($data, $defaults);
146 146
 
147
-		if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
147
+		if ($args['expiration'] && strtotime('NOW', current_time('timestamp')) > strtotime($args['expiration'], current_time('timestamp'))) {
148 148
 
149
-			if( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
149
+			if ('active' == $args['status'] || 'trialling' == $args['status']) {
150 150
 
151 151
 				// Force an active subscription to expired if expiration date is in the past
152 152
 				$args['status'] = 'expired';
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
 			}
155 155
 		}
156 156
 
157
-		do_action( 'wpinv_subscription_pre_create', $args );
157
+		do_action('wpinv_subscription_pre_create', $args);
158 158
 
159
-		$id = $this->subs_db->insert( $args, 'subscription' );
159
+		$id = $this->subs_db->insert($args, 'subscription');
160 160
 
161
-		do_action( 'wpinv_subscription_post_create', $id, $args );
161
+		do_action('wpinv_subscription_post_create', $id, $args);
162 162
 
163
-		return $this->setup_subscription( $id );
163
+		return $this->setup_subscription($id);
164 164
 
165 165
 	}
166 166
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	 * @param  array $args Array of fields to update
172 172
 	 * @return bool
173 173
 	 */
174
-	public function update( $args = array() ) {
174
+	public function update($args = array()) {
175 175
 
176
-		$ret = $this->subs_db->update( $this->id, $args );
176
+		$ret = $this->subs_db->update($this->id, $args);
177 177
 
178
-		do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
178
+		do_action('wpinv_recurring_update_subscription', $this->id, $args, $this);
179 179
 
180 180
 		return $ret;
181 181
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @return bool
189 189
 	 */
190 190
 	public function delete() {
191
-		return $this->subs_db->delete( $this->id );
191
+		return $this->subs_db->delete($this->id);
192 192
 	}
193 193
 
194 194
     /**
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
      * @return array
209 209
      */
210 210
     public function get_child_payments() {
211
-        $payments = get_posts( array(
211
+        $payments = get_posts(array(
212 212
             'post_parent'    => (int) $this->parent_payment_id,
213 213
             'posts_per_page' => '999',
214
-            'post_status'    => array( 'publish', 'wpi-processing', 'wpi-renewal' ),
214
+            'post_status'    => array('publish', 'wpi-processing', 'wpi-renewal'),
215 215
             'orderby'           => 'ID',
216 216
             'order'             => 'DESC',
217 217
             'post_type'      => 'wpi_invoice'
218
-        ) );
218
+        ));
219 219
 
220 220
         return $payments;
221 221
     }
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public function get_total_payments() {
230 230
         $child_payments = $this->get_child_payments();
231
-        $total_payments = !empty( $child_payments ) ? count( $child_payments ) : 0;
231
+        $total_payments = !empty($child_payments) ? count($child_payments) : 0;
232 232
 
233
-        if ( 'pending' != $this->status ) {
233
+        if ('pending' != $this->status) {
234 234
                 $total_payments++;
235 235
         }
236 236
 
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
      * @return int
245 245
      */
246 246
     public function get_times_billed() {
247
-        $times_billed = (int)$this->get_total_payments();
247
+        $times_billed = (int) $this->get_total_payments();
248 248
 
249
-        if ( ! empty( $this->trial_period ) && $times_billed > 0 ) {
249
+        if (!empty($this->trial_period) && $times_billed > 0) {
250 250
             $times_billed--;
251 251
         }
252 252
 
@@ -260,51 +260,51 @@  discard block
 block discarded – undo
260 260
      * @param  array $args Array of values for the payment, including amount and transaction ID
261 261
      * @return bool
262 262
      */
263
-    public function add_payment( $args = array() ) {
264
-        if ( ! $this->parent_payment_id ) {
263
+    public function add_payment($args = array()) {
264
+        if (!$this->parent_payment_id) {
265 265
             return false;
266 266
         }
267 267
 
268
-        $args = wp_parse_args( $args, array(
268
+        $args = wp_parse_args($args, array(
269 269
             'amount'         => '',
270 270
             'transaction_id' => '',
271 271
             'gateway'        => ''
272
-        ) );
272
+        ));
273 273
         
274
-        if ( empty( $args['transaction_id'] ) || $this->payment_exists( $args['transaction_id'] ) ) {
274
+        if (empty($args['transaction_id']) || $this->payment_exists($args['transaction_id'])) {
275 275
             return false;
276 276
         }
277 277
         
278
-        $parent_invoice = wpinv_get_invoice( $this->parent_payment_id );
279
-        if ( empty( $parent_invoice->ID ) ) {
278
+        $parent_invoice = wpinv_get_invoice($this->parent_payment_id);
279
+        if (empty($parent_invoice->ID)) {
280 280
             return false;
281 281
         }
282 282
 
283 283
         $invoice = new WPInv_Invoice();
284
-        $invoice->set( 'post_type', 'wpi_invoice' );
285
-        $invoice->set( 'parent_invoice', $this->parent_payment_id );
286
-        $invoice->set( 'currency', $parent_invoice->get_currency() );
287
-        $invoice->set( 'transaction_id', $args['transaction_id'] );
288
-        $invoice->set( 'key', $parent_invoice->generate_key() );
289
-        $invoice->set( 'ip', $parent_invoice->ip );
290
-        $invoice->set( 'user_id', $parent_invoice->get_user_id() );
291
-        $invoice->set( 'first_name', $parent_invoice->get_first_name() );
292
-        $invoice->set( 'last_name', $parent_invoice->get_last_name() );
293
-        $invoice->set( 'phone', $parent_invoice->phone );
294
-        $invoice->set( 'address', $parent_invoice->address );
295
-        $invoice->set( 'city', $parent_invoice->city );
296
-        $invoice->set( 'country', $parent_invoice->country );
297
-        $invoice->set( 'state', $parent_invoice->state );
298
-        $invoice->set( 'zip', $parent_invoice->zip );
299
-        $invoice->set( 'company', $parent_invoice->company );
300
-        $invoice->set( 'vat_number', $parent_invoice->vat_number );
301
-        $invoice->set( 'vat_rate', $parent_invoice->vat_rate );
302
-        $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed );
303
-
304
-        if ( empty( $args['gateway'] ) ) {
305
-            $invoice->set( 'gateway', $parent_invoice->get_gateway() );
284
+        $invoice->set('post_type', 'wpi_invoice');
285
+        $invoice->set('parent_invoice', $this->parent_payment_id);
286
+        $invoice->set('currency', $parent_invoice->get_currency());
287
+        $invoice->set('transaction_id', $args['transaction_id']);
288
+        $invoice->set('key', $parent_invoice->generate_key());
289
+        $invoice->set('ip', $parent_invoice->ip);
290
+        $invoice->set('user_id', $parent_invoice->get_user_id());
291
+        $invoice->set('first_name', $parent_invoice->get_first_name());
292
+        $invoice->set('last_name', $parent_invoice->get_last_name());
293
+        $invoice->set('phone', $parent_invoice->phone);
294
+        $invoice->set('address', $parent_invoice->address);
295
+        $invoice->set('city', $parent_invoice->city);
296
+        $invoice->set('country', $parent_invoice->country);
297
+        $invoice->set('state', $parent_invoice->state);
298
+        $invoice->set('zip', $parent_invoice->zip);
299
+        $invoice->set('company', $parent_invoice->company);
300
+        $invoice->set('vat_number', $parent_invoice->vat_number);
301
+        $invoice->set('vat_rate', $parent_invoice->vat_rate);
302
+        $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed);
303
+
304
+        if (empty($args['gateway'])) {
305
+            $invoice->set('gateway', $parent_invoice->get_gateway());
306 306
         } else {
307
-            $invoice->set( 'gateway', $args['gateway'] );
307
+            $invoice->set('gateway', $args['gateway']);
308 308
         }
309 309
         
310 310
         $recurring_details = $parent_invoice->get_recurring_details();
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
         // increase the earnings for each item in the subscription
313 313
         $items = $recurring_details['cart_details'];
314 314
         
315
-        if ( $items ) {        
315
+        if ($items) {        
316 316
             $add_items      = array();
317 317
             $cart_details   = array();
318 318
             
319
-            foreach ( $items as $item ) {
319
+            foreach ($items as $item) {
320 320
                 $add_item             = array();
321 321
                 $add_item['id']       = $item['id'];
322 322
                 $add_item['quantity'] = $item['quantity'];
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
                 break;
327 327
             }
328 328
             
329
-            $invoice->set( 'items', $add_items );
329
+            $invoice->set('items', $add_items);
330 330
             $invoice->cart_details = $cart_details;
331 331
         }
332 332
         
@@ -336,29 +336,29 @@  discard block
 block discarded – undo
336 336
         $tax                = $recurring_details['tax'];
337 337
         $discount           = $recurring_details['discount'];
338 338
         
339
-        if ( $discount > 0 ) {
340
-            $invoice->set( 'discount_code', $parent_invoice->discount_code );
339
+        if ($discount > 0) {
340
+            $invoice->set('discount_code', $parent_invoice->discount_code);
341 341
         }
342 342
         
343
-        $invoice->subtotal = wpinv_round_amount( $subtotal );
344
-        $invoice->tax      = wpinv_round_amount( $tax );
345
-        $invoice->discount = wpinv_round_amount( $discount );
346
-        $invoice->total    = wpinv_round_amount( $total );
343
+        $invoice->subtotal = wpinv_round_amount($subtotal);
344
+        $invoice->tax      = wpinv_round_amount($tax);
345
+        $invoice->discount = wpinv_round_amount($discount);
346
+        $invoice->total    = wpinv_round_amount($total);
347 347
 
348
-        $invoice  = apply_filters( 'wpinv_subscription_add_payment_save', $invoice, $this, $args );
348
+        $invoice = apply_filters('wpinv_subscription_add_payment_save', $invoice, $this, $args);
349 349
 
350 350
         $invoice->save();
351
-        $invoice->update_meta( '_wpinv_subscription_id', $this->id );
351
+        $invoice->update_meta('_wpinv_subscription_id', $this->id);
352 352
         
353
-        if ( !empty( $invoice->ID ) ) {
354
-            wpinv_update_payment_status( $invoice->ID, 'publish' );
353
+        if (!empty($invoice->ID)) {
354
+            wpinv_update_payment_status($invoice->ID, 'publish');
355 355
             sleep(1);
356
-            wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' );
356
+            wpinv_update_payment_status($invoice->ID, 'wpi-renewal');
357 357
             
358
-            $invoice = wpinv_get_invoice( $invoice->ID );
358
+            $invoice = wpinv_get_invoice($invoice->ID);
359 359
 
360
-            do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
361
-            do_action( 'wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id'] );
360
+            do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
361
+            do_action('wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id']);
362 362
             
363 363
             return $invoice->ID;
364 364
         }
@@ -374,12 +374,12 @@  discard block
 block discarded – undo
374 374
 	 */
375 375
 	public function get_transaction_id() {
376 376
 
377
-		if( empty( $this->transaction_id ) ) {
377
+		if (empty($this->transaction_id)) {
378 378
 
379
-			$txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id );
379
+			$txn_id = wpinv_get_payment_transaction_id($this->parent_payment_id);
380 380
 
381
-			if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) {
382
-				$this->set_transaction_id( $txn_id );
381
+			if (!empty($txn_id) && (int) $this->parent_payment_id !== (int) $txn_id) {
382
+				$this->set_transaction_id($txn_id);
383 383
 			}
384 384
 
385 385
 		}
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @since  1.0.0.4
395 395
 	 * @return bool
396 396
 	 */
397
-	public function set_transaction_id( $txn_id = '' ) {
398
-		$this->update( array( 'transaction_id' => $txn_id ) );
397
+	public function set_transaction_id($txn_id = '') {
398
+		$this->update(array('transaction_id' => $txn_id));
399 399
 		$this->transaction_id = $txn_id;
400 400
 	}
401 401
 
@@ -411,35 +411,35 @@  discard block
 block discarded – undo
411 411
 
412 412
 
413 413
 		// Determine what date to use as the start for the new expiration calculation
414
-		if( $expires > current_time( 'timestamp' ) && $this->is_active() ) {
414
+		if ($expires > current_time('timestamp') && $this->is_active()) {
415 415
 
416
-			$base_date  = $expires;
416
+			$base_date = $expires;
417 417
 
418 418
 		} else {
419 419
 
420
-			$base_date  = current_time( 'timestamp' );
420
+			$base_date = current_time('timestamp');
421 421
 
422 422
 		}
423 423
 
424
-		$last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) );
424
+		$last_day = wpinv_cal_days_in_month(CAL_GREGORIAN, date('n', $base_date), date('Y', $base_date));
425 425
 
426 426
 
427 427
 		$frequency = isset($this->frequency) ? $this->frequency : 1;
428
-		$expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period  . ' 23:59:59', $base_date ) );
428
+		$expiration = date('Y-m-d H:i:s', strtotime('+' . $frequency . ' ' . $this->period . ' 23:59:59', $base_date));
429 429
 
430
-		if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) {
431
-			$expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) );
430
+		if (date('j', $base_date) == $last_day && 'day' != $this->period) {
431
+			$expiration = date('Y-m-d H:i:s', strtotime($expiration . ' +2 days'));
432 432
 		}
433 433
 
434
-		$expiration  = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this );
434
+		$expiration  = apply_filters('wpinv_subscription_renewal_expiration', $expiration, $this->id, $this);
435 435
 
436
-		do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this );
436
+		do_action('wpinv_subscription_pre_renew', $this->id, $expiration, $this);
437 437
 
438 438
 		$this->status = 'active';
439 439
 		$times_billed = $this->get_times_billed();
440 440
 
441 441
 		// Complete subscription if applicable
442
-		if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
442
+		if ($this->bill_times > 0 && $times_billed >= $this->bill_times) {
443 443
 			$this->complete();
444 444
 			$this->status = 'completed';
445 445
 		}
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
 			'status'     => $this->status,
450 450
 		);
451 451
 
452
-        $this->subs_db->update( $this->id, $args );
452
+        $this->subs_db->update($this->id, $args);
453 453
 
454
-		do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this );
455
-		do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
454
+		do_action('wpinv_subscription_post_renew', $this->id, $expiration, $this);
455
+		do_action('wpinv_recurring_set_subscription_status', $this->id, $this->status, $this);
456 456
 
457 457
 	}
458 458
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	public function complete() {
468 468
 
469 469
 		// Only mark a subscription as complete if it's not already cancelled.
470
-		if ( 'cancelled' === $this->status ) {
470
+		if ('cancelled' === $this->status) {
471 471
 			return;
472 472
 		}
473 473
 
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 			'status' => 'completed'
476 476
 		);
477 477
 
478
-		if( $this->subs_db->update( $this->id, $args ) ) {
478
+		if ($this->subs_db->update($this->id, $args)) {
479 479
 
480 480
 			$this->status = 'completed';
481 481
 
482
-			do_action( 'wpinv_subscription_completed', $this->id, $this );
482
+			do_action('wpinv_subscription_completed', $this->id, $this);
483 483
 
484 484
 		}
485 485
 
@@ -494,15 +494,15 @@  discard block
 block discarded – undo
494 494
 	 * @param  $check_expiration bool True if expiration date should be checked with merchant processor before expiring
495 495
 	 * @return void
496 496
 	 */
497
-	public function expire( $check_expiration = false ) {
497
+	public function expire($check_expiration = false) {
498 498
 
499 499
 		$expiration = $this->expiration;
500 500
 
501
-		if( $check_expiration ) {
501
+		if ($check_expiration) {
502 502
 
503 503
 			// check_expiration() updates $this->expiration so compare to $expiration above
504 504
 
505
-			if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
505
+			if ($expiration < $this->get_expiration() && current_time('timestamp') < $this->get_expiration_time()) {
506 506
 
507 507
 				return false; // Do not mark as expired since real expiration date is in the future
508 508
 			}
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 			'status' => 'expired'
514 514
 		);
515 515
 
516
-		if( $this->subs_db->update( $this->id, $args ) ) {
516
+		if ($this->subs_db->update($this->id, $args)) {
517 517
 
518 518
 			$this->status = 'expired';
519 519
 
520
-			do_action( 'wpinv_subscription_expired', $this->id, $this );
520
+			do_action('wpinv_subscription_expired', $this->id, $this);
521 521
 
522 522
 		}
523 523
 
@@ -535,11 +535,11 @@  discard block
 block discarded – undo
535 535
 			'status' => 'failing'
536 536
 		);
537 537
 
538
-		if( $this->subs_db->update( $this->id, $args ) ) {
538
+		if ($this->subs_db->update($this->id, $args)) {
539 539
 
540 540
 			$this->status = 'failing';
541 541
 
542
-			do_action( 'wpinv_subscription_failing', $this->id, $this );
542
+			do_action('wpinv_subscription_failing', $this->id, $this);
543 543
 
544 544
 
545 545
 		}
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
      * @return void
554 554
      */
555 555
     public function cancel() {
556
-        if ( 'cancelled' === $this->status ) {
556
+        if ('cancelled' === $this->status) {
557 557
             return; // Already cancelled
558 558
         }
559 559
 
@@ -561,20 +561,20 @@  discard block
 block discarded – undo
561 561
             'status' => 'cancelled'
562 562
         );
563 563
 
564
-        if ( $this->subs_db->update( $this->id, $args ) ) {
565
-            if ( is_user_logged_in() ) {
566
-                $userdata = get_userdata( get_current_user_id() );
564
+        if ($this->subs_db->update($this->id, $args)) {
565
+            if (is_user_logged_in()) {
566
+                $userdata = get_userdata(get_current_user_id());
567 567
                 $user     = $userdata->display_name;
568 568
             } else {
569
-                $user = __( 'gateway', 'invoicing' );
569
+                $user = __('gateway', 'invoicing');
570 570
             }
571 571
 
572
-            $note = sprintf( __( 'Subscription has been cancelled by %s', 'invoicing' ), $user );
573
-            wpinv_insert_payment_note( $this->parent_payment_id, $note, '', '', true );
572
+            $note = sprintf(__('Subscription has been cancelled by %s', 'invoicing'), $user);
573
+            wpinv_insert_payment_note($this->parent_payment_id, $note, '', '', true);
574 574
 
575 575
             $this->status = 'cancelled';
576 576
 
577
-            do_action( 'wpinv_subscription_cancelled', $this->id, $this );
577
+            do_action('wpinv_subscription_cancelled', $this->id, $this);
578 578
         }
579 579
     }
580 580
 
@@ -589,10 +589,10 @@  discard block
 block discarded – undo
589 589
 	 */
590 590
 	public function can_cancel() {
591 591
         $ret = false;
592
-	    if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) {
592
+	    if ($this->gateway === 'manual' || in_array($this->status, $this->get_cancellable_statuses())) {
593 593
             $ret = true;
594 594
         }
595
-		return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this );
595
+		return apply_filters('wpinv_subscription_can_cancel', $ret, $this);
596 596
 	}
597 597
 
598 598
     /**
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
      * @return      array
604 604
      */
605 605
     public function get_cancellable_statuses() {
606
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
606
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
607 607
     }
608 608
 
609 609
 	/**
@@ -614,9 +614,9 @@  discard block
 block discarded – undo
614 614
 	 */
615 615
 	public function get_cancel_url() {
616 616
 
617
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
617
+		$url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-cancel');
618 618
 
619
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
619
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
620 620
 	}
621 621
 
622 622
 	/**
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 */
631 631
 	public function can_renew() {
632 632
 
633
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
633
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
634 634
 	}
635 635
 
636 636
 	/**
@@ -641,9 +641,9 @@  discard block
 block discarded – undo
641 641
 	 */
642 642
 	public function get_renew_url() {
643 643
 
644
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
644
+		$url = wp_nonce_url(add_query_arg(array('wpinv_action' => 'renew_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-renew');
645 645
 
646
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
646
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
647 647
 	}
648 648
 
649 649
 	/**
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 * @return bool
654 654
 	 */
655 655
 	public function can_update() {
656
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
656
+		return apply_filters('wpinv_subscription_can_update', false, $this);
657 657
 	}
658 658
 
659 659
 	/**
@@ -664,9 +664,9 @@  discard block
 block discarded – undo
664 664
 	 */
665 665
 	public function get_update_url() {
666 666
 
667
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
667
+		$url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->id));
668 668
 
669
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
669
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
670 670
 	}
671 671
 
672 672
 	/**
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
 
680 680
 		$ret = false;
681 681
 
682
-		if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
682
+		if (!$this->is_expired() && ($this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling')) {
683 683
 			$ret = true;
684 684
 		}
685 685
 
686
-		return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
686
+		return apply_filters('wpinv_subscription_is_active', $ret, $this->id, $this);
687 687
 
688 688
 	}
689 689
 
@@ -697,26 +697,26 @@  discard block
 block discarded – undo
697 697
 
698 698
 		$ret = false;
699 699
 
700
-		if ( $this->status == 'expired' ) {
700
+		if ($this->status == 'expired') {
701 701
 
702 702
 			$ret = true;
703 703
 
704
-		} elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
704
+		} elseif ('active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling') {
705 705
 
706 706
 			$ret        = false;
707 707
 			$expiration = $this->get_expiration_time();
708 708
 
709
-			if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
709
+			if ($expiration && strtotime('NOW', current_time('timestamp')) > $expiration) {
710 710
 				$ret = true;
711 711
 
712
-				if ( 'active' === $this->status || $this->status == 'trialling'  ) {
712
+				if ('active' === $this->status || $this->status == 'trialling') {
713 713
 					$this->expire();
714 714
 				}
715 715
 			}
716 716
 
717 717
 		}
718 718
 
719
-		return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
719
+		return apply_filters('wpinv_subscription_is_expired', $ret, $this->id, $this);
720 720
 
721 721
 	}
722 722
 
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	 * @return int
738 738
 	 */
739 739
 	public function get_expiration_time() {
740
-		return strtotime( $this->expiration, current_time( 'timestamp' ) );
740
+		return strtotime($this->expiration, current_time('timestamp'));
741 741
 	}
742 742
 
743 743
 	/**
@@ -761,37 +761,37 @@  discard block
 block discarded – undo
761 761
 	 */
762 762
 	public function get_status_label() {
763 763
 
764
-		switch( $this->get_status() ) {
764
+		switch ($this->get_status()) {
765 765
 			case 'active' :
766
-				$status = __( 'Active', 'invoicing' );
766
+				$status = __('Active', 'invoicing');
767 767
 				break;
768 768
 
769 769
 			case 'cancelled' :
770
-				$status = __( 'Cancelled', 'invoicing' );
770
+				$status = __('Cancelled', 'invoicing');
771 771
 				break;
772 772
 
773 773
 			case 'expired' :
774
-				$status = __( 'Expired', 'invoicing' );
774
+				$status = __('Expired', 'invoicing');
775 775
 				break;
776 776
 
777 777
 			case 'pending' :
778
-				$status = __( 'Pending', 'invoicing' );
778
+				$status = __('Pending', 'invoicing');
779 779
 				break;
780 780
 
781 781
 			case 'failing' :
782
-				$status = __( 'Failing', 'invoicing' );
782
+				$status = __('Failing', 'invoicing');
783 783
 				break;
784 784
 
785 785
 			case 'trialling' :
786
-				$status = __( 'Trialling', 'invoicing' );
786
+				$status = __('Trialling', 'invoicing');
787 787
 				break;
788 788
 
789 789
 			case 'completed' :
790
-				$status = __( 'Completed', 'invoicing' );
790
+				$status = __('Completed', 'invoicing');
791 791
 				break;
792 792
 
793 793
 			default:
794
-				$status = ucfirst( $this->get_status() );
794
+				$status = ucfirst($this->get_status());
795 795
 				break;
796 796
 		}
797 797
 
@@ -806,51 +806,51 @@  discard block
 block discarded – undo
806 806
      */
807 807
     public function get_status_label_html() {
808 808
 
809
-        switch( $get_status = $this->get_status() ) {
809
+        switch ($get_status = $this->get_status()) {
810 810
             case 'active' :
811
-                $status = __( 'Active', 'invoicing' );
811
+                $status = __('Active', 'invoicing');
812 812
                 $class = 'label-info';
813 813
                 break;
814 814
 
815 815
             case 'cancelled' :
816
-                $status = __( 'Cancelled', 'invoicing' );
816
+                $status = __('Cancelled', 'invoicing');
817 817
                 $class = 'label-danger';
818 818
                 break;
819 819
 
820 820
             case 'expired' :
821
-                $status = __( 'Expired', 'invoicing' );
821
+                $status = __('Expired', 'invoicing');
822 822
                 $class = 'label-default';
823 823
                 break;
824 824
 
825 825
             case 'pending' :
826
-                $status = __( 'Pending', 'invoicing' );
826
+                $status = __('Pending', 'invoicing');
827 827
                 $class = 'label-primary';
828 828
                 break;
829 829
 
830 830
             case 'failing' :
831
-                $status = __( 'Failing', 'invoicing' );
831
+                $status = __('Failing', 'invoicing');
832 832
                 $class = 'label-danger';
833 833
                 break;
834 834
 
835 835
             case 'trialling' :
836
-                $status = __( 'Trialling', 'invoicing' );
836
+                $status = __('Trialling', 'invoicing');
837 837
                 $class = 'label-info';
838 838
                 break;
839 839
 
840 840
             case 'completed' :
841
-                $status = __( 'Completed', 'invoicing' );
841
+                $status = __('Completed', 'invoicing');
842 842
                 $class = 'label-success';
843 843
                 break;
844 844
 
845 845
             default:
846
-                $status = ucfirst( $this->get_status() );
846
+                $status = ucfirst($this->get_status());
847 847
                 $class = 'label-default';
848 848
                 break;
849 849
         }
850 850
 
851 851
         $label = '<span class="sub-status label label-sub-' . $get_status . ' ' . $class . '">' . $status . '</span>';
852 852
 
853
-        return apply_filters( 'wpinv_subscription_status_label_html', $label, $get_status, $status );
853
+        return apply_filters('wpinv_subscription_status_label_html', $label, $get_status, $status);
854 854
     }
855 855
 
856 856
     /**
@@ -860,18 +860,18 @@  discard block
 block discarded – undo
860 860
      * @param  string $txn_id The transaction ID from the merchant processor
861 861
      * @return bool
862 862
      */
863
-    public function payment_exists( $txn_id = '' ) {
863
+    public function payment_exists($txn_id = '') {
864 864
         global $wpdb;
865 865
 
866
-        if ( empty( $txn_id ) ) {
866
+        if (empty($txn_id)) {
867 867
             return false;
868 868
         }
869 869
 
870
-        $txn_id = esc_sql( $txn_id );
870
+        $txn_id = esc_sql($txn_id);
871 871
 
872
-        $purchase = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1" );
872
+        $purchase = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1");
873 873
 
874
-        if ( $purchase != null ) {
874
+        if ($purchase != null) {
875 875
             return true;
876 876
         }
877 877
 
Please login to merge, or discard this patch.
includes/class-wpinv-bp-core.php 1 patch
Spacing   +125 added lines, -125 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
 
@@ -9,42 +9,42 @@  discard block
 block discarded – undo
9 9
     
10 10
     public function __construct() {
11 11
 
12
-        if ( !defined( 'WPINV_BP_SLUG' ) ) {
13
-            define( 'WPINV_BP_SLUG', 'invoices' );
12
+        if (!defined('WPINV_BP_SLUG')) {
13
+            define('WPINV_BP_SLUG', 'invoices');
14 14
         }
15 15
 
16
-        add_action( 'wp_ajax_invoicing_filter', array( $this, 'invoices_content' ) );
17
-        add_action( 'wp_ajax_nopriv_invoicing_filter', array( $this, 'invoices_content' ) );
18
-        add_filter( 'wpinv_settings_sections_general', array( $this, 'bp_section' ), 10, 1 );
19
-        add_filter( 'wpinv_settings_general', array( $this, 'bp_settings' ), 10, 1 );
20
-        add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 10, 2 );
16
+        add_action('wp_ajax_invoicing_filter', array($this, 'invoices_content'));
17
+        add_action('wp_ajax_nopriv_invoicing_filter', array($this, 'invoices_content'));
18
+        add_filter('wpinv_settings_sections_general', array($this, 'bp_section'), 10, 1);
19
+        add_filter('wpinv_settings_general', array($this, 'bp_settings'), 10, 1);
20
+        add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects'), 10, 2);
21 21
         add_action('bp_setup_nav', array($this, 'setup_nav'), 15);
22 22
         
23
-        $position       = wpinv_get_option( 'wpinv_menu_position' );
23
+        $position       = wpinv_get_option('wpinv_menu_position');
24 24
         $position       = $position !== '' && $position !== false ? $position : 91;
25
-        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
26
-        $this->id     = WPINV_BP_SLUG;
25
+        $this->position = apply_filters('wpinv_bp_nav_position', $position);
26
+        $this->id = WPINV_BP_SLUG;
27 27
     }
28 28
 
29 29
     public function setup_nav() {
30 30
 
31
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) || !is_user_logged_in()) {
31
+        if (wpinv_get_option('wpinv_bp_hide_menu') || !is_user_logged_in()) {
32 32
             return;
33 33
         }
34 34
 
35
-        if(bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')){
35
+        if (bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')) {
36 36
             return;
37 37
         }
38 38
 
39 39
         $count = $this->get_invoice_count();
40
-        $class = ( 0 === $count ) ? 'no-count' : 'count';
40
+        $class = (0 === $count) ? 'no-count' : 'count';
41 41
 
42 42
         $main_nav_name = sprintf(
43
-            __( 'My Invoices %s', 'invoicing' ),
43
+            __('My Invoices %s', 'invoicing'),
44 44
             sprintf(
45 45
                 '<span class="%s">%s</span>',
46
-                esc_attr( $class ),
47
-                bp_core_number_format( $count )
46
+                esc_attr($class),
47
+                bp_core_number_format($count)
48 48
             )
49 49
         );
50 50
 
@@ -52,31 +52,31 @@  discard block
 block discarded – undo
52 52
             'name'                => $main_nav_name,
53 53
             'slug'                => WPINV_BP_SLUG,
54 54
             'position'            => $this->position,
55
-            'screen_function'     => array( $this, 'invoices_screen' ),
55
+            'screen_function'     => array($this, 'invoices_screen'),
56 56
             'default_subnav_slug' => 'invoices',
57 57
             'item_css_id'         => $this->id
58 58
         );
59 59
 
60
-        bp_core_new_nav_item( $main_nav );
60
+        bp_core_new_nav_item($main_nav);
61 61
     }
62 62
     
63 63
     public function invoices_screen() {
64
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
64
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
65 65
             return;
66 66
         }
67 67
         
68
-        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
68
+        add_action('bp_template_content', array($this, 'invoices_content'));
69 69
 
70
-        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
70
+        $template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
71 71
         
72
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
72
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
73 73
     }
74 74
     
75 75
     public function invoices_content() {
76
-        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
76
+        if ($this->has_invoices(bp_ajax_querystring('invoices'))) {
77 77
             global $invoices_template;
78 78
             
79
-            do_action( 'wpinv_bp_invoices_before_content' );
79
+            do_action('wpinv_bp_invoices_before_content');
80 80
             ?>
81 81
             <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative">
82 82
                 <div id="pag-top" class="pagination">
@@ -90,61 +90,61 @@  discard block
 block discarded – undo
90 90
                 <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0">
91 91
                     <thead>
92 92
                         <tr>
93
-                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
94
-                                <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th>
93
+                            <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
94
+                                <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th>
95 95
                             <?php endforeach; ?>
96 96
                         </tr>
97 97
                     </thead>
98 98
                     <tbody>
99
-                        <?php foreach ( $invoices_template->invoices as $invoice ) {
99
+                        <?php foreach ($invoices_template->invoices as $invoice) {
100 100
                             ?>
101 101
                             <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
102
-                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
103
-                                    <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
104
-                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
105
-                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
106
-
107
-                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
108
-                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
109
-                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
102
+                                <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
103
+                                    <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>">
104
+                                        <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
105
+                                            <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
106
+
107
+                                        <?php elseif ('invoice-number' === $column_id) : ?>
108
+                                            <a href="<?php echo esc_url($invoice->get_view_url()); ?>">
109
+                                                <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
110 110
                                             </a>
111 111
 
112
-                                        <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
113
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
112
+                                        <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?>
113
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
114 114
 
115
-                                        <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
116
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
115
+                                        <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?>
116
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
117 117
 
118
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
119
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
118
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
119
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
120 120
 
121
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
122
-                                            <?php echo $invoice->get_total( true ); ?>
121
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
122
+                                            <?php echo $invoice->get_total(true); ?>
123 123
 
124
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
124
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
125 125
                                             <?php
126 126
                                                 $actions = array(
127 127
                                                     'pay'    => array(
128 128
                                                         'url'  => $invoice->get_checkout_payment_url(),
129
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
129
+                                                        'name' => __('Pay Now', 'invoicing'),
130 130
                                                         'class' => 'btn-success'
131 131
                                                     ),
132 132
                                                     'print'   => array(
133 133
                                                         'url'  => $invoice->get_view_url(),
134
-                                                        'name' => __( 'Print', 'invoicing' ),
134
+                                                        'name' => __('Print', 'invoicing'),
135 135
                                                         'class' => 'btn-primary',
136 136
                                                         'attrs' => 'target="_blank"'
137 137
                                                     )
138 138
                                                 );
139 139
 
140
-                                                if ( ! $invoice->needs_payment() ) {
141
-                                                    unset( $actions['pay'] );
140
+                                                if (!$invoice->needs_payment()) {
141
+                                                    unset($actions['pay']);
142 142
                                                 }
143 143
 
144
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
145
-                                                    foreach ( $actions as $key => $action ) {
144
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
145
+                                                    foreach ($actions as $key => $action) {
146 146
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
147
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
147
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
148 148
                                                     }
149 149
                                                 }
150 150
                                             ?>
@@ -172,64 +172,64 @@  discard block
 block discarded – undo
172 172
             </div>
173 173
             <?php
174 174
         
175
-            do_action( 'wpinv_bp_invoices_after_content' );
175
+            do_action('wpinv_bp_invoices_after_content');
176 176
         } else {
177 177
             ?>
178 178
             <div id="message" class="info">
179
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
179
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
180 180
             </div>
181 181
             <?php
182 182
         }
183 183
         
184
-        if ( defined( 'DOING_AJAX' ) ) {
184
+        if (defined('DOING_AJAX')) {
185 185
             exit;
186 186
         }
187 187
     }
188 188
     
189
-    public function has_invoices( $args = '' ) {
189
+    public function has_invoices($args = '') {
190 190
         global $invoices_template;
191 191
 
192
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
192
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
193 193
         // Parse arguments.
194
-        $r = bp_parse_args( $args, array(
194
+        $r = bp_parse_args($args, array(
195 195
             'status'            => 'all',
196 196
             'page_arg'          => 'bpage',
197 197
             'page'              => 1,
198 198
             'per_page'          => $per_page > 0 ? $per_page : 20,
199 199
             'max'               => false,
200 200
             'user_id'           => bp_displayed_user_id(),
201
-        ), 'has_invoices' );
201
+        ), 'has_invoices');
202 202
 
203 203
 
204
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
205
-            $r['per_page'] = (int)$r['max'];
204
+        if (!empty($r['max']) && ((int) $r['per_page'] > (int) $r['max'])) {
205
+            $r['per_page'] = (int) $r['max'];
206 206
         }
207 207
 
208 208
         // Get the invoices.
209
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
209
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
210 210
 
211
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
211
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
212 212
     }
213 213
     
214 214
     public function get_invoice_count() {
215
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'status' => 'all','user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
216
-        $invoices   = wpinv_get_invoices( $query );
215
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('status' => 'all', 'user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
216
+        $invoices   = wpinv_get_invoices($query);
217 217
         
218
-        return !empty( $invoices ) ? count( $invoices ) : 0;
218
+        return !empty($invoices) ? count($invoices) : 0;
219 219
     }
220 220
     
221 221
     public function pagination_count() {
222 222
         global $invoices_template;
223 223
 
224
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
225
-        $from_num  = bp_core_number_format( $start_num );
226
-        $to_num    = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) );
227
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
224
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
225
+        $from_num  = bp_core_number_format($start_num);
226
+        $to_num    = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1));
227
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
228 228
 
229
-        if ( 1 == $invoices_template->total_invoice_count ) {
230
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
229
+        if (1 == $invoices_template->total_invoice_count) {
230
+            $message = __('Viewing 1 invoice', 'invoicing');
231 231
         } else {
232
-            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total );
232
+            $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total);
233 233
         }
234 234
 
235 235
         return $message;
@@ -238,32 +238,32 @@  discard block
 block discarded – undo
238 238
     function pagination_links() {
239 239
         global $invoices_template;
240 240
 
241
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
241
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
242 242
     }
243 243
     
244
-    public function bp_section( $settings = array() ) {
245
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
244
+    public function bp_section($settings = array()) {
245
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
246 246
         return $settings;
247 247
     }
248 248
     
249
-    public function bp_settings( $settings = array() ) {
249
+    public function bp_settings($settings = array()) {
250 250
         $settings['wpinv_bp'] = array(
251 251
             'wpinv_bp_labels' => array(
252 252
                 'id'   => 'wpinv_bp_settings',
253
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
253
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
254 254
                 'desc' => '',
255 255
                 'type' => 'header',
256 256
             ),
257 257
             'wpinv_bp_hide_menu' => array(
258 258
                 'id'   => 'wpinv_bp_hide_menu',
259
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
260
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
259
+                'name' => __('Hide Invoices link', 'invoicing'),
260
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
261 261
                 'type' => 'checkbox',
262 262
             ),
263 263
             'wpinv_menu_position' => array(
264 264
                 'id'   => 'wpinv_menu_position',
265
-                'name' => __( 'Menu position', 'invoicing' ),
266
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
265
+                'name' => __('Menu position', 'invoicing'),
266
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
267 267
                 'type' => 'number',
268 268
                 'size' => 'small',
269 269
                 'min'  => '1',
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
             ),
274 274
             'wpinv_bp_per_page' => array(
275 275
                 'id'   => 'wpinv_bp_per_page',
276
-                'name' => __( 'Max invoices per page', 'invoicing' ),
277
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
276
+                'name' => __('Max invoices per page', 'invoicing'),
277
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
278 278
                 'type' => 'number',
279 279
                 'size' => 'small',
280 280
                 'min'  => '1',
@@ -287,20 +287,20 @@  discard block
 block discarded – undo
287 287
         return $settings;
288 288
     }
289 289
 
290
-    public function wp_nav_menu_objects($items, $args){
291
-        if(!is_user_logged_in()){
290
+    public function wp_nav_menu_objects($items, $args) {
291
+        if (!is_user_logged_in()) {
292 292
             return $items;
293 293
         }
294 294
 
295
-        if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){
295
+        if (!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)) {
296 296
             return $items;
297 297
         }
298 298
 
299 299
         $user_id = get_current_user_id();
300
-        $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG;
300
+        $link = bp_core_get_user_domain($user_id) . WPINV_BP_SLUG;
301 301
         $history_link = wpinv_get_history_page_uri();
302
-        foreach ( $items as $item ) {
303
-            $item->url = str_replace( $history_link, $link, $item->url );
302
+        foreach ($items as $item) {
303
+            $item->url = str_replace($history_link, $link, $item->url);
304 304
         }
305 305
 
306 306
         return $items;
@@ -318,78 +318,78 @@  discard block
 block discarded – undo
318 318
     public $pag_links = '';
319 319
     public $total_invoice_count = 0;
320 320
     
321
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
322
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
321
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
322
+        $this->invoices = array('invoices' => array(), 'total' => 0);
323 323
         
324
-        $this->pag_arg  = sanitize_key( $page_arg );
325
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
326
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
324
+        $this->pag_arg  = sanitize_key($page_arg);
325
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
326
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
327 327
 
328
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
329
-        if ( !empty( $status ) && $status != 'all' ) {
328
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
329
+        if (!empty($status) && $status != 'all') {
330 330
            $query_args['status'] = $status;
331 331
         }
332
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
332
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
333 333
         
334
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
335
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
334
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
335
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
336 336
             $this->invoices['total']    = $invoices->found_posts;
337 337
         }
338 338
 
339
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
340
-            $this->total_invoice_count = (int)$this->invoices['total'];
339
+        if (empty($max) || ($max >= (int) $this->invoices['total'])) {
340
+            $this->total_invoice_count = (int) $this->invoices['total'];
341 341
         } else {
342
-            $this->total_invoice_count = (int)$max;
342
+            $this->total_invoice_count = (int) $max;
343 343
         }
344 344
 
345 345
         $this->invoices = $this->invoices['invoices'];
346 346
 
347
-        $invoice_count = count( $this->invoices );
347
+        $invoice_count = count($this->invoices);
348 348
 
349
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
350
-            $this->invoice_count = (int)$invoice_count;
349
+        if (empty($max) || ($max >= (int) $invoice_count)) {
350
+            $this->invoice_count = (int) $invoice_count;
351 351
         } else {
352
-            $this->invoice_count = (int)$max;
352
+            $this->invoice_count = (int) $max;
353 353
         }
354 354
         
355
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
356
-            $this->pag_links = paginate_links( array(
357
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
355
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
356
+            $this->pag_links = paginate_links(array(
357
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
358 358
                 'format'    => '',
359
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
360
-                'current'   => (int)$this->pag_page,
361
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
362
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
359
+                'total'     => ceil((int) $this->total_invoice_count / (int) $this->pag_num),
360
+                'current'   => (int) $this->pag_page,
361
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
362
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
363 363
                 'mid_size'  => 1,
364 364
                 'add_args'  => array(),
365
-            ) );
365
+            ));
366 366
         }
367 367
     }
368 368
 
369 369
     public function has_invoices() {
370
-        return (bool) ! empty( $this->invoice_count );
370
+        return (bool) !empty($this->invoice_count);
371 371
     }
372 372
 
373 373
     public function next_invoice() {
374 374
         $this->current_invoice++;
375
-        $this->invoice = $this->invoices[ $this->current_invoice ];
375
+        $this->invoice = $this->invoices[$this->current_invoice];
376 376
 
377 377
         return $this->invoice;
378 378
     }
379 379
 
380 380
     public function rewind_invoices() {
381 381
         $this->current_invoice = -1;
382
-        if ( $this->invoice_count > 0 ) {
382
+        if ($this->invoice_count > 0) {
383 383
             $this->invoice = $this->invoices[0];
384 384
         }
385 385
     }
386 386
 
387 387
     public function invoices() {
388
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
388
+        if (($this->current_invoice + 1) < $this->invoice_count) {
389 389
             return true;
390
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
390
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
391 391
 
392
-            do_action( 'wpinv_bp_invoice_loop_end' );
392
+            do_action('wpinv_bp_invoice_loop_end');
393 393
             
394 394
             $this->rewind_invoices();
395 395
         }
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
         $this->in_the_loop = true;
404 404
         $this->invoice     = $this->next_invoice();
405 405
 
406
-        if ( 0 === $this->current_invoice ) {
407
-            do_action( 'wpinv_bp_invoice_loop_start' );
406
+        if (0 === $this->current_invoice) {
407
+            do_action('wpinv_bp_invoice_loop_start');
408 408
         }
409 409
     }
410 410
 }
411 411
 
412 412
 function wpinv_bp_setup_component() {
413 413
 
414
-    if(!class_exists( 'BuddyPress' )){
414
+    if (!class_exists('BuddyPress')) {
415 415
         return;
416 416
     }
417 417
 
418 418
     new WPInv_BP_Component();
419 419
 
420 420
 }
421
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
422 421
\ No newline at end of file
422
+add_action('bp_loaded', 'wpinv_bp_setup_component');
423 423
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-notes.php 1 patch
Spacing   +42 added lines, -42 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
 
@@ -14,74 +14,74 @@  discard block
 block discarded – undo
14 14
     }
15 15
     
16 16
     public function init() {
17
-        do_action( 'wpinv_class_notes_init', $this );
17
+        do_action('wpinv_class_notes_init', $this);
18 18
     }
19 19
     
20 20
     public function includes() {
21
-        do_action( 'wpinv_class_notes_includes', $this );
21
+        do_action('wpinv_class_notes_includes', $this);
22 22
     }
23 23
     
24 24
     public function actions() {
25 25
         // Secure inovice notes
26
-        add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
27
-        add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
26
+        add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
27
+        add_action('comment_feed_where', array($this, 'wpinv_comment_feed_where'), 10, 1);
28 28
         
29 29
         // Count comments
30
-        add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 11, 2 );
30
+        add_filter('wp_count_comments', array($this, 'wp_count_comments'), 11, 2);
31 31
         
32 32
         // Delete comments count cache whenever there is a new comment or a comment status changes
33
-        add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
34
-        add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
33
+        add_action('wp_insert_comment', array($this, 'delete_comments_count_cache'));
34
+        add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache'));
35 35
         
36
-        do_action( 'wpinv_class_notes_actions', $this );
36
+        do_action('wpinv_class_notes_actions', $this);
37 37
     }
38 38
         
39
-    public function set_invoice_note_type( $query ) {
40
-        $post_ID        = !empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
39
+    public function set_invoice_note_type($query) {
40
+        $post_ID = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
41 41
         
42
-        if ( $post_ID && in_array(get_post_type( $post_ID ), array($this->invoice_post_type, 'wpi_quote' )) ) {
42
+        if ($post_ID && in_array(get_post_type($post_ID), array($this->invoice_post_type, 'wpi_quote'))) {
43 43
             $query->query_vars['type__in']      = $this->comment_type;
44 44
             $query->query_vars['type__not_in']  = '';
45 45
         } else {        
46
-            if ( isset( $query->query_vars['type__in'] ) && $type_in = $query->query_vars['type__in'] ) {
47
-                if ( is_array( $type_in ) && in_array( $this->comment_type, $type_in ) ) {
48
-                    $key = array_search( $this->comment_type, $type_in );
49
-                    unset( $query->query_vars['type__in'][$key] );
50
-                } else if ( !is_array( $type_in ) && $type_in == $this->comment_type ) {
46
+            if (isset($query->query_vars['type__in']) && $type_in = $query->query_vars['type__in']) {
47
+                if (is_array($type_in) && in_array($this->comment_type, $type_in)) {
48
+                    $key = array_search($this->comment_type, $type_in);
49
+                    unset($query->query_vars['type__in'][$key]);
50
+                } else if (!is_array($type_in) && $type_in == $this->comment_type) {
51 51
                     $query->query_vars['type__in'] = '';
52 52
                 }
53 53
             }
54 54
             
55
-            if ( isset( $query->query_vars['type__not_in'] ) && $type_not_in = $query->query_vars['type__not_in'] ) {
56
-                if ( is_array( $type_not_in ) && !in_array( $this->comment_type, $type_not_in ) ) {
55
+            if (isset($query->query_vars['type__not_in']) && $type_not_in = $query->query_vars['type__not_in']) {
56
+                if (is_array($type_not_in) && !in_array($this->comment_type, $type_not_in)) {
57 57
                     $query->query_vars['type__not_in'][] = $this->comment_type;
58
-                } else if ( !is_array( $type_not_in ) && $type_not_in != $this->comment_type ) {
59
-                    $query->query_vars['type__not_in'] = (array)$query->query_vars['type__not_in'];
58
+                } else if (!is_array($type_not_in) && $type_not_in != $this->comment_type) {
59
+                    $query->query_vars['type__not_in'] = (array) $query->query_vars['type__not_in'];
60 60
                     $query->query_vars['type__not_in'][] = $this->comment_type;
61 61
                 }
62 62
             } else {
63
-                $query->query_vars['type__not_in']  = $this->comment_type;
63
+                $query->query_vars['type__not_in'] = $this->comment_type;
64 64
             }
65 65
         }
66 66
         
67 67
         return $query;
68 68
     }
69 69
     
70
-    public function get_invoice_notes( $invoice_id = 0, $type = '' ) {
70
+    public function get_invoice_notes($invoice_id = 0, $type = '') {
71 71
         $args = array( 
72 72
             'post_id'   => $invoice_id,
73 73
             'orderby'   => 'comment_ID',
74 74
             'order'     => 'ASC',
75 75
         );
76 76
         
77
-        if ( $type == 'customer' ) {
77
+        if ($type == 'customer') {
78 78
             $args['meta_key']   = '_wpi_customer_note';
79 79
             $args['meta_value'] = 1;
80 80
         }
81 81
         
82
-        $args   = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
82
+        $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
83 83
         
84
-        return get_comments( $args );
84
+        return get_comments($args);
85 85
     }
86 86
     
87 87
     /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      * @return void
93 93
      */
94 94
     public function delete_comments_count_cache() {
95
-        delete_transient( 'wpinv_count_comments' );
95
+        delete_transient('wpinv_count_comments');
96 96
     }
97 97
     
98 98
     /**
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
      * @param  int    $post_id Post ID.
104 104
      * @return object
105 105
      */
106
-    public function wp_count_comments( $stats, $post_id ) {
106
+    public function wp_count_comments($stats, $post_id) {
107 107
         global $wpdb;
108 108
 
109
-        if ( 0 === $post_id ) {
110
-            $stats = get_transient( 'wpinv_count_comments' );
109
+        if (0 === $post_id) {
110
+            $stats = get_transient('wpinv_count_comments');
111 111
 
112
-            if ( ! $stats ) {
112
+            if (!$stats) {
113 113
                 $stats = array();
114 114
 
115
-                $count = $wpdb->get_results( "SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A );
115
+                $count = $wpdb->get_results("SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A);
116 116
 
117 117
                 $total = 0;
118 118
                 $approved = array(
@@ -123,33 +123,33 @@  discard block
 block discarded – undo
123 123
                     'post-trashed' => 'post-trashed',
124 124
                 );
125 125
 
126
-                foreach ( (array) $count as $row ) {
126
+                foreach ((array) $count as $row) {
127 127
                     // Do not count post-trashed toward totals.
128
-                    if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) {
128
+                    if ('post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved']) {
129 129
                         $total += $row['num_comments'];
130 130
                     }
131
-                    if ( isset( $approved[ $row['comment_approved'] ] ) ) {
132
-                        $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
131
+                    if (isset($approved[$row['comment_approved']])) {
132
+                        $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
133 133
                     }
134 134
                 }
135 135
 
136 136
                 $stats['total_comments'] = $total;
137 137
                 $stats['all'] = $total;
138
-                foreach ( $approved as $key ) {
139
-                    if ( empty( $stats[ $key ] ) ) {
140
-                        $stats[ $key ] = 0;
138
+                foreach ($approved as $key) {
139
+                    if (empty($stats[$key])) {
140
+                        $stats[$key] = 0;
141 141
                     }
142 142
                 }
143 143
 
144 144
                 $stats = (object) $stats;
145
-                set_transient( 'wpinv_count_comments', $stats );
145
+                set_transient('wpinv_count_comments', $stats);
146 146
             }
147 147
         }
148 148
 
149 149
         return $stats;
150 150
     }
151 151
 
152
-    function wpinv_comment_feed_where($where){
153
-        return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
152
+    function wpinv_comment_feed_where($where) {
153
+        return $where . ($where ? ' AND ' : '') . " comment_type != 'wpinv_note' ";
154 154
     }
155 155
 }
Please login to merge, or discard this patch.