Passed
Push — master ( 793ba2...ec3085 )
by Brian
05:23
created
includes/payments/class-getpaid-checkout.php 2 patches
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -12,180 +12,180 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Checkout {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Payment_Form_Submission
17
-	 */
18
-	protected $payment_form_submission;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 * 
23
-	 * @param GetPaid_Payment_Form_Submission $submission
24
-	 */
25
-	public function __construct( $submission ) {
26
-		$this->payment_form_submission = $submission;
27
-	}
28
-
29
-	/**
30
-	 * Processes the checkout.
31
-	 *
32
-	 */
33
-	public function process_checkout() {
34
-
35
-		// Validate the submission.
36
-		$this->validate_submission();
37
-
38
-		// Prepare the invoice.
39
-		$items      = $this->get_submission_items();
40
-		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
42
-		$prepared   = $this->prepare_submission_data_for_saving();
43
-
44
-		$this->prepare_billing_info( $invoice );
45
-
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
47
-
48
-		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
50
-		$invoice->recalculate_total();
15
+    /**
16
+     * @var GetPaid_Payment_Form_Submission
17
+     */
18
+    protected $payment_form_submission;
19
+
20
+    /**
21
+     * Class constructor.
22
+     * 
23
+     * @param GetPaid_Payment_Form_Submission $submission
24
+     */
25
+    public function __construct( $submission ) {
26
+        $this->payment_form_submission = $submission;
27
+    }
28
+
29
+    /**
30
+     * Processes the checkout.
31
+     *
32
+     */
33
+    public function process_checkout() {
34
+
35
+        // Validate the submission.
36
+        $this->validate_submission();
37
+
38
+        // Prepare the invoice.
39
+        $items      = $this->get_submission_items();
40
+        $invoice    = $this->get_submission_invoice();
41
+        $invoice    = $this->process_submission_invoice( $invoice, $items );
42
+        $prepared   = $this->prepare_submission_data_for_saving();
43
+
44
+        $this->prepare_billing_info( $invoice );
45
+
46
+        $shipping   = $this->prepare_shipping_info( $invoice );
47
+
48
+        // Save the invoice.
49
+        $invoice->set_is_viewed( true );
50
+        $invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+        do_action( 'getpaid_checkout_invoice_updated', $invoice );
54 54
 
55
-		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
57
-	}
55
+        // Send to the gateway.
56
+        $this->post_process_submission( $invoice, $prepared, $shipping );
57
+    }
58 58
 
59
-	/**
60
-	 * Validates the submission.
61
-	 *
62
-	 */
63
-	protected function validate_submission() {
59
+    /**
60
+     * Validates the submission.
61
+     *
62
+     */
63
+    protected function validate_submission() {
64 64
 
65
-		$submission = $this->payment_form_submission;
66
-		$data       = $submission->get_data();
65
+        $submission = $this->payment_form_submission;
66
+        $data       = $submission->get_data();
67 67
 
68
-		// Do we have an error?
68
+        // Do we have an error?
69 69
         if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
70
+            wp_send_json_error( $submission->last_error );
71 71
         }
72 72
 
73
-		// We need a billing email.
73
+        // We need a billing email.
74 74
         if ( ! $submission->has_billing_email() ) {
75 75
             wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
76
-		}
76
+        }
77 77
 
78
-		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
-		}
78
+        // Non-recurring gateways should not be allowed to process recurring invoices.
79
+        if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
+            wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
+        }
82 82
 
83
-		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
86
-		}
83
+        // Ensure the gateway is active.
84
+        if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
+            wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
86
+        }
87 87
 
88
-		// Clear any existing errors.
89
-		wpinv_clear_errors();
88
+        // Clear any existing errors.
89
+        wpinv_clear_errors();
90 90
 
91
-		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
91
+        // Allow themes and plugins to hook to errors
92
+        do_action( 'getpaid_checkout_error_checks', $submission );
93 93
 
94
-		// Do we have any errors?
94
+        // Do we have any errors?
95 95
         if ( wpinv_get_errors() ) {
96 96
             wp_send_json_error( getpaid_get_errors_html() );
97
-		}
97
+        }
98 98
 
99
-	}
99
+    }
100 100
 
101
-	/**
102
-	 * Retrieves submission items.
103
-	 *
104
-	 * @return GetPaid_Form_Item[]
105
-	 */
106
-	protected function get_submission_items() {
101
+    /**
102
+     * Retrieves submission items.
103
+     *
104
+     * @return GetPaid_Form_Item[]
105
+     */
106
+    protected function get_submission_items() {
107 107
 
108
-		$items = $this->payment_form_submission->get_items();
108
+        $items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111 111
         if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112 112
             wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
113
-		}
114
-
115
-		return $items;
116
-	}
117
-
118
-	/**
119
-	 * Retrieves submission invoice.
120
-	 *
121
-	 * @return WPInv_Invoice
122
-	 */
123
-	protected function get_submission_invoice() {
124
-		$submission = $this->payment_form_submission;
125
-
126
-		if ( ! $submission->has_invoice() ) {
127
-			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
129
-			return $invoice;
130 113
         }
131 114
 
132
-		$invoice = $submission->get_invoice();
115
+        return $items;
116
+    }
133 117
 
134
-		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
-		}
118
+    /**
119
+     * Retrieves submission invoice.
120
+     *
121
+     * @return WPInv_Invoice
122
+     */
123
+    protected function get_submission_invoice() {
124
+        $submission = $this->payment_form_submission;
138 125
 
139
-		return $invoice;
140
-	}
126
+        if ( ! $submission->has_invoice() ) {
127
+            $invoice = new WPInv_Invoice();
128
+            $invoice->set_created_via( 'payment_form' );
129
+            return $invoice;
130
+        }
141 131
 
142
-	/**
143
-	 * Processes the submission invoice.
144
-	 *
145
-	 * @param WPInv_Invoice $invoice
146
-	 * @param GetPaid_Form_Item[] $items
147
-	 * @return WPInv_Invoice
148
-	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
132
+        $invoice = $submission->get_invoice();
150 133
 
151
-		$submission = $this->payment_form_submission;
152
-		$data       = $submission->get_data();
134
+        // Make sure that it is neither paid or refunded.
135
+        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
+            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
+        }
153 138
 
154
-		// Set-up the invoice details.
155
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
156
-		$invoice->set_user_id( $this->get_submission_customer() );
157
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
139
+        return $invoice;
140
+    }
141
+
142
+    /**
143
+     * Processes the submission invoice.
144
+     *
145
+     * @param WPInv_Invoice $invoice
146
+     * @param GetPaid_Form_Item[] $items
147
+     * @return WPInv_Invoice
148
+     */
149
+    protected function process_submission_invoice( $invoice, $items ) {
150
+
151
+        $submission = $this->payment_form_submission;
152
+        $data       = $submission->get_data();
153
+
154
+        // Set-up the invoice details.
155
+        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
156
+        $invoice->set_user_id( $this->get_submission_customer() );
157
+        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
158 158
         $invoice->set_items( $items );
159 159
         $invoice->set_fees( $submission->get_fees() );
160 160
         $invoice->set_taxes( $submission->get_taxes() );
161
-		$invoice->set_discounts( $submission->get_discounts() );
162
-		$invoice->set_gateway( $data['wpi-gateway'] );
161
+        $invoice->set_discounts( $submission->get_discounts() );
162
+        $invoice->set_gateway( $data['wpi-gateway'] );
163 163
 
164
-		$address_confirmed = $submission->get_field( 'confirm-address' );
165
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
164
+        $address_confirmed = $submission->get_field( 'confirm-address' );
165
+        $invoice->set_address_confirmed( ! empty( $address_confirmed ) );
166 166
 
167
-		if ( $submission->has_discount_code() ) {
167
+        if ( $submission->has_discount_code() ) {
168 168
             $invoice->set_discount_code( $submission->get_discount_code() );
169
-		}
170
-
171
-		getpaid_maybe_add_default_address( $invoice );
172
-		return $invoice;
173
-	}
174
-
175
-	/**
176
-	 * Retrieves the submission's customer.
177
-	 *
178
-	 * @return int The customer id.
179
-	 */
180
-	protected function get_submission_customer() {
181
-		$submission = $this->payment_form_submission;
182
-
183
-		// If this is an existing invoice...
184
-		if ( $submission->has_invoice() ) {
185
-			return $submission->get_invoice()->get_user_id();
186
-		}
187
-
188
-		// (Maybe) create the user.
169
+        }
170
+
171
+        getpaid_maybe_add_default_address( $invoice );
172
+        return $invoice;
173
+    }
174
+
175
+    /**
176
+     * Retrieves the submission's customer.
177
+     *
178
+     * @return int The customer id.
179
+     */
180
+    protected function get_submission_customer() {
181
+        $submission = $this->payment_form_submission;
182
+
183
+        // If this is an existing invoice...
184
+        if ( $submission->has_invoice() ) {
185
+            return $submission->get_invoice()->get_user_id();
186
+        }
187
+
188
+        // (Maybe) create the user.
189 189
         $user = get_current_user_id();
190 190
 
191 191
         if ( empty( $user ) ) {
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
         if ( empty( $user ) ) {
196 196
             $user = wpinv_create_user( $submission->get_billing_email() );
197 197
 
198
-			// (Maybe) send new user notification.
199
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
201
-				wp_send_new_user_notifications( $user, 'user' );
202
-			}
198
+            // (Maybe) send new user notification.
199
+            $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
+            if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
201
+                wp_send_new_user_notifications( $user, 'user' );
202
+            }
203 203
 
204 204
         }
