Passed
Push — master ( dafa5d...51f1c0 )
by Brian
05:09
created
includes/invoice-functions.php 1 patch
Spacing   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves the current invoice.
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 function getpaid_get_current_invoice_id() {
15 15
 
16 16
     // Ensure that we have an invoice key.
17
-    if ( empty( $_GET['invoice_key'] ) ) {
17
+    if (empty($_GET['invoice_key'])) {
18 18
         return 0;
19 19
     }
20 20
 
21 21
     // Retrieve an invoice using the key.
22
-    $invoice = new WPInv_Invoice( $_GET['invoice_key'] );
22
+    $invoice = new WPInv_Invoice($_GET['invoice_key']);
23 23
 
24 24
     // Compare the invoice key and the parsed key.
25
-    if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) {
25
+    if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) {
26 26
         return $invoice->get_id();
27 27
     }
28 28
 
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 /**
33 33
  * Checks if the current user cna view an invoice.
34 34
  */
35
-function wpinv_user_can_view_invoice( $invoice ) {
36
-    $invoice = new WPInv_Invoice( $invoice );
35
+function wpinv_user_can_view_invoice($invoice) {
36
+    $invoice = new WPInv_Invoice($invoice);
37 37
 
38 38
     // Abort if the invoice does not exist.
39
-    if ( 0 == $invoice->get_id() ) {
39
+    if (0 == $invoice->get_id()) {
40 40
         return false;
41 41
     }
42 42
 
43 43
     // Don't allow trash, draft status
44
-    if ( $invoice->is_draft() ) {
44
+    if ($invoice->is_draft()) {
45 45
         return false;
46 46
     }
47 47
 
48 48
     // If users are not required to login to check out, compare the invoice keys.
49
-    if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) {
49
+    if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) {
50 50
         return true;
51 51
     }
52 52
 
53 53
     // Always enable for admins..
54
-    if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user
54
+    if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user
55 55
         return true;
56 56
     }
57 57
 
58 58
     // Else, ensure that this is their invoice.
59
-    if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) {
59
+    if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) {
60 60
         return true;
61 61
     }
62 62
 
63
-    return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice );
63
+    return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice);
64 64
 }
65 65
 
66 66
 /**
67 67
  * Checks if the current user cna view an invoice receipt.
68 68
  */
69
-function wpinv_can_view_receipt( $invoice ) {
70
-	return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice );
69
+function wpinv_can_view_receipt($invoice) {
70
+	return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice);
71 71
 }
72 72
 
73 73
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function getpaid_get_invoice_post_types() {
79 79
     $post_types = array(
80
-        'wpi_quote'   => __( 'Quote', 'invoicing' ),
81
-        'wpi_invoice' => __( 'Invoice', 'invoicing' ),
80
+        'wpi_quote'   => __('Quote', 'invoicing'),
81
+        'wpi_invoice' => __('Invoice', 'invoicing'),
82 82
     );
83 83
 
84
-    return apply_filters( 'getpaid_invoice_post_types', $post_types );
84
+    return apply_filters('getpaid_invoice_post_types', $post_types);
85 85
 }
86 86
 
87 87
 /**
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
  * 
91 91
  * @param string $post_type The post type to check for.
92 92
  */
93
-function getpaid_is_invoice_post_type( $post_type ) {
94
-    return is_scalar( $post_type ) && ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() );
93
+function getpaid_is_invoice_post_type($post_type) {
94
+    return is_scalar($post_type) && !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types());
95 95
 }
96 96
 
97 97
 /**
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
102 102
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
103 103
  */
104
-function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) {
105
-    $data[ 'invoice_id' ] = 0;
106
-    return wpinv_insert_invoice( $data, $wp_error );
104
+function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) {
105
+    $data['invoice_id'] = 0;
106
+    return wpinv_insert_invoice($data, $wp_error);
107 107
 }
108 108
 
109 109
 /**
@@ -113,36 +113,36 @@  discard block
 block discarded – undo
113 113
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
114 114
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
115 115
  */
