Passed
Pull Request — master (#47)
by Kiran
04:02
created
includes/wpinv-general-functions.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -7,195 +7,195 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_is_checkout() {
15 15
     global $wp_query;
16 16
 
17
-    $is_object_set    = isset( $wp_query->queried_object );
18
-    $is_object_id_set = isset( $wp_query->queried_object_id );
19
-    $is_checkout      = is_page( wpinv_get_option( 'checkout_page' ) );
17
+    $is_object_set    = isset($wp_query->queried_object);
18
+    $is_object_id_set = isset($wp_query->queried_object_id);
19
+    $is_checkout      = is_page(wpinv_get_option('checkout_page'));
20 20
 
21
-    if ( !$is_object_set ) {
22
-        unset( $wp_query->queried_object );
21
+    if (!$is_object_set) {
22
+        unset($wp_query->queried_object);
23 23
     }
24 24
 
25
-    if ( !$is_object_id_set ) {
26
-        unset( $wp_query->queried_object_id );
25
+    if (!$is_object_id_set) {
26
+        unset($wp_query->queried_object_id);
27 27
     }
28 28
 
29
-    return apply_filters( 'wpinv_is_checkout', $is_checkout );
29
+    return apply_filters('wpinv_is_checkout', $is_checkout);
30 30
 }
31 31
 
32 32
 function wpinv_can_checkout() {
33 33
 	$can_checkout = true; // Always true for now
34 34
 
35
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
35
+	return (bool)apply_filters('wpinv_can_checkout', $can_checkout);
36 36
 }
37 37
 
38 38
 function wpinv_get_success_page_uri() {
39
-	$page_id = wpinv_get_option( 'success_page', 0 );
40
-	$page_id = absint( $page_id );
39
+	$page_id = wpinv_get_option('success_page', 0);
40
+	$page_id = absint($page_id);
41 41
 
42
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
42
+	return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id));
43 43
 }
44 44
 
45 45
 function wpinv_get_history_page_uri() {
46
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
-	$page_id = absint( $page_id );
46
+	$page_id = wpinv_get_option('invoice_history_page', 0);
47
+	$page_id = absint($page_id);
48 48
 
49
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
49
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id));
50 50
 }
51 51
 
52 52
 function wpinv_is_success_page() {
53
-	$is_success_page = wpinv_get_option( 'success_page', false );
54
-	$is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
53
+	$is_success_page = wpinv_get_option('success_page', false);
54
+	$is_success_page = isset($is_success_page) ? is_page($is_success_page) : false;
55 55
 
56
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
56
+	return apply_filters('wpinv_is_success_page', $is_success_page);
57 57
 }
58 58
 
59 59
 function wpinv_is_invoice_history_page() {
60
-	$ret = wpinv_get_option( 'invoice_history_page', false );
61
-	$ret = $ret ? is_page( $ret ) : false;
62
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
60
+	$ret = wpinv_get_option('invoice_history_page', false);
61
+	$ret = $ret ? is_page($ret) : false;
62
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
63 63
 }
64 64
 
65
-function wpinv_send_to_success_page( $args = null ) {
65
+function wpinv_send_to_success_page($args = null) {
66 66
 	$redirect = wpinv_get_success_page_uri();
67 67
     
68
-    if ( !empty( $args ) ) {
68
+    if (!empty($args)) {
69 69
         // Check for backward compatibility
70
-        if ( is_string( $args ) )
71
-            $args = str_replace( '?', '', $args );
70
+        if (is_string($args))
71
+            $args = str_replace('?', '', $args);
72 72
 
73
-        $args = wp_parse_args( $args );
73
+        $args = wp_parse_args($args);
74 74
 
75
-        $redirect = add_query_arg( $args, $redirect );
75
+        $redirect = add_query_arg($args, $redirect);
76 76
     }
77 77
 
78
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
78
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
79 79
     
80
-    $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args );
81
-    wp_redirect( $redirect );
80
+    $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args);
81
+    wp_redirect($redirect);
82 82
     exit;
83 83
 }
84 84
 
85
-function wpinv_send_to_failed_page( $args = null ) {
85
+function wpinv_send_to_failed_page($args = null) {
86 86
 	$redirect = wpinv_get_failed_transaction_uri();
87 87
     
88
-    if ( !empty( $args ) ) {
88
+    if (!empty($args)) {
89 89
         // Check for backward compatibility
90
-        if ( is_string( $args ) )
91
-            $args = str_replace( '?', '', $args );
90
+        if (is_string($args))
91
+            $args = str_replace('?', '', $args);
92 92
 
93
-        $args = wp_parse_args( $args );
93
+        $args = wp_parse_args($args);
94 94
 
95
-        $redirect = add_query_arg( $args, $redirect );
95
+        $redirect = add_query_arg($args, $redirect);
96 96
     }
97 97
 
98
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
98
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
99 99
     
100
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
101
-    wp_redirect( $redirect );
100
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
101
+    wp_redirect($redirect);
102 102
     exit;
103 103
 }
104 104
 
105
-function wpinv_get_checkout_uri( $args = array() ) {
106
-	$uri = wpinv_get_option( 'checkout_page', false );
107
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
105
+function wpinv_get_checkout_uri($args = array()) {
106
+	$uri = wpinv_get_option('checkout_page', false);
107
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
108 108
 
109
-	if ( !empty( $args ) ) {
109
+	if (!empty($args)) {
110 110
 		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
111
+		if (is_string($args))
112
+			$args = str_replace('?', '', $args);
113 113
 
114
-		$args = wp_parse_args( $args );
114
+		$args = wp_parse_args($args);
115 115
 
116
-		$uri = add_query_arg( $args, $uri );
116
+		$uri = add_query_arg($args, $uri);
117 117
 	}
118 118
 
119
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
119
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
120 120
 
121
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
121
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
122 122
 
123
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
123
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
124
+		$uri = preg_replace('/^http:/', 'https:', $uri);
125 125
 	}
126 126
 
127
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
127
+	return apply_filters('wpinv_get_checkout_uri', $uri);
128 128
 }
129 129
 
130
-function wpinv_send_back_to_checkout( $args = array() ) {
130
+function wpinv_send_back_to_checkout($args = array()) {
131 131
 	$redirect = wpinv_get_checkout_uri();
132 132
 
133
-	if ( ! empty( $args ) ) {
133
+	if (!empty($args)) {
134 134
 		// Check for backward compatibility
135
-		if ( is_string( $args ) )
136
-			$args = str_replace( '?', '', $args );
135
+		if (is_string($args))
136
+			$args = str_replace('?', '', $args);
137 137
 
138
-		$args = wp_parse_args( $args );
138
+		$args = wp_parse_args($args);
139 139
 
140
-		$redirect = add_query_arg( $args, $redirect );
140
+		$redirect = add_query_arg($args, $redirect);
141 141
 	}
142 142
 
143
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
143
+	wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args));
144 144
 	exit;
145 145
 }
146 146
 
147
-function wpinv_get_success_page_url( $query_string = null ) {
148
-	$success_page = wpinv_get_option( 'success_page', 0 );
149
-	$success_page = get_permalink( $success_page );
147
+function wpinv_get_success_page_url($query_string = null) {
148
+	$success_page = wpinv_get_option('success_page', 0);
149
+	$success_page = get_permalink($success_page);
150 150
 
151
-	if ( $query_string )
151
+	if ($query_string)
152 152
 		$success_page .= $query_string;
153 153
 
154
-	return apply_filters( 'wpinv_success_page_url', $success_page );
154
+	return apply_filters('wpinv_success_page_url', $success_page);
155 155
 }
156 156
 
157
-function wpinv_get_failed_transaction_uri( $extras = false ) {
158
-	$uri = wpinv_get_option( 'failure_page', '' );
159
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
157
+function wpinv_get_failed_transaction_uri($extras = false) {
158
+	$uri = wpinv_get_option('failure_page', '');
159
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
160 160
 
161
-	if ( $extras )
161
+	if ($extras)
162 162
 		$uri .= $extras;
163 163
 
164
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
164
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
165 165
 }
166 166
 
167 167
 function wpinv_is_failed_transaction_page() {
168
-	$ret = wpinv_get_option( 'failure_page', false );
169
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
168
+	$ret = wpinv_get_option('failure_page', false);
169
+	$ret = isset($ret) ? is_page($ret) : false;
170 170
 
171
-	return apply_filters( 'wpinv_is_failure_page', $ret );
171
+	return apply_filters('wpinv_is_failure_page', $ret);
172 172
 }
173 173
 
174
-function wpinv_transaction_query( $type = 'start' ) {
174
+function wpinv_transaction_query($type = 'start') {
175 175
     global $wpdb;
176 176
 
177 177
     $wpdb->hide_errors();
178 178
 
179
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
180
-        define( 'WPINV_USE_TRANSACTIONS', true );
179
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
180
+        define('WPINV_USE_TRANSACTIONS', true);
181 181
     }
182 182
 
183
-    if ( WPINV_USE_TRANSACTIONS ) {
184
-        switch ( $type ) {
183
+    if (WPINV_USE_TRANSACTIONS) {
184
+        switch ($type) {
185 185
             case 'commit' :
186
-                $wpdb->query( 'COMMIT' );
186
+                $wpdb->query('COMMIT');
187 187
                 break;
188 188
             case 'rollback' :
189
-                $wpdb->query( 'ROLLBACK' );
189
+                $wpdb->query('ROLLBACK');
190 190
                 break;
191 191
             default :
192
-                $wpdb->query( 'START TRANSACTION' );
192
+                $wpdb->query('START TRANSACTION');
193 193
             break;
194 194
         }
195 195
     }
196 196
 }
197 197
 
198
-function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) {
198
+function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) {
199 199
     $default_args = array(
200 200
         'status'        => '',
201 201
         'user_id'       => null,
@@ -205,72 +205,72 @@  discard block
 block discarded – undo
205 205
         'parent'        => 0
206 206
     );
207 207
 
208
-    $args           = wp_parse_args( $args, $default_args );
208
+    $args           = wp_parse_args($args, $default_args);
209 209
     $invoice_data   = array();
210 210
 
211
-    if ( $args['invoice_id'] > 0 ) {
212
-        $updating           = true;
211
+    if ($args['invoice_id'] > 0) {
212
+        $updating = true;
213 213
         $invoice_data['post_type']  = 'wpi_invoice';
214 214
         $invoice_data['ID']         = $args['invoice_id'];
215 215
     } else {
216 216
         $updating                       = false;
217 217
         $invoice_data['post_type']      = 'wpi_invoice';
218
-        $invoice_data['post_status']    = apply_filters( 'wpinv_default_invoice_status', 'pending' );
218
+        $invoice_data['post_status']    = apply_filters('wpinv_default_invoice_status', 'pending');
219 219
         $invoice_data['ping_status']    = 'closed';
220
-        $invoice_data['post_author']    = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
221
-        $invoice_data['post_title']     = wpinv_format_invoice_number( '0' );
222
-        $invoice_data['post_parent']    = absint( $args['parent'] );
223
-        if ( !empty( $args['created_date'] ) ) {
220
+        $invoice_data['post_author']    = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id();
221
+        $invoice_data['post_title']     = wpinv_format_invoice_number('0');
222
+        $invoice_data['post_parent']    = absint($args['parent']);
223
+        if (!empty($args['created_date'])) {
224 224
             $invoice_data['post_date']      = $args['created_date'];
225
-            $invoice_data['post_date_gmt']  = get_gmt_from_date( $args['created_date'] );
225
+            $invoice_data['post_date_gmt']  = get_gmt_from_date($args['created_date']);
226 226
         }
227 227
     }
228 228
 
229
-    if ( $args['status'] ) {
230
-        if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) {
231
-            return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) );
229
+    if ($args['status']) {
230
+        if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) {
231
+            return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status']));
232 232
         }
233
-        $invoice_data['post_status']    = $args['status'];
233
+        $invoice_data['post_status'] = $args['status'];
234 234
     }
235 235
 
236
-    if ( ! is_null( $args['user_note'] ) ) {
237
-        $invoice_data['post_excerpt']   = $args['user_note'];
236
+    if (!is_null($args['user_note'])) {
237
+        $invoice_data['post_excerpt'] = $args['user_note'];
238 238
     }
239 239
 
240
-    if ( $updating ) {
241
-        $invoice_id = wp_update_post( $invoice_data, true );
240
+    if ($updating) {
241
+        $invoice_id = wp_update_post($invoice_data, true);
242 242
     } else {
243
-        $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true );
243
+        $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true);
244 244
     }
245 245
 
246
-    if ( is_wp_error( $invoice_id ) ) {
246
+    if (is_wp_error($invoice_id)) {
247 247
         return $wp_error ? $invoice_id : 0;
248 248
     } else {
249
-        if ( !$updating ) {
250
-            $invoice_number = wpinv_format_invoice_number( $invoice_id );
249
+        if (!$updating) {
250
+            $invoice_number = wpinv_format_invoice_number($invoice_id);
251 251
             
252
-            $update = array( 'ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title( $invoice_number ) );
253
-            wp_update_post( $update );
252
+            $update = array('ID' => $invoice_id, 'post_title' => $invoice_number, 'post_name' => sanitize_title($invoice_number));
253
+            wp_update_post($update);
254 254
             
255
-            update_post_meta( $invoice_id, '_wpinv_number', $invoice_number );
255
+            update_post_meta($invoice_id, '_wpinv_number', $invoice_number);
256 256
         }
257 257
     }
258 258
     
259
-    $invoice = wpinv_get_invoice( $invoice_id );
260
-
261
-    if ( !$updating ) {
262
-        update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) );
263
-        update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() );
264
-        update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) );
265
-        update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() );
266
-        update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() );
267
-        update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) );
259
+    $invoice = wpinv_get_invoice($invoice_id);
260
+
261
+    if (!$updating) {
262
+        update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_')));
263
+        update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency());
264
+        update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax'));
265
+        update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip());
266
+        update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent());
267
+        update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via']));
268 268
         
269 269
         // Add invoice note
270
-        $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
270
+        $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status)));
271 271
     }
272 272
 
273
-    update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION );
273
+    update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION);
274 274
 
275 275
     return $invoice;
276 276
 }
@@ -278,118 +278,118 @@  discard block
 block discarded – undo
278 278
 function wpinv_get_prefix() {
279 279
     $invoice_prefix = 'INV-';
280 280
     
281
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
281
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
282 282
 }
283 283
 
284 284
 function wpinv_get_business_logo() {
285
-    $business_logo = wpinv_get_option( 'logo' );
286
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
285
+    $business_logo = wpinv_get_option('logo');
286
+    return apply_filters('wpinv_get_business_logo', $business_logo);
287 287
 }
288 288
 
289 289
 function wpinv_get_business_name() {
290 290
     $business_name = wpinv_get_option('store_name');
291
-    return apply_filters( 'wpinv_get_business_name', $business_name );
291
+    return apply_filters('wpinv_get_business_name', $business_name);
292 292
 }
293 293
 
294 294
 function wpinv_get_blogname() {
295
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
295
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
296 296
 }
297 297
 
298 298
 function wpinv_get_admin_email() {
299
-    $admin_email = get_option( 'admin_email' );
300
-    return apply_filters( 'wpinv_admin_email', $admin_email );
299
+    $admin_email = get_option('admin_email');
300
+    return apply_filters('wpinv_admin_email', $admin_email);
301 301
 }
302 302
 
303 303
 function wpinv_get_business_website() {
304
-    $business_website = home_url( '/' );
305
-    return apply_filters( 'wpinv_get_business_website', $business_website );
304
+    $business_website = home_url('/');
305
+    return apply_filters('wpinv_get_business_website', $business_website);
306 306
 }
307 307
 