205 205
 
@@ -209,31 +209,31 @@  discard block
 block discarded – undo
209 209
 
210 210
         if ( is_numeric( $user ) ) {
211 211
             return $user;
212
-		}
212
+        }
213 213
 
214
-		return $user->ID;
214
+        return $user->ID;
215 215
 
216
-	}
216
+    }
217 217
 
218
-	/**
218
+    /**
219 219
      * Prepares submission data for saving to the database.
220 220
      *
221
-	 * @return array
221
+     * @return array
222 222
      */
223 223
     public function prepare_submission_data_for_saving() {
224 224
 
225
-		$submission = $this->payment_form_submission;
225
+        $submission = $this->payment_form_submission;
226 226
 
227
-		// Prepared submission details.
227
+        // Prepared submission details.
228 228
         $prepared = array();
229 229
 
230 230
         // Raw submission details.
231
-		$data     = $submission->get_data();
231
+        $data     = $submission->get_data();
232 232
 
233
-		// Loop through the submitted details.
233
+        // Loop through the submitted details.
234 234
         foreach ( $submission->get_payment_form()->get_elements() as $field ) {
235 235
 
236
-			// Skip premade fields.
236
+            // Skip premade fields.
237 237
             if ( ! empty( $field['premade'] ) || $field['type'] == 'address' ) {
238 238
                 continue;
239 239
             }
@@ -251,176 +251,176 @@  discard block
 block discarded – undo
251 251
                     $label = $field['label'];
252 252
                 }
253 253
 
254
-				$prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] );
254
+                $prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] );
255 255
 
256 256
             }
257 257
 
258
-		}
258
+        }
259 259
 
260
-		return $prepared;
260
+        return $prepared;
261 261
 
262
-	}
262
+    }
263 263
 
264
-	/**
264
+    /**
265 265
      * Retrieves address details.
266 266
      *
267
-	 * @return array
268
-	 * @param WPInv_Invoice $invoice
269
-	 * @param string $type
267
+     * @return array
268
+     * @param WPInv_Invoice $invoice
269
+     * @param string $type
270 270
      */
271 271
     public function prepare_address_details( $invoice, $type = 'billing' ) {
272 272
 
273
-		$data     = $this->payment_form_submission->get_data();
274
-		$type     = sanitize_key( $type );
275
-		$address  = array();
276
-		$prepared = array();
273
+        $data     = $this->payment_form_submission->get_data();
274
+        $type     = sanitize_key( $type );
275
+        $address  = array();
276
+        $prepared = array();
277 277
 
278
-		if ( ! empty( $data[ $type ] ) ) {
279
-			$address = $data[ $type ];
280
-		}
278
+        if ( ! empty( $data[ $type ] ) ) {
279
+            $address = $data[ $type ];
280
+        }
281 281
 
282
-		// Clean address details.
283
-		foreach ( $address as $key => $value ) {
284
-			$key             = sanitize_key( $key );
285
-			$key             = str_replace( 'wpinv_', '', $key );
286
-			$value           = wpinv_clean( $value );
287
-			$prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
288
-		}
282
+        // Clean address details.
283
+        foreach ( $address as $key => $value ) {
284
+            $key             = sanitize_key( $key );
285
+            $key             = str_replace( 'wpinv_', '', $key );
286
+            $value           = wpinv_clean( $value );
287
+            $prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
288
+        }
289 289
 
290
-		// Filter address details.
291
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
290
+        // Filter address details.
291
+        $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
292 292
 
293
-		// Remove non-whitelisted values.
294
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
293
+        // Remove non-whitelisted values.
294
+        return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
295 295
 
296
-	}
296
+    }
297 297
 
298
-	/**
298
+    /**
299 299
      * Prepares the billing details.
300 300
      *
301
-	 * @return array
302
-	 * @param WPInv_Invoice $invoice
301
+     * @return array
302
+     * @param WPInv_Invoice $invoice
303 303
      */
304 304
     protected function prepare_billing_info( &$invoice ) {
305 305
 
306
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
306
+        $billing_address = $this->prepare_address_details( $invoice, 'billing' );
307 307
 
308
-		// Update the invoice with the billing details.
309
-		$invoice->set_props( $billing_address );
308
+        // Update the invoice with the billing details.
309
+        $invoice->set_props( $billing_address );
310 310
 
311
-	}
311
+    }
312 312
 
313
-	/**
313
+    /**
314 314
      * Prepares the shipping details.
315 315
      *
316
-	 * @return array
317
-	 * @param WPInv_Invoice $invoice
316
+     * @return array
317
+     * @param WPInv_Invoice $invoice
318 318
      */
319 319
     protected function prepare_shipping_info( $invoice ) {
320 320
 
321
-		$data = $this->payment_form_submission->get_data();
321
+        $data = $this->payment_form_submission->get_data();
322 322
 
323
-		if ( empty( $data['same-shipping-address'] ) ) {
324
-			return $this->prepare_address_details( $invoice, 'shipping' );
325
-		}
323
+        if ( empty( $data['same-shipping-address'] ) ) {
324
+            return $this->prepare_address_details( $invoice, 'shipping' );
325
+        }
326 326
 
327
-		return $this->prepare_address_details( $invoice, 'billing' );
327
+        return $this->prepare_address_details( $invoice, 'billing' );
328 328
 
329
-	}
329
+    }
330 330
 
331
-	/**
332
-	 * Confirms the submission is valid and send users to the gateway.
333
-	 *
334
-	 * @param WPInv_Invoice $invoice
335
-	 * @param array $prepared_payment_form_data
336
-	 * @param array $shipping
337
-	 */
338
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
331
+    /**
332
+     * Confirms the submission is valid and send users to the gateway.
333
+     *
334
+     * @param WPInv_Invoice $invoice
335
+     * @param array $prepared_payment_form_data
336
+     * @param array $shipping
337
+     */
338
+    protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
339 339
 
340
-		// Ensure the invoice exists.
340
+        // Ensure the invoice exists.
341 341
         if ( ! $invoice->exists() ) {
342 342
             wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
343 343
         }
344 344
 
345
-		// Save payment form data.
346
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
345
+        // Save payment form data.
346
+        $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
347 347
         if ( ! empty( $prepared_payment_form_data ) ) {
348 348
             update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data );
349
-		}
349
+        }
350 350
 
351
-		// Save payment form data.
351
+        // Save payment form data.
352 352
         if ( ! empty( $shipping ) ) {
353 353
             update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
354
-		}
354
+        }
355 355
 
356
-		// Backwards compatibility.
356
+        // Backwards compatibility.
357 357
         add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
358 358
 
359
-		$this->process_payment( $invoice );
359
+        $this->process_payment( $invoice );
360 360
 
361 361
         // If we are here, there was an error.
362
-		wpinv_send_back_to_checkout( $invoice );
362
+        wpinv_send_back_to_checkout( $invoice );
363 363
 
364
-	}
364
+    }
365 365
 
366
-	/**
367
-	 * Processes the actual payment.
368
-	 *
369
-	 * @param WPInv_Invoice $invoice
370
-	 */
371
-	protected function process_payment( $invoice ) {
366
+    /**
367
+     * Processes the actual payment.
368
+     *
369
+     * @param WPInv_Invoice $invoice
370
+     */
371
+    protected function process_payment( $invoice ) {
372 372
 
373
-		// Clear any checkout errors.
374
-		wpinv_clear_errors();
373
+        // Clear any checkout errors.
374
+        wpinv_clear_errors();
375 375
 
376
-		// No need to send free invoices to the gateway.
377
-		if ( $invoice->is_free() ) {
378
-			$this->process_free_payment( $invoice );
379
-		}
376
+        // No need to send free invoices to the gateway.
377
+        if ( $invoice->is_free() ) {
378
+            $this->process_free_payment( $invoice );
379
+        }
380 380
 
381
-		$submission = $this->payment_form_submission;
381
+        $submission = $this->payment_form_submission;
382 382
 
383
-		// Fires before sending to the gateway.
384
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
383
+        // Fires before sending to the gateway.
384
+        do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
385 385
 
386
-		// Allow the sumission data to be modified before it is sent to the gateway.
387
-		$submission_data    = $submission->get_data();
388
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
389
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
386
+        // Allow the sumission data to be modified before it is sent to the gateway.
387
+        $submission_data    = $submission->get_data();
388
+        $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
389
+        $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
390 390
 
391
-		// Validate the currency.
392
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
393
-			wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
394
-		}
391
+        // Validate the currency.
392
+        if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
393
+            wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
394
+        }
395 395
 
396
-		// Check to see if we have any errors.
397
-		if ( wpinv_get_errors() ) {
398
-			wpinv_send_back_to_checkout( $invoice );
399
-		}
396
+        // Check to see if we have any errors.
397
+        if ( wpinv_get_errors() ) {
398
+            wpinv_send_back_to_checkout( $invoice );
399
+        }
400 400
 
