Passed
Push — master ( c6d0db...756836 )
by Brian
04:55 queued 28s
created
templates/payment-forms-admin/previews/address.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/discount.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/paragraph.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/pay_button.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -7,172 +7,172 @@  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
-    $checkout_page    = wpinv_get_option( 'checkout_page' );
20
-    $is_checkout      = ! empty( $checkout_page ) && is_page( $checkout_page );
17
+    $is_object_set    = isset($wp_query->queried_object);
18
+    $is_object_id_set = isset($wp_query->queried_object_id);
19
+    $checkout_page    = wpinv_get_option('checkout_page');
20
+    $is_checkout      = !empty($checkout_page) && is_page($checkout_page);
21 21
 
22
-    if ( !$is_object_set ) {
23
-        unset( $wp_query->queried_object );
22
+    if (!$is_object_set) {
23
+        unset($wp_query->queried_object);
24 24
     }
25 25
 
26
-    if ( !$is_object_id_set ) {
27
-        unset( $wp_query->queried_object_id );
26
+    if (!$is_object_id_set) {
27
+        unset($wp_query->queried_object_id);
28 28
     }
29 29
 
30
-    return apply_filters( 'wpinv_is_checkout', $is_checkout );
30
+    return apply_filters('wpinv_is_checkout', $is_checkout);
31 31
 }
32 32
 
33 33
 function wpinv_can_checkout() {
34 34
 	$can_checkout = true; // Always true for now
35 35
 
36
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
36
+	return (bool) apply_filters('wpinv_can_checkout', $can_checkout);
37 37
 }
38 38
 
39 39
 function wpinv_get_success_page_uri() {
40
-	$page_id = wpinv_get_option( 'success_page', 0 );
41
-	$page_id = absint( $page_id );
40
+	$page_id = wpinv_get_option('success_page', 0);
41
+	$page_id = absint($page_id);
42 42
 
43
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
43
+	return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id));
44 44
 }
45 45
 
46 46
 function wpinv_get_history_page_uri() {
47
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
48
-	$page_id = absint( $page_id );
47
+	$page_id = wpinv_get_option('invoice_history_page', 0);
48
+	$page_id = absint($page_id);
49 49
 
50
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
50
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id));
51 51
 }
52 52
 
53 53
 function wpinv_is_success_page() {
54
-	$is_success_page = wpinv_get_option( 'success_page', false );
55
-	$is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
54
+	$is_success_page = wpinv_get_option('success_page', false);
55
+	$is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false;
56 56
 
57
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
57
+	return apply_filters('wpinv_is_success_page', $is_success_page);
58 58
 }
59 59
 
60 60
 function wpinv_is_invoice_history_page() {
61
-	$ret = wpinv_get_option( 'invoice_history_page', false );
62
-	$ret = $ret ? is_page( $ret ) : false;
63
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
61
+	$ret = wpinv_get_option('invoice_history_page', false);
62
+	$ret = $ret ? is_page($ret) : false;
63
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
64 64
 }
65 65
 
66 66
 function wpinv_is_subscriptions_history_page() {
67
-    $ret = wpinv_get_option( 'invoice_subscription_page', false );
68
-    $ret = $ret ? is_page( $ret ) : false;
69
-    return apply_filters( 'wpinv_is_subscriptions_history_page', $ret );
67
+    $ret = wpinv_get_option('invoice_subscription_page', false);
68
+    $ret = $ret ? is_page($ret) : false;
69
+    return apply_filters('wpinv_is_subscriptions_history_page', $ret);
70 70
 }
71 71
 
72 72
 /**
73 73
  * Redirects a user the success page.
74 74
  */