308
-function wpinv_get_terms_text( $invoice_id = 0 ) {
308
+function wpinv_get_terms_text($invoice_id = 0) {
309 309
     $terms_text = '';
310
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
310
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
311 311
 }
312 312
 
313 313
 function wpinv_get_business_footer() {
314
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
315
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
316
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
314
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
315
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
316
+    return apply_filters('wpinv_get_business_footer', $business_footer);
317 317
 }
318 318
 
319 319
 function wpinv_checkout_required_fields() {
320 320
     $required_fields = array();
321 321
     
322 322
     // Let payment gateways and other extensions determine if address fields should be required
323
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
323
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
324 324
     
325
-    if ( $require_billing_details ) {
325
+    if ($require_billing_details) {
326 326
         ///$required_fields['email'] = array(
327 327
                 ///'error_id' => 'invalid_email',
328 328
                 ///'error_message' => __( 'Please enter a valid email address', 'invoicing' )
329 329
             ///);
330 330
         $required_fields['first_name'] = array(
331 331
                 'error_id' => 'invalid_first_name',
332
-                'error_message' => __( 'Please enter your first name', 'invoicing' )
332
+                'error_message' => __('Please enter your first name', 'invoicing')
333 333
             );
334 334
         $required_fields['address'] = array(
335 335
                 'error_id' => 'invalid_address',
336
-                'error_message' => __( 'Please enter your address', 'invoicing' )
336
+                'error_message' => __('Please enter your address', 'invoicing')
337 337
             );
338 338
         $required_fields['city'] = array(
339 339
                 'error_id' => 'invalid_city',
340
-                'error_message' => __( 'Please enter your billing city', 'invoicing' )
340
+                'error_message' => __('Please enter your billing city', 'invoicing')
341 341
             );
342 342
         $required_fields['state'] = array(
343 343
                 'error_id' => 'invalid_state',
344
-                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
344
+                'error_message' => __('Please enter billing state / province', 'invoicing')
345 345
             );
346 346
         $required_fields['country'] = array(
347 347
                 'error_id' => 'invalid_country',
348
-                'error_message' => __( 'Please select your billing country', 'invoicing' )
348
+                'error_message' => __('Please select your billing country', 'invoicing')
349 349
             );
350 350
     }
351 351
 
352
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
352
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
353 353
 }
354 354
 
355 355
 function wpinv_is_ssl_enforced() {
356
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
357
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
356
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
357
+    return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
358 358
 }
359 359
 
360
-function wpinv_user_can_print_invoice( $post ) {
360
+function wpinv_user_can_print_invoice($post) {
361 361
     $allow = false;
362 362
     
363
-    if ( !( $user_id = get_current_user_id() ) ) {
363
+    if (!($user_id = get_current_user_id())) {
364 364
         return $allow;
365 365
     }
366 366
     
367
-    if ( is_int( $post ) ) {
368
-        $post = get_post( $post );
367
+    if (is_int($post)) {
368
+        $post = get_post($post);
369 369
     }
370 370
     
371 371
     // Allow to owner.
372
-    if ( is_object( $post ) && !empty( $post->post_author ) && $post->post_author == $user_id ) {
372
+    if (is_object($post) && !empty($post->post_author) && $post->post_author == $user_id) {
373 373
         $allow = true;
374 374
     }
375 375
     
376 376
     // Allow to admin user.
377
-    if ( current_user_can( 'manage_options' ) ) {
377
+    if (current_user_can('manage_options')) {
378 378
         $allow = true;
379 379
     }
380 380
     
381
-    return apply_filters( 'wpinv_can_print_invoice', $allow, $post );
381
+    return apply_filters('wpinv_can_print_invoice', $allow, $post);
382 382
 }
383 383
 
384 384
 function wpinv_schedule_events() {
385 385
     // hourly, daily and twicedaily
386
-    if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) {
387
-        wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' );
386
+    if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) {
387
+        wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily');
388 388
     }
389 389
 }
390
-add_action( 'wp', 'wpinv_schedule_events' );
390
+add_action('wp', 'wpinv_schedule_events');
391 391
 
392 392
 function wpinv_schedule_event_twicedaily() {
393 393
     wpinv_email_payment_reminders();
394 394
 }
395
-add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' );
396 395
\ No newline at end of file
396
+add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily');
397 397
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-notes.php 1 patch
Spacing   +39 added lines, -39 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,73 +14,73 @@  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 );
26
+        add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
27 27
         
28 28
         // Count comments
29
-        add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 11, 2 );
29
+        add_filter('wp_count_comments', array($this, 'wp_count_comments'), 11, 2);
30 30
         
31 31
         // Delete comments count cache whenever there is a new comment or a comment status changes
32
-        add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
33
-        add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
32
+        add_action('wp_insert_comment', array($this, 'delete_comments_count_cache'));
33
+        add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache'));
34 34
         
35
-        do_action( 'wpinv_class_notes_actions', $this );
35
+        do_action('wpinv_class_notes_actions', $this);
36 36
     }
37 37
         
38
-    public function set_invoice_note_type( $query ) {
39
-        $post_ID        = !empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
38
+    public function set_invoice_note_type($query) {
39
+        $post_ID = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
40 40
         
41
-        if ( $post_ID && get_post_type( $post_ID ) == $this->invoice_post_type ) {
41
+        if ($post_ID && get_post_type($post_ID) == $this->invoice_post_type) {
42 42
             $query->query_vars['type__in']      = $this->comment_type;
43 43
             $query->query_vars['type__not_in']  = '';
44 44
         } else {        
45
-            if ( isset( $query->query_vars['type__in'] ) && $type_in = $query->query_vars['type__in'] ) {
46
-                if ( is_array( $type_in ) && in_array( $this->comment_type, $type_in ) ) {
47
-                    $key = array_search( $this->comment_type, $type_in );
48
-                    unset( $query->query_vars['type__in'][$key] );
49
-                } else if ( !is_array( $type_in ) && $type_in == $this->comment_type ) {
45
+            if (isset($query->query_vars['type__in']) && $type_in = $query->query_vars['type__in']) {
46
+                if (is_array($type_in) && in_array($this->comment_type, $type_in)) {
47
+                    $key = array_search($this->comment_type, $type_in);
48
+                    unset($query->query_vars['type__in'][$key]);
49
+                } else if (!is_array($type_in) && $type_in == $this->comment_type) {
50 50
                     $query->query_vars['type__in'] = '';
51 51
                 }
52 52
             }
53 53
             
54
-            if ( isset( $query->query_vars['type__not_in'] ) && $type_not_in = $query->query_vars['type__not_in'] ) {
55
-                if ( is_array( $type_not_in ) && !in_array( $this->comment_type, $type_not_in ) ) {
54
+            if (isset($query->query_vars['type__not_in']) && $type_not_in = $query->query_vars['type__not_in']) {
55
+                if (is_array($type_not_in) && !in_array($this->comment_type, $type_not_in)) {
56 56
                     $query->query_vars['type__not_in'][] = $this->comment_type;
57
-                } else if ( !is_array( $type_not_in ) && $type_not_in != $this->comment_type ) {
57
+                } else if (!is_array($type_not_in) && $type_not_in != $this->comment_type) {
58 58
                     $query->query_vars['type__not_in'] = (array)$query->query_vars['type__not_in'];
59 59
                     $query->query_vars['type__not_in'][] = $this->comment_type;
60 60
                 }
61 61
             } else {
62
-                $query->query_vars['type__not_in']  = $this->comment_type;
62
+                $query->query_vars['type__not_in'] = $this->comment_type;
63 63
             }
64 64
         }
65 65
         
66 66
         return $query;
67 67
     }
68 68
     
69
-    public function get_invoice_notes( $invoice_id = 0, $type = '' ) {
69
+    public function get_invoice_notes($invoice_id = 0, $type = '') {
70 70
         $args = array( 
71 71
             'post_id'   => $invoice_id,
72 72
             'orderby'   => 'comment_ID',
73 73
             'order'     => 'DESC',
74 74
         );
75 75
         
76
-        if ( $type == 'customer' ) {
76
+        if ($type == 'customer') {
77 77
             $args['meta_key']   = '_wpi_customer_note';
78 78
             $args['meta_value'] = 1;
79 79
         }
80 80
         
81
-        $args   = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
81
+        $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
82 82
         
83
-        return get_comments( $args );
83
+        return get_comments($args);
84 84
     }
85 85
     
86 86
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @return void
92 92
      */
93 93
     public function delete_comments_count_cache() {
94
-        delete_transient( 'wpinv_count_comments' );
94
+        delete_transient('wpinv_count_comments');
95 95
     }
96 96
     
97 97
     /**
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
      * @param  int    $post_id Post ID.
103 103
      * @return object
104 104
      */
105
-    public function wp_count_comments( $stats, $post_id ) {
105
+    public function wp_count_comments($stats, $post_id) {
106 106
         global $wpdb;
107 107
 
108
-        if ( 0 === $post_id ) {
109
-            $stats = get_transient( 'wpinv_count_comments' );
108
+        if (0 === $post_id) {
109
+            $stats = get_transient('wpinv_count_comments');
110 110
 
111
-            if ( ! $stats ) {
111
+            if (!$stats) {
112 112
                 $stats = array();
113 113
 
114
-                $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 );
114
+                $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 115
 
116 116
                 $total = 0;
117 117
                 $approved = array(
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
                     'post-trashed' => 'post-trashed',
123 123
                 );
124 124
 
125
-                foreach ( (array) $count as $row ) {
125
+                foreach ((array)$count as $row) {
126 126
                     // Do not count post-trashed toward totals.
127
-                    if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) {
127
+                    if ('post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved']) {
128 128
                         $total += $row['num_comments'];
129 129
                     }
130
-                    if ( isset( $approved[ $row['comment_approved'] ] ) ) {
131
-                        $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
130
+                    if (isset($approved[$row['comment_approved']])) {
131
+                        $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
132 132
                     }
133 133
                 }
134 134
 
135 135
                 $stats['total_comments'] = $total;
136 136
                 $stats['all'] = $total;
137
-                foreach ( $approved as $key ) {
138
-                    if ( empty( $stats[ $key ] ) ) {
139
-                        $stats[ $key ] = 0;
137
+                foreach ($approved as $key) {
138
+                    if (empty($stats[$key])) {
139
+                        $stats[$key] = 0;
140 140
                     }
141 141
                 }
142 142
 
143
-                $stats = (object) $stats;
144
-                set_transient( 'wpinv_count_comments', $stats );
143
+                $stats = (object)$stats;
144
+                set_transient('wpinv_count_comments', $stats);
145 145
             }
146 146
         }
147 147
 
Please login to merge, or discard this patch.
includes/class-wpinv-db.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -21,108 +21,108 @@  discard block
 block discarded – undo
21 21
         return array();
22 22
     }
23 23
 
24
-    public function get( $row_id ) {
24
+    public function get($row_id) {
25 25
         global $wpdb;
26
-        return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1", $row_id ) );
26
+        return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1", $row_id));
27 27
     }
28 28
 
29
-    public function get_by( $column, $row_id ) {
29
+    public function get_by($column, $row_id) {
30 30
         global $wpdb;
31
-        $column = esc_sql( $column );
32
-        return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1", $row_id ) );
31
+        $column = esc_sql($column);
32
+        return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1", $row_id));
33 33
     }
34 34
 
35
-    public function get_column( $column, $row_id ) {
35
+    public function get_column($column, $row_id) {
36 36
         global $wpdb;
37
-        $column = esc_sql( $column );
38
-        return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1", $row_id ) );
37
+        $column = esc_sql($column);
38
+        return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1", $row_id));
39 39
     }
40 40
 
41
-    public function get_column_by( $column, $column_where, $column_value ) {
41
+    public function get_column_by($column, $column_where, $column_value) {
42 42
         global $wpdb;
43
-        $column_where = esc_sql( $column_where );
44
-        $column       = esc_sql( $column );
45
-        return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1", $column_value ) );
43
+        $column_where = esc_sql($column_where);
44
+        $column       = esc_sql($column);
45
+        return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1", $column_value));
46 46
     }
47 47
 
48
-    public function insert( $data, $type = '' ) {
48
+    public function insert($data, $type = '') {
49 49
         global $wpdb;
50 50
 
51
-        $data = wp_parse_args( $data, $this->get_column_defaults() );
51
+        $data = wp_parse_args($data, $this->get_column_defaults());
52 52
 
53
-        do_action( 'wpinv_pre_insert_' . $type, $data );
53
+        do_action('wpinv_pre_insert_' . $type, $data);
54 54
 
55 55
         $column_formats = $this->get_columns();
56 56
 
57
-        $data = array_change_key_case( $data );
57
+        $data = array_change_key_case($data);
58 58
 
59
-        $data = array_intersect_key( $data, $column_formats );
59
+        $data = array_intersect_key($data, $column_formats);
60 60
 
61
-        $data_keys = array_keys( $data );
62
-        $column_formats = array_merge( array_flip( $data_keys ), $column_formats );
61
+        $data_keys = array_keys($data);
62
+        $column_formats = array_merge(array_flip($data_keys), $column_formats);
63 63
 
64
-        $wpdb->insert( $this->table_name, $data, $column_formats );
64
+        $wpdb->insert($this->table_name, $data, $column_formats);
65 65
         $wpdb_insert_id = $wpdb->insert_id;
66 66
 
67
-        do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data );
67
+        do_action('wpinv_post_insert_' . $type, $wpdb_insert_id, $data);
68 68
 
69 69
         return $wpdb_insert_id;
70 70
     }
71 71
 
72
-    public function update( $row_id, $data = array(), $where = '' ) {
72
+    public function update($row_id, $data = array(), $where = '') {
73 73
         global $wpdb;
74 74
 
75
-        $row_id = absint( $row_id );
75
+        $row_id = absint($row_id);
76 76
 
77
-        if( empty( $row_id ) ) {
77
+        if (empty($row_id)) {
78 78
             return false;
79 79
         }
80 80
 
81
-        if( empty( $where ) ) {
81
+        if (empty($where)) {
82 82
             $where = $this->primary_key;
83 83
         }
84 84
 
85 85
         $column_formats = $this->get_columns();
86 86
 
87
-        $data = array_change_key_case( $data );
87
+        $data = array_change_key_case($data);
88 88
 
89
-        $data = array_intersect_key( $data, $column_formats );
89
+        $data = array_intersect_key($data, $column_formats);
90 90
 
91
-        $data_keys = array_keys( $data );
92
-        $column_formats = array_merge( array_flip( $data_keys ), $column_formats );
91
+        $data_keys = array_keys($data);
92
+        $column_formats = array_merge(array_flip($data_keys), $column_formats);
93 93
 
94
-        if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
94
+        if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
95 95
             return false;
96 96
         }
97 97
 
98 98
         return true;
99 99
     }
100 100
 
101
-    public function delete( $row_id = 0 ) {
101
+    public function delete($row_id = 0) {
102 102
         global $wpdb;
103 103
 
104
-        $row_id = absint( $row_id );
104
+        $row_id = absint($row_id);
105 105
 
106
-        if( empty( $row_id ) ) {
106
+        if (empty($row_id)) {
107 107
             return false;
108 108
         }
109 109
 
110
-        if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
110
+        if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
111 111
             return false;
112 112
         }
113 113
 
114 114
         return true;
115 115
     }
116 116
 
117
-    public function table_exists( $table ) {
117
+    public function table_exists($table) {
118 118
         global $wpdb;
119
-        $table = sanitize_text_field( $table );
119
+        $table = sanitize_text_field($table);
120 120
 
121
-        return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
121
+        return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
122 122
     }
123 123
 
124 124
     public function installed() {
125
-        return $this->table_exists( $this->table_name );
125
+        return $this->table_exists($this->table_name);
126 126
     }
127 127
 
128 128
 }
Please login to merge, or discard this patch.
includes/class-wpinv-subscription.php 1 patch
Spacing   +188 added lines, -188 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
 
@@ -27,60 +27,60 @@  discard block
 block discarded – undo
27 27
     public $user;
28 28
     public $post_type;
29 29
 
30
-    function __construct( $id_or_object = 0, $by_profile_id = false ) {
30
+    function __construct($id_or_object = 0, $by_profile_id = false) {
31 31
         $this->subscriptions_db = new WPInv_Subscriptions_DB;
32 32
 
33
-        if ( $by_profile_id ) {
34
-            $subscription = $this->subscriptions_db->get_by( 'profile_id', $id_or_object );
33
+        if ($by_profile_id) {
34
+            $subscription = $this->subscriptions_db->get_by('profile_id', $id_or_object);
35 35
 
36
-            if ( empty( $subscription ) ) {
36
+            if (empty($subscription)) {
37 37
                 return false;
38 38
             }
39 39
 
40 40
             $id_or_object = $subscription;
41 41
         }
42 42
 
43
-        return $this->setup_subscription( $id_or_object );
43
+        return $this->setup_subscription($id_or_object);
44 44
     }
45 45
 
46
-    private function setup_subscription( $id_or_object = 0 ) {
47
-        if ( empty( $id_or_object ) ) {
46
+    private function setup_subscription($id_or_object = 0) {
47
+        if (empty($id_or_object)) {
48 48
             return false;
49 49
         }
50 50
 
51
-        if ( is_numeric( $id_or_object ) ) {
52
-            $subscription = $this->subscriptions_db->get( $id_or_object );
53
-        } elseif ( is_object( $id_or_object ) ) {
51
+        if (is_numeric($id_or_object)) {
52
+            $subscription = $this->subscriptions_db->get($id_or_object);
53
+        } elseif (is_object($id_or_object)) {
54 54
             $subscription = $id_or_object;
55 55
         }
56 56
 
57
-        if ( empty( $subscription ) ) {
57
+        if (empty($subscription)) {
58 58
             return false;
59 59
         }
60 60
 
61
-        foreach( $subscription as $key => $value ) {
61
+        foreach ($subscription as $key => $value) {
62 62
             $this->$key = $value;
63 63
         }
64 64
 
65
-        $this->post_type = get_post_type( $this->parent_invoice_id );
66
-        $this->user = get_user_by( 'id', $this->user_id );
67
-        $this->gateway = wpinv_get_payment_gateway( $this->parent_invoice_id );
65
+        $this->post_type = get_post_type($this->parent_invoice_id);
66
+        $this->user = get_user_by('id', $this->user_id);
67
+        $this->gateway = wpinv_get_payment_gateway($this->parent_invoice_id);
68 68
 
69
-        do_action( 'wpinv_recurring_setup_subscription', $this );
69
+        do_action('wpinv_recurring_setup_subscription', $this);
70 70
 
71 71
         return $this;
72 72
     }
73 73
 
74
-    public function __get( $key ) {
75
-        if ( method_exists( $this, 'get_' . $key ) ) {
76
-            return call_user_func( array( $this, 'get_' . $key ) );
74
+    public function __get($key) {
75
+        if (method_exists($this, 'get_' . $key)) {
76
+            return call_user_func(array($this, 'get_' . $key));
77 77
         } else {
78
-            return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
78
+            return new WP_Error('wpinv-subscription-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key));
79 79
         }
80 80
     }
81 81
 
82
-    public function create( $data = array() ) {
83
-        if ( $this->id != 0 ) {
82
+    public function create($data = array()) {
83
+        if ($this->id != 0) {
84 84
             return false;
85 85
         }
86 86
 
@@ -101,37 +101,37 @@  discard block
 block discarded – undo
101 101
             'profile_id'        => '',
102 102
         );
103 103
 
104
-        $args = wp_parse_args( $data, $defaults );
104
+        $args = wp_parse_args($data, $defaults);
105 105
 
106
-        if ( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
107
-            if ( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
106
+        if ($args['expiration'] && strtotime('NOW', current_time('timestamp')) > strtotime($args['expiration'], current_time('timestamp'))) {
107
+            if ('active' == $args['status'] || 'trialling' == $args['status']) {
108 108
                 $args['status'] = 'expired';
109 109
             }
110 110
         }
111 111
 
112
-        do_action( 'wpinv_subscription_pre_create', $args );
112
+        do_action('wpinv_subscription_pre_create', $args);
113 113
 
114
-        $id = $this->subscriptions_db->insert( $args, 'subscription' );
114
+        $id = $this->subscriptions_db->insert($args, 'subscription');
115 115
 
116
-        do_action( 'wpinv_subscription_post_create', $id, $args );
116
+        do_action('wpinv_subscription_post_create', $id, $args);
117 117
 
118
-        return $this->setup_subscription( $id );
118
+        return $this->setup_subscription($id);
119 119
     }
120 120
 
121
-    public function update( $args = array() ) {
122
-        if ( isset( $args['status'] ) && strtolower( $this->status ) !== strtolower( $args['status'] ) ) {
123
-            $this->add_note( sprintf( __( 'Status changed from %s to %s', 'invoicing' ), $this->status, $args['status'] ) );
121
+    public function update($args = array()) {
122
+        if (isset($args['status']) && strtolower($this->status) !== strtolower($args['status'])) {
123
+            $this->add_note(sprintf(__('Status changed from %s to %s', 'invoicing'), $this->status, $args['status']));
124 124
         }
125 125
 
126
-        $ret = $this->subscriptions_db->update( $this->id, $args );
126
+        $ret = $this->subscriptions_db->update($this->id, $args);
127 127
 
128
-        do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
128
+        do_action('wpinv_recurring_update_subscription', $this->id, $args, $this);
129 129
 
130 130
         return $ret;
131 131
     }
132 132
 
133 133
     public function delete() {
134
-        return $this->subscriptions_db->delete( $this->id );
134
+        return $this->subscriptions_db->delete($this->id);
135 135
     }
136 136
 
137 137
     public function get_original_invoice_id() {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     }
140 140
 
141 141
     public function get_child_invoices() {
142
-        $invoices = wpinv_get_invoices( array(
142
+        $invoices = wpinv_get_invoices(array(
143 143
             'post_parent'    => (int)$this->parent_invoice_id,
144 144
             'posts_per_page' => '999',
145 145
             'post_status'    => 'any',
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
             'meta_value'     => $this->id,
149 149
             'orderby'        => 'ID',
150 150
             'order'          => 'DESC',
151
-        ) );
151
+        ));
152 152
 
153 153
         return (array)$invoices;
154 154
     }
155 155
 
156 156
     public function get_total_invoices() {
157
-        return count( $this->get_child_invoices() ) + 1;
157
+        return count($this->get_child_invoices()) + 1;
158 158
     }
159 159
 
160 160
     public function get_times_billed() {
161 161
         $times_billed = $this->get_total_invoices();
162 162
 
163
-        if ( ! empty( $this->trial_period ) ) {
163
+        if (!empty($this->trial_period)) {
164 164
             $times_billed -= 1;
165 165
         }
166 166
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
     public function get_lifetime_value() {
171 171
         $amount = 0.00;
172 172
 
173
-        $parent_invoice   = new WPInv_Invoice( $this->parent_invoice_id );
174
-        $ignored_statuses = array( 'wpi-refunded', 'pending', 'wpi-cancelled', 'wpi-failed' );
173
+        $parent_invoice   = new WPInv_Invoice($this->parent_invoice_id);
174
+        $ignored_statuses = array('wpi-refunded', 'pending', 'wpi-cancelled', 'wpi-failed');
175 175
 
176
-        if ( false === in_array( $parent_invoice->status, $ignored_statuses ) ) {
177
-            foreach ( $parent_invoice->cart_details as $cart_item ) {
178
-                if ( (int) $this->item_id === (int) $cart_item['id'] ) {
176
+        if (false === in_array($parent_invoice->status, $ignored_statuses)) {
177
+            foreach ($parent_invoice->cart_details as $cart_item) {
178
+                if ((int)$this->item_id === (int)$cart_item['id']) {
179 179
                     $amount += $cart_item['price'];
180 180
                     break;
181 181
                 }
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
 
185 185
         $children = $this->get_child_invoices();
186 186
 
187
-        if ( $children ) {
188
-            foreach( $children as $child ) {
189
-                $child_invoice = new WPInv_Invoice( $child->ID );
187
+        if ($children) {
188
+            foreach ($children as $child) {
189
+                $child_invoice = new WPInv_Invoice($child->ID);
190 190
                 
191
-                if ( 'wpi-refunded' === $child_invoice->status ) {
191
+                if ('wpi-refunded' === $child_invoice->status) {
192 192
                     continue;
193 193
                 }
194 194
 
@@ -199,46 +199,46 @@  discard block
 block discarded – undo
199 199
         return $amount;
200 200
     }
201 201
 
202
-    public function add_invoice( $args = array() ) {
203
-        $args = wp_parse_args( $args, array(
202
+    public function add_invoice($args = array()) {
203
+        $args = wp_parse_args($args, array(
204 204
             'amount'         => '',
205 205
             'transaction_id' => '',
206 206
             'gateway'        => ''
207
-        ) );
207
+        ));
208 208
 
209
-        if ( wpinv_payment_exists( $args['transaction_id'] ) ) {
209
+        if (wpinv_payment_exists($args['transaction_id'])) {
210 210
             return false;
211 211
         }
212 212
         
213
-        $parent_invoice = wpinv_get_invoice( $this->parent_invoice_id );
214
-        if ( empty( $parent_invoice ) ) {
213
+        $parent_invoice = wpinv_get_invoice($this->parent_invoice_id);
214
+        if (empty($parent_invoice)) {
215 215
             return;
216 216
         }
217 217
         
218 218
         $invoice = new WPInv_Invoice();
219
-        $invoice->set( 'parent_invoice', $this->parent_invoice_id );
220
-        $invoice->set( 'currency', $parent_invoice->get_currency() );
221
-        $invoice->set( 'transaction_id', $args['transaction_id'] );
222
-        $invoice->set( 'key', $parent_invoice->get_key() );
223
-        $invoice->set( 'ip', $parent_invoice->ip );
224
-        $invoice->set( 'user_id', $parent_invoice->get_user_id() );
225
-        $invoice->set( 'first_name', $parent_invoice->get_first_name() );
226
-        $invoice->set( 'last_name', $parent_invoice->get_last_name() );
227
-        $invoice->set( 'phone', $parent_invoice->phone );
228
-        $invoice->set( 'address', $parent_invoice->address );
229
-        $invoice->set( 'city', $parent_invoice->city );
230
-        $invoice->set( 'country', $parent_invoice->country );
231
-        $invoice->set( 'state', $parent_invoice->state );
232
-        $invoice->set( 'zip', $parent_invoice->zip );
233
-        $invoice->set( 'company', $parent_invoice->company );
234
-        $invoice->set( 'vat_number', $parent_invoice->vat_number );
235
-        $invoice->set( 'vat_rate', $parent_invoice->vat_rate );
236
-        $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed );
237
-
238
-        if ( empty( $args['gateway'] ) ) {
239
-            $invoice->set( 'gateway', $parent_invoice->get_gateway() );
219
+        $invoice->set('parent_invoice', $this->parent_invoice_id);
220
+        $invoice->set('currency', $parent_invoice->get_currency());
221
+        $invoice->set('transaction_id', $args['transaction_id']);
222
+        $invoice->set('key', $parent_invoice->get_key());
223
+        $invoice->set('ip', $parent_invoice->ip);
224
+        $invoice->set('user_id', $parent_invoice->get_user_id());
225
+        $invoice->set('first_name', $parent_invoice->get_first_name());
226
+        $invoice->set('last_name', $parent_invoice->get_last_name());
227
+        $invoice->set('phone', $parent_invoice->phone);
228
+        $invoice->set('address', $parent_invoice->address);
229
+        $invoice->set('city', $parent_invoice->city);
230
+        $invoice->set('country', $parent_invoice->country);
231
+        $invoice->set('state', $parent_invoice->state);
232
+        $invoice->set('zip', $parent_invoice->zip);
233
+        $invoice->set('company', $parent_invoice->company);
234
+        $invoice->set('vat_number', $parent_invoice->vat_number);
235
+        $invoice->set('vat_rate', $parent_invoice->vat_rate);
236
+        $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed);
237
+
238
+        if (empty($args['gateway'])) {
239
+            $invoice->set('gateway', $parent_invoice->get_gateway());
240 240
         } else {
241
-            $invoice->set( 'gateway', $args['gateway'] );
241
+            $invoice->set('gateway', $args['gateway']);
242 242
         }
243 243
         
244 244
         $recurring_details = $parent_invoice->get_recurring_details();
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
         // increase the earnings for each item in the subscription
247 247
         $items = $recurring_details['cart_details'];
248 248
         
249
-        if ( $items ) {        
249
+        if ($items) {        
250 250
             $add_items      = array();
251 251
             $cart_details   = array();
252 252
             
253
-            foreach ( $items as $item ) {
253
+            foreach ($items as $item) {
254 254
                 $add_item             = array();
255 255
                 $add_item['id']       = $item['id'];
256 256
                 $add_item['quantity'] = $item['quantity'];
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                 break;
261 261
             }
262 262
             
263
-            $invoice->set( 'items', $add_items );
263
+            $invoice->set('items', $add_items);
264 264
             $invoice->cart_details = $cart_details;
265 265
         }
266 266
         
@@ -270,70 +270,70 @@  discard block
 block discarded – undo
270 270
         $tax                = $recurring_details['tax'];
271 271
         $discount           = $recurring_details['discount'];
272 272
         
273
-        if ( $discount > 0 ) {
274
-            $invoice->set( 'discount_code', $parent_invoice->discount_code );
273
+        if ($discount > 0) {
274
+            $invoice->set('discount_code', $parent_invoice->discount_code);
275 275
         }
276 276
         
277
-        $invoice->subtotal = wpinv_round_amount( $subtotal );
278
-        $invoice->tax      = wpinv_round_amount( $tax );
279
-        $invoice->discount = wpinv_round_amount( $discount );
280
-        $invoice->total    = wpinv_round_amount( $total );
277
+        $invoice->subtotal = wpinv_round_amount($subtotal);
278
+        $invoice->tax      = wpinv_round_amount($tax);
279
+        $invoice->discount = wpinv_round_amount($discount);
280
+        $invoice->total    = wpinv_round_amount($total);
281 281
         $invoice->save();
282
-        $invoice->update_meta( '_wpinv_subscription_id', $this->id );
282
+        $invoice->update_meta('_wpinv_subscription_id', $this->id);
283 283
         
284
-        wpinv_update_payment_status( $invoice->ID, 'publish' );
284
+        wpinv_update_payment_status($invoice->ID, 'publish');
285 285
         sleep(1);
286
-        wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' );
286
+        wpinv_update_payment_status($invoice->ID, 'wpi-renewal');
287 287
         
288
-        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $this );
289
-        do_action( 'wpinv_recurring_record_payment', $invoice->ID, $this->parent_invoice_id, $total, $this );
288
+        do_action('wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $this);
289
+        do_action('wpinv_recurring_record_payment', $invoice->ID, $this->parent_invoice_id, $total, $this);
290 290
 
291 291
         return $invoice;
292 292
     }
293 293
 
294 294
     public function get_transaction_id() {
295
-        if ( empty( $this->transaction_id ) ) {
296
-            $txn_id = wpinv_get_payment_transaction_id( $this->parent_invoice_id );
295
+        if (empty($this->transaction_id)) {
296
+            $txn_id = wpinv_get_payment_transaction_id($this->parent_invoice_id);
297 297
 
298
-            if ( ! empty( $txn_id ) && (int) $this->parent_invoice_id !== (int) $txn_id ) {
299
-                $this->set_transaction_id( $txn_id );
298
+            if (!empty($txn_id) && (int)$this->parent_invoice_id !== (int)$txn_id) {
299
+                $this->set_transaction_id($txn_id);
300 300
             }
301 301
         }
302 302
 
303 303
         return $this->transaction_id;
304 304
     }
305 305
 
306
-    public function set_transaction_id( $txn_id = '' ) {
307
-        $this->update( array( 'transaction_id' => $txn_id ) );
306
+    public function set_transaction_id($txn_id = '') {
307
+        $this->update(array('transaction_id' => $txn_id));
308 308
         $this->transaction_id = $txn_id;
309 309
     }
310 310
 
311 311
     public function renew() {
312 312
         $expires = $this->get_expiration_time();
313 313
 
314
-        if ( $expires > current_time( 'timestamp' ) && $this->is_active() ) {
314
+        if ($expires > current_time('timestamp') && $this->is_active()) {
315 315
             $base_date  = $expires;
316 316
         } else {
317
-            $base_date  = current_time( 'timestamp' );
317
+            $base_date  = current_time('timestamp');
318 318
         }
319 319
 
320
-        $last_day = cal_days_in_month( CAL_GREGORIAN, date_i18n( 'n', $base_date ), date_i18n( 'Y', $base_date ) );
320
+        $last_day = cal_days_in_month(CAL_GREGORIAN, date_i18n('n', $base_date), date_i18n('Y', $base_date));
321 321
 
322 322
         $interval = isset($this->interval) ? $this->interval : 1;
323
-        $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $interval . ' ' . $this->period  . ' 23:59:59', $base_date ) );
323
+        $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $interval . ' ' . $this->period . ' 23:59:59', $base_date));
324 324
 
325
-        if ( date_i18n( 'j', $base_date ) == $last_day && 'day' != $this->period ) {
326
-            $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) );
325
+        if (date_i18n('j', $base_date) == $last_day && 'day' != $this->period) {
326
+            $expiration = date_i18n('Y-m-d H:i:s', strtotime($expiration . ' +2 days'));
327 327
         }
328 328
 
329
-        $expiration  = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this );
329
+        $expiration = apply_filters('wpinv_subscription_renewal_expiration', $expiration, $this->id, $this);
330 330
 
331
-        do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this );
331
+        do_action('wpinv_subscription_pre_renew', $this->id, $expiration, $this);
332 332
 
333 333
         $this->status = 'active';
334 334
         $times_billed = $this->get_times_billed();
335 335
 
336
-        if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
336
+        if ($this->bill_times > 0 && $times_billed >= $this->bill_times) {
337 337
             $this->complete();
338 338
             $this->status = 'completed';
339 339
         }
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
             'status'     => $this->status,
344 344
         );
345 345
 
346
-        $this->update( $args );
346
+        $this->update($args);
347 347
 
348
-        do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this );
349
-        do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
348
+        do_action('wpinv_subscription_post_renew', $this->id, $expiration, $this);
349
+        do_action('wpinv_recurring_set_subscription_status', $this->id, $this->status, $this);
350 350
     }
351 351
 
352 352
     public function complete() {
353
-        if ( 'cancelled' === $this->status ) {
353
+        if ('cancelled' === $this->status) {
354 354
             return;
355 355
         }
356 356
 
@@ -358,20 +358,20 @@  discard block
 block discarded – undo
358 358
             'status' => 'completed'
359 359
         );
360 360
 
361
-        if ( $this->subscriptions_db->update( $this->id, $args ) ) {
362
-            $this->add_note( sprintf( __( 'Status changed from %s to %s', 'invoicing' ), $this->status, 'completed' ) );
361
+        if ($this->subscriptions_db->update($this->id, $args)) {
362
+            $this->add_note(sprintf(__('Status changed from %s to %s', 'invoicing'), $this->status, 'completed'));
363 363
 
364 364
             $this->status = 'completed';
365 365
 
366
-            do_action( 'wpinv_subscription_completed', $this->id, $this );
366
+            do_action('wpinv_subscription_completed', $this->id, $this);
367 367
         }
368 368
     }
369 369
 
370
-    public function expire( $check_expiration = false ) {
370
+    public function expire($check_expiration = false) {
371 371
         $expiration = $this->expiration;
372 372
 
373
-        if ( $check_expiration && $this->check_expiration() ) {
374
-            if ( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
373
+        if ($check_expiration && $this->check_expiration()) {
374
+            if ($expiration < $this->get_expiration() && current_time('timestamp') < $this->get_expiration_time()) {
375 375
                 return false;
376 376
             }
377 377
         }
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
             'status' => 'expired'
381 381
         );
382 382
 
383
-        if ( $this->subscriptions_db->update( $this->id, $args ) ) {
384
-            $this->add_note( sprintf( __( 'Status changed from %s to %s', 'invoicing' ), $this->status, 'expired' ) );
383
+        if ($this->subscriptions_db->update($this->id, $args)) {
384
+            $this->add_note(sprintf(__('Status changed from %s to %s', 'invoicing'), $this->status, 'expired'));
385 385
 
386 386
             $this->status = 'expired';
387 387
 
388
-            do_action( 'wpinv_subscription_expired', $this->id, $this );
388
+            do_action('wpinv_subscription_expired', $this->id, $this);
389 389
         }
390 390
     }
391 391
 
@@ -394,17 +394,17 @@  discard block
 block discarded – undo
394 394
             'status' => 'failing'
395 395
         );
396 396
 
397
-        if ( $this->subscriptions_db->update( $this->id, $args ) ) {
398
-            $this->add_note( sprintf( __( 'Status changed from %s to %s', 'invoicing' ), $this->status, 'failing' ) );
397
+        if ($this->subscriptions_db->update($this->id, $args)) {
398
+            $this->add_note(sprintf(__('Status changed from %s to %s', 'invoicing'), $this->status, 'failing'));
399 399
 
400 400
             $this->status = 'failing';
401 401
 
402
-            do_action( 'wpinv_subscription_failing', $this->id, $this );
402
+            do_action('wpinv_subscription_failing', $this->id, $this);
403 403
         }
404 404
     }
405 405
 
406 406
     public function cancel() {
407
-        if ( 'cancelled' === $this->status ) {
407
+        if ('cancelled' === $this->status) {
408 408
             return;
409 409
         }
410 410
 
@@ -412,108 +412,108 @@  discard block
 block discarded – undo
412 412
             'status' => 'cancelled'
413 413
         );
414 414
 
415
-        if ( $this->subscriptions_db->update( $this->id, $args ) ) {
416
-            if ( is_user_logged_in() ) {
417
-                $userdata = get_userdata( get_current_user_id() );
415
+        if ($this->subscriptions_db->update($this->id, $args)) {
416
+            if (is_user_logged_in()) {
417
+                $userdata = get_userdata(get_current_user_id());
418 418
                 $user     = $userdata->user_login;
419 419
             } else {
420
-                $user = __( 'gateway', 'invoicing' );
420
+                $user = __('gateway', 'invoicing');
421 421
             }
422 422
 
423
-            $note = sprintf( __( 'Subscription #%d cancelled by %s', 'invoicing' ), $this->id, $user );
424
-            $this->add_note( $note );
423
+            $note = sprintf(__('Subscription #%d cancelled by %s', 'invoicing'), $this->id, $user);
424
+            $this->add_note($note);
425 425
             $this->status = 'cancelled';
426 426
 
427
-            do_action( 'wpinv_subscription_cancelled', $this->id, $this );
427
+            do_action('wpinv_subscription_cancelled', $this->id, $this);
428 428
         }
429 429
     }
430 430
 
431 431
     public function can_cancel() {
432
-        return apply_filters( 'wpinv_subscription_can_cancel', false, $this );
432
+        return apply_filters('wpinv_subscription_can_cancel', false, $this);
433 433
     }
434 434
 
435 435
     public function get_cancel_url() {
436
-        $url = wp_nonce_url( add_query_arg( array( 'wpi_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
436
+        $url = wp_nonce_url(add_query_arg(array('wpi_action' => 'cancel_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-cancel');
437 437
 
438
-        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
438
+        return apply_filters('wpinv_subscription_cancel_url', $url, $this);
439 439
     }
440 440
 
441 441
     public function can_renew() {
442
-        return apply_filters( 'wpinv_subscription_can_renew', false, $this );
442
+        return apply_filters('wpinv_subscription_can_renew', false, $this);
443 443
     }
444 444
 
445 445
     public function get_renew_url() {
446
-        $url = wp_nonce_url( add_query_arg( array( 'wpi_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
446
+        $url = wp_nonce_url(add_query_arg(array('wpi_action' => 'renew_subscription', 'sub_id' => $this->id)), 'wpinv-recurring-renew');
447 447
 
448
-        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
448
+        return apply_filters('wpinv_subscription_renew_url', $url, $this);
449 449
     }
450 450
 
451 451
     public function can_update() {
452
-        return apply_filters( 'wpinv_subscription_can_update', false, $this );
452
+        return apply_filters('wpinv_subscription_can_update', false, $this);
453 453
     }
454 454
 
455 455
     public function get_update_url() {
456
-        $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
456
+        $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->id));
457 457
 
458
-        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
458
+        return apply_filters('wpinv_subscription_update_url', $url, $this);
459 459
     }
460 460
 
461 461
     public function is_active() {
462 462
         $ret = false;
463 463
 
464
-        if ( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
464
+        if (!$this->is_expired() && ($this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling')) {
465 465
             $ret = true;
466 466
         }
467 467
 
468
-        return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
468
+        return apply_filters('wpinv_subscription_is_active', $ret, $this->id, $this);
469 469
     }
470 470
 
471 471
     public function is_expired() {
472 472
         $ret = false;
473 473
 
474
-        if ( $this->status == 'expired' ) {
474
+        if ($this->status == 'expired') {
475 475
             $ret = true;
476
-        } elseif ( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
476
+        } elseif ('active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling') {
477 477
             $ret        = false;
478 478
             $expiration = $this->get_expiration_time();
479 479
 
480
-            if ( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
480
+            if ($expiration && strtotime('NOW', current_time('timestamp')) > $expiration) {
481 481
                 $ret = true;
482 482
 
483
-                if ( 'active' === $this->status || $this->status == 'trialling'  ) {
483
+                if ('active' === $this->status || $this->status == 'trialling') {
484 484
                     $this->expire();
485 485
                 }
486 486
             }
487 487
         }
488 488
 
489
-        return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
489
+        return apply_filters('wpinv_subscription_is_expired', $ret, $this->id, $this);
490 490
     }
491 491
 
492
-    public function get_expiration( $check_gateway = true ) {
492
+    public function get_expiration($check_gateway = true) {
493 493
         return $this->expiration;
494 494
     }
495 495
 
496 496
     public function check_expiration() {
497
-        $ret   = false;
497
+        $ret = false;
498 498
         
499
-        $expiration = apply_filters( 'wpinv_subscription_ ' . $this->gateway . '_get_expiration', NULL, $this->id, $this );
499
+        $expiration = apply_filters('wpinv_subscription_ ' . $this->gateway . '_get_expiration', NULL, $this->id, $this);
500 500
         
501
-        $class = edd_recurring()->get_gateway_class( $this->gateway );
501
+        $class = edd_recurring()->get_gateway_class($this->gateway);
502 502
 
503
-        if ( $class && class_exists( $class ) ) {
503
+        if ($class && class_exists($class)) {
504 504
             $gateway = new $class;
505 505
 
506
-            if ( is_callable( array( $gateway, 'get_expiration' ) ) ) {
507
-                $expiration = $gateway->get_expiration( $this );
506
+            if (is_callable(array($gateway, 'get_expiration'))) {
507
+                $expiration = $gateway->get_expiration($this);
508 508
 
509
-                if ( ! is_wp_error( $expiration ) && $this->get_expiration_time() < strtotime( $expiration, current_time( 'timestamp' ) ) ) {
510
-                    $this->update( array( 'expiration' => $expiration ) );
509
+                if (!is_wp_error($expiration) && $this->get_expiration_time() < strtotime($expiration, current_time('timestamp'))) {
510
+                    $this->update(array('expiration' => $expiration));
511 511
                     $this->expiration = $expiration;
512 512
                     $ret = true;
513 513
 
514
-                    $this->add_note( sprintf( __( 'Expiration synced with gateway and updated to %s', 'invoicing' ), $expiration ) );
514
+                    $this->add_note(sprintf(__('Expiration synced with gateway and updated to %s', 'invoicing'), $expiration));
515 515
 
516
-                    do_action( 'edd_recurring_check_expiration', $this, $expiration );
516
+                    do_action('edd_recurring_check_expiration', $this, $expiration);
517 517
                 }
518 518
             }
519 519
         }
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
     }
523 523
 
524 524
     public function get_expiration_time() {
525
-        return strtotime( $this->expiration, current_time( 'timestamp' ) );
525
+        return strtotime($this->expiration, current_time('timestamp'));
526 526
     }
527 527
 
528 528
     public function get_status() {
@@ -532,36 +532,36 @@  discard block
 block discarded – undo
532 532
     }
533 533
 
534 534
     public function get_status_label() {
535
-        switch( $this->get_status() ) {
535
+        switch ($this->get_status()) {
536 536
             case 'active' :
537
-                $status = __( 'Active', 'invoicing' );
537
+                $status = __('Active', 'invoicing');
538 538
                 break;
539 539
             case 'cancelled' :
540
-                $status = __( 'Cancelled', 'invoicing' );
540
+                $status = __('Cancelled', 'invoicing');
541 541
                 break;
542 542
             case 'completed' :
543
-                $status = __( 'Completed', 'invoicing' );
543
+                $status = __('Completed', 'invoicing');
544 544
                 break;
545 545
             case 'expired' :
546
-                $status = __( 'Expired', 'invoicing' );
546
+                $status = __('Expired', 'invoicing');
547 547
                 break;
548 548
             case 'failing' :
549
-                $status = __( 'Failing', 'invoicing' );
549
+                $status = __('Failing', 'invoicing');
550 550
                 break;
551 551
             case 'pending' :
552
-                $status = __( 'Pending', 'invoicing' );
552
+                $status = __('Pending', 'invoicing');
553 553
                 break;
554 554
             case 'stopped' :
555
-                $status = __( 'Stopped', 'invoicing' );
555
+                $status = __('Stopped', 'invoicing');
556 556
                 break;
557 557
             case 'trialling' :
558
-                $status = __( 'Trialling', 'invoicing' );
558
+                $status = __('Trialling', 'invoicing');
559 559
                 break;
560 560
             default:
561 561
                 $status = $this->get_status();
562 562
                 
563
-                if ( $status ) {
564
-                    $status = __( wpinv_utf8_ucfirst( $status ), 'invoicing' );
563
+                if ($status) {
564
+                    $status = __(wpinv_utf8_ucfirst($status), 'invoicing');
565 565
                 }
566 566
                 break;
567 567
         }
@@ -569,57 +569,57 @@  discard block
 block discarded – undo
569 569
         return $status;
570 570
     }
571 571
 
572
-    public function get_notes( $length = 20, $paged = 1 ) {
573
-        $length = is_numeric( $length ) ? $length : 20;
574
-        $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
572
+    public function get_notes($length = 20, $paged = 1) {
573
+        $length = is_numeric($length) ? $length : 20;
574
+        $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
575 575
 
576 576
         $all_notes   = $this->get_raw_notes();
577
-        $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
577
+        $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
578 578
 
579
-        $desired_notes = array_slice( $notes_array, $offset, $length );
579
+        $desired_notes = array_slice($notes_array, $offset, $length);
580 580
 
581 581
         return $desired_notes;
582 582
     }
583 583
 
584 584
     public function get_notes_count() {
585 585
         $all_notes = $this->get_raw_notes();
586
-        $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
586
+        $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
587 587
 
588
-        return count( $notes_array );
588
+        return count($notes_array);
589 589
     }
590 590
 
591
-    public function add_note( $note = '' ) {
592
-        $note = trim( $note );
593
-        if ( empty( $note ) ) {
591
+    public function add_note($note = '') {
592
+        $note = trim($note);
593
+        if (empty($note)) {
594 594
             return false;
595 595
         }
596 596
 
597 597
         $notes = $this->get_raw_notes();
598 598
 
599
-        if ( empty( $notes ) ) {
599
+        if (empty($notes)) {
600 600
             $notes = '';
601 601
         }
602 602
 
603
-        $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
604
-        $new_note    = apply_filters( 'edd_subscription_add_note_string', $note_string );
603
+        $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')) . ' - ' . $note;
604
+        $new_note    = apply_filters('edd_subscription_add_note_string', $note_string);
605 605
         $notes      .= "\n\n" . $new_note;
606 606
 
607
-        do_action( 'edd_subscription_pre_add_note', $new_note, $this->id );
607
+        do_action('edd_subscription_pre_add_note', $new_note, $this->id);
608 608
 
609
-        $updated = $this->update( array( 'notes' => $notes ) );
609
+        $updated = $this->update(array('notes' => $notes));
610 610
 
611
-        if ( $updated ) {
611
+        if ($updated) {
612 612
             $this->notes = $this->get_notes();
613 613
         }
614 614
 
615
-        do_action( 'edd_subscription_post_add_note', $this->notes, $new_note, $this->id );
615
+        do_action('edd_subscription_post_add_note', $this->notes, $new_note, $this->id);
616 616
 
617 617
         return $new_note;
618 618
     }
619 619
 
620 620
     private function get_raw_notes() {
621
-        $all_notes = $this->subscriptions_db->get_column( 'notes', $this->id );
621
+        $all_notes = $this->subscriptions_db->get_column('notes', $this->id);
622 622
 
623
-        return (string) $all_notes;
623
+        return (string)$all_notes;
624 624
     }
625 625
 }
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +477 added lines, -477 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_get_option( $key = '', $default = false ) {
7
+function wpinv_get_option($key = '', $default = false) {
8 8
     global $wpinv_options;
9 9
 
10
-    $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default;
11
-    $value = apply_filters( 'wpinv_get_option', $value, $key, $default );
10
+    $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default;
11
+    $value = apply_filters('wpinv_get_option', $value, $key, $default);
12 12
 
13
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
13
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
14 14
 }
15 15
 
16
-function wpinv_update_option( $key = '', $value = false ) {
16
+function wpinv_update_option($key = '', $value = false) {
17 17
     // If no key, exit
18
-    if ( empty( $key ) ) {
18
+    if (empty($key)) {
19 19
         return false;
20 20
     }
21 21
 
22
-    if ( empty( $value ) ) {
23
-        $remove_option = wpinv_delete_option( $key );
22
+    if (empty($value)) {
23
+        $remove_option = wpinv_delete_option($key);
24 24
         return $remove_option;
25 25
     }
26 26
 
27 27
     // First let's grab the current settings
28
-    $options = get_option( 'wpinv_settings' );
28
+    $options = get_option('wpinv_settings');
29 29
 
30 30
     // Let's let devs alter that value coming in
31
-    $value = apply_filters( 'wpinv_update_option', $value, $key );
31
+    $value = apply_filters('wpinv_update_option', $value, $key);
32 32
 
33 33
     // Next let's try to update the value
34
-    $options[ $key ] = $value;
35
-    $did_update = update_option( 'wpinv_settings', $options );
34
+    $options[$key] = $value;
35
+    $did_update = update_option('wpinv_settings', $options);
36 36
 
37 37
     // If it updated, let's update the global variable
38
-    if ( $did_update ) {
38
+    if ($did_update) {
39 39
         global $wpinv_options;
40
-        $wpinv_options[ $key ] = $value;
40
+        $wpinv_options[$key] = $value;
41 41
     }
42 42
 
43 43
     return $did_update;
44 44
 }
45 45
 
46
-function wpinv_delete_option( $key = '' ) {
46
+function wpinv_delete_option($key = '') {
47 47
     // If no key, exit
48
-    if ( empty( $key ) ) {
48
+    if (empty($key)) {
49 49
         return false;
50 50
     }
51 51
 
52 52
     // First let's grab the current settings
53
-    $options = get_option( 'wpinv_settings' );
53
+    $options = get_option('wpinv_settings');
54 54
 
55 55
     // Next let's try to update the value
56
-    if( isset( $options[ $key ] ) ) {
57
-        unset( $options[ $key ] );
56
+    if (isset($options[$key])) {
57
+        unset($options[$key]);
58 58
     }
59 59
 
60
-    $did_update = update_option( 'wpinv_settings', $options );
60
+    $did_update = update_option('wpinv_settings', $options);
61 61
 
62 62
     // If it updated, let's update the global variable
63
-    if ( $did_update ){
63
+    if ($did_update) {
64 64
         global $wpinv_options;
65 65
         $wpinv_options = $options;
66 66
     }
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_get_settings() {
72
-    $settings = get_option( 'wpinv_settings' );
72
+    $settings = get_option('wpinv_settings');
73 73
 
74
-    if ( empty( $settings ) ) {
74
+    if (empty($settings)) {
75 75
         // Update old settings with new single option
76
-        $general_settings   = is_array( get_option( 'wpinv_settings_general' ) )    ? get_option( 'wpinv_settings_general' )    : array();
77
-        $gateways_settings  = is_array( get_option( 'wpinv_settings_gateways' ) )   ? get_option( 'wpinv_settings_gateways' )   : array();
78
-        $email_settings     = is_array( get_option( 'wpinv_settings_emails' ) )     ? get_option( 'wpinv_settings_emails' )     : array();
79
-        $tax_settings       = is_array( get_option( 'wpinv_settings_taxes' ) )      ? get_option( 'wpinv_settings_taxes' )      : array();
80
-        $misc_settings      = is_array( get_option( 'wpinv_settings_misc' ) )       ? get_option( 'wpinv_settings_misc' )       : array();
81
-        $tool_settings      = is_array( get_option( 'wpinv_settings_tools' ) )      ? get_option( 'wpinv_settings_tools' )      : array();
76
+        $general_settings   = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array();
77
+        $gateways_settings  = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array();
78
+        $email_settings     = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array();
79
+        $tax_settings       = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array();
80
+        $misc_settings      = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array();
81
+        $tool_settings      = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array();
82 82
 
83
-        $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings );
83
+        $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings);
84 84
 
85
-        update_option( 'wpinv_settings', $settings );
85
+        update_option('wpinv_settings', $settings);
86 86
 
87 87
     }
88
-    return apply_filters( 'wpinv_get_settings', $settings );
88
+    return apply_filters('wpinv_get_settings', $settings);
89 89
 }
90 90
 
91 91
 function wpinv_register_settings() {
92
-    if ( false == get_option( 'wpinv_settings' ) ) {
93
-        add_option( 'wpinv_settings' );
92
+    if (false == get_option('wpinv_settings')) {
93
+        add_option('wpinv_settings');
94 94
     }
95 95
     
96 96
     $register_settings = wpinv_get_registered_settings();
97 97
     
98
-    foreach ( $register_settings as $tab => $sections ) {
99
-        foreach ( $sections as $section => $settings) {
98
+    foreach ($register_settings as $tab => $sections) {
99
+        foreach ($sections as $section => $settings) {
100 100
             // Check for backwards compatibility
101
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
102
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
101
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
102
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
103 103
                 $section = 'main';
104 104
                 $settings = $sections;
105 105
             }
@@ -111,42 +111,42 @@  discard block
 block discarded – undo
111 111
                 'wpinv_settings_' . $tab . '_' . $section
112 112
             );
113 113
 
114
-            foreach ( $settings as $option ) {
114
+            foreach ($settings as $option) {
115 115
                 // For backwards compatibility
116
-                if ( empty( $option['id'] ) ) {
116
+                if (empty($option['id'])) {
117 117
                     continue;
118 118
                 }
119 119
 
120
-                $name = isset( $option['name'] ) ? $option['name'] : '';
120
+                $name = isset($option['name']) ? $option['name'] : '';
121 121
 
122 122
                 add_settings_field(
123 123
                     'wpinv_settings[' . $option['id'] . ']',
124 124
                     $name,
125
-                    function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
125
+                    function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
126 126
                     'wpinv_settings_' . $tab . '_' . $section,
127 127
                     'wpinv_settings_' . $tab . '_' . $section,
128 128
                     array(
129 129
                         'section'     => $section,
130
-                        'id'          => isset( $option['id'] )          ? $option['id']          : null,
131
-                        'desc'        => ! empty( $option['desc'] )      ? $option['desc']        : '',
132
-                        'name'        => isset( $option['name'] )        ? $option['name']        : null,
133
-                        'size'        => isset( $option['size'] )        ? $option['size']        : null,
134
-                        'options'     => isset( $option['options'] )     ? $option['options']     : '',
135
-                        'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
136
-                        'std'         => isset( $option['std'] )         ? $option['std']         : '',
137
-                        'min'         => isset( $option['min'] )         ? $option['min']         : null,
138
-                        'max'         => isset( $option['max'] )         ? $option['max']         : null,
139
-                        'step'        => isset( $option['step'] )        ? $option['step']        : null,
140
-                        'chosen'      => isset( $option['chosen'] )      ? $option['chosen']      : null,
141
-                        'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
142
-                        'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
143
-                        'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
144
-                        'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
145
-                        'onchange'    => !empty( $option['onchange'] )   ? $option['onchange']    : '',
146
-                        'custom'      => !empty( $option['custom'] )     ? $option['custom']      : '',
147
-                        'class'       =>  !empty( $option['class'] )     ? $option['class']      : '',
148
-                        'cols'        => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
149
-                        'rows'        => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
130
+                        'id'          => isset($option['id']) ? $option['id'] : null,
131
+                        'desc'        => !empty($option['desc']) ? $option['desc'] : '',
132
+                        'name'        => isset($option['name']) ? $option['name'] : null,
133
+                        'size'        => isset($option['size']) ? $option['size'] : null,
134
+                        'options'     => isset($option['options']) ? $option['options'] : '',
135
+                        'selected'    => isset($option['selected']) ? $option['selected'] : null,
136
+                        'std'         => isset($option['std']) ? $option['std'] : '',
137
+                        'min'         => isset($option['min']) ? $option['min'] : null,
138
+                        'max'         => isset($option['max']) ? $option['max'] : null,
139
+                        'step'        => isset($option['step']) ? $option['step'] : null,
140
+                        'chosen'      => isset($option['chosen']) ? $option['chosen'] : null,
141
+                        'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
142
+                        'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
143
+                        'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
144
+                        'faux'        => isset($option['faux']) ? $option['faux'] : false,
145
+                        'onchange'    => !empty($option['onchange']) ? $option['onchange'] : '',
146
+                        'custom'      => !empty($option['custom']) ? $option['custom'] : '',
147
+                        'class'       =>  !empty($option['class']) ? $option['class'] : '',
148
+                        'cols'        => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
149
+                        'rows'        => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
150 150
                     )
151 151
                 );
152 152
             }
@@ -154,21 +154,21 @@  discard block
 block discarded – undo
154 154
     }
155 155
 
156 156
     // Creates our settings in the options table
157
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
157
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
158 158
 }
159
-add_action( 'admin_init', 'wpinv_register_settings' );
159
+add_action('admin_init', 'wpinv_register_settings');
160 160
 
161 161
 function wpinv_get_registered_settings() {
162
-    $pages = wpinv_get_pages( true );
162
+    $pages = wpinv_get_pages(true);
163 163
     
164 164
     $due_payment_options       = array();
165
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
166
-    for ( $i = 1; $i <= 30; $i++ ) {
165
+    $due_payment_options[0]    = __('Now', 'invoicing');
166
+    for ($i = 1; $i <= 30; $i++) {
167 167
         $due_payment_options[$i] = $i;
168 168
     }
169 169
     
170 170
     $invoice_number_padd_options = array();
171
-    for ( $i = 0; $i <= 20; $i++ ) {
171
+    for ($i = 0; $i <= 20; $i++) {
172 172
         $invoice_number_padd_options[$i] = $i;
173 173
     }
174 174
     
@@ -177,141 +177,141 @@  discard block
 block discarded – undo
177 177
     $alert_wrapper_start = '<p style="color: #F00">';
178 178
     $alert_wrapper_close = '</p>';
179 179
     $wpinv_settings = array(
180
-        'general' => apply_filters( 'wpinv_settings_general',
180
+        'general' => apply_filters('wpinv_settings_general',
181 181
             array(
182 182
                 'main' => array(
183 183
                     'location_settings' => array(
184 184
                         'id'   => 'location_settings',
185
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
185
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
186 186
                         'desc' => '',
187 187
                         'type' => 'header',
188 188
                     ),
189 189
                     'default_country' => array(
190 190
                         'id'      => 'default_country',
191
-                        'name'    => __( 'Default Country', 'invoicing' ),
192
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
191
+                        'name'    => __('Default Country', 'invoicing'),
192
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
193 193
                         'type'    => 'select',
194 194
                         'options' => wpinv_get_country_list(),
195 195
                         'std'     => 'GB',
196 196
                         'chosen'  => true,
197
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
197
+                        'placeholder' => __('Select a country', 'invoicing'),
198 198
                     ),
199 199
                     'default_state' => array(
200 200
                         'id'      => 'default_state',
201
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
202
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
201
+                        'name'    => __('Default State / Province', 'invoicing'),
202
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
203 203
                         'type'    => 'country_states',
204
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
204
+                        'placeholder' => __('Select a state', 'invoicing'),
205 205
                     ),
206 206
                     'store_name' => array(
207 207
                         'id'   => 'store_name',
208
-                        'name' => __( 'Store Name', 'invoicing' ),
209
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
208
+                        'name' => __('Store Name', 'invoicing'),
209
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
210 210
                         'std'     => get_option('blogname'),
211 211
                         'type' => 'text',
212 212
                     ),
213 213
                     'logo' => array(
214 214
                         'id'   => 'logo',
215
-                        'name' => __( 'Logo URL', 'invoicing' ),
216
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
215
+                        'name' => __('Logo URL', 'invoicing'),
216
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
217 217
                         'type' => 'text',
218 218
                     ),
219 219
                     'store_address' => array(
220 220
                         'id'   => 'store_address',
221
-                        'name' => __( 'Store Address', 'invoicing' ),
222
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
221
+                        'name' => __('Store Address', 'invoicing'),
222
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
223 223
                         'type' => 'textarea',
224 224
                     ),
225 225
                     'page_settings' => array(
226 226
                         'id'   => 'page_settings',
227
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
227
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
228 228
                         'desc' => '',
229 229
                         'type' => 'header',
230 230
                     ),
231 231
                     'checkout_page' => array(
232 232
                         'id'          => 'checkout_page',
233
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
234
-                        'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
233
+                        'name'        => __('Checkout Page', 'invoicing'),
234
+                        'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
235 235
                         'type'        => 'select',
236 236
                         'options'     => $pages,
237 237
                         'chosen'      => true,
238
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
238
+                        'placeholder' => __('Select a page', 'invoicing'),
239 239
                     ),
240 240
                     'success_page' => array(
241 241
                         'id'          => 'success_page',
242
-                        'name'        => __( 'Success Page', 'invoicing' ),
243
-                        'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
242
+                        'name'        => __('Success Page', 'invoicing'),
243
+                        'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
244 244
                         'type'        => 'select',
245 245
                         'options'     => $pages,
246 246
                         'chosen'      => true,
247
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
247
+                        'placeholder' => __('Select a page', 'invoicing'),
248 248
                     ),
249 249
                     'failure_page' => array(
250 250
                         'id'          => 'failure_page',
251
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
252
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ),
251
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
252
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'),
253 253
                         'type'        => 'select',
254 254
                         'options'     => $pages,
255 255
                         'chosen'      => true,
256
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
256
+                        'placeholder' => __('Select a page', 'invoicing'),
257 257
                     ),
258 258
                     'invoice_history_page' => array(
259 259
                         'id'          => 'invoice_history_page',
260
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
261
-                        'desc'        => __( 'This page shows a invoice history for the current user', 'invoicing' ),
260
+                        'name'        => __('Invoice History Page', 'invoicing'),
261
+                        'desc'        => __('This page shows a invoice history for the current user', 'invoicing'),
262 262
                         'type'        => 'select',
263 263
                         'options'     => $pages,
264 264
                         'chosen'      => true,
265
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
265
+                        'placeholder' => __('Select a page', 'invoicing'),
266 266
                     )
267 267
                 ),
268 268
                 'currency_section' => array(
269 269
                     'currency_settings' => array(
270 270
                         'id'   => 'currency_settings',
271
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
271
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
272 272
                         'desc' => '',
273 273
                         'type' => 'header',
274 274
                     ),
275 275
                     'currency' => array(
276 276
                         'id'      => 'currency',
277
-                        'name'    => __( 'Currency', 'invoicing' ),
278
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
277
+                        'name'    => __('Currency', 'invoicing'),
278
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
279 279
                         'type'    => 'select',
280 280
                         'options' => wpinv_get_currencies(),
281 281
                         'chosen'  => true,
282 282
                     ),
283 283
                     'currency_position' => array(
284 284
                         'id'      => 'currency_position',
285
-                        'name'    => __( 'Currency Position', 'invoicing' ),
286
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
285
+                        'name'    => __('Currency Position', 'invoicing'),
286
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
287 287
                         'type'    => 'select',
288 288
                         'options'  => array(
289
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
290
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
291
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
292
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
289
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
290
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
291
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
292
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
293 293
                         )
294 294
                     ),
295 295
                     'thousands_separator' => array(
296 296
                         'id'   => 'thousands_separator',
297
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
298
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
297
+                        'name' => __('Thousands Separator', 'invoicing'),
298
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
299 299
                         'type' => 'text',
300 300
                         'size' => 'small',
301 301
                         'std'  => ',',
302 302
                     ),
303 303
                     'decimal_separator' => array(
304 304
                         'id'   => 'decimal_separator',
305
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
306
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
305
+                        'name' => __('Decimal Separator', 'invoicing'),
306
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
307 307
                         'type' => 'text',
308 308
                         'size' => 'small',
309 309
                         'std'  => '.',
310 310
                     ),
311 311
                     'decimals' => array(
312 312
                         'id'   => 'decimals',
313
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
314
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
313
+                        'name' => __('Number of Decimals', 'invoicing'),
314
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
315 315
                         'type' => 'number',
316 316
                         'size' => 'small',
317 317
                         'std'  => '2',
@@ -323,29 +323,29 @@  discard block
 block discarded – undo
323 323
                 'labels' => array(
324 324
                     'labels' => array(
325 325
                         'id'   => 'labels_settings',
326
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
326
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
327 327
                         'desc' => '',
328 328
                         'type' => 'header',
329 329
                     ),
330 330
                     'vat_name' => array(
331 331
                         'id' => 'vat_name',
332
-                        'name' => __( 'VAT Name', 'invoicing' ),
333
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
332
+                        'name' => __('VAT Name', 'invoicing'),
333
+                        'desc' => __('Enter the VAT name', 'invoicing'),
334 334
                         'type' => 'text',
335 335
                         'size' => 'regular',
336 336
                         'std' => 'VAT'
337 337
                     ),
338 338
                     'vat_invoice_notice_label' => array(
339 339
                         'id' => 'vat_invoice_notice_label',
340
-                        'name' => __( 'Invoice notice label', 'invoicing' ),
341
-                        'desc' => __( 'Use this to add a invoice notice section (label) to your invoices', 'invoicing' ),
340
+                        'name' => __('Invoice notice label', 'invoicing'),
341
+                        'desc' => __('Use this to add a invoice notice section (label) to your invoices', 'invoicing'),
342 342
                         'type' => 'text',
343 343
                         'size' => 'regular',
344 344
                     ),
345 345
                     'vat_invoice_notice' => array(
346 346
                         'id' => 'vat_invoice_notice',
347
-                        'name' => __( 'Invoice notice', 'invoicing' ),
348
-                        'desc' =>   __( 'Use this to add a invoice notice section (description) to your invoices', 'invoicing' ),
347
+                        'name' => __('Invoice notice', 'invoicing'),
348
+                        'desc' =>   __('Use this to add a invoice notice section (description) to your invoices', 'invoicing'),
349 349
                         'type' => 'text',
350 350
                         'size' => 'regular',
351 351
                     )
@@ -357,22 +357,22 @@  discard block
 block discarded – undo
357 357
                 'main' => array(
358 358
                     'gateway_settings' => array(
359 359
                         'id'   => 'api_header',
360
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
360
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
361 361
                         'desc' => '',
362 362
                         'type' => 'header',
363 363
                     ),
364 364
                     'gateways' => array(
365 365
                         'id'      => 'gateways',
366
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
367
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
366
+                        'name'    => __('Payment Gateways', 'invoicing'),
367
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
368 368
                         'type'    => 'gateways',
369 369
                         'std'     => array('manual'=>1),
370 370
                         'options' => wpinv_get_payment_gateways(),
371 371
                     ),
372 372
                     'default_gateway' => array(
373 373
                         'id'      => 'default_gateway',
374
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
375
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
374
+                        'name'    => __('Default Gateway', 'invoicing'),
375
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
376 376
                         'type'    => 'gateway_select',
377 377
                         'std'     => 'manual',
378 378
                         'options' => wpinv_get_payment_gateways(),
@@ -386,19 +386,19 @@  discard block
 block discarded – undo
386 386
                 'main' => array(
387 387
                     'tax_settings' => array(
388 388
                         'id'   => 'tax_settings',
389
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
389
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
390 390
                         'type' => 'header',
391 391
                     ),
392 392
                     'enable_taxes' => array(
393 393
                         'id'   => 'enable_taxes',
394
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
395
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
394
+                        'name' => __('Enable Taxes', 'invoicing'),
395
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
396 396
                         'type' => 'checkbox',
397 397
                     ),
398 398
                     'tax_rate' => array(
399 399
                         'id'   => 'tax_rate',
400
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
401
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
400
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
401
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
402 402
                         'type' => 'number',
403 403
                         'size' => 'small',
404 404
                         'min'  => '0',
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
                 'rates' => array(
411 411
                     'tax_rates' => array(
412 412
                         'id'   => 'tax_rates',
413
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
414
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
413
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
414
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
415 415
                         'type' => 'tax_rates',
416 416
                     ),
417 417
                 )
@@ -423,62 +423,62 @@  discard block
 block discarded – undo
423 423
                 'main' => array(
424 424
                     'email_settings_header' => array(
425 425
                         'id'   => 'email_settings_header',
426
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
426
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
427 427
                         'type' => 'header',
428 428
                     ),
429 429
                     'email_from_name' => array(
430 430
                         'id'   => 'email_from_name',
431
-                        'name' => __( 'From Name', 'invoicing' ),
432
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
433
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
431
+                        'name' => __('From Name', 'invoicing'),
432
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
433
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
434 434
                         'type' => 'text',
435 435
                     ),
436 436
                     'email_from' => array(
437 437
                         'id'   => 'email_from',
438
-                        'name' => __( 'From Email', 'invoicing' ),
439
-                        'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
440
-                        'std' => get_option( 'admin_email' ),
438
+                        'name' => __('From Email', 'invoicing'),
439
+                        'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
440
+                        'std' => get_option('admin_email'),
441 441
                         'type' => 'text',
442 442
                     ),
443 443
                     'overdue_settings_header' => array(
444 444
                         'id'   => 'overdue_settings_header',
445
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
445
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
446 446
                         'type' => 'header',
447 447
                     ),
448 448
                     'overdue_active' => array(
449 449
                         'id'   => 'overdue_active',
450
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
451
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
450
+                        'name' => __('Enable Due Date', 'invoicing'),
451
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
452 452
                         'type' => 'checkbox',
453 453
                         'std'  => false,
454 454
                     ),
455 455
                     'overdue_days' => array(
456 456
                         'id'          => 'overdue_days',
457
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
458
-                        'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
457
+                        'name'        => __('Default Due Date', 'invoicing'),
458
+                        'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
459 459
                         'type'        => 'select',
460 460
                         'options'     => $due_payment_options,
461 461
                         'chosen'      => true,
462 462
                         'std'         => 0,
463
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
463
+                        'placeholder' => __('Select a page', 'invoicing'),
464 464
                     ),
465 465
                     'email_template_header' => array(
466 466
                         'id'   => 'email_template_header',
467
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
467
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
468 468
                         'type' => 'header',
469 469
                     ),
470 470
                     'email_header_image' => array(
471 471
                         'id'   => 'email_header_image',
472
-                        'name' => __( 'Header Image', 'invoicing' ),
473
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
472
+                        'name' => __('Header Image', 'invoicing'),
473
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
474 474
                         'std' => '',
475 475
                         'type' => 'text',
476 476
                     ),
477 477
                     'email_footer_text' => array(
478 478
                         'id'   => 'email_footer_text',
479
-                        'name' => __( 'Footer Text', 'invoicing' ),
480
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
481
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
479
+                        'name' => __('Footer Text', 'invoicing'),
480
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
481
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
482 482
                         'type' => 'textarea',
483 483
                         'class' => 'regular-text',
484 484
                         'rows' => 2,
@@ -486,29 +486,29 @@  discard block
 block discarded – undo
486 486
                     ),
487 487
                     'email_base_color' => array(
488 488
                         'id'   => 'email_base_color',
489
-                        'name' => __( 'Base Color', 'invoicing' ),
490
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
489
+                        'name' => __('Base Color', 'invoicing'),
490
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
491 491
                         'std' => '#557da2',
492 492
                         'type' => 'color',
493 493
                     ),
494 494
                     'email_background_color' => array(
495 495
                         'id'   => 'email_background_color',
496
-                        'name' => __( 'Background Color', 'invoicing' ),
497
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
496
+                        'name' => __('Background Color', 'invoicing'),
497
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
498 498
                         'std' => '#f5f5f5',
499 499
                         'type' => 'color',
500 500
                     ),
501 501
                     'email_body_background_color' => array(
502 502
                         'id'   => 'email_body_background_color',
503
-                        'name' => __( 'Body Background Color', 'invoicing' ),
504
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
503
+                        'name' => __('Body Background Color', 'invoicing'),
504
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
505 505
                         'std' => '#fdfdfd',
506 506
                         'type' => 'color',
507 507
                     ),
508 508
                     'email_text_color' => array(
509 509
                         'id'   => 'email_text_color',
510
-                        'name' => __( 'Body Text Color', 'invoicing' ),
511
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
510
+                        'name' => __('Body Text Color', 'invoicing'),
511
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
512 512
                         'std' => '#505050',
513 513
                         'type' => 'color',
514 514
                     ),
@@ -527,25 +527,25 @@  discard block
 block discarded – undo
527 527
                 'main' => array(
528 528
                     'fields_settings' => array(
529 529
                         'id'   => 'fields_settings',
530
-                        'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>',
530
+                        'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>',
531 531
                         'type' => 'header',
532 532
                     ),
533 533
                     'phone_mandatory' => array(
534 534
                         'id'   => 'phone_mandatory',
535
-                        'name' => __( 'Phone No. Mandatory?', 'invoicing' ),
536
-                        'desc' => __( 'Tick this to make phone number mandatory in invoice address fields.', 'invoicing' ),
535
+                        'name' => __('Phone No. Mandatory?', 'invoicing'),
536
+                        'desc' => __('Tick this to make phone number mandatory in invoice address fields.', 'invoicing'),
537 537
                         'type' => 'checkbox',
538 538
                         'std'  => true,
539 539
                     ),
540 540
                     'invoice_number_format_settings' => array(
541 541
                         'id'   => 'invoice_number_format_settings',
542
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
542
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
543 543
                         'type' => 'header',
544 544
                     ),
545 545
                     'invoice_number_padd' => array(
546 546
                         'id'      => 'invoice_number_padd',
547
-                        'name'    => __( 'Minimum digits', 'invoicing' ),
548
-                        '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' ),
547
+                        'name'    => __('Minimum digits', 'invoicing'),
548
+                        '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'),
549 549
                         'type'    => 'select',
550 550
                         'options' => $invoice_number_padd_options,
551 551
                         'std'     => 5,
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
                     ),
554 554
                     'invoice_number_prefix' => array(
555 555
                         'id' => 'invoice_number_prefix',
556
-                        'name' => __( 'Invoice Number prefix', 'invoicing' ),
557
-                        'desc' => __( 'A prefix to prepend to all invoice numbers. Ex: WPINV-', 'invoicing' ),
556
+                        'name' => __('Invoice Number prefix', 'invoicing'),
557
+                        'desc' => __('A prefix to prepend to all invoice numbers. Ex: WPINV-', 'invoicing'),
558 558
                         'type' => 'text',
559 559
                         'size' => 'regular',
560 560
                         'std' => 'WPINV-',
@@ -562,25 +562,25 @@  discard block
 block discarded – undo
562 562
                     ),
563 563
                     'invoice_number_postfix' => array(
564 564
                         'id' => 'invoice_number_postfix',
565
-                        'name' => __( 'Invoice Number postfix', 'invoicing' ),
566
-                        'desc' => __( 'A postfix to append to all invoice numbers.', 'invoicing' ),
565
+                        'name' => __('Invoice Number postfix', 'invoicing'),
566
+                        'desc' => __('A postfix to append to all invoice numbers.', 'invoicing'),
567 567
                         'type' => 'text',
568 568
                         'size' => 'regular',
569 569
                         'std' => ''
570 570
                     ),
571 571
                     'guest_checkout_settings' => array(
572 572
                         'id'   => 'guest_checkout_settings',
573
-                        'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>',
573
+                        'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>',
574 574
                         'type' => 'header',
575 575
                     ),
576 576
                     'guest_checkout' => array(
577 577
                         'type'    => 'radio',
578 578
                         'id'      => 'guest_checkout',
579
-                        'name'    => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ),
580
-                        'desc'    => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link that sent to them via for pay for invoice.', 'invoicing' ),
579
+                        'name'    => __('Pay via Invoice Link for non logged in user', 'invoicing'),
580
+                        'desc'    => __('Select how invoice should be paid when non logged in user clicks on the invoice link that sent to them via for pay for invoice.', 'invoicing'),
581 581
                         'options' => array(
582
-                            0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ),
583
-                            1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ),
582
+                            0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'),
583
+                            1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'),
584 584
                         ),
585 585
                         'std'     => 0,
586 586
                     ),
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
                 'main' => array(
594 594
                     'tool_settings' => array(
595 595
                         'id'   => 'tool_settings',
596
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
597
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
596
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
597
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
598 598
                         'type' => 'tools',
599 599
                     ),
600 600
                 ),
@@ -602,135 +602,135 @@  discard block
 block discarded – undo
602 602
         )
603 603
     );
604 604
 
605
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
605
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
606 606
 }
607 607
 
608
-function wpinv_settings_sanitize( $input = array() ) {
608
+function wpinv_settings_sanitize($input = array()) {
609 609
     global $wpinv_options;
610 610
 
611
-    if ( empty( $_POST['_wp_http_referer'] ) ) {
611
+    if (empty($_POST['_wp_http_referer'])) {
612 612
         return $input;
613 613
     }
614 614
 
615
-    parse_str( $_POST['_wp_http_referer'], $referrer );
615
+    parse_str($_POST['_wp_http_referer'], $referrer);
616 616
 
617 617
     $settings = wpinv_get_registered_settings();
618
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
619
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
618
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
619
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
620 620
 
621 621
     $input = $input ? $input : array();
622
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
623
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
622
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
623
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
624 624
 
625 625
     // Loop through each setting being saved and pass it through a sanitization filter
626
-    foreach ( $input as $key => $value ) {
626
+    foreach ($input as $key => $value) {
627 627
         // Get the setting type (checkbox, select, etc)
628
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
628
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
629 629
 
630
-        if ( $type ) {
630
+        if ($type) {
631 631
             // Field type specific filter
632
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
632
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
633 633
         }
634 634
 
635 635
         // General filter
636
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
636
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
637 637
     }
638 638
 
639 639
     // Loop through the whitelist and unset any that are empty for the tab being saved
640
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
641
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
640
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
641
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
642 642
 
643
-    $found_settings = array_merge( $main_settings, $section_settings );
643
+    $found_settings = array_merge($main_settings, $section_settings);
644 644
 
645
-    if ( ! empty( $found_settings ) ) {
646
-        foreach ( $found_settings as $key => $value ) {
645
+    if (!empty($found_settings)) {
646
+        foreach ($found_settings as $key => $value) {
647 647
 
648 648
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
649
-            if ( is_numeric( $key ) ) {
649
+            if (is_numeric($key)) {
650 650
                 $key = $value['id'];
651 651
             }
652 652
 
653
-            if ( empty( $input[ $key ] ) ) {
654
-                unset( $wpinv_options[ $key ] );
653
+            if (empty($input[$key])) {
654
+                unset($wpinv_options[$key]);
655 655
             }
656 656
         }
657 657
     }
658 658
 
659 659
     // Merge our new settings with the existing
660
-    $output = array_merge( $wpinv_options, $input );
660
+    $output = array_merge($wpinv_options, $input);
661 661
 
662
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
662
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
663 663
 
664 664
     return $output;
665 665
 }
666 666
 
667
-function wpinv_settings_sanitize_misc_accounting( $input ) {
667
+function wpinv_settings_sanitize_misc_accounting($input) {
668 668
     global $wpinv_options, $wpi_session;
669 669
 
670
-    if ( !current_user_can( 'manage_options' ) ) {
670
+    if (!current_user_can('manage_options')) {
671 671
         return $input;
672 672
     }
673 673
 
674
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
674
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
675 675
         // Shows an admin notice about upgrading previous order numbers
676
-        $wpi_session->set( 'upgrade_sequential', '1' );
676
+        $wpi_session->set('upgrade_sequential', '1');
677 677
     }
678 678
 
679 679
     return $input;
680 680
 }
681
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
681
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
682 682
 
683
-function wpinv_settings_sanitize_tax_rates( $input ) {
684
-    if( !current_user_can( 'manage_options' ) ) {
683
+function wpinv_settings_sanitize_tax_rates($input) {
684
+    if (!current_user_can('manage_options')) {
685 685
         return $input;
686 686
     }
687 687
 
688
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
688
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
689 689
 
690 690
     $tax_rates = array();
691 691
 
692
-    if ( !empty( $new_rates ) ) {
693
-        foreach ( $new_rates as $rate ) {
694
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
692
+    if (!empty($new_rates)) {
693
+        foreach ($new_rates as $rate) {
694
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
695 695
                 continue;
696 696
             }
697 697
             
698
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
698
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
699 699
             
700 700
             $tax_rates[] = $rate;
701 701
         }
702 702
     }
703 703
 
704
-    update_option( 'wpinv_tax_rates', $tax_rates );
704
+    update_option('wpinv_tax_rates', $tax_rates);
705 705
 
706 706
     return $input;
707 707
 }
708
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
708
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
709 709
 
710
-function wpinv_sanitize_text_field( $input ) {
711
-    return trim( $input );
710
+function wpinv_sanitize_text_field($input) {
711
+    return trim($input);
712 712
 }
713
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
713
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
714 714
 
715 715
 function wpinv_get_settings_tabs() {
716 716
     $tabs             = array();
717
-    $tabs['general']  = __( 'General', 'invoicing' );
718
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
719
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
720
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
721
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
722
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
723
-
724
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
717
+    $tabs['general']  = __('General', 'invoicing');
718
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
719
+    $tabs['taxes']    = __('Taxes', 'invoicing');
720
+    $tabs['emails']   = __('Emails', 'invoicing');
721
+    $tabs['misc']     = __('Misc', 'invoicing');
722
+    $tabs['tools']    = __('Tools', 'invoicing');
723
+
724
+    return apply_filters('wpinv_settings_tabs', $tabs);
725 725
 }
726 726
 
727
-function wpinv_get_settings_tab_sections( $tab = false ) {
727
+function wpinv_get_settings_tab_sections($tab = false) {
728 728
     $tabs     = false;
729 729
     $sections = wpinv_get_registered_settings_sections();
730 730
 
731
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
732
-        $tabs = $sections[ $tab ];
733
-    } else if ( $tab ) {
731
+    if ($tab && !empty($sections[$tab])) {
732
+        $tabs = $sections[$tab];
733
+    } else if ($tab) {
734 734
         $tabs = false;
735 735
     }
736 736
 
@@ -740,135 +740,135 @@  discard block
 block discarded – undo
740 740
 function wpinv_get_registered_settings_sections() {
741 741
     static $sections = false;
742 742
 
743
-    if ( false !== $sections ) {
743
+    if (false !== $sections) {
744 744
         return $sections;
745 745
     }
746 746
 
747 747
     $sections = array(
748
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
749
-            'main' => __( 'General Settings', 'invoicing' ),
750
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
751
-            'labels' => __( 'Label Texts', 'invoicing' ),
752
-        ) ),
753
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
754
-            'main' => __( 'Gateway Settings', 'invoicing' ),
755
-        ) ),
756
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
757
-            'main' => __( 'Tax Settings', 'invoicing' ),
758
-            'rates' => __( 'Tax Rates', 'invoicing' ),
759
-        ) ),
760
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
761
-            'main' => __( 'Email Settings', 'invoicing' ),
762
-        ) ),
763
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
764
-            'main' => __( 'Misc Settings', 'invoicing' ),
765
-        ) ),
766
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
767
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
768
-        ) ),
748
+        'general' => apply_filters('wpinv_settings_sections_general', array(
749
+            'main' => __('General Settings', 'invoicing'),
750
+            'currency_section' => __('Currency Settings', 'invoicing'),
751
+            'labels' => __('Label Texts', 'invoicing'),
752
+        )),
753
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
754
+            'main' => __('Gateway Settings', 'invoicing'),
755
+        )),
756
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
757
+            'main' => __('Tax Settings', 'invoicing'),
758
+            'rates' => __('Tax Rates', 'invoicing'),
759
+        )),
760
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
761
+            'main' => __('Email Settings', 'invoicing'),
762
+        )),
763
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
764
+            'main' => __('Misc Settings', 'invoicing'),
765
+        )),
766
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
767
+            'main' => __('Diagnostic Tools', 'invoicing'),
768
+        )),
769 769
     );
770 770
 
771
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
771
+    $sections = apply_filters('wpinv_settings_sections', $sections);
772 772
 
773 773
     return $sections;
774 774
 }
775 775
 
776
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
776
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
777 777
 	$pages_options = array();
778 778
 
779
-	if( $default_label !== NULL && $default_label !== false ) {
780
-		$pages_options = array( '' => $default_label ); // Blank option
779
+	if ($default_label !== NULL && $default_label !== false) {
780
+		$pages_options = array('' => $default_label); // Blank option
781 781
 	}
782 782
 
783 783
 	$pages = get_pages();
784
-	if ( $pages ) {
785
-		foreach ( $pages as $page ) {
784
+	if ($pages) {
785
+		foreach ($pages as $page) {
786 786
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
787
-            $pages_options[ $page->ID ] = $title;
787
+            $pages_options[$page->ID] = $title;
788 788
 		}
789 789
 	}
790 790
 
791 791
 	return $pages_options;
792 792
 }
793 793
 
794
-function wpinv_header_callback( $args ) {
795
-	if ( !empty( $args['desc'] ) ) {
794
+function wpinv_header_callback($args) {
795
+	if (!empty($args['desc'])) {
796 796
         echo $args['desc'];
797 797
     }
798 798
 }
799 799
 
800
-function wpinv_hidden_callback( $args ) {
800
+function wpinv_hidden_callback($args) {
801 801
 	global $wpinv_options;
802 802
 
803
-	if ( isset( $args['set_value'] ) ) {
803
+	if (isset($args['set_value'])) {
804 804
 		$value = $args['set_value'];
805
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
806
-		$value = $wpinv_options[ $args['id'] ];
805
+	} elseif (isset($wpinv_options[$args['id']])) {
806
+		$value = $wpinv_options[$args['id']];
807 807
 	} else {
808
-		$value = isset( $args['std'] ) ? $args['std'] : '';
808
+		$value = isset($args['std']) ? $args['std'] : '';
809 809
 	}
810 810
 
811
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
811
+	if (isset($args['faux']) && true === $args['faux']) {
812 812
 		$args['readonly'] = true;
813
-		$value = isset( $args['std'] ) ? $args['std'] : '';
813
+		$value = isset($args['std']) ? $args['std'] : '';
814 814
 		$name  = '';
815 815
 	} else {
816
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
816
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
817 817
 	}
818 818
 
819
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
819
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
820 820
     
821 821
 	echo $html;
822 822
 }
823 823
 
824
-function wpinv_checkbox_callback( $args ) {
824
+function wpinv_checkbox_callback($args) {
825 825
 	global $wpinv_options;
826 826
     
827
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
827
+    $sanitize_id = wpinv_sanitize_key($args['id']);
828 828
 
829
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
829
+	if (isset($args['faux']) && true === $args['faux']) {
830 830
 		$name = '';
831 831
 	} else {
832 832
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
833 833
 	}
834 834
 
835
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
835
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
836 836
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
837
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
837
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
838 838
 
839 839
 	echo $html;
840 840
 }
841 841
 
842
-function wpinv_multicheck_callback( $args ) {
842
+function wpinv_multicheck_callback($args) {
843 843
 	global $wpinv_options;
844 844
 	
845
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
845
+	$sanitize_id = wpinv_sanitize_key($args['id']);
846 846
 	
847
-	if ( ! empty( $args['options'] ) ) {
848
-		foreach( $args['options'] as $key => $option ):
849
-			$sanitize_key = wpinv_sanitize_key( $key );
850
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
847
+	if (!empty($args['options'])) {
848
+		foreach ($args['options'] as $key => $option):
849
+			$sanitize_key = wpinv_sanitize_key($key);
850
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
851 851
 				$enabled = $sanitize_key;
852 852
 			} else { 
853 853
 				$enabled = NULL; 
854 854
 			}
855
-			echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
856
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
855
+			echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
856
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>';
857 857
 		endforeach;
858 858
 		echo '<p class="description">' . $args['desc'] . '</p>';
859 859
 	}
860 860
 }
861 861
 
862
-function wpinv_payment_icons_callback( $args ) {
862
+function wpinv_payment_icons_callback($args) {
863 863
 	global $wpinv_options;
864 864
     
865
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
865
+    $sanitize_id = wpinv_sanitize_key($args['id']);
866 866
 
867
-	if ( ! empty( $args['options'] ) ) {
868
-		foreach( $args['options'] as $key => $option ) {
869
-            $sanitize_key = wpinv_sanitize_key( $key );
867
+	if (!empty($args['options'])) {
868
+		foreach ($args['options'] as $key => $option) {
869
+            $sanitize_key = wpinv_sanitize_key($key);
870 870
             
871
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
871
+			if (isset($wpinv_options[$args['id']][$key])) {
872 872
 				$enabled = $option;
873 873
 			} else {
874 874
 				$enabled = NULL;
@@ -876,194 +876,194 @@  discard block
 block discarded – undo
876 876
 
877 877
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
878 878
 
879
-				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;';
879
+				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;';
880 880
 
881
-				if ( wpinv_string_is_image_url( $key ) ) {
882
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
881
+				if (wpinv_string_is_image_url($key)) {
882
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
883 883
 				} else {
884
-					$card = strtolower( str_replace( ' ', '', $option ) );
884
+					$card = strtolower(str_replace(' ', '', $option));
885 885
 
886
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
887
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
886
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
887
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
888 888
 					} else {
889
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
889
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
890 890
 						$content_dir = WP_CONTENT_DIR;
891 891
 
892
-						if ( function_exists( 'wp_normalize_path' ) ) {
892
+						if (function_exists('wp_normalize_path')) {
893 893
 							// Replaces backslashes with forward slashes for Windows systems
894
-							$image = wp_normalize_path( $image );
895
-							$content_dir = wp_normalize_path( $content_dir );
894
+							$image = wp_normalize_path($image);
895
+							$content_dir = wp_normalize_path($content_dir);
896 896
 						}
897 897
 
898
-						$image = str_replace( $content_dir, content_url(), $image );
898
+						$image = str_replace($content_dir, content_url(), $image);
899 899
 					}
900 900
 
901
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
901
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
902 902
 				}
903 903
 			echo $option . '</label>';
904 904
 		}
905
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
905
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
906 906
 	}
907 907
 }
908 908
 
909
-function wpinv_radio_callback( $args ) {
909
+function wpinv_radio_callback($args) {
910 910
 	global $wpinv_options;
911 911
     
912
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
912
+    $sanitize_id = wpinv_sanitize_key($args['id']);
913 913
     
914
-    foreach ( $args['options'] as $key => $option ) :
915
-		$sanitize_key = wpinv_sanitize_key( $key );
914
+    foreach ($args['options'] as $key => $option) :
915
+		$sanitize_key = wpinv_sanitize_key($key);
916 916
         
917 917
         $checked = false;
918 918
 
919
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
919
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
920 920
 			$checked = true;
921
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
921
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
922 922
 			$checked = true;
923 923
 
924 924
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
925
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
925
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
926 926
 	endforeach;
927 927
 
928
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
928
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
929 929
 }
930 930
 
931
-function wpinv_gateways_callback( $args ) {
931
+function wpinv_gateways_callback($args) {
932 932
 	global $wpinv_options;
933 933
     
934
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
934
+    $sanitize_id = wpinv_sanitize_key($args['id']);
935 935
 
936
-	foreach ( $args['options'] as $key => $option ) :
937
-		$sanitize_key = wpinv_sanitize_key( $key );
936
+	foreach ($args['options'] as $key => $option) :
937
+		$sanitize_key = wpinv_sanitize_key($key);
938 938
         
939
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
939
+        if (isset($wpinv_options['gateways'][$key]))
940 940
 			$enabled = '1';
941 941
 		else
942 942
 			$enabled = null;
943 943
 
944
-		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;';
945
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
944
+		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;';
945
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
946 946
 	endforeach;
947 947
 }
948 948
 
949 949
 function wpinv_gateway_select_callback($args) {
950 950
 	global $wpinv_options;
951 951
     
952
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
952
+    $sanitize_id = wpinv_sanitize_key($args['id']);
953 953
 
954 954
 	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
955 955
 
956
-	foreach ( $args['options'] as $key => $option ) :
957
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
958
-            $selected = selected( $key, $args['selected'], false );
956
+	foreach ($args['options'] as $key => $option) :
957
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
958
+            $selected = selected($key, $args['selected'], false);
959 959
         } else {
960
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
960
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
961 961
         }
962
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
962
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
963 963
 	endforeach;
964 964
 
965 965
 	echo '</select>';
966
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
966
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
967 967
 }
968 968
 
969
-function wpinv_text_callback( $args ) {
969
+function wpinv_text_callback($args) {
970 970
 	global $wpinv_options;
971 971
     
972
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
972
+    $sanitize_id = wpinv_sanitize_key($args['id']);
973 973
 
974
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
975
-		$value = $wpinv_options[ $args['id'] ];
974
+	if (isset($wpinv_options[$args['id']])) {
975
+		$value = $wpinv_options[$args['id']];
976 976
 	} else {
977
-		$value = isset( $args['std'] ) ? $args['std'] : '';
977
+		$value = isset($args['std']) ? $args['std'] : '';
978 978
 	}
979 979
 
980
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
980
+	if (isset($args['faux']) && true === $args['faux']) {
981 981
 		$args['readonly'] = true;
982
-		$value = isset( $args['std'] ) ? $args['std'] : '';
982
+		$value = isset($args['std']) ? $args['std'] : '';
983 983
 		$name  = '';
984 984
 	} else {
985
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
985
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
986 986
 	}
987 987
 
988 988
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
989
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
990
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
991
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
989
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
990
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
991
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
992 992
 
993 993
 	echo $html;
994 994
 }
995 995
 
996
-function wpinv_number_callback( $args ) {
996
+function wpinv_number_callback($args) {
997 997
 	global $wpinv_options;
998 998
     
999
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
999
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1000 1000
 
1001
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1002
-		$value = $wpinv_options[ $args['id'] ];
1001
+	if (isset($wpinv_options[$args['id']])) {
1002
+		$value = $wpinv_options[$args['id']];
1003 1003
 	} else {
1004
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1004
+		$value = isset($args['std']) ? $args['std'] : '';
1005 1005
 	}
1006 1006
 
1007
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1007
+	if (isset($args['faux']) && true === $args['faux']) {
1008 1008
 		$args['readonly'] = true;
1009
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1009
+		$value = isset($args['std']) ? $args['std'] : '';
1010 1010
 		$name  = '';
1011 1011
 	} else {
1012
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1012
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1013 1013
 	}
1014 1014
 
1015
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1016
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1017
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1015
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1016
+	$min  = isset($args['min']) ? $args['min'] : 0;
1017
+	$step = isset($args['step']) ? $args['step'] : 1;
1018 1018
 
1019
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1020
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1021
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1019
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1020
+	$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>';
1021
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1022 1022
 
1023 1023
 	echo $html;
1024 1024
 }
1025 1025
 
1026
-function wpinv_textarea_callback( $args ) {
1026
+function wpinv_textarea_callback($args) {
1027 1027
 	global $wpinv_options;
1028 1028
     
1029
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1029
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1030 1030
 
1031
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1032
-		$value = $wpinv_options[ $args['id'] ];
1031
+	if (isset($wpinv_options[$args['id']])) {
1032
+		$value = $wpinv_options[$args['id']];
1033 1033
 	} else {
1034
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1034
+		$value = isset($args['std']) ? $args['std'] : '';
1035 1035
 	}
1036 1036
     
1037
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1038
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1037
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1038
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1039 1039
 
1040
-	$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>';
1041
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1040
+	$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>';
1041
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1042 1042
 
1043 1043
 	echo $html;
1044 1044
 }
1045 1045
 
1046
-function wpinv_password_callback( $args ) {
1046
+function wpinv_password_callback($args) {
1047 1047
 	global $wpinv_options;
1048 1048
     
1049
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1049
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1050 1050
 
1051
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1052
-		$value = $wpinv_options[ $args['id'] ];
1051
+	if (isset($wpinv_options[$args['id']])) {
1052
+		$value = $wpinv_options[$args['id']];
1053 1053
 	} else {
1054
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1054
+		$value = isset($args['std']) ? $args['std'] : '';
1055 1055
 	}
1056 1056
 
1057
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1058
-	$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 ) . '"/>';
1059
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1057
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1058
+	$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) . '"/>';
1059
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1060 1060
 
1061 1061
 	echo $html;
1062 1062
 }
1063 1063
 
1064 1064
 function wpinv_missing_callback($args) {
1065 1065
 	printf(
1066
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1066
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1067 1067
 		'<strong>' . $args['id'] . '</strong>'
1068 1068
 	);
1069 1069
 }
@@ -1071,137 +1071,137 @@  discard block
 block discarded – undo
1071 1071
 function wpinv_select_callback($args) {
1072 1072
 	global $wpinv_options;
1073 1073
     
1074
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1074
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1075 1075
 
1076
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1077
-		$value = $wpinv_options[ $args['id'] ];
1076
+	if (isset($wpinv_options[$args['id']])) {
1077
+		$value = $wpinv_options[$args['id']];
1078 1078
 	} else {
1079
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1079
+		$value = isset($args['std']) ? $args['std'] : '';
1080 1080
 	}
1081 1081
     
1082
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1082
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1083 1083
         $value = $args['selected'];
1084 1084
     }
1085 1085
 
1086
-	if ( isset( $args['placeholder'] ) ) {
1086
+	if (isset($args['placeholder'])) {
1087 1087
 		$placeholder = $args['placeholder'];
1088 1088
 	} else {
1089 1089
 		$placeholder = '';
1090 1090
 	}
1091 1091
 
1092
-	if ( isset( $args['chosen'] ) ) {
1092
+	if (isset($args['chosen'])) {
1093 1093
 		$chosen = 'class="wpinv-chosen"';
1094 1094
 	} else {
1095 1095
 		$chosen = '';
1096 1096
 	}
1097 1097
     
1098
-    if( !empty( $args['onchange'] ) ) {
1099
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1098
+    if (!empty($args['onchange'])) {
1099
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1100 1100
     } else {
1101 1101
         $onchange = '';
1102 1102
     }
1103 1103
 
1104
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1104
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1105 1105
 
1106
-	foreach ( $args['options'] as $option => $name ) {
1107
-		$selected = selected( $option, $value, false );
1108
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1106
+	foreach ($args['options'] as $option => $name) {
1107
+		$selected = selected($option, $value, false);
1108
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1109 1109
 	}
1110 1110
 
1111 1111
 	$html .= '</select>';
1112
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1112
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1113 1113
 
1114 1114
 	echo $html;
1115 1115
 }
1116 1116
 
1117
-function wpinv_color_select_callback( $args ) {
1117
+function wpinv_color_select_callback($args) {
1118 1118
 	global $wpinv_options;
1119 1119
     
1120
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1120
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1121 1121
 
1122
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1123
-		$value = $wpinv_options[ $args['id'] ];
1122
+	if (isset($wpinv_options[$args['id']])) {
1123
+		$value = $wpinv_options[$args['id']];
1124 1124
 	} else {
1125
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1125
+		$value = isset($args['std']) ? $args['std'] : '';
1126 1126
 	}
1127 1127
 
1128
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1128
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1129 1129
 
1130
-	foreach ( $args['options'] as $option => $color ) {
1131
-		$selected = selected( $option, $value, false );
1132
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1130
+	foreach ($args['options'] as $option => $color) {
1131
+		$selected = selected($option, $value, false);
1132
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1133 1133
 	}
1134 1134
 
1135 1135
 	$html .= '</select>';
1136
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1136
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1137 1137
 
1138 1138
 	echo $html;
1139 1139
 }
1140 1140
 
1141
-function wpinv_rich_editor_callback( $args ) {
1141
+function wpinv_rich_editor_callback($args) {
1142 1142
 	global $wpinv_options, $wp_version;
1143 1143
     
1144
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1144
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1145 1145
 
1146
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1147
-		$value = $wpinv_options[ $args['id'] ];
1146
+	if (isset($wpinv_options[$args['id']])) {
1147
+		$value = $wpinv_options[$args['id']];
1148 1148
 
1149
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1150
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1149
+		if (empty($args['allow_blank']) && empty($value)) {
1150
+			$value = isset($args['std']) ? $args['std'] : '';
1151 1151
 		}
1152 1152
 	} else {
1153
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1153
+		$value = isset($args['std']) ? $args['std'] : '';
1154 1154
 	}
1155 1155
 
1156
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1156
+	$rows = isset($args['size']) ? $args['size'] : 20;
1157 1157
 
1158
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1158
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1159 1159
 		ob_start();
1160
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1160
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows)));
1161 1161
 		$html = ob_get_clean();
1162 1162
 	} else {
1163
-		$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>';
1163
+		$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>';
1164 1164
 	}
1165 1165
 
1166
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1166
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1167 1167
 
1168 1168
 	echo $html;
1169 1169
 }
1170 1170
 
1171
-function wpinv_upload_callback( $args ) {
1171
+function wpinv_upload_callback($args) {
1172 1172
 	global $wpinv_options;
1173 1173
     
1174
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1174
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1175 1175
 
1176
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1176
+	if (isset($wpinv_options[$args['id']])) {
1177 1177
 		$value = $wpinv_options[$args['id']];
1178 1178
 	} else {
1179 1179
 		$value = isset($args['std']) ? $args['std'] : '';
1180 1180
 	}
1181 1181
 
1182
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1183
-	$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 ) ) . '"/>';
1184
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1185
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1182
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1183
+	$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)) . '"/>';
1184
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1185
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1186 1186
 
1187 1187
 	echo $html;
1188 1188
 }
1189 1189
 
1190
-function wpinv_color_callback( $args ) {
1190
+function wpinv_color_callback($args) {
1191 1191
 	global $wpinv_options;
1192 1192
     
1193
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1193
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1194 1194
 
1195
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1196
-		$value = $wpinv_options[ $args['id'] ];
1195
+	if (isset($wpinv_options[$args['id']])) {
1196
+		$value = $wpinv_options[$args['id']];
1197 1197
 	} else {
1198
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1198
+		$value = isset($args['std']) ? $args['std'] : '';
1199 1199
 	}
1200 1200
 
1201
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1201
+	$default = isset($args['std']) ? $args['std'] : '';
1202 1202
 
1203
-	$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 ) . '" />';
1204
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1203
+	$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) . '" />';
1204
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1205 1205
 
1206 1206
 	echo $html;
1207 1207
 }
@@ -1209,9 +1209,9 @@  discard block
 block discarded – undo
1209 1209
 function wpinv_country_states_callback($args) {
1210 1210
 	global $wpinv_options;
1211 1211
     
1212
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1212
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1213 1213
 
1214
-	if ( isset( $args['placeholder'] ) ) {
1214
+	if (isset($args['placeholder'])) {
1215 1215
 		$placeholder = $args['placeholder'];
1216 1216
 	} else {
1217 1217
 		$placeholder = '';
@@ -1219,17 +1219,17 @@  discard block
 block discarded – undo
1219 1219
 
1220 1220
 	$states = wpinv_get_country_states();
1221 1221
 
1222
-	$chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1223
-	$class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1224
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1222
+	$chosen = ($args['chosen'] ? ' wpinv-chosen' : '');
1223
+	$class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1224
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1225 1225
 
1226
-	foreach ( $states as $option => $name ) {
1227
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1228
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1226
+	foreach ($states as $option => $name) {
1227
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1228
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1229 1229
 	}
1230 1230
 
1231 1231
 	$html .= '</select>';
1232
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1232
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1233 1233
 
1234 1234
 	echo $html;
1235 1235
 }
@@ -1244,25 +1244,25 @@  discard block
 block discarded – undo
1244 1244
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1245 1245
 		<thead>
1246 1246
 			<tr>
1247
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1248
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1249
-                <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>
1250
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1251
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1252
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1247
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1248
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1249
+                <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>
1250
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1251
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1252
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1253 1253
 			</tr>
1254 1254
 		</thead>
1255 1255
         <tbody>
1256
-		<?php if( !empty( $rates ) ) : ?>
1257
-			<?php foreach( $rates as $key => $rate ) : ?>
1256
+		<?php if (!empty($rates)) : ?>
1257
+			<?php foreach ($rates as $key => $rate) : ?>
1258 1258
             <?php 
1259
-            $sanitized_key = wpinv_sanitize_key( $key );
1259
+            $sanitized_key = wpinv_sanitize_key($key);
1260 1260
             ?>
1261 1261
 			<tr>
1262 1262
 				<td class="wpinv_tax_country">
1263 1263
 					<?php
1264
-					echo wpinv_html_select( array(
1265
-						'options'          => wpinv_get_country_list( true ),
1264
+					echo wpinv_html_select(array(
1265
+						'options'          => wpinv_get_country_list(true),
1266 1266
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1267 1267
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1268 1268
 						'selected'         => $rate['country'],
@@ -1270,72 +1270,72 @@  discard block
 block discarded – undo
1270 1270
 						'show_option_none' => false,
1271 1271
 						'class'            => 'wpinv-tax-country',
1272 1272
 						'chosen'           => false,
1273
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1274
-					) );
1273
+						'placeholder'      => __('Choose a country', 'invoicing')
1274
+					));
1275 1275
 					?>
1276 1276
 				</td>
1277 1277
 				<td class="wpinv_tax_state">
1278 1278
 					<?php
1279
-					$states = wpinv_get_country_states( $rate['country'] );
1280
-					if( !empty( $states ) ) {
1281
-						echo wpinv_html_select( array(
1282
-							'options'          => array_merge( array( '' => '' ), $states ),
1279
+					$states = wpinv_get_country_states($rate['country']);
1280
+					if (!empty($states)) {
1281
+						echo wpinv_html_select(array(
1282
+							'options'          => array_merge(array('' => ''), $states),
1283 1283
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1284 1284
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1285 1285
 							'selected'         => $rate['state'],
1286 1286
 							'show_option_all'  => false,
1287 1287
 							'show_option_none' => false,
1288 1288
 							'chosen'           => false,
1289
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1290
-						) );
1289
+							'placeholder'      => __('Choose a state', 'invoicing')
1290
+						));
1291 1291
 					} else {
1292
-						echo wpinv_html_text( array(
1292
+						echo wpinv_html_text(array(
1293 1293
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1294
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1294
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1295 1295
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1296
-						) );
1296
+						));
1297 1297
 					}
1298 1298
 					?>
1299 1299
 				</td>
1300 1300
 				<td class="wpinv_tax_global">
1301
-					<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'] ) ); ?>/>
1302
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1301
+					<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'])); ?>/>
1302
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1303 1303
 				</td>
1304
-				<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>
1305
-                <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>
1306
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1304
+				<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>
1305
+                <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>
1306
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1307 1307
 			</tr>
1308 1308
 			<?php endforeach; ?>
1309 1309
 		<?php else : ?>
1310 1310
 			<tr>
1311 1311
 				<td class="wpinv_tax_country">
1312 1312
 					<?php
1313
-					echo wpinv_html_select( array(
1314
-						'options'          => wpinv_get_country_list( true ),
1313
+					echo wpinv_html_select(array(
1314
+						'options'          => wpinv_get_country_list(true),
1315 1315
 						'name'             => 'tax_rates[0][country]',
1316 1316
 						'show_option_all'  => false,
1317 1317
 						'show_option_none' => false,
1318 1318
 						'class'            => 'wpinv-tax-country',
1319 1319
 						'chosen'           => false,
1320
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1321
-					) ); ?>
1320
+						'placeholder'      => __('Choose a country', 'invoicing')
1321
+					)); ?>
1322 1322
 				</td>
1323 1323
 				<td class="wpinv_tax_state">
1324
-					<?php echo wpinv_html_text( array(
1324
+					<?php echo wpinv_html_text(array(
1325 1325
 						'name' => 'tax_rates[0][state]'
1326
-					) ); ?>
1326
+					)); ?>
1327 1327
 				</td>
1328 1328
 				<td class="wpinv_tax_global">
1329 1329
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1330
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1330
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1331 1331
 				</td>
1332
-				<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>
1332
+				<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>
1333 1333
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1334
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1334
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1335 1335
 			</tr>
1336 1336
 		<?php endif; ?>
1337 1337
         </tbody>
1338
-        <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>
1338
+        <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>
1339 1339
 	</table>
1340 1340
 	<?php
1341 1341
 	echo ob_get_clean();
@@ -1346,44 +1346,44 @@  discard block
 block discarded – undo
1346 1346
     ob_start(); ?>
1347 1347
     </td><tr>
1348 1348
     <td colspan="2" class="wpinv_tools_tdbox">
1349
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1350
-    <?php do_action( 'wpinv_tools_before' ); ?>
1349
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1350
+    <?php do_action('wpinv_tools_before'); ?>
1351 1351
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1352 1352
         <thead>
1353 1353
             <tr>
1354
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1355
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1356
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1354
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1355
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1356
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1357 1357
             </tr>
1358 1358
         </thead>
1359
-            <?php do_action( 'wpinv_tools_row' ); ?>
1359
+            <?php do_action('wpinv_tools_row'); ?>
1360 1360
         <tbody>
1361 1361
         </tbody>
1362 1362
     </table>
1363
-    <?php do_action( 'wpinv_tools_after' ); ?>
1363
+    <?php do_action('wpinv_tools_after'); ?>
1364 1364
     <?php
1365 1365
     echo ob_get_clean();
1366 1366
 }
1367 1367
 
1368
-function wpinv_descriptive_text_callback( $args ) {
1369
-	echo wp_kses_post( $args['desc'] );
1368
+function wpinv_descriptive_text_callback($args) {
1369
+	echo wp_kses_post($args['desc']);
1370 1370
 }
1371 1371
 
1372
-function wpinv_hook_callback( $args ) {
1373
-	do_action( 'wpinv_' . $args['id'], $args );
1372
+function wpinv_hook_callback($args) {
1373
+	do_action('wpinv_' . $args['id'], $args);
1374 1374
 }
1375 1375
 
1376 1376
 function wpinv_set_settings_cap() {
1377 1377
 	return 'manage_options';
1378 1378
 }
1379
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1379
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1380 1380
 
1381
-function wpinv_settings_sanitize_input( $value, $key ) {
1382
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1383
-        $value = wpinv_sanitize_amount( $value, 4 );
1381
+function wpinv_settings_sanitize_input($value, $key) {
1382
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1383
+        $value = wpinv_sanitize_amount($value, 4);
1384 1384
         $value = $value >= 100 ? 99 : $value;
1385 1385
     }
1386 1386
         
1387 1387
     return $value;
1388 1388
 }
1389
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1390 1389
\ No newline at end of file
1390
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1391 1391
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 1 patch
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -7,228 +7,228 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-function wpinv_columns( $columns ) {
14
+function wpinv_columns($columns) {
15 15
     $columns = array(
16 16
         'cb'                => $columns['cb'],
17
-        'ID'                => __( 'ID', 'invoicing' ),
18
-        'details'           => __( 'Details', 'invoicing' ),
17
+        'ID'                => __('ID', 'invoicing'),
18
+        'details'           => __('Details', 'invoicing'),
19 19
         //'email'             => __( 'Email', 'invoicing' ),
20
-        'customer'          => __( 'Customer', 'invoicing' ),
21
-        'amount'            => __( 'Amount', 'invoicing' ),
22
-        'invoice_date'      => __( 'Date', 'invoicing' ),
23
-        'status'            => __( 'Status', 'invoicing' ),
24
-        'wpi_actions'       => __( 'Actions', 'invoicing' ),
20
+        'customer'          => __('Customer', 'invoicing'),
21
+        'amount'            => __('Amount', 'invoicing'),
22
+        'invoice_date'      => __('Date', 'invoicing'),
23
+        'status'            => __('Status', 'invoicing'),
24
+        'wpi_actions'       => __('Actions', 'invoicing'),
25 25
     );
26 26
 
27
-    return apply_filters( 'wpi_invoice_table_columns', $columns );
27
+    return apply_filters('wpi_invoice_table_columns', $columns);
28 28
 }
29
-add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' );
29
+add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns');
30 30
 
31
-function wpinv_bulk_actions( $actions ) {
32
-    if ( isset( $actions['edit'] ) ) {
33
-        unset( $actions['edit'] );
31
+function wpinv_bulk_actions($actions) {
32
+    if (isset($actions['edit'])) {
33
+        unset($actions['edit']);
34 34
     }
35 35
 
36 36
     return $actions;
37 37
 }
38
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
38
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
39 39
 
40
-function wpinv_sortable_columns( $columns ) {
40
+function wpinv_sortable_columns($columns) {
41 41
     $columns = array(
42
-        'ID'     => array( 'ID', true ),
43
-        'amount' => array( 'amount', false ),
44
-        'invoice_date'   => array( 'date', false ),
45
-        'customer'   => array( 'customer', false ),
42
+        'ID'     => array('ID', true),
43
+        'amount' => array('amount', false),
44
+        'invoice_date'   => array('date', false),
45
+        'customer'   => array('customer', false),
46 46
         ///'email'   => array( 'email', false ),
47
-        'status'   => array( 'status', false ),
47
+        'status'   => array('status', false),
48 48
     );
49 49
     
50
-    return apply_filters( 'wpi_invoice_table_sortable_columns', $columns );
50
+    return apply_filters('wpi_invoice_table_sortable_columns', $columns);
51 51
 }
52
-add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' );
52
+add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns');
53 53
 
54
-add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
55
-function wpinv_posts_custom_column( $column_name, $post_id = 0 ) {
54
+add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
55
+function wpinv_posts_custom_column($column_name, $post_id = 0) {
56 56
     global $post, $wpi_invoice;
57 57
     
58
-    if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) {
59
-        $wpi_invoice = new WPInv_Invoice( $post->ID );
58
+    if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) {
59
+        $wpi_invoice = new WPInv_Invoice($post->ID);
60 60
     }
61 61
 
62 62
     $value = NULL;
63 63
     
64
-    switch ( $column_name ) {
64
+    switch ($column_name) {
65 65
         case 'email' :
66
-            $value   = $wpi_invoice->get_email();
66
+            $value = $wpi_invoice->get_email();
67 67
             break;
68 68
         case 'customer' :
69 69
             $customer_name = $wpi_invoice->get_user_full_name();
70
-            $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' );
71
-            $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>';
72
-            if ( $email = $wpi_invoice->get_email() ) {
70
+            $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing');
71
+            $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>';
72
+            if ($email = $wpi_invoice->get_email()) {
73 73
                 $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>';
74 74
             }
75 75
             break;
76 76
         case 'amount' :
77
-            echo $wpi_invoice->get_total( true );
77
+            echo $wpi_invoice->get_total(true);
78 78
             break;
79 79
         case 'invoice_date' :
80
-            $date_format = get_option( 'date_format' );
81
-            $time_format = get_option( 'time_format' );
82
-            $date_time_format = $date_format . ' '. $time_format;
80
+            $date_format = get_option('date_format');
81
+            $time_format = get_option('time_format');
82
+            $date_time_format = $date_format . ' ' . $time_format;
83 83
             
84
-            $t_time = get_the_time( $date_time_format );
84
+            $t_time = get_the_time($date_time_format);
85 85
             $m_time = $post->post_date;
86
-            $h_time = mysql2date( $date_format, $m_time );
86
+            $h_time = mysql2date($date_format, $m_time);
87 87
             
88 88
             $value   = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
89 89
             break;
90 90
         case 'status' :
91
-            $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
91
+            $value   = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '');
92 92
             break;
93 93
         case 'details' :
94
-            $edit_link = get_edit_post_link( $post->ID );
95
-            $value = '<a href="' . esc_url( $edit_link ) . '">' . __( 'View Invoice Details', 'invoicing' ) . '</a>';
94
+            $edit_link = get_edit_post_link($post->ID);
95
+            $value = '<a href="' . esc_url($edit_link) . '">' . __('View Invoice Details', 'invoicing') . '</a>';
96 96
             break;
97 97
         case 'wpi_actions' :
98 98
             $value = '';
99
-            if ( !empty( $post->post_name ) ) {
100
-                $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
99
+            if (!empty($post->post_name)) {
100
+                $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
101 101
             }
102 102
             
103
-            if ( $email = $wpi_invoice->get_email() ) {
104
-                $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
103
+            if ($email = $wpi_invoice->get_email()) {
104
+                $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
105 105
             }
106 106
             
107 107
             break;
108 108
         default:
109
-            $value = isset( $post->$column_name ) ? $post->$column_name : '';
109
+            $value = isset($post->$column_name) ? $post->$column_name : '';
110 110
             break;
111 111
 
112 112
     }
113
-    $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name );
113
+    $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name);
114 114
     
115
-    if ( $value !== NULL ) {
115
+    if ($value !== NULL) {
116 116
         echo $value;
117 117
     }
118 118
 }
119 119
 
120
-function wpinv_admin_post_id( $id = 0 ) {
120
+function wpinv_admin_post_id($id = 0) {
121 121
     global $post;
122 122
 
123
-    if ( isset( $id ) && ! empty( $id ) ) {
123
+    if (isset($id) && !empty($id)) {
124 124
         return (int)$id;
125
-    } else if ( get_the_ID() ) {
126
-        return (int) get_the_ID();
127
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
128
-        return (int) $post->ID;
129
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
130
-        return (int) $_GET['post'];
131
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
132
-        return (int) $_GET['id'];
133
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
134
-        return (int) $_POST['id'];
125
+    } else if (get_the_ID()) {
126
+        return (int)get_the_ID();
127
+    } else if (isset($post->ID) && !empty($post->ID)) {
128
+        return (int)$post->ID;
129
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
130
+        return (int)$_GET['post'];
131
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
132
+        return (int)$_GET['id'];
133
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
134
+        return (int)$_POST['id'];
135 135
     } 
136 136
 
137 137
     return null;
138 138
 }
139 139
     
140
-function wpinv_admin_post_type( $id = 0 ) {
141
-    if ( !$id ) {
140
+function wpinv_admin_post_type($id = 0) {
141
+    if (!$id) {
142 142
         $id = wpinv_admin_post_id();
143 143
     }
144 144
     
145
-    $type = get_post_type( $id );
145
+    $type = get_post_type($id);
146 146
     
147
-    if ( !$type ) {
148
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
147
+    if (!$type) {
148
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
149 149
     }
150 150
     
151
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
151
+    return apply_filters('wpinv_admin_post_type', $type, $id);
152 152
 }
153 153
 
154 154
 function wpinv_admin_messages() {
155 155
 	global $wpinv_options;
156 156
 
157
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
158
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
157
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
158
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
159 159
 	}
160 160
 
161
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
162
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
161
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
162
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
163 163
 	}
164 164
 
165
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
166
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
165
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
166
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
167 167
 	}
168 168
 
169
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
170
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
169
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
170
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
171 171
 	}
172 172
 
173
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
174
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
173
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
174
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
175 175
 	}
176 176
 
177
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
178
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
177
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
178
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
179 179
 	}
180 180
 
181
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
182
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
181
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
182
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
183 183
     }
184 184
     
185
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
186
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
185
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
186
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
187 187
     }
188 188
 
189
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
190
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
189
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
190
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
191 191
     }
192 192
 
193
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
194
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
193
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
194
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
195 195
 	}
196 196
 
197
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
198
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
197
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
198
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
199 199
 	}
200 200
 
201
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
202
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
201
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
202
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
203 203
 	}
204 204
 
205
-	settings_errors( 'wpinv-notices' );
205
+	settings_errors('wpinv-notices');
206 206
 }
207
-add_action( 'admin_notices', 'wpinv_admin_messages' );
207
+add_action('admin_notices', 'wpinv_admin_messages');
208 208
 
209
-function wpinv_items_columns( $existing_columns ) {
209
+function wpinv_items_columns($existing_columns) {
210 210
     global $wpinv_euvat;
211 211
     
212 212
     $columns                = array();
213 213
     $columns['cb']          = $existing_columns['cb'];
214
-    $columns['title']       = __( 'Title', 'invoicing' );
215
-    $columns['price']       = __( 'Price', 'invoicing' );
216
-    if ( $wpinv_euvat->allow_vat_rules() ) {
217
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
214
+    $columns['title']       = __('Title', 'invoicing');
215
+    $columns['price']       = __('Price', 'invoicing');
216
+    if ($wpinv_euvat->allow_vat_rules()) {
217
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
218 218
     }
219
-    if ( $wpinv_euvat->allow_vat_classes() ) {
220
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
219
+    if ($wpinv_euvat->allow_vat_classes()) {
220
+        $columns['vat_class']   = __('VAT class', 'invoicing');
221 221
     }
222
-    $columns['type']        = __( 'Type', 'invoicing' );
223
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
224
-    $columns['date']        = __( 'Date', 'invoicing' );
225
-    $columns['id']          = __( 'ID', 'invoicing' );
222
+    $columns['type']        = __('Type', 'invoicing');
223
+    $columns['recurring']   = __('Recurring', 'invoicing');
224
+    $columns['date']        = __('Date', 'invoicing');
225
+    $columns['id']          = __('ID', 'invoicing');
226 226
 
227
-    return apply_filters( 'wpinv_items_columns', $columns );
227
+    return apply_filters('wpinv_items_columns', $columns);
228 228
 }
229
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
229
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
230 230
 
231
-function wpinv_items_sortable_columns( $columns ) {
231
+function wpinv_items_sortable_columns($columns) {
232 232
     $columns['price']       = 'price';
233 233
     $columns['vat_rule']    = 'vat_rule';
234 234
     $columns['vat_class']   = 'vat_class';
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 
239 239
     return $columns;
240 240
 }
241
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
241
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
242 242
 
243
-function wpinv_item_quick_edit( $column_name, $post_type ) {
244
-    if ( !( $post_type == 'wpi_item' && $column_name == 'price' ) ) {
243
+function wpinv_item_quick_edit($column_name, $post_type) {
244
+    if (!($post_type == 'wpi_item' && $column_name == 'price')) {
245 245
         return;
246 246
     }
247 247
     global $wpinv_euvat, $post;
@@ -249,23 +249,23 @@  discard block
 block discarded – undo
249 249
     $symbol    = wpinv_currency_symbol();
250 250
     $position  = wpinv_currency_position();
251 251
 
252
-    $price     = wpinv_get_item_price( $post->ID );
253
-    $item_type = wpinv_get_item_type( $post->ID );
252
+    $price     = wpinv_get_item_price($post->ID);
253
+    $item_type = wpinv_get_item_type($post->ID);
254 254
     ?>
255 255
     <fieldset class="inline-edit-col-right wpi-inline-item-col">
256 256
         <div class="inline-edit-col">
257 257
             <div class="inline-edit-group wp-clearfix">
258 258
                 <label class="inline-edit-wpinv-price">
259
-                    <span class="title"><?php _e( 'Item price', 'invoicing' );?></span>
260
-                    <span class="input-text-wrap"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" name="_wpinv_item_price" class="wpi-field-price wpi-price" id="wpinv_item_price-<?php echo $post->ID;?>"><?php echo ( $position == 'right' ? $symbol . '&nbsp;' : '' );?></span>
259
+                    <span class="title"><?php _e('Item price', 'invoicing'); ?></span>
260
+                    <span class="input-text-wrap"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" name="_wpinv_item_price" class="wpi-field-price wpi-price" id="wpinv_item_price-<?php echo $post->ID; ?>"><?php echo ($position == 'right' ? $symbol . '&nbsp;' : ''); ?></span>
261 261
                 </label>
262 262
             </div>
263
-            <?php if ( $wpinv_euvat->allow_vat_rules() ) { $rule_type = $wpinv_euvat->get_item_rule( $post->ID ); ?>
263
+            <?php if ($wpinv_euvat->allow_vat_rules()) { $rule_type = $wpinv_euvat->get_item_rule($post->ID); ?>
264 264
             <div class="inline-edit-group wp-clearfix">
265 265
                 <label class="inline-edit-wpinv-vat-rate">
266
-                    <span class="title"><?php _e( 'VAT rule type to use', 'invoicing' );?></span>
266
+                    <span class="title"><?php _e('VAT rule type to use', 'invoicing'); ?></span>
267 267
                     <span class="input-text-wrap">
268
-                        <?php echo wpinv_html_select( array(
268
+                        <?php echo wpinv_html_select(array(
269 269
                             'options'          => $wpinv_euvat->get_rules(),
270 270
                             'name'             => '_wpinv_vat_rules',
271 271
                             'id'               => 'wpinv_vat_rules-' . $post->ID,
@@ -273,16 +273,16 @@  discard block
 block discarded – undo
273 273
                             'show_option_all'  => false,
274 274
                             'show_option_none' => false,
275 275
                             'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
276
-                        ) ); ?>
276
+                        )); ?>
277 277
                     </span>
278 278
                 </label>
279 279
             </div>
280
-            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { $vat_class = $wpinv_euvat->get_item_class( $post->ID ); ?>
280
+            <?php } if ($wpinv_euvat->allow_vat_classes()) { $vat_class = $wpinv_euvat->get_item_class($post->ID); ?>
281 281
             <div class="inline-edit-group wp-clearfix">
282 282
                 <label class="inline-edit-wpinv-vat-class">
283
-                    <span class="title"><?php _e( 'VAT class to use', 'invoicing' );?></span>
283
+                    <span class="title"><?php _e('VAT class to use', 'invoicing'); ?></span>
284 284
                     <span class="input-text-wrap">
285
-                        <?php echo wpinv_html_select( array(
285
+                        <?php echo wpinv_html_select(array(
286 286
                             'options'          => $wpinv_euvat->get_all_classes(),
287 287
                             'name'             => '_wpinv_vat_class',
288 288
                             'id'               => 'wpinv_vat_class-' . $post->ID,
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
                             'show_option_all'  => false,
291 291
                             'show_option_none' => false,
292 292
                             'class'            => 'gdmbx2-text-medium wpinv-vat-class',
293
-                        ) ); ?>
293
+                        )); ?>
294 294
                     </span>
295 295
                 </label>
296 296
             </div>
297 297
             <?php } ?>
298 298
             <div class="inline-edit-group wp-clearfix">
299 299
                 <label class="inline-edit-wpinv-type">
300
-                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
300
+                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
301 301
                     <span class="input-text-wrap">
302
-                        <?php echo wpinv_html_select( array(
302
+                        <?php echo wpinv_html_select(array(
303 303
                             'options'          => wpinv_get_item_types(),
304 304
                             'name'             => '_wpinv_item_type',
305 305
                             'id'               => 'wpinv_item_type-' . $post->ID,
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
                             'show_option_all'  => false,
308 308
                             'show_option_none' => false,
309 309
                             'class'            => 'gdmbx2-text-medium wpinv-item-type',
310
-                        ) ); ?>
310
+                        )); ?>
311 311
                     </span>
312 312
                 </label>
313 313
             </div>
@@ -315,150 +315,150 @@  discard block
 block discarded – undo
315 315
     </fieldset>
316 316
     <?php
317 317
 }
318
-add_action( 'quick_edit_custom_box', 'wpinv_item_quick_edit', 10, 2 );
319
-add_action( 'bulk_edit_custom_box', 'wpinv_item_quick_edit', 10, 2 );
318
+add_action('quick_edit_custom_box', 'wpinv_item_quick_edit', 10, 2);
319
+add_action('bulk_edit_custom_box', 'wpinv_item_quick_edit', 10, 2);
320 320
 
321
-function wpinv_items_table_custom_column( $column ) {
321
+function wpinv_items_table_custom_column($column) {
322 322
     global $wpinv_euvat, $post, $wpi_item;
323 323
     
324
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
325
-        $wpi_item = new WPInv_Item( $post->ID );
324
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
325
+        $wpi_item = new WPInv_Item($post->ID);
326 326
     }
327 327
 
328
-    switch ( $column ) {
328
+    switch ($column) {
329 329
         case 'price' :
330
-            echo wpinv_item_price( $post->ID );
330
+            echo wpinv_item_price($post->ID);
331 331
         break;
332 332
         case 'vat_rule' :
333
-            echo $wpinv_euvat->item_rule_label( $post->ID );
333
+            echo $wpinv_euvat->item_rule_label($post->ID);
334 334
         break;
335 335
         case 'vat_class' :
336
-            echo $wpinv_euvat->item_class_label( $post->ID );
336
+            echo $wpinv_euvat->item_class_label($post->ID);
337 337
         break;
338 338
         case 'type' :
339
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
339
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
340 340
         break;
341 341
         case 'recurring' :
342
-            echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' );
342
+            echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>');
343 343
         break;
344 344
         case 'id' :
345 345
            echo $post->ID;
346 346
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
347
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
348
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
349
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
347
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
348
+                    if ($wpinv_euvat->allow_vat_rules()) {
349
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
350 350
                     }
351
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
352
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
351
+                    if ($wpinv_euvat->allow_vat_classes()) {
352
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
353 353
                     }
354
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
354
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
355 355
                 </div>';
356 356
         break;
357 357
     }
358 358
     
359
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
359
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
360 360
 }
361
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
361
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
362 362
 
363 363
 function wpinv_add_items_filters() {
364 364
     global $wpinv_euvat, $typenow;
365 365
 
366 366
     // Checks if the current post type is 'item'
367
-    if ( $typenow == 'wpi_item') {
368
-        if ( $wpinv_euvat->allow_vat_rules() ) {
369
-            echo wpinv_html_select( array(
370
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
367
+    if ($typenow == 'wpi_item') {
368
+        if ($wpinv_euvat->allow_vat_rules()) {
369
+            echo wpinv_html_select(array(
370
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
371 371
                     'name'             => 'vat_rule',
372 372
                     'id'               => 'vat_rule',
373
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
373
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
374 374
                     'show_option_all'  => false,
375 375
                     'show_option_none' => false,
376 376
                     'class'            => 'gdmbx2-text-medium',
377
-                ) );
377
+                ));
378 378
         }
379 379
         
380
-        if ( $wpinv_euvat->allow_vat_classes() ) {
381
-            echo wpinv_html_select( array(
382
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ),
380
+        if ($wpinv_euvat->allow_vat_classes()) {
381
+            echo wpinv_html_select(array(
382
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()),
383 383
                     'name'             => 'vat_class',
384 384
                     'id'               => 'vat_class',
385
-                    'selected'         => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ),
385
+                    'selected'         => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''),
386 386
                     'show_option_all'  => false,
387 387
                     'show_option_none' => false,
388 388
                     'class'            => 'gdmbx2-text-medium',
389
-                ) );
389
+                ));
390 390
         }
391 391
             
392
-        echo wpinv_html_select( array(
393
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
392
+        echo wpinv_html_select(array(
393
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
394 394
                 'name'             => 'type',
395 395
                 'id'               => 'type',
396
-                'selected'         => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ),
396
+                'selected'         => (isset($_GET['type']) ? $_GET['type'] : ''),
397 397
                 'show_option_all'  => false,
398 398
                 'show_option_none' => false,
399 399
                 'class'            => 'gdmbx2-text-medium',
400
-            ) );
400
+            ));
401 401
 
402
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
402
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
403 403
             echo '<input type="hidden" name="all_posts" value="1" />';
404 404
         }
405 405
     }
406 406
 }
407
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
407
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
408 408
 
409
-function wpinv_send_invoice_after_save( $post_id ) {
409
+function wpinv_send_invoice_after_save($post_id) {
410 410
     // If this is just a revision, don't send the email.
411
-    if ( wp_is_post_revision( $post_id ) ) {
411
+    if (wp_is_post_revision($post_id)) {
412 412
         return;
413 413
     }
414 414
     
415
-    if ( !current_user_can( 'manage_options' ) || !(get_post_type( $post_id ) == 'wpi_invoice' || get_post_type( $post_id ) == 'wpi_quote')  ) {
415
+    if (!current_user_can('manage_options') || !(get_post_type($post_id) == 'wpi_invoice' || get_post_type($post_id) == 'wpi_quote')) {
416 416
         return;
417 417
     }
418 418
     
419
-    if ( !empty( $_POST['wpi_save_send'] ) ) {
420
-        wpinv_user_invoice_notification( $post_id );
419
+    if (!empty($_POST['wpi_save_send'])) {
420
+        wpinv_user_invoice_notification($post_id);
421 421
     }
422 422
 }
423
-add_action( 'save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1 );
423
+add_action('save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1);
424 424
 
425
-function wpinv_send_register_new_user( $data, $postarr ) {
426
-    if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && $data['post_type'] == 'wpi_invoice' ) {
427
-        $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false;
428
-        $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL;
425
+function wpinv_send_register_new_user($data, $postarr) {
426
+    if (current_user_can('manage_options') && !empty($data['post_type']) && $data['post_type'] == 'wpi_invoice') {
427
+        $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false;
428
+        $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL;
429 429
         
430
-        if ( $is_new_user && $email && !email_exists( $email ) ) {
431
-            $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : '';
432
-            $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : '';
433
-            $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : '';
434
-            $user_nicename = $display_name ? trim( $display_name ) : $email;
435
-            $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : '';
430
+        if ($is_new_user && $email && !email_exists($email)) {
431
+            $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : '';
432
+            $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : '';
433
+            $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : '';
434
+            $user_nicename = $display_name ? trim($display_name) : $email;
435
+            $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : '';
436 436
             
437
-            $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true );
438
-            if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
439
-                $user_login = sanitize_user( str_replace( ' ', '', $user_company ), true );
437
+            $user_login = sanitize_user(str_replace(' ', '', $display_name), true);
438
+            if (!(validate_username($user_login) && !username_exists($user_login))) {
439
+                $user_login = sanitize_user(str_replace(' ', '', $user_company), true);
440 440
                 
441
-                if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
441
+                if (!(validate_username($user_login) && !username_exists($user_login))) {
442 442
                     $user_login = $email;
443 443
                 }
444 444
             }
445 445
             
446 446
             $userdata = array(
447 447
                 'user_login' => $user_login,
448
-                'user_pass' => wp_generate_password( 12, false ),
449
-                'user_email' => sanitize_text_field( $email ),
448
+                'user_pass' => wp_generate_password(12, false),
449
+                'user_email' => sanitize_text_field($email),
450 450
                 'first_name' => $first_name,
451 451
                 'last_name' => $last_name,
452
-                'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ),
452
+                'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50),
453 453
                 'nickname' => $display_name,
454 454
                 'display_name' => $display_name,
455 455
             );
456 456
 
457
-            $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata );
457
+            $userdata = apply_filters('wpinv_register_new_user_data', $userdata);
458 458
             
459
-            $new_user_id = wp_insert_user( $userdata );
459
+            $new_user_id = wp_insert_user($userdata);
460 460
             
461
-            if ( !is_wp_error( $new_user_id ) ) {
461
+            if (!is_wp_error($new_user_id)) {
462 462
                 $data['post_author'] = $new_user_id;
463 463
                 $_POST['post_author'] = $new_user_id;
464 464
                 $_POST['post_author_override'] = $new_user_id;
@@ -479,27 +479,27 @@  discard block
 block discarded – undo
479 479
                 
480 480
                 $meta = array();
481 481
                 ///$meta['_wpinv_user_id'] = $new_user_id;
482
-                foreach ( $meta_fields as $field ) {
483
-                    $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : '';
482
+                foreach ($meta_fields as $field) {
483
+                    $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : '';
484 484
                 }
485 485
                 
486
-                $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id );
486
+                $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id);
487 487
 
488 488
                 // Update user meta.
489
-                foreach ( $meta as $key => $value ) {
490
-                    update_user_meta( $new_user_id, $key, $value );
489
+                foreach ($meta as $key => $value) {
490
+                    update_user_meta($new_user_id, $key, $value);
491 491
                 }
492 492
                 
493
-                if ( function_exists( 'wp_send_new_user_notifications' ) ) {
493
+                if (function_exists('wp_send_new_user_notifications')) {
494 494
                     // Send email notifications related to the creation of new user.
495
-                    wp_send_new_user_notifications( $new_user_id, 'user' );
495
+                    wp_send_new_user_notifications($new_user_id, 'user');
496 496
                 }
497 497
             } else {
498
-                wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ );
498
+                wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__);
499 499
             }
500 500
         }
501 501
     }
502 502
     
503 503
     return $data;
504 504
 }
505
-add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 );
506 505
\ No newline at end of file
506
+add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2);
507 507
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -11,37 +11,37 @@
 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
-    update_option( 'wpinv_version', WPINV_VERSION );
24
+    update_option('wpinv_version', WPINV_VERSION);
25 25
 }
26
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
26
+add_action('admin_init', 'wpinv_automatic_upgrade');
27 27
 
28 28
 function wpinv_v005_upgrades() {
29 29
     global $wpdb;
30 30
     
31 31
     // Invoices status
32
-    $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
32
+    $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
33 33
     
34 34
     // Item meta key changes
35 35
     $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' )";
36
-    $results = $wpdb->get_results( $query );
36
+    $results = $wpdb->get_results($query);
37 37
     
38
-    if ( !empty( $results ) ) {
39
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
40
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
41
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
38
+    if (!empty($results)) {
39
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
40
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
41
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
42 42
         
43
-        foreach ( $results as $row ) {
44
-            clean_post_cache( $row->post_id );
43
+        foreach ($results as $row) {
44
+            clean_post_cache($row->post_id);
45 45
         }
46 46
     }
47 47
 }
48 48
\ 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   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {        
8
+    public static function output($post) {        
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
         
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22 22
         $item_types         = wpinv_get_item_types();
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
         }
30 30
         
31 31
         $cols = 5;
32
-        if ( $item_quantities ) {
32
+        if ($item_quantities) {
33 33
             $cols++;
34 34
         }
35
-        if ( $use_taxes ) {
35
+        if ($use_taxes) {
36 36
             $cols++;
37 37
         }
38 38
         $class = '';
39
-        if ( $invoice->is_paid() ) {
39
+        if ($invoice->is_paid()) {
40 40
             $class .= ' wpinv-paid';
41 41
         }
42
-        if ( $is_recurring ) {
42
+        if ($is_recurring) {
43 43
             $class .= ' wpi-recurring';
44 44
         }
45 45
         ?>
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
48 48
                 <thead>
49 49
                     <tr>
50
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
51
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
52
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
53
-                        <?php if ( $item_quantities ) { ?>
54
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
50
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
51
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
52
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
53
+                        <?php if ($item_quantities) { ?>
54
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
55 55
                         <?php } ?>
56
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
57
-                        <?php if ( $use_taxes ) { ?>
58
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
56
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
57
+                        <?php if ($use_taxes) { ?>
58
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
59 59
                         <?php } ?>
60 60
                         <th class="action"></th>
61 61
                     </tr>
62 62
                 </thead>
63 63
                 <tbody class="wpinv-line-items">
64
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
64
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
65 65
                 </tbody>
66 66
                 <tfoot class="wpinv-totals">
67 67
                     <tr>
@@ -73,44 +73,44 @@  discard block
 block discarded – undo
73 73
                                         </td>
74 74
                                         <td class="title">
75 75
                                             <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]">
76
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
76
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
77 77
                                             <div class="wp-clearfix">
78 78
                                                 <label class="wpi-vat-rule">
79
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
79
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
80 80
                                                     <span class="input-text-wrap">
81
-                                                        <?php echo wpinv_html_select( array(
81
+                                                        <?php echo wpinv_html_select(array(
82 82
                                                             'options'          => $wpinv_euvat->get_rules(),
83 83
                                                             'name'             => '_wpinv_quick[vat_rule]',
84 84
                                                             'id'               => '_wpinv_quick_vat_rule',
85 85
                                                             'show_option_all'  => false,
86 86
                                                             'show_option_none' => false,
87 87
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
88
-                                                        ) ); ?>
88
+                                                        )); ?>
89 89
                                                     </span>
90 90
                                                 </label>
91 91
                                             </div>
92
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
92
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
93 93
                                             <div class="wp-clearfix">
94 94
                                                 <label class="wpi-vat-class">
95
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
95
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
96 96
                                                     <span class="input-text-wrap">
97
-                                                        <?php echo wpinv_html_select( array(
97
+                                                        <?php echo wpinv_html_select(array(
98 98
                                                             'options'          => $wpinv_euvat->get_all_classes(),
99 99
                                                             'name'             => '_wpinv_quick[vat_class]',
100 100
                                                             'id'               => '_wpinv_quick_vat_class',
101 101
                                                             'show_option_all'  => false,
102 102
                                                             'show_option_none' => false,
103 103
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
104
-                                                        ) ); ?>
104
+                                                        )); ?>
105 105
                                                     </span>
106 106
                                                 </label>
107 107
                                             </div>
108 108
                                             <?php } ?>
109 109
                                             <div class="wp-clearfix">
110 110
                                                 <label class="wpi-item-type">
111
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
111
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
112 112
                                                     <span class="input-text-wrap">
113
-                                                        <?php echo wpinv_html_select( array(
113
+                                                        <?php echo wpinv_html_select(array(
114 114
                                                             'options'          => $item_types,
115 115
                                                             'name'             => '_wpinv_quick[type]',
116 116
                                                             'id'               => '_wpinv_quick_type',
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                                                             'show_option_all'  => false,
119 119
                                                             'show_option_none' => false,
120 120
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
121
-                                                        ) ); ?>
121
+                                                        )); ?>
122 122
                                                     </span>
123 123
                                                 </label>
124 124
                                             </div>
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
                                             </div>
132 132
                                         </td>
133 133
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
134
-                                        <?php if ( $item_quantities ) { ?>
134
+                                        <?php if ($item_quantities) { ?>
135 135
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
136 136
                                         <?php } ?>
137 137
                                         <td class="total"></td>
138
-                                        <?php if ( $use_taxes ) { ?>
138
+                                        <?php if ($use_taxes) { ?>
139 139
                                         <td class="tax"></td>
140 140
                                         <?php } ?>
141 141
                                         <td class="action"></td>
@@ -148,29 +148,29 @@  discard block
 block discarded – undo
148 148
                         <td colspan="<?php echo $cols; ?>"></td>
149 149
                     </tr>
150 150
                     <tr class="totals">
151
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
151
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
152 152
                         <td colspan="4">
153 153
                             <table cellspacing="0" cellpadding="0">
154 154
                                 <tr class="subtotal">
155
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
156
-                                    <td class="total"><?php echo $subtotal;?></td>
155
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
156
+                                    <td class="total"><?php echo $subtotal; ?></td>
157 157
                                     <td class="action"></td>
158 158
                                 </tr>
159 159
                                 <tr class="discount">
160
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
161
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
160
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
161
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
162 162
                                     <td class="action"></td>
163 163
                                 </tr>
164
-                                <?php if ( $use_taxes ) { ?>
164
+                                <?php if ($use_taxes) { ?>
165 165
                                 <tr class="tax">
166
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
167
-                                    <td class="total"><?php echo $tax;?></td>
166
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
167
+                                    <td class="total"><?php echo $tax; ?></td>
168 168
                                     <td class="action"></td>
169 169
                                 </tr>
170 170
                                 <?php } ?>
171 171
                                 <tr class="total">
172
-                                    <td class="name"><?php _e( 'Invoice Total:', 'invoicing' );?></td>
173
-                                    <td class="total"><?php echo $total;?></td>
172
+                                    <td class="name"><?php _e('Invoice Total:', 'invoicing'); ?></td>
173
+                                    <td class="total"><?php echo $total; ?></td>
174 174
                                     <td class="action"></td>
175 175
                                 </tr>
176 176
                             </table>
@@ -180,89 +180,89 @@  discard block
 block discarded – undo
180 180
             </table>
181 181
             <div class="wpinv-actions">
182 182
                 <?php
183
-                    if ( !$invoice->is_paid() ) {
184
-                    if ( !$invoice->is_recurring() ) {
185
-                    echo wpinv_item_dropdown( array(
183
+                    if (!$invoice->is_paid()) {
184
+                    if (!$invoice->is_recurring()) {
185
+                    echo wpinv_item_dropdown(array(
186 186
                         'name'             => 'wpinv_invoice_item',
187 187
                         'id'               => 'wpinv_invoice_item',
188 188
                         'with_packages'    => false,
189 189
                         'show_recurring'   => true,
190
-                    ) );
190
+                    ));
191 191
                     ?>
192
-                <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">
192
+                <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">
193 193
                     <?php } ?>
194
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
194
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
195 195
             </div>
196 196
         </div>
197 197
         <?php
198 198
     }
199 199
     
200
-    public static function prices( $post ) {        
200
+    public static function prices($post) {        
201 201
         $symbol         = wpinv_currency_symbol();
202 202
         $position       = wpinv_currency_position();
203
-        $item           = new WPInv_Item( $post->ID );
203
+        $item           = new WPInv_Item($post->ID);
204 204
         
205 205
         $price          = $item->get_price();
206 206
         $is_recurring   = $item->is_recurring();
207 207
         $period         = $item->get_recurring_period();
208
-        $interval       = absint( $item->get_recurring_interval() );
209
-        $times          = absint( $item->get_recurring_limit() );
208
+        $interval       = absint($item->get_recurring_interval());
209
+        $times          = absint($item->get_recurring_limit());
210 210
         $free_trial     = $item->has_free_trial();
211 211
         $trial_interval = $item->get_trial_interval();
212 212
         $trial_period   = $item->get_trial_period();
213 213
         
214 214
         $intervals      = array();
215
-        for ( $i = 1; $i <= 90; $i++ ) {
215
+        for ($i = 1; $i <= 90; $i++) {
216 216
             $intervals[$i] = $i;
217 217
         }
218 218
         
219
-        $interval       = $interval > 0 ? $interval : 1;
219
+        $interval = $interval > 0 ? $interval : 1;
220 220
         
221 221
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
222 222
         ?>
223
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_package(), true ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
224
-        <?php if ( $item->is_package() ) { ?>
225
-        <span class="description"><?php _e( 'GD package item price can be edited only from GD payment manager.', 'invoicing' ); ?></span>
223
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_package(), true); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
224
+        <?php if ($item->is_package()) { ?>
225
+        <span class="description"><?php _e('GD package item price can be edited only from GD payment manager.', 'invoicing'); ?></span>
226 226
         <?php } ?>
227 227
         </p>
228 228
         <p class="wpinv-row-is-recurring">
229 229
             <label for="wpinv_is_recurring">
230
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
231
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
230
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
231
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
232 232
             </label>
233 233
         </p>
234
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
235
-                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
236
-                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
234
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
235
+                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
236
+                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
237 237
                     'options'          => $intervals,
238 238
                     'name'             => 'wpinv_recurring_interval',
239 239
                     'id'               => 'wpinv_recurring_interval',
240 240
                     'selected'         => $interval,
241 241
                     'show_option_all'  => false,
242 242
                     'show_option_none' => false
243
-                ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
244
-                <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>
243
+                )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
244
+                <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>
245 245
                 <span class="clear wpi-trial-clr"></span>
246 246
                 <label class="wpinv-free-trial" for="wpinv_free_trial">
247
-                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
248
-                    <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
247
+                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
248
+                    <?php echo __('Offer free trial for', 'invoicing'); ?>
249 249
                 </label>
250 250
                 <label class="wpinv-trial-interval" for="wpinv_trial_interval">
251
-                    <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
251
+                    <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
252 252
                 </label>
253 253
         </p>
254
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
255
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
254
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
255
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
256 256
         <?php
257 257
     }
258 258
     
259
-    public static function vat_rules( $post ) {
259
+    public static function vat_rules($post) {
260 260
         global $wpinv_euvat;
261 261
         
262
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
262
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
263 263
         ?>
264
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
265
-        <?php echo wpinv_html_select( array(
264
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
265
+        <?php echo wpinv_html_select(array(
266 266
                     'options'          => $wpinv_euvat->get_rules(),
267 267
                     'name'             => 'wpinv_vat_rules',
268 268
                     'id'               => 'wpinv_vat_rules',
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
                     'show_option_all'  => false,
271 271
                     'show_option_none' => false,
272 272
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
273
-                ) ); ?>
273
+                )); ?>
274 274
         </p>
275
-        <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>
276
-        <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>
275
+        <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>
276
+        <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>
277 277
         <?php
278 278
     }
279 279
     
280
-    public static function vat_classes( $post ) {
280
+    public static function vat_classes($post) {
281 281
         global $wpinv_euvat;
282 282
         
283
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
283
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
284 284
         ?>
285
-        <p><?php echo wpinv_html_select( array(
285
+        <p><?php echo wpinv_html_select(array(
286 286
                     'options'          => $wpinv_euvat->get_all_classes(),
287 287
                     'name'             => 'wpinv_vat_class',
288 288
                     'id'               => 'wpinv_vat_class',
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
                     'show_option_all'  => false,
291 291
                     'show_option_none' => false,
292 292
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
293
-                ) ); ?>
293
+                )); ?>
294 294
         </p>
295
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
295
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
296 296
         <?php
297 297
     }
298 298
     
299
-    public static function item_info( $post ) {
300
-        $item_type = wpinv_get_item_type( $post->ID );
301
-        do_action( 'wpinv_item_info_metabox_before', $post );
299
+    public static function item_info($post) {
300
+        $item_type = wpinv_get_item_type($post->ID);
301
+        do_action('wpinv_item_info_metabox_before', $post);
302 302
         ?>
303
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
304
-        <?php echo wpinv_html_select( array(
303
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
304
+        <?php echo wpinv_html_select(array(
305 305
                     'options'          => wpinv_get_item_types(),
306 306
                     'name'             => 'wpinv_item_type',
307 307
                     'id'               => 'wpinv_item_type',
@@ -310,114 +310,114 @@  discard block
 block discarded – undo
310 310
                     'show_option_none' => false,
311 311
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
312 312
                     //'disabled'         => $item_type == 'package' ? true : false,
313
-                ) ); ?>
313
+                )); ?>
314 314
         </p>
315
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( 'Standard: standard item type', 'invoicing' );?><br><?php _e( 'Fee: like Registration Fee, Signup Fee etc.', 'invoicing' );?></p>
315
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('Standard: standard item type', 'invoicing'); ?><br><?php _e('Fee: like Registration Fee, Signup Fee etc.', 'invoicing'); ?></p>
316 316
         <?php
317
-        do_action( 'wpinv_item_info_metabox_after', $post );
317
+        do_action('wpinv_item_info_metabox_after', $post);
318 318
     }
319 319
     
320
-    public static function meta_values( $post ) {
321
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
320
+    public static function meta_values($post) {
321
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
322 322
             'type',
323 323
             'custom_id'
324
-        ) );
324
+        ));
325 325
         
326
-        if ( empty( $meta_keys ) ) {
326
+        if (empty($meta_keys)) {
327 327
             return;
328 328
         }
329 329
         
330
-        do_action( 'wpinv_meta_values_metabox_before', $post );
330
+        do_action('wpinv_meta_values_metabox_before', $post);
331 331
         
332
-        foreach ( $meta_keys as $meta_key ) {
332
+        foreach ($meta_keys as $meta_key) {
333 333
             ?>
334
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
334
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
335 335
             <?php 
336 336
         }
337 337
         
338
-        do_action( 'wpinv_meta_values_metabox_after', $post );
338
+        do_action('wpinv_meta_values_metabox_after', $post);
339 339
     }
340 340
     
341
-    public static function save( $post_id, $data, $post ) {
342
-        $invoice        = new WPInv_Invoice( $post_id );
341
+    public static function save($post_id, $data, $post) {
342
+        $invoice        = new WPInv_Invoice($post_id);
343 343
         
344 344
         // Billing
345
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
346
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
347
-        $company        = sanitize_text_field( $data['wpinv_company'] );
348
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
349
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
350
-        $address        = sanitize_text_field( $data['wpinv_address'] );
351
-        $city           = sanitize_text_field( $data['wpinv_city'] );
352
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
353
-        $country        = sanitize_text_field( $data['wpinv_country'] );
354
-        $state          = sanitize_text_field( $data['wpinv_state'] );
345
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
346
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
347
+        $company        = sanitize_text_field($data['wpinv_company']);
348
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
349
+        $phone          = sanitize_text_field($data['wpinv_phone']);
350
+        $address        = sanitize_text_field($data['wpinv_address']);
351
+        $city           = sanitize_text_field($data['wpinv_city']);
352
+        $zip            = sanitize_text_field($data['wpinv_zip']);
353
+        $country        = sanitize_text_field($data['wpinv_country']);
354
+        $state          = sanitize_text_field($data['wpinv_state']);
355 355
         
356 356
         // Details
357
-        $status         = sanitize_text_field( $data['wpinv_status'] );
358
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
359
-        $number         = sanitize_text_field( $data['wpinv_number'] );
360
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
357
+        $status         = sanitize_text_field($data['wpinv_status']);
358
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
359
+        $number         = sanitize_text_field($data['wpinv_number']);
360
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
361 361
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
362 362
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
363 363
         
364
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
364
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
365 365
         
366
-        $invoice->set( 'due_date', $due_date );
367
-        $invoice->set( 'first_name', $first_name );
368
-        $invoice->set( 'last_name', $last_name );
369
-        $invoice->set( 'company', $company );
370
-        $invoice->set( 'vat_number', $vat_number );
371
-        $invoice->set( 'phone', $phone );
372
-        $invoice->set( 'address', $address );
373
-        $invoice->set( 'city', $city );
374
-        $invoice->set( 'zip', $zip );
375
-        $invoice->set( 'country', $country );
376
-        $invoice->set( 'state', $state );
377
-        $invoice->set( 'status', $status );
378
-        $invoice->set( 'number', $number );
366
+        $invoice->set('due_date', $due_date);
367
+        $invoice->set('first_name', $first_name);
368
+        $invoice->set('last_name', $last_name);
369
+        $invoice->set('company', $company);
370
+        $invoice->set('vat_number', $vat_number);
371
+        $invoice->set('phone', $phone);
372
+        $invoice->set('address', $address);
373
+        $invoice->set('city', $city);
374
+        $invoice->set('zip', $zip);
375
+        $invoice->set('country', $country);
376
+        $invoice->set('state', $state);
377
+        $invoice->set('status', $status);
378
+        $invoice->set('number', $number);
379 379
         //$invoice->set( 'discounts', $discounts );
380 380
         //$invoice->set( 'discount', $discount );
381
-        $invoice->set( 'ip', $ip );
381
+        $invoice->set('ip', $ip);
382 382
         $invoice->old_status = $_POST['original_post_status'];
383 383
         $invoice->currency = wpinv_get_currency();
384
-        if ( !empty( $data['wpinv_gateway'] ) ) {
385
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
384
+        if (!empty($data['wpinv_gateway'])) {
385
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
386 386
         }
387 387
         $saved = $invoice->save();
388 388
         
389 389
         // Check for payment notes
390
-        if ( !empty( $data['invoice_note'] ) ) {
391
-            $note               = wp_kses( $data['invoice_note'], array() );
392
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
390
+        if (!empty($data['invoice_note'])) {
391
+            $note               = wp_kses($data['invoice_note'], array());
392
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
393 393
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
394 394
         
395
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
395
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
396 396
         }
397 397
         
398 398
         // Update user address if empty.
399
-        if ( $saved && !empty( $invoice ) ) {
400
-            if ( $user_id = $invoice->get_user_id() ) {
401
-                $user_address = wpinv_get_user_address( $user_id, false );
399
+        if ($saved && !empty($invoice)) {
400
+            if ($user_id = $invoice->get_user_id()) {
401
+                $user_address = wpinv_get_user_address($user_id, false);
402 402
                 
403 403
                 if (empty($user_address['first_name'])) {
404
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
405
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
404
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
405
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
406 406
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
407
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
407
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
408 408
                 }
409 409
                 
410 410
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
411
-                    update_user_meta( $user_id, '_wpinv_address', $address );
412
-                    update_user_meta( $user_id, '_wpinv_city', $city );
413
-                    update_user_meta( $user_id, '_wpinv_state', $state );
414
-                    update_user_meta( $user_id, '_wpinv_country', $country );
415
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
416
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
411
+                    update_user_meta($user_id, '_wpinv_address', $address);
412
+                    update_user_meta($user_id, '_wpinv_city', $city);
413
+                    update_user_meta($user_id, '_wpinv_state', $state);
414
+                    update_user_meta($user_id, '_wpinv_country', $country);
415
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
416
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
417 417
                 }
418 418
             }
419 419
             
420
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
420
+            do_action('wpinv_invoice_metabox_saved', $invoice);
421 421
         }
422 422
         
423 423
         return $saved;
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
     ?>
11 11
     <div class="wrap">
12 12
         <h1>
13
-            <?php _e( 'Subscriptions', 'invoicing' ); ?>
14
-            <a href="<?php echo esc_url( add_query_arg( array( 'wpi_action' => 'add_subscription' ) ) ); ?>" class="add-new-h2"><?php _e( 'Add New', 'invoicing' ); ?></a>
13
+            <?php _e('Subscriptions', 'invoicing'); ?>
14
+            <a href="<?php echo esc_url(add_query_arg(array('wpi_action' => 'add_subscription'))); ?>" class="add-new-h2"><?php _e('Add New', 'invoicing'); ?></a>
15 15
         </h1>
16 16
         <?php
17 17
         //$subscribers_table = new EDD_Subscription_Reports_Table();
Please login to merge, or discard this patch.