401
-		// Send info to the gateway for payment processing
402
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
401
+        // Send info to the gateway for payment processing
402
+        do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
403 403
 
404
-		// Backwards compatibility.
405
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
404
+        // Backwards compatibility.
405
+        wpinv_send_to_gateway( $submission_gateway, $invoice );
406 406
 
407
-	}
407
+    }
408 408
 
409
-	/**
410
-	 * Marks the invoice as paid in case the checkout is free.
411
-	 *
412
-	 * @param WPInv_Invoice $invoice
413
-	 */
414
-	protected function process_free_payment( $invoice ) {
409
+    /**
410
+     * Marks the invoice as paid in case the checkout is free.
411
+     *
412
+     * @param WPInv_Invoice $invoice
413
+     */
414
+    protected function process_free_payment( $invoice ) {
415 415
 
416
-		$invoice->set_gateway( 'none' );
417
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
418
-		$invoice->mark_paid();
419
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
416
+        $invoice->set_gateway( 'none' );
417
+        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
418
+        $invoice->mark_paid();
419
+        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
420 420
 
421
-	}
421
+    }
422 422
 
423
-	/**
423
+    /**
424 424
      * Sends a redrect response to payment details.
425 425
      *
426 426
      */
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 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
  * Main Checkout Class.
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * 
23 23
 	 * @param GetPaid_Payment_Form_Submission $submission
24 24
 	 */
25
-	public function __construct( $submission ) {
25
+	public function __construct($submission) {
26 26
 		$this->payment_form_submission = $submission;
27 27
 	}
28 28
 
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
 		// Prepare the invoice.
39 39
 		$items      = $this->get_submission_items();
40 40
 		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
41
+		$invoice    = $this->process_submission_invoice($invoice, $items);
42 42
 		$prepared   = $this->prepare_submission_data_for_saving();
43 43
 
44
-		$this->prepare_billing_info( $invoice );
44
+		$this->prepare_billing_info($invoice);
45 45
 
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
46
+		$shipping = $this->prepare_shipping_info($invoice);
47 47
 
48 48
 		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
49
+		$invoice->set_is_viewed(true);
50 50
 		$invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+		do_action('getpaid_checkout_invoice_updated', $invoice);
54 54
 
55 55
 		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
56
+		$this->post_process_submission($invoice, $prepared, $shipping);
57 57
 	}
58 58
 
59 59
 	/**
@@ -66,34 +66,34 @@  discard block
 block discarded – undo
66 66
 		$data       = $submission->get_data();
67 67
 
68 68
 		// Do we have an error?
69
-        if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
69
+        if (!empty($submission->last_error)) {
70
+			wp_send_json_error($submission->last_error);
71 71
         }
72 72
 
73 73
 		// We need a billing email.
74
-        if ( ! $submission->has_billing_email() ) {
75
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
74
+        if (!$submission->has_billing_email()) {
75
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
76 76
 		}
77 77
 
78 78
 		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
79
+		if ($submission->should_collect_payment_details() && $submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) {
80
+			wp_send_json_error(__('The selected payment gateway does not support subscription payments.', 'invoicing'));
81 81
 		}
82 82
 
83 83
 		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
84
+		if ($submission->should_collect_payment_details() && !wpinv_is_gateway_active($data['wpi-gateway'])) {
85
+			wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing'));
86 86
 		}
87 87
 
88 88
 		// Clear any existing errors.
89 89
 		wpinv_clear_errors();
90 90
 
91 91
 		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
92
+		do_action('getpaid_checkout_error_checks', $submission);
93 93
 
94 94
 		// Do we have any errors?
95
-        if ( wpinv_get_errors() ) {
96
-            wp_send_json_error( getpaid_get_errors_html() );
95
+        if (wpinv_get_errors()) {
96
+            wp_send_json_error(getpaid_get_errors_html());
97 97
 		}
98 98
 
99 99
 	}
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 		$items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111
-        if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112
-            wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
111
+        if (empty($items) && !$this->payment_form_submission->has_fees()) {
112
+            wp_send_json_error(__('Please provide at least one item or amount.', 'invoicing'));
113 113
 		}
114 114
 
115 115
 		return $items;
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 	protected function get_submission_invoice() {
124 124
 		$submission = $this->payment_form_submission;
125 125
 
126
-		if ( ! $submission->has_invoice() ) {
126
+		if (!$submission->has_invoice()) {
127 127
 			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
128
+			$invoice->set_created_via('payment_form');
129 129
 			return $invoice;
130 130
         }
131 131
 
132 132
 		$invoice = $submission->get_invoice();
133 133
 
134 134
 		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
135
+		if ($invoice->is_paid() || $invoice->is_refunded()) {
136
+			wp_send_json_error(__('This invoice has already been paid for.', 'invoicing'));
137 137
 		}
138 138
 
139 139
 		return $invoice;
@@ -146,29 +146,29 @@  discard block
 block discarded – undo
146 146
 	 * @param GetPaid_Form_Item[] $items
147 147
 	 * @return WPInv_Invoice
148 148
 	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
149
+	protected function process_submission_invoice($invoice, $items) {
150 150
 
151 151
 		$submission = $this->payment_form_submission;
152 152
 		$data       = $submission->get_data();
153 153
 
154 154
 		// Set-up the invoice details.
155
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
156
-		$invoice->set_user_id( $this->get_submission_customer() );
157
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
158
-        $invoice->set_items( $items );
159
-        $invoice->set_fees( $submission->get_fees() );
160
-        $invoice->set_taxes( $submission->get_taxes() );
161
-		$invoice->set_discounts( $submission->get_discounts() );
162
-		$invoice->set_gateway( $data['wpi-gateway'] );
163
-
164
-		$address_confirmed = $submission->get_field( 'confirm-address' );
165
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
166
-
167
-		if ( $submission->has_discount_code() ) {
168
-            $invoice->set_discount_code( $submission->get_discount_code() );
155
+		$invoice->set_email(sanitize_email($submission->get_billing_email()));
156
+		$invoice->set_user_id($this->get_submission_customer());
157
+		$invoice->set_payment_form(absint($submission->get_payment_form()->get_id()));
158
+        $invoice->set_items($items);
159
+        $invoice->set_fees($submission->get_fees());
160
+        $invoice->set_taxes($submission->get_taxes());
161
+		$invoice->set_discounts($submission->get_discounts());
162
+		$invoice->set_gateway($data['wpi-gateway']);
163
+
164
+		$address_confirmed = $submission->get_field('confirm-address');
165
+		$invoice->set_address_confirmed(!empty($address_confirmed));
166
+
167
+		if ($submission->has_discount_code()) {
168
+            $invoice->set_discount_code($submission->get_discount_code());
169 169
 		}
170 170
 
171
-		getpaid_maybe_add_default_address( $invoice );
171
+		getpaid_maybe_add_default_address($invoice);
172 172
 		return $invoice;
173 173
 	}
174 174
 
@@ -181,33 +181,33 @@  discard block
 block discarded – undo
181 181
 		$submission = $this->payment_form_submission;
182 182
 
183 183
 		// If this is an existing invoice...
184
-		if ( $submission->has_invoice() ) {
184
+		if ($submission->has_invoice()) {
185 185
 			return $submission->get_invoice()->get_user_id();
186 186
 		}
187 187
 
188 188
 		// (Maybe) create the user.
189 189
         $user = get_current_user_id();
190 190
 
191
-        if ( empty( $user ) ) {
192
-            $user = get_user_by( 'email', $submission->get_billing_email() );
191
+        if (empty($user)) {
192
+            $user = get_user_by('email', $submission->get_billing_email());
193 193
         }
194 194
 
195
-        if ( empty( $user ) ) {
196
-            $user = wpinv_create_user( $submission->get_billing_email() );
195
+        if (empty($user)) {
196
+            $user = wpinv_create_user($submission->get_billing_email());
197 197
 
198 198
 			// (Maybe) send new user notification.
199
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
201
-				wp_send_new_user_notifications( $user, 'user' );
199
+			$should_send_notification = wpinv_get_option('disable_new_user_emails');
200
+			if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
201
+				wp_send_new_user_notifications($user, 'user');
202 202
 			}
203 203
 
204 204
         }
205 205
 
206
-        if ( is_wp_error( $user ) ) {
207
-            wp_send_json_error( $user->get_error_message() );
206
+        if (is_wp_error($user)) {
207
+            wp_send_json_error($user->get_error_message());
208 208
         }
209 209
 
210
-        if ( is_numeric( $user ) ) {
210
+        if (is_numeric($user)) {
211 211
             return $user;
212 212
 		}
213 213
 
@@ -228,30 +228,30 @@  discard block
 block discarded – undo
228 228
         $prepared = array();
229 229
 
230 230
         // Raw submission details.
231
-		$data     = $submission->get_data();
231
+		$data = $submission->get_data();
232 232
 
233 233
 		// Loop through the submitted details.
234
-        foreach ( $submission->get_payment_form()->get_elements() as $field ) {
234
+        foreach ($submission->get_payment_form()->get_elements() as $field) {
235 235
 
236 236
 			// Skip premade fields.
237
-            if ( ! empty( $field['premade'] ) || $field['type'] == 'address' ) {
237
+            if (!empty($field['premade']) || $field['type'] == 'address') {
238 238
                 continue;
239 239
             }
240 240
 
241 241
             // If it is required and not set, abort.
242
-            if ( ! $submission->is_required_field_set( $field ) ) {
243
-                wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
242
+            if (!$submission->is_required_field_set($field)) {
243
+                wp_send_json_error(__('Please fill all required fields.', 'invoicing'));
244 244
             }
245 245
 
246 246
             // Handle misc fields.
247
-            if ( isset( $data[ $field['id'] ] ) ) {
247
+            if (isset($data[$field['id']])) {
248 248
                 $label = $field['id'];
249 249
 
250
-                if ( isset( $field['label'] ) ) {
250
+                if (isset($field['label'])) {
251 251
                     $label = $field['label'];
252 252
                 }
253 253
 
254
-				$prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] );
254
+				$prepared[wpinv_clean($label)] = wp_kses_post($data[$field['id']]);
255 255
 
256 256
             }
257 257
 
@@ -268,30 +268,30 @@  discard block
 block discarded – undo
268 268
 	 * @param WPInv_Invoice $invoice
269 269
 	 * @param string $type
270 270
      */