116
-function wpinv_update_invoice( $data = array(), $wp_error = false ) {
116
+function wpinv_update_invoice($data = array(), $wp_error = false) {
117 117
 
118 118
     // Backwards compatibility.
119
-    if ( ! empty( $data['ID'] ) ) {
119
+    if (!empty($data['ID'])) {
120 120
         $data['invoice_id'] = $data['ID'];
121 121
     }
122 122
 
123 123
     // Do we have an invoice id?
124
-    if ( empty( $data['invoice_id'] ) ) {
125
-        return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0;
124
+    if (empty($data['invoice_id'])) {
125
+        return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0;
126 126
     }
127 127
 
128 128
     // Retrieve the invoice.
129
-    $invoice = wpinv_get_invoice( $data['invoice_id'] );
129
+    $invoice = wpinv_get_invoice($data['invoice_id']);
130 130
 
131 131
     // And abort if it does not exist.
132
-    if ( empty( $invoice ) ) {
133
-        return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0;
132
+    if (empty($invoice)) {
133
+        return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0;
134 134
     }
135 135
 
136 136
     // Do not update totals for paid / refunded invoices.
137
-    if ( $invoice->is_paid() || $invoice->is_refunded() ) {
137
+    if ($invoice->is_paid() || $invoice->is_refunded()) {
138 138
 
139
-        if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) {
140
-            return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0;
139
+        if (!empty($data['items']) || !empty($data['cart_details'])) {
140
+            return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0;
141 141
         }
142 142
 
143 143
     }
144 144
 
145
-    return wpinv_insert_invoice( $data, $wp_error );
145
+    return wpinv_insert_invoice($data, $wp_error);
146 146
 
147 147
 }
148 148
 
@@ -153,34 +153,34 @@  discard block
 block discarded – undo
153 153
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
154 154
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
155 155
  */
156
-function wpinv_insert_invoice( $data = array(), $wp_error = false ) {
156
+function wpinv_insert_invoice($data = array(), $wp_error = false) {
157 157
 
158 158
     // Ensure that we have invoice data.
159
-    if ( empty( $data ) ) {
159
+    if (empty($data)) {
160 160
         return false;
161 161
     }
162 162
 
163 163
     // The invoice id will be provided when updating an invoice.
164
-    $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false;
164
+    $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false;
165 165
 
166 166
     // Retrieve the invoice.
167
-    $invoice = new WPInv_Invoice( $data['invoice_id'] );
167
+    $invoice = new WPInv_Invoice($data['invoice_id']);
168 168
 
169 169
     // Do we have an error?
170
-    if ( ! empty( $invoice->last_error ) ) {
171
-        return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0;
170
+    if (!empty($invoice->last_error)) {
171
+        return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0;
172 172
     }
173 173
 
174 174
     // Backwards compatibility (billing address).
175
-    if ( ! empty( $data['user_info'] ) ) {
175
+    if (!empty($data['user_info'])) {
176 176
 
177
-        foreach ( $data['user_info'] as $key => $value ) {
177
+        foreach ($data['user_info'] as $key => $value) {
178 178
 
179
-            if ( $key == 'discounts' ) {
179
+            if ($key == 'discounts') {
180 180
                 $value = (array) $value;
181
-                $data[ 'discount_code' ] = empty( $value ) ? null : $value[0];
181
+                $data['discount_code'] = empty($value) ? null : $value[0];
182 182
             } else {
183
-                $data[ $key ] = $value;
183
+                $data[$key] = $value;
184 184
             }
185 185
 
186 186
         }
@@ -188,30 +188,30 @@  discard block
 block discarded – undo
188 188
     }
189 189
 
190 190
     // Backwards compatibility.
191
-    if ( ! empty( $data['payment_details'] ) ) {
191
+    if (!empty($data['payment_details'])) {
192 192
 
193
-        foreach ( $data['payment_details'] as $key => $value ) {
194
-            $data[ $key ] = $value;
193
+        foreach ($data['payment_details'] as $key => $value) {
194
+            $data[$key] = $value;
195 195
         }
196 196
 
197 197
     }
198 198
 
199 199
     // Set up the owner of the invoice.
200
-    $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id();
200
+    $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id();
201 201
 
202 202
     // Make sure the user exists.
203
-    if ( ! get_userdata( $user_id ) ) {
204
-        return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0;
203
+    if (!get_userdata($user_id)) {
204
+        return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0;
205 205
     }
206 206
 
207
-    $address = wpinv_get_user_address( $user_id );
207
+    $address = wpinv_get_user_address($user_id);
208 208
 
209
-    foreach ( $address as $key => $value ) {
209
+    foreach ($address as $key => $value) {
210 210
 
211
-        if ( $value == '' ) {
212
-            $address[ $key ] = null;
211
+        if ($value == '') {
212
+            $address[$key] = null;
213 213
         } else {
214
-            $address[ $key ] = wpinv_clean( $value );
214
+            $address[$key] = wpinv_clean($value);
215 215
         }
216 216
 
217 217
     }
@@ -222,103 +222,103 @@  discard block
 block discarded – undo
222 222
         array(
223 223
 
224 224
             // Basic info.
225
-            'template'             => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null,
226
-            'email_cc'             => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null,
227
-            'date_created'         => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null,
228
-            'due_date'             => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null,
229
-            'date_completed'       => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null,
230
-            'number'               => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null,
231
-            'key'                  => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null,
232
-            'status'               => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null,
233
-            'post_type'            => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null,
234
-            'user_ip'              => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(),
235
-            'parent_id'            => isset( $data['parent'] ) ? intval( $data['parent'] ) : null,
236
-            'mode'                 => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null,
237
-            'description'          => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null,
225
+            'template'             => isset($data['template']) ? wpinv_clean($data['template']) : null,
226
+            'email_cc'             => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null,
227
+            'date_created'         => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null,
228
+            'due_date'             => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null,
229
+            'date_completed'       => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null,
230
+            'number'               => isset($data['number']) ? wpinv_clean($data['number']) : null,
231
+            'key'                  => isset($data['key']) ? wpinv_clean($data['key']) : null,
232
+            'status'               => isset($data['status']) ? wpinv_clean($data['status']) : null,
233
+            'post_type'            => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null,
234
+            'user_ip'              => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(),
235
+            'parent_id'            => isset($data['parent']) ? intval($data['parent']) : null,
236
+            'mode'                 => isset($data['mode']) ? wpinv_clean($data['mode']) : null,
237
+            'description'          => isset($data['description']) ? wp_kses_post($data['description']) : null,
238 238
 
239 239
             // Payment info.
240
-            'disable_taxes'        => ! empty( $data['disable_taxes'] ),
241
-            'currency'             => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(),
242
-            'gateway'              => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null,
243
-            'transaction_id'       => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null,
244
-            'discount_code'        => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null,
245
-            'payment_form'         => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null,
246
-            'submission_id'        => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null,
247
-            'subscription_id'      => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null,
248
-            'is_viewed'            => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null,
249
-            'fees'                 => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null,
250
-            'discounts'            => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null,
251
-            'taxes'                => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null,
240
+            'disable_taxes'        => !empty($data['disable_taxes']),
241
+            'currency'             => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(),
242
+            'gateway'              => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null,
243
+            'transaction_id'       => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null,
244
+            'discount_code'        => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null,
245
+            'payment_form'         => isset($data['payment_form']) ? intval($data['payment_form']) : null,
246
+            'submission_id'        => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null,
247
+            'subscription_id'      => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null,
248
+            'is_viewed'            => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null,
249
+            'fees'                 => isset($data['fees']) ? wpinv_clean($data['fees']) : null,
250
+            'discounts'            => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null,
251
+            'taxes'                => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null,
252 252
             
253 253
 
254 254
             // Billing details.
255 255
             'user_id'              => $data['user_id'],
256
-            'first_name'           => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'],
257
-            'last_name'            => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'],
258
-            'address'              => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] ,
259
-            'vat_number'           => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'],
260
-            'company'              => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'],
261
-            'zip'                  => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'],
262
-            'state'                => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'],
263
-            'city'                 => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'],
264
-            'country'              => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'],
265
-            'phone'                => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'],
266
-            'address_confirmed'    => ! empty( $data['address_confirmed'] ),
256
+            'first_name'           => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'],
257
+            'last_name'            => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'],
258
+            'address'              => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'],
259
+            'vat_number'           => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'],
260
+            'company'              => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'],
261
+            'zip'                  => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'],
262
+            'state'                => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'],
263
+            'city'                 => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'],
264
+            'country'              => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'],
265
+            'phone'                => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'],
266
+            'address_confirmed'    => !empty($data['address_confirmed']),
267 267
 
268 268
         )
269 269
 
270 270
     );
271 271
 
272 272
     // Backwards compatibililty.
273
-    if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) {
273
+    if (!empty($data['cart_details']) && is_array($data['cart_details'])) {
274 274
         $data['items'] = array();
275 275
 
276
-        foreach( $data['cart_details'] as $_item ) {
276
+        foreach ($data['cart_details'] as $_item) {
277 277
 
278 278
             // Ensure that we have an item id.
279
-            if ( empty(  $_item['id']  ) ) {
279
+            if (empty($_item['id'])) {
280 280
                 continue;
281 281
             }
282 282
 
283 283
             // Retrieve the item.
284
-            $item = new GetPaid_Form_Item(  $_item['id']  );
284
+            $item = new GetPaid_Form_Item($_item['id']);
285 285
 
286 286
             // Ensure that it is purchasable.
287
-            if ( ! $item->can_purchase() ) {
287
+            if (!$item->can_purchase()) {
288 288
                 continue;
289 289
             }
290 290
 
291 291
             // Set quantity.
292
-            if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) {
293
-                $item->set_quantity( $_item['quantity'] );
292
+            if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) {
293
+                $item->set_quantity($_item['quantity']);
294 294
             }
295 295
 
296 296
             // Set price.
297
-            if ( isset( $_item['item_price'] ) ) {
298
-                $item->set_price( $_item['item_price'] );
297
+            if (isset($_item['item_price'])) {
298
+                $item->set_price($_item['item_price']);
299 299
             }
300 300
 
301
-            if ( isset( $_item['custom_price'] ) ) {
302
-                $item->set_price( $_item['custom_price'] );
301
+            if (isset($_item['custom_price'])) {
302
+                $item->set_price($_item['custom_price']);
303 303
             }
304 304
 
305 305
             // Set name.
306
-            if ( ! empty( $_item['name'] ) ) {
307
-                $item->set_name( $_item['name'] );
306
+            if (!empty($_item['name'])) {
307
+                $item->set_name($_item['name']);
308 308
             }
309 309
 
310 310
             // Set description.
311
-            if ( isset( $_item['description'] ) ) {
312
-                $item->set_custom_description( $_item['description'] );
311
+            if (isset($_item['description'])) {
312
+                $item->set_custom_description($_item['description']);
313 313
             }
314 314
 
315 315
             // Set meta.
316
-            if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) {
316
+            if (isset($_item['meta']) && is_array($_item['meta'])) {
317 317
 
318
-                $item->set_item_meta( $_item['meta'] );
318
+                $item->set_item_meta($_item['meta']);
319 319
 
320
-                if ( isset( $_item['meta']['description'] ) ) {
321
-                    $item->set_custom_description( $_item['meta']['description'] );
320
+                if (isset($_item['meta']['description'])) {
321
+                    $item->set_custom_description($_item['meta']['description']);
322 322
                 }
323 323
 
324 324
             }
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
     }
330 330
 
331 331
     // Add invoice items.
332
-    if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) {
332
+    if (!empty($data['items']) && is_array($data['items'])) {
333 333
 
334
-        $invoice->set_items( array() );
334
+        $invoice->set_items(array());
335 335
 
336
-        foreach ( $data['items'] as $item ) {
336
+        foreach ($data['items'] as $item) {
337 337
 
338
-            if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) {
339
-                $invoice->add_item( $item );
338
+            if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) {
339
+                $invoice->add_item($item);
340 340
             }
341 341
 
342 342
         }
@@ -347,30 +347,30 @@  discard block
 block discarded – undo
347 347
     $invoice->recalculate_total();
348 348
     $invoice->save();
349 349
 
350
-    if ( ! $invoice->get_id() ) {
351
-        return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0;
350
+    if (!$invoice->get_id()) {
351
+        return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0;
352 352
     }
353 353
 
354 354
     // Add private note.
355
-    if ( ! empty( $data['private_note'] ) ) {
356
-        $invoice->add_note( $data['private_note'] );
355
+    if (!empty($data['private_note'])) {
356
+        $invoice->add_note($data['private_note']);
357 357
     }
358 358
 
359 359
     // User notes.
360
-    if ( !empty( $data['user_note'] ) ) {
361
-        $invoice->add_note( $data['user_note'], true );
360
+    if (!empty($data['user_note'])) {
361
+        $invoice->add_note($data['user_note'], true);
362 362
     }
363 363
 
364 364
     // Created via.
365
-    if ( isset( $data['created_via'] ) ) {
366
-        update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] );
365
+    if (isset($data['created_via'])) {
366
+        update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']);
367 367
     }
368 368
 
369 369
     // Backwards compatiblity.
370
-    if ( $invoice->is_quote() ) {
370
+    if ($invoice->is_quote()) {
371 371
 
372
-        if ( isset( $data['valid_until'] ) ) {
373
-            update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] );
372
+        if (isset($data['valid_until'])) {
373
+            update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']);
374 374
         }
375 375
         return $invoice;
376 376
 
@@ -385,18 +385,18 @@  discard block
 block discarded – undo
385 385
  * @param $bool $deprecated
386 386
  * @return WPInv_Invoice|null
387 387
  */
388
-function wpinv_get_invoice( $invoice = 0, $deprecated = false ) {
388
+function wpinv_get_invoice($invoice = 0, $deprecated = false) {
389 389
 
390 390
     // If we are retrieving the invoice from the cart...
391
-    if ( $deprecated && empty( $invoice ) ) {
391
+    if ($deprecated && empty($invoice)) {
392 392
         $invoice = (int) getpaid_get_current_invoice_id();
393 393
     }
394 394
 
395 395
     // Retrieve the invoice.
396
-    $invoice = new WPInv_Invoice( $invoice );
396
+    $invoice = new WPInv_Invoice($invoice);
397 397
 
398 398
     // Check if it exists.
399
-    if ( $invoice->get_id() != 0 ) {
399
+    if ($invoice->get_id() != 0) {
400 400
         return $invoice;
401 401
     }
402 402
 
@@ -409,15 +409,15 @@  discard block
 block discarded – undo
409 409
  * @param array $args Args to search for.
410 410
  * @return WPInv_Invoice[]|int[]|object
411 411
  */
412
-function wpinv_get_invoices( $args ) {
412
+function wpinv_get_invoices($args) {
413 413
 
414 414
     // Prepare args.
415 415
     $args = wp_parse_args(
416 416
         $args,
417 417
         array(
418
-            'status'   => array_keys( wpinv_get_invoice_statuses() ),
418
+            'status'   => array_keys(wpinv_get_invoice_statuses()),
419 419
             'type'     => 'wpi_invoice',
420
-            'limit'    => get_option( 'posts_per_page' ),
420
+            'limit'    => get_option('posts_per_page'),
421 421
             'return'   => 'objects',
422 422
         )
423 423
     );
@@ -435,24 +435,24 @@  discard block
 block discarded – undo
435 435
         'post__in'       => 'include',
436 436
     );
437 437
 
438
-    foreach ( $map_legacy as $to => $from ) {
439
-        if ( isset( $args[ $from ] ) ) {
440
-            $args[ $to ] = $args[ $from ];
441
-            unset( $args[ $from ] );
438
+    foreach ($map_legacy as $to => $from) {
439
+        if (isset($args[$from])) {
440
+            $args[$to] = $args[$from];
441
+            unset($args[$from]);
442 442
         }
443 443
     }
444 444
 
445 445
     // Backwards compatibility.
446
-    if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) {
446
+    if (!empty($args['email']) && empty($args['user'])) {
447 447
         $args['user'] = $args['email'];
448
-        unset( $args['email'] );
448
+        unset($args['email']);
449 449
     }
450 450
 
451 451
     // Handle cases where the user is set as an email.
452
-    if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) {
453
-        $user = get_user_by( 'email', $args['user'] );
452
+    if (!empty($args['author']) && is_email($args['author'])) {
453
+        $user = get_user_by('email', $args['user']);
454 454
 
455
-        if ( $user ) {
455
+        if ($user) {
456 456
             $args['author'] = $user->user_email;
457 457
         }
458 458
 
@@ -463,31 +463,31 @@  discard block
 block discarded – undo
463 463
 
464 464
     // Show all posts.
465 465
     $paginate = true;
466
-    if ( isset( $args['paginate'] ) ) {
466
+    if (isset($args['paginate'])) {
467 467
 
468 468
         $paginate = $args['paginate'];
469
-        $args['no_found_rows'] = empty( $args['paginate'] );
470
-        unset( $args['paginate'] );
469
+        $args['no_found_rows'] = empty($args['paginate']);
470
+        unset($args['paginate']);
471 471
 
472 472
     }
473 473
 
474 474
     // Whether to return objects or fields.
475 475
     $return = $args['return'];
476
-    unset( $args['return'] );
476
+    unset($args['return']);
477 477
 
478 478
     // Get invoices.
479
-    $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) );
479
+    $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args));
480 480
 
481 481
     // Prepare the results.
482
-    if ( 'objects' === $return ) {
483
-        $results = array_map( 'wpinv_get_invoice', $invoices->posts );
484
-    } elseif ( 'self' === $return ) {
482
+    if ('objects' === $return) {
483
+        $results = array_map('wpinv_get_invoice', $invoices->posts);
484
+    } elseif ('self' === $return) {
485 485
         return $invoices;
486 486
     } else {
487 487
         $results = $invoices->posts;
488 488
     }
489 489
 
490
-    if ( $paginate ) {
490
+    if ($paginate) {
491 491
         return (object) array(
492 492
             'invoices'      => $results,
493 493
             'total'         => $invoices->found_posts,
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
  * @param string $transaction_id The transaction id to check.
506 506
  * @return int Invoice id on success or 0 on failure
507 507
  */
508
-function wpinv_get_id_by_transaction_id( $transaction_id ) {
509
-    return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' );
508
+function wpinv_get_id_by_transaction_id($transaction_id) {
509
+    return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id');
510 510
 }
511 511
 
512 512
 /**
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
  * @param string $invoice_number The invoice number to check.
516 516
  * @return int Invoice id on success or 0 on failure
517 517
  */
518
-function wpinv_get_id_by_invoice_number( $invoice_number ) {
519
-    return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' );
518
+function wpinv_get_id_by_invoice_number($invoice_number) {
519
+    return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number');
520 520
 }
521 521
 
522 522
 /**
@@ -525,8 +525,8 @@  discard block
 block discarded – undo
525 525
  * @param string $invoice_key The invoice key to check.
526 526
  * @return int Invoice id on success or 0 on failure
527 527
  */
528
-function wpinv_get_invoice_id_by_key( $invoice_key ) {
529
-    return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' );
528
+function wpinv_get_invoice_id_by_key($invoice_key) {
529
+    return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key');
530 530
 }
531 531
 
532 532
 /**
@@ -536,19 +536,19 @@  discard block
 block discarded – undo
536 536
  * @param string $type Optionally filter by type i.e customer|system
537 537
  * @return array|null
538 538
  */
539
-function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) {
539
+function wpinv_get_invoice_notes($invoice = 0, $type = '') {
540 540
 
541 541
     // Prepare the invoice.
542
-    $invoice = wpinv_get_invoice( $invoice );
543
-    if ( empty( $invoice ) ) {
542
+    $invoice = wpinv_get_invoice($invoice);
543
+    if (empty($invoice)) {
544 544
         return NULL;
545 545
     }
546 546
 
547 547
     // Fetch notes.
548
-    $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type );
548
+    $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type);
549 549
 
550 550
     // Filter the notes.
551
-    return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type );
551
+    return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type);
552 552
 }
553 553
 
554 554
 /**
@@ -556,10 +556,10 @@  discard block
 block discarded – undo
556 556
  * 
557 557
  * @param string $post_type
558 558
  */
559
-function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) {
559
+function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') {
560 560
 
561
-    $label   = getpaid_get_post_type_label( $post_type, false );
562
-    $label   = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label );
561
+    $label   = getpaid_get_post_type_label($post_type, false);
562
+    $label   = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label);
563 563
     $columns = array(
564 564
 
565 565
             'invoice-number'  => array(
@@ -568,22 +568,22 @@  discard block
 block discarded – undo
568 568
             ),
569 569
 
570 570
             'created-date'    => array(
571
-                'title' => __( 'Created Date', 'invoicing' ),
571
+                'title' => __('Created Date', 'invoicing'),
572 572
                 'class' => 'text-left'
573 573
             ),
574 574
 
575 575
             'payment-date'    => array(
576
-                'title' => __( 'Payment Date', 'invoicing' ),
576
+                'title' => __('Payment Date', 'invoicing'),
577 577
                 'class' => 'text-left'
578 578
             ),
579 579
 
580 580
             'invoice-status'  => array(
581
-                'title' => __( 'Status', 'invoicing' ),
581
+                'title' => __('Status', 'invoicing'),
582 582
                 'class' => 'text-center'
583 583
             ),
584 584
 
585 585
             'invoice-total'   => array(
586
-                'title' => __( 'Total', 'invoicing' ),
586
+                'title' => __('Total', 'invoicing'),
587 587
                 'class' => 'text-right'
588 588
             ),
589 589
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 
595 595
         );
596 596
 
597
-    return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type );
597
+    return apply_filters('wpinv_user_invoices_columns', $columns, $post_type);
598 598
 }
599 599
 
600 600
 /**
@@ -604,59 +604,59 @@  discard block
 block discarded – undo
604 604
 
605 605
     // Find the invoice.
606 606
     $invoice_id = getpaid_get_current_invoice_id();
607
-    $invoice = new WPInv_Invoice( $invoice_id );
607
+    $invoice = new WPInv_Invoice($invoice_id);
608 608
 
609 609
     // Abort if non was found.
610
-    if ( empty( $invoice_id ) || $invoice->is_draft() ) {
610
+    if (empty($invoice_id) || $invoice->is_draft()) {
611 611
 
612 612
         return aui()->alert(
613 613
             array(
614 614
                 'type'    => 'warning',
615
-                'content' => __( 'We could not find your invoice', 'invoicing' ),
615
+                'content' => __('We could not find your invoice', 'invoicing'),
616 616
             )
617 617
         );
618 618
 
619 619
     }
620 620
 
621 621
     // Can the user view this invoice?
622
-    if ( ! wpinv_can_view_receipt( $invoice_id ) ) {
622
+    if (!wpinv_can_view_receipt($invoice_id)) {
623 623
 
624 624
         return aui()->alert(
625 625
             array(
626 626
                 'type'    => 'warning',
627
-                'content' => __( 'You are not allowed to view this receipt', 'invoicing' ),
627
+                'content' => __('You are not allowed to view this receipt', 'invoicing'),
628 628
             )
629 629
         );
630 630
 
631 631
     }
632 632
 
633 633
     // Load the template.
634
-    return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) );
634
+    return wpinv_get_template_html('invoice-receipt.php', compact('invoice'));
635 635
 
636 636
 }
637 637
 
638 638
 /**
639 639
  * Displays the invoice history.
640 640
  */
641
-function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) {
641
+function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') {
642 642
 
643 643
     // Ensure that we have a user id.
644
-    if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
644
+    if (empty($user_id) || !is_numeric($user_id)) {
645 645
         $user_id = get_current_user_id();
646 646
     }
647 647
 
648
-    $label = getpaid_get_post_type_label( $post_type );
649
-    $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label );
648
+    $label = getpaid_get_post_type_label($post_type);
649
+    $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label);
650 650
 
651 651
     // View user id.
652
-    if ( empty( $user_id ) ) {
652
+    if (empty($user_id)) {
653 653
 
654 654
         return aui()->alert(
655 655
             array(
656 656
                 'type'    => 'warning',
657 657
                 'content' => sprintf(
658
-                    __( 'You must be logged in to view your %s.', 'invoicing' ),
659
-                    strtolower( $label )
658
+                    __('You must be logged in to view your %s.', 'invoicing'),
659
+                    strtolower($label)
660 660
                 )
661 661
             )
662 662
         );
@@ -667,23 +667,23 @@  discard block
 block discarded – undo
667 667
     $invoices = wpinv_get_invoices(
668 668
 
669 669
         array(
670
-            'page'      => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1,
670
+            'page'      => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1,
671 671
             'user'      => $user_id,
672 672
             'paginate'  => true,
673 673
             'type'      => $post_type,
674
-            'status'    => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ),
674
+            'status'    => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)),
675 675
         )
676 676
 
677 677
     );
678 678
 
679
-    if ( empty( $invoices->total ) ) {
679
+    if (empty($invoices->total)) {
680 680
 
681 681
         return aui()->alert(
682 682
             array(
683 683
                 'type'    => 'info',
684 684
                 'content' => sprintf(
685
-                    __( 'No %s found.', 'invoicing' ),
686
-                    strtolower( $label )
685
+                    __('No %s found.', 'invoicing'),
686
+                    strtolower($label)
687 687
                 )
688 688
             )
689 689
         );
@@ -691,38 +691,38 @@  discard block
 block discarded – undo
691 691
     }
692 692
 
693 693
     // Load the template.
694
-    return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) );
694
+    return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type'));
695 695
 
696 696
 }
697 697
 
698 698
 /**
699 699
  * Formats an invoice number given an invoice type.
700 700
  */
701
-function wpinv_format_invoice_number( $number, $type = '' ) {
701
+function wpinv_format_invoice_number($number, $type = '') {
702 702
 
703 703
     // Allow other plugins to overide this.
704
-    $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type );
705
-    if ( null !== $check ) {
704
+    $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type);
705
+    if (null !== $check) {
706 706
         return $check;
707 707
     }
708 708
 
709 709
     // Ensure that we have a numeric number.
710
-    if ( ! is_numeric( $number ) ) {
710
+    if (!is_numeric($number)) {
711 711
         return $number;
712 712
     }
713 713
 
714 714
     // Format the number.
715
-    $padd             = absint( (int) wpinv_get_option( 'invoice_number_padd', 5 ) );
716
-    $prefix           = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) );
717
-    $prefix           = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) );
718
-    $postfix          = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) );
719
-    $postfix          = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) );
720
-    $formatted_number = zeroise( absint( $number ), $padd );
715
+    $padd             = absint((int) wpinv_get_option('invoice_number_padd', 5));
716
+    $prefix           = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-'));
717
+    $prefix           = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type));
718
+    $postfix          = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix'));
719
+    $postfix          = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type));
720
+    $formatted_number = zeroise(absint($number), $padd);
721 721
 
722 722
     // Add the prefix and post fix.
723 723
     $formatted_number = $prefix . $formatted_number . $postfix;
724 724
 
725
-    return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd );
725
+    return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd);
726 726
 }
727 727
 
728 728
 /**
@@ -731,58 +731,58 @@  discard block
 block discarded – undo
731 731
  * @param string $type.
732 732
  * @return int|null|bool
733 733
  */
734
-function wpinv_get_next_invoice_number( $type = '' ) {
734
+function wpinv_get_next_invoice_number($type = '') {
735 735
 
736 736
     // Allow plugins to overide this.
737
-    $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type );
738
-    if ( null !== $check ) {
737
+    $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type);
738
+    if (null !== $check) {
739 739
         return $check;
740 740
     }
741 741
 
742 742
     // Ensure sequential invoice numbers is active.
743
-    if ( ! wpinv_sequential_number_active() ) {
743
+    if (!wpinv_sequential_number_active()) {
744 744
         return false;
745 745
     }
746 746
 
747 747
     // Retrieve the current number and the start number.
748
-    $number = (int) get_option( 'wpinv_last_invoice_number', 0 );
749
-    $start  = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) );
748
+    $number = (int) get_option('wpinv_last_invoice_number', 0);
749
+    $start  = absint((int) wpinv_get_option('invoice_sequence_start', 1));
750 750
 
751 751
     // Ensure that we are starting at a positive integer.
752
-    $start  = max( $start, 1 );
752
+    $start  = max($start, 1);
753 753
 
754 754
     // If this is the first invoice, use the start number.
755
-    $number = max( $start, $number );
755
+    $number = max($start, $number);
756 756
 
757 757
     // Format the invoice number.
758
-    $formatted_number = wpinv_format_invoice_number( $number, $type );
758
+    $formatted_number = wpinv_format_invoice_number($number, $type);
759 759
 
760 760
     // Ensure that this number is unique.
761
-    $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' );
761
+    $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number');
762 762
 
763 763
     // We found a match. Nice.
764
-    if ( empty( $invoice_id ) ) {
765
-        update_option( 'wpinv_last_invoice_number', $number );
766
-        return apply_filters( 'wpinv_get_next_invoice_number', $number );
764
+    if (empty($invoice_id)) {
765
+        update_option('wpinv_last_invoice_number', $number);
766
+        return apply_filters('wpinv_get_next_invoice_number', $number);
767 767
     }
768 768
 
769
-    update_option( 'wpinv_last_invoice_number', $number + 1 );
770
-    return wpinv_get_next_invoice_number( $type );
769
+    update_option('wpinv_last_invoice_number', $number + 1);
770
+    return wpinv_get_next_invoice_number($type);
771 771
 
772 772
 }
773 773
 
774 774
 /**
775 775
  * The prefix used for invoice paths.
776 776
  */
777
-function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) {
778
-    return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type );
777
+function wpinv_post_name_prefix($post_type = 'wpi_invoice') {
778
+    return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type);
779 779
 }
780 780
 
781
-function wpinv_generate_post_name( $post_ID ) {
782
-    $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) );
783
-    $post_name = sanitize_title( $prefix . $post_ID );
781
+function wpinv_generate_post_name($post_ID) {
782
+    $prefix = wpinv_post_name_prefix(get_post_type($post_ID));
783
+    $post_name = sanitize_title($prefix . $post_ID);
784 784
 
785
-    return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix );
785
+    return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix);
786 786
 }
787 787
 
788 788
 /**
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
  * 
791 791
  * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object.
792 792
  */
793
-function wpinv_is_invoice_viewed( $invoice ) {
794
-    $invoice = new WPInv_Invoice( $invoice );
793
+function wpinv_is_invoice_viewed($invoice) {
794
+    $invoice = new WPInv_Invoice($invoice);
795 795
     return (bool) $invoice->get_is_viewed();
796 796
 }
797 797
 
@@ -800,17 +800,17 @@  discard block
 block discarded – undo
800 800
  * 
801 801
  * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object.
802 802
  */
803
-function getpaid_maybe_mark_invoice_as_viewed( $invoice ) {
804
-    $invoice = new WPInv_Invoice( $invoice );
803
+function getpaid_maybe_mark_invoice_as_viewed($invoice) {
804
+    $invoice = new WPInv_Invoice($invoice);
805 805
 
806
-    if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) {
807
-        $invoice->set_is_viewed( true );
806
+    if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) {
807
+        $invoice->set_is_viewed(true);
808 808
         $invoice->save();
809 809
     }
810 810
 
811 811
 }
812
-add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' );
813
-add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' );
812
+add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed');
813
+add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed');
814 814
 
815 815
 /**
816 816
  * Processes an invoice refund.
@@ -819,27 +819,27 @@  discard block
 block discarded – undo
819 819
  * @param array $status_transition
820 820
  * @todo: descrease customer/store earnings
821 821
  */
822
-function getpaid_maybe_process_refund( $invoice, $status_transition ) {
822
+function getpaid_maybe_process_refund($invoice, $status_transition) {
823 823
 
824
-    if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) {
824
+    if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) {
825 825
         return;
826 826
     }
827 827
 
828 828
     $discount_code = $invoice->get_discount_code();
829
-    if ( ! empty( $discount_code ) ) {
830
-        $discount = wpinv_get_discount_obj( $discount_code );
829
+    if (!empty($discount_code)) {
830
+        $discount = wpinv_get_discount_obj($discount_code);
831 831
 
832
-        if ( $discount->exists() ) {
832
+        if ($discount->exists()) {
833 833
             $discount->increase_usage( -1 );
834 834
         }
835 835
 
836 836
     }
837 837
 
838
-    do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() );
839
-    do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() );
840
-    do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() );
838
+    do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id());
839
+    do_action('wpinv_refund_invoice', $invoice, $invoice->get_id());
840
+    do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id());
841 841
 }
842
-add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 );
842
+add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2);
843 843
 
844 844
 
845 845
 /**
@@ -847,48 +847,48 @@  discard block
 block discarded – undo
847 847
  *
848 848
  * @param int $invoice_id
849 849
  */
850
-function getpaid_process_invoice_payment( $invoice_id ) {
850
+function getpaid_process_invoice_payment($invoice_id) {
851 851
 
852 852
     // Fetch the invoice.
853
-    $invoice = new WPInv_Invoice( $invoice_id );
853
+    $invoice = new WPInv_Invoice($invoice_id);
854 854
 
855 855
     // We only want to do this once.
856
-    if ( 1 ==  get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) {
856
+    if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) {
857 857
         return;
858 858
     }
859 859
 
860
-    update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 );
860
+    update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1);
861 861
 
862 862
     // Fires when processing a payment.
863
-    do_action( 'getpaid_process_payment', $invoice );
863
+    do_action('getpaid_process_payment', $invoice);
864 864
 
865 865
     // Fire an action for each invoice item.
866
-    foreach( $invoice->get_items() as $item ) {
867
-        do_action( 'getpaid_process_item_payment', $item, $invoice );
866
+    foreach ($invoice->get_items() as $item) {
867
+        do_action('getpaid_process_item_payment', $item, $invoice);
868 868
     }
869 869
 
870 870
     // Increase discount usage.
871 871
     $discount_code = $invoice->get_discount_code();
872
-    if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) {
873
-        $discount = wpinv_get_discount_obj( $discount_code );
872
+    if (!empty($discount_code) && !$invoice->is_renewal()) {
873
+        $discount = wpinv_get_discount_obj($discount_code);
874 874
 
875
-        if ( $discount->exists() ) {
875
+        if ($discount->exists()) {
876 876
             $discount->increase_usage();
877 877
         }
878 878
 
879 879
     }
880 880
 
881 881
     // Record reverse vat.
882
-    if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) {
882
+    if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) {
883 883
 
884
-        if ( wpinv_same_country_exempt_vat() && wpinv_is_base_country( $invoice->get_country() ) ) {
885
-            $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true );
884
+        if (wpinv_same_country_exempt_vat() && wpinv_is_base_country($invoice->get_country())) {
885
+            $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true);
886 886
         }
887 887
 
888 888
     }
889 889
 
890 890
 }
891
-add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' );
891
+add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment');
892 892
 
893 893
 /**
894 894
  * Returns an array of invoice item columns
@@ -896,13 +896,13 @@  discard block
 block discarded – undo
896 896
  * @param int|WPInv_Invoice $invoice
897 897
  * @return array
898 898
  */
899
-function getpaid_invoice_item_columns( $invoice ) {
899
+function getpaid_invoice_item_columns($invoice) {
900 900
 
901 901
     // Prepare the invoice.
902
-    $invoice = new WPInv_Invoice( $invoice );
902
+    $invoice = new WPInv_Invoice($invoice);
903 903
 
904 904
     // Abort if there is no invoice.
905
-    if ( 0 == $invoice->get_id() ) {
905
+    if (0 == $invoice->get_id()) {
906 906
         return array();
907 907
     }
908 908
 
@@ -910,47 +910,47 @@  discard block
 block discarded – undo
910 910
     $columns = apply_filters(
911 911
         'getpaid_invoice_item_columns',
912 912
         array(
913
-            'name'     => __( 'Item', 'invoicing' ),
914
-            'price'    => __( 'Price', 'invoicing' ),
915
-            'quantity' => __( 'Quantity', 'invoicing' ),
916
-            'subtotal' => __( 'Subtotal', 'invoicing' ),
913
+            'name'     => __('Item', 'invoicing'),
914
+            'price'    => __('Price', 'invoicing'),
915
+            'quantity' => __('Quantity', 'invoicing'),
916
+            'subtotal' => __('Subtotal', 'invoicing'),
917 917
         ),
918 918
         $invoice
919 919
     );
920 920
 
921 921
     // Quantities.
922
-    if ( isset( $columns[ 'quantity' ] ) ) {
922
+    if (isset($columns['quantity'])) {
923 923
 
924
-        if ( 'hours' == $invoice->get_template() ) {
925
-            $columns[ 'quantity' ] = __( 'Hours', 'invoicing' );
924
+        if ('hours' == $invoice->get_template()) {
925
+            $columns['quantity'] = __('Hours', 'invoicing');
926 926
         }
927 927
 
928
-        if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) {
929
-            unset( $columns[ 'quantity' ] );
928
+        if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) {
929
+            unset($columns['quantity']);
930 930
         }
931 931
 
932 932
     }
933 933
 
934 934
 
935 935
     // Price.
936
-    if ( isset( $columns[ 'price' ] ) ) {
936
+    if (isset($columns['price'])) {
937 937
 
938
-        if ( 'amount' == $invoice->get_template() ) {
939
-            $columns[ 'price' ] = __( 'Amount', 'invoicing' );
938
+        if ('amount' == $invoice->get_template()) {
939
+            $columns['price'] = __('Amount', 'invoicing');
940 940
         }
941 941
 
942
-        if ( 'hours' == $invoice->get_template() ) {
943
-            $columns[ 'price' ] = __( 'Rate', 'invoicing' );
942
+        if ('hours' == $invoice->get_template()) {
943
+            $columns['price'] = __('Rate', 'invoicing');
944 944
         }
945 945
 
946 946
     }
947 947
 
948 948
 
949 949
     // Sub total.
950
-    if ( isset( $columns[ 'subtotal' ] ) ) {
950
+    if (isset($columns['subtotal'])) {
951 951
 
952
-        if ( 'amount' == $invoice->get_template() ) {
953
-            unset( $columns[ 'subtotal' ] );
952
+        if ('amount' == $invoice->get_template()) {
953
+            unset($columns['subtotal']);
954 954
         }
955 955
 
956 956
     }
@@ -964,30 +964,30 @@  discard block
 block discarded – undo
964 964
  * @param int|WPInv_Invoice $invoice
965 965
  * @return array
966 966
  */
967
-function getpaid_invoice_totals_rows( $invoice ) {
967
+function getpaid_invoice_totals_rows($invoice) {
968 968
 
969 969
     // Prepare the invoice.
970
-    $invoice = new WPInv_Invoice( $invoice );
970
+    $invoice = new WPInv_Invoice($invoice);
971 971
 
972 972
     // Abort if there is no invoice.
973
-    if ( 0 == $invoice->get_id() ) {
973
+    if (0 == $invoice->get_id()) {
974 974
         return array();
975 975
     }
976 976
 
977 977
     $totals = apply_filters(
978 978
         'getpaid_invoice_totals_rows',
979 979
         array(
980
-            'subtotal' => __( 'Subtotal', 'invoicing' ),
981
-            'tax'      => __( 'Tax', 'invoicing' ),
982
-            'fee'      => __( 'Fee', 'invoicing' ),
983
-            'discount' => __( 'Discount', 'invoicing' ),
984
-            'total'    => __( 'Total', 'invoicing' ),
980
+            'subtotal' => __('Subtotal', 'invoicing'),
981
+            'tax'      => __('Tax', 'invoicing'),
982
+            'fee'      => __('Fee', 'invoicing'),
983
+            'discount' => __('Discount', 'invoicing'),
984
+            'total'    => __('Total', 'invoicing'),
985 985
         ),
986 986
         $invoice
987 987
     );
988 988
 
989
-    if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) {
990
-        unset( $totals['tax'] );
989
+    if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) {
990
+        unset($totals['tax']);
991 991
     }
992 992
 
993 993
     return $totals;
@@ -998,47 +998,47 @@  discard block
 block discarded – undo
998 998
  * 
999 999
  * @param WPInv_Invoice $invoice
1000 1000
  */
1001
-function getpaid_new_invoice( $invoice ) {
1001
+function getpaid_new_invoice($invoice) {
1002 1002
 
1003
-    if ( ! $invoice->get_status() ) {
1003
+    if (!$invoice->get_status()) {
1004 1004
         return;
1005 1005
     }
1006 1006
 
1007 1007
     // Add an invoice created note.
1008 1008
     $invoice->add_note(
1009 1009
         sprintf(
1010
-            __( '%s created with the status "%s".', 'invoicing' ),
1011
-            ucfirst( $invoice->get_invoice_quote_type() ),
1012
-            wpinv_status_nicename( $invoice->get_status(), $invoice  )
1010
+            __('%s created with the status "%s".', 'invoicing'),
1011
+            ucfirst($invoice->get_invoice_quote_type()),
1012
+            wpinv_status_nicename($invoice->get_status(), $invoice)
1013 1013
         )
1014 1014
     );
1015 1015
 
1016 1016
 }
1017
-add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' );
1017
+add_action('getpaid_new_invoice', 'getpaid_new_invoice');
1018 1018
 
1019 1019
 /**
1020 1020
  * This function updates invoice caches.
1021 1021
  * 
1022 1022
  * @param WPInv_Invoice $invoice
1023 1023
  */
1024
-function getpaid_update_invoice_caches( $invoice ) {
1024
+function getpaid_update_invoice_caches($invoice) {
1025 1025
 
1026 1026
     // Cache invoice number.
1027
-    wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" );
1027
+    wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids");
1028 1028
 
1029 1029
     // Cache invoice key.
1030
-    wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" );
1030
+    wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids");
1031 1031
 
1032 1032
     // (Maybe) cache transaction id.
1033 1033
     $transaction_id = $invoice->get_transaction_id();
1034 1034
 
1035
-    if ( ! empty( $transaction_id ) ) {
1036
-        wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" );
1035
+    if (!empty($transaction_id)) {
1036
+        wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids");
1037 1037
     }
1038 1038
 
1039 1039
 }
1040
-add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 );
1041
-add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 );
1040
+add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5);
1041
+add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5);
1042 1042
 
1043 1043
 /**
1044 1044
  * Duplicates an invoice.
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
  * @param  WPInv_Invoice $old_invoice The invoice to duplicate
1049 1049
  * @return WPInv_Invoice The new invoice.
1050 1050
  */
1051
-function getpaid_duplicate_invoice( $old_invoice ) {
1051
+function getpaid_duplicate_invoice($old_invoice) {
1052 1052
 
1053 1053
     // Create the new invoice.
1054 1054
     $invoice = new WPInv_Invoice();
@@ -1109,123 +1109,123 @@  discard block
 block discarded – undo
1109 1109
  * @param WPInv_Invoice $invoice
1110 1110
  * @return array
1111 1111
  */
1112
-function getpaid_get_invoice_meta( $invoice ) {
1112
+function getpaid_get_invoice_meta($invoice) {
1113 1113
 
1114 1114
     // Load the invoice meta.
1115 1115
     $meta = array(
1116 1116
 
1117 1117
         'number' => array(
1118 1118
             'label' => sprintf(
1119
-                __( '%s Number', 'invoicing' ),
1120
-                ucfirst( $invoice->get_invoice_quote_type() )
1119
+                __('%s Number', 'invoicing'),
1120
+                ucfirst($invoice->get_invoice_quote_type())
1121 1121
             ),
1122
-            'value' => sanitize_text_field( $invoice->get_number() ),
1122
+            'value' => sanitize_text_field($invoice->get_number()),
1123 1123
         ),
1124 1124
 
1125 1125
         'status' => array(
1126 1126
             'label' => sprintf(
1127
-                __( '%s Status', 'invoicing' ),
1128
-                ucfirst( $invoice->get_invoice_quote_type() )
1127
+                __('%s Status', 'invoicing'),
1128
+                ucfirst($invoice->get_invoice_quote_type())
1129 1129
             ),
1130 1130
             'value' => $invoice->get_status_label_html(),
1131 1131
         ),
1132 1132
 
1133 1133
         'date' => array(
1134 1134
             'label' => sprintf(
1135
-                __( '%s Date', 'invoicing' ),
1136
-                ucfirst( $invoice->get_invoice_quote_type() )
1135
+                __('%s Date', 'invoicing'),
1136
+                ucfirst($invoice->get_invoice_quote_type())
1137 1137
             ),
1138
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
1138
+            'value' => getpaid_format_date($invoice->get_created_date()),
1139 1139
         ),
1140 1140
 
1141 1141
         'date_paid' => array(
1142
-            'label' => __( 'Paid On', 'invoicing' ),
1143
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
1142
+            'label' => __('Paid On', 'invoicing'),
1143
+            'value' => getpaid_format_date($invoice->get_completed_date()),
1144 1144
         ),
1145 1145
 
1146 1146
         'gateway'   => array(
1147
-            'label' => __( 'Payment Method', 'invoicing' ),
1148
-            'value' => sanitize_text_field( $invoice->get_gateway_title() ),
1147
+            'label' => __('Payment Method', 'invoicing'),
1148
+            'value' => sanitize_text_field($invoice->get_gateway_title()),
1149 1149
         ),
1150 1150
 
1151 1151
         'transaction_id' => array(
1152
-            'label' => __( 'Transaction ID', 'invoicing' ),
1153
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
1152
+            'label' => __('Transaction ID', 'invoicing'),
1153
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
1154 1154
         ),
1155 1155
 
1156 1156
         'due_date'  => array(
1157
-            'label' => __( 'Due Date', 'invoicing' ),
1158
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
1157
+            'label' => __('Due Date', 'invoicing'),
1158
+            'value' => getpaid_format_date($invoice->get_due_date()),
1159 1159
         ),
1160 1160
 
1161 1161
         'vat_number' => array(
1162
-            'label' => __( 'VAT Number', 'invoicing' ),
1163
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
1162
+            'label' => __('VAT Number', 'invoicing'),
1163
+            'value' => sanitize_text_field($invoice->get_vat_number()),
1164 1164
         ),
1165 1165
 
1166 1166
     );
1167 1167
 
1168 1168
     // If it is not paid, remove the date of payment.
1169
-    if ( ! $invoice->is_paid() ) {
1170
-        unset( $meta[ 'date_paid' ] );
1171
-        unset( $meta[ 'transaction_id' ] );
1169
+    if (!$invoice->is_paid()) {
1170
+        unset($meta['date_paid']);
1171
+        unset($meta['transaction_id']);
1172 1172
     }
1173 1173
 
1174
-    if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) {
1175
-        unset( $meta[ 'gateway' ] );
1174
+    if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) {
1175
+        unset($meta['gateway']);
1176 1176
     }
1177 1177
 
1178 1178
     // Only display the due date if due dates are enabled.
1179
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
1180
-        unset( $meta[ 'due_date' ] );
1179
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
1180
+        unset($meta['due_date']);
1181 1181
     }
1182 1182
 
1183 1183
     // Only display the vat number if taxes are enabled.
1184
-    if ( ! wpinv_use_taxes() ) {
1185
-        unset( $meta[ 'vat_number' ] );
1184
+    if (!wpinv_use_taxes()) {
1185
+        unset($meta['vat_number']);
1186 1186
     }
1187 1187
 
1188
-    if ( $invoice->is_recurring() ) {
1188
+    if ($invoice->is_recurring()) {
1189 1189
 
1190 1190
         // Link to the parent invoice.
1191
-        if ( $invoice->is_renewal() ) {
1191
+        if ($invoice->is_renewal()) {
1192 1192
 
1193
-            $meta[ 'parent' ] = array(
1193
+            $meta['parent'] = array(
1194 1194
 
1195 1195
                 'label' => sprintf(
1196
-                    __( 'Parent %s', 'invoicing' ),
1197
-                    ucfirst( $invoice->get_invoice_quote_type() )
1196
+                    __('Parent %s', 'invoicing'),
1197
+                    ucfirst($invoice->get_invoice_quote_type())
1198 1198
                 ),
1199 1199
 
1200
-                'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
1200
+                'value' => wpinv_invoice_link($invoice->get_parent_id()),
1201 1201
 
1202 1202
             );
1203 1203
 
1204 1204
         }
1205 1205
 
1206
-        $subscription = wpinv_get_subscription( $invoice );
1206
+        $subscription = wpinv_get_subscription($invoice);
1207 1207
 
1208
-        if ( ! empty ( $subscription ) ) {
1208
+        if (!empty ($subscription)) {
1209 1209
 
1210 1210
             // Display the renewal date.
1211
-            if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) {
1211
+            if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) {
1212 1212
 
1213
-                $meta[ 'renewal_date' ] = array(
1213
+                $meta['renewal_date'] = array(
1214 1214
 
1215
-                    'label' => __( 'Renews On', 'invoicing' ),
1216
-                    'value' => getpaid_format_date( $subscription->get_expiration() ),
1215
+                    'label' => __('Renews On', 'invoicing'),
1216
+                    'value' => getpaid_format_date($subscription->get_expiration()),
1217 1217
         
1218 1218
                 );
1219 1219
 
1220 1220
             }
1221 1221
 
1222
-            if ( $invoice->is_parent() ) {
1222
+            if ($invoice->is_parent()) {
1223 1223
 
1224 1224
                 // Display the recurring amount.
1225
-                $meta[ 'recurring_total' ] = array(
1225
+                $meta['recurring_total'] = array(
1226 1226
 
1227
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
1228
-                    'value' => wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ),
1227
+                    'label' => __('Recurring Amount', 'invoicing'),
1228
+                    'value' => wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency()),
1229 1229
         
1230 1230
                 );
1231 1231
 
@@ -1235,15 +1235,15 @@  discard block
 block discarded – undo
1235 1235
     }
1236 1236
 
1237 1237
     // Add the invoice total to the meta.
1238
-    $meta[ 'invoice_total' ] = array(
1238
+    $meta['invoice_total'] = array(
1239 1239
 
1240
-        'label' => __( 'Total Amount', 'invoicing' ),
1241
-        'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
1240
+        'label' => __('Total Amount', 'invoicing'),
1241
+        'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
1242 1242
 
1243 1243
     );
1244 1244
 
1245 1245
     // Provide a way for third party plugins to filter the meta.
1246
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
1246
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
1247 1247
 
1248 1248
     return $meta;
1249 1249
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 2 patches
Indentation   +327 added lines, -327 removed lines patch added patch discarded remove patch
@@ -20,199 +20,199 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class GetPaid_Installer {
22 22
 
23
-	/**
24
-	 * Upgrades the install.
25
-	 *
26
-	 * @param string $upgrade_from The current invoicing version.
27
-	 */
28
-	public function upgrade_db( $upgrade_from ) {
29
-
30
-		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
32
-
33
-		// Setup the invoice Custom Post Type.
34
-		GetPaid_Post_Types::register_post_types();
35
-
36
-		// Clear the permalinks
37
-		flush_rewrite_rules();
38
-
39
-		// Maybe create new/missing pages.
40
-		$this->create_pages();
41
-
42
-		// Maybe re(add) admin capabilities.
43
-		$this->add_capabilities();
44
-
45
-		// Create any missing database tables.
46
-		$method = "upgrade_from_$upgrade_from";
47
-
48
-		if ( method_exists( $this, $method ) ) {
49
-			$this->$method();
50
-		}
51
-
52
-	}
53
-
54
-	/**
55
-	 * Do a fresh install.
56
-	 *
57
-	 */
58
-	public function upgrade_from_0() {
59
-		$this->create_subscriptions_table();
60
-		$this->create_invoices_table();
61
-		$this->create_invoice_items_table();
62
-	}
63
-
64
-	/**
65
-	 * Upgrade to 0.0.5
66
-	 *
67
-	 */
68
-	public function upgrade_from_004() {
69
-		global $wpdb;
70
-
71
-		// Invoices.
72
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
73
-		if ( ! empty( $results ) ) {
74
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
75
-
76
-			// Clean post cache
77
-			foreach ( $results as $row ) {
78
-				clean_post_cache( $row->ID );
79
-			}
80
-
81
-		}
82
-
83
-		// Item meta key changes
84
-		$query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
85
-		$results = $wpdb->get_results( $query );
86
-
87
-		if ( ! empty( $results ) ) {
88
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
89
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
90
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
91
-
92
-			foreach ( $results as $row ) {
93
-				clean_post_cache( $row->post_id );
94
-			}
95
-
96
-		}
97
-
98
-		$this->upgrade_from_102();
99
-	}
100
-
101
-	/**
102
-	 * Upgrade to 1.0.3
103
-	 *
104
-	 */
105
-	public function upgrade_from_102() {
106
-		$this->create_subscriptions_table();
107
-		$this->upgrade_from_118();
108
-	}
109
-
110
-	/**
111
-	 * Upgrade to version 2.0.0.
112
-	 *
113
-	 */
114
-	public function upgrade_from_118() {
115
-		$this->create_invoices_table();
116
-		$this->create_invoice_items_table();
117
-		$this->migrate_old_invoices();
118
-	}
119
-
120
-	/**
121
-	 * Give administrators the capability to manage GetPaid.
122
-	 *
123
-	 */
124
-	public function add_capabilities() {
125
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
126
-	}
127
-
128
-	/**
129
-	 * Re-create GetPaid pages.
130
-	 *
131
-	 */
132
-	public function create_pages() {
133
-
134
-		$pages = apply_filters(
135
-			'wpinv_create_pages',
136
-			array(
137
-
138
-				// Checkout page.
139
-				'checkout_page' => array(
140
-					'name'      => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
141
-					'title'     => _x( 'Checkout', 'Page title', 'invoicing' ),
142
-					'content'   => '
23
+    /**
24
+     * Upgrades the install.
25
+     *
26
+     * @param string $upgrade_from The current invoicing version.
27
+     */
28
+    public function upgrade_db( $upgrade_from ) {
29
+
30
+        // Save the current invoicing version.
31
+        update_option( 'wpinv_version', WPINV_VERSION );
32
+
33
+        // Setup the invoice Custom Post Type.
34
+        GetPaid_Post_Types::register_post_types();
35
+
36
+        // Clear the permalinks
37
+        flush_rewrite_rules();
38
+
39
+        // Maybe create new/missing pages.
40
+        $this->create_pages();
41
+
42
+        // Maybe re(add) admin capabilities.
43
+        $this->add_capabilities();
44
+
45
+        // Create any missing database tables.
46
+        $method = "upgrade_from_$upgrade_from";
47
+
48
+        if ( method_exists( $this, $method ) ) {
49
+            $this->$method();
50
+        }
51
+
52
+    }
53
+
54
+    /**
55
+     * Do a fresh install.
56
+     *
57
+     */
58
+    public function upgrade_from_0() {
59
+        $this->create_subscriptions_table();
60
+        $this->create_invoices_table();
61
+        $this->create_invoice_items_table();
62
+    }
63
+
64
+    /**
65
+     * Upgrade to 0.0.5
66
+     *
67
+     */
68
+    public function upgrade_from_004() {
69
+        global $wpdb;
70
+
71
+        // Invoices.
72
+        $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
73
+        if ( ! empty( $results ) ) {
74
+            $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
75
+
76
+            // Clean post cache
77
+            foreach ( $results as $row ) {
78
+                clean_post_cache( $row->ID );
79
+            }
80
+
81
+        }
82
+
83
+        // Item meta key changes
84
+        $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
85
+        $results = $wpdb->get_results( $query );
86
+
87
+        if ( ! empty( $results ) ) {
88
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
89
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
90
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
91
+
92
+            foreach ( $results as $row ) {
93
+                clean_post_cache( $row->post_id );
94
+            }
95
+
96
+        }
97
+
98
+        $this->upgrade_from_102();
99
+    }
100
+
101
+    /**
102
+     * Upgrade to 1.0.3
103
+     *
104
+     */
105
+    public function upgrade_from_102() {
106
+        $this->create_subscriptions_table();
107
+        $this->upgrade_from_118();
108
+    }
109
+
110
+    /**
111
+     * Upgrade to version 2.0.0.
112
+     *
113
+     */
114
+    public function upgrade_from_118() {
115
+        $this->create_invoices_table();
116
+        $this->create_invoice_items_table();
117
+        $this->migrate_old_invoices();
118
+    }
119
+
120
+    /**
121
+     * Give administrators the capability to manage GetPaid.
122
+     *
123
+     */
124
+    public function add_capabilities() {
125
+        $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
126
+    }
127
+
128
+    /**
129
+     * Re-create GetPaid pages.
130
+     *
131
+     */
132
+    public function create_pages() {
133
+
134
+        $pages = apply_filters(
135
+            'wpinv_create_pages',
136
+            array(
137
+
138
+                // Checkout page.
139
+                'checkout_page' => array(
140
+                    'name'      => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
141
+                    'title'     => _x( 'Checkout', 'Page title', 'invoicing' ),
142
+                    'content'   => '
143 143
 						<!-- wp:shortcode -->
144 144
 						[wpinv_checkout]
145 145
 						<!-- /wp:shortcode -->
146 146
 					',
147
-					'parent'    => '',
148
-				),
149
-
150
-				// Invoice history page.
151
-				'invoice_history_page' => array(
152
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
153
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
154
-					'content' => '
147
+                    'parent'    => '',
148
+                ),
149
+
150
+                // Invoice history page.
151
+                'invoice_history_page' => array(
152
+                    'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
153
+                    'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
154
+                    'content' => '
155 155
 					<!-- wp:shortcode -->
156 156
 					[wpinv_history]
157 157
 					<!-- /wp:shortcode -->
158 158
 				',
159
-					'parent'  => '',
160
-				),
161
-
162
-				// Success page content.
163
-				'success_page' => array(
164
-					'name'     => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
165
-					'title'    => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
166
-					'content'  => '
159
+                    'parent'  => '',
160
+                ),
161
+
162
+                // Success page content.
163
+                'success_page' => array(
164
+                    'name'     => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
165
+                    'title'    => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
166
+                    'content'  => '
167 167
 					<!-- wp:shortcode -->
168 168
 					[wpinv_receipt]
169 169
 					<!-- /wp:shortcode -->
170 170
 				',
171
-					'parent'   => 'gp-checkout',
172
-				),
173
-
174
-				// Failure page content.
175
-				'failure_page' => array(
176
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
177
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
178
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
179
-					'parent'  => 'gp-checkout',
180
-				),
181
-
182
-				// Subscriptions history page.
183
-				'invoice_subscription_page' => array(
184
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
185
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
186
-					'content' => '
171
+                    'parent'   => 'gp-checkout',
172
+                ),
173
+
174
+                // Failure page content.
175
+                'failure_page' => array(
176
+                    'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
177
+                    'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
178
+                    'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
179
+                    'parent'  => 'gp-checkout',
180
+                ),
181
+
182
+                // Subscriptions history page.
183
+                'invoice_subscription_page' => array(
184
+                    'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
185
+                    'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
186
+                    'content' => '
187 187
 					<!-- wp:shortcode -->
188 188
 					[wpinv_subscriptions]
189 189
 					<!-- /wp:shortcode -->
190 190
 				',
191
-					'parent' => '',
192
-				),
191
+                    'parent' => '',
192
+                ),
193 193
 
194
-			)
195
-		);
194
+            )
195
+        );
196 196
 
197
-		foreach ( $pages as $key => $page ) {
198
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
199
-		}
197
+        foreach ( $pages as $key => $page ) {
198
+            wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
199
+        }
200 200
 
201
-	}
201
+    }
202 202
 
203
-	/**
204
-	 * Create subscriptions table.
205
-	 *
206
-	 */
207
-	public function create_subscriptions_table() {
203
+    /**
204
+     * Create subscriptions table.
205
+     *
206
+     */
207
+    public function create_subscriptions_table() {
208 208
 
209
-		global $wpdb;
209
+        global $wpdb;
210 210
 
211
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
211
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
212 212
 
213
-		// Create tables.
214
-		$charset_collate = $wpdb->get_charset_collate();
215
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions (
213
+        // Create tables.
214
+        $charset_collate = $wpdb->get_charset_collate();
215
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions (
216 216
 			id bigint(20) unsigned NOT NULL auto_increment,
217 217
 			customer_id bigint(20) NOT NULL,
218 218
 			frequency int(11) NOT NULL DEFAULT '1',
@@ -235,22 +235,22 @@  discard block
 block discarded – undo
235 235
 			KEY customer_and_status (customer_id, status)
236 236
 		  ) $charset_collate;";
237 237
 
238
-		dbDelta( $sql );
238
+        dbDelta( $sql );
239 239
 
240
-	}
240
+    }
241 241
 
242
-	/**
243
-	 * Create invoices table.
244
-	 *
245
-	 */
246
-	public function create_invoices_table() {
247
-		global $wpdb;
242
+    /**
243
+     * Create invoices table.
244
+     *
245
+     */
246
+    public function create_invoices_table() {
247
+        global $wpdb;
248 248
 
249
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
249
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
250 250
 
251
-		// Create tables.
252
-		$charset_collate = $wpdb->get_charset_collate();
253
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices (
251
+        // Create tables.
252
+        $charset_collate = $wpdb->get_charset_collate();
253
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices (
254 254
 			post_id BIGINT(20) NOT NULL,
255 255
             `number` VARCHAR(100),
256 256
             `key` VARCHAR(100),
@@ -286,22 +286,22 @@  discard block
 block discarded – undo
286 286
 			KEY `key` (`key`)
287 287
 		  ) $charset_collate;";
288 288
 
289
-		dbDelta( $sql );
289
+        dbDelta( $sql );
290 290
 
291
-	}
291
+    }
292 292
 
293
-	/**
294
-	 * Create invoice items table.
295
-	 *
296
-	 */
297
-	public function create_invoice_items_table() {
298
-		global $wpdb;
293
+    /**
294
+     * Create invoice items table.
295
+     *
296
+     */
297
+    public function create_invoice_items_table() {
298
+        global $wpdb;
299 299
 
300
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
300
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
301 301
 
302
-		// Create tables.
303
-		$charset_collate = $wpdb->get_charset_collate();
304
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items (
302
+        // Create tables.
303
+        $charset_collate = $wpdb->get_charset_collate();
304
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items (
305 305
 			ID BIGINT(20) NOT NULL AUTO_INCREMENT,
306 306
             post_id BIGINT(20) NOT NULL,
307 307
             item_id BIGINT(20) NOT NULL,
@@ -323,138 +323,138 @@  discard block
 block discarded – undo
323 323
 			KEY post_id (post_id)
324 324
 		  ) $charset_collate;";
325 325
 
326
-		dbDelta( $sql );
327
-
328
-	}
329
-
330
-	/**
331
-	 * Migrates old invoices to new invoices.
332
-	 *
333
-	 */
334
-	public function migrate_old_invoices() {
335
-		global $wpdb;
336
-
337
-		$invoices = array_unique(
338
-			get_posts(
339
-				array(
340
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
341
-					'posts_per_page' => -1,
342
-					'fields'         => 'ids',
343
-					'post_status'    => array_keys( get_post_stati() ),
344
-				)
345
-			)
346
-		);
347
-
348
-		// Abort if we do not have any invoices.
349
-		if ( empty( $invoices ) ) {
350
-			return;
351
-		}
352
-
353
-		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
354
-		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
355
-
356
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
357
-
358
-		$invoice_rows = array();
359
-		foreach ( $invoices as $invoice ) {
360
-
361
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
362
-
363
-			if ( empty( $invoice->ID ) ) {
364
-				return;
365
-			}
366
-
367
-			$fields = array (
368
-				'post_id'        => $invoice->ID,
369
-				'number'         => $invoice->get_number(),
370
-				'key'            => $invoice->get_key(),
371
-				'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
372
-				'mode'           => $invoice->mode,
373
-				'user_ip'        => $invoice->get_ip(),
374
-				'first_name'     => $invoice->get_first_name(),
375
-				'last_name'      => $invoice->get_last_name(),
376
-				'address'        => $invoice->get_address(),
377
-				'city'           => $invoice->city,
378
-				'state'          => $invoice->state,
379
-				'country'        => $invoice->country,
380
-				'zip'            => $invoice->zip,
381
-				'adddress_confirmed' => (int) $invoice->adddress_confirmed,
382
-				'gateway'        => $invoice->get_gateway(),
383
-				'transaction_id' => $invoice->get_transaction_id(),
384
-				'currency'       => $invoice->get_currency(),
385
-				'subtotal'       => $invoice->get_subtotal(),
386
-				'tax'            => $invoice->get_tax(),
387
-				'fees_total'     => $invoice->get_fees_total(),
388
-				'total'          => $invoice->get_total(),
389
-				'discount'       => $invoice->get_discount(),
390
-				'discount_code'  => $invoice->get_discount_code(),
391
-				'disable_taxes'  => $invoice->disable_taxes,
392
-				'due_date'       => $invoice->get_due_date(),
393
-				'completed_date' => $invoice->get_completed_date(),
394
-				'company'        => $invoice->company,
395
-				'vat_number'     => $invoice->vat_number,
396
-				'vat_rate'       => $invoice->vat_rate,
397
-				'custom_meta'    => $invoice->payment_meta
398
-			);
399
-
400
-			foreach ( $fields as $key => $val ) {
401
-				if ( is_null( $val ) ) {
402
-					$val = '';
403
-				}
404
-				$val = maybe_serialize( $val );
405
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
406
-			}
407
-
408
-			$fields = implode( ', ', $fields );
409
-			$invoice_rows[] = "($fields)";
410
-
411
-			$item_rows    = array();
412
-			$item_columns = array();
413
-			foreach ( $invoice->get_cart_details() as $details ) {
414
-				$fields = array(
415
-					'post_id'          => $invoice->ID,
416
-					'item_id'          => $details['id'],
417
-					'item_name'        => $details['name'],
418
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
419
-					'vat_rate'         => $details['vat_rate'],
420
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
421
-					'tax'              => $details['tax'],
422
-					'item_price'       => $details['item_price'],
423
-					'custom_price'     => $details['custom_price'],
424
-					'quantity'         => $details['quantity'],
425
-					'discount'         => $details['discount'],
426
-					'subtotal'         => $details['subtotal'],
427
-					'price'            => $details['price'],
428
-					'meta'             => $details['meta'],
429
-					'fees'             => $details['fees'],
430
-				);
431
-
432
-				$item_columns = array_keys ( $fields );
433
-
434
-				foreach ( $fields as $key => $val ) {
435
-					if ( is_null( $val ) ) {
436
-						$val = '';
437
-					}
438
-					$val = maybe_serialize( $val );
439
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
440
-				}
441
-
442
-				$fields = implode( ', ', $fields );
443
-				$item_rows[] = "($fields)";
444
-			}
445
-
446
-			$item_rows    = implode( ', ', $item_rows );
447
-			$item_columns = implode( ', ', $item_columns );
448
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
449
-		}
450
-
451
-		if ( empty( $invoice_rows ) ) {
452
-			return;
453
-		}
454
-
455
-		$invoice_rows = implode( ', ', $invoice_rows );
456
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
457
-
458
-	}
326
+        dbDelta( $sql );
327
+
328
+    }
329
+
330
+    /**
331
+     * Migrates old invoices to new invoices.
332
+     *
333
+     */
334
+    public function migrate_old_invoices() {
335
+        global $wpdb;
336
+
337
+        $invoices = array_unique(
338
+            get_posts(
339
+                array(
340
+                    'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
341
+                    'posts_per_page' => -1,
342
+                    'fields'         => 'ids',
343
+                    'post_status'    => array_keys( get_post_stati() ),
344
+                )
345
+            )
346
+        );
347
+
348
+        // Abort if we do not have any invoices.
349
+        if ( empty( $invoices ) ) {
350
+            return;
351
+        }
352
+
353
+        $invoices_table      = $wpdb->prefix . 'getpaid_invoices';
354
+        $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
355
+
356
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
357
+
358
+        $invoice_rows = array();
359
+        foreach ( $invoices as $invoice ) {
360
+
361
+            $invoice = new WPInv_Legacy_Invoice( $invoice );
362
+
363
+            if ( empty( $invoice->ID ) ) {
364
+                return;
365
+            }
366
+
367
+            $fields = array (
368
+                'post_id'        => $invoice->ID,
369
+                'number'         => $invoice->get_number(),
370
+                'key'            => $invoice->get_key(),
371
+                'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
372
+                'mode'           => $invoice->mode,
373
+                'user_ip'        => $invoice->get_ip(),
374
+                'first_name'     => $invoice->get_first_name(),
375
+                'last_name'      => $invoice->get_last_name(),
376
+                'address'        => $invoice->get_address(),
377
+                'city'           => $invoice->city,
378
+                'state'          => $invoice->state,
379
+                'country'        => $invoice->country,
380
+                'zip'            => $invoice->zip,
381
+                'adddress_confirmed' => (int) $invoice->adddress_confirmed,
382
+                'gateway'        => $invoice->get_gateway(),
383
+                'transaction_id' => $invoice->get_transaction_id(),
384
+                'currency'       => $invoice->get_currency(),
385
+                'subtotal'       => $invoice->get_subtotal(),
386
+                'tax'            => $invoice->get_tax(),
387
+                'fees_total'     => $invoice->get_fees_total(),
388
+                'total'          => $invoice->get_total(),
389
+                'discount'       => $invoice->get_discount(),
390
+                'discount_code'  => $invoice->get_discount_code(),
391
+                'disable_taxes'  => $invoice->disable_taxes,
392
+                'due_date'       => $invoice->get_due_date(),
393
+                'completed_date' => $invoice->get_completed_date(),
394
+                'company'        => $invoice->company,
395
+                'vat_number'     => $invoice->vat_number,
396
+                'vat_rate'       => $invoice->vat_rate,
397
+                'custom_meta'    => $invoice->payment_meta
398
+            );
399
+
400
+            foreach ( $fields as $key => $val ) {
401
+                if ( is_null( $val ) ) {
402
+                    $val = '';
403
+                }
404
+                $val = maybe_serialize( $val );
405
+                $fields[ $key ] = $wpdb->prepare( '%s', $val );
406
+            }
407
+
408
+            $fields = implode( ', ', $fields );
409
+            $invoice_rows[] = "($fields)";
410
+
411
+            $item_rows    = array();
412
+            $item_columns = array();
413
+            foreach ( $invoice->get_cart_details() as $details ) {
414
+                $fields = array(
415
+                    'post_id'          => $invoice->ID,
416
+                    'item_id'          => $details['id'],
417
+                    'item_name'        => $details['name'],
418
+                    'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
419
+                    'vat_rate'         => $details['vat_rate'],
420
+                    'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
421
+                    'tax'              => $details['tax'],
422
+                    'item_price'       => $details['item_price'],
423
+                    'custom_price'     => $details['custom_price'],
424
+                    'quantity'         => $details['quantity'],
425
+                    'discount'         => $details['discount'],
426
+                    'subtotal'         => $details['subtotal'],
427
+                    'price'            => $details['price'],
428
+                    'meta'             => $details['meta'],
429
+                    'fees'             => $details['fees'],
430
+                );
431
+
432
+                $item_columns = array_keys ( $fields );
433
+
434
+                foreach ( $fields as $key => $val ) {
435
+                    if ( is_null( $val ) ) {
436
+                        $val = '';
437
+                    }
438
+                    $val = maybe_serialize( $val );
439
+                    $fields[ $key ] = $wpdb->prepare( '%s', $val );
440
+                }
441
+
442
+                $fields = implode( ', ', $fields );
443
+                $item_rows[] = "($fields)";
444
+            }
445
+
446
+            $item_rows    = implode( ', ', $item_rows );
447
+            $item_columns = implode( ', ', $item_columns );
448
+            $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
449
+        }
450
+
451
+        if ( empty( $invoice_rows ) ) {
452
+            return;
453
+        }
454
+
455
+        $invoice_rows = implode( ', ', $invoice_rows );
456
+        $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
457
+
458
+    }
459 459
 
460 460
 }
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   2.0.2
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * The main installer/updater class.
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @param string $upgrade_from The current invoicing version.
27 27
 	 */
28
-	public function upgrade_db( $upgrade_from ) {
28
+	public function upgrade_db($upgrade_from) {
29 29
 
30 30
 		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
31
+		update_option('wpinv_version', WPINV_VERSION);
32 32
 
33 33
 		// Setup the invoice Custom Post Type.
34 34
 		GetPaid_Post_Types::register_post_types();
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		// Create any missing database tables.
46 46
 		$method = "upgrade_from_$upgrade_from";
47 47
 
48
-		if ( method_exists( $this, $method ) ) {
48
+		if (method_exists($this, $method)) {
49 49
 			$this->$method();
50 50
 		}
51 51
 
@@ -69,28 +69,28 @@  discard block
 block discarded – undo
69 69
 		global $wpdb;
70 70
 
71 71
 		// Invoices.
72
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
73
-		if ( ! empty( $results ) ) {
74
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
72
+		$results = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
73
+		if (!empty($results)) {
74
+			$wpdb->query("UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
75 75
 
76 76
 			// Clean post cache
77
-			foreach ( $results as $row ) {
78
-				clean_post_cache( $row->ID );
77
+			foreach ($results as $row) {
78
+				clean_post_cache($row->ID);
79 79
 			}
80 80
 
81 81
 		}
82 82
 
83 83
 		// Item meta key changes
84 84
 		$query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
85
-		$results = $wpdb->get_results( $query );
85
+		$results = $wpdb->get_results($query);
86 86
 
87
-		if ( ! empty( $results ) ) {
88
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
89
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
90
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
87
+		if (!empty($results)) {
88
+			$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
89
+			$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
90
+			$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
91 91
 
92
-			foreach ( $results as $row ) {
93
-				clean_post_cache( $row->post_id );
92
+			foreach ($results as $row) {
93
+				clean_post_cache($row->post_id);
94 94
 			}
95 95
 
96 96
 		}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 */
124 124
 	public function add_capabilities() {
125
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
125
+		$GLOBALS['wp_roles']->add_cap('administrator', 'manage_invoicing');
126 126
 	}
127 127
 
128 128
 	/**
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 
138 138
 				// Checkout page.
139 139
 				'checkout_page' => array(
140
-					'name'      => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
141
-					'title'     => _x( 'Checkout', 'Page title', 'invoicing' ),
140
+					'name'      => _x('gp-checkout', 'Page slug', 'invoicing'),
141
+					'title'     => _x('Checkout', 'Page title', 'invoicing'),
142 142
 					'content'   => '
143 143
 						<!-- wp:shortcode -->
144 144
 						[wpinv_checkout]
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 
150 150
 				// Invoice history page.
151 151
 				'invoice_history_page' => array(
152
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
153
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
152
+					'name'    => _x('gp-invoices', 'Page slug', 'invoicing'),
153
+					'title'   => _x('My Invoices', 'Page title', 'invoicing'),
154 154
 					'content' => '
155 155
 					<!-- wp:shortcode -->
156 156
 					[wpinv_history]
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 
162 162
 				// Success page content.
163 163
 				'success_page' => array(
164
-					'name'     => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
165
-					'title'    => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
164
+					'name'     => _x('gp-receipt', 'Page slug', 'invoicing'),
165
+					'title'    => _x('Payment Confirmation', 'Page title', 'invoicing'),
166 166
 					'content'  => '
167 167
 					<!-- wp:shortcode -->
168 168
 					[wpinv_receipt]
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 
174 174
 				// Failure page content.
175 175
 				'failure_page' => array(
176
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
177
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
178
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
176
+					'name'    => _x('gp-transaction-failed', 'Page slug', 'invoicing'),
177
+					'title'   => _x('Transaction Failed', 'Page title', 'invoicing'),
178
+					'content' => __('Your transaction failed, please try again or contact site support.', 'invoicing'),
179 179
 					'parent'  => 'gp-checkout',
180 180
 				),
181 181
 
182 182
 				// Subscriptions history page.
183 183
 				'invoice_subscription_page' => array(
184
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
185
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
184
+					'name'    => _x('gp-subscriptions', 'Page slug', 'invoicing'),
185
+					'title'   => _x('My Subscriptions', 'Page title', 'invoicing'),
186 186
 					'content' => '
187 187
 					<!-- wp:shortcode -->
188 188
 					[wpinv_subscriptions]
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 			)
195 195
 		);
196 196
 
197
-		foreach ( $pages as $key => $page ) {
198
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
197
+		foreach ($pages as $key => $page) {
198
+			wpinv_create_page(esc_sql($page['name']), $key, $page['title'], $page['content'], $page['parent']);
199 199
 		}
200 200
 
201 201
 	}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
 		global $wpdb;
210 210
 
211
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
211
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
212 212
 
213 213
 		// Create tables.
214 214
 		$charset_collate = $wpdb->get_charset_collate();
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			KEY customer_and_status (customer_id, status)
236 236
 		  ) $charset_collate;";
237 237
 
238
-		dbDelta( $sql );
238
+		dbDelta($sql);
239 239
 
240 240
 	}
241 241
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	public function create_invoices_table() {
247 247
 		global $wpdb;
248 248
 
249
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
249
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
250 250
 
251 251
 		// Create tables.
252 252
 		$charset_collate = $wpdb->get_charset_collate();
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 			KEY `key` (`key`)
287 287
 		  ) $charset_collate;";
288 288
 
289
-		dbDelta( $sql );
289
+		dbDelta($sql);
290 290
 
291 291
 	}
292 292
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	public function create_invoice_items_table() {
298 298
 		global $wpdb;
299 299
 
300
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
300
+		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
301 301
 
302 302
 		// Create tables.
303 303
 		$charset_collate = $wpdb->get_charset_collate();
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 			KEY post_id (post_id)
324 324
 		  ) $charset_collate;";
325 325
 
326
-		dbDelta( $sql );
326
+		dbDelta($sql);
327 327
 
328 328
 	}
329 329
 
@@ -337,38 +337,38 @@  discard block
 block discarded – undo
337 337
 		$invoices = array_unique(
338 338
 			get_posts(
339 339
 				array(
340
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
340
+					'post_type'      => array('wpi_invoice', 'wpi_quote'),
341 341
 					'posts_per_page' => -1,
342 342
 					'fields'         => 'ids',
343
-					'post_status'    => array_keys( get_post_stati() ),
343
+					'post_status'    => array_keys(get_post_stati()),
344 344
 				)
345 345
 			)
346 346
 		);
347 347
 
348 348
 		// Abort if we do not have any invoices.
349
-		if ( empty( $invoices ) ) {
349
+		if (empty($invoices)) {
350 350
 			return;
351 351
 		}
352 352
 
353 353
 		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
354 354
 		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
355 355
 
356
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
356
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php');
357 357
 
358 358
 		$invoice_rows = array();
359
-		foreach ( $invoices as $invoice ) {
359
+		foreach ($invoices as $invoice) {
360 360
 
361
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
361
+			$invoice = new WPInv_Legacy_Invoice($invoice);
362 362
 
363
-			if ( empty( $invoice->ID ) ) {
363
+			if (empty($invoice->ID)) {
364 364
 				return;
365 365
 			}
366 366
 
367
-			$fields = array (
367
+			$fields = array(
368 368
 				'post_id'        => $invoice->ID,
369 369
 				'number'         => $invoice->get_number(),
370 370
 				'key'            => $invoice->get_key(),
371
-				'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
371
+				'type'           => str_replace('wpi_', '', $invoice->post_type),
372 372
 				'mode'           => $invoice->mode,
373 373
 				'user_ip'        => $invoice->get_ip(),
374 374
 				'first_name'     => $invoice->get_first_name(),
@@ -397,27 +397,27 @@  discard block
 block discarded – undo
397 397
 				'custom_meta'    => $invoice->payment_meta
398 398
 			);
399 399
 
400
-			foreach ( $fields as $key => $val ) {
401
-				if ( is_null( $val ) ) {
400
+			foreach ($fields as $key => $val) {
401
+				if (is_null($val)) {
402 402
 					$val = '';
403 403
 				}
404
-				$val = maybe_serialize( $val );
405
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
404
+				$val = maybe_serialize($val);
405
+				$fields[$key] = $wpdb->prepare('%s', $val);
406 406
 			}
407 407
 
408
-			$fields = implode( ', ', $fields );
408
+			$fields = implode(', ', $fields);
409 409
 			$invoice_rows[] = "($fields)";
410 410
 
411 411
 			$item_rows    = array();
412 412
 			$item_columns = array();
413
-			foreach ( $invoice->get_cart_details() as $details ) {
413
+			foreach ($invoice->get_cart_details() as $details) {
414 414
 				$fields = array(
415 415
 					'post_id'          => $invoice->ID,
416 416
 					'item_id'          => $details['id'],
417 417
 					'item_name'        => $details['name'],
418
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
418
+					'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
419 419
 					'vat_rate'         => $details['vat_rate'],
420
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
420
+					'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
421 421
 					'tax'              => $details['tax'],
422 422
 					'item_price'       => $details['item_price'],
423 423
 					'custom_price'     => $details['custom_price'],
@@ -429,31 +429,31 @@  discard block
 block discarded – undo
429 429
 					'fees'             => $details['fees'],
430 430
 				);
431 431
 
432
-				$item_columns = array_keys ( $fields );
432
+				$item_columns = array_keys($fields);
433 433
 
434
-				foreach ( $fields as $key => $val ) {
435
-					if ( is_null( $val ) ) {
434
+				foreach ($fields as $key => $val) {
435
+					if (is_null($val)) {
436 436
 						$val = '';
437 437
 					}
438
-					$val = maybe_serialize( $val );
439
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
438
+					$val = maybe_serialize($val);
439
+					$fields[$key] = $wpdb->prepare('%s', $val);
440 440
 				}
441 441
 
442
-				$fields = implode( ', ', $fields );
442
+				$fields = implode(', ', $fields);
443 443
 				$item_rows[] = "($fields)";
444 444
 			}
445 445
 
446
-			$item_rows    = implode( ', ', $item_rows );
447
-			$item_columns = implode( ', ', $item_columns );
448
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
446
+			$item_rows    = implode(', ', $item_rows);
447
+			$item_columns = implode(', ', $item_columns);
448
+			$wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
449 449
 		}
450 450
 
451
-		if ( empty( $invoice_rows ) ) {
451
+		if (empty($invoice_rows)) {
452 452
 			return;
453 453
 		}
454 454
 
455
-		$invoice_rows = implode( ', ', $invoice_rows );
456
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
455
+		$invoice_rows = implode(', ', $invoice_rows);
456
+		$wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
457 457
 
458 458
 	}
459 459
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +307 added lines, -307 removed lines patch added patch discarded remove patch
@@ -14,73 +14,73 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66 66
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
68
-		do_action( 'getpaid_init_admin_hooks', $this );
67
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
68
+        do_action( 'getpaid_init_admin_hooks', $this );
69 69
 
70 70
     }
71 71
 
72 72
     /**
73
-	 * Register admin scripts
74
-	 *
75
-	 */
76
-	public function enqeue_scripts() {
73
+     * Register admin scripts
74
+     *
75
+     */
76
+    public function enqeue_scripts() {
77 77
         global $current_screen, $pagenow;
78 78
 
79
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
80
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
79
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
80
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
81 81
 
82 82
         if ( ! empty( $current_screen->post_type ) ) {
83
-			$page = $current_screen->post_type;
83
+            $page = $current_screen->post_type;
84 84
         }
85 85
 
86 86
         // General styles.
@@ -103,54 +103,54 @@  discard block
 block discarded – undo
103 103
         }
104 104
 
105 105
         // Payment form scripts.
106
-		if ( 'wpi_payment_form' == $page && $editing ) {
106
+        if ( 'wpi_payment_form' == $page && $editing ) {
107 107
             $this->load_payment_form_scripts();
108 108
         }
109 109
 
110
-		if ( $page == 'wpinv-subscriptions' ) {
111
-			wp_enqueue_script( 'postbox' );
112
-		}
110
+        if ( $page == 'wpinv-subscriptions' ) {
111
+            wp_enqueue_script( 'postbox' );
112
+        }
113 113
 
114 114
     }
115 115
 
116 116
     /**
117
-	 * Returns admin js translations.
118
-	 *
119
-	 */
120
-	protected function get_admin_i18() {
117
+     * Returns admin js translations.
118
+     *
119
+     */
120
+    protected function get_admin_i18() {
121 121
         global $post;
122 122
 
123
-		$date_range = array(
124
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
125
-		);
123
+        $date_range = array(
124
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
125
+        );
126 126
 
127
-		if ( $date_range['period'] == 'custom' ) {
127
+        if ( $date_range['period'] == 'custom' ) {
128 128
 			
129
-			if ( isset( $_GET['from'] ) ) {
130
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
131
-			}
129
+            if ( isset( $_GET['from'] ) ) {
130
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
131
+            }
132 132
 
133
-			if ( isset( $_GET['to'] ) ) {
134
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
135
-			}
133
+            if ( isset( $_GET['to'] ) ) {
134
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
135
+            }
136 136
 
137
-		}
137
+        }
138 138
 
139 139
         $i18n = array(
140 140
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
141 141
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
142
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
143
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
144
-			'rest_root'                 => esc_url_raw( rest_url() ),
145
-			'date_range'                => $date_range,
142
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
143
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
144
+            'rest_root'                 => esc_url_raw( rest_url() ),
145
+            'date_range'                => $date_range,
146 146
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
147 147
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
148 148
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
149 149
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
150 150
             'tax'                       => wpinv_tax_amount(),
151 151
             'discount'                  => 0,
152
-			'currency_symbol'           => wpinv_currency_symbol(),
153
-			'currency'                  => wpinv_get_currency(),
152
+            'currency_symbol'           => wpinv_currency_symbol(),
153
+            'currency'                  => wpinv_get_currency(),
154 154
             'currency_pos'              => wpinv_currency_position(),
155 155
             'thousand_sep'              => wpinv_thousands_separator(),
156 156
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -173,112 +173,112 @@  discard block
 block discarded – undo
173 173
             'searching'                 => __( 'Searching', 'invoicing' ),
174 174
         );
175 175
 
176
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
176
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
177 177
 
178
-			$invoice              = new WPInv_Invoice( $post );
179
-			$i18n['save_invoice'] = sprintf(
180
-				__( 'Save %s', 'invoicing' ),
181
-				ucfirst( $invoice->get_invoice_quote_type() )
182
-			);
178
+            $invoice              = new WPInv_Invoice( $post );
179
+            $i18n['save_invoice'] = sprintf(
180
+                __( 'Save %s', 'invoicing' ),
181
+                ucfirst( $invoice->get_invoice_quote_type() )
182
+            );
183 183
 
184
-			$i18n['invoice_description'] = sprintf(
185
-				__( '%s Description', 'invoicing' ),
186
-				ucfirst( $invoice->get_invoice_quote_type() )
187
-			);
184
+            $i18n['invoice_description'] = sprintf(
185
+                __( '%s Description', 'invoicing' ),
186
+                ucfirst( $invoice->get_invoice_quote_type() )
187
+            );
188 188
 
189
-		}
190
-		return $i18n;
191
-	}
189
+        }
190
+        return $i18n;
191
+    }
192 192
 
193
-	/**
194
-	 * Change the admin footer text on GetPaid admin pages.
195
-	 *
196
-	 * @since  2.0.0
197
-	 * @param  string $footer_text
198
-	 * @return string
199
-	 */
200
-	public function admin_footer_text( $footer_text ) {
201
-		global $current_screen;
193
+    /**
194
+     * Change the admin footer text on GetPaid admin pages.
195
+     *
196
+     * @since  2.0.0
197
+     * @param  string $footer_text
198
+     * @return string
199
+     */
200
+    public function admin_footer_text( $footer_text ) {
201
+        global $current_screen;
202 202
 
203
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
203
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
204 204
 
205 205
         if ( ! empty( $current_screen->post_type ) ) {
206
-			$page = $current_screen->post_type;
206
+            $page = $current_screen->post_type;
207 207
         }
208 208
 
209 209
         // General styles.
210 210
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
211 211
 
212
-			// Change the footer text
213
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
214
-
215
-				$rating_url  = esc_url(
216
-					wp_nonce_url(
217
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
218
-						'getpaid-nonce',
219
-						'getpaid-nonce'
220
-						)
221
-				);
222
-
223
-				$footer_text = sprintf(
224
-					/* translators: %s: five stars */
225
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
226
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
227
-				);
228
-
229
-			} else {
230
-
231
-				$footer_text = sprintf(
232
-					/* translators: %s: GetPaid */
233
-					__( 'Thank you for using %s!', 'invoicing' ),
234
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
235
-				);
236
-
237
-			}
238
-
239
-		}
240
-
241
-		return $footer_text;
242
-	}
243
-
244
-	/**
245
-	 * Redirects to wp.org to rate the plugin.
246
-	 *
247
-	 * @since  2.0.0
248
-	 */
249
-	public function redirect_to_wordpress_rating_page() {
250
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
251
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
252
-		exit;
253
-	}
212
+            // Change the footer text
213
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
214
+
215
+                $rating_url  = esc_url(
216
+                    wp_nonce_url(
217
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
218
+                        'getpaid-nonce',
219
+                        'getpaid-nonce'
220
+                        )
221
+                );
222
+
223
+                $footer_text = sprintf(
224
+                    /* translators: %s: five stars */
225
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
226
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
227
+                );
228
+
229
+            } else {
230
+
231
+                $footer_text = sprintf(
232
+                    /* translators: %s: GetPaid */
233
+                    __( 'Thank you for using %s!', 'invoicing' ),
234
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
235
+                );
236
+
237
+            }
238
+
239
+        }
240
+
241
+        return $footer_text;
242
+    }
254 243
 
255 244
     /**
256
-	 * Loads payment form js.
257
-	 *
258
-	 */
259
-	protected function load_payment_form_scripts() {
245
+     * Redirects to wp.org to rate the plugin.
246
+     *
247
+     * @since  2.0.0
248
+     */
249
+    public function redirect_to_wordpress_rating_page() {
250
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
251
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
252
+        exit;
253
+    }
254
+
255
+    /**
256
+     * Loads payment form js.
257
+     *
258
+     */
259
+    protected function load_payment_form_scripts() {
260 260
         global $post;
261 261
 
262 262
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
263
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
264
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
263
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
264
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
265 265
 
266
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
267
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
266
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
267
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
268 268
 
269
-		wp_localize_script(
269
+        wp_localize_script(
270 270
             'wpinv-admin-payment-form-script',
271 271
             'wpinvPaymentFormAdmin',
272 272
             array(
273
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
274
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
275
-				'currency'      => wpinv_currency_symbol(),
276
-				'position'      => wpinv_currency_position(),
277
-				'decimals'      => (int) wpinv_decimals(),
278
-				'thousands_sep' => wpinv_thousands_separator(),
279
-				'decimals_sep'  => wpinv_decimal_separator(),
280
-				'form_items'    => gepaid_get_form_items( $post->ID ),
281
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
273
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
274
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
275
+                'currency'      => wpinv_currency_symbol(),
276
+                'position'      => wpinv_currency_position(),
277
+                'decimals'      => (int) wpinv_decimals(),
278
+                'thousands_sep' => wpinv_thousands_separator(),
279
+                'decimals_sep'  => wpinv_decimal_separator(),
280
+                'form_items'    => gepaid_get_form_items( $post->ID ),
281
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
282 282
             )
283 283
         );
284 284
 
@@ -287,20 +287,20 @@  discard block
 block discarded – undo
287 287
     }
288 288
 
289 289
     /**
290
-	 * Add our classes to admin pages.
290
+     * Add our classes to admin pages.
291 291
      *
292 292
      * @param string $classes
293 293
      * @return string
294
-	 *
295
-	 */
294
+     *
295
+     */
296 296
     public function admin_body_class( $classes ) {
297
-		global $pagenow, $post, $current_screen;
297
+        global $pagenow, $post, $current_screen;
298 298
 
299 299
 
300 300
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
301 301
 
302 302
         if ( ! empty( $current_screen->post_type ) ) {
303
-			$page = $current_screen->post_type;
303
+            $page = $current_screen->post_type;
304 304
         }
305 305
 
306 306
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -309,59 +309,59 @@  discard block
 block discarded – undo
309 309
 
310 310
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
311 311
             $classes .= ' wpinv-cpt wpinv';
312
-		}
312
+        }
313 313
 		
314
-		if ( getpaid_is_invoice_post_type( $page ) ) {
314
+        if ( getpaid_is_invoice_post_type( $page ) ) {
315 315
             $classes .= ' getpaid-is-invoice-cpt';
316 316
         }
317 317
 
318
-		return $classes;
318
+        return $classes;
319 319
     }
320 320
 
321 321
     /**
322
-	 * Maybe show the AyeCode Connect Notice.
323
-	 */
324
-	public function init_ayecode_connect_helper(){
322
+     * Maybe show the AyeCode Connect Notice.
323
+     */
324
+    public function init_ayecode_connect_helper(){
325 325
 
326 326
         new AyeCode_Connect_Helper(
327 327
             array(
328
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
329
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
330
-				'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>" ),
331
-				'connect_button'    => __("Connect Site","invoicing"),
332
-				'connecting_button'    => __("Connecting...","invoicing"),
333
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
334
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
328
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
329
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
330
+                '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>" ),
331
+                'connect_button'    => __("Connect Site","invoicing"),
332
+                'connecting_button'    => __("Connecting...","invoicing"),
333
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
334
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
335 335
             ),
336 336
             array( 'wpi-addons' )
337 337
         );
338 338
 
339 339
     }
340 340
 
341
-	/**
342
-	 * Redirect users to settings on activation.
343
-	 *
344
-	 * @return void
345
-	 */
346
-	public function activation_redirect() {
341
+    /**
342
+     * Redirect users to settings on activation.
343
+     *
344
+     * @return void
345
+     */
346
+    public function activation_redirect() {
347 347
 
348
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
348
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
349 349
 
350
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
351
-			return;
352
-		}
350
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
351
+            return;
352
+        }
353 353
 
354
-		// Bail if activating from network, or bulk
355
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
356
-			return;
357
-		}
354
+        // Bail if activating from network, or bulk
355
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
356
+            return;
357
+        }
358 358
 
359
-	    update_option( 'wpinv_redirected_to_settings', 1 );
359
+        update_option( 'wpinv_redirected_to_settings', 1 );
360 360
 
361 361
         wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
362 362
         exit;
363 363
 
364
-	}
364
+    }
365 365
 
366 366
     /**
367 367
      * Fires an admin action after verifying that a user can fire them.
@@ -375,162 +375,162 @@  discard block
 block discarded – undo
375 375
 
376 376
     }
377 377
 
378
-	/**
378
+    /**
379 379
      * Sends a payment reminder to a customer.
380
-	 * 
381
-	 * @param array $args
380
+     * 
381
+     * @param array $args
382 382
      */
383 383
     public function send_customer_invoice( $args ) {
384
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
384
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
385 385
 
386
-		if ( $sent ) {
387
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
388
-		} else {
389
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
390
-		}
386
+        if ( $sent ) {
387
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
388
+        } else {
389
+            $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
390
+        }
391 391
 
392
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
393
-		exit;
394
-	}
392
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
393
+        exit;
394
+    }
395 395
 
396
-	/**
396
+    /**
397 397
      * Sends a payment reminder to a customer.
398
-	 * 
399
-	 * @param array $args
398
+     * 
399
+     * @param array $args
400 400
      */
401 401
     public function send_customer_payment_reminder( $args ) {
402
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
402
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
403 403
 
404
-		if ( $sent ) {
405
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
406
-		} else {
407
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
408
-		}
404
+        if ( $sent ) {
405
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
406
+        } else {
407
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
408
+        }
409 409
 
410
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
411
-		exit;
412
-	}
410
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
411
+        exit;
412
+    }
413 413
 
414
-	/**
414
+    /**
415 415
      * Resets tax rates.
416
-	 * 
416
+     * 
417 417
      */
418 418
     public function admin_reset_tax_rates() {
419 419
 
420
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
421
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
422
-		exit;
420
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
421
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
422
+        exit;
423 423
 
424
-	}
424
+    }
425 425
 
426 426
     /**
427
-	 * Returns an array of admin notices.
428
-	 *
429
-	 * @since       1.0.19
427
+     * Returns an array of admin notices.
428
+     *
429
+     * @since       1.0.19
430 430
      * @return array
431
-	 */
432
-	public function get_notices() {
433
-		$notices = get_option( 'wpinv_admin_notices' );
431
+     */
432
+    public function get_notices() {
433
+        $notices = get_option( 'wpinv_admin_notices' );
434 434
         return is_array( $notices ) ? $notices : array();
435
-	}
436
-
437
-	/**
438
-	 * Clears all admin notices
439
-	 *
440
-	 * @access      public
441
-	 * @since       1.0.19
442
-	 */
443
-	public function clear_notices() {
444
-		delete_option( 'wpinv_admin_notices' );
445
-	}
446
-
447
-	/**
448
-	 * Saves a new admin notice
449
-	 *
450
-	 * @access      public
451
-	 * @since       1.0.19
452
-	 */
453
-	public function save_notice( $type, $message ) {
454
-		$notices = $this->get_notices();
455
-
456
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
457
-			$notices[ $type ] = array();
458
-		}
459
-
460
-		$notices[ $type ][] = $message;
461
-
462
-		update_option( 'wpinv_admin_notices', $notices );
463
-	}
464
-
465
-	/**
466
-	 * Displays a success notice
467
-	 *
468
-	 * @param       string $msg The message to qeue.
469
-	 * @access      public
470
-	 * @since       1.0.19
471
-	 */
472
-	public function show_success( $msg ) {
473
-		$this->save_notice( 'success', $msg );
474
-	}
475
-
476
-	/**
477
-	 * Displays a error notice
478
-	 *
479
-	 * @access      public
480
-	 * @param       string $msg The message to qeue.
481
-	 * @since       1.0.19
482
-	 */
483
-	public function show_error( $msg ) {
484
-		$this->save_notice( 'error', $msg );
485
-	}
486
-
487
-	/**
488
-	 * Displays a warning notice
489
-	 *
490
-	 * @access      public
491
-	 * @param       string $msg The message to qeue.
492
-	 * @since       1.0.19
493
-	 */
494
-	public function show_warning( $msg ) {
495
-		$this->save_notice( 'warning', $msg );
496
-	}
497
-
498
-	/**
499
-	 * Displays a info notice
500
-	 *
501
-	 * @access      public
502
-	 * @param       string $msg The message to qeue.
503
-	 * @since       1.0.19
504
-	 */
505
-	public function show_info( $msg ) {
506
-		$this->save_notice( 'info', $msg );
507
-	}
508
-
509
-	/**
510
-	 * Show notices
511
-	 *
512
-	 * @access      public
513
-	 * @since       1.0.19
514
-	 */
515
-	public function show_notices() {
435
+    }
436
+
437
+    /**
438
+     * Clears all admin notices
439
+     *
440
+     * @access      public
441
+     * @since       1.0.19
442
+     */
443
+    public function clear_notices() {
444
+        delete_option( 'wpinv_admin_notices' );
445
+    }
446
+
447
+    /**
448
+     * Saves a new admin notice
449
+     *
450
+     * @access      public
451
+     * @since       1.0.19
452
+     */
453
+    public function save_notice( $type, $message ) {
454
+        $notices = $this->get_notices();
455
+
456
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
457
+            $notices[ $type ] = array();
458
+        }
459
+
460
+        $notices[ $type ][] = $message;
461
+
462
+        update_option( 'wpinv_admin_notices', $notices );
463
+    }
464
+
465
+    /**
466
+     * Displays a success notice
467
+     *
468
+     * @param       string $msg The message to qeue.
469
+     * @access      public
470
+     * @since       1.0.19
471
+     */
472
+    public function show_success( $msg ) {
473
+        $this->save_notice( 'success', $msg );
474
+    }
475
+
476
+    /**
477
+     * Displays a error notice
478
+     *
479
+     * @access      public
480
+     * @param       string $msg The message to qeue.
481
+     * @since       1.0.19
482
+     */
483
+    public function show_error( $msg ) {
484
+        $this->save_notice( 'error', $msg );
485
+    }
486
+
487
+    /**
488
+     * Displays a warning notice
489
+     *
490
+     * @access      public
491
+     * @param       string $msg The message to qeue.
492
+     * @since       1.0.19
493
+     */
494
+    public function show_warning( $msg ) {
495
+        $this->save_notice( 'warning', $msg );
496
+    }
497
+
498
+    /**
499
+     * Displays a info notice
500
+     *
501
+     * @access      public
502
+     * @param       string $msg The message to qeue.
503
+     * @since       1.0.19
504
+     */
505
+    public function show_info( $msg ) {
506
+        $this->save_notice( 'info', $msg );
507
+    }
508
+
509
+    /**
510
+     * Show notices
511
+     *
512
+     * @access      public
513
+     * @since       1.0.19
514
+     */
515
+    public function show_notices() {
516 516
 
517 517
         $notices = $this->get_notices();
518 518
         $this->clear_notices();
519 519
 
520
-		foreach ( $notices as $type => $messages ) {
520
+        foreach ( $notices as $type => $messages ) {
521 521
 
522
-			if ( ! is_array( $messages ) ) {
523
-				continue;
524
-			}
522
+            if ( ! is_array( $messages ) ) {
523
+                continue;
524
+            }
525 525
 
526 526
             $type  = sanitize_key( $type );
527
-			foreach ( $messages as $message ) {
527
+            foreach ( $messages as $message ) {
528 528
                 $message = wp_kses_post( $message );
529
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
529
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
530 530
             }
531 531
 
532 532
         }
533 533
 
534
-	}
534
+    }
535 535
 
536 536
 }
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 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.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
68
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
65
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
66
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
67
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
68
+		do_action('getpaid_init_admin_hooks', $this);
69 69
 
70 70
     }
71 71
 
@@ -76,39 +76,39 @@  discard block
 block discarded – undo
76 76
 	public function enqeue_scripts() {
77 77
         global $current_screen, $pagenow;
78 78
 
79
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
79
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
80 80
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
81 81
 
82
-        if ( ! empty( $current_screen->post_type ) ) {
82
+        if (!empty($current_screen->post_type)) {
83 83
 			$page = $current_screen->post_type;
84 84
         }
85 85
 
86 86
         // General styles.
87
-        if ( false !== stripos( $page, 'wpi' ) ) {
87
+        if (false !== stripos($page, 'wpi')) {
88 88
 
89 89
             // Styles.
90
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
91
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
92
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
93
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
90
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
91
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
92
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
93
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
94 94
 
95 95
             // Scripts.
96
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
97
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
96
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
97
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
98 98
 
99
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
100
-            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 );
101
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
99
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
100
+            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);
101
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
102 102
 
103 103
         }
104 104
 
105 105
         // Payment form scripts.
106
-		if ( 'wpi_payment_form' == $page && $editing ) {
106
+		if ('wpi_payment_form' == $page && $editing) {
107 107
             $this->load_payment_form_scripts();
108 108
         }
109 109
 
110
-		if ( $page == 'wpinv-subscriptions' ) {
111
-			wp_enqueue_script( 'postbox' );
110
+		if ($page == 'wpinv-subscriptions') {
111
+			wp_enqueue_script('postbox');
112 112
 		}
113 113
 
114 114
     }
@@ -121,32 +121,32 @@  discard block
 block discarded – undo
121 121
         global $post;
122 122
 
123 123
 		$date_range = array(
124
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
124
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
125 125
 		);
126 126
 
127
-		if ( $date_range['period'] == 'custom' ) {
127
+		if ($date_range['period'] == 'custom') {
128 128
 			
129
-			if ( isset( $_GET['from'] ) ) {
130
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
129
+			if (isset($_GET['from'])) {
130
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
131 131
 			}
132 132
 
133
-			if ( isset( $_GET['to'] ) ) {
134
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
133
+			if (isset($_GET['to'])) {
134
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
135 135
 			}
136 136
 
137 137
 		}
138 138
 
139 139
         $i18n = array(
140
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
141
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
142
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
143
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
144
-			'rest_root'                 => esc_url_raw( rest_url() ),
140
+            'ajax_url'                  => admin_url('admin-ajax.php'),
141
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
142
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
143
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
144
+			'rest_root'                 => esc_url_raw(rest_url()),
145 145
 			'date_range'                => $date_range,
146
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
147
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
148
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
149
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
146
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
147
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
148
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
149
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
150 150
             'tax'                       => wpinv_tax_amount(),
151 151
             'discount'                  => 0,
152 152
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -155,35 +155,35 @@  discard block
 block discarded – undo
155 155
             'thousand_sep'              => wpinv_thousands_separator(),
156 156
             'decimal_sep'               => wpinv_decimal_separator(),
157 157
             'decimals'                  => wpinv_decimals(),
158
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
159
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
160
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
161
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
162
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
163
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
164
-            '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' ),
165
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
166
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
167
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
168
-            'action_edit'               => __( 'Edit', 'invoicing' ),
169
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
170
-            'item_description'          => __( 'Item Description', 'invoicing' ),
171
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
172
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
173
-            'searching'                 => __( 'Searching', 'invoicing' ),
158
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
159
+            'status_publish'            => wpinv_status_nicename('publish'),
160
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
161
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
162
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
163
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
164
+            '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'),
165
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
166
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
167
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
168
+            'action_edit'               => __('Edit', 'invoicing'),
169
+            'action_cancel'             => __('Cancel', 'invoicing'),
170
+            'item_description'          => __('Item Description', 'invoicing'),
171
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
172
+            'discount_description'      => __('Discount Description', 'invoicing'),
173
+            'searching'                 => __('Searching', 'invoicing'),
174 174
         );
175 175
 
176
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
176
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
177 177
 
178
-			$invoice              = new WPInv_Invoice( $post );
178
+			$invoice              = new WPInv_Invoice($post);
179 179
 			$i18n['save_invoice'] = sprintf(
180
-				__( 'Save %s', 'invoicing' ),
181
-				ucfirst( $invoice->get_invoice_quote_type() )
180
+				__('Save %s', 'invoicing'),
181
+				ucfirst($invoice->get_invoice_quote_type())
182 182
 			);
183 183
 
184 184
 			$i18n['invoice_description'] = sprintf(
185
-				__( '%s Description', 'invoicing' ),
186
-				ucfirst( $invoice->get_invoice_quote_type() )
185
+				__('%s Description', 'invoicing'),
186
+				ucfirst($invoice->get_invoice_quote_type())
187 187
 			);
188 188
 
189 189
 		}
@@ -197,24 +197,24 @@  discard block
 block discarded – undo
197 197
 	 * @param  string $footer_text
198 198
 	 * @return string
199 199
 	 */
200
-	public function admin_footer_text( $footer_text ) {
200
+	public function admin_footer_text($footer_text) {
201 201
 		global $current_screen;
202 202
 
203
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
203
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
204 204
 
205
-        if ( ! empty( $current_screen->post_type ) ) {
205
+        if (!empty($current_screen->post_type)) {
206 206
 			$page = $current_screen->post_type;
207 207
         }
208 208
 
209 209
         // General styles.
210
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
210
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
211 211
 
212 212
 			// Change the footer text
213
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
213
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
214 214
 
215
-				$rating_url  = esc_url(
215
+				$rating_url = esc_url(
216 216
 					wp_nonce_url(
217
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
217
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
218 218
 						'getpaid-nonce',
219 219
 						'getpaid-nonce'
220 220
 						)
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 
223 223
 				$footer_text = sprintf(
224 224
 					/* translators: %s: five stars */
225
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
225
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
226 226
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
227 227
 				);
228 228
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
 				$footer_text = sprintf(
232 232
 					/* translators: %s: GetPaid */
233
-					__( 'Thank you for using %s!', 'invoicing' ),
233
+					__('Thank you for using %s!', 'invoicing'),
234 234
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
235 235
 				);
236 236
 
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 * @since  2.0.0
248 248
 	 */
249 249
 	public function redirect_to_wordpress_rating_page() {
250
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
251
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
250
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
251
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
252 252
 		exit;
253 253
 	}
254 254
 
@@ -259,30 +259,30 @@  discard block
 block discarded – undo
259 259
 	protected function load_payment_form_scripts() {
260 260
         global $post;
261 261
 
262
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
263
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
264
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
262
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
263
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
264
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
265 265
 
266
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
267
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
266
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
267
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
268 268
 
269 269
 		wp_localize_script(
270 270
             'wpinv-admin-payment-form-script',
271 271
             'wpinvPaymentFormAdmin',
272 272
             array(
273
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
274
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
273
+				'elements'      => wpinv_get_data('payment-form-elements'),
274
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
275 275
 				'currency'      => wpinv_currency_symbol(),
276 276
 				'position'      => wpinv_currency_position(),
277 277
 				'decimals'      => (int) wpinv_decimals(),
278 278
 				'thousands_sep' => wpinv_thousands_separator(),
279 279
 				'decimals_sep'  => wpinv_decimal_separator(),
280
-				'form_items'    => gepaid_get_form_items( $post->ID ),
280
+				'form_items'    => gepaid_get_form_items($post->ID),
281 281
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
282 282
             )
283 283
         );
284 284
 
285
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
285
+        wp_enqueue_script('wpinv-admin-payment-form-script');
286 286
 
287 287
     }
288 288
 
@@ -293,25 +293,25 @@  discard block
 block discarded – undo
293 293
      * @return string
294 294
 	 *
295 295
 	 */
296
-    public function admin_body_class( $classes ) {
296
+    public function admin_body_class($classes) {
297 297
 		global $pagenow, $post, $current_screen;
298 298
 
299 299
 
300
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
300
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
301 301
 
302
-        if ( ! empty( $current_screen->post_type ) ) {
302
+        if (!empty($current_screen->post_type)) {
303 303
 			$page = $current_screen->post_type;
304 304
         }
305 305
 
306
-        if ( false !== stripos( $page, 'wpi' ) ) {
307
-            $classes .= ' wpi-' . sanitize_key( $page );
306
+        if (false !== stripos($page, 'wpi')) {
307
+            $classes .= ' wpi-' . sanitize_key($page);
308 308
         }
309 309
 
310
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
310
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
311 311
             $classes .= ' wpinv-cpt wpinv';
312 312
 		}
313 313
 		
314
-		if ( getpaid_is_invoice_post_type( $page ) ) {
314
+		if (getpaid_is_invoice_post_type($page)) {
315 315
             $classes .= ' getpaid-is-invoice-cpt';
316 316
         }
317 317
 
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
     /**
322 322
 	 * Maybe show the AyeCode Connect Notice.
323 323
 	 */
324
-	public function init_ayecode_connect_helper(){
324
+	public function init_ayecode_connect_helper() {
325 325
 
326 326
         new AyeCode_Connect_Helper(
327 327
             array(
328
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
329
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
330
-				'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>" ),
331
-				'connect_button'    => __("Connect Site","invoicing"),
332
-				'connecting_button'    => __("Connecting...","invoicing"),
333
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
334
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
328
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
329
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
330
+				'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>"),
331
+				'connect_button'    => __("Connect Site", "invoicing"),
332
+				'connecting_button'    => __("Connecting...", "invoicing"),
333
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
334
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
335 335
             ),
336
-            array( 'wpi-addons' )
336
+            array('wpi-addons')
337 337
         );
338 338
 
339 339
     }
@@ -345,20 +345,20 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	public function activation_redirect() {
347 347
 
348
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
348
+		$redirected = get_option('wpinv_redirected_to_settings');
349 349
 
350
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
350
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
351 351
 			return;
352 352
 		}
353 353
 
354 354
 		// Bail if activating from network, or bulk
355
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
355
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
356 356
 			return;
357 357
 		}
358 358
 
359
-	    update_option( 'wpinv_redirected_to_settings', 1 );
359
+	    update_option('wpinv_redirected_to_settings', 1);
360 360
 
361
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
361
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
362 362
         exit;
363 363
 
364 364
 	}
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
      */
369 369
     public function maybe_do_admin_action() {
370 370
 
371
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
372
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
373
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
371
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
372
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
373
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
374 374
         }
375 375
 
376 376
     }
@@ -380,16 +380,16 @@  discard block
 block discarded – undo
380 380
 	 * 
381 381
 	 * @param array $args
382 382
      */
383
-    public function send_customer_invoice( $args ) {
384
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
383
+    public function send_customer_invoice($args) {
384
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
385 385
 
386
-		if ( $sent ) {
387
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
386
+		if ($sent) {
387
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
388 388
 		} else {
389
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
389
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
390 390
 		}
391 391
 
392
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
392
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
393 393
 		exit;
394 394
 	}
395 395
 
@@ -398,16 +398,16 @@  discard block
 block discarded – undo
398 398
 	 * 
399 399
 	 * @param array $args
400 400
      */
401
-    public function send_customer_payment_reminder( $args ) {
402
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
401
+    public function send_customer_payment_reminder($args) {
402
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
403 403
 
404
-		if ( $sent ) {
405
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
404
+		if ($sent) {
405
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
406 406
 		} else {
407
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
407
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
408 408
 		}
409 409
 
410
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
410
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
411 411
 		exit;
412 412
 	}
413 413
 
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
      */
418 418
     public function admin_reset_tax_rates() {
419 419
 
420
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
421
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
420
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
421
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
422 422
 		exit;
423 423
 
424 424
 	}
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
      * @return array
431 431
 	 */
432 432
 	public function get_notices() {
433
-		$notices = get_option( 'wpinv_admin_notices' );
434
-        return is_array( $notices ) ? $notices : array();
433
+		$notices = get_option('wpinv_admin_notices');
434
+        return is_array($notices) ? $notices : array();
435 435
 	}
436 436
 
437 437
 	/**
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	 * @since       1.0.19
442 442
 	 */
443 443
 	public function clear_notices() {
444
-		delete_option( 'wpinv_admin_notices' );
444
+		delete_option('wpinv_admin_notices');
445 445
 	}
446 446
 
447 447
 	/**
@@ -450,16 +450,16 @@  discard block
 block discarded – undo
450 450
 	 * @access      public
451 451
 	 * @since       1.0.19
452 452
 	 */
453
-	public function save_notice( $type, $message ) {
453
+	public function save_notice($type, $message) {
454 454
 		$notices = $this->get_notices();
455 455
 
456
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
457
-			$notices[ $type ] = array();
456
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
457
+			$notices[$type] = array();
458 458
 		}
459 459
 
460
-		$notices[ $type ][] = $message;
460
+		$notices[$type][] = $message;
461 461
 
462
-		update_option( 'wpinv_admin_notices', $notices );
462
+		update_option('wpinv_admin_notices', $notices);
463 463
 	}
464 464
 
465 465
 	/**
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 	 * @access      public
470 470
 	 * @since       1.0.19
471 471
 	 */
472
-	public function show_success( $msg ) {
473
-		$this->save_notice( 'success', $msg );
472
+	public function show_success($msg) {
473
+		$this->save_notice('success', $msg);
474 474
 	}
475 475
 
476 476
 	/**
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 * @param       string $msg The message to qeue.
481 481
 	 * @since       1.0.19
482 482
 	 */
483
-	public function show_error( $msg ) {
484
-		$this->save_notice( 'error', $msg );
483
+	public function show_error($msg) {
484
+		$this->save_notice('error', $msg);
485 485
 	}
486 486
 
487 487
 	/**
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 	 * @param       string $msg The message to qeue.
492 492
 	 * @since       1.0.19
493 493
 	 */
494
-	public function show_warning( $msg ) {
495
-		$this->save_notice( 'warning', $msg );
494
+	public function show_warning($msg) {
495
+		$this->save_notice('warning', $msg);
496 496
 	}
497 497
 
498 498
 	/**
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 * @param       string $msg The message to qeue.
503 503
 	 * @since       1.0.19
504 504
 	 */
505
-	public function show_info( $msg ) {
506
-		$this->save_notice( 'info', $msg );
505
+	public function show_info($msg) {
506
+		$this->save_notice('info', $msg);
507 507
 	}
508 508
 
509 509
 	/**
@@ -517,15 +517,15 @@  discard block
 block discarded – undo
517 517
         $notices = $this->get_notices();
518 518
         $this->clear_notices();
519 519
 
520
-		foreach ( $notices as $type => $messages ) {
520
+		foreach ($notices as $type => $messages) {
521 521
 
522
-			if ( ! is_array( $messages ) ) {
522
+			if (!is_array($messages)) {
523 523
 				continue;
524 524
 			}
525 525
 
526
-            $type  = sanitize_key( $type );
527
-			foreach ( $messages as $message ) {
528
-                $message = wp_kses_post( $message );
526
+            $type = sanitize_key($type);
527
+			foreach ($messages as $message) {
528
+                $message = wp_kses_post($message);
529 529
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
530 530
             }
531 531
 
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15 15
             echo $discount->get_code();
16 16
         break;
@@ -21,33 +21,33 @@  discard block
 block discarded – undo
21 21
             echo $discount->get_usage();
22 22
         break;
23 23
         case 'start_date' :
24
-            echo getpaid_format_date_value( $discount->get_start_date() );
24
+            echo getpaid_format_date_value($discount->get_start_date());
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) );
27
+            echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_discount' ) {
37
-        $actions = wpinv_discount_row_actions( $post, $actions );
36
+    if ($post_type == 'wpi_discount') {
37
+        $actions = wpinv_discount_row_actions($post, $actions);
38 38
     }
39 39
 
40 40
     return $actions;
41 41
 }
42 42
 
43
-function wpinv_discount_row_actions( $discount, $row_actions ) {
44
-    $row_actions  = array();
45
-    $edit_link = get_edit_post_link( $discount->ID );
46
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
43
+function wpinv_discount_row_actions($discount, $row_actions) {
44
+    $row_actions = array();
45
+    $edit_link = get_edit_post_link($discount->ID);
46
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
47 47
 
48
-    if ( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
48
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
49 49
 
50
-        $url    = esc_url(
50
+        $url = esc_url(
51 51
                     wp_nonce_url(
52 52
                         add_query_arg(
53 53
                             array(
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
                         'getpaid-nonce'
60 60
                     )
61 61
                 );
62
-		$anchor = __( 'Deactivate', 'invoicing' );
63
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
62
+		$anchor = __('Deactivate', 'invoicing');
63
+		$title  = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing');
64 64
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
65 65
 
66
-    } else if( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
66
+    } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
67 67
 
68
-        $url    = esc_url(
68
+        $url = esc_url(
69 69
             wp_nonce_url(
70 70
                 add_query_arg(
71 71
                     array(
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
                 'getpaid-nonce'
78 78
             )
79 79
         );
80
-		$anchor = __( 'Activate', 'invoicing' );
81
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
80
+		$anchor = __('Activate', 'invoicing');
81
+		$title  = esc_attr__('Are you sure you want to activate this discount?', 'invoicing');
82 82
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
83 83
 
84 84
     }
85 85
 
86
-    $url    = esc_url(
86
+    $url = esc_url(
87 87
         wp_nonce_url(
88 88
             add_query_arg(
89 89
                 array(
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
             'getpaid-nonce'
96 96
         )
97 97
     );
98
-	$anchor = __( 'Delete', 'invoicing' );
99
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
98
+	$anchor = __('Delete', 'invoicing');
99
+	$title  = esc_attr__('Are you sure you want to delete this discount?', 'invoicing');
100 100
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
101 101
 
102
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
102
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
103 103
 
104 104
     return $row_actions;
105 105
 }
@@ -107,68 +107,68 @@  discard block
 block discarded – undo
107 107
 function wpinv_restrict_manage_posts() {
108 108
     global $typenow;
109 109
 
110
-    if( 'wpi_discount' == $typenow ) {
110
+    if ('wpi_discount' == $typenow) {
111 111
         wpinv_discount_filters();
112 112
     }
113 113
 }
114
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
114
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
115 115
 
116 116
 function wpinv_discount_filters() {
117 117
 
118 118
     ?>
119 119
     <select name="discount_type" id="dropdown_wpinv_discount_type">
120
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
120
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
121 121
         <?php
122 122
             $types = wpinv_get_discount_types();
123 123
 
124
-            foreach ( $types as $name => $type ) {
125
-                echo '<option value="' . esc_attr( $name ) . '"';
124
+            foreach ($types as $name => $type) {
125
+                echo '<option value="' . esc_attr($name) . '"';
126 126
 
127
-                if ( isset( $_GET['discount_type'] ) )
128
-                    selected( $name, $_GET['discount_type'] );
127
+                if (isset($_GET['discount_type']))
128
+                    selected($name, $_GET['discount_type']);
129 129
 
130
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
130
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
131 131
             }
132 132
         ?>
133 133
     </select>
134 134
     <?php
135 135
 }
136 136
 
137
-function wpinv_request( $vars ) {
137
+function wpinv_request($vars) {
138 138
     global $typenow, $wp_post_statuses;
139 139
 
140
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
141
-        if ( ! isset( $vars['post_status'] ) ) {
142
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
140
+    if (getpaid_is_invoice_post_type($typenow)) {
141
+        if (!isset($vars['post_status'])) {
142
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
143 143
 
144
-            foreach ( $post_statuses as $status => $value ) {
145
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
146
-                    unset( $post_statuses[ $status ] );
144
+            foreach ($post_statuses as $status => $value) {
145
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
146
+                    unset($post_statuses[$status]);
147 147
                 }
148 148
             }
149 149
 
150
-            $vars['post_status'] = array_keys( $post_statuses );
150
+            $vars['post_status'] = array_keys($post_statuses);
151 151
         }
152 152
 
153
-    } else if ( 'wpi_discount' == $typenow ) {
154
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
153
+    } else if ('wpi_discount' == $typenow) {
154
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
155 155
         // Filter vat rule type
156
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
156
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
157 157
             $meta_query[] = array(
158 158
                     'key'   => '_wpi_discount_type',
159
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
159
+                    'value' => sanitize_text_field($_GET['discount_type']),
160 160
                     'compare' => '='
161 161
                 );
162 162
         }
163 163
 
164
-        if ( !empty( $meta_query ) ) {
164
+        if (!empty($meta_query)) {
165 165
             $vars['meta_query'] = $meta_query;
166 166
         }
167 167
     }
168 168
 
169 169
     return $vars;
170 170
 }
171
-add_filter( 'request', 'wpinv_request' );
171
+add_filter('request', 'wpinv_request');
172 172
 
173 173
 /**
174 174
  * Create a page and store the ID in an option.
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
  * @param int $post_parent (default: 0) Parent for the new page
181 181
  * @return int page ID
182 182
  */
183
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
183
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
184 184
     global $wpdb;
185 185
 
186
-    $option_value = wpinv_get_option( $option );
186
+    $option_value = wpinv_get_option($option);
187 187
 
188
-    if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) {
189
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
188
+    if (!empty($option_value) && ($page_object = get_post($option_value))) {
189
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
190 190
             // Valid page is already in place
191 191
             return $page_object->ID;
192 192
         }
193 193
     }
194 194
 
195
-    if(!empty($post_parent)){
195
+    if (!empty($post_parent)) {
196 196
         $page = get_page_by_path($post_parent);
197 197
         if ($page) {
198 198
             $post_parent = $page->ID;
@@ -201,40 +201,40 @@  discard block
 block discarded – undo
201 201
         }
202 202
     }
203 203
 
204
-    if ( strlen( $page_content ) > 0 ) {
204
+    if (strlen($page_content) > 0) {
205 205
         // Search for an existing page with the specified page content (typically a shortcode)
206
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
206
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
207 207
     } else {
208 208
         // Search for an existing page with the specified page slug
209
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
209
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
210 210
     }
211 211
 
212
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
212
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
213 213
 
214
-    if ( $valid_page_found ) {
215
-        if ( $option ) {
216
-            wpinv_update_option( $option, $valid_page_found );
214
+    if ($valid_page_found) {
215
+        if ($option) {
216
+            wpinv_update_option($option, $valid_page_found);
217 217
         }
218 218
         return $valid_page_found;
219 219
     }
220 220
 
221 221
     // Search for a matching valid trashed page
222
-    if ( strlen( $page_content ) > 0 ) {
222
+    if (strlen($page_content) > 0) {
223 223
         // Search for an existing page with the specified page content (typically a shortcode)
224
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
224
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
225 225
     } else {
226 226
         // Search for an existing page with the specified page slug
227
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
227
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
228 228
     }
229 229
 
230
-    if ( $trashed_page_found ) {
230
+    if ($trashed_page_found) {
231 231
         $page_id   = $trashed_page_found;
232 232
         $page_data = array(
233 233
             'ID'             => $page_id,
234 234
             'post_status'    => 'publish',
235 235
             'post_parent'    => $post_parent,
236 236
         );
237
-        wp_update_post( $page_data );
237
+        wp_update_post($page_data);
238 238
     } else {
239 239
         $page_data = array(
240 240
             'post_status'    => 'publish',
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
             'post_parent'    => $post_parent,
247 247
             'comment_status' => 'closed',
248 248
         );
249
-        $page_id = wp_insert_post( $page_data );
249
+        $page_id = wp_insert_post($page_data);
250 250
     }
251 251
 
252
-    if ( $option ) {
253
-        wpinv_update_option( $option, (int) $page_id );
252
+    if ($option) {
253
+        wpinv_update_option($option, (int) $page_id);
254 254
     }
255 255
 
256 256
     return $page_id;
Please login to merge, or discard this patch.
includes/admin/register-settings.php 3 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = wpinv_clean( $option['desc'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = wpinv_clean( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228 228
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229 229
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
230
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
232 232
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233 233
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
246 246
 }
247 247
 
248 248
 /**
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
293 293
 
294
-		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
294
+        // Key specific filter.
295
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 
349 349
     foreach ( $new_rates as $rate ) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
356
-		$tax_rates[]     = $rate;
351
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
+        $rate['name']    = sanitize_text_field( $rate['name'] );
353
+        $rate['state']   = sanitize_text_field( $rate['state'] );
354
+        $rate['country'] = sanitize_text_field( $rate['country'] );
355
+        $rate['global']  = empty( $rate['state'] );
356
+        $tax_rates[]     = $rate;
357 357
 
358
-	}
358
+    }
359 359
 
360 360
     update_option( 'wpinv_tax_rates', $tax_rates );
361 361
 
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
     $tabs['general']  = __( 'General', 'invoicing' );
374 374
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375 375
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
376
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
-	}
378
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
380
+    }
381 381
 
382 382
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383 383
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -415,14 +415,14 @@  discard block
 block discarded – undo
415 415
         ) ),
416 416
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
417 417
             'main'  => __( 'Tax Settings', 'invoicing' ),
418
-			'rates' => __( 'Tax Rates', 'invoicing' ),
419
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
418
+            'rates' => __( 'Tax Rates', 'invoicing' ),
419
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
420 420
         ) ),
421 421
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
422 422
             'main' => __( 'Email Settings', 'invoicing' ),
423
-		) ),
423
+        ) ),
424 424
 
425
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
425
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
426 426
 
427 427
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
428 428
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -442,51 +442,51 @@  discard block
 block discarded – undo
442 442
 }
443 443
 
444 444
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
445
-	$pages_options = array();
445
+    $pages_options = array();
446 446
 
447
-	if( $default_label !== NULL && $default_label !== false ) {
448
-		$pages_options = array( '' => $default_label ); // Blank option
449
-	}
447
+    if( $default_label !== NULL && $default_label !== false ) {
448
+        $pages_options = array( '' => $default_label ); // Blank option
449
+    }
450 450
 
451
-	$pages = get_pages();
452
-	if ( $pages ) {
453
-		foreach ( $pages as $page ) {
454
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
451
+    $pages = get_pages();
452
+    if ( $pages ) {
453
+        foreach ( $pages as $page ) {
454
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
455 455
             $pages_options[ $page->ID ] = $title;
456
-		}
457
-	}
456
+        }
457
+    }
458 458
 
459
-	return $pages_options;
459
+    return $pages_options;
460 460
 }
461 461
 
462 462
 function wpinv_header_callback( $args ) {
463
-	if ( !empty( $args['desc'] ) ) {
463
+    if ( !empty( $args['desc'] ) ) {
464 464
         echo $args['desc'];
465 465
     }
466 466
 }
467 467
 
468 468
 function wpinv_hidden_callback( $args ) {
469
-	global $wpinv_options;
470
-
471
-	if ( isset( $args['set_value'] ) ) {
472
-		$value = $args['set_value'];
473
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
-		$value = $wpinv_options[ $args['id'] ];
475
-	} else {
476
-		$value = isset( $args['std'] ) ? $args['std'] : '';
477
-	}
478
-
479
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
480
-		$args['readonly'] = true;
481
-		$value = isset( $args['std'] ) ? $args['std'] : '';
482
-		$name  = '';
483
-	} else {
484
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
485
-	}
486
-
487
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
469
+    global $wpinv_options;
470
+
471
+    if ( isset( $args['set_value'] ) ) {
472
+        $value = $args['set_value'];
473
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
+        $value = $wpinv_options[ $args['id'] ];
475
+    } else {
476
+        $value = isset( $args['std'] ) ? $args['std'] : '';
477
+    }
478
+
479
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
480
+        $args['readonly'] = true;
481
+        $value = isset( $args['std'] ) ? $args['std'] : '';
482
+        $name  = '';
483
+    } else {
484
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
485
+    }
486
+
487
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
488 488
     
489
-	echo $html;
489
+    echo $html;
490 490
 }
491 491
 
492 492
 /**
@@ -494,12 +494,12 @@  discard block
 block discarded – undo
494 494
  */
495 495
 function wpinv_checkbox_callback( $args ) {
496 496
 
497
-	$std = isset( $args['std'] ) ? $args['std'] : '';
498
-	$std = wpinv_get_option( $args['id'], $std );
499
-	$id  = esc_attr( $args['id'] );
497
+    $std = isset( $args['std'] ) ? $args['std'] : '';
498
+    $std = wpinv_get_option( $args['id'], $std );
499
+    $id  = esc_attr( $args['id'] );
500 500
 
501
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
502
-	?>
501
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
502
+    ?>
503 503
 		<fieldset>
504 504
 			<label>
505 505
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -511,77 +511,77 @@  discard block
 block discarded – undo
511 511
 
512 512
 function wpinv_multicheck_callback( $args ) {
513 513
 	
514
-	global $wpinv_options;
514
+    global $wpinv_options;
515 515
 
516
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
517
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
516
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
517
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
518 518
 
519
-	if ( ! empty( $args['options'] ) ) {
519
+    if ( ! empty( $args['options'] ) ) {
520 520
 
521
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
522
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
521
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
522
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
523 523
 
524
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
524
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
525 525
         foreach( $args['options'] as $key => $option ):
526
-			$sanitize_key = wpinv_sanitize_key( $key );
527
-			if ( in_array( $sanitize_key, $value ) ) { 
528
-				$enabled = $sanitize_key;
529
-			} else { 
530
-				$enabled = NULL; 
531
-			}
532
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
533
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
534
-		endforeach;
535
-		echo '</div>';
536
-		echo '<p class="description">' . $args['desc'] . '</p>';
537
-	}
526
+            $sanitize_key = wpinv_sanitize_key( $key );
527
+            if ( in_array( $sanitize_key, $value ) ) { 
528
+                $enabled = $sanitize_key;
529
+            } else { 
530
+                $enabled = NULL; 
531
+            }
532
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
533
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
534
+        endforeach;
535
+        echo '</div>';
536
+        echo '<p class="description">' . $args['desc'] . '</p>';
537
+    }
538 538
 }
539 539
 
540 540
 function wpinv_payment_icons_callback( $args ) {
541
-	global $wpinv_options;
541
+    global $wpinv_options;
542 542
     
543 543
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
544 544
 
545
-	if ( ! empty( $args['options'] ) ) {
546
-		foreach( $args['options'] as $key => $option ) {
545
+    if ( ! empty( $args['options'] ) ) {
546
+        foreach( $args['options'] as $key => $option ) {
547 547
             $sanitize_key = wpinv_sanitize_key( $key );
548 548
             
549
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
550
-				$enabled = $option;
551
-			} else {
552
-				$enabled = NULL;
553
-			}
554
-
555
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
556
-
557
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
558
-
559
-				if ( wpinv_string_is_image_url( $key ) ) {
560
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
-				} else {
562
-					$card = strtolower( str_replace( ' ', '', $option ) );
563
-
564
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
-					} else {
567
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
568
-						$content_dir = WP_CONTENT_DIR;
569
-
570
-						if ( function_exists( 'wp_normalize_path' ) ) {
571
-							// Replaces backslashes with forward slashes for Windows systems
572
-							$image = wp_normalize_path( $image );
573
-							$content_dir = wp_normalize_path( $content_dir );
574
-						}
575
-
576
-						$image = str_replace( $content_dir, content_url(), $image );
577
-					}
578
-
579
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580
-				}
581
-			echo $option . '</label>';
582
-		}
583
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
584
-	}
549
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
550
+                $enabled = $option;
551
+            } else {
552
+                $enabled = NULL;
553
+            }
554
+
555
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
556
+
557
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
558
+
559
+                if ( wpinv_string_is_image_url( $key ) ) {
560
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
+                } else {
562
+                    $card = strtolower( str_replace( ' ', '', $option ) );
563
+
564
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
566
+                    } else {
567
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
568
+                        $content_dir = WP_CONTENT_DIR;
569
+
570
+                        if ( function_exists( 'wp_normalize_path' ) ) {
571
+                            // Replaces backslashes with forward slashes for Windows systems
572
+                            $image = wp_normalize_path( $image );
573
+                            $content_dir = wp_normalize_path( $content_dir );
574
+                        }
575
+
576
+                        $image = str_replace( $content_dir, content_url(), $image );
577
+                    }
578
+
579
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580
+                }
581
+            echo $option . '</label>';
582
+        }
583
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
584
+    }
585 585
 }
586 586
 
587 587
 /**
@@ -589,9 +589,9 @@  discard block
 block discarded – undo
589 589
  */
590 590
 function wpinv_radio_callback( $args ) {
591 591
 
592
-	$std = isset( $args['std'] ) ? $args['std'] : '';
593
-	$std = wpinv_get_option( $args['id'], $std );
594
-	?>
592
+    $std = isset( $args['std'] ) ? $args['std'] : '';
593
+    $std = wpinv_get_option( $args['id'], $std );
594
+    ?>
595 595
 		<fieldset>
596 596
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
597 597
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 			</ul>
606 606
 		</fieldset>
607 607
 	<?php
608
-	getpaid_settings_description_callback( $args );
608
+    getpaid_settings_description_callback( $args );
609 609
 }
610 610
 
611 611
 /**
@@ -613,50 +613,50 @@  discard block
 block discarded – undo
613 613
  */
614 614
 function getpaid_settings_description_callback( $args ) {
615 615
 
616
-	if ( ! empty( $args['desc'] ) ) {
617
-		$description = wp_kses_post( $args['desc'] );
618
-		echo "<p class='description'>$description</p>";
619
-	}
616
+    if ( ! empty( $args['desc'] ) ) {
617
+        $description = wp_kses_post( $args['desc'] );
618
+        echo "<p class='description'>$description</p>";
619
+    }
620 620
 
621 621
 }
622 622
 
623 623
 function wpinv_gateways_callback( $args ) {
624 624
 
625
-	$gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
625
+    $gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
626 626
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
627 627
 
628
-	foreach ( $args['options'] as $key => $option ) :
629
-		$sanitize_key = wpinv_sanitize_key( $key );
628
+    foreach ( $args['options'] as $key => $option ) :
629
+        $sanitize_key = wpinv_sanitize_key( $key );
630 630
         
631 631
         if ( is_array( $gateways ) && isset( $gateways[ $key ] ) )
632
-			$enabled = '1';
633
-		else
634
-			$enabled = null;
632
+            $enabled = '1';
633
+        else
634
+            $enabled = null;
635 635
 
636
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
638
-	endforeach;
636
+        echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
638
+    endforeach;
639 639
 }
640 640
 
641 641
 function wpinv_gateway_select_callback($args) {
642
-	global $wpinv_options;
642
+    global $wpinv_options;
643 643
     
644 644
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
645 645
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
646 646
 
647
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
647
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
650
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
649
+    foreach ( $args['options'] as $key => $option ) :
650
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651 651
             $selected = selected( $key, $args['selected'], false );
652 652
         } else {
653 653
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
654 654
         }
655
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
656
-	endforeach;
655
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
656
+    endforeach;
657 657
 
658
-	echo '</select>';
659
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
658
+    echo '</select>';
659
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
660 660
 }
661 661
 
662 662
 /**
@@ -667,29 +667,29 @@  discard block
 block discarded – undo
667 667
  */
668 668
 function wpinv_settings_attrs_helper( $args ) {
669 669
 
670
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
671
-	$id           = esc_attr( $args['id'] );
672
-	$placeholder  = esc_attr( $args['placeholder'] );
670
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
671
+    $id           = esc_attr( $args['id'] );
672
+    $placeholder  = esc_attr( $args['placeholder'] );
673 673
 
674
-	if ( ! empty( $args['faux'] ) ) {
675
-		$args['readonly'] = true;
676
-		$name             = '';
677
-	} else {
678
-		$value  = wpinv_get_option( $args['id'], $value );
679
-		$name   = "wpinv_settings[$id]";
680
-	}
674
+    if ( ! empty( $args['faux'] ) ) {
675
+        $args['readonly'] = true;
676
+        $name             = '';
677
+    } else {
678
+        $value  = wpinv_get_option( $args['id'], $value );
679
+        $name   = "wpinv_settings[$id]";
680
+    }
681 681
 
682
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
683
-	$class    = esc_attr( $args['class'] );
684
-	$style    = esc_attr( $args['style'] );
685
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
682
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
683
+    $class    = esc_attr( $args['class'] );
684
+    $style    = esc_attr( $args['style'] );
685
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
686 686
 
687
-	$onchange = '';
687
+    $onchange = '';
688 688
     if ( ! empty( $args['onchange'] ) ) {
689 689
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
690
-	}
690
+    }
691 691
 
692
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
692
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
693 693
 }
694 694
 
695 695
 /**
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
  */
698 698
 function wpinv_text_callback( $args ) {
699 699
 
700
-	$desc = wp_kses_post( $args['desc'] );
701
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
702
-	$attr = wpinv_settings_attrs_helper( $args );
700
+    $desc = wp_kses_post( $args['desc'] );
701
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
702
+    $attr = wpinv_settings_attrs_helper( $args );
703 703
 
704
-	?>
704
+    ?>
705 705
 		<label style="width: 100%;">
706 706
 			<input type="text" <?php echo $attr; ?>>
707 707
 			<?php echo $desc; ?>
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
  */
716 716
 function wpinv_number_callback( $args ) {
717 717
 
718
-	$desc = wp_kses_post( $args['desc'] );
719
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
720
-	$attr = wpinv_settings_attrs_helper( $args );
721
-	$max  = intval( $args['max'] );
722
-	$min  = intval( $args['min'] );
723
-	$step = floatval( $args['step'] );
718
+    $desc = wp_kses_post( $args['desc'] );
719
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
720
+    $attr = wpinv_settings_attrs_helper( $args );
721
+    $max  = intval( $args['max'] );
722
+    $min  = intval( $args['min'] );
723
+    $step = floatval( $args['step'] );
724 724
 
725
-	?>
725
+    ?>
726 726
 		<label style="width: 100%;">
727 727
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
728 728
 			<?php echo $desc; ?>
@@ -732,48 +732,48 @@  discard block
 block discarded – undo
732 732
 }
733 733
 
734 734
 function wpinv_textarea_callback( $args ) {
735
-	global $wpinv_options;
735
+    global $wpinv_options;
736 736
     
737 737
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
738 738
 
739
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
-		$value = $wpinv_options[ $args['id'] ];
741
-	} else {
742
-		$value = isset( $args['std'] ) ? $args['std'] : '';
743
-	}
739
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
+        $value = $wpinv_options[ $args['id'] ];
741
+    } else {
742
+        $value = isset( $args['std'] ) ? $args['std'] : '';
743
+    }
744 744
     
745 745
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
746 746
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
747 747
 
748
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
749
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
748
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
749
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
750 750
 
751
-	echo $html;
751
+    echo $html;
752 752
 }
753 753
 
754 754
 function wpinv_password_callback( $args ) {
755
-	global $wpinv_options;
755
+    global $wpinv_options;
756 756
     
757 757
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
758 758
 
759
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
-		$value = $wpinv_options[ $args['id'] ];
761
-	} else {
762
-		$value = isset( $args['std'] ) ? $args['std'] : '';
763
-	}
759
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
+        $value = $wpinv_options[ $args['id'] ];
761
+    } else {
762
+        $value = isset( $args['std'] ) ? $args['std'] : '';
763
+    }
764 764
 
765
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
766
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
767
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
765
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
766
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
767
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
768 768
 
769
-	echo $html;
769
+    echo $html;
770 770
 }
771 771
 
772 772
 function wpinv_missing_callback($args) {
773
-	printf(
774
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
775
-		'<strong>' . $args['id'] . '</strong>'
776
-	);
773
+    printf(
774
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
775
+        '<strong>' . $args['id'] . '</strong>'
776
+    );
777 777
 }
778 778
 
779 779
 /**
@@ -781,13 +781,13 @@  discard block
 block discarded – undo
781 781
  */
782 782
 function wpinv_select_callback( $args ) {
783 783
 
784
-	$desc   = wp_kses_post( $args['desc'] );
785
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
786
-	$attr   = wpinv_settings_attrs_helper( $args );
787
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
788
-	$value  = wpinv_get_option( $args['id'], $value );
784
+    $desc   = wp_kses_post( $args['desc'] );
785
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
786
+    $attr   = wpinv_settings_attrs_helper( $args );
787
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
788
+    $value  = wpinv_get_option( $args['id'], $value );
789 789
 
790
-	?>
790
+    ?>
791 791
 		<label style="width: 100%;">
792 792
 			<select <?php echo $attr; ?>>
793 793
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -801,123 +801,123 @@  discard block
 block discarded – undo
801 801
 }
802 802
 
803 803
 function wpinv_color_select_callback( $args ) {
804
-	global $wpinv_options;
804
+    global $wpinv_options;
805 805
     
806 806
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
807 807
 
808
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
-		$value = $wpinv_options[ $args['id'] ];
810
-	} else {
811
-		$value = isset( $args['std'] ) ? $args['std'] : '';
812
-	}
808
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
+        $value = $wpinv_options[ $args['id'] ];
810
+    } else {
811
+        $value = isset( $args['std'] ) ? $args['std'] : '';
812
+    }
813 813
 
814
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
814
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
815 815
 
816
-	foreach ( $args['options'] as $option => $color ) {
817
-		$selected = selected( $option, $value, false );
818
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
819
-	}
816
+    foreach ( $args['options'] as $option => $color ) {
817
+        $selected = selected( $option, $value, false );
818
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
819
+    }
820 820
 
821
-	$html .= '</select>';
822
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
821
+    $html .= '</select>';
822
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
823 823
 
824
-	echo $html;
824
+    echo $html;
825 825
 }
826 826
 
827 827
 function wpinv_rich_editor_callback( $args ) {
828
-	global $wpinv_options, $wp_version;
828
+    global $wpinv_options, $wp_version;
829 829
     
830 830
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
831 831
 
832
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
833
-		$value = $wpinv_options[ $args['id'] ];
832
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
833
+        $value = $wpinv_options[ $args['id'] ];
834 834
 
835
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
836
-			$value = isset( $args['std'] ) ? $args['std'] : '';
837
-		}
838
-	} else {
839
-		$value = isset( $args['std'] ) ? $args['std'] : '';
840
-	}
835
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
836
+            $value = isset( $args['std'] ) ? $args['std'] : '';
837
+        }
838
+    } else {
839
+        $value = isset( $args['std'] ) ? $args['std'] : '';
840
+    }
841 841
 
842
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
842
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
843 843
 
844
-	$html = '<div class="getpaid-settings-editor-input">';
845
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
846
-		ob_start();
847
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
848
-		$html .= ob_get_clean();
849
-	} else {
850
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
851
-	}
844
+    $html = '<div class="getpaid-settings-editor-input">';
845
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
846
+        ob_start();
847
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
848
+        $html .= ob_get_clean();
849
+    } else {
850
+        $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
851
+    }
852 852
 
853
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
853
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
854 854
 
855
-	echo $html;
855
+    echo $html;
856 856
 }
857 857
 
858 858
 function wpinv_upload_callback( $args ) {
859
-	global $wpinv_options;
859
+    global $wpinv_options;
860 860
     
861 861
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
862 862
 
863
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
864
-		$value = $wpinv_options[$args['id']];
865
-	} else {
866
-		$value = isset($args['std']) ? $args['std'] : '';
867
-	}
863
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
864
+        $value = $wpinv_options[$args['id']];
865
+    } else {
866
+        $value = isset($args['std']) ? $args['std'] : '';
867
+    }
868 868
 
869
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
870
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
871
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
872
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
869
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
870
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
871
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
872
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
873 873
 
874
-	echo $html;
874
+    echo $html;
875 875
 }
876 876
 
877 877
 function wpinv_color_callback( $args ) {
878
-	global $wpinv_options;
878
+    global $wpinv_options;
879 879
     
880 880
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
881 881
 
882
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
-		$value = $wpinv_options[ $args['id'] ];
884
-	} else {
885
-		$value = isset( $args['std'] ) ? $args['std'] : '';
886
-	}
882
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
+        $value = $wpinv_options[ $args['id'] ];
884
+    } else {
885
+        $value = isset( $args['std'] ) ? $args['std'] : '';
886
+    }
887 887
 
888
-	$default = isset( $args['std'] ) ? $args['std'] : '';
888
+    $default = isset( $args['std'] ) ? $args['std'] : '';
889 889
 
890
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
891
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
890
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
891
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892 892
 
893
-	echo $html;
893
+    echo $html;
894 894
 }
895 895
 
896 896
 function wpinv_country_states_callback($args) {
897
-	global $wpinv_options;
897
+    global $wpinv_options;
898 898
     
899 899
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
900 900
 
901
-	if ( isset( $args['placeholder'] ) ) {
902
-		$placeholder = $args['placeholder'];
903
-	} else {
904
-		$placeholder = '';
905
-	}
901
+    if ( isset( $args['placeholder'] ) ) {
902
+        $placeholder = $args['placeholder'];
903
+    } else {
904
+        $placeholder = '';
905
+    }
906 906
 
907
-	$states = wpinv_get_country_states();
907
+    $states = wpinv_get_country_states();
908 908
 
909
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
909
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
911 911
 
912
-	foreach ( $states as $option => $name ) {
913
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
914
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
915
-	}
912
+    foreach ( $states as $option => $name ) {
913
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
914
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
915
+    }
916 916
 
917
-	$html .= '</select>';
918
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
917
+    $html .= '</select>';
918
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
919 919
 
920
-	echo $html;
920
+    echo $html;
921 921
 }
922 922
 
923 923
 /**
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
  */
926 926
 function wpinv_tax_rates_callback() {
927 927
 	
928
-	?>
928
+    ?>
929 929
 		</td>
930 930
 	</tr>
931 931
 	<tr class="bsui">
@@ -940,17 +940,17 @@  discard block
 block discarded – undo
940 940
  * Displays a tax rate' edit row.
941 941
  */
942 942
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
943
-	ob_start();
943
+    ob_start();
944 944
 
945
-	$key                      = sanitize_key( $key );
946
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
947
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
945
+    $key                      = sanitize_key( $key );
946
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
947
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
948 948
 
949
-	if ( $echo ) {
950
-		echo ob_get_clean();
951
-	} else {
952
-		return ob_get_clean(); 
953
-	}
949
+    if ( $echo ) {
950
+        echo ob_get_clean();
951
+    } else {
952
+        return ob_get_clean(); 
953
+    }
954 954
 
955 955
 }
956 956
 
@@ -978,19 +978,19 @@  discard block
 block discarded – undo
978 978
 }
979 979
 
980 980
 function wpinv_descriptive_text_callback( $args ) {
981
-	echo wp_kses_post( $args['desc'] );
981
+    echo wp_kses_post( $args['desc'] );
982 982
 }
983 983
 
984 984
 function wpinv_raw_html_callback( $args ) {
985
-	echo $args['desc'];
985
+    echo $args['desc'];
986 986
 }
987 987
 
988 988
 function wpinv_hook_callback( $args ) {
989
-	do_action( 'wpinv_' . $args['id'], $args );
989
+    do_action( 'wpinv_' . $args['id'], $args );
990 990
 }
991 991
 
992 992
 function wpinv_set_settings_cap() {
993
-	return wpinv_get_capability();
993
+    return wpinv_get_capability();
994 994
 }
995 995
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
996 996
 
Please login to merge, or discard this patch.
Spacing   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( ! is_array( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (!is_array($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,47 +190,47 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name    = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name    = isset($option['name']) ? $option['name'] : '';
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = wpinv_clean( $option['desc'] );
199
+	if (isset($option['desc']) && !empty($option['help-tip'])) {
200
+		$tip   = wpinv_clean($option['desc']);
201 201
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
202
+		unset($option['desc']);
203 203
 	}
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
207 207
         'wpinv_settings[' . $option['id'] . ']',
208 208
         $name,
209
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
209
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
210 210
         $section,
211 211
         $section,
212 212
         array(
213 213
             'section'     => $section,
214
-            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
215
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
214
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
215
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
216 216
             'name'        => $name,
217
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
218
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
219
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
220
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
221
-            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
222
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
223
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
224
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
225
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
226
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
227
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
228
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
229
-            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
230
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
231
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
232
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
217
+            'size'        => isset($option['size']) ? $option['size'] : null,
218
+            'options'     => isset($option['options']) ? $option['options'] : '',
219
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
220
+            'std'         => isset($option['std']) ? $option['std'] : '',
221
+            'min'         => isset($option['min']) ? $option['min'] : 0,
222
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
223
+            'step'        => isset($option['step']) ? $option['step'] : 1,
224
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
225
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
226
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
227
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
228
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
229
+            'custom'      => isset($option['custom']) ? $option['custom'] : '',
230
+			'class'       => isset($option['class']) ? $option['class'] : '',
231
+			'style'       => isset($option['style']) ? $option['style'] : '',
232
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
233
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
234 234
         )
235 235
     );
236 236
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
  * @return array
243 243
  */
244 244
 function wpinv_get_registered_settings() {
245
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
245
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
246 246
 }
247 247
 
248 248
 /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
  * @return array
252 252
  */
253 253
 function getpaid_get_integration_settings() {
254
-    return apply_filters( 'getpaid_integration_settings', array() );
254
+    return apply_filters('getpaid_integration_settings', array());
255 255
 }
256 256
 
257 257
 /**
@@ -259,139 +259,139 @@  discard block
 block discarded – undo
259 259
  * 
260 260
  * @return array
261 261
  */
262
-function wpinv_settings_sanitize( $input = array() ) {
262
+function wpinv_settings_sanitize($input = array()) {
263 263
 
264 264
     $wpinv_options = wpinv_get_options();
265 265
 
266
-    if ( empty( wp_get_raw_referer() ) ) {
266
+    if (empty(wp_get_raw_referer())) {
267 267
         return $input;
268 268
     }
269 269
 
270
-    wp_parse_str( wp_get_raw_referer(), $referrer );
270
+    wp_parse_str(wp_get_raw_referer(), $referrer);
271 271
 
272 272
     $settings = wpinv_get_registered_settings();
273
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
274
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
273
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
274
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
275 275
 
276 276
     $input = $input ? $input : array();
277
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
278
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
277
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
278
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
279 279
 
280 280
     // Loop through each setting being saved and pass it through a sanitization filter
281
-    foreach ( $input as $key => $value ) {
281
+    foreach ($input as $key => $value) {
282 282
 
283 283
         // Get the setting type (checkbox, select, etc)
284
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
284
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
285 285
 
286
-        if ( $type ) {
286
+        if ($type) {
287 287
             // Field type specific filter
288
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
288
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
289 289
         }
290 290
 
291 291
         // General filter
292
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
292
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
293 293
 
294 294
 		// Key specific filter.
295
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
295
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
296 296
     }
297 297
 
298 298
     // Loop through the whitelist and unset any that are empty for the tab being saved
299
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
300
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
299
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
300
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
301 301
 
302
-    $found_settings = array_merge( $main_settings, $section_settings );
302
+    $found_settings = array_merge($main_settings, $section_settings);
303 303
 
304
-    if ( ! empty( $found_settings ) ) {
305
-        foreach ( $found_settings as $key => $value ) {
304
+    if (!empty($found_settings)) {
305
+        foreach ($found_settings as $key => $value) {
306 306
 
307 307
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
308
-            if ( is_numeric( $key ) ) {
308
+            if (is_numeric($key)) {
309 309
                 $key = $value['id'];
310 310
             }
311 311
 
312
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
313
-                unset( $wpinv_options[ $key ] );
312
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
313
+                unset($wpinv_options[$key]);
314 314
             }
315 315
         }
316 316
     }
317 317
 
318 318
     // Merge our new settings with the existing
319
-    $output = array_merge( $wpinv_options, $input );
319
+    $output = array_merge($wpinv_options, $input);
320 320
 
321
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
321
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
322 322
 
323 323
     return $output;
324 324
 }
325 325
 
326
-function wpinv_settings_sanitize_misc_accounting( $input ) {
326
+function wpinv_settings_sanitize_misc_accounting($input) {
327 327
 
328
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
328
+    if (!wpinv_current_user_can_manage_invoicing()) {
329 329
         return $input;
330 330
     }
331 331
 
332
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
332
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
333 333
         // Shows an admin notice about upgrading previous order numbers
334
-        getpaid_session()->set( 'upgrade_sequential', '1' );
334
+        getpaid_session()->set('upgrade_sequential', '1');
335 335
     }
336 336
 
337 337
     return $input;
338 338
 }
339
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
339
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
340 340
 
341
-function wpinv_settings_sanitize_tax_rates( $input ) {
342
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
341
+function wpinv_settings_sanitize_tax_rates($input) {
342
+    if (!wpinv_current_user_can_manage_invoicing()) {
343 343
         return $input;
344 344
     }
345 345
 
346
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
346
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
347 347
     $tax_rates = array();
348 348
 
349
-    foreach ( $new_rates as $rate ) {
349
+    foreach ($new_rates as $rate) {
350 350
 
351
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
352
-		$rate['name']    = sanitize_text_field( $rate['name'] );
353
-		$rate['state']   = sanitize_text_field( $rate['state'] );
354
-		$rate['country'] = sanitize_text_field( $rate['country'] );
355
-		$rate['global']  = empty( $rate['state'] );
351
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
352
+		$rate['name']    = sanitize_text_field($rate['name']);
353
+		$rate['state']   = sanitize_text_field($rate['state']);
354
+		$rate['country'] = sanitize_text_field($rate['country']);
355
+		$rate['global']  = empty($rate['state']);
356 356
 		$tax_rates[]     = $rate;
357 357
 
358 358
 	}
359 359
 
360
-    update_option( 'wpinv_tax_rates', $tax_rates );
360
+    update_option('wpinv_tax_rates', $tax_rates);
361 361
 
362 362
     return $input;
363 363
 }
364
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
364
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
365 365
 
366
-function wpinv_sanitize_text_field( $input ) {
367
-    return trim( $input );
366
+function wpinv_sanitize_text_field($input) {
367
+    return trim($input);
368 368
 }
369
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
369
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
370 370
 
371 371
 function wpinv_get_settings_tabs() {
372 372
     $tabs             = array();
373
-    $tabs['general']  = __( 'General', 'invoicing' );
374
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
375
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
376
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
373
+    $tabs['general']  = __('General', 'invoicing');
374
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
375
+    $tabs['taxes']    = __('Taxes', 'invoicing');
376
+	$tabs['emails'] = __('Emails', 'invoicing');
377 377
 
378
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
379
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
378
+	if (count(getpaid_get_integration_settings()) > 0) {
379
+		$tabs['integrations'] = __('Integrations', 'invoicing');
380 380
 	}
381 381
 
382
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
383
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
384
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
382
+    $tabs['privacy']  = __('Privacy', 'invoicing');
383
+    $tabs['misc']     = __('Misc', 'invoicing');
384
+    $tabs['tools']    = __('Tools', 'invoicing');
385 385
 
386
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
386
+    return apply_filters('wpinv_settings_tabs', $tabs);
387 387
 }
388 388
 
389
-function wpinv_get_settings_tab_sections( $tab = false ) {
389
+function wpinv_get_settings_tab_sections($tab = false) {
390 390
     $tabs     = false;
391 391
     $sections = wpinv_get_registered_settings_sections();
392 392
 
393
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
394
-        $tabs = $sections[ $tab ];
393
+    if ($tab && !empty($sections[$tab])) {
394
+        $tabs = $sections[$tab];
395 395
     }
396 396
 
397 397
     return $tabs;
@@ -400,91 +400,91 @@  discard block
 block discarded – undo
400 400
 function wpinv_get_registered_settings_sections() {
401 401
     static $sections = false;
402 402
 
403
-    if ( false !== $sections ) {
403
+    if (false !== $sections) {
404 404
         return $sections;
405 405
     }
406 406
 
407 407
     $sections = array(
408
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
409
-            'main' => __( 'General Settings', 'invoicing' ),
410
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
411
-            'labels' => __( 'Label Texts', 'invoicing' ),
412
-        ) ),
413
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
414
-            'main' => __( 'Gateway Settings', 'invoicing' ),
415
-        ) ),
416
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
417
-            'main'  => __( 'Tax Settings', 'invoicing' ),
418
-			'rates' => __( 'Tax Rates', 'invoicing' ),
419
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
420
-        ) ),
421
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
422
-            'main' => __( 'Email Settings', 'invoicing' ),
423
-		) ),
424
-
425
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
426
-
427
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
428
-            'main' => __( 'Privacy policy', 'invoicing' ),
429
-        ) ),
430
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
431
-            'main' => __( 'Miscellaneous', 'invoicing' ),
432
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
433
-        ) ),
434
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
435
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
436
-        ) ),
408
+        'general' => apply_filters('wpinv_settings_sections_general', array(
409
+            'main' => __('General Settings', 'invoicing'),
410
+            'currency_section' => __('Currency Settings', 'invoicing'),
411
+            'labels' => __('Label Texts', 'invoicing'),
412
+        )),
413
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
414
+            'main' => __('Gateway Settings', 'invoicing'),
415
+        )),
416
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
417
+            'main'  => __('Tax Settings', 'invoicing'),
418
+			'rates' => __('Tax Rates', 'invoicing'),
419
+			'vat'   => __('EU VAT Settings', 'invoicing')
420
+        )),
421
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
422
+            'main' => __('Email Settings', 'invoicing'),
423
+		)),
424
+
425
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
426
+
427
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
428
+            'main' => __('Privacy policy', 'invoicing'),
429
+        )),
430
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
431
+            'main' => __('Miscellaneous', 'invoicing'),
432
+            'custom-css' => __('Custom CSS', 'invoicing'),
433
+        )),
434
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
435
+            'main' => __('Diagnostic Tools', 'invoicing'),
436
+        )),
437 437
     );
438 438
 
439
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
439
+    $sections = apply_filters('wpinv_settings_sections', $sections);
440 440
 
441 441
     return $sections;
442 442
 }
443 443
 
444
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
444
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
445 445
 	$pages_options = array();
446 446
 
447
-	if( $default_label !== NULL && $default_label !== false ) {
448
-		$pages_options = array( '' => $default_label ); // Blank option
447
+	if ($default_label !== NULL && $default_label !== false) {
448
+		$pages_options = array('' => $default_label); // Blank option
449 449
 	}
450 450
 
451 451
 	$pages = get_pages();
452
-	if ( $pages ) {
453
-		foreach ( $pages as $page ) {
452
+	if ($pages) {
453
+		foreach ($pages as $page) {
454 454
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
455
-            $pages_options[ $page->ID ] = $title;
455
+            $pages_options[$page->ID] = $title;
456 456
 		}
457 457
 	}
458 458
 
459 459
 	return $pages_options;
460 460
 }
461 461
 
462
-function wpinv_header_callback( $args ) {
463
-	if ( !empty( $args['desc'] ) ) {
462
+function wpinv_header_callback($args) {
463
+	if (!empty($args['desc'])) {
464 464
         echo $args['desc'];
465 465
     }
466 466
 }
467 467
 
468
-function wpinv_hidden_callback( $args ) {
468
+function wpinv_hidden_callback($args) {
469 469
 	global $wpinv_options;
470 470
 
471
-	if ( isset( $args['set_value'] ) ) {
471
+	if (isset($args['set_value'])) {
472 472
 		$value = $args['set_value'];
473
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
474
-		$value = $wpinv_options[ $args['id'] ];
473
+	} elseif (isset($wpinv_options[$args['id']])) {
474
+		$value = $wpinv_options[$args['id']];
475 475
 	} else {
476
-		$value = isset( $args['std'] ) ? $args['std'] : '';
476
+		$value = isset($args['std']) ? $args['std'] : '';
477 477
 	}
478 478
 
479
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
479
+	if (isset($args['faux']) && true === $args['faux']) {
480 480
 		$args['readonly'] = true;
481
-		$value = isset( $args['std'] ) ? $args['std'] : '';
481
+		$value = isset($args['std']) ? $args['std'] : '';
482 482
 		$name  = '';
483 483
 	} else {
484
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
484
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
485 485
 	}
486 486
 
487
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
487
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
488 488
     
489 489
 	echo $html;
490 490
 }
@@ -492,61 +492,61 @@  discard block
 block discarded – undo
492 492
 /**
493 493
  * Displays a checkbox settings callback.
494 494
  */
495
-function wpinv_checkbox_callback( $args ) {
495
+function wpinv_checkbox_callback($args) {
496 496
 
497
-	$std = isset( $args['std'] ) ? $args['std'] : '';
498
-	$std = wpinv_get_option( $args['id'], $std );
499
-	$id  = esc_attr( $args['id'] );
497
+	$std = isset($args['std']) ? $args['std'] : '';
498
+	$std = wpinv_get_option($args['id'], $std);
499
+	$id  = esc_attr($args['id']);
500 500
 
501
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
501
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
502 502
 	?>
503 503
 		<fieldset>
504 504
 			<label>
505
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
506
-				<?php echo wp_kses_post( $args['desc'] ); ?>
505
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
506
+				<?php echo wp_kses_post($args['desc']); ?>
507 507
 			</label>
508 508
 		</fieldset>
509 509
 	<?php
510 510
 }
511 511
 
512
-function wpinv_multicheck_callback( $args ) {
512
+function wpinv_multicheck_callback($args) {
513 513
 	
514 514
 	global $wpinv_options;
515 515
 
516
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
517
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
516
+	$sanitize_id = wpinv_sanitize_key($args['id']);
517
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
518 518
 
519
-	if ( ! empty( $args['options'] ) ) {
519
+	if (!empty($args['options'])) {
520 520
 
521
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
522
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
521
+		$std     = isset($args['std']) ? $args['std'] : array();
522
+		$value   = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std;
523 523
 
524 524
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
525
-        foreach( $args['options'] as $key => $option ):
526
-			$sanitize_key = wpinv_sanitize_key( $key );
527
-			if ( in_array( $sanitize_key, $value ) ) { 
525
+        foreach ($args['options'] as $key => $option):
526
+			$sanitize_key = wpinv_sanitize_key($key);
527
+			if (in_array($sanitize_key, $value)) { 
528 528
 				$enabled = $sanitize_key;
529 529
 			} else { 
530 530
 				$enabled = NULL; 
531 531
 			}
532
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
533
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
532
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
533
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
534 534
 		endforeach;
535 535
 		echo '</div>';
536 536
 		echo '<p class="description">' . $args['desc'] . '</p>';
537 537
 	}
538 538
 }
539 539
 
540
-function wpinv_payment_icons_callback( $args ) {
540
+function wpinv_payment_icons_callback($args) {
541 541
 	global $wpinv_options;
542 542
     
543
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
543
+    $sanitize_id = wpinv_sanitize_key($args['id']);
544 544
 
545
-	if ( ! empty( $args['options'] ) ) {
546
-		foreach( $args['options'] as $key => $option ) {
547
-            $sanitize_key = wpinv_sanitize_key( $key );
545
+	if (!empty($args['options'])) {
546
+		foreach ($args['options'] as $key => $option) {
547
+            $sanitize_key = wpinv_sanitize_key($key);
548 548
             
549
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
549
+			if (isset($wpinv_options[$args['id']][$key])) {
550 550
 				$enabled = $option;
551 551
 			} else {
552 552
 				$enabled = NULL;
@@ -554,109 +554,109 @@  discard block
 block discarded – undo
554 554
 
555 555
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
556 556
 
557
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
557
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
558 558
 
559
-				if ( wpinv_string_is_image_url( $key ) ) {
560
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
559
+				if (wpinv_string_is_image_url($key)) {
560
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561 561
 				} else {
562
-					$card = strtolower( str_replace( ' ', '', $option ) );
562
+					$card = strtolower(str_replace(' ', '', $option));
563 563
 
564
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
565
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
564
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
565
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
566 566
 					} else {
567
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
567
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
568 568
 						$content_dir = WP_CONTENT_DIR;
569 569
 
570
-						if ( function_exists( 'wp_normalize_path' ) ) {
570
+						if (function_exists('wp_normalize_path')) {
571 571
 							// Replaces backslashes with forward slashes for Windows systems
572
-							$image = wp_normalize_path( $image );
573
-							$content_dir = wp_normalize_path( $content_dir );
572
+							$image = wp_normalize_path($image);
573
+							$content_dir = wp_normalize_path($content_dir);
574 574
 						}
575 575
 
576
-						$image = str_replace( $content_dir, content_url(), $image );
576
+						$image = str_replace($content_dir, content_url(), $image);
577 577
 					}
578 578
 
579
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
579
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
580 580
 				}
581 581
 			echo $option . '</label>';
582 582
 		}
583
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
583
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
584 584
 	}
585 585
 }
586 586
 
587 587
 /**
588 588
  * Displays a radio settings field.
589 589
  */
590
-function wpinv_radio_callback( $args ) {
590
+function wpinv_radio_callback($args) {
591 591
 
592
-	$std = isset( $args['std'] ) ? $args['std'] : '';
593
-	$std = wpinv_get_option( $args['id'], $std );
592
+	$std = isset($args['std']) ? $args['std'] : '';
593
+	$std = wpinv_get_option($args['id'], $std);
594 594
 	?>
595 595
 		<fieldset>
596
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
597
-				<?php foreach( $args['options'] as $key => $option ) : ?>
596
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
597
+				<?php foreach ($args['options'] as $key => $option) : ?>
598 598
 					<li>
599 599
 						<label>
600
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
601
-							<?php echo wp_kses_post( $option ); ?>
600
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
601
+							<?php echo wp_kses_post($option); ?>
602 602
 						</label>
603 603
 					</li>
604 604
 				<?php endforeach; ?>
605 605
 			</ul>
606 606
 		</fieldset>
607 607
 	<?php
608
-	getpaid_settings_description_callback( $args );
608
+	getpaid_settings_description_callback($args);
609 609
 }
610 610
 
611 611
 /**
612 612
  * Displays a description if available.
613 613
  */
614
-function getpaid_settings_description_callback( $args ) {
614
+function getpaid_settings_description_callback($args) {
615 615
 
616
-	if ( ! empty( $args['desc'] ) ) {
617
-		$description = wp_kses_post( $args['desc'] );
616
+	if (!empty($args['desc'])) {
617
+		$description = wp_kses_post($args['desc']);
618 618
 		echo "<p class='description'>$description</p>";
619 619
 	}
620 620
 
621 621
 }
622 622
 
623
-function wpinv_gateways_callback( $args ) {
623
+function wpinv_gateways_callback($args) {
624 624
 
625
-	$gateways    = wpinv_get_option( 'gateways', array( 'manual' => 1 ) );
626
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
625
+	$gateways = wpinv_get_option('gateways', array('manual' => 1));
626
+    $sanitize_id = wpinv_sanitize_key($args['id']);
627 627
 
628
-	foreach ( $args['options'] as $key => $option ) :
629
-		$sanitize_key = wpinv_sanitize_key( $key );
628
+	foreach ($args['options'] as $key => $option) :
629
+		$sanitize_key = wpinv_sanitize_key($key);
630 630
         
631
-        if ( is_array( $gateways ) && isset( $gateways[ $key ] ) )
631
+        if (is_array($gateways) && isset($gateways[$key]))
632 632
 			$enabled = '1';
633 633
 		else
634 634
 			$enabled = null;
635 635
 
636
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
636
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
638 638
 	endforeach;
639 639
 }
640 640
 
641 641
 function wpinv_gateway_select_callback($args) {
642 642
 	global $wpinv_options;
643 643
     
644
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
645
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
644
+    $sanitize_id = wpinv_sanitize_key($args['id']);
645
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
646 646
 
647
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
647
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
648 648
 
649
-	foreach ( $args['options'] as $key => $option ) :
650
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
651
-            $selected = selected( $key, $args['selected'], false );
649
+	foreach ($args['options'] as $key => $option) :
650
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
651
+            $selected = selected($key, $args['selected'], false);
652 652
         } else {
653
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
653
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
654 654
         }
655
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
655
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
656 656
 	endforeach;
657 657
 
658 658
 	echo '</select>';
659
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
659
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
660 660
 }
661 661
 
662 662
 /**
@@ -665,28 +665,28 @@  discard block
 block discarded – undo
665 665
  * @param array $args
666 666
  * @return string
667 667
  */
668
-function wpinv_settings_attrs_helper( $args ) {
668
+function wpinv_settings_attrs_helper($args) {
669 669
 
670
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
671
-	$id           = esc_attr( $args['id'] );
672
-	$placeholder  = esc_attr( $args['placeholder'] );
670
+	$value        = isset($args['std']) ? $args['std'] : '';
671
+	$id           = esc_attr($args['id']);
672
+	$placeholder  = esc_attr($args['placeholder']);
673 673
 
674
-	if ( ! empty( $args['faux'] ) ) {
674
+	if (!empty($args['faux'])) {
675 675
 		$args['readonly'] = true;
676 676
 		$name             = '';
677 677
 	} else {
678
-		$value  = wpinv_get_option( $args['id'], $value );
678
+		$value  = wpinv_get_option($args['id'], $value);
679 679
 		$name   = "wpinv_settings[$id]";
680 680
 	}
681 681
 
682
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
683
-	$class    = esc_attr( $args['class'] );
684
-	$style    = esc_attr( $args['style'] );
685
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
682
+	$value    = is_scalar($value) ? esc_attr($value) : '';
683
+	$class    = esc_attr($args['class']);
684
+	$style    = esc_attr($args['style']);
685
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
686 686
 
687 687
 	$onchange = '';
688
-    if ( ! empty( $args['onchange'] ) ) {
689
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
688
+    if (!empty($args['onchange'])) {
689
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
690 690
 	}
691 691
 
692 692
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 /**
696 696
  * Displays a text input settings callback.
697 697
  */
698
-function wpinv_text_callback( $args ) {
698
+function wpinv_text_callback($args) {
699 699
 
700
-	$desc = wp_kses_post( $args['desc'] );
701
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
702
-	$attr = wpinv_settings_attrs_helper( $args );
700
+	$desc = wp_kses_post($args['desc']);
701
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
702
+	$attr = wpinv_settings_attrs_helper($args);
703 703
 
704 704
 	?>
705 705
 		<label style="width: 100%;">
@@ -713,14 +713,14 @@  discard block
 block discarded – undo
713 713
 /**
714 714
  * Displays a number input settings callback.
715 715
  */
716
-function wpinv_number_callback( $args ) {
716
+function wpinv_number_callback($args) {
717 717
 
718
-	$desc = wp_kses_post( $args['desc'] );
719
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
720
-	$attr = wpinv_settings_attrs_helper( $args );
721
-	$max  = intval( $args['max'] );
722
-	$min  = intval( $args['min'] );
723
-	$step = floatval( $args['step'] );
718
+	$desc = wp_kses_post($args['desc']);
719
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
720
+	$attr = wpinv_settings_attrs_helper($args);
721
+	$max  = intval($args['max']);
722
+	$min  = intval($args['min']);
723
+	$step = floatval($args['step']);
724 724
 
725 725
 	?>
726 726
 		<label style="width: 100%;">
@@ -731,47 +731,47 @@  discard block
 block discarded – undo
731 731
 
732 732
 }
733 733
 
734
-function wpinv_textarea_callback( $args ) {
734
+function wpinv_textarea_callback($args) {
735 735
 	global $wpinv_options;
736 736
     
737
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
737
+    $sanitize_id = wpinv_sanitize_key($args['id']);
738 738
 
739
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
740
-		$value = $wpinv_options[ $args['id'] ];
739
+	if (isset($wpinv_options[$args['id']])) {
740
+		$value = $wpinv_options[$args['id']];
741 741
 	} else {
742
-		$value = isset( $args['std'] ) ? $args['std'] : '';
742
+		$value = isset($args['std']) ? $args['std'] : '';
743 743
 	}
744 744
     
745
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
746
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
745
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
746
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
747 747
 
748
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
749
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
748
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
749
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
750 750
 
751 751
 	echo $html;
752 752
 }
753 753
 
754
-function wpinv_password_callback( $args ) {
754
+function wpinv_password_callback($args) {
755 755
 	global $wpinv_options;
756 756
     
757
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
757
+    $sanitize_id = wpinv_sanitize_key($args['id']);
758 758
 
759
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
760
-		$value = $wpinv_options[ $args['id'] ];
759
+	if (isset($wpinv_options[$args['id']])) {
760
+		$value = $wpinv_options[$args['id']];
761 761
 	} else {
762
-		$value = isset( $args['std'] ) ? $args['std'] : '';
762
+		$value = isset($args['std']) ? $args['std'] : '';
763 763
 	}
764 764
 
765
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
766
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
767
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
765
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
766
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
767
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
768 768
 
769 769
 	echo $html;
770 770
 }
771 771
 
772 772
 function wpinv_missing_callback($args) {
773 773
 	printf(
774
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
774
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
775 775
 		'<strong>' . $args['id'] . '</strong>'
776 776
 	);
777 777
 }
@@ -779,20 +779,20 @@  discard block
 block discarded – undo
779 779
 /**
780 780
  * Displays a number input settings callback.
781 781
  */
782
-function wpinv_select_callback( $args ) {
782
+function wpinv_select_callback($args) {
783 783
 
784
-	$desc   = wp_kses_post( $args['desc'] );
785
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
786
-	$attr   = wpinv_settings_attrs_helper( $args );
787
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
788
-	$value  = wpinv_get_option( $args['id'], $value );
784
+	$desc   = wp_kses_post($args['desc']);
785
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
786
+	$attr   = wpinv_settings_attrs_helper($args);
787
+	$value  = isset($args['std']) ? $args['std'] : '';
788
+	$value  = wpinv_get_option($args['id'], $value);
789 789
 
790 790
 	?>
791 791
 		<label style="width: 100%;">
792 792
 			<select <?php echo $attr; ?>>
793
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
794
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( is_array( $value ) ? in_array( "$option", $value, true ) : "$option" === $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
795
-				<?php endforeach;?>
793
+				<?php foreach ($args['options'] as $option => $name) : ?>
794
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected(is_array($value) ? in_array("$option", $value, true) : "$option" === $value); ?>><?php echo wpinv_clean($name); ?></option>
795
+				<?php endforeach; ?>
796 796
 			</select>
797 797
 			<?php echo $desc; ?>
798 798
 		</label>
@@ -800,95 +800,95 @@  discard block
 block discarded – undo
800 800
 
801 801
 }
802 802
 
803
-function wpinv_color_select_callback( $args ) {
803
+function wpinv_color_select_callback($args) {
804 804
 	global $wpinv_options;
805 805
     
806
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
806
+    $sanitize_id = wpinv_sanitize_key($args['id']);
807 807
 
808
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
809
-		$value = $wpinv_options[ $args['id'] ];
808
+	if (isset($wpinv_options[$args['id']])) {
809
+		$value = $wpinv_options[$args['id']];
810 810
 	} else {
811
-		$value = isset( $args['std'] ) ? $args['std'] : '';
811
+		$value = isset($args['std']) ? $args['std'] : '';
812 812
 	}
813 813
 
814
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
814
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
815 815
 
816
-	foreach ( $args['options'] as $option => $color ) {
817
-		$selected = selected( $option, $value, false );
818
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
816
+	foreach ($args['options'] as $option => $color) {
817
+		$selected = selected($option, $value, false);
818
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
819 819
 	}
820 820
 
821 821
 	$html .= '</select>';
822
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
822
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
823 823
 
824 824
 	echo $html;
825 825
 }
826 826
 
827
-function wpinv_rich_editor_callback( $args ) {
827
+function wpinv_rich_editor_callback($args) {
828 828
 	global $wpinv_options, $wp_version;
829 829
     
830
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
830
+    $sanitize_id = wpinv_sanitize_key($args['id']);
831 831
 
832
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
833
-		$value = $wpinv_options[ $args['id'] ];
832
+	if (isset($wpinv_options[$args['id']])) {
833
+		$value = $wpinv_options[$args['id']];
834 834
 
835
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
836
-			$value = isset( $args['std'] ) ? $args['std'] : '';
835
+		if (empty($args['allow_blank']) && empty($value)) {
836
+			$value = isset($args['std']) ? $args['std'] : '';
837 837
 		}
838 838
 	} else {
839
-		$value = isset( $args['std'] ) ? $args['std'] : '';
839
+		$value = isset($args['std']) ? $args['std'] : '';
840 840
 	}
841 841
 
842
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
842
+	$rows = isset($args['size']) ? $args['size'] : 20;
843 843
 
844 844
 	$html = '<div class="getpaid-settings-editor-input">';
845
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
845
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
846 846
 		ob_start();
847
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
847
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
848 848
 		$html .= ob_get_clean();
849 849
 	} else {
850
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
850
+		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
851 851
 	}
852 852
 
853
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
853
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
854 854
 
855 855
 	echo $html;
856 856
 }
857 857
 
858
-function wpinv_upload_callback( $args ) {
858
+function wpinv_upload_callback($args) {
859 859
 	global $wpinv_options;
860 860
     
861
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
861
+    $sanitize_id = wpinv_sanitize_key($args['id']);
862 862
 
863
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
863
+	if (isset($wpinv_options[$args['id']])) {
864 864
 		$value = $wpinv_options[$args['id']];
865 865
 	} else {
866 866
 		$value = isset($args['std']) ? $args['std'] : '';
867 867
 	}
868 868
 
869
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
870
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
871
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
872
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
869
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
870
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
871
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
872
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
873 873
 
874 874
 	echo $html;
875 875
 }
876 876
 
877
-function wpinv_color_callback( $args ) {
877
+function wpinv_color_callback($args) {
878 878
 	global $wpinv_options;
879 879
     
880
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
880
+    $sanitize_id = wpinv_sanitize_key($args['id']);
881 881
 
882
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
883
-		$value = $wpinv_options[ $args['id'] ];
882
+	if (isset($wpinv_options[$args['id']])) {
883
+		$value = $wpinv_options[$args['id']];
884 884
 	} else {
885
-		$value = isset( $args['std'] ) ? $args['std'] : '';
885
+		$value = isset($args['std']) ? $args['std'] : '';
886 886
 	}
887 887
 
888
-	$default = isset( $args['std'] ) ? $args['std'] : '';
888
+	$default = isset($args['std']) ? $args['std'] : '';
889 889
 
890
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
891
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
890
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />';
891
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
892 892
 
893 893
 	echo $html;
894 894
 }
@@ -896,9 +896,9 @@  discard block
 block discarded – undo
896 896
 function wpinv_country_states_callback($args) {
897 897
 	global $wpinv_options;
898 898
     
899
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
899
+    $sanitize_id = wpinv_sanitize_key($args['id']);
900 900
 
901
-	if ( isset( $args['placeholder'] ) ) {
901
+	if (isset($args['placeholder'])) {
902 902
 		$placeholder = $args['placeholder'];
903 903
 	} else {
904 904
 		$placeholder = '';
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 
907 907
 	$states = wpinv_get_country_states();
908 908
 
909
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
909
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
910
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
911 911
 
912
-	foreach ( $states as $option => $name ) {
913
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
914
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
912
+	foreach ($states as $option => $name) {
913
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
914
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
915 915
 	}
916 916
 
917 917
 	$html .= '</select>';
918
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
918
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
919 919
 
920 920
 	echo $html;
921 921
 }
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 	</tr>
931 931
 	<tr class="bsui">
932 932
     	<td colspan="2" class="p-0">
933
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
933
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
934 934
 
935 935
 	<?php
936 936
 
@@ -939,14 +939,14 @@  discard block
 block discarded – undo
939 939
 /**
940 940
  * Displays a tax rate' edit row.
941 941
  */
942
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
942
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
943 943
 	ob_start();
944 944
 
945
-	$key                      = sanitize_key( $key );
946
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
947
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
945
+	$key                      = sanitize_key($key);
946
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
947
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
948 948
 
949
-	if ( $echo ) {
949
+	if ($echo) {
950 950
 		echo ob_get_clean();
951 951
 	} else {
952 952
 		return ob_get_clean(); 
@@ -958,81 +958,81 @@  discard block
 block discarded – undo
958 958
     ob_start(); ?>
959 959
     </td><tr>
960 960
     <td colspan="2" class="wpinv_tools_tdbox">
961
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
962
-    <?php do_action( 'wpinv_tools_before' ); ?>
961
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
962
+    <?php do_action('wpinv_tools_before'); ?>
963 963
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
964 964
         <thead>
965 965
             <tr>
966
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
967
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
968
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
966
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
967
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
968
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
969 969
             </tr>
970 970
         </thead>
971
-            <?php do_action( 'wpinv_tools_row' ); ?>
971
+            <?php do_action('wpinv_tools_row'); ?>
972 972
         <tbody>
973 973
         </tbody>
974 974
     </table>
975
-    <?php do_action( 'wpinv_tools_after' ); ?>
975
+    <?php do_action('wpinv_tools_after'); ?>
976 976
     <?php
977 977
     echo ob_get_clean();
978 978
 }
979 979
 
980
-function wpinv_descriptive_text_callback( $args ) {
981
-	echo wp_kses_post( $args['desc'] );
980
+function wpinv_descriptive_text_callback($args) {
981
+	echo wp_kses_post($args['desc']);
982 982
 }
983 983
 
984
-function wpinv_raw_html_callback( $args ) {
984
+function wpinv_raw_html_callback($args) {
985 985
 	echo $args['desc'];
986 986
 }
987 987
 
988
-function wpinv_hook_callback( $args ) {
989
-	do_action( 'wpinv_' . $args['id'], $args );
988
+function wpinv_hook_callback($args) {
989
+	do_action('wpinv_' . $args['id'], $args);
990 990
 }
991 991
 
992 992
 function wpinv_set_settings_cap() {
993 993
 	return wpinv_get_capability();
994 994
 }
995
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
995
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
996 996
 
997
-function wpinv_settings_sanitize_input( $value, $key ) {
997
+function wpinv_settings_sanitize_input($value, $key) {
998 998
 
999
-    if ( $key == 'tax_rate' ) {
1000
-        $value = wpinv_sanitize_amount( $value );
999
+    if ($key == 'tax_rate') {
1000
+        $value = wpinv_sanitize_amount($value);
1001 1001
         $value = $value >= 100 ? 99 : $value;
1002 1002
     }
1003 1003
 
1004 1004
     return $value;
1005 1005
 }
1006
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1006
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1007 1007
 
1008
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1009
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1010
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1008
+function wpinv_on_update_settings($old_value, $value, $option) {
1009
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1010
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1011 1011
     
1012
-    if ( $old != $new ) {
1013
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1012
+    if ($old != $new) {
1013
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1014 1014
     }
1015 1015
 }
1016
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1017
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1018
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1019
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1020
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1021
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1022
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1023
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1024
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1025
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1026
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1027
-
1028
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1016
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1017
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1018
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1019
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1020
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1021
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1022
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1023
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1024
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1025
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1026
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1027
+
1028
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1029 1029
     ?>
1030 1030
     <div class="wpinv-email-wc-row ">
1031 1031
         <div class="wpinv-email-wc-td">
1032
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1032
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1033 1033
             <p class="wpinv-email-wc-description">
1034 1034
                 <?php
1035
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1035
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1036 1036
                     <strong>{site_title} :</strong> Site Title<br>
1037 1037
                     <strong>{name} :</strong> Customer\'s full name<br>
1038 1038
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1047 1047
                     <strong>{date} :</strong> Today\'s date.<br>
1048 1048
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1049
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1049
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1050 1050
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1051 1051
                 ?>
1052 1052
             </p>
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -628,10 +628,11 @@
 block discarded – undo
628 628
 	foreach ( $args['options'] as $key => $option ) :
629 629
 		$sanitize_key = wpinv_sanitize_key( $key );
630 630
         
631
-        if ( is_array( $gateways ) && isset( $gateways[ $key ] ) )
632
-			$enabled = '1';
633
-		else
634
-			$enabled = null;
631
+        if ( is_array( $gateways ) && isset( $gateways[ $key ] ) ) {
632
+        			$enabled = '1';
633
+        } else {
634
+					$enabled = null;
635
+		}
635 636
 
636 637
 		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
637 638
 		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Please use GetPaid_Notification_Email_Sender
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /*
12 12
 |--------------------------------------------------------------------------
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Generates the email header.
19 19
  */
20
-function wpinv_email_header( $email_heading ) {
21
-    wpinv_get_template( 'emails/wpinv-email-header.php', compact( 'email_heading' ) );
20
+function wpinv_email_header($email_heading) {
21
+    wpinv_get_template('emails/wpinv-email-header.php', compact('email_heading'));
22 22
 }
23
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
23
+add_action('wpinv_email_header', 'wpinv_email_header');
24 24
 
25 25
 
26 26
 /**
27 27
  * Generates the email footer.
28 28
  */
29 29
 function wpinv_email_footer() {
30
-    wpinv_get_template( 'emails/wpinv-email-footer.php' );
30
+    wpinv_get_template('emails/wpinv-email-footer.php');
31 31
 }
32
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
32
+add_action('wpinv_email_footer', 'wpinv_email_footer');
33 33
 
34 34
 
35 35
 /**
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
  * @param string $email_type
40 40
  * @param bool $sent_to_admin
41 41
  */
42
-function wpinv_email_invoice_details( $invoice,  $email_type, $sent_to_admin ) {
42
+function wpinv_email_invoice_details($invoice, $email_type, $sent_to_admin) {
43 43
 
44
-    $args = compact( 'invoice', 'email_type', 'sent_to_admin' );
45
-    wpinv_get_template( 'emails/invoice-details.php', $args );
44
+    $args = compact('invoice', 'email_type', 'sent_to_admin');
45
+    wpinv_get_template('emails/invoice-details.php', $args);
46 46
 
47 47
 }
48
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
48
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
49 49
 
50 50
 /**
51 51
  * Display line items in emails.
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
  * @param string $email_type
55 55
  * @param bool $sent_to_admin
56 56
  */
57
-function wpinv_email_invoice_items( $invoice, $email_type, $sent_to_admin ) {
57
+function wpinv_email_invoice_items($invoice, $email_type, $sent_to_admin) {
58 58
 
59 59
     // Prepare line items.
60
-    $columns = getpaid_invoice_item_columns( $invoice );
61
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
60
+    $columns = getpaid_invoice_item_columns($invoice);
61
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
62 62
 
63 63
     // Load the template.
64
-    wpinv_get_template( 'emails/invoice-items.php', compact( 'invoice', 'columns', 'email_type', 'sent_to_admin' ) );
64
+    wpinv_get_template('emails/invoice-items.php', compact('invoice', 'columns', 'email_type', 'sent_to_admin'));
65 65
 
66 66
 }
67
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
67
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
68 68
 
69 69
 
70 70
 /**
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
  * @param string $email_type
75 75
  * @param bool $sent_to_admin
76 76
  */
77
-function wpinv_email_billing_details( $invoice, $email_type, $sent_to_admin ) {
77
+function wpinv_email_billing_details($invoice, $email_type, $sent_to_admin) {
78 78
 
79
-    $args = compact( 'invoice', 'email_type', 'sent_to_admin' );
80
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', $args );
79
+    $args = compact('invoice', 'email_type', 'sent_to_admin');
80
+    wpinv_get_template('emails/wpinv-email-billing-details.php', $args);
81 81
 
82 82
 }
83
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
83
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
84 84
 
85 85
 /**
86 86
  * Returns email css.
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
  */
89 89
 function getpaid_get_email_css() {
90 90
 
91
-    $css = wpinv_get_template_html( 'emails/wpinv-email-styles.php' );
92
-    return apply_filters( 'wpinv_email_styles', $css );
91
+    $css = wpinv_get_template_html('emails/wpinv-email-styles.php');
92
+    return apply_filters('wpinv_email_styles', $css);
93 93
 
94 94
 }
95 95
 
@@ -100,26 +100,26 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  * 
102 102
  */
103
-function wpinv_email_style_body( $content ) {
103
+function wpinv_email_style_body($content) {
104 104
 
105
-    if ( ! class_exists( 'DOMDocument' ) ) {
105
+    if (!class_exists('DOMDocument')) {
106 106
         return $content;
107 107
     }
108 108
 
109 109
     $css = getpaid_get_email_css();
110 110
 
111 111
     // include css inliner
112
-	if ( ! class_exists( 'Emogrifier' ) ) {
113
-		include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
112
+	if (!class_exists('Emogrifier')) {
113
+		include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
114 114
     }
115 115
 
116 116
     // Inline the css.
117 117
     try {
118
-        $emogrifier = new Emogrifier( $content, $css );
118
+        $emogrifier = new Emogrifier($content, $css);
119 119
         $_content   = $emogrifier->emogrify();
120 120
         $content    = $_content;
121
-    } catch ( Exception $e ) {
122
-        wpinv_error_log( $e->getMessage(), 'emogrifier' );
121
+    } catch (Exception $e) {
122
+        wpinv_error_log($e->getMessage(), 'emogrifier');
123 123
     }
124 124
 
125 125
     return $content;
@@ -128,37 +128,37 @@  discard block
 block discarded – undo
128 128
 
129 129
 // Backwards compatibility.
130 130
 function wpinv_init_transactional_emails() {
131
-    foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) {
132
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
131
+    foreach (apply_filters('wpinv_email_actions', array()) as $action) {
132
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
133 133
     }
134 134
 }
135
-add_action( 'init', 'wpinv_init_transactional_emails' );
135
+add_action('init', 'wpinv_init_transactional_emails');
136 136
 
137 137
 function wpinv_send_transactional_email() {
138 138
     $args       = func_get_args();
139 139
     $function   = current_filter() . '_notification';
140
-    do_action_ref_array( $function, $args );
140
+    do_action_ref_array($function, $args);
141 141
 }
142 142
 
143 143
 function wpinv_mail_get_from_address() {
144
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from', get_option( 'admin_email' ) ) );
145
-    return sanitize_email( $from_address );
144
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from', get_option('admin_email')));
145
+    return sanitize_email($from_address);
146 146
 }
147 147
 
148 148
 function wpinv_mail_get_from_name() {
149
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name', get_bloginfo( 'name', 'display' ) ) );
150
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
149
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name', get_bloginfo('name', 'display')));
150
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
151 151
 }
152 152
 
153
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
154
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
155
-    return ( $active ? true : false );
153
+function wpinv_mail_admin_bcc_active($mail_type = '') {
154
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
155
+    return ($active ? true : false);
156 156
 }
157 157
     
158
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
159
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
158
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
159
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
160 160
 
161
-    switch ( $email_type ) {
161
+    switch ($email_type) {
162 162
         case 'html' :
163 163
             $content_type = 'text/html';
164 164
             break;
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
  * @param array        $attachments Any files to attach to the email.
184 184
  * @param string|array $cc An email or array of extra emails to send a copy of the email to.
185 185
  */
186
-function wpinv_mail_send( $to, $subject, $message, $deprecated, $attachments = array(), $cc = array() ) {
186
+function wpinv_mail_send($to, $subject, $message, $deprecated, $attachments = array(), $cc = array()) {
187 187
 
188 188
     $mailer  = new GetPaid_Notification_Email_Sender();
189
-    $message = wpinv_email_style_body( $message );
190
-    $to      = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) );
189
+    $message = wpinv_email_style_body($message);
190
+    $to      = array_merge(wpinv_parse_list($to), wpinv_parse_list($cc));
191 191
 
192 192
 	return $mailer->send(
193 193
         $to,
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
  * @return array
205 205
  */
206 206
 function wpinv_get_emails() {
207
-    return apply_filters( 'wpinv_get_emails', wpinv_get_data( 'email-settings' ) );
207
+    return apply_filters('wpinv_get_emails', wpinv_get_data('email-settings'));
208 208
 }
209 209
 
210 210
 /**
@@ -213,172 +213,172 @@  discard block
 block discarded – undo
213 213
  * @param array $settings
214 214
  * @return array
215 215
  */
216
-function wpinv_settings_emails( $settings = array() ) {
217
-    $settings = array_merge( $settings, wpinv_get_emails() );
218
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
216
+function wpinv_settings_emails($settings = array()) {
217
+    $settings = array_merge($settings, wpinv_get_emails());
218
+    return apply_filters('wpinv_settings_get_emails', $settings);
219 219
 }
220
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
220
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
221 221
 
222 222
 /**
223 223
  * Filter email section names.
224 224
  * 
225 225
  */
226
-function wpinv_settings_sections_emails( $settings ) {
227
-    foreach  ( wpinv_get_emails() as $key => $email) {
228
-        $settings[$key] = ! empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : strip_tags( $key );
226
+function wpinv_settings_sections_emails($settings) {
227
+    foreach (wpinv_get_emails() as $key => $email) {
228
+        $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : strip_tags($key);
229 229
     }
230 230
 
231 231
     return $settings;    
232 232
 }
233
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
233
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
234 234
 
235
-function wpinv_email_is_enabled( $email_type ) {
235
+function wpinv_email_is_enabled($email_type) {
236 236
     $emails = wpinv_get_emails();
237
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
237
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
238 238
 
239
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
239
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
240 240
 }
241 241
 
242
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
243
-    switch ( $email_type ) {
242
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
243
+    switch ($email_type) {
244 244
         case 'new_invoice':
245 245
         case 'cancelled_invoice':
246 246
         case 'failed_invoice':
247 247
             $recipient  = wpinv_get_admin_email();
248 248
         break;
249 249
         default:
250
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
251
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
250
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
251
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
252 252
         break;
253 253
     }
254 254
 
255
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
255
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
256 256
 }
257 257
 
258 258
 /**
259 259
  * Returns invoice CC recipients
260 260
  */
261
-function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) {
262
-    switch ( $email_type ) {
261
+function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) {
262
+    switch ($email_type) {
263 263
         case 'new_invoice':
264 264
         case 'cancelled_invoice':
265 265
         case 'failed_invoice':
266 266
             return array();
267 267
         break;
268 268
         default:
269
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
270
-            $recipient  = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true );
271
-            if ( empty( $recipient ) ) {
269
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
270
+            $recipient  = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true);
271
+            if (empty($recipient)) {
272 272
                 return array();
273 273
             }
274
-            return  array_filter( array_map( 'trim', explode( ',', $recipient ) ) );
274
+            return  array_filter(array_map('trim', explode(',', $recipient)));
275 275
         break;
276 276
     }
277 277
 
278 278
 }
279 279
 
280
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
281
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
282
-    $subject    = __( $subject, 'invoicing' );
280
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
281
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
282
+    $subject    = __($subject, 'invoicing');
283 283
 
284
-    $subject    = wpinv_email_format_text( $subject, $invoice );
284
+    $subject    = wpinv_email_format_text($subject, $invoice);
285 285
 
286
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
286
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
287 287
 }
288 288
 
289
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
290
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
291
-    $email_heading = __( $email_heading, 'invoicing' );
289
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
290
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
291
+    $email_heading = __($email_heading, 'invoicing');
292 292
 
293
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
293
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
294 294
 
295
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
295
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
296 296
 }
297 297
 
298
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
299
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
300
-    $content    = __( $content, 'invoicing' );
298
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
299
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
300
+    $content    = __($content, 'invoicing');
301 301
 
302
-    $content    = wpinv_email_format_text( $content, $invoice );
302
+    $content    = wpinv_email_format_text($content, $invoice);
303 303
 
304
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
304
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
305 305
 }
306 306
 
307
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
307
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
308 308
     $from_name = wpinv_mail_get_from_address();
309 309
     $from_email = wpinv_mail_get_from_address();
310 310
     
311
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
311
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
312 312
     
313
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
314
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
313
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
314
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
315 315
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
316 316
     
317
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
317
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
318 318
 }
319 319
 
320
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
320
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
321 321
     $attachments = array();
322 322
     
323
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
323
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
324 324
 }
325 325
 
326 326
 /**
327 327
  * Searches for and replaces certain placeholders in an email.
328 328
  */
329
-function wpinv_email_format_text( $content, $invoice ) {
329
+function wpinv_email_format_text($content, $invoice) {
330 330
 
331 331
     $replace_array = array(
332 332
         '{site_title}'      => wpinv_get_blogname(),
333
-        '{date}'            => getpaid_format_date( current_time( 'mysql' ) ),
333
+        '{date}'            => getpaid_format_date(current_time('mysql')),
334 334
     );
335 335
 
336
-    $invoice = new WPInv_Invoice( $invoice );
336
+    $invoice = new WPInv_Invoice($invoice);
337 337
 
338
-    if ( $invoice->get_id() ) {
338
+    if ($invoice->get_id()) {
339 339
 
340 340
         $replace_array = array_merge(
341 341
             $replace_array, 
342 342
             array(
343
-                '{name}'            => sanitize_text_field( $invoice->get_user_full_name() ),
344
-                '{full_name}'       => sanitize_text_field( $invoice->get_user_full_name() ),
345
-                '{first_name}'      => sanitize_text_field( $invoice->get_first_name() ),
346
-                '{last_name}'       => sanitize_text_field( $invoice->get_last_name() ),
347
-                '{email}'           => sanitize_email( $invoice->get_email() ),
348
-                '{invoice_number}'  => sanitize_text_field( $invoice->get_number() ),
349
-                '{invoice_total}'   => sanitize_text_field( wpinv_price( $invoice->get_total( true ), $invoice->get_currency() ) ),
350
-                '{invoice_link}'    => esc_url( $invoice->get_view_url() ),
351
-                '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ),
352
-                '{invoice_date}'    => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ),
353
-                '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ),
354
-                '{invoice_quote}'   => sanitize_text_field( $invoice->get_invoice_quote_type() ),
355
-                '{invoice_label}'   => sanitize_text_field( ucfirst( $invoice->get_invoice_quote_type() ) ),
356
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
343
+                '{name}'            => sanitize_text_field($invoice->get_user_full_name()),
344
+                '{full_name}'       => sanitize_text_field($invoice->get_user_full_name()),
345
+                '{first_name}'      => sanitize_text_field($invoice->get_first_name()),
346
+                '{last_name}'       => sanitize_text_field($invoice->get_last_name()),
347
+                '{email}'           => sanitize_email($invoice->get_email()),
348
+                '{invoice_number}'  => sanitize_text_field($invoice->get_number()),
349
+                '{invoice_total}'   => sanitize_text_field(wpinv_price($invoice->get_total(true), $invoice->get_currency())),
350
+                '{invoice_link}'    => esc_url($invoice->get_view_url()),
351
+                '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()),
352
+                '{invoice_date}'    => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))),
353
+                '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))),
354
+                '{invoice_quote}'   => sanitize_text_field($invoice->get_invoice_quote_type()),
355
+                '{invoice_label}'   => sanitize_text_field(ucfirst($invoice->get_invoice_quote_type())),
356
+                '{is_was}'          => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
357 357
             )
358 358
         );
359 359
 
360 360
     }
361 361
 
362 362
     // Let third party plugins filter the arra.
363
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
363
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
364 364
 
365
-    foreach ( $replace_array as $key => $value ) {
366
-        $content = str_replace( $key, $value, $content );
365
+    foreach ($replace_array as $key => $value) {
366
+        $content = str_replace($key, $value, $content);
367 367
     }
368 368
 
369
-    return apply_filters( 'wpinv_email_content_replace', $content );
369
+    return apply_filters('wpinv_email_content_replace', $content);
370 370
 }
371 371
 
372 372
 
373
-function wpinv_email_wrap_message( $message ) {
373
+function wpinv_email_wrap_message($message) {
374 374
     // Buffer
375 375
     ob_start();
376 376
 
377
-    do_action( 'wpinv_email_header' );
377
+    do_action('wpinv_email_header');
378 378
 
379
-    echo wpautop( wptexturize( $message ) );
379
+    echo wpautop(wptexturize($message));
380 380
 
381
-    do_action( 'wpinv_email_footer' );
381
+    do_action('wpinv_email_footer');
382 382
 
383 383
     // Get contents
384 384
     $message = ob_get_clean();
@@ -386,21 +386,21 @@  discard block
 block discarded – undo
386 386
     return $message;
387 387
 }
388 388
 
389
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type ) {
390
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->get_id(), true ) ) {
391
-        $date_format = get_option( 'date_format' );
392
-        $time_format = get_option( 'time_format' );
389
+function wpinv_add_notes_to_invoice_email($invoice, $email_type) {
390
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->get_id(), true)) {
391
+        $date_format = get_option('date_format');
392
+        $time_format = get_option('time_format');
393 393
         ?>
394 394
         <div id="wpinv-email-notes">
395
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
395
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
396 396
             <ol class="wpinv-notes-lists">
397 397
         <?php
398
-        foreach ( $invoice_notes as $note ) {
399
-            $note_time = strtotime( $note->comment_date );
398
+        foreach ($invoice_notes as $note) {
399
+            $note_time = strtotime($note->comment_date);
400 400
             ?>
401 401
             <li class="comment wpinv-note">
402
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
403
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
402
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
403
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
404 404
             </li>
405 405
             <?php
406 406
         }
@@ -409,4 +409,4 @@  discard block
 block discarded – undo
409 409
         <?php
410 410
     }
411 411
 }
412
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
412
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 1 patch
Spacing   +118 added lines, -118 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
  * Returns an array of eu states.
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @return array
13 13
  */
14 14
 function getpaid_get_eu_states() {
15
-    return wpinv_get_data( 'eu-states' );
15
+    return wpinv_get_data('eu-states');
16 16
 }
17 17
 
18 18
 /**
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  * 
21 21
  * @return bool
22 22
  */
23
-function getpaid_is_eu_state( $country ) {
24
-    return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false;
23
+function getpaid_is_eu_state($country) {
24
+    return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false;
25 25
 }
26 26
 
27 27
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * @return array
31 31
  */
32 32
 function getpaid_get_gst_states() {
33
-    return array( 'AU', 'NZ', 'CA', 'CN' );
33
+    return array('AU', 'NZ', 'CA', 'CN');
34 34
 }
35 35
 
36 36
 /**
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
  * 
39 39
  * @return bool
40 40
  */
41
-function getpaid_is_gst_country( $country ) {
42
-    return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false;
41
+function getpaid_is_gst_country($country) {
42
+    return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false;
43 43
 }
44 44
 
45 45
 /**
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function wpinv_use_taxes() {
51 51
 
52
-    $ret = wpinv_get_option( 'enable_taxes', false );
53
-    return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) );
52
+    $ret = wpinv_get_option('enable_taxes', false);
53
+    return (bool) apply_filters('wpinv_use_taxes', !empty($ret));
54 54
 
55 55
 }
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @param WPInv_Invoice $invoice
61 61
  * @return bool
62 62
  */
63
-function wpinv_is_invoice_taxable( $invoice ) {
63
+function wpinv_is_invoice_taxable($invoice) {
64 64
     return $invoice->is_taxable();
65 65
 }
66 66
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
  * @param string $country
71 71
  * @return bool
72 72
  */
73
-function wpinv_is_country_taxable( $country ) {
74
-    $is_eu     = getpaid_is_eu_state( $country );
75
-    $is_exempt = $is_eu && $country == wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat();
73
+function wpinv_is_country_taxable($country) {
74
+    $is_eu     = getpaid_is_eu_state($country);
75
+    $is_exempt = $is_eu && $country == wpinv_is_base_country($country) && wpinv_same_country_exempt_vat();
76 76
 
77
-    return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); 
77
+    return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); 
78 78
 
79 79
 }
80 80
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
  * @param WPInv_Item|GetPaid_Form_Item $item
85 85
  * @return bool
86 86
  */
87
-function wpinv_is_item_taxable( $item ) {
87
+function wpinv_is_item_taxable($item) {
88 88
     return '_exempt' != $item->get_vat_rule();
89 89
 }
90 90
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
  * @return bool
95 95
  */
96 96
 function wpinv_use_store_address_as_tax_base() {
97
-    $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base';
98
-    return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base );
97
+    $use_base = wpinv_get_option('tax_base', 'billing') == 'base';
98
+    return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base);
99 99
 }
100 100
 
101 101
 /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
  * @return bool
105 105
  */
106 106
 function wpinv_prices_include_tax() {
107
-    $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes';
108
-    return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive );
107
+    $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes';
108
+    return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive);
109 109
 }
110 110
 
111 111
 /**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
  * @return bool
115 115
  */
116 116
 function wpinv_round_tax_per_tax_rate() {
117
-    $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 );
118
-    return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) );
117
+    $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1);
118
+    return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding));
119 119
 }
120 120
 
121 121
 /**
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
  * @return bool
125 125
  */
126 126
 function wpinv_display_individual_tax_rates() {
127
-    $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual';
128
-    return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual );
127
+    $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual';
128
+    return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual);
129 129
 }
130 130
 
131 131
 /**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
  * @return float
135 135
  */
136 136
 function wpinv_get_default_tax_rate() {
137
-    $rate = wpinv_get_option( 'tax_rate', 20 );
138
-    return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) );
137
+    $rate = wpinv_get_option('tax_rate', 20);
138
+    return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate));
139 139
 }
140 140
 
141 141
 /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  * @return bool
145 145
  */
146 146
 function wpinv_same_country_exempt_vat() {
147
-    return 'no' == wpinv_get_option( 'vat_same_country_rule', 'always' );
147
+    return 'no' == wpinv_get_option('vat_same_country_rule', 'always');
148 148
 }
149 149
 
150 150
 /**
@@ -164,28 +164,28 @@  discard block
 block discarded – undo
164 164
  * @param string $state
165 165
  * @return array
166 166
  */
167
-function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) {
167
+function getpaid_get_item_tax_rates($item, $country = '', $state = '') {
168 168
 
169 169
     // Abort if the item is not taxable.
170
-    if ( ! wpinv_is_item_taxable( $item ) ) {
170
+    if (!wpinv_is_item_taxable($item)) {
171 171
         return array();
172 172
     }
173 173
 
174 174
     // Maybe use the store address.
175
-    if ( wpinv_use_store_address_as_tax_base() ) {
175
+    if (wpinv_use_store_address_as_tax_base()) {
176 176
         $country = wpinv_get_default_country();
177 177
         $state   = wpinv_get_default_state();
178 178
     }
179 179
 
180 180
     // Retrieve tax rates.
181
-    $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state );
181
+    $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state);
182 182
 
183 183
     // Fallback to the default tax rates if non were found.
184
-    if ( empty( $tax_rates ) ) {
184
+    if (empty($tax_rates)) {
185 185
         $tax_rates = GetPaid_Tax::get_default_tax_rates();
186 186
     }
187 187
 
188
-    return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state );
188
+    return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state);
189 189
 }
190 190
 
191 191
 /**
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
  * @param array $rates
196 196
  * @return array
197 197
  */
198
-function getpaid_filter_item_tax_rates( $item, $rates ) {
198
+function getpaid_filter_item_tax_rates($item, $rates) {
199 199
 
200 200
     $tax_class = $item->get_vat_class();
201 201
 
202
-    foreach ( $rates as $i => $rate ) {
202
+    foreach ($rates as $i => $rate) {
203 203
 
204
-        if ( $tax_class == '_reduced' ) {
205
-            $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate'];
204
+        if ($tax_class == '_reduced') {
205
+            $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate'];
206 206
         }
207 207
 
208
-        if ( $tax_class == '_exempt' ) {
209
-            $rates[ $i ]['rate'] = 0;
208
+        if ($tax_class == '_exempt') {
209
+            $rates[$i]['rate'] = 0;
210 210
         }
211 211
 
212 212
     }
213 213
 
214
-    return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item );
214
+    return apply_filters('getpaid_filter_item_tax_rates', $rates, $item);
215 215
 }
216 216
 
217 217
 /**
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
  * @param array $rates
222 222
  * @return array
223 223
  */
224
-function getpaid_calculate_item_taxes( $amount, $rates ) {
224
+function getpaid_calculate_item_taxes($amount, $rates) {
225 225
 
226 226
     $is_inclusive = wpinv_prices_include_tax();
227
-    $taxes        = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive );
227
+    $taxes        = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive);
228 228
 
229
-    return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates );
229
+    return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates);
230 230
 }
231 231
 
232 232
 /**
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
  * @param float $recurring_tax_amount
239 239
  * @return array
240 240
  */
241
-function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
241
+function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) {
242 242
 
243
-    $initial_tax   = $tax_amount;
243
+    $initial_tax = $tax_amount;
244 244
 	$recurring_tax = 0;
245 245
 
246
-    if ( $item->is_recurring() ) {
246
+    if ($item->is_recurring()) {
247 247
 		$recurring_tax = $recurring_tax_amount;
248 248
 	}
249 249
 
250 250
 	return array(
251
-		'name'          => sanitize_text_field( $tax_name ),
251
+		'name'          => sanitize_text_field($tax_name),
252 252
 		'initial_tax'   => $initial_tax,
253 253
 		'recurring_tax' => $recurring_tax,
254 254
     );
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
  * @param string $vat_number
262 262
  * @return string
263 263
  */
264
-function wpinv_sanitize_vat_number( $vat_number ) {
265
-    return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
264
+function wpinv_sanitize_vat_number($vat_number) {
265
+    return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
266 266
 }
267 267
 
268 268
 /**
@@ -271,22 +271,22 @@  discard block
 block discarded – undo
271 271
  * @param string $vat_number
272 272
  * @return bool
273 273
  */
274
-function wpinv_regex_validate_vat_number( $vat_number ) {
274
+function wpinv_regex_validate_vat_number($vat_number) {
275 275
 
276
-    $country    = substr( $vat_number, 0, 2 );
277
-    $vatin      = substr( $vat_number, 2 );
278
-    $regexes    = wpinv_get_data( 'vat-number-regexes' );
276
+    $country    = substr($vat_number, 0, 2);
277
+    $vatin      = substr($vat_number, 2);
278
+    $regexes    = wpinv_get_data('vat-number-regexes');
279 279
 
280
-    if ( isset( $regexes[ $country ] ) ) {
280
+    if (isset($regexes[$country])) {
281 281
 
282
-        $regex = $regexes[ $country ];
282
+        $regex = $regexes[$country];
283 283
         $regex = '/^(?:' . $regex . ')$/';
284
-        return 1 === preg_match( $regex, $vatin );
284
+        return 1 === preg_match($regex, $vatin);
285 285
 
286 286
     }
287 287
 
288 288
     // Not an EU state, use filters to validate the number.
289
-    return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number );
289
+    return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number);
290 290
 }
291 291
 
292 292
 /**
@@ -295,29 +295,29 @@  discard block
 block discarded – undo
295 295
  * @param string $vat_number
296 296
  * @return bool
297 297
  */
298
-function wpinv_vies_validate_vat_number( $vat_number ) {
298
+function wpinv_vies_validate_vat_number($vat_number) {
299 299
 
300
-    $country    = substr( $vat_number, 0, 2 );
301
-    $vatin      = substr( $vat_number, 2 );
300
+    $country    = substr($vat_number, 0, 2);
301
+    $vatin      = substr($vat_number, 2);
302 302
 
303 303
     $url        = add_query_arg(
304 304
         array(
305
-            'ms'  => urlencode( $country ),
306
-            'iso' => urlencode( $country ),
307
-            'vat' => urlencode( $vatin ),
305
+            'ms'  => urlencode($country),
306
+            'iso' => urlencode($country),
307
+            'vat' => urlencode($vatin),
308 308
         ),
309 309
         'http://ec.europa.eu/taxation_customs/vies/viesquer.do'
310 310
     );
311 311
 
312
-    $response   = wp_remote_get( $url );
313
-    $response   = wp_remote_retrieve_body( $response );
312
+    $response   = wp_remote_get($url);
313
+    $response   = wp_remote_retrieve_body($response);
314 314
 
315 315
     // Fallback gracefully if the VIES website is down.
316
-    if ( empty( $response ) ) {
316
+    if (empty($response)) {
317 317
         return true;
318 318
     }
319 319
 
320
-    return 1 !== preg_match( '/invalid VAT number/i', $response );
320
+    return 1 !== preg_match('/invalid VAT number/i', $response);
321 321
 
322 322
 }
323 323
 
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
  * @param string $country
329 329
  * @return bool
330 330
  */
331
-function wpinv_validate_vat_number( $vat_number, $country ) {
331
+function wpinv_validate_vat_number($vat_number, $country) {
332 332
 
333 333
     // Abort if we are not validating this.
334
-    if ( ! wpinv_should_validate_vat_number() || empty( $vat_number ) ) {
334
+    if (!wpinv_should_validate_vat_number() || empty($vat_number)) {
335 335
         return true;
336 336
     }
337 337
 
338 338
     // In case the vat number does not have a country code...
339
-    $vat_number = wpinv_sanitize_vat_number( $vat_number );
340
-    $_country   = substr( $vat_number, 0, 2 );
341
-    $_country   = $_country == wpinv_country_name( $_country );
339
+    $vat_number = wpinv_sanitize_vat_number($vat_number);
340
+    $_country   = substr($vat_number, 0, 2);
341
+    $_country   = $_country == wpinv_country_name($_country);
342 342
 
343
-    if ( $_country ) {
344
-        $vat_number = strtoupper( $country ) . $vat_number;
343
+    if ($_country) {
344
+        $vat_number = strtoupper($country) . $vat_number;
345 345
     }
346 346
 
347
-    return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number );
347
+    return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number);
348 348
 }
349 349
 
350 350
 /**
@@ -353,40 +353,40 @@  discard block
 block discarded – undo
353 353
  * @return bool
354 354
  */
355 355
 function wpinv_should_validate_vat_number() {
356
-    $validate = wpinv_get_option( 'validate_vat_number' );
357
-	return ! empty( $validate );
356
+    $validate = wpinv_get_option('validate_vat_number');
357
+	return !empty($validate);
358 358
 }
359 359
 
360
-function wpinv_sales_tax_for_year( $year = null ) {
361
-    return wpinv_price( wpinv_get_sales_tax_for_year( $year ) );
360
+function wpinv_sales_tax_for_year($year = null) {
361
+    return wpinv_price(wpinv_get_sales_tax_for_year($year));
362 362
 }
363 363
 
364
-function wpinv_get_sales_tax_for_year( $year = null ) {
364
+function wpinv_get_sales_tax_for_year($year = null) {
365 365
     global $wpdb;
366 366
 
367 367
     // Start at zero
368 368
     $tax = 0;
369 369
 
370
-    if ( ! empty( $year ) ) {
370
+    if (!empty($year)) {
371 371
         $args = array(
372 372
             'post_type'      => 'wpi_invoice',
373
-            'post_status'    => array( 'publish' ),
373
+            'post_status'    => array('publish'),
374 374
             'posts_per_page' => -1,
375 375
             'year'           => $year,
376 376
             'fields'         => 'ids'
377 377
         );
378 378
 
379
-        $payments    = get_posts( $args );
380
-        $payment_ids = implode( ',', $payments );
379
+        $payments    = get_posts($args);
380
+        $payment_ids = implode(',', $payments);
381 381
 
382
-        if ( count( $payments ) > 0 ) {
382
+        if (count($payments) > 0) {
383 383
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
384
-            $tax = $wpdb->get_var( $sql );
384
+            $tax = $wpdb->get_var($sql);
385 385
         }
386 386
 
387 387
     }
388 388
 
389
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
389
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
390 390
 }
391 391
 
392 392
 function wpinv_is_cart_taxed() {
@@ -395,33 +395,33 @@  discard block
 block discarded – undo
395 395
 
396 396
 function wpinv_prices_show_tax_on_checkout() {
397 397
     return false; // TODO
398
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
398
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
399 399
 
400
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
400
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
401 401
 }
402 402
 
403 403
 function wpinv_display_tax_rate() {
404
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
404
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
405 405
 
406
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
406
+    return apply_filters('wpinv_display_tax_rate', $ret);
407 407
 }
408 408
 
409 409
 function wpinv_cart_needs_tax_address_fields() {
410
-    if( !wpinv_is_cart_taxed() )
410
+    if (!wpinv_is_cart_taxed())
411 411
         return false;
412 412
 
413
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
413
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
414 414
 }
415 415
 
416
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
417
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
418
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
416
+function wpinv_item_is_tax_exclusive($item_id = 0) {
417
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
418
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
419 419
 }
420 420
 
421
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
421
+function wpinv_currency_decimal_filter($decimals = 2) {
422 422
     $currency = wpinv_get_currency();
423 423
 
424
-    switch ( $currency ) {
424
+    switch ($currency) {
425 425
         case 'RIAL' :
426 426
         case 'JPY' :
427 427
         case 'TWD' :
@@ -430,13 +430,13 @@  discard block
 block discarded – undo
430 430
             break;
431 431
     }
432 432
 
433
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
433
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
434 434
 }
435 435
 
436 436
 function wpinv_tax_amount() {
437 437
     $output = 0.00;
438 438
     
439
-    return apply_filters( 'wpinv_tax_amount', $output );
439
+    return apply_filters('wpinv_tax_amount', $output);
440 440
 }
441 441
 
442 442
 /**
@@ -444,25 +444,25 @@  discard block
 block discarded – undo
444 444
  * 
445 445
  * @param string|bool|null $vat_rule
446 446
  */
447
-function getpaid_filter_vat_rule( $vat_rule ) {
447
+function getpaid_filter_vat_rule($vat_rule) {
448 448
 
449
-    if ( empty( $vat_rule ) ) {        
449
+    if (empty($vat_rule)) {        
450 450
         return 'digital';
451 451
     }
452 452
 
453 453
     return $vat_rule;
454 454
 }
455
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
455
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
456 456
 
457 457
 /**
458 458
  * Filters the VAT class to ensure that each item has a VAT class.
459 459
  * 
460 460
  * @param string|bool|null $vat_rule
461 461
  */
462
-function getpaid_filter_vat_class( $vat_class ) {
463
-    return empty( $vat_class ) ? '_standard' : $vat_class;
462
+function getpaid_filter_vat_class($vat_class) {
463
+    return empty($vat_class) ? '_standard' : $vat_class;
464 464
 }
465
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
465
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
466 466
 
467 467
 /**
468 468
  * Returns a list of all tax classes.
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
     return apply_filters(
475 475
         'getpaid_tax_classes',
476 476
         array(
477
-            '_standard' => __( 'Standard Tax Rate', 'invoicing' ),
478
-            '_reduced'  => __( 'Reduced Tax Rate', 'invoicing' ),
479
-            '_exempt'   => __( 'Tax Exempt', 'invoicing' ),
477
+            '_standard' => __('Standard Tax Rate', 'invoicing'),
478
+            '_reduced'  => __('Reduced Tax Rate', 'invoicing'),
479
+            '_exempt'   => __('Tax Exempt', 'invoicing'),
480 480
         )
481 481
     );
482 482
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
     return apply_filters(
493 493
         'getpaid_tax_rules',
494 494
         array(
495
-            'physical' => __( 'Physical Item', 'invoicing' ),
496
-            'digital'  => __( 'Digital Item', 'invoicing' ),
495
+            'physical' => __('Physical Item', 'invoicing'),
496
+            'digital'  => __('Digital Item', 'invoicing'),
497 497
         )
498 498
     );
499 499
 
@@ -505,15 +505,15 @@  discard block
 block discarded – undo
505 505
  * @param string $tax_class
506 506
  * @return string
507 507
  */
508
-function getpaid_get_tax_class_label( $tax_class ) {
508
+function getpaid_get_tax_class_label($tax_class) {
509 509
 
510 510
     $classes = getpaid_get_tax_classes();
511 511
 
512
-    if ( isset( $classes[ $tax_class ] ) ) {
513
-        return sanitize_text_field( $classes[ $tax_class ] );
512
+    if (isset($classes[$tax_class])) {
513
+        return sanitize_text_field($classes[$tax_class]);
514 514
     }
515 515
 
516
-    return sanitize_text_field( $tax_class );
516
+    return sanitize_text_field($tax_class);
517 517
 
518 518
 }
519 519
 
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
  * @param string $tax_rule
524 524
  * @return string
525 525
  */
526
-function getpaid_get_tax_rule_label( $tax_rule ) {
526
+function getpaid_get_tax_rule_label($tax_rule) {
527 527
 
528 528
     $rules = getpaid_get_tax_rules();
529 529
 
530
-    if ( isset( $rules[ $tax_rule ] ) ) {
531
-        return sanitize_text_field( $rules[ $tax_rule ] );
530
+    if (isset($rules[$tax_rule])) {
531
+        return sanitize_text_field($rules[$tax_rule]);
532 532
     }
533 533
 
534
-    return sanitize_text_field( $tax_rule );
534
+    return sanitize_text_field($tax_rule);
535 535
 
536 536
 }
Please login to merge, or discard this patch.
includes/data/admin-settings.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -8,197 +8,197 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13
-$pages = wpinv_get_pages( true );
13
+$pages = wpinv_get_pages(true);
14 14
     
15 15
 $currencies = wpinv_get_currencies();
16 16
     
17 17
 $currency_code_options = array();
18
-foreach ( $currencies as $code => $name ) {
19
-    $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
18
+foreach ($currencies as $code => $name) {
19
+    $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
20 20
 }
21 21
     
22 22
 $due_payment_options       = array();
23
-$due_payment_options[0]    = __( 'Now', 'invoicing' );
24
-for ( $i = 1; $i <= 30; $i++ ) {
23
+$due_payment_options[0]    = __('Now', 'invoicing');
24
+for ($i = 1; $i <= 30; $i++) {
25 25
     $due_payment_options[$i] = $i;
26 26
 }
27 27
     
28 28
 $invoice_number_padd_options = array();
29
-for ( $i = 0; $i <= 20; $i++ ) {
29
+for ($i = 0; $i <= 20; $i++) {
30 30
     $invoice_number_padd_options[$i] = $i;
31 31
 }
32 32
     
33 33
 $currency_symbol = wpinv_currency_symbol();
34 34
     
35 35
 $last_number = $reset_number = '';
36
-if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
37
-    $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number );
36
+if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
37
+    $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number);
38 38
 
39
-    if ( !empty( $last_invoice_number ) ) {
40
-        $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
39
+    if (!empty($last_invoice_number)) {
40
+        $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
41 41
     }
42 42
 
43 43
     $nonce = wp_create_nonce('reset_invoice_count');
44
-    $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
44
+    $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
45 45
 }
46 46
     
47 47
 $alert_wrapper_start = '<p style="color: #F00">';
48 48
 $alert_wrapper_close = '</p>';
49 49
 
50 50
 return array(
51
-    'general' => apply_filters( 'wpinv_settings_general',
51
+    'general' => apply_filters('wpinv_settings_general',
52 52
         array(
53 53
             'main' => array(
54 54
                 'location_settings' => array(
55 55
                     'id'   => 'location_settings',
56
-                    'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
56
+                    'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
57 57
                     'desc' => '',
58 58
                     'type' => 'header',
59 59
                 ),
60 60
                 'default_country' => array(
61 61
                     'id'      => 'default_country',
62
-                    'name'    => __( 'Default Country', 'invoicing' ),
63
-                    'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
62
+                    'name'    => __('Default Country', 'invoicing'),
63
+                    'desc'    => __('Where does your store operate from?', 'invoicing'),
64 64
                     'type'    => 'select',
65 65
                     'options' => wpinv_get_country_list(),
66 66
                     'std'     => 'GB',
67 67
                     'class'   => 'wpi_select2',
68
-                    'placeholder' => __( 'Select a country', 'invoicing' ),
68
+                    'placeholder' => __('Select a country', 'invoicing'),
69 69
                 ),
70 70
                 'default_state' => array(
71 71
                     'id'      => 'default_state',
72
-                    'name'    => __( 'Default State / Province', 'invoicing' ),
73
-                    'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
72
+                    'name'    => __('Default State / Province', 'invoicing'),
73
+                    'desc'    => __('What state / province does your store operate from?', 'invoicing'),
74 74
                     'type'    => 'country_states',
75 75
                     'class'   => 'wpi_select2',
76
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
76
+                    'placeholder' => __('Select a state', 'invoicing'),
77 77
                 ),
78 78
                 'store_name' => array(
79 79
                     'id'   => 'store_name',
80
-                    'name' => __( 'Store Name', 'invoicing' ),
81
-                    'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
80
+                    'name' => __('Store Name', 'invoicing'),
81
+                    'desc' => __('Store name to print on invoices.', 'invoicing'),
82 82
                     'std'     => get_option('blogname'),
83 83
                     'type' => 'text',
84 84
                 ),
85 85
                 'logo' => array(
86 86
                     'id'   => 'logo',
87
-                    'name' => __( 'Logo URL', 'invoicing' ),
88
-                    'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
87
+                    'name' => __('Logo URL', 'invoicing'),
88
+                    'desc' => __('Store logo to print on invoices.', 'invoicing'),
89 89
                     'type' => 'text',
90 90
                 ),
91 91
                 'store_address' => array(
92 92
                     'id'   => 'store_address',
93
-                    'name' => __( 'Store Address', 'invoicing' ),
94
-                    'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
93
+                    'name' => __('Store Address', 'invoicing'),
94
+                    'desc' => __('Enter the store address to display on invoice', 'invoicing'),
95 95
                     'type' => 'textarea',
96 96
                 ),
97 97
                 'page_settings' => array(
98 98
                     'id'   => 'page_settings',
99
-                    'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
99
+                    'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
100 100
                     'desc' => '',
101 101
                     'type' => 'header',
102 102
                 ),
103 103
                 'checkout_page' => array(
104 104
                     'id'          => 'checkout_page',
105
-                    'name'        => __( 'Checkout Page', 'invoicing' ),
106
-                    'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
105
+                    'name'        => __('Checkout Page', 'invoicing'),
106
+                    'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
107 107
                     'type'        => 'select',
108 108
                     'options'     => $pages,
109 109
                     'class'       => 'wpi_select2',
110
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
110
+                    'placeholder' => __('Select a page', 'invoicing'),
111 111
                     'help-tip'    => true,
112 112
                 ),
113 113
                 'success_page' => array(
114 114
                     'id'          => 'success_page',
115
-                    'name'        => __( 'Success Page', 'invoicing' ),
116
-                    'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
115
+                    'name'        => __('Success Page', 'invoicing'),
116
+                    'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
117 117
                     'type'        => 'select',
118 118
                     'options'     => $pages,
119 119
                     'class'       => 'wpi_select2',
120
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
120
+                    'placeholder' => __('Select a page', 'invoicing'),
121 121
                     'help-tip'    => true,
122 122
                 ),
123 123
                 'failure_page' => array(
124 124
                     'id'          => 'failure_page',
125
-                    'name'        => __( 'Failed Transaction Page', 'invoicing' ),
126
-                    'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
125
+                    'name'        => __('Failed Transaction Page', 'invoicing'),
126
+                    'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
127 127
                     'type'        => 'select',
128 128
                     'options'     => $pages,
129 129
                     'class'       => 'wpi_select2',
130
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
130
+                    'placeholder' => __('Select a page', 'invoicing'),
131 131
                     'help-tip'    => true,
132 132
                 ),
133 133
                 'invoice_history_page' => array(
134 134
                     'id'          => 'invoice_history_page',
135
-                    'name'        => __( 'Invoice History Page', 'invoicing' ),
136
-                    'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
135
+                    'name'        => __('Invoice History Page', 'invoicing'),
136
+                    'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
137 137
                     'type'        => 'select',
138 138
                     'options'     => $pages,
139 139
                     'class'       => 'wpi_select2',
140
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
140
+                    'placeholder' => __('Select a page', 'invoicing'),
141 141
                     'help-tip'    => true,
142 142
                 ),
143 143
                 'invoice_subscription_page' => array(
144 144
                     'id'          => 'invoice_subscription_page',
145
-                    'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
146
-                    'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
145
+                    'name'        => __('Invoice Subscriptions Page', 'invoicing'),
146
+                    'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
147 147
                     'type'        => 'select',
148 148
                     'options'     => $pages,
149 149
                     'class'       => 'wpi_select2',
150
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
150
+                    'placeholder' => __('Select a page', 'invoicing'),
151 151
                     'help-tip'    => true,
152 152
                 ),
153 153
             ),
154 154
             'currency_section' => array(
155 155
                 'currency_settings' => array(
156 156
                     'id'   => 'currency_settings',
157
-                    'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
157
+                    'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
158 158
                     'desc' => '',
159 159
                     'type' => 'header',
160 160
                 ),
161 161
                 'currency' => array(
162 162
                     'id'      => 'currency',
163
-                    'name'    => __( 'Currency', 'invoicing' ),
164
-                    'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
163
+                    'name'    => __('Currency', 'invoicing'),
164
+                    'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
165 165
                     'type'    => 'select',
166 166
                     'class'       => 'wpi_select2',
167 167
                     'options' => $currency_code_options,
168 168
                 ),
169 169
                 'currency_position' => array(
170 170
                     'id'      => 'currency_position',
171
-                    'name'    => __( 'Currency Position', 'invoicing' ),
172
-                    'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
171
+                    'name'    => __('Currency Position', 'invoicing'),
172
+                    'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
173 173
                     'type'    => 'select',
174 174
                     'class'   => 'wpi_select2',
175 175
                     'options'  => array(
176
-                        'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
177
-                        'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
178
-                        'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
179
-                        'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
176
+                        'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
177
+                        'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
178
+                        'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
179
+                        'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
180 180
                     )
181 181
                 ),
182 182
                 'thousands_separator' => array(
183 183
                     'id'   => 'thousands_separator',
184
-                    'name' => __( 'Thousands Separator', 'invoicing' ),
185
-                    'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
184
+                    'name' => __('Thousands Separator', 'invoicing'),
185
+                    'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
186 186
                     'type' => 'text',
187 187
                     'size' => 'small',
188 188
                     'std'  => ',',
189 189
                 ),
190 190
                 'decimal_separator' => array(
191 191
                     'id'   => 'decimal_separator',
192
-                    'name' => __( 'Decimal Separator', 'invoicing' ),
193
-                    'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
192
+                    'name' => __('Decimal Separator', 'invoicing'),
193
+                    'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
194 194
                     'type' => 'text',
195 195
                     'size' => 'small',
196 196
                     'std'  => '.',
197 197
                 ),
198 198
                 'decimals' => array(
199 199
                     'id'   => 'decimals',
200
-                    'name' => __( 'Number of Decimals', 'invoicing' ),
201
-                    'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
200
+                    'name' => __('Number of Decimals', 'invoicing'),
201
+                    'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
202 202
                     'type' => 'number',
203 203
                     'size' => 'small',
204 204
                     'std'  => '2',
@@ -210,21 +210,21 @@  discard block
 block discarded – undo
210 210
             'labels' => array(
211 211
                 'labels' => array(
212 212
                     'id'   => 'labels_settings',
213
-                    'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
213
+                    'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
214 214
                     'desc' => '',
215 215
                     'type' => 'header',
216 216
                 ),
217 217
                 'vat_invoice_notice_label' => array(
218 218
                     'id' => 'vat_invoice_notice_label',
219
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
220
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
219
+                    'name' => __('Invoice Notice Label', 'invoicing'),
220
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
221 221
                     'type' => 'text',
222 222
                     'size' => 'regular',
223 223
                 ),
224 224
                 'vat_invoice_notice' => array(
225 225
                     'id' => 'vat_invoice_notice',
226
-                    'name' => __( 'Invoice notice', 'invoicing' ),
227
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
226
+                    'name' => __('Invoice notice', 'invoicing'),
227
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
228 228
                     'type' => 'text',
229 229
                     'size' => 'regular',
230 230
                 ),
@@ -236,22 +236,22 @@  discard block
 block discarded – undo
236 236
             'main' => array(
237 237
                 'gateway_settings' => array(
238 238
                     'id'   => 'api_header',
239
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
239
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
240 240
                     'desc' => '',
241 241
                     'type' => 'header',
242 242
                 ),
243 243
                 'gateways' => array(
244 244
                     'id'      => 'gateways',
245
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
246
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
245
+                    'name'    => __('Payment Gateways', 'invoicing'),
246
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
247 247
                     'type'    => 'gateways',
248 248
                     'std'     => array('manual'=>1),
249 249
                     'options' => wpinv_get_payment_gateways(),
250 250
                 ),
251 251
                 'default_gateway' => array(
252 252
                     'id'      => 'default_gateway',
253
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
254
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
253
+                    'name'    => __('Default Gateway', 'invoicing'),
254
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
255 255
                     'type'    => 'gateway_select',
256 256
                     'std'     => 'manual',
257 257
                     'class'   => 'wpi_select2',
@@ -266,32 +266,32 @@  discard block
 block discarded – undo
266 266
             'main' => array(
267 267
                 'tax_settings' => array(
268 268
                     'id'   => 'tax_settings',
269
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
269
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
270 270
                     'type' => 'header',
271 271
                 ),
272 272
 
273 273
                 'enable_taxes' => array(
274 274
                     'id'       => 'enable_taxes',
275
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
276
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
275
+                    'name'     => __('Enable Taxes', 'invoicing'),
276
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
277 277
                     'type'     => 'checkbox',
278 278
                     'std'      => 0,
279 279
                 ),
280 280
 
281 281
                 'tax_subtotal_rounding' => array(
282 282
                     'id'                => 'tax_subtotal_rounding',
283
-                    'name'              => __( 'Rounding', 'invoicing' ),
284
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
283
+                    'name'              => __('Rounding', 'invoicing'),
284
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
285 285
                     'type'              => 'checkbox',
286 286
                     'std'               => 1,
287 287
                 ),
288 288
 
289 289
                 'prices_include_tax' => array(
290 290
                     'id'      => 'prices_include_tax',
291
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
291
+                    'name'    => __('Prices entered with tax', 'invoicing'),
292 292
                     'options' => array(
293
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
294
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
293
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
294
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
295 295
                     ),
296 296
                     'type'    => 'select',
297 297
                     'std'     => 'no',
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 
300 300
                 'tax_base'              => array(
301 301
                     'id'                => 'tax_base',
302
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
302
+                    'name'              => __('Calculate tax based on', 'invoicing'),
303 303
                     'options'           => array(
304
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
305
-                        'base'          => __( 'Shop base address', 'invoicing' ),
304
+                        'billing'       => __('Customer billing address', 'invoicing'),
305
+                        'base'          => __('Shop base address', 'invoicing'),
306 306
                     ),
307 307
                     'type'              => 'select',
308 308
                     'std'               => 'billing',
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 
311 311
                 'tax_display_totals'    => array(
312 312
                     'id'                => 'tax_display_totals',
313
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
313
+                    'name'              => __('Display tax totals', 'invoicing'),
314 314
                     'options'           => array(
315
-                        'single'        => __( 'As a single total', 'invoicing' ),
316
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
315
+                        'single'        => __('As a single total', 'invoicing'),
316
+                        'individual'    => __('As individual tax rates', 'invoicing'),
317 317
                     ),
318 318
                     'type'              => 'select',
319 319
                     'std'               => 'individual',
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 
322 322
                 'tax_rate' => array(
323 323
                     'id'   => 'tax_rate',
324
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
325
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
324
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
325
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
326 326
                     'type' => 'number',
327 327
                     'size' => 'small',
328 328
                     'min'  => '0',
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
             'rates' => array(
335 335
                 'tax_rates' => array(
336 336
                     'id'   => 'tax_rates',
337
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
338
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
337
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
338
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
339 339
                     'type' => 'tax_rates',
340 340
                 ),
341 341
             ),
@@ -344,44 +344,44 @@  discard block
 block discarded – undo
344 344
 
345 345
                 'vat_company_name' => array(
346 346
                     'id' => 'vat_company_name',
347
-                    'name' => __( 'Company Name', 'invoicing' ),
348
-                    'desc' => wp_sprintf(__( 'Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
347
+                    'name' => __('Company Name', 'invoicing'),
348
+                    'desc' => wp_sprintf(__('Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
349 349
                     'type' => 'text',
350 350
                     'size' => 'regular',
351 351
                 ),
352 352
 
353 353
                 'vat_number' => array(
354 354
                     'id'   => 'vat_number',
355
-                    'name' => __( 'VAT Number', 'invoicing' ),
356
-                    'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ),
355
+                    'name' => __('VAT Number', 'invoicing'),
356
+                    'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'),
357 357
                     'type' => 'text',
358 358
                     'size' => 'regular',
359 359
                 ),
360 360
 
361 361
                 'vat_prevent_b2c_purchase' => array(
362 362
                     'id' => 'vat_prevent_b2c_purchase',
363
-                    'name' => __( 'Prevent B2C Sales', 'invoicing' ),
364
-                    'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ),
363
+                    'name' => __('Prevent B2C Sales', 'invoicing'),
364
+                    'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'),
365 365
                     'type' => 'checkbox'
366 366
                 ),
367 367
 
368 368
                 'validate_vat_number' => array(
369 369
                     'id'   => 'validate_vat_number',
370
-                    'name' => __( 'Validate VAT Number', 'invoicing' ),
371
-                    'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ),
370
+                    'name' => __('Validate VAT Number', 'invoicing'),
371
+                    'desc' => __('Validate VAT numbers with VIES.', 'invoicing'),
372 372
                     'type' => 'checkbox'
373 373
                 ),
374 374
 
375 375
                 'vat_same_country_rule' => array(
376 376
                     'id'          => 'vat_same_country_rule',
377
-                    'name'        => __( 'Same Country Rule', 'invoicing' ),
378
-                    'desc'        => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ),
377
+                    'name'        => __('Same Country Rule', 'invoicing'),
378
+                    'desc'        => __('What should happen if a customer is from the same country as your business?', 'invoicing'),
379 379
                     'type'        => 'select',
380 380
                     'options'     => array(
381
-                        'no'        => __( 'Do not charge Tax', 'invoicing' ),
382
-                        'always'    => __( 'Charge Tax', 'invoicing' ),
381
+                        'no'        => __('Do not charge Tax', 'invoicing'),
382
+                        'always'    => __('Charge Tax', 'invoicing'),
383 383
                     ),
384
-                    'placeholder' => __( 'Select an option', 'invoicing' ),
384
+                    'placeholder' => __('Select an option', 'invoicing'),
385 385
                     'std'         => 'always',
386 386
                 ),
387 387
 
@@ -395,68 +395,68 @@  discard block
 block discarded – undo
395 395
             'main' => array(
396 396
                 'email_settings_header' => array(
397 397
                     'id'   => 'email_settings_header',
398
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
398
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
399 399
                     'type' => 'header',
400 400
                 ),
401 401
                 'email_from_name' => array(
402 402
                     'id'   => 'email_from_name',
403
-                    'name' => __( 'From Name', 'invoicing' ),
404
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
405
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
403
+                    'name' => __('From Name', 'invoicing'),
404
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
405
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
406 406
                     'type' => 'text',
407 407
                 ),
408 408
                 'email_from' => array(
409 409
                     'id'   => 'email_from',
410
-                    'name' => __( 'From Email', 'invoicing' ),
411
-                    'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
412
-                    'std' => get_option( 'admin_email' ),
410
+                    'name' => __('From Email', 'invoicing'),
411
+                    'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
412
+                    'std' => get_option('admin_email'),
413 413
                     'type' => 'text',
414 414
                 ),
415 415
                 'admin_email' => array(
416 416
                     'id'   => 'admin_email',
417
-                    'name' => __( 'Admin Email', 'invoicing' ),
418
-                    'desc' => __( 'Where should we send admin notifications?', 'invoicing' ),
419
-                    'std' => get_option( 'admin_email' ),
417
+                    'name' => __('Admin Email', 'invoicing'),
418
+                    'desc' => __('Where should we send admin notifications?', 'invoicing'),
419
+                    'std' => get_option('admin_email'),
420 420
                     'type' => 'text',
421 421
                 ),
422 422
                 'overdue_settings_header' => array(
423 423
                     'id'   => 'overdue_settings_header',
424
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
424
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
425 425
                     'type' => 'header',
426 426
                 ),
427 427
                 'overdue_active' => array(
428 428
                     'id'   => 'overdue_active',
429
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
430
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
429
+                    'name' => __('Enable Due Date', 'invoicing'),
430
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
431 431
                     'type' => 'checkbox',
432 432
                     'std'  => false,
433 433
                 ),
434 434
                 'overdue_days' => array(
435 435
                     'id'          => 'overdue_days',
436
-                    'name'        => __( 'Default Due Date', 'invoicing' ),
437
-                    'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
436
+                    'name'        => __('Default Due Date', 'invoicing'),
437
+                    'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
438 438
                     'type'        => 'select',
439 439
                     'options'     => $due_payment_options,
440 440
                     'std'         => 0,
441
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
441
+                    'placeholder' => __('Select a page', 'invoicing'),
442 442
                 ),
443 443
                 'email_template_header' => array(
444 444
                     'id'   => 'email_template_header',
445
-                    'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
445
+                    'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
446 446
                     'type' => 'header',
447 447
                 ),
448 448
                 'email_header_image' => array(
449 449
                     'id'   => 'email_header_image',
450
-                    'name' => __( 'Header Image', 'invoicing' ),
451
-                    'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
450
+                    'name' => __('Header Image', 'invoicing'),
451
+                    'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
452 452
                     'std' => '',
453 453
                     'type' => 'text',
454 454
                 ),
455 455
                 'email_footer_text' => array(
456 456
                     'id'   => 'email_footer_text',
457
-                    'name' => __( 'Footer Text', 'invoicing' ),
458
-                    'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
459
-                    'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ),
457
+                    'name' => __('Footer Text', 'invoicing'),
458
+                    'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
459
+                    'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'),
460 460
                     'type' => 'textarea',
461 461
                     'class' => 'regular-text',
462 462
                     'rows' => 2,
@@ -464,29 +464,29 @@  discard block
 block discarded – undo
464 464
                 ),
465 465
                 'email_base_color' => array(
466 466
                     'id'   => 'email_base_color',
467
-                    'name' => __( 'Base Color', 'invoicing' ),
468
-                    'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
467
+                    'name' => __('Base Color', 'invoicing'),
468
+                    'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
469 469
                     'std' => '#557da2',
470 470
                     'type' => 'color',
471 471
                 ),
472 472
                 'email_background_color' => array(
473 473
                     'id'   => 'email_background_color',
474
-                    'name' => __( 'Background Color', 'invoicing' ),
475
-                    'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
474
+                    'name' => __('Background Color', 'invoicing'),
475
+                    'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
476 476
                     'std' => '#f5f5f5',
477 477
                     'type' => 'color',
478 478
                 ),
479 479
                 'email_body_background_color' => array(
480 480
                     'id'   => 'email_body_background_color',
481
-                    'name' => __( 'Body Background Color', 'invoicing' ),
482
-                    'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
481
+                    'name' => __('Body Background Color', 'invoicing'),
482
+                    'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
483 483
                     'std' => '#fdfdfd',
484 484
                     'type' => 'color',
485 485
                 ),
486 486
                 'email_text_color' => array(
487 487
                     'id'   => 'email_text_color',
488
-                    'name' => __( 'Body Text Color', 'invoicing' ),
489
-                    'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
488
+                    'name' => __('Body Text Color', 'invoicing'),
489
+                    'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
490 490
                     'std' => '#505050',
491 491
                     'type' => 'color',
492 492
                 ),
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
     ),
502 502
 
503 503
     // Integrations.
504
-    'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ),
504
+    'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'),
505 505
 
506 506
     /** Privacy Settings */
507 507
     'privacy' => apply_filters('wpinv_settings_privacy',
@@ -509,17 +509,17 @@  discard block
 block discarded – undo
509 509
             'main' => array(
510 510
                 'invoicing_privacy_policy_settings' => array(
511 511
                     'id'   => 'invoicing_privacy_policy_settings',
512
-                    'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
512
+                    'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
513 513
                     'type' => 'header',
514 514
                 ),
515 515
                 'privacy_page' => array(
516 516
                     'id'          => 'privacy_page',
517
-                    'name'        => __( 'Privacy Page', 'invoicing' ),
518
-                    'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
517
+                    'name'        => __('Privacy Page', 'invoicing'),
518
+                    'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
519 519
                     'type'        => 'select',
520
-                    'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
520
+                    'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
521 521
                     'class'       => 'wpi_select2',
522
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
522
+                    'placeholder' => __('Select a page', 'invoicing'),
523 523
                 ),
524 524
             ),
525 525
         )
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
             'main' => array(
531 531
                 'invoice_number_format_settings' => array(
532 532
                     'id'   => 'invoice_number_format_settings',
533
-                    'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
533
+                    'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
534 534
                     'type' => 'header',
535 535
                 ),
536 536
                 'sequential_invoice_number' => array(
537 537
                     'id'   => 'sequential_invoice_number',
538
-                    'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
539
-                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
538
+                    'name' => __('Sequential Invoice Numbers', 'invoicing'),
539
+                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
540 540
                     'type' => 'checkbox',
541 541
                 ),
542 542
                 'invoice_sequence_start' => array(
543 543
                     'id'   => 'invoice_sequence_start',
544
-                    'name' => __( 'Sequential Starting Number', 'invoicing' ),
545
-                    'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
544
+                    'name' => __('Sequential Starting Number', 'invoicing'),
545
+                    'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
546 546
                     'type' => 'number',
547 547
                     'size' => 'small',
548 548
                     'std'  => '1',
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
                 ),
551 551
                 'invoice_number_padd' => array(
552 552
                     'id'      => 'invoice_number_padd',
553
-                    'name'    => __( 'Minimum Digits', 'invoicing' ),
554
-                    'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
553
+                    'name'    => __('Minimum Digits', 'invoicing'),
554
+                    'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
555 555
                     'type'    => 'select',
556 556
                     'options' => $invoice_number_padd_options,
557 557
                     'std'     => 5,
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
                 ),
560 560
                 'invoice_number_prefix' => array(
561 561
                     'id' => 'invoice_number_prefix',
562
-                    'name' => __( 'Invoice Number Prefix', 'invoicing' ),
563
-                    'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
562
+                    'name' => __('Invoice Number Prefix', 'invoicing'),
563
+                    'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
564 564
                     'type' => 'text',
565 565
                     'size' => 'regular',
566 566
                     'std' => 'INV-',
@@ -568,41 +568,41 @@  discard block
 block discarded – undo
568 568
                 ),
569 569
                 'invoice_number_postfix' => array(
570 570
                     'id' => 'invoice_number_postfix',
571
-                    'name' => __( 'Invoice Number Postfix', 'invoicing' ),
572
-                    'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
571
+                    'name' => __('Invoice Number Postfix', 'invoicing'),
572
+                    'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
573 573
                     'type' => 'text',
574 574
                     'size' => 'regular',
575 575
                     'std' => ''
576 576
                 ),
577 577
                 'checkout_settings' => array(
578 578
                     'id'   => 'checkout_settings',
579
-                    'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
579
+                    'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
580 580
                     'type' => 'header',
581 581
                 ),
582 582
                 'login_to_checkout' => array(
583 583
                     'id'   => 'login_to_checkout',
584
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
585
-                    'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
584
+                    'name' => __('Require Login To Checkout', 'invoicing'),
585
+                    'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
586 586
                     'type' => 'checkbox',
587 587
                 ),
588 588
 
589 589
                 'maxmind_license_key' => array(
590 590
                     'id'   => 'maxmind_license_key',
591
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
591
+                    'name' => __('MaxMind License Key', 'invoicing'),
592 592
                     'type' => 'text',
593 593
                     'size' => 'regular',
594
-                    'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>',
594
+                    'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>',
595 595
                 ),
596 596
 
597 597
                 'uninstall_settings' => array(
598 598
                     'id'   => 'uninstall_settings',
599
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
599
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
600 600
                     'type' => 'header',
601 601
                 ),
602 602
                 'remove_data_on_unistall' => array(
603 603
                     'id'   => 'remove_data_on_unistall',
604
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
605
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
604
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
605
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
606 606
                     'type' => 'checkbox',
607 607
                     'std'  => ''
608 608
                 ),
@@ -611,13 +611,13 @@  discard block
 block discarded – undo
611 611
             'custom-css' => array(
612 612
                 'css_settings' => array(
613 613
                     'id'   => 'css_settings',
614
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
614
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
615 615
                     'type' => 'header',
616 616
                 ),
617 617
                 'template_custom_css' => array(
618 618
                     'id' => 'template_custom_css',
619
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
620
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
619
+                    'name' => __('Invoice Template CSS', 'invoicing'),
620
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
621 621
                     'type' => 'textarea',
622 622
                     'class'=> 'regular-text',
623 623
                     'rows' => 10,
@@ -631,8 +631,8 @@  discard block
 block discarded – undo
631 631
             'main' => array(
632 632
                 'tool_settings' => array(
633 633
                     'id'   => 'tool_settings',
634
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
635
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
634
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
635
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
636 636
                     'type' => 'tools',
637 637
                 ),
638 638
             ),
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@  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
 /**
@@ -49,139 +49,139 @@  discard block
 block discarded – undo
49 49
  * @param string $post_type The post type or invoice type.
50 50
  * @return string The history page URL.
51 51
  */
52
-function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) {
53
-    $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) );
54
-	$page_id   = wpinv_get_option( "{$post_type}_history_page", 0 );
55
-	$page_id   = absint( $page_id );
56
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type );
52
+function wpinv_get_history_page_uri($post_type = 'wpi_invoice') {
53
+    $post_type = sanitize_key(str_replace('wpi_', '', $post_type));
54
+	$page_id   = wpinv_get_option("{$post_type}_history_page", 0);
55
+	$page_id   = absint($page_id);
56
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type);
57 57
 }
58 58
 
59 59
 function wpinv_is_success_page() {
60
-	$is_success_page = wpinv_get_option( 'success_page', false );
61
-	$is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
60
+	$is_success_page = wpinv_get_option('success_page', false);
61
+	$is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false;
62 62
 
63
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
63
+	return apply_filters('wpinv_is_success_page', $is_success_page);
64 64
 }
65 65
 
66 66
 function wpinv_is_invoice_history_page() {
67
-	$ret = wpinv_get_option( 'invoice_history_page', false );
68
-	$ret = $ret ? is_page( $ret ) : false;
69
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
67
+	$ret = wpinv_get_option('invoice_history_page', false);
68
+	$ret = $ret ? is_page($ret) : false;
69
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
70 70
 }
71 71
 
72 72
 function wpinv_is_subscriptions_history_page() {
73
-    $ret = wpinv_get_option( 'invoice_subscription_page', false );
74
-    $ret = $ret ? is_page( $ret ) : false;
75
-    return apply_filters( 'wpinv_is_subscriptions_history_page', $ret );
73
+    $ret = wpinv_get_option('invoice_subscription_page', false);
74
+    $ret = $ret ? is_page($ret) : false;
75
+    return apply_filters('wpinv_is_subscriptions_history_page', $ret);
76 76
 }
77 77
 
78 78
 /**
79 79
  * Redirects a user the success page.
80 80
  */
81
-function wpinv_send_to_success_page( $args = array() ) {
81
+function wpinv_send_to_success_page($args = array()) {
82 82
 
83 83
     $redirect = add_query_arg(
84
-        wp_parse_args( $args ),
84
+        wp_parse_args($args),
85 85
         wpinv_get_success_page_uri()
86 86
     );
87 87
 
88
-    $redirect = apply_filters( 'wpinv_send_to_success_page_url', $redirect, $args );
88
+    $redirect = apply_filters('wpinv_send_to_success_page_url', $redirect, $args);
89 89
 
90
-    wp_redirect( $redirect );
90
+    wp_redirect($redirect);
91 91
     exit;
92 92
 }
93 93
 
94
-function wpinv_send_to_failed_page( $args = null ) {
94
+function wpinv_send_to_failed_page($args = null) {
95 95
 	$redirect = wpinv_get_failed_transaction_uri();
96 96
     
97
-    if ( !empty( $args ) ) {
97
+    if (!empty($args)) {
98 98
         // Check for backward compatibility
99
-        if ( is_string( $args ) )
100
-            $args = str_replace( '?', '', $args );
99
+        if (is_string($args))
100
+            $args = str_replace('?', '', $args);
101 101
 
102
-        $args = wp_parse_args( $args );
102
+        $args = wp_parse_args($args);
103 103
 
104
-        $redirect = add_query_arg( $args, $redirect );
104
+        $redirect = add_query_arg($args, $redirect);
105 105
     }
106 106
 
107
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
107
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
108 108
     
109
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
110
-    wp_redirect( $redirect );
109
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
110
+    wp_redirect($redirect);
111 111
     exit;
112 112
 }
113 113
 
114
-function wpinv_get_checkout_uri( $args = array() ) {
115
-	$uri = wpinv_get_option( 'checkout_page', false );
116
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
114
+function wpinv_get_checkout_uri($args = array()) {
115
+	$uri = wpinv_get_option('checkout_page', false);
116
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
117 117
 
118
-	if ( !empty( $args ) ) {
118
+	if (!empty($args)) {
119 119
 		// Check for backward compatibility
120
-		if ( is_string( $args ) )
121
-			$args = str_replace( '?', '', $args );
120
+		if (is_string($args))
121
+			$args = str_replace('?', '', $args);
122 122
 
123
-		$args = wp_parse_args( $args );
123
+		$args = wp_parse_args($args);
124 124
 
125
-		$uri = add_query_arg( $args, $uri );
125
+		$uri = add_query_arg($args, $uri);
126 126
 	}
127 127
 
128
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
128
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
129 129
 
130
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
130
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
131 131
 
132
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
133
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
132
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
133
+		$uri = preg_replace('/^http:/', 'https:', $uri);
134 134
 	}
135 135
 
136
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
136
+	return apply_filters('wpinv_get_checkout_uri', $uri);
137 137
 }
138 138
 
139
-function wpinv_get_success_page_url( $query_string = null ) {
140
-	$success_page = wpinv_get_option( 'success_page', 0 );
141
-	$success_page = get_permalink( $success_page );
139
+function wpinv_get_success_page_url($query_string = null) {
140
+	$success_page = wpinv_get_option('success_page', 0);
141
+	$success_page = get_permalink($success_page);
142 142
 
143
-	if ( $query_string )
143
+	if ($query_string)
144 144
 		$success_page .= $query_string;
145 145
 
146
-	return apply_filters( 'wpinv_success_page_url', $success_page );
146
+	return apply_filters('wpinv_success_page_url', $success_page);
147 147
 }
148 148
 
149
-function wpinv_get_failed_transaction_uri( $extras = false ) {
150
-	$uri = wpinv_get_option( 'failure_page', '' );
151
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
149
+function wpinv_get_failed_transaction_uri($extras = false) {
150
+	$uri = wpinv_get_option('failure_page', '');
151
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
152 152
 
153
-	if ( $extras )
153
+	if ($extras)
154 154
 		$uri .= $extras;
155 155
 
156
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
156
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
157 157
 }
158 158
 
159 159
 function wpinv_is_failed_transaction_page() {
160
-	$ret = wpinv_get_option( 'failure_page', false );
161
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
160
+	$ret = wpinv_get_option('failure_page', false);
161
+	$ret = isset($ret) ? is_page($ret) : false;
162 162
 
163
-	return apply_filters( 'wpinv_is_failure_page', $ret );
163
+	return apply_filters('wpinv_is_failure_page', $ret);
164 164
 }
165 165
 
166
-function wpinv_transaction_query( $type = 'start' ) {
166
+function wpinv_transaction_query($type = 'start') {
167 167
     global $wpdb;
168 168
 
169 169
     $wpdb->hide_errors();
170 170
 
171
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
172
-        define( 'WPINV_USE_TRANSACTIONS', true );
171
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
172
+        define('WPINV_USE_TRANSACTIONS', true);
173 173
     }
174 174
 
175
-    if ( WPINV_USE_TRANSACTIONS ) {
176
-        switch ( $type ) {
175
+    if (WPINV_USE_TRANSACTIONS) {
176
+        switch ($type) {
177 177
             case 'commit' :
178
-                $wpdb->query( 'COMMIT' );
178
+                $wpdb->query('COMMIT');
179 179
                 break;
180 180
             case 'rollback' :
181
-                $wpdb->query( 'ROLLBACK' );
181
+                $wpdb->query('ROLLBACK');
182 182
                 break;
183 183
             default :
184
-                $wpdb->query( 'START TRANSACTION' );
184
+                $wpdb->query('START TRANSACTION');
185 185
             break;
186 186
         }
187 187
     }
@@ -190,141 +190,141 @@  discard block
 block discarded – undo
190 190
 function wpinv_get_prefix() {
191 191
     $invoice_prefix = 'INV-';
192 192
     
193
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
193
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
194 194
 }
195 195
 
196 196
 function wpinv_get_business_logo() {
197
-    $business_logo = wpinv_get_option( 'logo' );
198
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
197
+    $business_logo = wpinv_get_option('logo');
198
+    return apply_filters('wpinv_get_business_logo', $business_logo);
199 199
 }
200 200
 
201 201
 function wpinv_get_business_name() {
202
-    $business_name = wpinv_get_option('store_name', wpinv_get_blogname() );
203
-    return apply_filters( 'wpinv_get_business_name', $business_name );
202
+    $business_name = wpinv_get_option('store_name', wpinv_get_blogname());
203
+    return apply_filters('wpinv_get_business_name', $business_name);
204 204
 }
205 205
 
206 206
 function wpinv_get_blogname() {
207
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
207
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
208 208
 }
209 209
 
210 210
 function wpinv_get_admin_email() {
211
-    $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) );
212
-    return apply_filters( 'wpinv_admin_email', $admin_email );
211
+    $admin_email = wpinv_get_option('admin_email', get_option('admin_email'));
212
+    return apply_filters('wpinv_admin_email', $admin_email);
213 213
 }
214 214
 
215 215
 function wpinv_get_business_website() {
216
-    $business_website = home_url( '/' );
217
-    return apply_filters( 'wpinv_get_business_website', $business_website );
216
+    $business_website = home_url('/');
217
+    return apply_filters('wpinv_get_business_website', $business_website);
218 218
 }
219 219
 
220
-function wpinv_get_terms_text( $invoice_id = 0 ) {
220
+function wpinv_get_terms_text($invoice_id = 0) {
221 221
     $terms_text = '';
222
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
222
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
223 223
 }
224 224
 
225 225
 function wpinv_get_business_footer() {
226
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
227
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
228
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
226
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
227
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
228
+    return apply_filters('wpinv_get_business_footer', $business_footer);
229 229
 }
230 230
 
231 231
 function wpinv_checkout_required_fields() {
232 232
     $required_fields = array();
233 233
     
234 234
     // Let payment gateways and other extensions determine if address fields should be required
235
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
235
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
236 236
     
237
-    if ( $require_billing_details ) {
238
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
237
+    if ($require_billing_details) {
238
+		if ((bool) wpinv_get_option('fname_mandatory')) {
239 239
 			$required_fields['first_name'] = array(
240 240
 				'error_id' => 'invalid_first_name',
241
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
241
+				'error_message' => __('Please enter your first name', 'invoicing')
242 242
 			);
243 243
 		}
244
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
244
+		if ((bool) wpinv_get_option('address_mandatory')) {
245 245
 			$required_fields['address'] = array(
246 246
 				'error_id' => 'invalid_address',
247
-				'error_message' => __( 'Please enter your address', 'invoicing' )
247
+				'error_message' => __('Please enter your address', 'invoicing')
248 248
 			);
249 249
 		}
250
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
250
+		if ((bool) wpinv_get_option('city_mandatory')) {
251 251
 			$required_fields['city'] = array(
252 252
 				'error_id' => 'invalid_city',
253
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
253
+				'error_message' => __('Please enter your billing city', 'invoicing')
254 254
 			);
255 255
 		}
256
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
256
+		if ((bool) wpinv_get_option('state_mandatory')) {
257 257
 			$required_fields['state'] = array(
258 258
 				'error_id' => 'invalid_state',
259
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
259
+				'error_message' => __('Please enter billing state / province', 'invoicing')
260 260
 			);
261 261
 		}
262
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
262
+		if ((bool) wpinv_get_option('country_mandatory')) {
263 263
 			$required_fields['country'] = array(
264 264
 				'error_id' => 'invalid_country',
265
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
265
+				'error_message' => __('Please select your billing country', 'invoicing')
266 266
 			);
267 267
 		}
268 268
     }
269 269
 
270
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
270
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
271 271
 }
272 272
 
273 273
 function wpinv_is_ssl_enforced() {
274
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
275
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
274
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
275
+    return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
276 276
 }
277 277
 
278 278
 function wpinv_schedule_event_twicedaily() {
279 279
     wpinv_email_payment_reminders();
280 280
 }
281
-add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' );
281
+add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily');
282 282
 
283 283
 function wpinv_require_login_to_checkout() {
284
-    $return = wpinv_get_option( 'login_to_checkout', false );
285
-    return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return );
284
+    $return = wpinv_get_option('login_to_checkout', false);
285
+    return (bool) apply_filters('wpinv_require_login_to_checkout', $return);
286 286
 }
287 287
 
288
-function wpinv_sequential_number_active( $type = '' ) {
289
-    $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type );
290
-    if ( null !== $check ) {
288
+function wpinv_sequential_number_active($type = '') {
289
+    $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type);
290
+    if (null !== $check) {
291 291
         return $check;
292 292
     }
293 293
     
294
-    return wpinv_get_option( 'sequential_invoice_number' );
294
+    return wpinv_get_option('sequential_invoice_number');
295 295
 }
296 296
 
297
-function wpinv_switch_to_locale( $locale = NULL ) {
297
+function wpinv_switch_to_locale($locale = NULL) {
298 298
     global $invoicing, $wpi_switch_locale;
299 299
 
300
-    if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) {
301
-        $locale = empty( $locale ) ? get_locale() : $locale;
300
+    if (!empty($invoicing) && function_exists('switch_to_locale')) {
301
+        $locale = empty($locale) ? get_locale() : $locale;
302 302
 
303
-        switch_to_locale( $locale );
303
+        switch_to_locale($locale);
304 304
 
305 305
         $wpi_switch_locale = $locale;
306 306
 
307
-        add_filter( 'plugin_locale', 'get_locale' );
307
+        add_filter('plugin_locale', 'get_locale');
308 308
 
309 309
         $invoicing->load_textdomain();
310 310
 
311
-        do_action( 'wpinv_switch_to_locale', $locale );
311
+        do_action('wpinv_switch_to_locale', $locale);
312 312
     }
313 313
 }
314 314
 
315 315
 function wpinv_restore_locale() {
316 316
     global $invoicing, $wpi_switch_locale;
317 317
     
318
-    if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) {
318
+    if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) {
319 319
         restore_previous_locale();
320 320
 
321 321
         $wpi_switch_locale = NULL;
322 322
 
323
-        remove_filter( 'plugin_locale', 'get_locale' );
323
+        remove_filter('plugin_locale', 'get_locale');
324 324
 
325 325
         $invoicing->load_textdomain();
326 326
 
327
-        do_action( 'wpinv_restore_locale' );
327
+        do_action('wpinv_restore_locale');
328 328
     }
329 329
 }
330 330
 
@@ -332,22 +332,22 @@  discard block
 block discarded – undo
332 332
  * Returns the default form's id.
333 333
  */
334 334
 function wpinv_get_default_payment_form() {
335
-    $form = get_option( 'wpinv_default_payment_form' );
335
+    $form = get_option('wpinv_default_payment_form');
336 336
 
337
-    if ( empty( $form ) || 'publish' != get_post_status( $form ) ) {
337
+    if (empty($form) || 'publish' != get_post_status($form)) {
338 338
         $form = wp_insert_post(
339 339
             array(
340 340
                 'post_type'   => 'wpi_payment_form',
341
-                'post_title'  => __( 'Checkout (default)', 'invoicing' ),
341
+                'post_title'  => __('Checkout (default)', 'invoicing'),
342 342
                 'post_status' => 'publish',
343 343
                 'meta_input'  => array(
344
-                    'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ),
344
+                    'wpinv_form_elements' => wpinv_get_data('default-payment-form'),
345 345
                     'wpinv_form_items'    => array(),
346 346
                 )
347 347
             )
348 348
         );
349 349
 
350
-        update_option( 'wpinv_default_payment_form', $form );
350
+        update_option('wpinv_default_payment_form', $form);
351 351
     }
352 352
 
353 353
     return $form;
@@ -358,19 +358,19 @@  discard block
 block discarded – undo
358 358
  * 
359 359
  * @param int $payment_form
360 360
  */
361
-function getpaid_get_payment_form_elements( $payment_form ) {
361
+function getpaid_get_payment_form_elements($payment_form) {
362 362
 
363
-    if ( empty( $payment_form ) ) {
364
-        return wpinv_get_data( 'sample-payment-form' );
363
+    if (empty($payment_form)) {
364
+        return wpinv_get_data('sample-payment-form');
365 365
     }
366 366
 
367
-    $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true );
367
+    $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true);
368 368
 
369
-    if ( is_array( $form_elements ) ) {
369
+    if (is_array($form_elements)) {
370 370
         return $form_elements;
371 371
     }
372 372
 
373
-    return wpinv_get_data( 'sample-payment-form' );
373
+    return wpinv_get_data('sample-payment-form');
374 374
 
375 375
 }
376 376
 
@@ -379,13 +379,13 @@  discard block
 block discarded – undo
379 379
  * 
380 380
  * @param int $payment_form
381 381
  */
382
-function gepaid_get_form_items( $id ) {
383
-    $form = new GetPaid_Payment_Form( $id );
382
+function gepaid_get_form_items($id) {
383
+    $form = new GetPaid_Payment_Form($id);
384 384
 
385 385
     // Is this a default form?
386
-    if ( $form->is_default() ) {
386
+    if ($form->is_default()) {
387 387
         return array();
388 388
     }
389 389
 
390
-    return $form->get_items( 'view', 'arrays' );
390
+    return $form->get_items('view', 'arrays');
391 391
 }
Please login to merge, or discard this patch.