75
-function wpinv_send_to_success_page( $args = array() ) {
75
+function wpinv_send_to_success_page($args = array()) {
76 76
     $redirect = add_query_arg(
77
-        wp_parse_args( $args ),
77
+        wp_parse_args($args),
78 78
         wpinv_get_success_page_uri()
79 79
     );
80 80
 
81
-    wp_redirect( $redirect );
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_get_success_page_url( $query_string = null ) {
131
-	$success_page = wpinv_get_option( 'success_page', 0 );
132
-	$success_page = get_permalink( $success_page );
130
+function wpinv_get_success_page_url($query_string = null) {
131
+	$success_page = wpinv_get_option('success_page', 0);
132
+	$success_page = get_permalink($success_page);
133 133
 
134
-	if ( $query_string )
134
+	if ($query_string)
135 135
 		$success_page .= $query_string;
136 136
 
137
-	return apply_filters( 'wpinv_success_page_url', $success_page );
137
+	return apply_filters('wpinv_success_page_url', $success_page);
138 138
 }
139 139
 
140
-function wpinv_get_failed_transaction_uri( $extras = false ) {
141
-	$uri = wpinv_get_option( 'failure_page', '' );
142
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
140
+function wpinv_get_failed_transaction_uri($extras = false) {
141
+	$uri = wpinv_get_option('failure_page', '');
142
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
143 143
 
144
-	if ( $extras )
144
+	if ($extras)
145 145
 		$uri .= $extras;
146 146
 
147
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
147
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
148 148
 }
149 149
 
150 150
 function wpinv_is_failed_transaction_page() {
151
-	$ret = wpinv_get_option( 'failure_page', false );
152
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
151
+	$ret = wpinv_get_option('failure_page', false);
152
+	$ret = isset($ret) ? is_page($ret) : false;
153 153
 
154
-	return apply_filters( 'wpinv_is_failure_page', $ret );
154
+	return apply_filters('wpinv_is_failure_page', $ret);
155 155
 }
156 156
 
157
-function wpinv_transaction_query( $type = 'start' ) {
157
+function wpinv_transaction_query($type = 'start') {
158 158
     global $wpdb;
159 159
 
160 160
     $wpdb->hide_errors();
161 161
 
162
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
163
-        define( 'WPINV_USE_TRANSACTIONS', true );
162
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
163
+        define('WPINV_USE_TRANSACTIONS', true);
164 164
     }
165 165
 
166
-    if ( WPINV_USE_TRANSACTIONS ) {
167
-        switch ( $type ) {
166
+    if (WPINV_USE_TRANSACTIONS) {
167
+        switch ($type) {
168 168
             case 'commit' :
169
-                $wpdb->query( 'COMMIT' );
169
+                $wpdb->query('COMMIT');
170 170
                 break;
171 171
             case 'rollback' :
172
-                $wpdb->query( 'ROLLBACK' );
172
+                $wpdb->query('ROLLBACK');
173 173
                 break;
174 174
             default :
175
-                $wpdb->query( 'START TRANSACTION' );
175
+                $wpdb->query('START TRANSACTION');
176 176
             break;
177 177
         }
178 178
     }
@@ -181,141 +181,141 @@  discard block
 block discarded – undo
181 181
 function wpinv_get_prefix() {
182 182
     $invoice_prefix = 'INV-';
183 183
     
184
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
184
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
185 185
 }
186 186
 
187 187
 function wpinv_get_business_logo() {
188
-    $business_logo = wpinv_get_option( 'logo' );
189
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
188
+    $business_logo = wpinv_get_option('logo');
189
+    return apply_filters('wpinv_get_business_logo', $business_logo);
190 190
 }
191 191
 
192 192
 function wpinv_get_business_name() {
193 193
     $business_name = wpinv_get_option('store_name');
194
-    return apply_filters( 'wpinv_get_business_name', $business_name );
194
+    return apply_filters('wpinv_get_business_name', $business_name);
195 195
 }
196 196
 
197 197
 function wpinv_get_blogname() {
198
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
198
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
199 199
 }
200 200
 
201 201
 function wpinv_get_admin_email() {
202
-    $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) );
203
-    return apply_filters( 'wpinv_admin_email', $admin_email );
202
+    $admin_email = wpinv_get_option('admin_email', get_option('admin_email'));
203
+    return apply_filters('wpinv_admin_email', $admin_email);
204 204
 }
205 205
 
206 206
 function wpinv_get_business_website() {
207
-    $business_website = home_url( '/' );
208
-    return apply_filters( 'wpinv_get_business_website', $business_website );
207
+    $business_website = home_url('/');
208
+    return apply_filters('wpinv_get_business_website', $business_website);
209 209
 }
210 210
 
211
-function wpinv_get_terms_text( $invoice_id = 0 ) {
211
+function wpinv_get_terms_text($invoice_id = 0) {
212 212
     $terms_text = '';
213
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
213
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
214 214
 }
215 215
 
216 216
 function wpinv_get_business_footer() {
217
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
218
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
219
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
217
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
218
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
219
+    return apply_filters('wpinv_get_business_footer', $business_footer);
220 220
 }
221 221
 
222 222
 function wpinv_checkout_required_fields() {
223 223
     $required_fields = array();
224 224
     
225 225
     // Let payment gateways and other extensions determine if address fields should be required
226
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
226
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
227 227
     
228
-    if ( $require_billing_details ) {
229
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
228
+    if ($require_billing_details) {
229
+		if ((bool) wpinv_get_option('fname_mandatory')) {
230 230
 			$required_fields['first_name'] = array(
231 231
 				'error_id' => 'invalid_first_name',
232
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
232
+				'error_message' => __('Please enter your first name', 'invoicing')
233 233
 			);
234 234
 		}
235
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
235
+		if ((bool) wpinv_get_option('address_mandatory')) {
236 236
 			$required_fields['address'] = array(
237 237
 				'error_id' => 'invalid_address',
238
-				'error_message' => __( 'Please enter your address', 'invoicing' )
238
+				'error_message' => __('Please enter your address', 'invoicing')
239 239
 			);
240 240
 		}
241
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
241
+		if ((bool) wpinv_get_option('city_mandatory')) {
242 242
 			$required_fields['city'] = array(
243 243
 				'error_id' => 'invalid_city',
244
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
244
+				'error_message' => __('Please enter your billing city', 'invoicing')
245 245
 			);
246 246
 		}
247
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
247
+		if ((bool) wpinv_get_option('state_mandatory')) {
248 248
 			$required_fields['state'] = array(
249 249
 				'error_id' => 'invalid_state',
250
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
250
+				'error_message' => __('Please enter billing state / province', 'invoicing')
251 251
 			);
252 252
 		}
253
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
253
+		if ((bool) wpinv_get_option('country_mandatory')) {
254 254
 			$required_fields['country'] = array(
255 255
 				'error_id' => 'invalid_country',
256
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
256
+				'error_message' => __('Please select your billing country', 'invoicing')
257 257
 			);
258 258
 		}
259 259
     }
260 260
 
261
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
261
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
262 262
 }
263 263
 
264 264
 function wpinv_is_ssl_enforced() {
265
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
266
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
265
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
266
+    return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
267 267
 }
268 268
 
269 269
 function wpinv_schedule_event_twicedaily() {
270 270
     wpinv_email_payment_reminders();
271 271
 }
272
-add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' );
272
+add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily');
273 273
 
274 274
 function wpinv_require_login_to_checkout() {
275
-    $return = wpinv_get_option( 'login_to_checkout', false );
276
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
275
+    $return = wpinv_get_option('login_to_checkout', false);
276
+    return (bool) apply_filters('wpinv_require_login_to_checkout', $return);
277 277
 }
278 278
 
279
-function wpinv_sequential_number_active( $type = '' ) {
280
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
281
-    if ( null !== $check ) {
279
+function wpinv_sequential_number_active($type = '') {
280
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
281
+    if (null !== $check) {
282 282
         return $check;
283 283
     }
284 284
     
285
-    return wpinv_get_option( 'sequential_invoice_number' );
285
+    return wpinv_get_option('sequential_invoice_number');
286 286
 }
287 287
 
288
-function wpinv_switch_to_locale( $locale = NULL ) {
288
+function wpinv_switch_to_locale($locale = NULL) {
289 289
     global $invoicing, $wpi_switch_locale;
290 290
 
291
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
292
-        $locale = empty( $locale ) ? get_locale() : $locale;
291
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
292
+        $locale = empty($locale) ? get_locale() : $locale;
293 293
 
294
-        switch_to_locale( $locale );
294
+        switch_to_locale($locale);
295 295
 
296 296
         $wpi_switch_locale = $locale;
297 297
 
298
-        add_filter( 'plugin_locale', 'get_locale' );
298
+        add_filter('plugin_locale', 'get_locale');
299 299
 
300 300
         $invoicing->load_textdomain();
301 301
 
302
-        do_action( 'wpinv_switch_to_locale', $locale );
302
+        do_action('wpinv_switch_to_locale', $locale);
303 303
     }
304 304
 }
305 305
 
306 306
 function wpinv_restore_locale() {
307 307
     global $invoicing, $wpi_switch_locale;
308 308
     
309
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
309
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
310 310
         restore_previous_locale();
311 311
 
312 312
         $wpi_switch_locale = NULL;
313 313
 
314
-        remove_filter( 'plugin_locale', 'get_locale' );
314
+        remove_filter('plugin_locale', 'get_locale');
315 315
 
316 316
         $invoicing->load_textdomain();
317 317
 
318
-        do_action( 'wpinv_restore_locale' );
318
+        do_action('wpinv_restore_locale');
319 319
     }
320 320
 }
321 321
 
@@ -323,22 +323,22 @@  discard block
 block discarded – undo
323 323
  * Returns the default form's id.
324 324
  */
325 325
 function wpinv_get_default_payment_form() {
326
-    $form = get_option( 'wpinv_default_payment_form' );
326
+    $form = get_option('wpinv_default_payment_form');
327 327
 
328
-    if ( empty( $form ) || 'publish' != get_post_status( $form ) ) {
328
+    if (empty($form) || 'publish' != get_post_status($form)) {
329 329
         $form = wp_insert_post(
330 330
             array(
331 331
                 'post_type'   => 'wpi_payment_form',
332
-                'post_title'  => __( 'Checkout (default)', 'invoicing' ),
332
+                'post_title'  => __('Checkout (default)', 'invoicing'),
333 333
                 'post_status' => 'publish',
334 334
                 'meta_input'  => array(
335
-                    'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ),
335
+                    'wpinv_form_elements' => wpinv_get_data('default-payment-form'),
336 336
                     'wpinv_form_items'    => array(),
337 337
                 )
338 338
             )
339 339
         );
340 340
 
341
-        update_option( 'wpinv_default_payment_form', $form );
341
+        update_option('wpinv_default_payment_form', $form);
342 342
     }
343 343
 
344 344
     return $form;
@@ -349,19 +349,19 @@  discard block
 block discarded – undo
349 349
  * 
350 350
  * @param int $payment_form
351 351
  */
352
-function getpaid_get_payment_form_elements( $payment_form ) {
352
+function getpaid_get_payment_form_elements($payment_form) {
353 353
 
354
-    if ( empty( $payment_form ) ) {
355
-        return wpinv_get_data( 'sample-payment-form' );
354
+    if (empty($payment_form)) {
355
+        return wpinv_get_data('sample-payment-form');
356 356
     }
357 357
 
358
-    $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true );
358
+    $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true);
359 359
 
360
-    if ( is_array( $form_elements ) ) {
360
+    if (is_array($form_elements)) {
361 361
         return $form_elements;
362 362
     }
363 363
 
364
-    return wpinv_get_data( 'sample-payment-form' );
364
+    return wpinv_get_data('sample-payment-form');
365 365
 
366 366
 }
367 367
 
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
  * 
371 371
  * @param int $payment_form
372 372
  */
373
-function gepaid_get_form_items( $id ) {
374
-    $form = new GetPaid_Payment_Form( $id );
373
+function gepaid_get_form_items($id) {
374
+    $form = new GetPaid_Payment_Form($id);
375 375
 
376 376
     // Is this a default form?
377
-    if ( $form->is_default() ) {
377
+    if ($form->is_default()) {
378 378
         return array();
379 379
     }
380 380
 
381
-    return $form->get_items( 'view', 'arrays' );
381
+    return $form->get_items('view', 'arrays');
382 382
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
     /**
31 31
 	 * Class constructor.
32 32
 	 */
33
-	public function __construct(){
33
+	public function __construct() {
34 34
 
35
-        $this->admin_path  = plugin_dir_path( __FILE__ );
36
-        $this->admin_url   = plugins_url( '/', __FILE__ );
35
+        $this->admin_path  = plugin_dir_path(__FILE__);
36
+        $this->admin_url   = plugins_url('/', __FILE__);
37 37
 
38
-        if ( is_admin() ) {
38
+        if (is_admin()) {
39 39
 			$this->init_admin_hooks();
40 40
         }
41 41
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 */
48 48
 	private function init_admin_hooks() {
49
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
50
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
51
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
52
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
53
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
54
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
55
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
56
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
57
-		do_action( 'getpaid_init_admin_hooks', $this );
49
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
50
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
51
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
52
+        add_action('admin_init', array($this, 'activation_redirect'));
53
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
54
+		add_action('admin_notices', array($this, 'show_notices'));
55
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
56
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
57
+		do_action('getpaid_init_admin_hooks', $this);
58 58
 
59 59
     }
60 60
 
@@ -65,49 +65,49 @@  discard block
 block discarded – undo
65 65
 	public function enqeue_scripts() {
66 66
         global $current_screen, $pagenow;
67 67
 
68
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
68
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
69 69
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
70 70
 
71
-        if ( ! empty( $current_screen->post_type ) ) {
71
+        if (!empty($current_screen->post_type)) {
72 72
 			$page = $current_screen->post_type;
73 73
         }
74 74
 
75 75
         // General styles.
76
-        if ( false !== stripos( $page, 'wpi' ) ) {
76
+        if (false !== stripos($page, 'wpi')) {
77 77
 
78 78
             // Styles.
79
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
80
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
81
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
82
-            wp_enqueue_style( 'wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
83
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
79
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
80
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
81
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
82
+            wp_enqueue_style('wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
83
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
84 84
 
85 85
             // Scripts.
86
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
87
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
86
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
87
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
88 88
 
89
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
90
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
91
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
89
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
90
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
91
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
92 92
 
93 93
         }
94 94
 
95 95
         // Payment form scripts.
96
-		if ( 'wpi_payment_form' == $page && $editing ) {
96
+		if ('wpi_payment_form' == $page && $editing) {
97 97
             $this->load_payment_form_scripts();
98 98
         }
99 99
 
100
-        if ( $page == 'wpinv-subscriptions' ) {
101
-			wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
102
-			wp_enqueue_script( 'wpinv-sub-admin-script' );
100
+        if ($page == 'wpinv-subscriptions') {
101
+			wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
102
+			wp_enqueue_script('wpinv-sub-admin-script');
103 103
 		}
104 104
 
105
-		if ( $page == 'wpinv-reports' ) {
106
-			wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
105
+		if ($page == 'wpinv-reports') {
106
+			wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
107 107
 		}
108 108
 
109
-		if ( $page == 'wpinv-subscriptions' ) {
110
-			wp_enqueue_script( 'postbox' );
109
+		if ($page == 'wpinv-subscriptions') {
110
+			wp_enqueue_script('postbox');
111 111
 		}
112 112
 
113 113
     }
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         global $post;
121 121
 
122 122
         return array(
123
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
124
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
125
-            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
126
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
127
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
128
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
129
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
123
+            'ajax_url'                  => admin_url('admin-ajax.php'),
124
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
125
+            'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
126
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
127
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
128
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
129
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
130 130
             'tax'                       => wpinv_tax_amount(),
131 131
             'discount'                  => wpinv_discount_amount(),
132 132
             'currency_symbol'           => wpinv_currency_symbol(),
@@ -134,24 +134,24 @@  discard block
 block discarded – undo
134 134
             'thousand_sep'              => wpinv_thousands_separator(),
135 135
             'decimal_sep'               => wpinv_decimal_separator(),
136 136
             'decimals'                  => wpinv_decimals(),
137
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
138
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
139
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
140
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
141
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
142
-            'OneItemMin'                => __( 'Invoice must contain at least one item', 'invoicing' ),
143
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
144
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
145
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
146
-            'emptyInvoice'              => __( 'Add at least one item to save invoice!', 'invoicing' ),
147
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
148
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
149
-            'action_edit'               => __( 'Edit', 'invoicing' ),
150
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
151
-            'item_description'          => __( 'Item Description', 'invoicing' ),
152
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
153
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
154
-            'searching'                 => __( 'Searching', 'invoicing' ),
137
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
138
+            'status_publish'            => wpinv_status_nicename('publish'),
139
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
140
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
141
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
142
+            'OneItemMin'                => __('Invoice must contain at least one item', 'invoicing'),
143
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
144
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
145
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
146
+            'emptyInvoice'              => __('Add at least one item to save invoice!', 'invoicing'),
147
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
148
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
149
+            'action_edit'               => __('Edit', 'invoicing'),
150
+            'action_cancel'             => __('Cancel', 'invoicing'),
151
+            'item_description'          => __('Item Description', 'invoicing'),
152
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
153
+            'discount_description'      => __('Discount Description', 'invoicing'),
154
+            'searching'                 => __('Searching', 'invoicing'),
155 155
         );
156 156
 
157 157
     }
@@ -163,30 +163,30 @@  discard block
 block discarded – undo
163 163
 	protected function load_payment_form_scripts() {
164 164
         global $post;
165 165
 
166
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
167
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
168
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
166
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
167
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
168
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
169 169
 
170
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
171
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
170
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
171
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
172 172
 
173 173
 		wp_localize_script(
174 174
             'wpinv-admin-payment-form-script',
175 175
             'wpinvPaymentFormAdmin',
176 176
             array(
177
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
178
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
177
+				'elements'      => wpinv_get_data('payment-form-elements'),
178
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
179 179
 				'currency'      => wpinv_currency_symbol(),
180 180
 				'position'      => wpinv_currency_position(),
181 181
 				'decimals'      => (int) wpinv_decimals(),
182 182
 				'thousands_sep' => wpinv_thousands_separator(),
183 183
 				'decimals_sep'  => wpinv_decimal_separator(),
184
-				'form_items'    => gepaid_get_form_items( $post->ID ),
184
+				'form_items'    => gepaid_get_form_items($post->ID),
185 185
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
186 186
             )
187 187
         );
188 188
 
189
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
189
+        wp_enqueue_script('wpinv-admin-payment-form-script');
190 190
 
191 191
     }
192 192
 
@@ -197,25 +197,25 @@  discard block
 block discarded – undo
197 197
      * @return string
198 198
 	 *
199 199
 	 */
200
-    public function admin_body_class( $classes ) {
200
+    public function admin_body_class($classes) {
201 201
 		global $pagenow, $post, $current_screen;
202 202
 
203 203
 
204
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
204
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
205 205
 
206
-        if ( ! empty( $current_screen->post_type ) ) {
206
+        if (!empty($current_screen->post_type)) {
207 207
 			$page = $current_screen->post_type;
208 208
         }
209 209
 
210
-        if ( false !== stripos( $page, 'wpi' ) ) {
211
-            $classes .= ' wpi-' . sanitize_key( $page );
210
+        if (false !== stripos($page, 'wpi')) {
211
+            $classes .= ' wpi-' . sanitize_key($page);
212 212
         }
213 213
 
214
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
214
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
215 215
             $classes .= ' wpinv-cpt wpinv';
216 216
         }
217 217
 
218
-		if ( $pagenow == 'post.php' && $page == 'wpi_item' && ! empty( $post ) && ! wpinv_item_is_editable( $post ) ) {
218
+		if ($pagenow == 'post.php' && $page == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
219 219
 			$classes .= ' wpi-editable-n';
220 220
 		}
221 221
 
@@ -225,19 +225,19 @@  discard block
 block discarded – undo
225 225
     /**
226 226
 	 * Maybe show the AyeCode Connect Notice.
227 227
 	 */
228
-	public function init_ayecode_connect_helper(){
228
+	public function init_ayecode_connect_helper() {
229 229
 
230 230
         new AyeCode_Connect_Helper(
231 231
             array(
232
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
233
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
234
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
235
-				'connect_button'    => __("Connect Site","invoicing"),
236
-				'connecting_button'    => __("Connecting...","invoicing"),
237
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
238
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
232
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
233
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
234
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
235
+				'connect_button'    => __("Connect Site", "invoicing"),
236
+				'connecting_button'    => __("Connecting...", "invoicing"),
237
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
238
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
239 239
             ),
240
-            array( 'wpi-addons' )
240
+            array('wpi-addons')
241 241
         );
242 242
 
243 243
     }
@@ -248,19 +248,19 @@  discard block
 block discarded – undo
248 248
     public function activation_redirect() {
249 249
 
250 250
 		// Bail if no activation redirect.
251
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
251
+		if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) {
252 252
 			return;
253 253
 		}
254 254
 
255 255
 		// Delete the redirect transient.
256
-		delete_transient( '_wpinv_activation_redirect' );
256
+		delete_transient('_wpinv_activation_redirect');
257 257
 
258 258
 		// Bail if activating from network, or bulk
259
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
259
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
260 260
 			return;
261 261
 		}
262 262
 
263
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
263
+		wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
264 264
 		exit;
265 265
     }
266 266
 
@@ -269,9 +269,9 @@  discard block
 block discarded – undo
269 269
      */
270 270
     public function maybe_do_admin_action() {
271 271
 
272
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
273
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
274
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
272
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
273
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
274
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
275 275
         }
276 276
 
277 277
     }
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 	 * 
282 282
 	 * @param array $args
283 283
      */
284
-    public function send_customer_invoice( $args ) {
285
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
284
+    public function send_customer_invoice($args) {
285
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
286 286
 
287
-		if ( $sent ) {
288
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
287
+		if ($sent) {
288
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
289 289
 		} else {
290
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
290
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
291 291
 		}
292 292
 
293
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
293
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
294 294
 		exit;
295 295
 	}
296 296
 
@@ -299,16 +299,16 @@  discard block
 block discarded – undo
299 299
 	 * 
300 300
 	 * @param array $args
301 301
      */
302
-    public function send_customer_payment_reminder( $args ) {
303
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
302
+    public function send_customer_payment_reminder($args) {
303
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
304 304
 
305
-		if ( $sent ) {
306
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
305
+		if ($sent) {
306
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
307 307
 		} else {
308
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
308
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
309 309
 		}
310 310
 
311
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
311
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
312 312
 		exit;
313 313
 	}
314 314
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
      * @return array
320 320
 	 */
321 321
 	public function get_notices() {
322
-		$notices = get_option( 'wpinv_admin_notices' );
323
-        return is_array( $notices ) ? $notices : array();
322
+		$notices = get_option('wpinv_admin_notices');
323
+        return is_array($notices) ? $notices : array();
324 324
 	}
325 325
 
326 326
 	/**
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @since       1.0.19
331 331
 	 */
332 332
 	public function clear_notices() {
333
-		delete_option( 'wpinv_admin_notices' );
333
+		delete_option('wpinv_admin_notices');
334 334
 	}
335 335
 
336 336
 	/**
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 	 * @access      public
340 340
 	 * @since       1.0.19
341 341
 	 */
342
-	public function save_notice( $type, $message ) {
342
+	public function save_notice($type, $message) {
343 343
 		$notices = $this->get_notices();
344 344
 
345
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
346
-			$notices[ $type ] = array();
345
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
346
+			$notices[$type] = array();
347 347
 		}
348 348
 
349
-		$notices[ $type ][] = $message;
349
+		$notices[$type][] = $message;
350 350
 
351
-		update_option( 'wpinv_admin_notices', $notices );
351
+		update_option('wpinv_admin_notices', $notices);
352 352
 	}
353 353
 
354 354
 	/**
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 * @access      public
359 359
 	 * @since       1.0.19
360 360
 	 */
361
-	public function show_success( $msg ) {
362
-		$this->save_notice( 'success', $msg );
361
+	public function show_success($msg) {
362
+		$this->save_notice('success', $msg);
363 363
 	}
364 364
 
365 365
 	/**
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 * @param       string $msg The message to qeue.
370 370
 	 * @since       1.0.19
371 371
 	 */
372
-	public function show_error( $msg ) {
373
-		$this->save_notice( 'error', $msg );
372
+	public function show_error($msg) {
373
+		$this->save_notice('error', $msg);
374 374
 	}
375 375
 
376 376
 	/**
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 	 * @param       string $msg The message to qeue.
381 381
 	 * @since       1.0.19
382 382
 	 */
383
-	public function show_warning( $msg ) {
384
-		$this->save_notice( 'warning', $msg );
383
+	public function show_warning($msg) {
384
+		$this->save_notice('warning', $msg);
385 385
 	}
386 386
 
387 387
 	/**
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 	 * @param       string $msg The message to qeue.
392 392
 	 * @since       1.0.19
393 393
 	 */
394
-	public function show_info( $msg ) {
395
-		$this->save_notice( 'info', $msg );
394
+	public function show_info($msg) {
395
+		$this->save_notice('info', $msg);
396 396
 	}
397 397
 
398 398
 	/**
@@ -406,15 +406,15 @@  discard block
 block discarded – undo
406 406
         $notices = $this->get_notices();
407 407
         $this->clear_notices();
408 408
 
409
-		foreach ( $notices as $type => $messages ) {
409
+		foreach ($notices as $type => $messages) {
410 410
 
411
-			if ( ! is_array( $messages ) ) {
411
+			if (!is_array($messages)) {
412 412
 				continue;
413 413
 			}
414 414
 
415
-            $type  = sanitize_key( $type );
416
-			foreach ( $messages as $message ) {
417
-                $message = wp_kses_post( $message );
415
+            $type = sanitize_key($type);
416
+			foreach ($messages as $message) {
417
+                $message = wp_kses_post($message);
418 418
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
419 419
             }
420 420
 
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 1 patch
Spacing   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  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
 /**
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
  * 
19 19
  * @return bool
20 20
  */
21
-function getpaid_is_eu_state( $country ) {
22
-    return WPInv_EUVat::is_eu_state( $country );
21
+function getpaid_is_eu_state($country) {
22
+    return WPInv_EUVat::is_eu_state($country);
23 23
 }
24 24
 
25 25
 /**
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
  * 
28 28
  * @return bool
29 29
  */
30
-function getpaid_is_gst_country( $country ) {
31
-    return WPInv_EUVat::is_gst_country( $country );
30
+function getpaid_is_gst_country($country) {
31
+    return WPInv_EUVat::is_gst_country($country);
32 32
 }
33 33
 
34 34
 /**
@@ -42,117 +42,117 @@  discard block
 block discarded – undo
42 42
 
43 43
 
44 44
 function wpinv_use_taxes() {
45
-    $ret = wpinv_get_option( 'enable_taxes', false );
45
+    $ret = wpinv_get_option('enable_taxes', false);
46 46
     
47
-    return (bool) apply_filters( 'wpinv_use_taxes', $ret );
47
+    return (bool) apply_filters('wpinv_use_taxes', $ret);
48 48
 }
49 49
 
50 50
 function wpinv_get_tax_rates() {
51
-    $rates = get_option( 'wpinv_tax_rates', array() );
51
+    $rates = get_option('wpinv_tax_rates', array());
52 52
     
53
-    return apply_filters( 'wpinv_get_tax_rates', $rates );
53
+    return apply_filters('wpinv_get_tax_rates', $rates);
54 54
 }
55 55
 
56
-function wpinv_get_tax_rate( $country = false, $state = false, $item_id = 0 ) {
56
+function wpinv_get_tax_rate($country = false, $state = false, $item_id = 0) {
57 57
     global $wpinv_euvat, $wpi_tax_rates, $wpi_userID;
58
-    $wpi_tax_rates = !empty( $wpi_tax_rates ) ? $wpi_tax_rates : array();
58
+    $wpi_tax_rates = !empty($wpi_tax_rates) ? $wpi_tax_rates : array();
59 59
     
60
-    if ( !empty( $wpi_tax_rates ) && !empty( $item_id ) && isset( $wpi_tax_rates[$item_id] ) ) {
60
+    if (!empty($wpi_tax_rates) && !empty($item_id) && isset($wpi_tax_rates[$item_id])) {
61 61
         return $wpi_tax_rates[$item_id];
62 62
     }
63 63
     
64
-    if ( !$wpinv_euvat->item_is_taxable( $item_id, $country, $state ) ) {
64
+    if (!$wpinv_euvat->item_is_taxable($item_id, $country, $state)) {
65 65
         $wpi_tax_rates[$item_id] = 0;
66 66
         return 0;
67 67
     }
68 68
 
69 69
     $is_global = false;
70
-    if ( $item_id == 'global' ) {
70
+    if ($item_id == 'global') {
71 71
         $is_global = true;
72 72
         $item_id = 0;
73 73
     }
74 74
     
75
-    $rate           = (float)wpinv_get_option( 'tax_rate', 0 );
76
-    $user_address   = wpinv_get_user_address( $wpi_userID );
75
+    $rate           = (float) wpinv_get_option('tax_rate', 0);
76
+    $user_address   = wpinv_get_user_address($wpi_userID);
77 77
     
78
-    if( empty( $country ) ) {
79
-        if( !empty( $_POST['wpinv_country'] ) ) {
78
+    if (empty($country)) {
79
+        if (!empty($_POST['wpinv_country'])) {
80 80
             $country = $_POST['wpinv_country'];
81
-        } elseif( !empty( $_POST['wpinv_country'] ) ) {
81
+        } elseif (!empty($_POST['wpinv_country'])) {
82 82
             $country = $_POST['wpinv_country'];
83
-        } elseif( !empty( $_POST['country'] ) ) {
83
+        } elseif (!empty($_POST['country'])) {
84 84
             $country = $_POST['country'];
85
-        } elseif( is_user_logged_in() && !empty( $user_address ) ) {
85
+        } elseif (is_user_logged_in() && !empty($user_address)) {
86 86
             $country = $user_address['country'];
87 87
         }
88
-        $country = !empty( $country ) ? $country : wpinv_get_default_country();
88
+        $country = !empty($country) ? $country : wpinv_get_default_country();
89 89
     }
90 90
 
91
-    if( empty( $state ) ) {
92
-        if( !empty( $_POST['wpinv_state'] ) ) {
91
+    if (empty($state)) {
92
+        if (!empty($_POST['wpinv_state'])) {
93 93
             $state = $_POST['wpinv_state'];
94
-        } elseif( !empty( $_POST['wpinv_state'] ) ) {
94
+        } elseif (!empty($_POST['wpinv_state'])) {
95 95
             $state = $_POST['wpinv_state'];
96
-        } elseif( !empty( $_POST['state'] ) ) {
96
+        } elseif (!empty($_POST['state'])) {
97 97
             $state = $_POST['state'];
98
-        } elseif( is_user_logged_in() && !empty( $user_address ) ) {
98
+        } elseif (is_user_logged_in() && !empty($user_address)) {
99 99
             $state = $user_address['state'];
100 100
         }
101
-        $state = !empty( $state ) ? $state : wpinv_get_default_state();
101
+        $state = !empty($state) ? $state : wpinv_get_default_state();
102 102
     }
103 103
     
104
-    if( !empty( $country ) ) {
105
-        $tax_rates   = wpinv_get_tax_rates();
104
+    if (!empty($country)) {
105
+        $tax_rates = wpinv_get_tax_rates();
106 106
 
107
-        if( !empty( $tax_rates ) ) {
107
+        if (!empty($tax_rates)) {
108 108
             // Locate the tax rate for this country / state, if it exists
109
-            foreach( $tax_rates as $key => $tax_rate ) {
110
-                if( $country != $tax_rate['country'] )
109
+            foreach ($tax_rates as $key => $tax_rate) {
110
+                if ($country != $tax_rate['country'])
111 111
                     continue;
112 112
 
113
-                if( !empty( $tax_rate['global'] ) ) {
114
-                    if( !empty( $tax_rate['rate'] ) ) {
115
-                        $rate = number_format( $tax_rate['rate'], 4 );
113
+                if (!empty($tax_rate['global'])) {
114
+                    if (!empty($tax_rate['rate'])) {
115
+                        $rate = number_format($tax_rate['rate'], 4);
116 116
                     }
117 117
                 } else {
118 118
 
119
-                    if( empty( $tax_rate['state'] ) || strtolower( $state ) != strtolower( $tax_rate['state'] ) )
119
+                    if (empty($tax_rate['state']) || strtolower($state) != strtolower($tax_rate['state']))
120 120
                         continue;
121 121
 
122 122
                     $state_rate = $tax_rate['rate'];
123
-                    if( 0 !== $state_rate || !empty( $state_rate ) ) {
124
-                        $rate = number_format( $state_rate, 4 );
123
+                    if (0 !== $state_rate || !empty($state_rate)) {
124
+                        $rate = number_format($state_rate, 4);
125 125
                     }
126 126
                 }
127 127
             }
128 128
         }
129 129
     }
130 130
     
131
-    $rate = apply_filters( 'wpinv_tax_rate', $rate, $country, $state, $item_id );
131
+    $rate = apply_filters('wpinv_tax_rate', $rate, $country, $state, $item_id);
132 132
     
133
-    if ( !empty( $item_id ) ) {
133
+    if (!empty($item_id)) {
134 134
         $wpi_tax_rates[$item_id] = $rate;
135
-    } else if ( $is_global ) {
135
+    } else if ($is_global) {
136 136
         $wpi_tax_rates['global'] = $rate;
137 137
     }
138 138
     
139 139
     return $rate;
140 140
 }
141 141
 
142
-function wpinv_get_formatted_tax_rate( $country = false, $state = false, $item_id ) {
143
-    $rate = wpinv_get_tax_rate( $country, $state, $item_id );
144
-    $rate = round( $rate, 4 );
142
+function wpinv_get_formatted_tax_rate($country = false, $state = false, $item_id) {
143
+    $rate = wpinv_get_tax_rate($country, $state, $item_id);
144
+    $rate = round($rate, 4);
145 145
     $formatted = $rate .= '%';
146
-    return apply_filters( 'wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id );
146
+    return apply_filters('wpinv_formatted_tax_rate', $formatted, $rate, $country, $state, $item_id);
147 147
 }
148 148
 
149
-function wpinv_calculate_tax( $amount = 0, $country = false, $state = false, $item_id = 0 ) {
150
-    $rate = wpinv_get_tax_rate( $country, $state, $item_id );
149
+function wpinv_calculate_tax($amount = 0, $country = false, $state = false, $item_id = 0) {
150
+    $rate = wpinv_get_tax_rate($country, $state, $item_id);
151 151
     $tax  = 0.00;
152 152
 
153
-    if ( wpinv_use_taxes() ) {        
154
-        if ( wpinv_prices_include_tax() ) {
155
-            $pre_tax = ( $amount / ( ( 1 + $rate ) * 0.01 ) );
153
+    if (wpinv_use_taxes()) {        
154
+        if (wpinv_prices_include_tax()) {
155
+            $pre_tax = ($amount / ((1 + $rate) * 0.01));
156 156
             $tax     = $amount - $pre_tax;
157 157
         } else {
158 158
             $tax = $amount * $rate * 0.01;
@@ -160,46 +160,46 @@  discard block
 block discarded – undo
160 160
 
161 161
     }
162 162
 
163
-    return apply_filters( 'wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id );
163
+    return apply_filters('wpinv_taxed_amount', $tax, $rate, $country, $state, $item_id);
164 164
 }
165 165
 
166 166
 function wpinv_prices_include_tax() {
167 167
     return false; // TODO
168
-    $ret = ( wpinv_get_option( 'prices_include_tax', false ) == 'yes' && wpinv_use_taxes() );
168
+    $ret = (wpinv_get_option('prices_include_tax', false) == 'yes' && wpinv_use_taxes());
169 169
 
170
-    return apply_filters( 'wpinv_prices_include_tax', $ret );
170
+    return apply_filters('wpinv_prices_include_tax', $ret);
171 171
 }
172 172
 
173
-function wpinv_sales_tax_for_year( $year = null ) {
174
-    return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) );
173
+function wpinv_sales_tax_for_year($year = null) {
174
+    return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year)));
175 175
 }
176 176
 
177
-function wpinv_get_sales_tax_for_year( $year = null ) {
177
+function wpinv_get_sales_tax_for_year($year = null) {
178 178
     global $wpdb;
179 179
 
180 180
     // Start at zero
181 181
     $tax = 0;
182 182
 
183
-    if ( ! empty( $year ) ) {
183
+    if (!empty($year)) {
184 184
         $args = array(
185 185
             'post_type'      => 'wpi_invoice',
186
-            'post_status'    => array( 'publish' ),
186
+            'post_status'    => array('publish'),
187 187
             'posts_per_page' => -1,
188 188
             'year'           => $year,
189 189
             'fields'         => 'ids'
190 190
         );
191 191
 
192
-        $payments    = get_posts( $args );
193
-        $payment_ids = implode( ',', $payments );
192
+        $payments    = get_posts($args);
193
+        $payment_ids = implode(',', $payments);
194 194
 
195
-        if ( count( $payments ) > 0 ) {
195
+        if (count($payments) > 0) {
196 196
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
197
-            $tax = $wpdb->get_var( $sql );
197
+            $tax = $wpdb->get_var($sql);
198 198
         }
199 199
 
200 200
     }
201 201
 
202
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
202
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
203 203
 }
204 204
 
205 205
 function wpinv_is_cart_taxed() {
@@ -208,33 +208,33 @@  discard block
 block discarded – undo
208 208
 
209 209
 function wpinv_prices_show_tax_on_checkout() {
210 210
     return false; // TODO
211
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
211
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
212 212
 
213
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
213
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
214 214
 }
215 215
 
216 216
 function wpinv_display_tax_rate() {
217
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
217
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
218 218
 
219
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
219
+    return apply_filters('wpinv_display_tax_rate', $ret);
220 220
 }
221 221
 
222 222
 function wpinv_cart_needs_tax_address_fields() {
223
-    if( !wpinv_is_cart_taxed() )
223
+    if (!wpinv_is_cart_taxed())
224 224
         return false;
225 225
 
226
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
226
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
227 227
 }
228 228
 
229
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
230
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
231
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
229
+function wpinv_item_is_tax_exclusive($item_id = 0) {
230
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
231
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
232 232
 }
233 233
 
234
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
234
+function wpinv_currency_decimal_filter($decimals = 2) {
235 235
     $currency = wpinv_get_currency();
236 236
 
237
-    switch ( $currency ) {
237
+    switch ($currency) {
238 238
         case 'RIAL' :
239 239
         case 'JPY' :
240 240
         case 'TWD' :
@@ -243,50 +243,50 @@  discard block
 block discarded – undo
243 243
             break;
244 244
     }
245 245
 
246
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
246
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
247 247
 }
248 248
 
249 249
 function wpinv_tax_amount() {
250 250
     $output = 0.00;
251 251
     
252
-    return apply_filters( 'wpinv_tax_amount', $output );
252
+    return apply_filters('wpinv_tax_amount', $output);
253 253
 }
254 254
 
255 255
 // VAT Settings
256
-function wpinv_vat_rate_add_callback( $args ) {
256
+function wpinv_vat_rate_add_callback($args) {
257 257
     ?>
258
-    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e( 'Add', 'invoicing' );?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
258
+    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_add" type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
259 259
     <?php
260 260
 }
261 261
 
262
-function wpinv_vat_rate_delete_callback( $args ) {
262
+function wpinv_vat_rate_delete_callback($args) {
263 263
     global $wpinv_euvat;
264 264
     
265 265
     $vat_classes = $wpinv_euvat->get_rate_classes();
266
-    $vat_class = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '';
267
-    if ( isset( $vat_classes[$vat_class] ) ) {
266
+    $vat_class = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '';
267
+    if (isset($vat_classes[$vat_class])) {
268 268
     ?>
269
-    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf( esc_attr__( 'Delete class "%s"', 'invoicing' ), $vat_classes[$vat_class] );?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
269
+    <p class="wpi-vat-rate-actions"><input id="wpi_vat_rate_delete" type="button" value="<?php echo wp_sprintf(esc_attr__('Delete class "%s"', 'invoicing'), $vat_classes[$vat_class]); ?>" class="button button-primary" />&nbsp;&nbsp;<i style="display:none;" class="fa fa-refresh fa-spin"></i></p>
270 270
     <?php
271 271
     }
272 272
 }
273 273
 
274
-function wpinv_vat_rates_callback( $args ) {
274
+function wpinv_vat_rates_callback($args) {
275 275
     global $wpinv_euvat;
276 276
     
277 277
     $vat_classes    = $wpinv_euvat->get_rate_classes();
278
-    $vat_class      = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' && isset( $vat_classes[$_REQUEST['wpi_sub']] )? sanitize_text_field( $_REQUEST['wpi_sub'] ) : '_standard';
278
+    $vat_class      = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' && isset($vat_classes[$_REQUEST['wpi_sub']]) ? sanitize_text_field($_REQUEST['wpi_sub']) : '_standard';
279 279
     
280 280
     $eu_states      = $wpinv_euvat->get_eu_states();
281 281
     $countries      = wpinv_get_country_list();
282 282
     $vat_groups     = $wpinv_euvat->get_vat_groups();
283
-    $rates          = $wpinv_euvat->get_vat_rates( $vat_class );
283
+    $rates          = $wpinv_euvat->get_vat_rates($vat_class);
284 284
     ob_start();
285 285
 ?>
286 286
 </td><tr>
287 287
     <td colspan="2" class="wpinv_vat_tdbox">
288
-    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class;?>" />
289
-    <p><?php echo ( isset( $args['desc'] ) ? $args['desc'] : '' ); ?></p>
288
+    <input type="hidden" name="wpi_vat_class" value="<?php echo $vat_class; ?>" />
289
+    <p><?php echo (isset($args['desc']) ? $args['desc'] : ''); ?></p>
290 290
     <table id="wpinv_vat_rates" class="wp-list-table widefat fixed posts">
291 291
         <colgroup>
292 292
             <col width="50px" />
@@ -298,43 +298,43 @@  discard block
 block discarded – undo
298 298
         </colgroup>
299 299
         <thead>
300 300
             <tr>
301
-                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e( 'Country', 'invoicing' ); ?></th>
302
-                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e( 'Apply rate to whole country', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
303
-                <th scope="col" class="wpinv_vat_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
304
-                <th scope="col" class="wpinv_vat_name"><?php _e( 'VAT Name', 'invoicing' ); ?></th>
305
-                <th scope="col" class="wpinv_vat_group"><?php _e( 'Tax Group', 'invoicing' ); ?></th>
301
+                <th scope="col" colspan="2" class="wpinv_vat_country_name"><?php _e('Country', 'invoicing'); ?></th>
302
+                <th scope="col" class="wpinv_vat_global" title="<?php esc_attr_e('Apply rate to whole country', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
303
+                <th scope="col" class="wpinv_vat_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
304
+                <th scope="col" class="wpinv_vat_name"><?php _e('VAT Name', 'invoicing'); ?></th>
305
+                <th scope="col" class="wpinv_vat_group"><?php _e('Tax Group', 'invoicing'); ?></th>
306 306
             </tr>
307 307
         </thead>
308 308
         <tbody>
309
-        <?php if( !empty( $eu_states ) ) { ?>
309
+        <?php if (!empty($eu_states)) { ?>
310 310
         <?php 
311
-        foreach ( $eu_states as $state ) { 
312
-            $country_name = isset( $countries[$state] ) ? $countries[$state] : '';
311
+        foreach ($eu_states as $state) { 
312
+            $country_name = isset($countries[$state]) ? $countries[$state] : '';
313 313
             
314 314
             // Filter the rate for each country
315
-            $country_rate = array_filter( $rates, function( $rate ) use( $state ) { return $rate['country'] === $state; } );
315
+            $country_rate = array_filter($rates, function($rate) use($state) { return $rate['country'] === $state; } );
316 316
             
317 317
             // If one does not exist create a default
318
-            $country_rate = is_array( $country_rate ) && count( $country_rate ) > 0 ? reset( $country_rate ) : array();
318
+            $country_rate = is_array($country_rate) && count($country_rate) > 0 ? reset($country_rate) : array();
319 319
             
320
-            $vat_global = isset( $country_rate['global'] ) ? !empty( $country_rate['global'] ) : true;
321
-            $vat_rate = isset( $country_rate['rate'] ) ? $country_rate['rate'] : '';
322
-            $vat_name = !empty( $country_rate['name'] ) ? esc_attr( stripslashes( $country_rate['name'] ) ) : '';
323
-            $vat_group = !empty( $country_rate['group'] ) ? $country_rate['group'] : ( $vat_class === '_standard' ? 'standard' : 'reduced' );
320
+            $vat_global = isset($country_rate['global']) ? !empty($country_rate['global']) : true;
321
+            $vat_rate = isset($country_rate['rate']) ? $country_rate['rate'] : '';
322
+            $vat_name = !empty($country_rate['name']) ? esc_attr(stripslashes($country_rate['name'])) : '';
323
+            $vat_group = !empty($country_rate['group']) ? $country_rate['group'] : ($vat_class === '_standard' ? 'standard' : 'reduced');
324 324
         ?>
325 325
         <tr>
326 326
             <td class="wpinv_vat_country"><?php echo $state; ?><input type="hidden" name="vat_rates[<?php echo $state; ?>][country]" value="<?php echo $state; ?>" /><input type="hidden" name="vat_rates[<?php echo $state; ?>][state]" value="" /></td>
327 327
             <td class="wpinv_vat_country_name"><?php echo $country_name; ?></td>
328 328
             <td class="wpinv_vat_global">
329
-                <input type="checkbox" name="vat_rates[<?php echo $state;?>][global]" id="vat_rates[<?php echo $state;?>][global]" value="1" <?php checked( true, $vat_global );?> disabled="disabled" />
330
-                <label for="tax_rates[<?php echo $state;?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
331
-                <input type="hidden" name="vat_rates[<?php echo $state;?>][global]" value="1" checked="checked" />
329
+                <input type="checkbox" name="vat_rates[<?php echo $state; ?>][global]" id="vat_rates[<?php echo $state; ?>][global]" value="1" <?php checked(true, $vat_global); ?> disabled="disabled" />
330
+                <label for="tax_rates[<?php echo $state; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
331
+                <input type="hidden" name="vat_rates[<?php echo $state; ?>][global]" value="1" checked="checked" />
332 332
             </td>
333
-            <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state;?>][rate]" value="<?php echo $vat_rate; ?>" /></td>
334
-            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state;?>][name]" value="<?php echo $vat_name; ?>" /></td>
333
+            <td class="wpinv_vat_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="vat_rates[<?php echo $state; ?>][rate]" value="<?php echo $vat_rate; ?>" /></td>
334
+            <td class="wpinv_vat_name"><input type="text" class="regular-text" name="vat_rates[<?php echo $state; ?>][name]" value="<?php echo $vat_name; ?>" /></td>
335 335
             <td class="wpinv_vat_group">
336 336
             <?php
337
-            echo wpinv_html_select( array(
337
+            echo wpinv_html_select(array(
338 338
                                         'name'             => 'vat_rates[' . $state . '][group]',
339 339
                                         'selected'         => $vat_group,
340 340
                                         'id'               => 'vat_rates[' . $state . '][group]',
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
                                         'multiple'         => false,
344 344
                                         'show_option_all'  => false,
345 345
                                         'show_option_none' => false
346
-                                    ) );
346
+                                    ));
347 347
             ?>
348 348
             </td>
349 349
         </tr>
350 350
         <?php } ?>
351 351
         <tr>
352 352
             <td colspan="6" style="background-color:#fafafa;">
353
-                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e( 'Update EU VAT Rates', 'invoicing' ); ?>" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span>
353
+                <span><input id="wpi_vat_get_rates_group" type="button" class="button-secondary" value="<?php esc_attr_e('Update EU VAT Rates', 'invoicing'); ?>" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span><span id="wpinv-rates-error-wrap" class="wpinv_errors" style="display:none;"></span>
354 354
             </td>
355 355
         </tr>
356 356
         <?php } ?>
@@ -362,35 +362,35 @@  discard block
 block discarded – undo
362 362
     echo $content;
363 363
 }
364 364
 
365
-function wpinv_vat_number_callback( $args ) {
365
+function wpinv_vat_number_callback($args) {
366 366
     global $wpinv_euvat;
367 367
     
368 368
     $vat_number     = $wpinv_euvat->get_vat_number();
369 369
     $vat_valid      = $wpinv_euvat->is_vat_validated();
370 370
 
371
-    $size           = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
372
-    $validated_text = $vat_valid ? __( 'VAT number validated', 'invoicing' ) : __( 'VAT number not validated', 'invoicing' );
371
+    $size           = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
372
+    $validated_text = $vat_valid ? __('VAT number validated', 'invoicing') : __('VAT number not validated', 'invoicing');
373 373
     $disabled       = $vat_valid ? 'disabled="disabled"' : " ";
374 374
     
375
-    $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr( stripslashes( $vat_number ) ) . '"/>';
376
-    $html .= '<span>&nbsp;<input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__( 'Validate VAT Number', 'invoicing' ) . '" /></span>';
377
-    $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int)$vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>';
378
-    $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __( 'Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing' ).'</p>' . '</label>';
379
-    $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce( 'vat_validation' ) . '">';
375
+    $html = '<input type="text" class="' . $size . '-text" id="wpinv_settings[' . $args['id'] . ']" name="wpinv_settings[' . $args['id'] . ']" placeholder="GB123456789" value="' . esc_attr(stripslashes($vat_number)) . '"/>';
376
+    $html .= '<span>&nbsp;<input type="button" id="wpinv_vat_validate" class="wpinv_validate_vat_button button-secondary" ' . $disabled . ' value="' . esc_attr__('Validate VAT Number', 'invoicing') . '" /></span>';
377
+    $html .= '<span class="wpinv-vat-stat wpinv-vat-stat-' . (int) $vat_valid . '"><i class="fa"></i> <font>' . $validated_text . '</font></span>';
378
+    $html .= '<label for="wpinv_settings[' . $args['id'] . ']">' . '<p>' . __('Enter your VAT number including country identifier, eg: GB123456789 (Settings must be saved after validation)', 'invoicing') . '</p>' . '</label>';
379
+    $html .= '<input type="hidden" name="_wpi_nonce" value="' . wp_create_nonce('vat_validation') . '">';
380 380
 
381 381
     echo $html;
382 382
 }
383 383
 
384
-function wpinv_eu_fallback_rate_callback( $args ) {
384
+function wpinv_eu_fallback_rate_callback($args) {
385 385
     global $wpinv_options;
386 386
 
387
-    $value = isset( $wpinv_options[$args['id']] ) ? $wpinv_options[ $args['id'] ] : ( isset( $args['std'] ) ? $args['std'] : '' );
388
-    $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'small';
387
+    $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : '');
388
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'small';
389 389
     
390
-    $html = '<input type="number" min="0" max="99" step="any" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '" />';
391
-    $html .= '<span>&nbsp;<input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Add EU Member States', 'invoicing' ) . '" /></span>';
392
-    $html .= '<span>&nbsp;<input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__( 'Remove EU Member States', 'invoicing' ) . '" /></span>';
393
-    $html .= '<span>&nbsp;<input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__( 'Update EU VAT Rates', 'invoicing' ) . '" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span>';
390
+    $html = '<input type="number" min="0" max="99" step="any" class="' . $size . '-text" id="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '" name="wpinv_settings[' . $args['id'] . ']" value="' . esc_attr(stripslashes($value)) . '" />';
391
+    $html .= '<span>&nbsp;<input id="wpi_add_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Add EU Member States', 'invoicing') . '" /></span>';
392
+    $html .= '<span>&nbsp;<input id="wpi_remove_eu_states" type="button" class="button-secondary" value="' . esc_attr__('Remove EU Member States', 'invoicing') . '" /></span>';
393
+    $html .= '<span>&nbsp;<input id="wpi_vat_get_rates" type="button" class="button-secondary" value="' . esc_attr__('Update EU VAT Rates', 'invoicing') . '" />&nbsp;&nbsp;<i style="display:none" class="fa fa-refresh fa-spin"></i></span>';
394 394
     $html .= '<p><label for="wpinv_settings_' . $args['section'] . '_' . $args['id'] . '">' . $args['desc'] . '</label></p>';
395 395
     echo $html;
396 396
     ?>
@@ -398,36 +398,36 @@  discard block
 block discarded – undo
398 398
     <?php
399 399
 }
400 400
 
401
-function wpinv_vat_ip_lookup_callback( $args ) {
401
+function wpinv_vat_ip_lookup_callback($args) {
402 402
     global $wpinv_options, $wpinv_euvat;
403 403
 
404
-    $value =  isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ]  : ( isset( $args['std'] ) ? $args['std'] : 'default' );
404
+    $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : (isset($args['std']) ? $args['std'] : 'default');
405 405
     
406 406
     $options = array();
407
-    if ( function_exists( 'geoip_country_code_by_name' ) ) {
408
-        $options['geoip'] = __( 'PHP GeoIP extension', 'invoicing' );
407
+    if (function_exists('geoip_country_code_by_name')) {
408
+        $options['geoip'] = __('PHP GeoIP extension', 'invoicing');
409 409
     }
410 410
     
411 411
     $geoip2_database = $wpinv_euvat->geoip2_country_dbfile();
412 412
     
413
-    if ( !function_exists( 'bcadd' ) ) {
414
-        $geoip2_message = __( 'GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing' );
413
+    if (!function_exists('bcadd')) {
414
+        $geoip2_message = __('GeoIP2 service requires the BC Math PHP extension, it is not loaded in your version of PHP!', 'invoicing');
415 415
     } else {
416
-        $geoip2_message = ini_get('safe_mode') ? __( 'GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing' ) : '';
416
+        $geoip2_message = ini_get('safe_mode') ? __('GeoIP2 is not supported with PHP safe mode enabled!', 'invoicing') : '';
417 417
     }
418 418
     
419
-    if ( $geoip2_database !== false && empty( $geoip2_message ) ) {
420
-        $options['geoip2'] = __( 'GeoIP2 Database', 'invoicing' );
419
+    if ($geoip2_database !== false && empty($geoip2_message)) {
420
+        $options['geoip2'] = __('GeoIP2 Database', 'invoicing');
421 421
     }
422 422
     
423
-    if ( function_exists( 'simplexml_load_file' ) ) {
424
-        $options['geoplugin'] = __( 'geoPlugin Web Service', 'invoicing' );
423
+    if (function_exists('simplexml_load_file')) {
424
+        $options['geoplugin'] = __('geoPlugin Web Service', 'invoicing');
425 425
     }
426 426
     
427
-    $options['site']    = __( 'Use default country', 'invoicing' );
428
-    $options['default'] = __( 'Auto', 'invoicing' );
427
+    $options['site']    = __('Use default country', 'invoicing');
428
+    $options['default'] = __('Auto', 'invoicing');
429 429
 
430
-    $html = wpinv_html_select( array(
430
+    $html = wpinv_html_select(array(
431 431
         'name'             => "wpinv_settings[{$args['id']}]",
432 432
         'selected'         => $value,
433 433
         'id'               => "wpinv_settings[{$args['id']}]",
@@ -439,23 +439,23 @@  discard block
 block discarded – undo
439 439
     ));
440 440
     
441 441
     $desc = '<label for="wpinv_settings[' . $args['id'] . ']">';
442
-    $desc .= __( 'Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing' );
442
+    $desc .= __('Select the option Invoicing should use to determine the country from the IP address of the user.', 'invoicing');
443 443
     $desc .= '<p>';
444
-    if ( empty( $geoip2_message ) ) {
445
-        if ( $geoip2_database ) {
444
+    if (empty($geoip2_message)) {
445
+        if ($geoip2_database) {
446 446
             $last_updated = '';
447
-            if ( $time_updated = wpinv_get_option( 'wpinv_geoip2_date_updated' ) ) {
448
-                $date_updated = date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $time_updated );
449
-                $last_updated = '<br>' . sprintf( __( 'The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing' ), $date_updated );
447
+            if ($time_updated = wpinv_get_option('wpinv_geoip2_date_updated')) {
448
+                $date_updated = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $time_updated);
449
+                $last_updated = '<br>' . sprintf(__('The GeoIP2 database was last updated on: <b>%s</b>', 'invoicing'), $date_updated);
450 450
             }
451
-            $desc .= __(  'GeoIP2 database exists:', 'invoicing' ) . $last_updated . '&nbsp;<input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __( 'Update GeoIP2 database now (~30MB)', 'invoicing' ) . '"></input>';
451
+            $desc .= __('GeoIP2 database exists:', 'invoicing') . $last_updated . '&nbsp;<input type="button" id="wpi_geoip2" action="update" class="wpinv-refresh-geoip2-btn button-secondary" value="' . __('Update GeoIP2 database now (~30MB)', 'invoicing') . '"></input>';
452 452
         } else {
453
-            $desc .= __( 'GeoIP2 database does not exist:', 'invoicing' ) . '&nbsp;<input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __( 'Download GeoIP2 database now', 'invoicing' ) . ' (~30MB)"></input><br>' . __(  'After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing' );
453
+            $desc .= __('GeoIP2 database does not exist:', 'invoicing') . '&nbsp;<input type="button" id="wpi_geoip2" action="download" class="wpinv-download-geoip2-btn button-secondary" value="' . __('Download GeoIP2 database now', 'invoicing') . ' (~30MB)"></input><br>' . __('After downloading the GeoIP2 database the GeoIP2 lookup option will show.', 'invoicing');
454 454
         }
455 455
     } else {
456 456
         $desc .= $geoip2_message;
457 457
     }
458
-    $desc .= '</p><p>'. __( 'geoPlugin is a great free service please consider supporting them: ', 'invoicing' ) . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>';
458
+    $desc .= '</p><p>' . __('geoPlugin is a great free service please consider supporting them: ', 'invoicing') . ' <a href="http://www.geoplugin.com/" target="_blank">GeoPlugin.com</a></p>';
459 459
     $desc .= '</label>';
460 460
     
461 461
     $html .= $desc;
@@ -471,39 +471,39 @@  discard block
 block discarded – undo
471 471
  * 
472 472
  * @param string|bool|null $vat_rule
473 473
  */
474
-function getpaid_filter_vat_rule( $vat_rule ) {
474
+function getpaid_filter_vat_rule($vat_rule) {
475 475
 
476
-    if ( empty( $vat_rule ) ) {        
476
+    if (empty($vat_rule)) {        
477 477
         return getpaid_tax()->allow_vat_rules() ? 'digital' : 'physical';
478 478
     }
479 479
 
480 480
     return $vat_rule;
481 481
 }
482
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
482
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
483 483
 
484 484
 /**
485 485
  * Filters the VAT class to ensure that each item has a VAT class.
486 486
  * 
487 487
  * @param string|bool|null $vat_rule
488 488
  */
489
-function getpaid_filter_vat_class( $vat_class ) {
490
-    return empty( $vat_class ) ? '_standard' : $vat_class;
489
+function getpaid_filter_vat_class($vat_class) {
490
+    return empty($vat_class) ? '_standard' : $vat_class;
491 491
 }
492
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
492
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
493 493
 
494 494
 /**
495 495
  * Returns the ip address location url.
496 496
  * 
497 497
  */
498
-function getpaid_ip_location_url( $ip_address ) {
498
+function getpaid_ip_location_url($ip_address) {
499 499
 
500 500
     return add_query_arg(
501 501
         array(
502 502
             'action'   => 'wpinv_ip_geolocation',
503 503
             'ip'       => $ip_address,
504
-            '_wpnonce' => wp_create_nonce( 'getpaid-ip-location' )
504
+            '_wpnonce' => wp_create_nonce('getpaid-ip-location')
505 505
         ),
506
-        admin_url( 'admin-ajax.php' )
506
+        admin_url('admin-ajax.php')
507 507
     );
508 508
 
509 509
 }
@@ -513,59 +513,59 @@  discard block
 block discarded – undo
513 513
  * 
514 514
  * @return array|bool
515 515
  */
516
-function getpaid_geolocate_ip_address( $ip_address ) {
516
+function getpaid_geolocate_ip_address($ip_address) {
517 517
 
518 518
     // Do we have an ip address?
519
-    if ( empty( $ip_address ) ) {
519
+    if (empty($ip_address)) {
520 520
         return false;
521 521
     }
522 522
 
523 523
     /**
524 524
      * Retrieve ip address using max mind.
525 525
      */
526
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = getpaid_tax()->geoip2_city_record( $ip_address ) ) {
526
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = getpaid_tax()->geoip2_city_record($ip_address)) {
527 527
 
528 528
         try {
529 529
             $iso        = $geoip2_city->country->isoCode;
530 530
             $country    = $geoip2_city->country->name;
531
-            $region     = ! empty( $geoip2_city->subdivisions ) && ! empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
531
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
532 532
             $city       = $geoip2_city->city->name;
533 533
             $longitude  = $geoip2_city->location->longitude;
534 534
             $latitude   = $geoip2_city->location->latitude;
535
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
536
-        } catch( Exception $e ) {
537
-            wpinv_error_log( $e->getMessage(), 'MaxMind Exception', __FILE__, __LINE__ );
535
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
536
+        } catch (Exception $e) {
537
+            wpinv_error_log($e->getMessage(), 'MaxMind Exception', __FILE__, __LINE__);
538 538
         }
539 539
 
540 540
     }
541 541
 
542 542
     // If that fails, GeoLocate using GeoPlugin.
543
-    if ( ( empty( $iso ) || empty( $longitude ) || empty( $latitude ) ) && function_exists( 'simplexml_load_file' ) ) {
543
+    if ((empty($iso) || empty($longitude) || empty($latitude)) && function_exists('simplexml_load_file')) {
544 544
 
545 545
         try {
546
-            $url      = esc_url( add_query_arg( 'ip', urlencode( $ip_address ), 'http://www.geoplugin.net/xml.gp' ) );
547
-            $load_xml = simplexml_load_file( $url );
546
+            $url      = esc_url(add_query_arg('ip', urlencode($ip_address), 'http://www.geoplugin.net/xml.gp'));
547
+            $load_xml = simplexml_load_file($url);
548 548
 
549
-            if ( ! empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && ! empty( $load_xml->geoplugin_latitude ) && ! empty( $load_xml->geoplugin_longitude ) ) {
549
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
550 550
                 $iso        = $load_xml->geoplugin_countryCode;
551 551
                 $country    = $load_xml->geoplugin_countryName;
552
-                $region     = ! empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
553
-                $city       = ! empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
552
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
553
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
554 554
                 $longitude  = $load_xml->geoplugin_longitude;
555 555
                 $latitude   = $load_xml->geoplugin_latitude;
556 556
                 $credit     = $load_xml->geoplugin_credit;
557
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
557
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
558 558
             }
559
-        } catch( Exception $e ) {
560
-            wpinv_error_log( $e->getMessage(), 'GeoPlugin Exception', __FILE__, __LINE__ );
559
+        } catch (Exception $e) {
560
+            wpinv_error_log($e->getMessage(), 'GeoPlugin Exception', __FILE__, __LINE__);
561 561
         }
562 562
 
563 563
     }
564 564
 
565
-   if ( empty( $iso )  ) {
565
+   if (empty($iso)) {
566 566
        return false;
567 567
    }
568 568
 
569
-   return compact( 'iso', 'country', 'region', 'city', 'longitude', 'latitude', 'credit' );
569
+   return compact('iso', 'country', 'region', 'city', 'longitude', 'latitude', 'credit');
570 570
 
571 571
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-forms.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment forms controller class
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 	public function __construct() {
20 20
 
21 21
 		// Update a payment form's revenue whenever an invoice is paid for or refunded.
22
-		add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) );
23
-		add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) );
22
+		add_action('getpaid_invoice_payment_status_changed', array($this, 'increment_form_revenue'));
23
+		add_action('getpaid_invoice_payment_status_reversed', array($this, 'decrease_form_revenue'));
24 24
 
25 25
 		// Sync form amount whenever invoice statuses change.
26
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 );
27
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 );
28
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 );
26
+		add_action('getpaid_invoice_status_changed', array($this, 'update_form_failed_amount'), 10, 3);
27
+		add_action('getpaid_invoice_status_changed', array($this, 'update_form_refunded_amount'), 10, 3);
28
+		add_action('getpaid_invoice_status_changed', array($this, 'update_form_cancelled_amount'), 10, 3);
29 29
 
30 30
 	}
31 31
 
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @param WPInv_Invoice $invoice
36 36
 	 */
37
-	public function increment_form_revenue( $invoice ) {
37
+	public function increment_form_revenue($invoice) {
38 38
 
39
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
40
-		if ( $form->get_id() ) {
41
-			$form->set_earned( $form->get_earned() + $invoice->get_total() );
39
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
40
+		if ($form->get_id()) {
41
+			$form->set_earned($form->get_earned() + $invoice->get_total());
42 42
 			$form->save();
43 43
 		}
44 44
 
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @param WPInv_Invoice $invoice
51 51
 	 */
52
-	public function decrease_form_revenue( $invoice ) {
52
+	public function decrease_form_revenue($invoice) {
53 53
 
54
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
55
-		if ( $form->get_id() ) {
56
-			$form->set_earned( $form->get_earned() - $invoice->get_total() );
54
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
55
+		if ($form->get_id()) {
56
+			$form->set_earned($form->get_earned() - $invoice->get_total());
57 57
 			$form->save();
58 58
 		}
59 59
 
@@ -66,20 +66,20 @@  discard block
 block discarded – undo
66 66
 	 * @param string $from
67 67
 	 * @param string $to
68 68
 	 */
69
-	public function update_form_failed_amount( $invoice, $from, $to ) {
69
+	public function update_form_failed_amount($invoice, $from, $to) {
70 70
 
71
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
72
-		if ( $form->get_id() ) {
71
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
72
+		if ($form->get_id()) {
73 73
 			return;
74 74
 		}
75 75
 
76
-		if ( 'wpi-failed' == $from ) {
77
-			$form->set_failed( $form->get_failed() - $invoice->get_total() );
76
+		if ('wpi-failed' == $from) {
77
+			$form->set_failed($form->get_failed() - $invoice->get_total());
78 78
 			$form->save();
79 79
 		}
80 80
 
81
-		if ( 'wpi-failed' == $to ) {
82
-			$form->set_failed( $form->get_failed() + $invoice->get_total() );
81
+		if ('wpi-failed' == $to) {
82
+			$form->set_failed($form->get_failed() + $invoice->get_total());
83 83
 			$form->save();
84 84
 		}
85 85
 
@@ -92,20 +92,20 @@  discard block
 block discarded – undo
92 92
 	 * @param string $from
93 93
 	 * @param string $to
94 94
 	 */
95
-	public function update_form_refunded_amount( $invoice, $from, $to ) {
95
+	public function update_form_refunded_amount($invoice, $from, $to) {
96 96
 
97
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
98
-		if ( $form->get_id() ) {
97
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
98
+		if ($form->get_id()) {
99 99
 			return;
100 100
 		}
101 101
 
102
-		if ( 'wpi-refunded' == $from ) {
103
-			$form->set_refunded( $form->get_refunded() - $invoice->get_total() );
102
+		if ('wpi-refunded' == $from) {
103
+			$form->set_refunded($form->get_refunded() - $invoice->get_total());
104 104
 			$form->save();
105 105
 		}
106 106
 
107
-		if ( 'wpi-refunded' == $to ) {
108
-			$form->set_refunded( $form->get_refunded() + $invoice->get_total() );
107
+		if ('wpi-refunded' == $to) {
108
+			$form->set_refunded($form->get_refunded() + $invoice->get_total());
109 109
 			$form->save();
110 110
 		}
111 111
 
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
 	 * @param string $from
119 119
 	 * @param string $to
120 120
 	 */
121
-	public function update_form_cancelled_amount( $invoice, $from, $to ) {
121
+	public function update_form_cancelled_amount($invoice, $from, $to) {
122 122
 
123
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
124
-		if ( $form->get_id() ) {
123
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
124
+		if ($form->get_id()) {
125 125
 			return;
126 126
 		}
127 127
 
128
-		if ( 'wpi-cancelled' == $from ) {
129
-			$form->set_cancelled( $form->get_cancelled() - $invoice->get_total() );
128
+		if ('wpi-cancelled' == $from) {
129
+			$form->set_cancelled($form->get_cancelled() - $invoice->get_total());
130 130
 			$form->save();
131 131
 		}
132 132
 
133
-		if ( 'wpi-cancelled' == $to ) {
134
-			$form->set_cancelled( $form->get_cancelled() + $invoice->get_total() );
133
+		if ('wpi-cancelled' == $to) {
134
+			$form->set_cancelled($form->get_cancelled() + $invoice->get_total());
135 135
 			$form->save();
136 136
 		}
137 137
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-discount-details.php 1 patch
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the discount.
27
-        $discount = new WPInv_Discount( $post );
27
+        $discount = new WPInv_Discount($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32
-        do_action( 'wpinv_discount_form_top', $discount );
32
+        do_action('wpinv_discount_form_top', $discount);
33 33
 
34 34
         // Set the currency position.
35 35
         $position = wpinv_currency_position();
36 36
 
37
-        if ( $position == 'left_space' ) {
37
+        if ($position == 'left_space') {
38 38
             $position = 'left';
39 39
         }
40 40
 
41
-        if ( $position == 'right_space' ) {
41
+        if ($position == 'right_space') {
42 42
             $position = 'right';
43 43
         }
44 44
 
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
         </style>
53 53
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
54 54
 
55
-            <?php do_action( 'wpinv_discount_form_first', $discount ); ?>
55
+            <?php do_action('wpinv_discount_form_first', $discount); ?>
56 56
 
57
-            <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?>
57
+            <?php do_action('wpinv_discount_form_before_code', $discount); ?>
58 58
             <div class="form-group row">
59 59
                 <label for="wpinv_discount_code" class="col-sm-3 col-form-label">
60
-                    <?php _e( 'Discount Code', 'invoicing' );?>
60
+                    <?php _e('Discount Code', 'invoicing'); ?>
61 61
                 </label>
62 62
                 <div class="col-sm-8">
63 63
                     <div class="row">
64 64
                         <div class="col-sm-12 form-group">
65
-                            <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
65
+                            <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
66 66
                         </div>
67 67
                         <div class="col-sm-12">
68 68
                             <?php
69
-                                do_action( 'wpinv_discount_form_before_single_use', $discount );
69
+                                do_action('wpinv_discount_form_before_single_use', $discount);
70 70
 
71 71
                                 echo aui()->input(
72 72
                                     array(
73 73
                                         'id'          => 'wpinv_discount_single_use',
74 74
                                         'name'        => 'wpinv_discount_single_use',
75 75
                                         'type'        => 'checkbox',
76
-                                        'label'       => __( 'Each customer can only use this discount once', 'invoicing' ),
76
+                                        'label'       => __('Each customer can only use this discount once', 'invoicing'),
77 77
                                         'value'       => '1',
78 78
                                         'checked'     => $discount->is_single_use(),
79 79
                                     )
80 80
                                 );
81 81
 
82
-                                do_action( 'wpinv_discount_form_single_use', $discount );
82
+                                do_action('wpinv_discount_form_single_use', $discount);
83 83
                             ?>
84 84
                         </div>
85 85
                         <div class="col-sm-12">
86 86
                             <?php
87
-                                do_action( 'wpinv_discount_form_before_recurring', $discount );
87
+                                do_action('wpinv_discount_form_before_recurring', $discount);
88 88
 
89 89
                                 echo aui()->input(
90 90
                                     array(
91 91
                                         'id'          => 'wpinv_discount_recurring',
92 92
                                         'name'        => 'wpinv_discount_recurring',
93 93
                                         'type'        => 'checkbox',
94
-                                        'label'       => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ),
94
+                                        'label'       => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'),
95 95
                                         'value'       => '1',
96 96
                                         'checked'     => $discount->is_recurring(),
97 97
                                     )
98 98
                                 );
99 99
 
100
-                                do_action( 'wpinv_discount_form_recurring', $discount );
100
+                                do_action('wpinv_discount_form_recurring', $discount);
101 101
                             ?>
102 102
                         </div>
103 103
                     </div>
104 104
                 </div>
105 105
                 <div class="col-sm-1 pt-2 pl-0">
106
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span>
106
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span>
107 107
                 </div>
108 108
             </div>
109
-            <?php do_action( 'wpinv_discount_form_code', $discount ); ?>
109
+            <?php do_action('wpinv_discount_form_code', $discount); ?>
110 110
 
111
-            <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?>
111
+            <?php do_action('wpinv_discount_form_before_type', $discount); ?>
112 112
             <div class="form-group row">
113 113
                 <label for="wpinv_discount_type" class="col-sm-3 col-form-label">
114
-                    <?php _e( 'Discount Type', 'invoicing' );?>
114
+                    <?php _e('Discount Type', 'invoicing'); ?>
115 115
                 </label>
116 116
                 <div class="col-sm-8">
117 117
                     <?php
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
                             array(
120 120
                                 'id'               => 'wpinv_discount_type',
121 121
                                 'name'             => 'wpinv_discount_type',
122
-                                'label'            => __( 'Discount Type', 'invoicing' ),
123
-                                'placeholder'      => __( 'Select Discount Type', 'invoicing' ),
124
-                                'value'            => $discount->get_type( 'edit' ),
122
+                                'label'            => __('Discount Type', 'invoicing'),
123
+                                'placeholder'      => __('Select Discount Type', 'invoicing'),
124
+                                'value'            => $discount->get_type('edit'),
125 125
                                 'select2'          => true,
126 126
                                 'data-allow-clear' => 'false',
127 127
                                 'options'          => wpinv_get_discount_types()
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
                     ?>
131 131
                 </div>
132 132
                 <div class="col-sm-1 pt-2 pl-0">
133
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span>
133
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span>
134 134
                 </div>
135 135
             </div>
136
-            <?php do_action( 'wpinv_discount_form_type', $discount ); ?>
136
+            <?php do_action('wpinv_discount_form_type', $discount); ?>
137 137
 
138
-            <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?>
139
-            <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap">
138
+            <?php do_action('wpinv_discount_form_before_amount', $discount); ?>
139
+            <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap">
140 140
                 <label for="wpinv_discount_amount" class="col-sm-3 col-form-label">
141
-                    <?php _e( 'Discount Amount', 'invoicing' );?>
141
+                    <?php _e('Discount Amount', 'invoicing'); ?>
142 142
                 </label>
143 143
                 <div class="col-sm-8">
144 144
                     <div class="input-group input-group-sm">
145
-                        <?php if( 'left' == $position ) : ?>
145
+                        <?php if ('left' == $position) : ?>
146 146
                             <div class="input-group-prepend left wpinv-if-flat">
147 147
                                 <span class="input-group-text">
148 148
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                             </div>
151 151
                         <?php endif; ?>
152 152
 
153
-                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control">
153
+                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control">
154 154
 
155
-                        <?php if( 'right' == $position ) : ?>
155
+                        <?php if ('right' == $position) : ?>
156 156
                             <div class="input-group-prepend left wpinv-if-flat">
157 157
                                 <span class="input-group-text">
158 158
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
                     </div>
166 166
                 </div>
167 167
                 <div class="col-sm-1 pt-2 pl-0">
168
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span>
168
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span>
169 169
                 </div>
170 170
             </div>
171
-            <?php do_action( 'wpinv_discount_form_amount', $discount ); ?>
171
+            <?php do_action('wpinv_discount_form_amount', $discount); ?>
172 172
 
173
-            <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?>
173
+            <?php do_action('wpinv_discount_form_before_items', $discount); ?>
174 174
             <div class="form-group row">
175 175
                 <label for="wpinv_discount_items" class="col-sm-3 col-form-label">
176
-                    <?php _e( 'Items', 'invoicing' );?>
176
+                    <?php _e('Items', 'invoicing'); ?>
177 177
                 </label>
178 178
                 <div class="col-sm-8">
179 179
                     <?php
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
                             array(
182 182
                                 'id'               => 'wpinv_discount_items',
183 183
                                 'name'             => 'wpinv_discount_items[]',
184
-                                'label'            => __( 'Items', 'invoicing' ),
185
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
186
-                                'value'            => $discount->get_items( 'edit' ),
184
+                                'label'            => __('Items', 'invoicing'),
185
+                                'placeholder'      => __('Select Items', 'invoicing'),
186
+                                'value'            => $discount->get_items('edit'),
187 187
                                 'select2'          => true,
188 188
                                 'multiple'         => true,
189 189
                                 'data-allow-clear' => 'false',
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
                     ?>
194 194
                 </div>
195 195
                 <div class="col-sm-1 pt-2 pl-0">
196
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span>
196
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span>
197 197
                 </div>
198 198
             </div>
199
-            <?php do_action( 'wpinv_discount_form_items', $discount ); ?>
199
+            <?php do_action('wpinv_discount_form_items', $discount); ?>
200 200
 
201
-            <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?>
201
+            <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?>
202 202
             <div class="form-group row">
203 203
                 <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label">
204
-                    <?php _e( 'Excluded Items', 'invoicing' );?>
204
+                    <?php _e('Excluded Items', 'invoicing'); ?>
205 205
                 </label>
206 206
                 <div class="col-sm-8">
207 207
                     <?php
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             array(
210 210
                                 'id'               => 'wpinv_discount_excluded_items',
211 211
                                 'name'             => 'wpinv_discount_excluded_items[]',
212
-                                'label'            => __( 'Excluded Items', 'invoicing' ),
213
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
214
-                                'value'            => $discount->get_excluded_items( 'edit' ),
212
+                                'label'            => __('Excluded Items', 'invoicing'),
213
+                                'placeholder'      => __('Select Items', 'invoicing'),
214
+                                'value'            => $discount->get_excluded_items('edit'),
215 215
                                 'select2'          => true,
216 216
                                 'multiple'         => true,
217 217
                                 'data-allow-clear' => 'false',
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
                     ?>
222 222
                 </div>
223 223
                 <div class="col-sm-1 pt-2 pl-0">
224
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span>
224
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span>
225 225
                 </div>
226 226
             </div>
227
-            <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?>
227
+            <?php do_action('wpinv_discount_form_excluded_items', $discount); ?>
228 228
 
229
-            <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?>
229
+            <?php do_action('wpinv_discount_form_before_start', $discount); ?>
230 230
             <div class="form-group row">
231 231
                 <label for="wpinv_discount_start" class="col-sm-3 col-form-label">
232
-                    <?php _e( 'Start Date', 'invoicing' );?>
232
+                    <?php _e('Start Date', 'invoicing'); ?>
233 233
                 </label>
234 234
                 <div class="col-sm-8">
235 235
                     <?php
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
                                 'type'        => 'datepicker',
239 239
                                 'id'          => 'wpinv_discount_start',
240 240
                                 'name'        => 'wpinv_discount_start',
241
-                                'label'       => __( 'Start Date', 'invoicing' ),
241
+                                'label'       => __('Start Date', 'invoicing'),
242 242
                                 'placeholder' => 'YYYY-MM-DD 00:00',
243 243
                                 'class'       => 'form-control-sm',
244
-                                'value'       => $discount->get_start_date( 'edit' ),
244
+                                'value'       => $discount->get_start_date('edit'),
245 245
                                 'extra_attributes' => array(
246 246
                                     'data-enable-time' => 'true',
247 247
                                     'data-time_24hr'   => 'true',
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
                     ?>
253 253
                 </div>
254 254
                 <div class="col-sm-1 pt-2 pl-0">
255
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span>
255
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span>
256 256
                 </div>
257 257
             </div>
258
-            <?php do_action( 'wpinv_discount_form_start', $discount ); ?>
258
+            <?php do_action('wpinv_discount_form_start', $discount); ?>
259 259
 
260
-            <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?>
260
+            <?php do_action('wpinv_discount_form_before_expiration', $discount); ?>
261 261
             <div class="form-group row">
262 262
                 <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label">
263
-                    <?php _e( 'Expiration Date', 'invoicing' );?>
263
+                    <?php _e('Expiration Date', 'invoicing'); ?>
264 264
                 </label>
265 265
                 <div class="col-sm-8">
266 266
                     <?php
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
                                 'type'        => 'datepicker',
270 270
                                 'id'          => 'wpinv_discount_expiration',
271 271
                                 'name'        => 'wpinv_discount_expiration',
272
-                                'label'       => __( 'Expiration Date', 'invoicing' ),
272
+                                'label'       => __('Expiration Date', 'invoicing'),
273 273
                                 'placeholder' => 'YYYY-MM-DD 00:00',
274 274
                                 'class'       => 'form-control-sm',
275
-                                'value'       => $discount->get_end_date( 'edit' ),
275
+                                'value'       => $discount->get_end_date('edit'),
276 276
                                 'extra_attributes' => array(
277 277
                                     'data-enable-time' => 'true',
278 278
                                     'data-time_24hr'   => 'true',
@@ -285,27 +285,27 @@  discard block
 block discarded – undo
285 285
                     ?>
286 286
                 </div>
287 287
                 <div class="col-sm-1 pt-2 pl-0">
288
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span>
288
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span>
289 289
                 </div>
290 290
             </div>
291
-            <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?>
291
+            <?php do_action('wpinv_discount_form_expiration', $discount); ?>
292 292
 
293
-            <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?>
293
+            <?php do_action('wpinv_discount_form_before_min_total', $discount); ?>
294 294
             <div class="form-group row">
295 295
                 <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label">
296
-                    <?php _e( 'Minimum Amount', 'invoicing' );?>
296
+                    <?php _e('Minimum Amount', 'invoicing'); ?>
297 297
                 </label>
298 298
                 <div class="col-sm-8">
299 299
                     <div class="input-group input-group-sm">
300
-                        <?php if( 'left' == $position ) : ?>
300
+                        <?php if ('left' == $position) : ?>
301 301
                             <div class="input-group-prepend">
302 302
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
303 303
                             </div>
304 304
                         <?php endif; ?>
305 305
 
306
-                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control">
306
+                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control">
307 307
 
308
-                        <?php if( 'left' != $position ) : ?>
308
+                        <?php if ('left' != $position) : ?>
309 309
                             <div class="input-group-append">
310 310
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
311 311
                             </div>
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
                     </div>
314 314
                 </div>
315 315
                 <div class="col-sm-1 pt-2 pl-0">
316
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span>
316
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span>
317 317
                 </div>
318 318
             </div>
319
-            <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?>
319
+            <?php do_action('wpinv_discount_form_min_total', $discount); ?>
320 320
 
321
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
321
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
322 322
             <div class="form-group row">
323 323
                 <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label">
324
-                    <?php _e( 'Maximum Amount', 'invoicing' );?>
324
+                    <?php _e('Maximum Amount', 'invoicing'); ?>
325 325
                 </label>
326 326
                 <div class="col-sm-8">
327 327
                     <div class="input-group input-group-sm">
328
-                        <?php if( 'left' == $position ) : ?>
328
+                        <?php if ('left' == $position) : ?>
329 329
                             <div class="input-group-prepend">
330 330
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
331 331
                             </div>
332 332
                         <?php endif; ?>
333 333
 
334
-                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control">
334
+                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control">
335 335
 
336
-                        <?php if( 'left' != $position ) : ?>
336
+                        <?php if ('left' != $position) : ?>
337 337
                             <div class="input-group-append">
338 338
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
339 339
                             </div>
@@ -341,30 +341,30 @@  discard block
 block discarded – undo
341 341
                     </div>
342 342
                 </div>
343 343
                 <div class="col-sm-1 pt-2 pl-0">
344
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span>
344
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span>
345 345
                 </div>
346 346
             </div>
347
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
347
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
348 348
 
349
-            <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?>
349
+            <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?>
350 350
             <div class="form-group row">
351 351
                 <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label">
352
-                    <?php _e( 'Maximum Uses', 'invoicing' );?>
352
+                    <?php _e('Maximum Uses', 'invoicing'); ?>
353 353
                 </label>
354 354
                 <div class="col-sm-8">
355
-                    <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
355
+                    <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
356 356
                 </div>
357 357
                 <div class="col-sm-1 pt-2 pl-0">
358
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span>
358
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span>
359 359
                 </div>
360 360
             </div>
361
-            <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?>
361
+            <?php do_action('wpinv_discount_form_max_uses', $discount); ?>
362 362
 
363
-            <?php do_action( 'wpinv_discount_form_last', $discount ); ?>
363
+            <?php do_action('wpinv_discount_form_last', $discount); ?>
364 364
 
365 365
         </div>
366 366
         <?php
367
-        do_action( 'wpinv_discount_form_bottom', $post );
367
+        do_action('wpinv_discount_form_bottom', $post);
368 368
     }
369 369
 
370 370
     /**
@@ -372,30 +372,30 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
 	 * @param int $post_id
374 374
 	 */
375
-	public static function save( $post_id ) {
375
+	public static function save($post_id) {
376 376
 
377 377
         // Prepare the discount.
378
-        $discount = new WPInv_Discount( $post_id );
378
+        $discount = new WPInv_Discount($post_id);
379 379
 
380 380
         // Load new data.
381 381
         $discount->set_props(
382 382
 			array(
383
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null,
384
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null,
385
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
386
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
387
-				'is_single_use'        => isset( $_POST['wpinv_discount_single_use'] ),
388
-                'type'                 => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null,
389
-				'is_recurring'         => isset( $_POST['wpinv_discount_recurring'] ),
390
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(),
391
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(),
392
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null,
393
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null,
394
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null,
383
+				'code'                 => isset($_POST['wpinv_discount_code']) ? $_POST['wpinv_discount_code'] : null,
384
+				'amount'               => isset($_POST['wpinv_discount_amount']) ? $_POST['wpinv_discount_amount'] : null,
385
+				'start'                => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null,
386
+				'expiration'           => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null,
387
+				'is_single_use'        => isset($_POST['wpinv_discount_single_use']),
388
+                'type'                 => isset($_POST['wpinv_discount_type']) ? $_POST['wpinv_discount_type'] : null,
389
+				'is_recurring'         => isset($_POST['wpinv_discount_recurring']),
390
+				'items'                => isset($_POST['wpinv_discount_items']) ? $_POST['wpinv_discount_items'] : array(),
391
+				'excluded_items'       => isset($_POST['wpinv_discount_excluded_items']) ? $_POST['wpinv_discount_excluded_items'] : array(),
392
+				'max_uses'             => isset($_POST['wpinv_discount_max_uses']) ? $_POST['wpinv_discount_max_uses'] : null,
393
+				'min_total'            => isset($_POST['wpinv_discount_min_total']) ? $_POST['wpinv_discount_min_total'] : null,
394
+				'max_total'            => isset($_POST['wpinv_discount_max_total']) ? $_POST['wpinv_discount_max_total'] : null,
395 395
 			)
396 396
         );
397 397
 
398 398
 		$discount->save();
399
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
399
+		do_action('getpaid_discount_metabox_save', $post_id, $discount);
400 400
 	}
401 401
 }
Please login to merge, or discard this patch.