271
-    public function prepare_address_details( $invoice, $type = 'billing' ) {
271
+    public function prepare_address_details($invoice, $type = 'billing') {
272 272
 
273 273
 		$data     = $this->payment_form_submission->get_data();
274
-		$type     = sanitize_key( $type );
274
+		$type     = sanitize_key($type);
275 275
 		$address  = array();
276 276
 		$prepared = array();
277 277
 
278
-		if ( ! empty( $data[ $type ] ) ) {
279
-			$address = $data[ $type ];
278
+		if (!empty($data[$type])) {
279
+			$address = $data[$type];
280 280
 		}
281 281
 
282 282
 		// Clean address details.
283
-		foreach ( $address as $key => $value ) {
284
-			$key             = sanitize_key( $key );
285
-			$key             = str_replace( 'wpinv_', '', $key );
286
-			$value           = wpinv_clean( $value );
287
-			$prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
283
+		foreach ($address as $key => $value) {
284
+			$key             = sanitize_key($key);
285
+			$key             = str_replace('wpinv_', '', $key);
286
+			$value           = wpinv_clean($value);
287
+			$prepared[$key] = apply_filters("getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice);
288 288
 		}
289 289
 
290 290
 		// Filter address details.
291
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
291
+		$prepared = apply_filters("getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice);
292 292
 
293 293
 		// Remove non-whitelisted values.
294
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
294
+		return array_filter($prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY);
295 295
 
296 296
 	}
297 297
 
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
 	 * @return array
302 302
 	 * @param WPInv_Invoice $invoice
303 303
      */
304
-    protected function prepare_billing_info( &$invoice ) {
304
+    protected function prepare_billing_info(&$invoice) {
305 305
 
306
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
306
+		$billing_address = $this->prepare_address_details($invoice, 'billing');
307 307
 
308 308
 		// Update the invoice with the billing details.
309
-		$invoice->set_props( $billing_address );
309
+		$invoice->set_props($billing_address);
310 310
 
311 311
 	}
312 312
 
@@ -316,15 +316,15 @@  discard block
 block discarded – undo
316 316
 	 * @return array
317 317
 	 * @param WPInv_Invoice $invoice
318 318
      */
319
-    protected function prepare_shipping_info( $invoice ) {
319
+    protected function prepare_shipping_info($invoice) {
320 320
 
321 321
 		$data = $this->payment_form_submission->get_data();
322 322
 
323
-		if ( empty( $data['same-shipping-address'] ) ) {
324
-			return $this->prepare_address_details( $invoice, 'shipping' );
323
+		if (empty($data['same-shipping-address'])) {
324
+			return $this->prepare_address_details($invoice, 'shipping');
325 325
 		}
326 326
 
327
-		return $this->prepare_address_details( $invoice, 'billing' );
327
+		return $this->prepare_address_details($invoice, 'billing');
328 328
 
329 329
 	}
330 330
 
@@ -335,31 +335,31 @@  discard block
 block discarded – undo
335 335
 	 * @param array $prepared_payment_form_data
336 336
 	 * @param array $shipping
337 337
 	 */
338
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
338
+	protected function post_process_submission($invoice, $prepared_payment_form_data, $shipping) {
339 339
 
340 340
 		// Ensure the invoice exists.
341
-        if ( ! $invoice->exists() ) {
342
-            wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
341
+        if (!$invoice->exists()) {
342
+            wp_send_json_error(__('An error occured while saving your invoice. Please try again.', 'invoicing'));
343 343
         }
344 344
 
345 345
 		// Save payment form data.
346
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
347
-        if ( ! empty( $prepared_payment_form_data ) ) {
348
-            update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data );
346
+		$prepared_payment_form_data = apply_filters('getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice);
347
+        if (!empty($prepared_payment_form_data)) {
348
+            update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data);
349 349
 		}
350 350
 
351 351
 		// Save payment form data.
352
-        if ( ! empty( $shipping ) ) {
353
-            update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
352
+        if (!empty($shipping)) {
353
+            update_post_meta($invoice->get_id(), 'shipping_address', $shipping);
354 354
 		}
355 355
 
356 356
 		// Backwards compatibility.
357
-        add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
357
+        add_filter('wp_redirect', array($this, 'send_redirect_response'));
358 358
 
359
-		$this->process_payment( $invoice );
359
+		$this->process_payment($invoice);
360 360
 
361 361
         // If we are here, there was an error.
362
-		wpinv_send_back_to_checkout( $invoice );
362
+		wpinv_send_back_to_checkout($invoice);
363 363
 
364 364
 	}
365 365
 
@@ -368,41 +368,41 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @param WPInv_Invoice $invoice
370 370
 	 */
371
-	protected function process_payment( $invoice ) {
371
+	protected function process_payment($invoice) {
372 372
 
373 373
 		// Clear any checkout errors.
374 374
 		wpinv_clear_errors();
375 375
 
376 376
 		// No need to send free invoices to the gateway.
377
-		if ( $invoice->is_free() ) {
378
-			$this->process_free_payment( $invoice );
377
+		if ($invoice->is_free()) {
378
+			$this->process_free_payment($invoice);
379 379
 		}
380 380
 
381 381
 		$submission = $this->payment_form_submission;
382 382
 
383 383
 		// Fires before sending to the gateway.
384
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
384
+		do_action('getpaid_checkout_before_gateway', $invoice, $submission);
385 385
 
386 386
 		// Allow the sumission data to be modified before it is sent to the gateway.
387 387
 		$submission_data    = $submission->get_data();
388
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
389
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
388
+		$submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice);
389
+		$submission_data    = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice);
390 390
 
391 391
 		// Validate the currency.
392
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
393
-			wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
392
+		if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) {
393
+			wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support this currency', 'invoicing'));
394 394
 		}
395 395
 
396 396
 		// Check to see if we have any errors.
397
-		if ( wpinv_get_errors() ) {
398
-			wpinv_send_back_to_checkout( $invoice );
397
+		if (wpinv_get_errors()) {
398
+			wpinv_send_back_to_checkout($invoice);
399 399
 		}
400 400
 
401 401
 		// Send info to the gateway for payment processing
402
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
402
+		do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission);
403 403
 
404 404
 		// Backwards compatibility.
405
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
405
+		wpinv_send_to_gateway($submission_gateway, $invoice);
406 406
 
407 407
 	}
408 408
 
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @param WPInv_Invoice $invoice
413 413
 	 */
414
-	protected function process_free_payment( $invoice ) {
414
+	protected function process_free_payment($invoice) {
415 415
 
416
-		$invoice->set_gateway( 'none' );
417
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
416
+		$invoice->set_gateway('none');
417
+		$invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true);
418 418
 		$invoice->mark_paid();
419
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
419
+		wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
420 420
 
421 421
 	}
422 422
 
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
      * Sends a redrect response to payment details.
425 425
      *
426 426
      */
427
-    public function send_redirect_response( $url ) {
428
-        $url = urlencode( $url );
429
-        wp_send_json_success( $url );
427
+    public function send_redirect_response($url) {
428
+        $url = urlencode($url);
429
+        wp_send_json_success($url);
430 430
     }
431 431
 
432 432
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice  = new WPInv_Invoice( $post );
28
-        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-        $customer = new WP_User( $customer );
30
-        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+        $invoice  = new WPInv_Invoice($post);
28
+        $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+        $customer = new WP_User($customer);
30
+        $display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
         ?>
34 34
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
                         <div class="col-12 col-sm-6">
44 44
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
45 45
                                 <div>
46
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
46
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
47 47
                                 </div>
48 48
                                 <div>
49
-                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
50
-                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo sanitize_text_field( $display ); ?> </option>)
49
+                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
50
+                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo sanitize_text_field($display); ?> </option>)
51 51
                                     </select>
52 52
                                 </div>
53 53
                             </div>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                                             'type'        => 'text',
61 61
                                             'id'          => 'getpaid-invoice-new-user-email',
62 62
                                             'name'        => 'wpinv_email',
63
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
63
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
64 64
                                             'label_type'  => 'vertical',
65 65
                                             'placeholder' => '[email protected]',
66 66
                                             'class'       => 'form-control-sm',
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
                             </div>
71 71
                         </div>
72 72
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
73
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
73
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
74 74
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
75 75
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
76
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
76
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
77 77
                                 </a>
78 78
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
79 79
                                     <i aria-hidden="true" class="fa fa-plus"></i>
80
-                                    <?php _e( 'Add New User', 'invoicing' );?>
80
+                                    <?php _e('Add New User', 'invoicing'); ?>
81 81
                                 </a>
82 82
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
83 83
                                     <i aria-hidden="true" class="fa fa-close"></i>
84
-                                    <?php _e( 'Cancel', 'invoicing' );?>
84
+                                    <?php _e('Cancel', 'invoicing'); ?>
85 85
                                 </a>
86 86
                             <?php endif; ?>
87 87
                         </div>
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
                                         'type'        => 'text',
95 95
                                         'id'          => 'wpinv_first_name',
96 96
                                         'name'        => 'wpinv_first_name',
97
-                                        'label'       => __( 'First Name', 'invoicing' ),
97
+                                        'label'       => __('First Name', 'invoicing'),
98 98
                                         'label_type'  => 'vertical',
99 99
                                         'placeholder' => '',
100 100
                                         'class'       => 'form-control-sm',
101
-                                        'value'       => $invoice->get_first_name( 'edit' ),
101
+                                        'value'       => $invoice->get_first_name('edit'),
102 102
                                     )
103 103
                                 );
104 104
                             ?>
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
                                         'type'        => 'text',
111 111
                                         'id'          => 'wpinv_last_name',
112 112
                                         'name'        => 'wpinv_last_name',
113
-                                        'label'       => __( 'Last Name', 'invoicing' ),
113
+                                        'label'       => __('Last Name', 'invoicing'),
114 114
                                         'label_type'  => 'vertical',
115 115
                                         'placeholder' => '',
116 116
                                         'class'       => 'form-control-sm',
117
-                                        'value'       => $invoice->get_last_name( 'edit' ),
117
+                                        'value'       => $invoice->get_last_name('edit'),
118 118
                                     )
119 119
                                 );
120 120
                             ?>
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                                         'type'        => 'text',
130 130
                                         'id'          => 'wpinv_company',
131 131
                                         'name'        => 'wpinv_company',
132
-                                        'label'       => __( 'Company', 'invoicing' ),
132
+                                        'label'       => __('Company', 'invoicing'),
133 133
                                         'label_type'  => 'vertical',
134 134
                                         'placeholder' => '',
135 135
                                         'class'       => 'form-control-sm',
136
-                                        'value'       => $invoice->get_company( 'edit' ),
136
+                                        'value'       => $invoice->get_company('edit'),
137 137
                                     )
138 138
                                 );
139 139
                             ?>
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
                                         'type'        => 'text',
146 146
                                         'id'          => 'wpinv_vat_number',
147 147
                                         'name'        => 'wpinv_vat_number',
148
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
148
+                                        'label'       => __('Vat Number', 'invoicing'),
149 149
                                         'label_type'  => 'vertical',
150 150
                                         'placeholder' => '',
151 151
                                         'class'       => 'form-control-sm',
152
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
152
+                                        'value'       => $invoice->get_vat_number('edit'),
153 153
                                     )
154 154
                                 );
155 155
                             ?>
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
                                         'type'        => 'text',
165 165
                                         'id'          => 'wpinv_address',
166 166
                                         'name'        => 'wpinv_address',
167
-                                        'label'       => __( 'Address', 'invoicing' ),
167
+                                        'label'       => __('Address', 'invoicing'),
168 168
                                         'label_type'  => 'vertical',
169 169
                                         'placeholder' => '',
170 170
                                         'class'       => 'form-control-sm',
171
-                                        'value'       => $invoice->get_address( 'edit' ),
171
+                                        'value'       => $invoice->get_address('edit'),
172 172
                                     )
173 173
                                 );
174 174
                             ?>
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
                                         'type'        => 'text',
181 181
                                         'id'          => 'wpinv_city',
182 182
                                         'name'        => 'wpinv_city',
183
-                                        'label'       => __( 'City', 'invoicing' ),
183
+                                        'label'       => __('City', 'invoicing'),
184 184
                                         'label_type'  => 'vertical',
185 185
                                         'placeholder' => '',
186 186
                                         'class'       => 'form-control-sm',
187
-                                        'value'       => $invoice->get_city( 'edit' ),
187
+                                        'value'       => $invoice->get_city('edit'),
188 188
                                     )
189 189
                                 );
190 190
                             ?>
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
                                     array(
199 199
                                         'id'          => 'wpinv_country',
200 200
                                         'name'        => 'wpinv_country',
201
-                                        'label'       => __( 'Country', 'invoicing' ),
201
+                                        'label'       => __('Country', 'invoicing'),
202 202
                                         'label_type'  => 'vertical',
203
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
203
+                                        'placeholder' => __('Choose a country', 'invoicing'),
204 204
                                         'class'       => 'form-control-sm',
205
-                                        'value'       => $invoice->get_country( 'edit' ),
205
+                                        'value'       => $invoice->get_country('edit'),
206 206
                                         'options'     => wpinv_get_country_list(),
207 207
                                         'data-allow-clear' => 'false',
208 208
                                         'select2'          => true,
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
                         <div class="col-12 col-sm-6">
214 214
                             <?php
215 215
 
216
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
216
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
217 217
 
218
-                                if ( empty( $states ) ) {
218
+                                if (empty($states)) {
219 219
 
220 220
                                     echo aui()->input(
221 221
                                         array(
222 222
                                             'type'        => 'text',
223 223
                                             'id'          => 'wpinv_state',
224 224
                                             'name'        => 'wpinv_state',
225
-                                            'label'       => __( 'State', 'invoicing' ),
225
+                                            'label'       => __('State', 'invoicing'),
226 226
                                             'label_type'  => 'vertical',
227 227
                                             'placeholder' => '',
228 228
                                             'class'       => 'form-control-sm',
229
-                                            'value'       => $invoice->get_state( 'edit' ),
229
+                                            'value'       => $invoice->get_state('edit'),
230 230
                                         )
231 231
                                     );
232 232
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
                                         array(
237 237
                                             'id'          => 'wpinv_state',
238 238
                                             'name'        => 'wpinv_state',
239
-                                            'label'       => __( 'State', 'invoicing' ),
239
+                                            'label'       => __('State', 'invoicing'),
240 240
                                             'label_type'  => 'vertical',
241
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
241
+                                            'placeholder' => __('Select a state', 'invoicing'),
242 242
                                             'class'       => 'form-control-sm',
243
-                                            'value'       => $invoice->get_state( 'edit' ),
243
+                                            'value'       => $invoice->get_state('edit'),
244 244
                                             'options'     => $states,
245 245
                                             'data-allow-clear' => 'false',
246 246
                                             'select2'          => true,
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
                                         'type'        => 'text',
262 262
                                         'id'          => 'wpinv_zip',
263 263
                                         'name'        => 'wpinv_zip',
264
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
264
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
265 265
                                         'label_type'  => 'vertical',
266 266
                                         'placeholder' => '',
267 267
                                         'class'       => 'form-control-sm',
268
-                                        'value'       => $invoice->get_zip( 'edit' ),
268
+                                        'value'       => $invoice->get_zip('edit'),
269 269
                                     )
270 270
                                 );
271 271
                             ?>
@@ -277,18 +277,18 @@  discard block
 block discarded – undo
277 277
                                         'type'        => 'text',
278 278
                                         'id'          => 'wpinv_phone',
279 279
                                         'name'        => 'wpinv_phone',
280
-                                        'label'       => __( 'Phone', 'invoicing' ),
280
+                                        'label'       => __('Phone', 'invoicing'),
281 281
                                         'label_type'  => 'vertical',
282 282
                                         'placeholder' => '',
283 283
                                         'class'       => 'form-control-sm',
284
-                                        'value'       => $invoice->get_phone( 'edit' ),
284
+                                        'value'       => $invoice->get_phone('edit'),
285 285
                                     )
286 286
                                 );
287 287
                             ?>
288 288
                         </div>
289 289
                     </div>
290 290
 
291
-                    <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
291
+                    <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
292 292
             </div>
293 293
         <?php
294 294
     }
@@ -298,50 +298,50 @@  discard block
 block discarded – undo
298 298
 	 *
299 299
 	 * @param int $post_id
300 300
 	 */
301
-	public static function save( $post_id ) {
301
+	public static function save($post_id) {
302 302
 
303 303
         // Prepare the invoice.
304
-        $invoice = new WPInv_Invoice( $post_id );
304
+        $invoice = new WPInv_Invoice($post_id);
305 305
 
306 306
         // Load new data.
307 307
         $invoice->set_props(
308 308
 			array(
309
-                'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
310
-                'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
311
-                'disable_taxes'        => isset( $_POST['disable_taxes'] ),
312
-                'currency'             => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
313
-                'gateway'              => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
314
-                'address'              => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
315
-                'vat_number'           => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
316
-                'company'              => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
317
-                'zip'                  => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
318
-                'state'                => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
319
-                'city'                 => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
320
-                'country'              => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
321
-                'phone'                => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
322
-                'first_name'           => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
323
-                'last_name'            => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
324
-                'author'               => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
325
-                'date_created'         => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
326
-                'date_completed'       => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
327
-                'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
328
-                'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
329
-                'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
309
+                'template'             => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
310
+                'email_cc'             => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
311
+                'disable_taxes'        => isset($_POST['disable_taxes']),
312
+                'currency'             => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
313
+                'gateway'              => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null,
314
+                'address'              => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
315
+                'vat_number'           => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
316
+                'company'              => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
317
+                'zip'                  => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
318
+                'state'                => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
319
+                'city'                 => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
320
+                'country'              => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
321
+                'phone'                => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
322
+                'first_name'           => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
323
+                'last_name'            => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
324
+                'author'               => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
325
+                'date_created'         => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
326
+                'date_completed'       => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null,
327
+                'due_date'             => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
328
+                'number'               => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
329
+                'status'               => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
330 330
 			)
331 331
         );
332 332
 
333 333
         // Discount code.
334
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
334
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
335 335
 
336
-            if ( isset( $_POST['wpinv_discount_code'] ) ) {
337
-                $invoice->set_discount_code( $_POST['wpinv_discount_code'] );
336
+            if (isset($_POST['wpinv_discount_code'])) {
337
+                $invoice->set_discount_code($_POST['wpinv_discount_code']);
338 338
             }
339 339
 
340
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
341
-            if ( $discount->exists() ) {
342
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
340
+            $discount = new WPInv_Discount($invoice->get_discount_code());
341
+            if ($discount->exists()) {
342
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
343 343
             } else {
344
-                $invoice->remove_discount( 'discount_code' );
344
+                $invoice->remove_discount('discount_code');
345 345
             }
346 346
 
347 347
             // Recalculate totals.
@@ -350,17 +350,17 @@  discard block
 block discarded – undo
350 350
         }
351 351
 
352 352
         // If we're creating a new user...
353
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( $_POST['wpinv_email'] ) ) {
353
+        if (!empty($_POST['wpinv_new_user']) && is_email($_POST['wpinv_email'])) {
354 354
 
355 355
             // Attempt to create the user.
356
-            $user = wpinv_create_user( sanitize_email( $_POST['wpinv_email'] ) );
356
+            $user = wpinv_create_user(sanitize_email($_POST['wpinv_email']));
357 357
 
358 358
 
359 359
             // If successful, update the invoice author.
360
-            if ( is_numeric( $user ) ) {
361
-                $invoice->set_author( $user );
360
+            if (is_numeric($user)) {
361
+                $invoice->set_author($user);
362 362
             } else {
363
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
363
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
364 364
             }
365 365
         }
366 366
 
@@ -374,24 +374,24 @@  discard block
 block discarded – undo
374 374
         $GLOBALS['wpinv_skip_invoice_notification'] = false;
375 375
 
376 376
         // (Maybe) send new user notification.
377
-        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
378
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
379
-            wp_send_new_user_notifications( $user, 'user' );
377
+        $should_send_notification = wpinv_get_option('disable_new_user_emails');
378
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
379
+            wp_send_new_user_notifications($user, 'user');
380 380
         }
381 381
 
382
-        if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
382
+        if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) {
383 383
 
384
-            $sent = getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
384
+            $sent = getpaid()->get('invoice_emails')->user_invoice($invoice, true);
385 385
 
386
-            if ( $sent ) {
387
-                getpaid_admin()->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
386
+            if ($sent) {
387
+                getpaid_admin()->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
388 388
             } else {
389
-                getpaid_admin()->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
389
+                getpaid_admin()->show_error(__('Could not send the invoice to the customer', 'invoicing'));
390 390
             }
391 391
 
392 392
         }
393 393
 
394 394
         // Fires after an invoice is saved.
395
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
395
+		do_action('wpinv_invoice_metabox_saved', $invoice);
396 396
 	}
397 397
 }
Please login to merge, or discard this patch.
includes/data/admin-settings.php 1 patch
Spacing   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -8,205 +8,205 @@  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
 $invoice_number_padd_options = array();
23
-for ( $i = 0; $i <= 20; $i++ ) {
23
+for ($i = 0; $i <= 20; $i++) {
24 24
     $invoice_number_padd_options[$i] = $i;
25 25
 }
26 26
     
27 27
 $currency_symbol = wpinv_currency_symbol();
28 28
     
29 29
 $last_number = $reset_number = '';
30
-if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
31
-    $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number );
30
+if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
31
+    $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number);
32 32
 
33
-    if ( !empty( $last_invoice_number ) ) {
34
-        $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
33
+    if (!empty($last_invoice_number)) {
34
+        $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
35 35
     }
36 36
 
37 37
     $nonce = wp_create_nonce('reset_invoice_count');
38
-    $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
38
+    $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
39 39
 }
40 40
     
41 41
 $alert_wrapper_start = '<p style="color: #F00">';
42 42
 $alert_wrapper_close = '</p>';
43 43
 
44 44
 return array(
45
-    'general' => apply_filters( 'wpinv_settings_general',
45
+    'general' => apply_filters('wpinv_settings_general',
46 46
         array(
47 47
             'main' => array(
48 48
                 'location_settings' => array(
49 49
                     'id'   => 'location_settings',
50
-                    'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
50
+                    'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
51 51
                     'desc' => '',
52 52
                     'type' => 'header',
53 53
                 ),
54 54
                 'default_country' => array(
55 55
                     'id'      => 'default_country',
56
-                    'name'    => __( 'Default Country', 'invoicing' ),
57
-                    'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
56
+                    'name'    => __('Default Country', 'invoicing'),
57
+                    'desc'    => __('Where does your store operate from?', 'invoicing'),
58 58
                     'type'    => 'select',
59 59
                     'options' => wpinv_get_country_list(),
60 60
                     'std'     => 'GB',
61 61
                     'class'   => 'wpi_select2',
62
-                    'placeholder' => __( 'Select a country', 'invoicing' ),
62
+                    'placeholder' => __('Select a country', 'invoicing'),
63 63
                 ),
64 64
                 'default_state' => array(
65 65
                     'id'      => 'default_state',
66
-                    'name'    => __( 'Default State / Province', 'invoicing' ),
67
-                    'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
66
+                    'name'    => __('Default State / Province', 'invoicing'),
67
+                    'desc'    => __('What state / province does your store operate from?', 'invoicing'),
68 68
                     'type'    => 'country_states',
69 69
                     'class'   => 'wpi_select2',
70
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
70
+                    'placeholder' => __('Select a state', 'invoicing'),
71 71
                 ),
72 72
                 'store_name' => array(
73 73
                     'id'   => 'store_name',
74
-                    'name' => __( 'Store Name', 'invoicing' ),
75
-                    'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
74
+                    'name' => __('Store Name', 'invoicing'),
75
+                    'desc' => __('Store name to print on invoices.', 'invoicing'),
76 76
                     'std'     => get_option('blogname'),
77 77
                     'type' => 'text',
78 78
                 ),
79 79
                 'logo' => array(
80 80
                     'id'   => 'logo',
81
-                    'name' => __( 'Logo URL', 'invoicing' ),
82
-                    'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
81
+                    'name' => __('Logo URL', 'invoicing'),
82
+                    'desc' => __('Store logo to print on invoices.', 'invoicing'),
83 83
                     'type' => 'text',
84 84
                 ),
85 85
                 'logo_width'      => array(
86 86
                     'id'          => 'logo_width',
87
-                    'name'        => __( 'Logo width', 'invoicing' ),
88
-                    'desc'        => __( 'Logo width to use in invoice image.', 'invoicing' ),
87
+                    'name'        => __('Logo width', 'invoicing'),
88
+                    'desc'        => __('Logo width to use in invoice image.', 'invoicing'),
89 89
                     'type'        => 'number',
90
-                    'placeholder' => __( 'Auto', 'invoicing' ),
90
+                    'placeholder' => __('Auto', 'invoicing'),
91 91
                 ),
92 92
                 'logo_height'     => array(
93 93
                     'id'          => 'logo_height',
94
-                    'name'        => __( 'Logo height', 'invoicing' ),
95
-                    'desc'        => __( 'Logo height to use in invoice image.', 'invoicing' ),
94
+                    'name'        => __('Logo height', 'invoicing'),
95
+                    'desc'        => __('Logo height to use in invoice image.', 'invoicing'),
96 96
                     'type'        => 'number',
97
-                    'placeholder' => __( 'Auto', 'invoicing' ),
97
+                    'placeholder' => __('Auto', 'invoicing'),
98 98
                 ),
99 99
                 'store_address' => array(
100 100
                     'id'   => 'store_address',
101
-                    'name' => __( 'Store Address', 'invoicing' ),
102
-                    'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
101
+                    'name' => __('Store Address', 'invoicing'),
102
+                    'desc' => __('Enter the store address to display on invoice', 'invoicing'),
103 103
                     'type' => 'textarea',
104 104
                 ),
105 105
                 'page_settings' => array(
106 106
                     'id'   => 'page_settings',
107
-                    'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
107
+                    'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
108 108
                     'desc' => '',
109 109
                     'type' => 'header',
110 110
                 ),
111 111
                 'checkout_page' => array(
112 112
                     'id'          => 'checkout_page',
113
-                    'name'        => __( 'Checkout Page', 'invoicing' ),
114
-                    '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' ),
113
+                    'name'        => __('Checkout Page', 'invoicing'),
114
+                    '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'),
115 115
                     'type'        => 'select',
116 116
                     'options'     => $pages,
117 117
                     'class'       => 'wpi_select2',
118
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
118
+                    'placeholder' => __('Select a page', 'invoicing'),
119 119
                     'help-tip'    => true,
120 120
                 ),
121 121
                 'success_page' => array(
122 122
                     'id'          => 'success_page',
123
-                    'name'        => __( 'Success Page', 'invoicing' ),
124
-                    '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' ),
123
+                    'name'        => __('Success Page', 'invoicing'),
124
+                    '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'),
125 125
                     'type'        => 'select',
126 126
                     'options'     => $pages,
127 127
                     'class'       => 'wpi_select2',
128
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
128
+                    'placeholder' => __('Select a page', 'invoicing'),
129 129
                     'help-tip'    => true,
130 130
                 ),
131 131
                 'failure_page' => array(
132 132
                     'id'          => 'failure_page',
133
-                    'name'        => __( 'Failed Transaction Page', 'invoicing' ),
134
-                    'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
133
+                    'name'        => __('Failed Transaction Page', 'invoicing'),
134
+                    'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
135 135
                     'type'        => 'select',
136 136
                     'options'     => $pages,
137 137
                     'class'       => 'wpi_select2',
138
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
138
+                    'placeholder' => __('Select a page', 'invoicing'),
139 139
                     'help-tip'    => true,
140 140
                 ),
141 141
                 'invoice_history_page' => array(
142 142
                     'id'          => 'invoice_history_page',
143
-                    'name'        => __( 'Invoice History Page', 'invoicing' ),
144
-                    'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
143
+                    'name'        => __('Invoice History Page', 'invoicing'),
144
+                    'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
145 145
                     'type'        => 'select',
146 146
                     'options'     => $pages,
147 147
                     'class'       => 'wpi_select2',
148
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
148
+                    'placeholder' => __('Select a page', 'invoicing'),
149 149
                     'help-tip'    => true,
150 150
                 ),
151 151
                 'invoice_subscription_page' => array(
152 152
                     'id'          => 'invoice_subscription_page',
153
-                    'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
154
-                    'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
153
+                    'name'        => __('Invoice Subscriptions Page', 'invoicing'),
154
+                    'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
155 155
                     'type'        => 'select',
156 156
                     'options'     => $pages,
157 157
                     'class'       => 'wpi_select2',
158
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
158
+                    'placeholder' => __('Select a page', 'invoicing'),
159 159
                     'help-tip'    => true,
160 160
                 ),
161 161
             ),
162 162
             'currency_section' => array(
163 163
                 'currency_settings' => array(
164 164
                     'id'   => 'currency_settings',
165
-                    'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
165
+                    'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
166 166
                     'desc' => '',
167 167
                     'type' => 'header',
168 168
                 ),
169 169
                 'currency' => array(
170 170
                     'id'      => 'currency',
171
-                    'name'    => __( 'Currency', 'invoicing' ),
172
-                    'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
171
+                    'name'    => __('Currency', 'invoicing'),
172
+                    'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
173 173
                     'type'    => 'select',
174 174
                     'class'       => 'wpi_select2',
175 175
                     'options' => $currency_code_options,
176 176
                 ),
177 177
                 'currency_position' => array(
178 178
                     'id'      => 'currency_position',
179
-                    'name'    => __( 'Currency Position', 'invoicing' ),
180
-                    'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
179
+                    'name'    => __('Currency Position', 'invoicing'),
180
+                    'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
181 181
                     'type'    => 'select',
182 182
                     'class'   => 'wpi_select2',
183 183
                     'options'  => array(
184
-                        'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
185
-                        'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
186
-                        'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
187
-                        'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
184
+                        'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
185
+                        'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
186
+                        'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
187
+                        'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
188 188
                     )
189 189
                 ),
190 190
                 'thousands_separator' => array(
191 191
                     'id'   => 'thousands_separator',
192
-                    'name' => __( 'Thousands Separator', 'invoicing' ),
193
-                    'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
192
+                    'name' => __('Thousands Separator', 'invoicing'),
193
+                    'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
194 194
                     'type' => 'text',
195 195
                     'size' => 'small',
196 196
                     'std'  => ',',
197 197
                 ),
198 198
                 'decimal_separator' => array(
199 199
                     'id'   => 'decimal_separator',
200
-                    'name' => __( 'Decimal Separator', 'invoicing' ),
201
-                    'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
200
+                    'name' => __('Decimal Separator', 'invoicing'),
201
+                    'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
202 202
                     'type' => 'text',
203 203
                     'size' => 'small',
204 204
                     'std'  => '.',
205 205
                 ),
206 206
                 'decimals' => array(
207 207
                     'id'   => 'decimals',
208
-                    'name' => __( 'Number of Decimals', 'invoicing' ),
209
-                    'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
208
+                    'name' => __('Number of Decimals', 'invoicing'),
209
+                    'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
210 210
                     'type' => 'number',
211 211
                     'size' => 'small',
212 212
                     'std'  => '2',
@@ -218,21 +218,21 @@  discard block
 block discarded – undo
218 218
             'labels' => array(
219 219
                 'labels' => array(
220 220
                     'id'   => 'labels_settings',
221
-                    'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
221
+                    'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
222 222
                     'desc' => '',
223 223
                     'type' => 'header',
224 224
                 ),
225 225
                 'vat_invoice_notice_label' => array(
226 226
                     'id' => 'vat_invoice_notice_label',
227
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
228
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
227
+                    'name' => __('Invoice Notice Label', 'invoicing'),
228
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
229 229
                     'type' => 'text',
230 230
                     'size' => 'regular',
231 231
                 ),
232 232
                 'vat_invoice_notice' => array(
233 233
                     'id' => 'vat_invoice_notice',
234
-                    'name' => __( 'Invoice notice', 'invoicing' ),
235
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
234
+                    'name' => __('Invoice notice', 'invoicing'),
235
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
236 236
                     'type' => 'text',
237 237
                     'size' => 'regular',
238 238
                 ),
@@ -244,22 +244,22 @@  discard block
 block discarded – undo
244 244
             'main' => array(
245 245
                 'gateway_settings' => array(
246 246
                     'id'   => 'api_header',
247
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
247
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
248 248
                     'desc' => '',
249 249
                     'type' => 'header',
250 250
                 ),
251 251
                 'gateways' => array(
252 252
                     'id'      => 'gateways',
253
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
254
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
253
+                    'name'    => __('Payment Gateways', 'invoicing'),
254
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
255 255
                     'type'    => 'gateways',
256
-                    'std'     => array( 'manual'=>1 ),
256
+                    'std'     => array('manual'=>1),
257 257
                     'options' => wpinv_get_payment_gateways(),
258 258
                 ),
259 259
                 'default_gateway' => array(
260 260
                     'id'      => 'default_gateway',
261
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
262
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
261
+                    'name'    => __('Default Gateway', 'invoicing'),
262
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
263 263
                     'type'    => 'gateway_select',
264 264
                     'std'     => 'manual',
265 265
                     'class'   => 'wpi_select2',
@@ -274,32 +274,32 @@  discard block
 block discarded – undo
274 274
             'main' => array(
275 275
                 'tax_settings' => array(
276 276
                     'id'   => 'tax_settings',
277
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
277
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
278 278
                     'type' => 'header',
279 279
                 ),
280 280
 
281 281
                 'enable_taxes' => array(
282 282
                     'id'       => 'enable_taxes',
283
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
284
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
283
+                    'name'     => __('Enable Taxes', 'invoicing'),
284
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
285 285
                     'type'     => 'checkbox',
286 286
                     'std'      => 0,
287 287
                 ),
288 288
 
289 289
                 'tax_subtotal_rounding' => array(
290 290
                     'id'                => 'tax_subtotal_rounding',
291
-                    'name'              => __( 'Rounding', 'invoicing' ),
292
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
291
+                    'name'              => __('Rounding', 'invoicing'),
292
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
293 293
                     'type'              => 'checkbox',
294 294
                     'std'               => 1,
295 295
                 ),
296 296
 
297 297
                 'prices_include_tax' => array(
298 298
                     'id'      => 'prices_include_tax',
299
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
299
+                    'name'    => __('Prices entered with tax', 'invoicing'),
300 300
                     'options' => array(
301
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
302
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
301
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
302
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
303 303
                     ),
304 304
                     'type'    => 'select',
305 305
                     'std'     => 'no',
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 
308 308
                 'tax_base'              => array(
309 309
                     'id'                => 'tax_base',
310
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
310
+                    'name'              => __('Calculate tax based on', 'invoicing'),
311 311
                     'options'           => array(
312
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
313
-                        'base'          => __( 'Shop base address', 'invoicing' ),
312
+                        'billing'       => __('Customer billing address', 'invoicing'),
313
+                        'base'          => __('Shop base address', 'invoicing'),
314 314
                     ),
315 315
                     'type'              => 'select',
316 316
                     'std'               => 'billing',
@@ -318,10 +318,10 @@  discard block
 block discarded – undo
318 318
 
319 319
                 'tax_display_totals'    => array(
320 320
                     'id'                => 'tax_display_totals',
321
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
321
+                    'name'              => __('Display tax totals', 'invoicing'),
322 322
                     'options'           => array(
323
-                        'single'        => __( 'As a single total', 'invoicing' ),
324
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
323
+                        'single'        => __('As a single total', 'invoicing'),
324
+                        'individual'    => __('As individual tax rates', 'invoicing'),
325 325
                     ),
326 326
                     'type'              => 'select',
327 327
                     'std'               => 'individual',
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 
330 330
                 'tax_rate' => array(
331 331
                     'id'   => 'tax_rate',
332
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
333
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
332
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
333
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
334 334
                     'type' => 'number',
335 335
                     'size' => 'small',
336 336
                     'min'  => '0',
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
             'rates' => array(
343 343
                 'tax_rates' => array(
344 344
                     'id'   => 'tax_rates',
345
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
346
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
345
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
346
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
347 347
                     'type' => 'tax_rates',
348 348
                 ),
349 349
             ),
@@ -352,45 +352,45 @@  discard block
 block discarded – undo
352 352
 
353 353
                 'vat_company_name' => array(
354 354
                     'id' => 'vat_company_name',
355
-                    'name' => __( 'Company Name', 'invoicing' ),
356
-                    '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>' ),
355
+                    'name' => __('Company Name', 'invoicing'),
356
+                    '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>'),
357 357
                     'type' => 'text',
358 358
                     'size' => 'regular',
359 359
                 ),
360 360
 
361 361
                 'vat_number' => array(
362 362
                     'id'   => 'vat_number',
363
-                    'name' => __( 'VAT Number', 'invoicing' ),
364
-                    'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ),
363
+                    'name' => __('VAT Number', 'invoicing'),
364
+                    'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'),
365 365
                     'type' => 'text',
366 366
                     'size' => 'regular',
367 367
                 ),
368 368
 
369 369
                 'vat_prevent_b2c_purchase' => array(
370 370
                     'id' => 'vat_prevent_b2c_purchase',
371
-                    'name' => __( 'Prevent B2C Sales', 'invoicing' ),
372
-                    'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ),
371
+                    'name' => __('Prevent B2C Sales', 'invoicing'),
372
+                    'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'),
373 373
                     'type' => 'checkbox'
374 374
                 ),
375 375
 
376 376
                 'validate_vat_number' => array(
377 377
                     'id'   => 'validate_vat_number',
378
-                    'name' => __( 'Validate VAT Number', 'invoicing' ),
379
-                    'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ),
378
+                    'name' => __('Validate VAT Number', 'invoicing'),
379
+                    'desc' => __('Validate VAT numbers with VIES.', 'invoicing'),
380 380
                     'type' => 'checkbox'
381 381
                 ),
382 382
 
383 383
                 'vat_same_country_rule' => array(
384 384
                     'id'          => 'vat_same_country_rule',
385
-                    'name'        => __( 'Same Country Rule', 'invoicing' ),
386
-                    'desc'        => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ),
385
+                    'name'        => __('Same Country Rule', 'invoicing'),
386
+                    'desc'        => __('What should happen if a customer is from the same country as your business?', 'invoicing'),
387 387
                     'type'        => 'select',
388 388
                     'options'     => array(
389
-                        'no'        => __( 'Do not charge tax', 'invoicing' ),
390
-                        'always'    => __( 'Charge tax unless vat number is validated', 'invoicing' ),
391
-                        'vat_too'   => __( 'Charge tax even if vat number is validated', 'invoicing' )
389
+                        'no'        => __('Do not charge tax', 'invoicing'),
390
+                        'always'    => __('Charge tax unless vat number is validated', 'invoicing'),
391
+                        'vat_too'   => __('Charge tax even if vat number is validated', 'invoicing')
392 392
                     ),
393
-                    'placeholder' => __( 'Select an option', 'invoicing' ),
393
+                    'placeholder' => __('Select an option', 'invoicing'),
394 394
                     'std'         => 'vat_too',
395 395
                 ),
396 396
 
@@ -404,59 +404,59 @@  discard block
 block discarded – undo
404 404
             'main' => array(
405 405
                 'email_settings_header' => array(
406 406
                     'id'   => 'email_settings_header',
407
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
407
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
408 408
                     'type' => 'header',
409 409
                 ),
410 410
                 'email_from_name' => array(
411 411
                     'id'   => 'email_from_name',
412
-                    'name' => __( 'From Name', 'invoicing' ),
413
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
414
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
412
+                    'name' => __('From Name', 'invoicing'),
413
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
414
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
415 415
                     'type' => 'text',
416 416
                 ),
417 417
                 'email_from' => array(
418 418
                     'id'   => 'email_from',
419
-                    'name' => __( 'From Email', 'invoicing' ),
420
-                    '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),
421
-                    'std' => get_option( 'admin_email' ),
419
+                    'name' => __('From Email', 'invoicing'),
420
+                    '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),
421
+                    'std' => get_option('admin_email'),
422 422
                     'type' => 'text',
423 423
                 ),
424 424
                 'admin_email' => array(
425 425
                     'id'   => 'admin_email',
426
-                    'name' => __( 'Admin Email', 'invoicing' ),
427
-                    'desc' => __( 'Where should we send admin notifications?', 'invoicing' ),
428
-                    'std' => get_option( 'admin_email' ),
426
+                    'name' => __('Admin Email', 'invoicing'),
427
+                    'desc' => __('Where should we send admin notifications?', 'invoicing'),
428
+                    'std' => get_option('admin_email'),
429 429
                     'type' => 'text',
430 430
                 ),
431 431
                 'overdue_settings_header' => array(
432 432
                     'id'   => 'overdue_settings_header',
433
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
433
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
434 434
                     'type' => 'header',
435 435
                 ),
436 436
                 'overdue_active' => array(
437 437
                     'id'   => 'overdue_active',
438
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
439
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
438
+                    'name' => __('Enable Due Date', 'invoicing'),
439
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
440 440
                     'type' => 'checkbox',
441 441
                     'std'  => false,
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,46 +568,46 @@  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
                 'disable_new_user_emails' => array(
583 583
                     'id'   => 'disable_new_user_emails',
584
-                    'name' => __( 'Disable new user emails', 'invoicing' ),
585
-                    'desc' => __( 'Do not send an email to customers when a new user account is created for them.', 'invoicing' ),
584
+                    'name' => __('Disable new user emails', 'invoicing'),
585
+                    'desc' => __('Do not send an email to customers when a new user account is created for them.', 'invoicing'),
586 586
                     'type' => 'checkbox',
587 587
                 ),
588 588
                 'login_to_checkout' => array(
589 589
                     'id'   => 'login_to_checkout',
590
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
591
-                    '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' ),
590
+                    'name' => __('Require Login To Checkout', 'invoicing'),
591
+                    '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'),
592 592
                     'type' => 'checkbox',
593 593
                 ),
594 594
                 'maxmind_license_key' => array(
595 595
                     'id'   => 'maxmind_license_key',
596
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
596
+                    'name' => __('MaxMind License Key', 'invoicing'),
597 597
                     'type' => 'text',
598 598
                     'size' => 'regular',
599
-                    '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>',
599
+                    '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>',
600 600
                 ),
601 601
 
602 602
                 'uninstall_settings' => array(
603 603
                     'id'   => 'uninstall_settings',
604
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
604
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
605 605
                     'type' => 'header',
606 606
                 ),
607 607
                 'remove_data_on_unistall' => array(
608 608
                     'id'   => 'remove_data_on_unistall',
609
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
610
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
609
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
610
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
611 611
                     'type' => 'checkbox',
612 612
                     'std'  => ''
613 613
                 ),
@@ -616,13 +616,13 @@  discard block
 block discarded – undo
616 616
             'custom-css' => array(
617 617
                 'css_settings' => array(
618 618
                     'id'   => 'css_settings',
619
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
619
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
620 620
                     'type' => 'header',
621 621
                 ),
622 622
                 'template_custom_css' => array(
623 623
                     'id' => 'template_custom_css',
624
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
625
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
624
+                    'name' => __('Invoice Template CSS', 'invoicing'),
625
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
626 626
                     'type' => 'textarea',
627 627
                     'class'=> 'regular-text',
628 628
                     'rows' => 10,
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
             'main' => array(
637 637
                 'tool_settings' => array(
638 638
                     'id'   => 'tool_settings',
639
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
640
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
639
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
640
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
641 641
                     'type' => 'tools',
642 642
                 ),
643 643
             ),
Please login to merge, or discard this patch.