Passed
Pull Request — master (#462)
by Viktor
04:15
created
includes/payments/class-getpaid-payment-form-submission.php 2 patches
Indentation   +761 added lines, -761 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,187 +10,187 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form_Submission {
11 11
 
12 12
     /**
13
-	 * Submission ID
14
-	 *
15
-	 * @var string
16
-	 */
17
-	public $id = null;
18
-
19
-	/**
20
-	 * The raw submission data.
21
-	 *
22
-	 * @var array
23
-	 */
24
-	protected $data = null;
25
-
26
-	/**
27
-	 * Submission totals
28
-	 *
29
-	 * @var array
30
-	 */
31
-	protected $totals = array(
32
-
33
-		'subtotal'      => array(
34
-			'initial'   => 0,
35
-			'recurring' => 0,
36
-		),
37
-
38
-		'discount'      => array(
39
-			'initial'   => 0,
40
-			'recurring' => 0,
41
-		),
42
-
43
-		'fees'          => array(
44
-			'initial'   => 0,
45
-			'recurring' => 0,
46
-		),
47
-
48
-		'taxes'         => array(
49
-			'initial'   => 0,
50
-			'recurring' => 0,
51
-		),
52
-
53
-	);
54
-
55
-	/**
56
-	 * Sets the associated payment form.
57
-	 *
58
-	 * @var GetPaid_Payment_Form
59
-	 */
13
+     * Submission ID
14
+     *
15
+     * @var string
16
+     */
17
+    public $id = null;
18
+
19
+    /**
20
+     * The raw submission data.
21
+     *
22
+     * @var array
23
+     */
24
+    protected $data = null;
25
+
26
+    /**
27
+     * Submission totals
28
+     *
29
+     * @var array
30
+     */
31
+    protected $totals = array(
32
+
33
+        'subtotal'      => array(
34
+            'initial'   => 0,
35
+            'recurring' => 0,
36
+        ),
37
+
38
+        'discount'      => array(
39
+            'initial'   => 0,
40
+            'recurring' => 0,
41
+        ),
42
+
43
+        'fees'          => array(
44
+            'initial'   => 0,
45
+            'recurring' => 0,
46
+        ),
47
+
48
+        'taxes'         => array(
49
+            'initial'   => 0,
50
+            'recurring' => 0,
51
+        ),
52
+
53
+    );
54
+
55
+    /**
56
+     * Sets the associated payment form.
57
+     *
58
+     * @var GetPaid_Payment_Form
59
+     */
60 60
     protected $payment_form = null;
61 61
 
62 62
     /**
63
-	 * The country for the submission.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	public $country = null;
68
-
69
-    /**
70
-	 * The state for the submission.
71
-	 *
72
-	 * @since 1.0.19
73
-	 * @var string
74
-	 */
75
-	public $state = null;
76
-
77
-	/**
78
-	 * The invoice associated with the submission.
79
-	 *
80
-	 * @var WPInv_Invoice
81
-	 */
82
-	protected $invoice = null;
83
-
84
-	/**
85
-	 * The recurring item for the submission.
86
-	 *
87
-	 * @var int
88
-	 */
89
-	public $has_recurring = 0;
90
-
91
-	/**
92
-	 * An array of fees for the submission.
93
-	 *
94
-	 * @var array
95
-	 */
96
-	protected $fees = array();
97
-
98
-	/**
99
-	 * An array of discounts for the submission.
100
-	 *
101
-	 * @var array
102
-	 */
103
-	protected $discounts = array();
104
-
105
-	/**
106
-	 * An array of taxes for the submission.
107
-	 *
108
-	 * @var array
109
-	 */
110
-	protected $taxes = array();
111
-
112
-	/**
113
-	 * An array of items for the submission.
114
-	 *
115
-	 * @var GetPaid_Form_Item[]
116
-	 */
117
-	protected $items = array();
118
-
119
-	/**
120
-	 * The last error.
121
-	 *
122
-	 * @var string
123
-	 */
124
-	public $last_error = null;
125
-
126
-    /**
127
-	 * Class constructor.
128
-	 *
129
-	 */
130
-	public function __construct() {
131
-
132
-		// Set the state and country to the default state and country.
133
-		$this->country = wpinv_default_billing_country();
134
-		$this->state   = wpinv_get_default_state();
135
-
136
-		// Do we have an actual submission?
137
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
138
-			$this->load_data( $_POST );
139
-		}
140
-
141
-	}
142
-
143
-	/**
144
-	 * Loads submission data.
145
-	 *
146
-	 * @param array $data
147
-	 */
148
-	public function load_data( $data ) {
149
-
150
-		// Remove slashes from the submitted data...
151
-		$data       = wp_unslash( $data );
152
-
153
-		// Allow plugins to filter the data.
154
-		$data       = apply_filters( 'getpaid_submission_data', $data, $this );
155
-
156
-		// Cache it...
157
-		$this->data = $data;
158
-
159
-		// Then generate a unique id from the data.
160
-		$this->id   = md5( wp_json_encode( $data ) );
161
-
162
-		// Finally, process the submission.
163
-		try {
164
-
165
-			// Each process is passed an instance of the class (with reference)
166
-			// and should throw an Exception whenever it encounters one.
167
-			$processors = apply_filters(
168
-				'getpaid_payment_form_submission_processors',
169
-				array(
170
-					array( $this, 'process_payment_form' ),
171
-					array( $this, 'process_invoice' ),
172
-					array( $this, 'process_fees' ),
173
-					array( $this, 'process_items' ),
174
-					array( $this, 'process_taxes' ),
175
-					array( $this, 'process_discount' ),
176
-				),
177
-				$this		
178
-			);
179
-
180
-			foreach ( $processors as $processor ) {
181
-				call_user_func_array( $processor, array( &$this ) );
182
-			}
183
-
184
-		} catch ( Exception $e ) {
185
-			$this->last_error = $e->getMessage();
186
-		}
187
-
188
-		// Fired when we are done processing a submission.
189
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
190
-
191
-	}
192
-
193
-	/*
63
+     * The country for the submission.
64
+     *
65
+     * @var string
66
+     */
67
+    public $country = null;
68
+
69
+    /**
70
+     * The state for the submission.
71
+     *
72
+     * @since 1.0.19
73
+     * @var string
74
+     */
75
+    public $state = null;
76
+
77
+    /**
78
+     * The invoice associated with the submission.
79
+     *
80
+     * @var WPInv_Invoice
81
+     */
82
+    protected $invoice = null;
83
+
84
+    /**
85
+     * The recurring item for the submission.
86
+     *
87
+     * @var int
88
+     */
89
+    public $has_recurring = 0;
90
+
91
+    /**
92
+     * An array of fees for the submission.
93
+     *
94
+     * @var array
95
+     */
96
+    protected $fees = array();
97
+
98
+    /**
99
+     * An array of discounts for the submission.
100
+     *
101
+     * @var array
102
+     */
103
+    protected $discounts = array();
104
+
105
+    /**
106
+     * An array of taxes for the submission.
107
+     *
108
+     * @var array
109
+     */
110
+    protected $taxes = array();
111
+
112
+    /**
113
+     * An array of items for the submission.
114
+     *
115
+     * @var GetPaid_Form_Item[]
116
+     */
117
+    protected $items = array();
118
+
119
+    /**
120
+     * The last error.
121
+     *
122
+     * @var string
123
+     */
124
+    public $last_error = null;
125
+
126
+    /**
127
+     * Class constructor.
128
+     *
129
+     */
130
+    public function __construct() {
131
+
132
+        // Set the state and country to the default state and country.
133
+        $this->country = wpinv_default_billing_country();
134
+        $this->state   = wpinv_get_default_state();
135
+
136
+        // Do we have an actual submission?
137
+        if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
138
+            $this->load_data( $_POST );
139
+        }
140
+
141
+    }
142
+
143
+    /**
144
+     * Loads submission data.
145
+     *
146
+     * @param array $data
147
+     */
148
+    public function load_data( $data ) {
149
+
150
+        // Remove slashes from the submitted data...
151
+        $data       = wp_unslash( $data );
152
+
153
+        // Allow plugins to filter the data.
154
+        $data       = apply_filters( 'getpaid_submission_data', $data, $this );
155
+
156
+        // Cache it...
157
+        $this->data = $data;
158
+
159
+        // Then generate a unique id from the data.
160
+        $this->id   = md5( wp_json_encode( $data ) );
161
+
162
+        // Finally, process the submission.
163
+        try {
164
+
165
+            // Each process is passed an instance of the class (with reference)
166
+            // and should throw an Exception whenever it encounters one.
167
+            $processors = apply_filters(
168
+                'getpaid_payment_form_submission_processors',
169
+                array(
170
+                    array( $this, 'process_payment_form' ),
171
+                    array( $this, 'process_invoice' ),
172
+                    array( $this, 'process_fees' ),
173
+                    array( $this, 'process_items' ),
174
+                    array( $this, 'process_taxes' ),
175
+                    array( $this, 'process_discount' ),
176
+                ),
177
+                $this		
178
+            );
179
+
180
+            foreach ( $processors as $processor ) {
181
+                call_user_func_array( $processor, array( &$this ) );
182
+            }
183
+
184
+        } catch ( Exception $e ) {
185
+            $this->last_error = $e->getMessage();
186
+        }
187
+
188
+        // Fired when we are done processing a submission.
189
+        do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
190
+
191
+    }
192
+
193
+    /*
194 194
 	|--------------------------------------------------------------------------
195 195
 	| Payment Forms.
196 196
 	|--------------------------------------------------------------------------
@@ -199,39 +199,39 @@  discard block
 block discarded – undo
199 199
 	| submission has an active payment form etc.
200 200
     */
201 201
 
202
-	/**
203
-	 * Prepares the submission's payment form.
204
-	 *
205
-	 * @since 1.0.19
206
-	 */
207
-	public function process_payment_form() {
202
+    /**
203
+     * Prepares the submission's payment form.
204
+     *
205
+     * @since 1.0.19
206
+     */
207
+    public function process_payment_form() {
208 208
 
209
-		// Every submission needs an active payment form.
210
-		if ( empty( $this->data['form_id'] ) ) {
211
-			throw new Exception( __( 'Missing payment form', 'invoicing' ) );
212
-		}
209
+        // Every submission needs an active payment form.
210
+        if ( empty( $this->data['form_id'] ) ) {
211
+            throw new Exception( __( 'Missing payment form', 'invoicing' ) );
212
+        }
213 213
 
214
-		// Fetch the payment form.
215
-		$this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
214
+        // Fetch the payment form.
215
+        $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
216 216
 
217
-		if ( ! $this->payment_form->is_active() ) {
218
-			throw new Exception( __( 'Payment form not active', 'invoicing' ) );
219
-		}
217
+        if ( ! $this->payment_form->is_active() ) {
218
+            throw new Exception( __( 'Payment form not active', 'invoicing' ) );
219
+        }
220 220
 
221
-		do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
222
-	}
221
+        do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
222
+    }
223 223
 
224 224
     /**
225
-	 * Returns the payment form.
226
-	 *
227
-	 * @since 1.0.19
228
-	 * @return GetPaid_Payment_Form
229
-	 */
230
-	public function get_payment_form() {
231
-		return $this->payment_form;
232
-	}
225
+     * Returns the payment form.
226
+     *
227
+     * @since 1.0.19
228
+     * @return GetPaid_Payment_Form
229
+     */
230
+    public function get_payment_form() {
231
+        return $this->payment_form;
232
+    }
233 233
 
234
-	/*
234
+    /*
235 235
 	|--------------------------------------------------------------------------
236 236
 	| Invoices.
237 237
 	|--------------------------------------------------------------------------
@@ -240,61 +240,61 @@  discard block
 block discarded – undo
240 240
 	| might be for an existing invoice.
241 241
 	*/
242 242
 
243
-	/**
244
-	 * Prepares the submission's invoice.
245
-	 *
246
-	 * @since 1.0.19
247
-	 */
248
-	public function process_invoice() {
243
+    /**
244
+     * Prepares the submission's invoice.
245
+     *
246
+     * @since 1.0.19
247
+     */
248
+    public function process_invoice() {
249 249
 
250
-		// Abort if there is no invoice.
251
-		if ( empty( $this->data['invoice_id'] ) ) {
252
-			return;
253
-		}
250
+        // Abort if there is no invoice.
251
+        if ( empty( $this->data['invoice_id'] ) ) {
252
+            return;
253
+        }
254 254
 
255
-		// If the submission is for an existing invoice, ensure that it exists
256
-		// and that it is not paid for.
257
-		$invoice = wpinv_get_invoice( $this->data['invoice_id'] );
255
+        // If the submission is for an existing invoice, ensure that it exists
256
+        // and that it is not paid for.
257
+        $invoice = wpinv_get_invoice( $this->data['invoice_id'] );
258 258
 
259 259
         if ( empty( $invoice ) ) {
260
-			throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
261
-		}
262
-
263
-		if ( $invoice->is_paid() ) {
264
-			throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
265
-		}
266
-
267
-		$this->payment_form->set_items( $invoice->get_items() );
268
-		$this->payment_form->invoice = $invoice;
269
-
270
-		$this->country = $invoice->get_country();
271
-		$this->state   = $invoice->get_state();
272
-		$this->invoice = $invoice;
273
-
274
-		do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
275
-	}
276
-
277
-	/**
278
-	 * Returns the associated invoice.
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @return WPInv_Invoice
282
-	 */
283
-	public function get_invoice() {
284
-		return $this->invoice;
285
-	}
286
-
287
-	/**
288
-	 * Checks whether there is an invoice associated with this submission.
289
-	 *
290
-	 * @since 1.0.19
291
-	 * @return bool
292
-	 */
293
-	public function has_invoice() {
294
-		return ! empty( $this->invoice );
295
-	}
296
-
297
-	/*
260
+            throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
261
+        }
262
+
263
+        if ( $invoice->is_paid() ) {
264
+            throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
265
+        }
266
+
267
+        $this->payment_form->set_items( $invoice->get_items() );
268
+        $this->payment_form->invoice = $invoice;
269
+
270
+        $this->country = $invoice->get_country();
271
+        $this->state   = $invoice->get_state();
272
+        $this->invoice = $invoice;
273
+
274
+        do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
275
+    }
276
+
277
+    /**
278
+     * Returns the associated invoice.
279
+     *
280
+     * @since 1.0.19
281
+     * @return WPInv_Invoice
282
+     */
283
+    public function get_invoice() {
284
+        return $this->invoice;
285
+    }
286
+
287
+    /**
288
+     * Checks whether there is an invoice associated with this submission.
289
+     *
290
+     * @since 1.0.19
291
+     * @return bool
292
+     */
293
+    public function has_invoice() {
294
+        return ! empty( $this->invoice );
295
+    }
296
+
297
+    /*
298 298
 	|--------------------------------------------------------------------------
299 299
 	| Items.
300 300
 	|--------------------------------------------------------------------------
@@ -303,115 +303,115 @@  discard block
 block discarded – undo
303 303
 	| recurring item. But can have an unlimited number of non-recurring items.
304 304
 	*/
305 305
 
306
-	/**
307
-	 * Prepares the submission's items.
308
-	 *
309
-	 * @since 1.0.19
310
-	 */
311
-	public function process_items() {
312
-
313
-		$processor = new GetPaid_Payment_Form_Submission_Items( $this );
314
-
315
-		foreach ( $processor->items as $item ) {
316
-			$this->add_item( $item );
317
-		}
318
-
319
-		do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
320
-	}
321
-
322
-	/**
323
-	 * Adds an item to the submission.
324
-	 *
325
-	 * @since 1.0.19
326
-	 * @param GetPaid_Form_Item $item
327
-	 */
328
-	public function add_item( $item ) {
329
-
330
-		// Make sure that it is available for purchase.
331
-		if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
332
-			return;
333
-		}
334
-
335
-		// Each submission can only contain one recurring item.
336
-		if ( $item->is_recurring() ) {
337
-
338
-			if ( $this->has_recurring != 0 ) {
339
-				throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) );
340
-			}
341
-
342
-			$this->has_recurring = $item->get_id();
343
-
344
-		}
345
-
346
-		// Update the items and totals.
347
-		$this->items[ $item->get_id() ]         = $item;
348
-		$this->totals['subtotal']['initial']   += $item->get_sub_total();
349
-		$this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
350
-
351
-	}
352
-
353
-	/**
354
-	 * Removes a specific item.
355
-	 * 
356
-	 * You should not call this method after the discounts and taxes
357
-	 * have been calculated.
358
-	 *
359
-	 * @since 1.0.19
360
-	 */
361
-	public function remove_item( $item_id ) {
362
-
363
-		if ( isset( $this->items[ $item_id ] ) ) {
364
-			$this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
365
-			$this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
366
-
367
-			if ( $this->items[ $item_id ]->is_recurring() ) {
368
-				$this->has_recurring = 0;
369
-			}
370
-
371
-			unset( $this->items[ $item_id ] );
372
-		}
373
-
374
-	}
375
-
376
-	/**
377
-	 * Returns the subtotal.
378
-	 *
379
-	 * @since 1.0.19
380
-	 */
381
-	public function get_subtotal() {
382
-
383
-		if ( wpinv_prices_include_tax() ) {
384
-			return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
385
-		}
386
-
387
-		return $this->totals['subtotal']['initial'];
388
-	}
389
-
390
-	/**
391
-	 * Returns the recurring subtotal.
392
-	 *
393
-	 * @since 1.0.19
394
-	 */
395
-	public function get_recurring_subtotal() {
396
-
397
-		if ( wpinv_prices_include_tax() ) {
398
-			return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
399
-		}
400
-
401
-		return $this->totals['subtotal']['recurring'];
402
-	}
403
-
404
-	/**
405
-	 * Returns all items.
406
-	 *
407
-	 * @since 1.0.19
408
-	 * @return GetPaid_Form_Item[]
409
-	 */
410
-	public function get_items() {
411
-		return $this->items;
412
-	}
413
-
414
-	/*
306
+    /**
307
+     * Prepares the submission's items.
308
+     *
309
+     * @since 1.0.19
310
+     */
311
+    public function process_items() {
312
+
313
+        $processor = new GetPaid_Payment_Form_Submission_Items( $this );
314
+
315
+        foreach ( $processor->items as $item ) {
316
+            $this->add_item( $item );
317
+        }
318
+
319
+        do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
320
+    }
321
+
322
+    /**
323
+     * Adds an item to the submission.
324
+     *
325
+     * @since 1.0.19
326
+     * @param GetPaid_Form_Item $item
327
+     */
328
+    public function add_item( $item ) {
329
+
330
+        // Make sure that it is available for purchase.
331
+        if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
332
+            return;
333
+        }
334
+
335
+        // Each submission can only contain one recurring item.
336
+        if ( $item->is_recurring() ) {
337
+
338
+            if ( $this->has_recurring != 0 ) {
339
+                throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) );
340
+            }
341
+
342
+            $this->has_recurring = $item->get_id();
343
+
344
+        }
345
+
346
+        // Update the items and totals.
347
+        $this->items[ $item->get_id() ]         = $item;
348
+        $this->totals['subtotal']['initial']   += $item->get_sub_total();
349
+        $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
350
+
351
+    }
352
+
353
+    /**
354
+     * Removes a specific item.
355
+     * 
356
+     * You should not call this method after the discounts and taxes
357
+     * have been calculated.
358
+     *
359
+     * @since 1.0.19
360
+     */
361
+    public function remove_item( $item_id ) {
362
+
363
+        if ( isset( $this->items[ $item_id ] ) ) {
364
+            $this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
365
+            $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
366
+
367
+            if ( $this->items[ $item_id ]->is_recurring() ) {
368
+                $this->has_recurring = 0;
369
+            }
370
+
371
+            unset( $this->items[ $item_id ] );
372
+        }
373
+
374
+    }
375
+
376
+    /**
377
+     * Returns the subtotal.
378
+     *
379
+     * @since 1.0.19
380
+     */
381
+    public function get_subtotal() {
382
+
383
+        if ( wpinv_prices_include_tax() ) {
384
+            return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
385
+        }
386
+
387
+        return $this->totals['subtotal']['initial'];
388
+    }
389
+
390
+    /**
391
+     * Returns the recurring subtotal.
392
+     *
393
+     * @since 1.0.19
394
+     */
395
+    public function get_recurring_subtotal() {
396
+
397
+        if ( wpinv_prices_include_tax() ) {
398
+            return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
399
+        }
400
+
401
+        return $this->totals['subtotal']['recurring'];
402
+    }
403
+
404
+    /**
405
+     * Returns all items.
406
+     *
407
+     * @since 1.0.19
408
+     * @return GetPaid_Form_Item[]
409
+     */
410
+    public function get_items() {
411
+        return $this->items;
412
+    }
413
+
414
+    /*
415 415
 	|--------------------------------------------------------------------------
416 416
 	| Taxes
417 417
 	|--------------------------------------------------------------------------
@@ -420,122 +420,122 @@  discard block
 block discarded – undo
420 420
 	| or only one-time.
421 421
     */
422 422
 
423
-	/**
424
-	 * Prepares the submission's taxes.
425
-	 *
426
-	 * @since 1.0.19
427
-	 */
428
-	public function process_taxes() {
429
-
430
-		// Abort if we're not using taxes.
431
-		if ( ! $this->use_taxes() ) {
432
-			return;
433
-		}
434
-
435
-		// If a custom country && state has been passed in, use it to calculate taxes.
436
-		$country = $this->get_field( 'wpinv_country', 'billing' );
437
-		if ( ! empty( $country ) ) {
438
-			$this->country = $country;
439
-		}
440
-
441
-		$state = $this->get_field( 'wpinv_state', 'billing' );
442
-		if ( ! empty( $state ) ) {
443
-			$this->state = $state;
444
-		}
445
-
446
-		// Abort if the country is not taxable.
447
-		if ( ! wpinv_is_country_taxable( $this->country ) ) {
448
-			return;
449
-		}
450
-
451
-		$processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
452
-
453
-		foreach ( $processor->taxes as $tax ) {
454
-			$this->add_tax( $tax );
455
-		}
456
-
457
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
458
-	}
459
-
460
-	/**
461
-	 * Adds a tax to the submission.
462
-	 *
463
-	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
464
-	 * @since 1.0.19
465
-	 */
466
-	public function add_tax( $tax ) {
467
-
468
-		if ( wpinv_round_tax_per_tax_rate() ) {
469
-			$tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
470
-			$tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
471
-		}
472
-
473
-		$this->taxes[ $tax['name'] ]         = $tax;
474
-		$this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
475
-		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
476
-
477
-	}
478
-
479
-	/**
480
-	 * Removes a specific tax.
481
-	 *
482
-	 * @since 1.0.19
483
-	 */
484
-	public function remove_tax( $tax_name ) {
485
-
486
-		if ( isset( $this->taxes[ $tax_name ] ) ) {
487
-			$this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
488
-			$this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
489
-			unset( $this->taxes[ $tax_name ] );
490
-		}
491
-
492
-	}
493
-
494
-	/**
495
-	 * Whether or not we'll use taxes for the submission.
496
-	 *
497
-	 * @since 1.0.19
498
-	 */
499
-	public function use_taxes() {
500
-
501
-		$use_taxes = wpinv_use_taxes();
502
-
503
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
504
-			$use_taxes = false;
505
-		}
506
-
507
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
508
-
509
-	}
510
-
511
-	/**
512
-	 * Returns the tax.
513
-	 *
514
-	 * @since 1.0.19
515
-	 */
516
-	public function get_tax() {
517
-		return $this->totals['taxes']['initial'];
518
-	}
519
-
520
-	/**
521
-	 * Returns the recurring tax.
522
-	 *
523
-	 * @since 1.0.19
524
-	 */
525
-	public function get_recurring_tax() {
526
-		return $this->totals['taxes']['recurring'];
527
-	}
528
-
529
-	/**
530
-	 * Returns all taxes.
531
-	 *
532
-	 * @since 1.0.19
533
-	 */
534
-	public function get_taxes() {
535
-		return $this->taxes;
536
-	}
537
-
538
-	/*
423
+    /**
424
+     * Prepares the submission's taxes.
425
+     *
426
+     * @since 1.0.19
427
+     */
428
+    public function process_taxes() {
429
+
430
+        // Abort if we're not using taxes.
431
+        if ( ! $this->use_taxes() ) {
432
+            return;
433
+        }
434
+
435
+        // If a custom country && state has been passed in, use it to calculate taxes.
436
+        $country = $this->get_field( 'wpinv_country', 'billing' );
437
+        if ( ! empty( $country ) ) {
438
+            $this->country = $country;
439
+        }
440
+
441
+        $state = $this->get_field( 'wpinv_state', 'billing' );
442
+        if ( ! empty( $state ) ) {
443
+            $this->state = $state;
444
+        }
445
+
446
+        // Abort if the country is not taxable.
447
+        if ( ! wpinv_is_country_taxable( $this->country ) ) {
448
+            return;
449
+        }
450
+
451
+        $processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
452
+
453
+        foreach ( $processor->taxes as $tax ) {
454
+            $this->add_tax( $tax );
455
+        }
456
+
457
+        do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
458
+    }
459
+
460
+    /**
461
+     * Adds a tax to the submission.
462
+     *
463
+     * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
464
+     * @since 1.0.19
465
+     */
466
+    public function add_tax( $tax ) {
467
+
468
+        if ( wpinv_round_tax_per_tax_rate() ) {
469
+            $tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
470
+            $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
471
+        }
472
+
473
+        $this->taxes[ $tax['name'] ]         = $tax;
474
+        $this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
475
+        $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
476
+
477
+    }
478
+
479
+    /**
480
+     * Removes a specific tax.
481
+     *
482
+     * @since 1.0.19
483
+     */
484
+    public function remove_tax( $tax_name ) {
485
+
486
+        if ( isset( $this->taxes[ $tax_name ] ) ) {
487
+            $this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
488
+            $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
489
+            unset( $this->taxes[ $tax_name ] );
490
+        }
491
+
492
+    }
493
+
494
+    /**
495
+     * Whether or not we'll use taxes for the submission.
496
+     *
497
+     * @since 1.0.19
498
+     */
499
+    public function use_taxes() {
500
+
501
+        $use_taxes = wpinv_use_taxes();
502
+
503
+        if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
504
+            $use_taxes = false;
505
+        }
506
+
507
+        return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
508
+
509
+    }
510
+
511
+    /**
512
+     * Returns the tax.
513
+     *
514
+     * @since 1.0.19
515
+     */
516
+    public function get_tax() {
517
+        return $this->totals['taxes']['initial'];
518
+    }
519
+
520
+    /**
521
+     * Returns the recurring tax.
522
+     *
523
+     * @since 1.0.19
524
+     */
525
+    public function get_recurring_tax() {
526
+        return $this->totals['taxes']['recurring'];
527
+    }
528
+
529
+    /**
530
+     * Returns all taxes.
531
+     *
532
+     * @since 1.0.19
533
+     */
534
+    public function get_taxes() {
535
+        return $this->taxes;
536
+    }
537
+
538
+    /*
539 539
 	|--------------------------------------------------------------------------
540 540
 	| Discounts
541 541
 	|--------------------------------------------------------------------------
@@ -544,99 +544,99 @@  discard block
 block discarded – undo
544 544
 	| or only one-time. They also do not have to come from a discount code.
545 545
     */
546 546
 
547
-	/**
548
-	 * Prepares the submission's discount.
549
-	 *
550
-	 * @since 1.0.19
551
-	 */
552
-	public function process_discount() {
553
-
554
-		$initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
555
-		$recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
556
-		$processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
557
-
558
-		foreach ( $processor->discounts as $discount ) {
559
-			$this->add_discount( $discount );
560
-		}
561
-
562
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
563
-	}
564
-
565
-	/**
566
-	 * Adds a discount to the submission.
567
-	 *
568
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
569
-	 * @since 1.0.19
570
-	 */
571
-	public function add_discount( $discount ) {
572
-		$this->discounts[ $discount['name'] ]   = $discount;
573
-		$this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
574
-		$this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
575
-	}
576
-
577
-	/**
578
-	 * Removes a discount from the submission.
579
-	 *
580
-	 * @since 1.0.19
581
-	 */
582
-	public function remove_discount( $name ) {
583
-
584
-		if ( isset( $this->discounts[ $name ] ) ) {
585
-			$this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
586
-			$this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
587
-			unset( $this->discounts[ $name ] );
588
-		}
589
-
590
-	}
591
-
592
-	/**
593
-	 * Checks whether there is a discount code associated with this submission.
594
-	 *
595
-	 * @since 1.0.19
596
-	 * @return bool
597
-	 */
598
-	public function has_discount_code() {
599
-		return ! empty( $this->discounts['discount_code'] );
600
-	}
601
-
602
-	/**
603
-	 * Returns the discount code.
604
-	 *
605
-	 * @since 1.0.19
606
-	 * @return string
607
-	 */
608
-	public function get_discount_code() {
609
-		return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : '';
610
-	}
611
-
612
-	/**
613
-	 * Returns the discount.
614
-	 *
615
-	 * @since 1.0.19
616
-	 */
617
-	public function get_discount() {
618
-		return $this->totals['discount']['initial'];
619
-	}
620
-
621
-	/**
622
-	 * Returns the recurring discount.
623
-	 *
624
-	 * @since 1.0.19
625
-	 */
626
-	public function get_recurring_discount() {
627
-		return $this->totals['discount']['recurring'];
628
-	}
629
-
630
-	/**
631
-	 * Returns all discounts.
632
-	 *
633
-	 * @since 1.0.19
634
-	 */
635
-	public function get_discounts() {
636
-		return $this->discounts;
637
-	}
638
-
639
-	/*
547
+    /**
548
+     * Prepares the submission's discount.
549
+     *
550
+     * @since 1.0.19
551
+     */
552
+    public function process_discount() {
553
+
554
+        $initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
555
+        $recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
556
+        $processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
557
+
558
+        foreach ( $processor->discounts as $discount ) {
559
+            $this->add_discount( $discount );
560
+        }
561
+
562
+        do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
563
+    }
564
+
565
+    /**
566
+     * Adds a discount to the submission.
567
+     *
568
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
569
+     * @since 1.0.19
570
+     */
571
+    public function add_discount( $discount ) {
572
+        $this->discounts[ $discount['name'] ]   = $discount;
573
+        $this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
574
+        $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
575
+    }
576
+
577
+    /**
578
+     * Removes a discount from the submission.
579
+     *
580
+     * @since 1.0.19
581
+     */
582
+    public function remove_discount( $name ) {
583
+
584
+        if ( isset( $this->discounts[ $name ] ) ) {
585
+            $this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
586
+            $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
587
+            unset( $this->discounts[ $name ] );
588
+        }
589
+
590
+    }
591
+
592
+    /**
593
+     * Checks whether there is a discount code associated with this submission.
594
+     *
595
+     * @since 1.0.19
596
+     * @return bool
597
+     */
598
+    public function has_discount_code() {
599
+        return ! empty( $this->discounts['discount_code'] );
600
+    }
601
+
602
+    /**
603
+     * Returns the discount code.
604
+     *
605
+     * @since 1.0.19
606
+     * @return string
607
+     */
608
+    public function get_discount_code() {
609
+        return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : '';
610
+    }
611
+
612
+    /**
613
+     * Returns the discount.
614
+     *
615
+     * @since 1.0.19
616
+     */
617
+    public function get_discount() {
618
+        return $this->totals['discount']['initial'];
619
+    }
620
+
621
+    /**
622
+     * Returns the recurring discount.
623
+     *
624
+     * @since 1.0.19
625
+     */
626
+    public function get_recurring_discount() {
627
+        return $this->totals['discount']['recurring'];
628
+    }
629
+
630
+    /**
631
+     * Returns all discounts.
632
+     *
633
+     * @since 1.0.19
634
+     */
635
+    public function get_discounts() {
636
+        return $this->discounts;
637
+    }
638
+
639
+    /*
640 640
 	|--------------------------------------------------------------------------
641 641
 	| Fees
642 642
 	|--------------------------------------------------------------------------
@@ -646,89 +646,89 @@  discard block
 block discarded – undo
646 646
 	| fees.
647 647
     */
648 648
 
649
-	/**
650
-	 * Prepares the submission's fees.
651
-	 *
652
-	 * @since 1.0.19
653
-	 */
654
-	public function process_fees() {
655
-
656
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
657
-
658
-		foreach ( $fees_processor->fees as $fee ) {
659
-			$this->add_fee( $fee );
660
-		}
661
-
662
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
663
-	}
664
-
665
-	/**
666
-	 * Adds a fee to the submission.
667
-	 *
668
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
669
-	 * @since 1.0.19
670
-	 */
671
-	public function add_fee( $fee ) {
672
-
673
-		$this->fees[ $fee['name'] ]         = $fee;
674
-		$this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
675
-		$this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
676
-
677
-	}
678
-
679
-	/**
680
-	 * Removes a fee from the submission.
681
-	 *
682
-	 * @since 1.0.19
683
-	 */
684
-	public function remove_fee( $name ) {
685
-
686
-		if ( isset( $this->fees[ $name ] ) ) {
687
-			$this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
688
-			$this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
689
-			unset( $this->fees[ $name ] );
690
-		}
691
-
692
-	}
693
-
694
-	/**
695
-	 * Returns the fees.
696
-	 *
697
-	 * @since 1.0.19
698
-	 */
699
-	public function get_fee() {
700
-		return $this->totals['fees']['initial'];
701
-	}
702
-
703
-	/**
704
-	 * Returns the recurring fees.
705
-	 *
706
-	 * @since 1.0.19
707
-	 */
708
-	public function get_recurring_fee() {
709
-		return $this->totals['fees']['recurring'];
710
-	}
711
-
712
-	/**
713
-	 * Returns all fees.
714
-	 *
715
-	 * @since 1.0.19
716
-	 */
717
-	public function get_fees() {
718
-		return $this->fees;
719
-	}
720
-
721
-	/**
722
-	 * Checks if there are any fees for the form.
723
-	 *
724
-	 * @return bool
725
-	 * @since 1.0.19
726
-	 */
727
-	public function has_fees() {
728
-		return count( $this->fees ) !== 0;
729
-	}
730
-
731
-	/*
649
+    /**
650
+     * Prepares the submission's fees.
651
+     *
652
+     * @since 1.0.19
653
+     */
654
+    public function process_fees() {
655
+
656
+        $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
657
+
658
+        foreach ( $fees_processor->fees as $fee ) {
659
+            $this->add_fee( $fee );
660
+        }
661
+
662
+        do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
663
+    }
664
+
665
+    /**
666
+     * Adds a fee to the submission.
667
+     *
668
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
669
+     * @since 1.0.19
670
+     */
671
+    public function add_fee( $fee ) {
672
+
673
+        $this->fees[ $fee['name'] ]         = $fee;
674
+        $this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
675
+        $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
676
+
677
+    }
678
+
679
+    /**
680
+     * Removes a fee from the submission.
681
+     *
682
+     * @since 1.0.19
683
+     */
684
+    public function remove_fee( $name ) {
685
+
686
+        if ( isset( $this->fees[ $name ] ) ) {
687
+            $this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
688
+            $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
689
+            unset( $this->fees[ $name ] );
690
+        }
691
+
692
+    }
693
+
694
+    /**
695
+     * Returns the fees.
696
+     *
697
+     * @since 1.0.19
698
+     */
699
+    public function get_fee() {
700
+        return $this->totals['fees']['initial'];
701
+    }
702
+
703
+    /**
704
+     * Returns the recurring fees.
705
+     *
706
+     * @since 1.0.19
707
+     */
708
+    public function get_recurring_fee() {
709
+        return $this->totals['fees']['recurring'];
710
+    }
711
+
712
+    /**
713
+     * Returns all fees.
714
+     *
715
+     * @since 1.0.19
716
+     */
717
+    public function get_fees() {
718
+        return $this->fees;
719
+    }
720
+
721
+    /**
722
+     * Checks if there are any fees for the form.
723
+     *
724
+     * @return bool
725
+     * @since 1.0.19
726
+     */
727
+    public function has_fees() {
728
+        return count( $this->fees ) !== 0;
729
+    }
730
+
731
+    /*
732 732
 	|--------------------------------------------------------------------------
733 733
 	| MISC
734 734
 	|--------------------------------------------------------------------------
@@ -736,109 +736,109 @@  discard block
 block discarded – undo
736 736
 	| Extra submission functions.
737 737
     */
738 738
 
739
-	/**
740
-	 * Returns the total amount to collect for this submission.
741
-	 *
742
-	 * @since 1.0.19
743
-	 */
744
-	public function get_total() {
745
-		$total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount();
746
-		return max( $total, 0 );
747
-	}
748
-
749
-	/**
750
-	 * Returns the recurring total amount to collect for this submission.
751
-	 *
752
-	 * @since 1.0.19
753
-	 */
754
-	public function get_recurring_total() {
755
-		$total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount();
756
-		return max( $total, 0 );
757
-	}
758
-
759
-	/**
760
-	 * Whether payment details should be collected for this submission.
761
-	 *
762
-	 * @since 1.0.19
763
-	 */
764
-	public function should_collect_payment_details() {
765
-		$initial   = $this->get_total();
766
-		$recurring = $this->get_recurring_total();
767
-
768
-		if ( $this->has_recurring == 0 ) {
769
-			$recurring = 0;
770
-		}
771
-
772
-		$collect = $initial > 0 || $recurring > 0;
773
-		return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
774
-	}
775
-
776
-	/**
777
-	 * Returns the billing email of the user.
778
-	 *
779
-	 * @since 1.0.19
780
-	 */
781
-	public function get_billing_email() {
782
-		return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
783
-	}
784
-
785
-	/**
786
-	 * Checks if the submitter has a billing email.
787
-	 *
788
-	 * @since 1.0.19
789
-	 */
790
-	public function has_billing_email() {
791
-		$billing_email = $this->get_billing_email();
792
-		return ! empty( $billing_email ) && is_email( $billing_email );
793
-	}
794
-
795
-	/**
796
-	 * Returns the appropriate currency for the submission.
797
-	 *
798
-	 * @since 1.0.19
799
-	 * @return string
800
-	 */
801
-	public function get_currency() {
802
-		return $this->has_invoice() ? $this->invoice->get_currency() : wpinv_get_currency();
803
-    }
804
-
805
-    /**
806
-	 * Returns the raw submission data.
807
-	 *
808
-	 * @since 1.0.19
809
-	 * @return array
810
-	 */
811
-	public function get_data() {
812
-		return $this->data;
813
-	}
814
-
815
-	/**
816
-	 * Returns a field from the submission data
817
-	 *
818
-	 * @param string $field
819
-	 * @since 1.0.19
820
-	 * @return mixed|null
821
-	 */
822
-	public function get_field( $field, $sub_array_key = null ) {
823
-		return getpaid_get_array_field( $this->data, $field, $sub_array_key );
824
-	}
825
-
826
-	/**
827
-	 * Checks if a required field is set.
828
-	 *
829
-	 * @since 1.0.19
830
-	 */
831
-	public function is_required_field_set( $field ) {
832
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
833
-	}
834
-
835
-	/**
836
-	 * Formats an amount
837
-	 *
838
-	 * @since 1.0.19
839
-	 */
840
-	public function format_amount( $amount ) {
841
-		return wpinv_price( $amount, $this->get_currency() );
842
-	}
739
+    /**
740
+     * Returns the total amount to collect for this submission.
741
+     *
742
+     * @since 1.0.19
743
+     */
744
+    public function get_total() {
745
+        $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount();
746
+        return max( $total, 0 );
747
+    }
748
+
749
+    /**
750
+     * Returns the recurring total amount to collect for this submission.
751
+     *
752
+     * @since 1.0.19
753
+     */
754
+    public function get_recurring_total() {
755
+        $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount();
756
+        return max( $total, 0 );
757
+    }
758
+
759
+    /**
760
+     * Whether payment details should be collected for this submission.
761
+     *
762
+     * @since 1.0.19
763
+     */
764
+    public function should_collect_payment_details() {
765
+        $initial   = $this->get_total();
766
+        $recurring = $this->get_recurring_total();
767
+
768
+        if ( $this->has_recurring == 0 ) {
769
+            $recurring = 0;
770
+        }
771
+
772
+        $collect = $initial > 0 || $recurring > 0;
773
+        return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
774
+    }
775
+
776
+    /**
777
+     * Returns the billing email of the user.
778
+     *
779
+     * @since 1.0.19
780
+     */
781
+    public function get_billing_email() {
782
+        return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
783
+    }
784
+
785
+    /**
786
+     * Checks if the submitter has a billing email.
787
+     *
788
+     * @since 1.0.19
789
+     */
790
+    public function has_billing_email() {
791
+        $billing_email = $this->get_billing_email();
792
+        return ! empty( $billing_email ) && is_email( $billing_email );
793
+    }
794
+
795
+    /**
796
+     * Returns the appropriate currency for the submission.
797
+     *
798
+     * @since 1.0.19
799
+     * @return string
800
+     */
801
+    public function get_currency() {
802
+        return $this->has_invoice() ? $this->invoice->get_currency() : wpinv_get_currency();
803
+    }
804
+
805
+    /**
806
+     * Returns the raw submission data.
807
+     *
808
+     * @since 1.0.19
809
+     * @return array
810
+     */
811
+    public function get_data() {
812
+        return $this->data;
813
+    }
814
+
815
+    /**
816
+     * Returns a field from the submission data
817
+     *
818
+     * @param string $field
819
+     * @since 1.0.19
820
+     * @return mixed|null
821
+     */
822
+    public function get_field( $field, $sub_array_key = null ) {
823
+        return getpaid_get_array_field( $this->data, $field, $sub_array_key );
824
+    }
825
+
826
+    /**
827
+     * Checks if a required field is set.
828
+     *
829
+     * @since 1.0.19
830
+     */
831
+    public function is_required_field_set( $field ) {
832
+        return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
833
+    }
834
+
835
+    /**
836
+     * Formats an amount
837
+     *
838
+     * @since 1.0.19
839
+     */
840
+    public function format_amount( $amount ) {
841
+        return wpinv_price( $amount, $this->get_currency() );
842
+    }
843 843
 
844 844
 }
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 		$this->state   = wpinv_get_default_state();
135 135
 
136 136
 		// Do we have an actual submission?
137
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
138
-			$this->load_data( $_POST );
137
+		if (isset($_POST['getpaid_payment_form_submission'])) {
138
+			$this->load_data($_POST);
139 139
 		}
140 140
 
141 141
 	}
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param array $data
147 147
 	 */
148
-	public function load_data( $data ) {
148
+	public function load_data($data) {
149 149
 
150 150
 		// Remove slashes from the submitted data...
151
-		$data       = wp_unslash( $data );
151
+		$data       = wp_unslash($data);
152 152
 
153 153
 		// Allow plugins to filter the data.
154
-		$data       = apply_filters( 'getpaid_submission_data', $data, $this );
154
+		$data       = apply_filters('getpaid_submission_data', $data, $this);
155 155
 
156 156
 		// Cache it...
157 157
 		$this->data = $data;
158 158
 
159 159
 		// Then generate a unique id from the data.
160
-		$this->id   = md5( wp_json_encode( $data ) );
160
+		$this->id   = md5(wp_json_encode($data));
161 161
 
162 162
 		// Finally, process the submission.
163 163
 		try {
@@ -167,26 +167,26 @@  discard block
 block discarded – undo
167 167
 			$processors = apply_filters(
168 168
 				'getpaid_payment_form_submission_processors',
169 169
 				array(
170
-					array( $this, 'process_payment_form' ),
171
-					array( $this, 'process_invoice' ),
172
-					array( $this, 'process_fees' ),
173
-					array( $this, 'process_items' ),
174
-					array( $this, 'process_taxes' ),
175
-					array( $this, 'process_discount' ),
170
+					array($this, 'process_payment_form'),
171
+					array($this, 'process_invoice'),
172
+					array($this, 'process_fees'),
173
+					array($this, 'process_items'),
174
+					array($this, 'process_taxes'),
175
+					array($this, 'process_discount'),
176 176
 				),
177 177
 				$this		
178 178
 			);
179 179
 
180
-			foreach ( $processors as $processor ) {
181
-				call_user_func_array( $processor, array( &$this ) );
180
+			foreach ($processors as $processor) {
181
+				call_user_func_array($processor, array(&$this));
182 182
 			}
183 183
 
184
-		} catch ( Exception $e ) {
184
+		} catch (Exception $e) {
185 185
 			$this->last_error = $e->getMessage();
186 186
 		}
187 187
 
188 188
 		// Fired when we are done processing a submission.
189
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
189
+		do_action_ref_array('getpaid_process_submission', array(&$this));
190 190
 
191 191
 	}
192 192
 
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
 	public function process_payment_form() {
208 208
 
209 209
 		// Every submission needs an active payment form.
210
-		if ( empty( $this->data['form_id'] ) ) {
211
-			throw new Exception( __( 'Missing payment form', 'invoicing' ) );
210
+		if (empty($this->data['form_id'])) {
211
+			throw new Exception(__('Missing payment form', 'invoicing'));
212 212
 		}
213 213
 
214 214
 		// Fetch the payment form.
215
-		$this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
215
+		$this->payment_form = new GetPaid_Payment_Form($this->data['form_id']);
216 216
 
217
-		if ( ! $this->payment_form->is_active() ) {
218
-			throw new Exception( __( 'Payment form not active', 'invoicing' ) );
217
+		if (!$this->payment_form->is_active()) {
218
+			throw new Exception(__('Payment form not active', 'invoicing'));
219 219
 		}
220 220
 
221
-		do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
221
+		do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this));
222 222
 	}
223 223
 
224 224
     /**
@@ -248,30 +248,30 @@  discard block
 block discarded – undo
248 248
 	public function process_invoice() {
249 249
 
250 250
 		// Abort if there is no invoice.
251
-		if ( empty( $this->data['invoice_id'] ) ) {
251
+		if (empty($this->data['invoice_id'])) {
252 252
 			return;
253 253
 		}
254 254
 
255 255
 		// If the submission is for an existing invoice, ensure that it exists
256 256
 		// and that it is not paid for.
257
-		$invoice = wpinv_get_invoice( $this->data['invoice_id'] );
257
+		$invoice = wpinv_get_invoice($this->data['invoice_id']);
258 258
 
259
-        if ( empty( $invoice ) ) {
260
-			throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
259
+        if (empty($invoice)) {
260
+			throw new Exception(__('Invalid invoice', 'invoicing'));
261 261
 		}
262 262
 
263
-		if ( $invoice->is_paid() ) {
264
-			throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
263
+		if ($invoice->is_paid()) {
264
+			throw new Exception(__('This invoice is already paid for.', 'invoicing'));
265 265
 		}
266 266
 
267
-		$this->payment_form->set_items( $invoice->get_items() );
267
+		$this->payment_form->set_items($invoice->get_items());
268 268
 		$this->payment_form->invoice = $invoice;
269 269
 
270 270
 		$this->country = $invoice->get_country();
271 271
 		$this->state   = $invoice->get_state();
272 272
 		$this->invoice = $invoice;
273 273
 
274
-		do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
274
+		do_action_ref_array('getpaid_submissions_process_invoice', array(&$this));
275 275
 	}
276 276
 
277 277
 	/**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @return bool
292 292
 	 */
293 293
 	public function has_invoice() {
294
-		return ! empty( $this->invoice );
294
+		return !empty($this->invoice);
295 295
 	}
296 296
 
297 297
 	/*
@@ -310,13 +310,13 @@  discard block
 block discarded – undo
310 310
 	 */
311 311
 	public function process_items() {
312 312
 
313
-		$processor = new GetPaid_Payment_Form_Submission_Items( $this );
313
+		$processor = new GetPaid_Payment_Form_Submission_Items($this);
314 314
 
315
-		foreach ( $processor->items as $item ) {
316
-			$this->add_item( $item );
315
+		foreach ($processor->items as $item) {
316
+			$this->add_item($item);
317 317
 		}
318 318
 
319
-		do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
319
+		do_action_ref_array('getpaid_submissions_process_items', array(&$this));
320 320
 	}
321 321
 
322 322
 	/**
@@ -325,18 +325,18 @@  discard block
 block discarded – undo
325 325
 	 * @since 1.0.19
326 326
 	 * @param GetPaid_Form_Item $item
327 327
 	 */
328
-	public function add_item( $item ) {
328
+	public function add_item($item) {
329 329
 
330 330
 		// Make sure that it is available for purchase.
331
-		if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
331
+		if (!$item->can_purchase() || isset($this->items[$item->get_id()])) {
332 332
 			return;
333 333
 		}
334 334
 
335 335
 		// Each submission can only contain one recurring item.
336
-		if ( $item->is_recurring() ) {
336
+		if ($item->is_recurring()) {
337 337
 
338
-			if ( $this->has_recurring != 0 ) {
339
-				throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) );
338
+			if ($this->has_recurring != 0) {
339
+				throw new Exception(__('You can only buy one recurring item at a time.', 'invoicing'));
340 340
 			}
341 341
 
342 342
 			$this->has_recurring = $item->get_id();
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 		}
345 345
 
346 346
 		// Update the items and totals.
347
-		$this->items[ $item->get_id() ]         = $item;
347
+		$this->items[$item->get_id()]         = $item;
348 348
 		$this->totals['subtotal']['initial']   += $item->get_sub_total();
349 349
 		$this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
350 350
 
@@ -358,17 +358,17 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @since 1.0.19
360 360
 	 */
361
-	public function remove_item( $item_id ) {
361
+	public function remove_item($item_id) {
362 362
 
363
-		if ( isset( $this->items[ $item_id ] ) ) {
364
-			$this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
365
-			$this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
363
+		if (isset($this->items[$item_id])) {
364
+			$this->totals['subtotal']['initial']   -= $this->items[$item_id]->get_sub_total();
365
+			$this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total();
366 366
 
367
-			if ( $this->items[ $item_id ]->is_recurring() ) {
367
+			if ($this->items[$item_id]->is_recurring()) {
368 368
 				$this->has_recurring = 0;
369 369
 			}
370 370
 
371
-			unset( $this->items[ $item_id ] );
371
+			unset($this->items[$item_id]);
372 372
 		}
373 373
 
374 374
 	}
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 */
381 381
 	public function get_subtotal() {
382 382
 
383
-		if ( wpinv_prices_include_tax() ) {
383
+		if (wpinv_prices_include_tax()) {
384 384
 			return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
385 385
 		}
386 386
 
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	 */
395 395
 	public function get_recurring_subtotal() {
396 396
 
397
-		if ( wpinv_prices_include_tax() ) {
397
+		if (wpinv_prices_include_tax()) {
398 398
 			return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
399 399
 		}
400 400
 
@@ -428,33 +428,33 @@  discard block
 block discarded – undo
428 428
 	public function process_taxes() {
429 429
 
430 430
 		// Abort if we're not using taxes.
431
-		if ( ! $this->use_taxes() ) {
431
+		if (!$this->use_taxes()) {
432 432
 			return;
433 433
 		}
434 434
 
435 435
 		// If a custom country && state has been passed in, use it to calculate taxes.
436
-		$country = $this->get_field( 'wpinv_country', 'billing' );
437
-		if ( ! empty( $country ) ) {
436
+		$country = $this->get_field('wpinv_country', 'billing');
437
+		if (!empty($country)) {
438 438
 			$this->country = $country;
439 439
 		}
440 440
 
441
-		$state = $this->get_field( 'wpinv_state', 'billing' );
442
-		if ( ! empty( $state ) ) {
441
+		$state = $this->get_field('wpinv_state', 'billing');
442
+		if (!empty($state)) {
443 443
 			$this->state = $state;
444 444
 		}
445 445
 
446 446
 		// Abort if the country is not taxable.
447
-		if ( ! wpinv_is_country_taxable( $this->country ) ) {
447
+		if (!wpinv_is_country_taxable($this->country)) {
448 448
 			return;
449 449
 		}
450 450
 
451
-		$processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
451
+		$processor = new GetPaid_Payment_Form_Submission_Taxes($this);
452 452
 
453
-		foreach ( $processor->taxes as $tax ) {
454
-			$this->add_tax( $tax );
453
+		foreach ($processor->taxes as $tax) {
454
+			$this->add_tax($tax);
455 455
 		}
456 456
 
457
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
457
+		do_action_ref_array('getpaid_submissions_process_taxes', array(&$this));
458 458
 	}
459 459
 
460 460
 	/**
@@ -463,16 +463,16 @@  discard block
 block discarded – undo
463 463
 	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
464 464
 	 * @since 1.0.19
465 465
 	 */
466
-	public function add_tax( $tax ) {
466
+	public function add_tax($tax) {
467 467
 
468
-		if ( wpinv_round_tax_per_tax_rate() ) {
469
-			$tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
470
-			$tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
468
+		if (wpinv_round_tax_per_tax_rate()) {
469
+			$tax['initial_tax']   = wpinv_round_amount($tax['initial_tax']);
470
+			$tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']);
471 471
 		}
472 472
 
473
-		$this->taxes[ $tax['name'] ]         = $tax;
474
-		$this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
475
-		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
473
+		$this->taxes[$tax['name']]         = $tax;
474
+		$this->totals['taxes']['initial']   += wpinv_sanitize_amount($tax['initial_tax']);
475
+		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']);
476 476
 
477 477
 	}
478 478
 
@@ -481,12 +481,12 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @since 1.0.19
483 483
 	 */
484
-	public function remove_tax( $tax_name ) {
484
+	public function remove_tax($tax_name) {
485 485
 
486
-		if ( isset( $this->taxes[ $tax_name ] ) ) {
487
-			$this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
488
-			$this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
489
-			unset( $this->taxes[ $tax_name ] );
486
+		if (isset($this->taxes[$tax_name])) {
487
+			$this->totals['taxes']['initial']   -= $this->taxes[$tax_name]['initial_tax'];
488
+			$this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax'];
489
+			unset($this->taxes[$tax_name]);
490 490
 		}
491 491
 
492 492
 	}
@@ -500,11 +500,11 @@  discard block
 block discarded – undo
500 500
 
501 501
 		$use_taxes = wpinv_use_taxes();
502 502
 
503
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
503
+		if ($this->has_invoice() && !$this->invoice->is_taxable()) {
504 504
 			$use_taxes = false;
505 505
 		}
506 506
 
507
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
507
+		return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this);
508 508
 
509 509
 	}
510 510
 
@@ -553,13 +553,13 @@  discard block
 block discarded – undo
553 553
 
554 554
 		$initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
555 555
 		$recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
556
-		$processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
556
+		$processor        = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total);
557 557
 
558
-		foreach ( $processor->discounts as $discount ) {
559
-			$this->add_discount( $discount );
558
+		foreach ($processor->discounts as $discount) {
559
+			$this->add_discount($discount);
560 560
 		}
561 561
 
562
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
562
+		do_action_ref_array('getpaid_submissions_process_discounts', array(&$this));
563 563
 	}
564 564
 
565 565
 	/**
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
569 569
 	 * @since 1.0.19
570 570
 	 */
571
-	public function add_discount( $discount ) {
572
-		$this->discounts[ $discount['name'] ]   = $discount;
573
-		$this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
574
-		$this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
571
+	public function add_discount($discount) {
572
+		$this->discounts[$discount['name']]   = $discount;
573
+		$this->totals['discount']['initial']   += wpinv_sanitize_amount($discount['initial_discount']);
574
+		$this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']);
575 575
 	}
576 576
 
577 577
 	/**
@@ -579,12 +579,12 @@  discard block
 block discarded – undo
579 579
 	 *
580 580
 	 * @since 1.0.19
581 581
 	 */
582
-	public function remove_discount( $name ) {
582
+	public function remove_discount($name) {
583 583
 
584
-		if ( isset( $this->discounts[ $name ] ) ) {
585
-			$this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
586
-			$this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
587
-			unset( $this->discounts[ $name ] );
584
+		if (isset($this->discounts[$name])) {
585
+			$this->totals['discount']['initial']   -= $this->discounts[$name]['initial_discount'];
586
+			$this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount'];
587
+			unset($this->discounts[$name]);
588 588
 		}
589 589
 
590 590
 	}
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 * @return bool
597 597
 	 */
598 598
 	public function has_discount_code() {
599
-		return ! empty( $this->discounts['discount_code'] );
599
+		return !empty($this->discounts['discount_code']);
600 600
 	}
601 601
 
602 602
 	/**
@@ -653,13 +653,13 @@  discard block
 block discarded – undo
653 653
 	 */
654 654
 	public function process_fees() {
655 655
 
656
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
656
+		$fees_processor = new GetPaid_Payment_Form_Submission_Fees($this);
657 657
 
658
-		foreach ( $fees_processor->fees as $fee ) {
659
-			$this->add_fee( $fee );
658
+		foreach ($fees_processor->fees as $fee) {
659
+			$this->add_fee($fee);
660 660
 		}
661 661
 
662
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
662
+		do_action_ref_array('getpaid_submissions_process_fees', array(&$this));
663 663
 	}
664 664
 
665 665
 	/**
@@ -668,11 +668,11 @@  discard block
 block discarded – undo
668 668
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
669 669
 	 * @since 1.0.19
670 670
 	 */
671
-	public function add_fee( $fee ) {
671
+	public function add_fee($fee) {
672 672
 
673
-		$this->fees[ $fee['name'] ]         = $fee;
674
-		$this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
675
-		$this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
673
+		$this->fees[$fee['name']]         = $fee;
674
+		$this->totals['fees']['initial']   += wpinv_sanitize_amount($fee['initial_fee']);
675
+		$this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']);
676 676
 
677 677
 	}
678 678
 
@@ -681,12 +681,12 @@  discard block
 block discarded – undo
681 681
 	 *
682 682
 	 * @since 1.0.19
683 683
 	 */
684
-	public function remove_fee( $name ) {
684
+	public function remove_fee($name) {
685 685
 
686
-		if ( isset( $this->fees[ $name ] ) ) {
687
-			$this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
688
-			$this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
689
-			unset( $this->fees[ $name ] );
686
+		if (isset($this->fees[$name])) {
687
+			$this->totals['fees']['initial']   -= $this->fees[$name]['initial_fee'];
688
+			$this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee'];
689
+			unset($this->fees[$name]);
690 690
 		}
691 691
 
692 692
 	}
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 	 * @since 1.0.19
726 726
 	 */
727 727
 	public function has_fees() {
728
-		return count( $this->fees ) !== 0;
728
+		return count($this->fees) !== 0;
729 729
 	}
730 730
 
731 731
 	/*
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
 	 */
744 744
 	public function get_total() {
745 745
 		$total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount();
746
-		return max( $total, 0 );
746
+		return max($total, 0);
747 747
 	}
748 748
 
749 749
 	/**
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	 */
754 754
 	public function get_recurring_total() {
755 755
 		$total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount();
756
-		return max( $total, 0 );
756
+		return max($total, 0);
757 757
 	}
758 758
 
759 759
 	/**
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
 		$initial   = $this->get_total();
766 766
 		$recurring = $this->get_recurring_total();
767 767
 
768
-		if ( $this->has_recurring == 0 ) {
768
+		if ($this->has_recurring == 0) {
769 769
 			$recurring = 0;
770 770
 		}
771 771
 
772 772
 		$collect = $initial > 0 || $recurring > 0;
773
-		return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
773
+		return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this);
774 774
 	}
775 775
 
776 776
 	/**
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	 * @since 1.0.19
780 780
 	 */
781 781
 	public function get_billing_email() {
782
-		return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
782
+		return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this);
783 783
 	}
784 784
 
785 785
 	/**
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 	 */
790 790
 	public function has_billing_email() {
791 791
 		$billing_email = $this->get_billing_email();
792
-		return ! empty( $billing_email ) && is_email( $billing_email );
792
+		return !empty($billing_email) && is_email($billing_email);
793 793
 	}
794 794
 
795 795
 	/**
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 	 * @since 1.0.19
820 820
 	 * @return mixed|null
821 821
 	 */
822
-	public function get_field( $field, $sub_array_key = null ) {
823
-		return getpaid_get_array_field( $this->data, $field, $sub_array_key );
822
+	public function get_field($field, $sub_array_key = null) {
823
+		return getpaid_get_array_field($this->data, $field, $sub_array_key);
824 824
 	}
825 825
 
826 826
 	/**
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
 	 *
829 829
 	 * @since 1.0.19
830 830
 	 */
831
-	public function is_required_field_set( $field ) {
832
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
831
+	public function is_required_field_set($field) {
832
+		return empty($field['required']) || !empty($this->data[$field['id']]);
833 833
 	}
834 834
 
835 835
 	/**
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	 *
838 838
 	 * @since 1.0.19
839 839
 	 */
840
-	public function format_amount( $amount ) {
841
-		return wpinv_price( $amount, $this->get_currency() );
840
+	public function format_amount($amount) {
841
+		return wpinv_price($amount, $this->get_currency());
842 842
 	}
843 843
 
844 844
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-payment-form.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Payment_Form {
@@ -11,23 +11,23 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @param WP_Post $post
13 13
      */
14
-    public static function output_details( $post ) {
15
-        $details = get_post_meta( $post->ID, 'payment_form_data', true );
14
+    public static function output_details($post) {
15
+        $details = get_post_meta($post->ID, 'payment_form_data', true);
16 16
 
17
-        if ( ! is_array( $details ) ) {
17
+        if (!is_array($details)) {
18 18
             return;
19 19
         }
20 20
 
21 21
         echo '<div class="bsui"> <div class="form-row">';
22 22
 
23
-        foreach ( $details as $key => $value ) {
24
-            $key = sanitize_text_field( $key );
23
+        foreach ($details as $key => $value) {
24
+            $key = sanitize_text_field($key);
25 25
 
26
-            if ( is_array( $value ) ) {
27
-                $value = implode( ',', $value );
26
+            if (is_array($value)) {
27
+                $value = implode(',', $value);
28 28
             }
29 29
 
30
-            $value = esc_html( $value );
30
+            $value = esc_html($value);
31 31
             echo "<div class='col-6 form-group'><strong>$key:</strong></div><div class='col-6 form-group'>$value</div>";
32 32
         }
33 33
 
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
      *
41 41
      * @param WP_Post $post
42 42
      */
43
-    public static function output_shortcode( $post ) {
43
+    public static function output_shortcode($post) {
44 44
 
45
-        if ( ! is_numeric( $post ) ) {
45
+        if (!is_numeric($post)) {
46 46
             $post = $post->ID;
47 47
         }
48 48
 
49
-        if ( $post == wpinv_get_default_payment_form() ) {
49
+        if ($post == wpinv_get_default_payment_form()) {
50 50
             echo '&mdash;';
51 51
             return;
52 52
         }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -14,71 +14,71 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
65 65
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
66
-		do_action( 'getpaid_init_admin_hooks', $this );
66
+        do_action( 'getpaid_init_admin_hooks', $this );
67 67
 
68 68
     }
69 69
 
70 70
     /**
71
-	 * Register admin scripts
72
-	 *
73
-	 */
74
-	public function enqeue_scripts() {
71
+     * Register admin scripts
72
+     *
73
+     */
74
+    public function enqeue_scripts() {
75 75
         global $current_screen, $pagenow;
76 76
 
77
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
78
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
77
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
78
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
79 79
 
80 80
         if ( ! empty( $current_screen->post_type ) ) {
81
-			$page = $current_screen->post_type;
81
+            $page = $current_screen->post_type;
82 82
         }
83 83
 
84 84
         // General styles.
@@ -101,21 +101,21 @@  discard block
 block discarded – undo
101 101
         }
102 102
 
103 103
         // Payment form scripts.
104
-		if ( 'wpi_payment_form' == $page && $editing ) {
104
+        if ( 'wpi_payment_form' == $page && $editing ) {
105 105
             $this->load_payment_form_scripts();
106 106
         }
107 107
 
108
-		if ( $page == 'wpinv-subscriptions' ) {
109
-			wp_enqueue_script( 'postbox' );
110
-		}
108
+        if ( $page == 'wpinv-subscriptions' ) {
109
+            wp_enqueue_script( 'postbox' );
110
+        }
111 111
 
112 112
     }
113 113
 
114 114
     /**
115
-	 * Returns admin js translations.
116
-	 *
117
-	 */
118
-	protected function get_admin_i18() {
115
+     * Returns admin js translations.
116
+     *
117
+     */
118
+    protected function get_admin_i18() {
119 119
         global $post;
120 120
 
121 121
         $i18n = array(
@@ -151,50 +151,50 @@  discard block
 block discarded – undo
151 151
             'searching'                 => __( 'Searching', 'invoicing' ),
152 152
         );
153 153
 
154
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
154
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
155 155
 
156
-			$invoice              = new WPInv_Invoice( $post );
157
-			$i18n['save_invoice'] = sprintf(
158
-				__( 'Save %s', 'invoicing' ),
159
-				ucfirst( $invoice->get_type() )
160
-			);
156
+            $invoice              = new WPInv_Invoice( $post );
157
+            $i18n['save_invoice'] = sprintf(
158
+                __( 'Save %s', 'invoicing' ),
159
+                ucfirst( $invoice->get_type() )
160
+            );
161 161
 
162
-			$i18n['invoice_description'] = sprintf(
163
-				__( '%s Description', 'invoicing' ),
164
-				ucfirst( $invoice->get_type() )
165
-			);
162
+            $i18n['invoice_description'] = sprintf(
163
+                __( '%s Description', 'invoicing' ),
164
+                ucfirst( $invoice->get_type() )
165
+            );
166 166
 
167
-		}
168
-		return $i18n;
167
+        }
168
+        return $i18n;
169 169
     }
170 170
 
171 171
     /**
172
-	 * Loads payment form js.
173
-	 *
174
-	 */
175
-	protected function load_payment_form_scripts() {
172
+     * Loads payment form js.
173
+     *
174
+     */
175
+    protected function load_payment_form_scripts() {
176 176
         global $post;
177 177
 
178 178
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
179
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
180
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
179
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
180
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
181 181
 
182
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
183
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
182
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
183
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
184 184
 
185
-		wp_localize_script(
185
+        wp_localize_script(
186 186
             'wpinv-admin-payment-form-script',
187 187
             'wpinvPaymentFormAdmin',
188 188
             array(
189
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
190
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
191
-				'currency'      => wpinv_currency_symbol(),
192
-				'position'      => wpinv_currency_position(),
193
-				'decimals'      => (int) wpinv_decimals(),
194
-				'thousands_sep' => wpinv_thousands_separator(),
195
-				'decimals_sep'  => wpinv_decimal_separator(),
196
-				'form_items'    => gepaid_get_form_items( $post->ID ),
197
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
189
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
190
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
191
+                'currency'      => wpinv_currency_symbol(),
192
+                'position'      => wpinv_currency_position(),
193
+                'decimals'      => (int) wpinv_decimals(),
194
+                'thousands_sep' => wpinv_thousands_separator(),
195
+                'decimals_sep'  => wpinv_decimal_separator(),
196
+                'form_items'    => gepaid_get_form_items( $post->ID ),
197
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
198 198
             )
199 199
         );
200 200
 
@@ -203,20 +203,20 @@  discard block
 block discarded – undo
203 203
     }
204 204
 
205 205
     /**
206
-	 * Add our classes to admin pages.
206
+     * Add our classes to admin pages.
207 207
      *
208 208
      * @param string $classes
209 209
      * @return string
210
-	 *
211
-	 */
210
+     *
211
+     */
212 212
     public function admin_body_class( $classes ) {
213
-		global $pagenow, $post, $current_screen;
213
+        global $pagenow, $post, $current_screen;
214 214
 
215 215
 
216 216
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
217 217
 
218 218
         if ( ! empty( $current_screen->post_type ) ) {
219
-			$page = $current_screen->post_type;
219
+            $page = $current_screen->post_type;
220 220
         }
221 221
 
222 222
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -225,29 +225,29 @@  discard block
 block discarded – undo
225 225
 
226 226
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
227 227
             $classes .= ' wpinv-cpt wpinv';
228
-		}
228
+        }
229 229
 		
230
-		if ( getpaid_is_invoice_post_type( $page ) ) {
230
+        if ( getpaid_is_invoice_post_type( $page ) ) {
231 231
             $classes .= ' getpaid-is-invoice-cpt';
232 232
         }
233 233
 
234
-		return $classes;
234
+        return $classes;
235 235
     }
236 236
 
237 237
     /**
238
-	 * Maybe show the AyeCode Connect Notice.
239
-	 */
240
-	public function init_ayecode_connect_helper(){
238
+     * Maybe show the AyeCode Connect Notice.
239
+     */
240
+    public function init_ayecode_connect_helper(){
241 241
 
242 242
         new AyeCode_Connect_Helper(
243 243
             array(
244
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
245
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
246
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
247
-				'connect_button'    => __("Connect Site","invoicing"),
248
-				'connecting_button'    => __("Connecting...","invoicing"),
249
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
250
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
244
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
245
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
246
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
247
+                'connect_button'    => __("Connect Site","invoicing"),
248
+                'connecting_button'    => __("Connecting...","invoicing"),
249
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
250
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
251 251
             ),
252 252
             array( 'wpi-addons' )
253 253
         );
@@ -259,21 +259,21 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public function activation_redirect() {
261 261
 
262
-		// Bail if no activation redirect.
263
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
264
-			return;
265
-		}
262
+        // Bail if no activation redirect.
263
+        if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
264
+            return;
265
+        }
266 266
 
267
-		// Delete the redirect transient.
268
-		delete_transient( '_wpinv_activation_redirect' );
267
+        // Delete the redirect transient.
268
+        delete_transient( '_wpinv_activation_redirect' );
269 269
 
270
-		// Bail if activating from network, or bulk
271
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
272
-			return;
273
-		}
270
+        // Bail if activating from network, or bulk
271
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
272
+            return;
273
+        }
274 274
 
275
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
276
-		exit;
275
+        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
276
+        exit;
277 277
     }
278 278
 
279 279
     /**
@@ -288,162 +288,162 @@  discard block
 block discarded – undo
288 288
 
289 289
     }
290 290
 
291
-	/**
291
+    /**
292 292
      * Sends a payment reminder to a customer.
293
-	 * 
294
-	 * @param array $args
293
+     * 
294
+     * @param array $args
295 295
      */
296 296
     public function send_customer_invoice( $args ) {
297
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
297
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
298 298
 
299
-		if ( $sent ) {
300
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
301
-		} else {
302
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
303
-		}
299
+        if ( $sent ) {
300
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
301
+        } else {
302
+            $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
303
+        }
304 304
 
305
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
306
-		exit;
307
-	}
305
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
306
+        exit;
307
+    }
308 308
 
309
-	/**
309
+    /**
310 310
      * Sends a payment reminder to a customer.
311
-	 * 
312
-	 * @param array $args
311
+     * 
312
+     * @param array $args
313 313
      */
314 314
     public function send_customer_payment_reminder( $args ) {
315
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
315
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
316 316
 
317
-		if ( $sent ) {
318
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
319
-		} else {
320
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
321
-		}
317
+        if ( $sent ) {
318
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
319
+        } else {
320
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
321
+        }
322 322
 
323
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
324
-		exit;
325
-	}
323
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
324
+        exit;
325
+    }
326 326
 
327
-	/**
327
+    /**
328 328
      * Resets tax rates.
329
-	 * 
329
+     * 
330 330
      */
331 331
     public function admin_reset_tax_rates() {
332 332
 
333
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
334
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
335
-		exit;
333
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
334
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
335
+        exit;
336 336
 
337
-	}
337
+    }
338 338
 
339 339
     /**
340
-	 * Returns an array of admin notices.
341
-	 *
342
-	 * @since       1.0.19
340
+     * Returns an array of admin notices.
341
+     *
342
+     * @since       1.0.19
343 343
      * @return array
344
-	 */
345
-	public function get_notices() {
346
-		$notices = get_option( 'wpinv_admin_notices' );
344
+     */
345
+    public function get_notices() {
346
+        $notices = get_option( 'wpinv_admin_notices' );
347 347
         return is_array( $notices ) ? $notices : array();
348
-	}
349
-
350
-	/**
351
-	 * Clears all admin notices
352
-	 *
353
-	 * @access      public
354
-	 * @since       1.0.19
355
-	 */
356
-	public function clear_notices() {
357
-		delete_option( 'wpinv_admin_notices' );
358
-	}
359
-
360
-	/**
361
-	 * Saves a new admin notice
362
-	 *
363
-	 * @access      public
364
-	 * @since       1.0.19
365
-	 */
366
-	public function save_notice( $type, $message ) {
367
-		$notices = $this->get_notices();
368
-
369
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
370
-			$notices[ $type ] = array();
371
-		}
372
-
373
-		$notices[ $type ][] = $message;
374
-
375
-		update_option( 'wpinv_admin_notices', $notices );
376
-	}
377
-
378
-	/**
379
-	 * Displays a success notice
380
-	 *
381
-	 * @param       string $msg The message to qeue.
382
-	 * @access      public
383
-	 * @since       1.0.19
384
-	 */
385
-	public function show_success( $msg ) {
386
-		$this->save_notice( 'success', $msg );
387
-	}
388
-
389
-	/**
390
-	 * Displays a error notice
391
-	 *
392
-	 * @access      public
393
-	 * @param       string $msg The message to qeue.
394
-	 * @since       1.0.19
395
-	 */
396
-	public function show_error( $msg ) {
397
-		$this->save_notice( 'error', $msg );
398
-	}
399
-
400
-	/**
401
-	 * Displays a warning notice
402
-	 *
403
-	 * @access      public
404
-	 * @param       string $msg The message to qeue.
405
-	 * @since       1.0.19
406
-	 */
407
-	public function show_warning( $msg ) {
408
-		$this->save_notice( 'warning', $msg );
409
-	}
410
-
411
-	/**
412
-	 * Displays a info notice
413
-	 *
414
-	 * @access      public
415
-	 * @param       string $msg The message to qeue.
416
-	 * @since       1.0.19
417
-	 */
418
-	public function show_info( $msg ) {
419
-		$this->save_notice( 'info', $msg );
420
-	}
421
-
422
-	/**
423
-	 * Show notices
424
-	 *
425
-	 * @access      public
426
-	 * @since       1.0.19
427
-	 */
428
-	public function show_notices() {
348
+    }
349
+
350
+    /**
351
+     * Clears all admin notices
352
+     *
353
+     * @access      public
354
+     * @since       1.0.19
355
+     */
356
+    public function clear_notices() {
357
+        delete_option( 'wpinv_admin_notices' );
358
+    }
359
+
360
+    /**
361
+     * Saves a new admin notice
362
+     *
363
+     * @access      public
364
+     * @since       1.0.19
365
+     */
366
+    public function save_notice( $type, $message ) {
367
+        $notices = $this->get_notices();
368
+
369
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
370
+            $notices[ $type ] = array();
371
+        }
372
+
373
+        $notices[ $type ][] = $message;
374
+
375
+        update_option( 'wpinv_admin_notices', $notices );
376
+    }
377
+
378
+    /**
379
+     * Displays a success notice
380
+     *
381
+     * @param       string $msg The message to qeue.
382
+     * @access      public
383
+     * @since       1.0.19
384
+     */
385
+    public function show_success( $msg ) {
386
+        $this->save_notice( 'success', $msg );
387
+    }
388
+
389
+    /**
390
+     * Displays a error notice
391
+     *
392
+     * @access      public
393
+     * @param       string $msg The message to qeue.
394
+     * @since       1.0.19
395
+     */
396
+    public function show_error( $msg ) {
397
+        $this->save_notice( 'error', $msg );
398
+    }
399
+
400
+    /**
401
+     * Displays a warning notice
402
+     *
403
+     * @access      public
404
+     * @param       string $msg The message to qeue.
405
+     * @since       1.0.19
406
+     */
407
+    public function show_warning( $msg ) {
408
+        $this->save_notice( 'warning', $msg );
409
+    }
410
+
411
+    /**
412
+     * Displays a info notice
413
+     *
414
+     * @access      public
415
+     * @param       string $msg The message to qeue.
416
+     * @since       1.0.19
417
+     */
418
+    public function show_info( $msg ) {
419
+        $this->save_notice( 'info', $msg );
420
+    }
421
+
422
+    /**
423
+     * Show notices
424
+     *
425
+     * @access      public
426
+     * @since       1.0.19
427
+     */
428
+    public function show_notices() {
429 429
 
430 430
         $notices = $this->get_notices();
431 431
         $this->clear_notices();
432 432
 
433
-		foreach ( $notices as $type => $messages ) {
433
+        foreach ( $notices as $type => $messages ) {
434 434
 
435
-			if ( ! is_array( $messages ) ) {
436
-				continue;
437
-			}
435
+            if ( ! is_array( $messages ) ) {
436
+                continue;
437
+            }
438 438
 
439 439
             $type  = sanitize_key( $type );
440
-			foreach ( $messages as $message ) {
440
+            foreach ( $messages as $message ) {
441 441
                 $message = wp_kses_post( $message );
442
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
442
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
443 443
             }
444 444
 
445 445
         }
446 446
 
447
-	}
447
+    }
448 448
 
449 449
 }
Please login to merge, or discard this patch.
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
65
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
66
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
64
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
65
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
66
+		do_action('getpaid_init_admin_hooks', $this);
67 67
 
68 68
     }
69 69
 
@@ -74,39 +74,39 @@  discard block
 block discarded – undo
74 74
 	public function enqeue_scripts() {
75 75
         global $current_screen, $pagenow;
76 76
 
77
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
77
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
78 78
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
79 79
 
80
-        if ( ! empty( $current_screen->post_type ) ) {
80
+        if (!empty($current_screen->post_type)) {
81 81
 			$page = $current_screen->post_type;
82 82
         }
83 83
 
84 84
         // General styles.
85
-        if ( false !== stripos( $page, 'wpi' ) ) {
85
+        if (false !== stripos($page, 'wpi')) {
86 86
 
87 87
             // Styles.
88
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
89
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
90
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
91
-            wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' );
88
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
89
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
90
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
91
+            wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16');
92 92
 
93 93
             // Scripts.
94
-            wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true );
95
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
94
+            wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true);
95
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
96 96
 
97
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
98
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ),  $version );
99
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
97
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
98
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version);
99
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
100 100
 
101 101
         }
102 102
 
103 103
         // Payment form scripts.
104
-		if ( 'wpi_payment_form' == $page && $editing ) {
104
+		if ('wpi_payment_form' == $page && $editing) {
105 105
             $this->load_payment_form_scripts();
106 106
         }
107 107
 
108
-		if ( $page == 'wpinv-subscriptions' ) {
109
-			wp_enqueue_script( 'postbox' );
108
+		if ($page == 'wpinv-subscriptions') {
109
+			wp_enqueue_script('postbox');
110 110
 		}
111 111
 
112 112
     }
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
         global $post;
120 120
 
121 121
         $i18n = array(
122
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
123
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
124
-            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
125
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
126
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
127
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
128
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
122
+            'ajax_url'                  => admin_url('admin-ajax.php'),
123
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
124
+            'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
125
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
126
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
127
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
128
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
129 129
             'tax'                       => wpinv_tax_amount(),
130 130
             'discount'                  => 0,
131 131
             'currency_symbol'           => wpinv_currency_symbol(),
@@ -133,35 +133,35 @@  discard block
 block discarded – undo
133 133
             'thousand_sep'              => wpinv_thousands_separator(),
134 134
             'decimal_sep'               => wpinv_decimal_separator(),
135 135
             'decimals'                  => wpinv_decimals(),
136
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
137
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
138
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
139
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
140
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
141
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
142
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
143
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
144
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
145
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
146
-            'action_edit'               => __( 'Edit', 'invoicing' ),
147
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
148
-            'item_description'          => __( 'Item Description', 'invoicing' ),
149
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
150
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
151
-            'searching'                 => __( 'Searching', 'invoicing' ),
136
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
137
+            'status_publish'            => wpinv_status_nicename('publish'),
138
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
139
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
140
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
141
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
142
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
143
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
144
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
145
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
146
+            'action_edit'               => __('Edit', 'invoicing'),
147
+            'action_cancel'             => __('Cancel', 'invoicing'),
148
+            'item_description'          => __('Item Description', 'invoicing'),
149
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
150
+            'discount_description'      => __('Discount Description', 'invoicing'),
151
+            'searching'                 => __('Searching', 'invoicing'),
152 152
         );
153 153
 
154
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
154
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
155 155
 
156
-			$invoice              = new WPInv_Invoice( $post );
156
+			$invoice              = new WPInv_Invoice($post);
157 157
 			$i18n['save_invoice'] = sprintf(
158
-				__( 'Save %s', 'invoicing' ),
159
-				ucfirst( $invoice->get_type() )
158
+				__('Save %s', 'invoicing'),
159
+				ucfirst($invoice->get_type())
160 160
 			);
161 161
 
162 162
 			$i18n['invoice_description'] = sprintf(
163
-				__( '%s Description', 'invoicing' ),
164
-				ucfirst( $invoice->get_type() )
163
+				__('%s Description', 'invoicing'),
164
+				ucfirst($invoice->get_type())
165 165
 			);
166 166
 
167 167
 		}
@@ -175,30 +175,30 @@  discard block
 block discarded – undo
175 175
 	protected function load_payment_form_scripts() {
176 176
         global $post;
177 177
 
178
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
179
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
180
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
178
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
179
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
180
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
181 181
 
182
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
183
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
182
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
183
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
184 184
 
185 185
 		wp_localize_script(
186 186
             'wpinv-admin-payment-form-script',
187 187
             'wpinvPaymentFormAdmin',
188 188
             array(
189
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
190
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
189
+				'elements'      => wpinv_get_data('payment-form-elements'),
190
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
191 191
 				'currency'      => wpinv_currency_symbol(),
192 192
 				'position'      => wpinv_currency_position(),
193 193
 				'decimals'      => (int) wpinv_decimals(),
194 194
 				'thousands_sep' => wpinv_thousands_separator(),
195 195
 				'decimals_sep'  => wpinv_decimal_separator(),
196
-				'form_items'    => gepaid_get_form_items( $post->ID ),
196
+				'form_items'    => gepaid_get_form_items($post->ID),
197 197
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
198 198
             )
199 199
         );
200 200
 
201
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
201
+        wp_enqueue_script('wpinv-admin-payment-form-script');
202 202
 
203 203
     }
204 204
 
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
      * @return string
210 210
 	 *
211 211
 	 */
212
-    public function admin_body_class( $classes ) {
212
+    public function admin_body_class($classes) {
213 213
 		global $pagenow, $post, $current_screen;
214 214
 
215 215
 
216
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
216
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
217 217
 
218
-        if ( ! empty( $current_screen->post_type ) ) {
218
+        if (!empty($current_screen->post_type)) {
219 219
 			$page = $current_screen->post_type;
220 220
         }
221 221
 
222
-        if ( false !== stripos( $page, 'wpi' ) ) {
223
-            $classes .= ' wpi-' . sanitize_key( $page );
222
+        if (false !== stripos($page, 'wpi')) {
223
+            $classes .= ' wpi-' . sanitize_key($page);
224 224
         }
225 225
 
226
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
226
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
227 227
             $classes .= ' wpinv-cpt wpinv';
228 228
 		}
229 229
 		
230
-		if ( getpaid_is_invoice_post_type( $page ) ) {
230
+		if (getpaid_is_invoice_post_type($page)) {
231 231
             $classes .= ' getpaid-is-invoice-cpt';
232 232
         }
233 233
 
@@ -237,19 +237,19 @@  discard block
 block discarded – undo
237 237
     /**
238 238
 	 * Maybe show the AyeCode Connect Notice.
239 239
 	 */
240
-	public function init_ayecode_connect_helper(){
240
+	public function init_ayecode_connect_helper() {
241 241
 
242 242
         new AyeCode_Connect_Helper(
243 243
             array(
244
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
245
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
246
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
247
-				'connect_button'    => __("Connect Site","invoicing"),
248
-				'connecting_button'    => __("Connecting...","invoicing"),
249
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
250
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
244
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
245
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
246
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
247
+				'connect_button'    => __("Connect Site", "invoicing"),
248
+				'connecting_button'    => __("Connecting...", "invoicing"),
249
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
250
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
251 251
             ),
252
-            array( 'wpi-addons' )
252
+            array('wpi-addons')
253 253
         );
254 254
 
255 255
     }
@@ -260,19 +260,19 @@  discard block
 block discarded – undo
260 260
     public function activation_redirect() {
261 261
 
262 262
 		// Bail if no activation redirect.
263
-		if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) {
263
+		if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) {
264 264
 			return;
265 265
 		}
266 266
 
267 267
 		// Delete the redirect transient.
268
-		delete_transient( '_wpinv_activation_redirect' );
268
+		delete_transient('_wpinv_activation_redirect');
269 269
 
270 270
 		// Bail if activating from network, or bulk
271
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
271
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
272 272
 			return;
273 273
 		}
274 274
 
275
-		wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
275
+		wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
276 276
 		exit;
277 277
     }
278 278
 
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function maybe_do_admin_action() {
283 283
 
284
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
285
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
286
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
284
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
285
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
286
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
287 287
         }
288 288
 
289 289
     }
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
 	 * 
294 294
 	 * @param array $args
295 295
      */
296
-    public function send_customer_invoice( $args ) {
297
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) );
296
+    public function send_customer_invoice($args) {
297
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']));
298 298
 
299
-		if ( $sent ) {
300
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
299
+		if ($sent) {
300
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
301 301
 		} else {
302
-			$this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) );
302
+			$this->show_error(__('Could not sent the invoice to the customer', 'invoicing'));
303 303
 		}
304 304
 
305
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
305
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
306 306
 		exit;
307 307
 	}
308 308
 
@@ -311,16 +311,16 @@  discard block
 block discarded – undo
311 311
 	 * 
312 312
 	 * @param array $args
313 313
      */
314
-    public function send_customer_payment_reminder( $args ) {
315
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
314
+    public function send_customer_payment_reminder($args) {
315
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
316 316
 
317
-		if ( $sent ) {
318
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
317
+		if ($sent) {
318
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
319 319
 		} else {
320
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
320
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
321 321
 		}
322 322
 
323
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
323
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
324 324
 		exit;
325 325
 	}
326 326
 
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
      */
331 331
     public function admin_reset_tax_rates() {
332 332
 
333
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
334
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
333
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
334
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
335 335
 		exit;
336 336
 
337 337
 	}
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
      * @return array
344 344
 	 */
345 345
 	public function get_notices() {
346
-		$notices = get_option( 'wpinv_admin_notices' );
347
-        return is_array( $notices ) ? $notices : array();
346
+		$notices = get_option('wpinv_admin_notices');
347
+        return is_array($notices) ? $notices : array();
348 348
 	}
349 349
 
350 350
 	/**
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	 * @since       1.0.19
355 355
 	 */
356 356
 	public function clear_notices() {
357
-		delete_option( 'wpinv_admin_notices' );
357
+		delete_option('wpinv_admin_notices');
358 358
 	}
359 359
 
360 360
 	/**
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
 	 * @access      public
364 364
 	 * @since       1.0.19
365 365
 	 */
366
-	public function save_notice( $type, $message ) {
366
+	public function save_notice($type, $message) {
367 367
 		$notices = $this->get_notices();
368 368
 
369
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
370
-			$notices[ $type ] = array();
369
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
370
+			$notices[$type] = array();
371 371
 		}
372 372
 
373
-		$notices[ $type ][] = $message;
373
+		$notices[$type][] = $message;
374 374
 
375
-		update_option( 'wpinv_admin_notices', $notices );
375
+		update_option('wpinv_admin_notices', $notices);
376 376
 	}
377 377
 
378 378
 	/**
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @access      public
383 383
 	 * @since       1.0.19
384 384
 	 */
385
-	public function show_success( $msg ) {
386
-		$this->save_notice( 'success', $msg );
385
+	public function show_success($msg) {
386
+		$this->save_notice('success', $msg);
387 387
 	}
388 388
 
389 389
 	/**
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @param       string $msg The message to qeue.
394 394
 	 * @since       1.0.19
395 395
 	 */
396
-	public function show_error( $msg ) {
397
-		$this->save_notice( 'error', $msg );
396
+	public function show_error($msg) {
397
+		$this->save_notice('error', $msg);
398 398
 	}
399 399
 
400 400
 	/**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @param       string $msg The message to qeue.
405 405
 	 * @since       1.0.19
406 406
 	 */
407
-	public function show_warning( $msg ) {
408
-		$this->save_notice( 'warning', $msg );
407
+	public function show_warning($msg) {
408
+		$this->save_notice('warning', $msg);
409 409
 	}
410 410
 
411 411
 	/**
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param       string $msg The message to qeue.
416 416
 	 * @since       1.0.19
417 417
 	 */
418
-	public function show_info( $msg ) {
419
-		$this->save_notice( 'info', $msg );
418
+	public function show_info($msg) {
419
+		$this->save_notice('info', $msg);
420 420
 	}
421 421
 
422 422
 	/**
@@ -430,15 +430,15 @@  discard block
 block discarded – undo
430 430
         $notices = $this->get_notices();
431 431
         $this->clear_notices();
432 432
 
433
-		foreach ( $notices as $type => $messages ) {
433
+		foreach ($notices as $type => $messages) {
434 434
 
435
-			if ( ! is_array( $messages ) ) {
435
+			if (!is_array($messages)) {
436 436
 				continue;
437 437
 			}
438 438
 
439
-            $type  = sanitize_key( $type );
440
-			foreach ( $messages as $message ) {
441
-                $message = wp_kses_post( $message );
439
+            $type = sanitize_key($type);
440
+			foreach ($messages as $message) {
441
+                $message = wp_kses_post($message);
442 442
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
443 443
             }
444 444
 
Please login to merge, or discard this patch.
includes/class-wpinv-euvat.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,27 +55,27 @@
 block discarded – undo
55 55
     public static function vat_rates_settings() {}
56 56
 
57 57
     /**
58
-	 *
59
-	 * @deprecated
60
-	 */
58
+     *
59
+     * @deprecated
60
+     */
61 61
     public static function vat_settings() {}
62 62
 
63 63
     /**
64
-	 *
65
-	 * @deprecated
66
-	 */
64
+     *
65
+     * @deprecated
66
+     */
67 67
     public static function maxmind_folder() {}
68 68
 
69 69
     /**
70
-	 *
71
-	 * @deprecated
72
-	 */
70
+     *
71
+     * @deprecated
72
+     */
73 73
     public static function geoip2_download_database() {}
74 74
 
75 75
     /**
76
-	 *
77
-	 * @deprecated
78
-	 */
76
+     *
77
+     * @deprecated
78
+     */
79 79
     public static function geoip2_download_file() {}
80 80
 
81 81
     /**
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 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
  * @deprecated
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * @deprecated
40 40
      */
41
-    public static function is_eu_state( $country_code ) {
42
-        return getpaid_is_eu_state( $country_code );
41
+    public static function is_eu_state($country_code) {
42
+        return getpaid_is_eu_state($country_code);
43 43
     }
44 44
 
45 45
     /**
46 46
      * @deprecated
47 47
      */
48
-    public static function is_gst_country( $country_code ) {
49
-        return getpaid_is_gst_country( $country_code );
48
+    public static function is_gst_country($country_code) {
49
+        return getpaid_is_gst_country($country_code);
50 50
     }
51 51
 
52 52
     /**
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-taxes.php 2 patches
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -12,210 +12,210 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Taxes {
14 14
 
15
-	/**
16
-	 * Submission taxes.
17
-	 * @var array
18
-	 */
19
-	public $taxes = array();
15
+    /**
16
+     * Submission taxes.
17
+     * @var array
18
+     */
19
+    public $taxes = array();
20
+
21
+    /**
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        // Validate VAT number.
29
+        $this->validate_vat( $submission );
30
+
31
+        foreach ( $submission->get_items() as $item ) {
32
+            $this->process_item_tax( $item, $submission );
33
+        }
34
+
35
+        // Process any existing invoice taxes.
36
+        if ( $submission->has_invoice() ) {
37
+            $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes );
38
+        }
39
+
40
+    }
41
+
42
+    /**
43
+     * Maybe process tax.
44
+     *
45
+     * @since 1.0.19
46
+     * @param GetPaid_Form_Item $item
47
+     * @param GetPaid_Payment_Form_Submission $submission
48
+     */
49
+    public function process_item_tax( $item, $submission ) {
50
+
51
+        $rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
52
+        $rates    = getpaid_filter_item_tax_rates( $item, $rates );
53
+        $taxes    = getpaid_calculate_item_taxes( $item->get_sub_total(), $rates );
54
+        $r_taxes  = getpaid_calculate_item_taxes( $item->get_recurring_sub_total(), $rates );
55
+
56
+        foreach ( $taxes as $name => $amount ) {
57
+            $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
58
+            $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
59
+
60
+            if ( ! isset( $this->taxes[ $name ] ) ) {
61
+                $this->taxes[ $name ] = $tax;
62
+                continue;
63
+            }
64
+
65
+            $this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
66
+            $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
67
+
68
+        }
69
+
70
+    }
20 71
 
21 72
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		// Validate VAT number.
29
-		$this->validate_vat( $submission );
30
-
31
-		foreach ( $submission->get_items() as $item ) {
32
-			$this->process_item_tax( $item, $submission );
33
-		}
34
-
35
-		// Process any existing invoice taxes.
36
-		if ( $submission->has_invoice() ) {
37
-			$this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes );
38
-		}
39
-
40
-	}
41
-
42
-	/**
43
-	 * Maybe process tax.
44
-	 *
45
-	 * @since 1.0.19
46
-	 * @param GetPaid_Form_Item $item
47
-	 * @param GetPaid_Payment_Form_Submission $submission
48
-	 */
49
-	public function process_item_tax( $item, $submission ) {
50
-
51
-		$rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
52
-		$rates    = getpaid_filter_item_tax_rates( $item, $rates );
53
-		$taxes    = getpaid_calculate_item_taxes( $item->get_sub_total(), $rates );
54
-		$r_taxes  = getpaid_calculate_item_taxes( $item->get_recurring_sub_total(), $rates );
55
-
56
-		foreach ( $taxes as $name => $amount ) {
57
-			$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
58
-			$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
59
-
60
-			if ( ! isset( $this->taxes[ $name ] ) ) {
61
-				$this->taxes[ $name ] = $tax;
62
-				continue;
63
-			}
64
-
65
-			$this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
66
-			$this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
67
-
68
-		}
69
-
70
-	}
71
-
72
-	/**
73
-	 * Checks if the submission has a digital item.
74
-	 *
75
-	 * @param GetPaid_Payment_Form_Submission $submission
76
-	 * @since 1.0.19
77
-	 * @return bool
78
-	 */
79
-	public function has_digital_item( $submission ) {
80
-
81
-		foreach ( $submission->get_items() as $item ) {
82
-
83
-			if ( 'digital' == $item->get_vat_rule() ) {
84
-				return true;
85
-			}
86
-
87
-		}
88
-
89
-		return false;
90
-	}
91
-
92
-	/**
93
-	 * Checks if this is an eu store.
94
-	 *
95
-	 * @since 1.0.19
96
-	 * @return bool
97
-	 */
98
-	public function is_eu_store() {
99
-		return $this->is_eu_country( wpinv_get_default_country() );
100
-	}
101
-
102
-	/**
103
-	 * Checks if this is an eu country.
104
-	 *
105
-	 * @param string $country
106
-	 * @since 1.0.19
107
-	 * @return bool
108
-	 */
109
-	public function is_eu_country( $country ) {
110
-		return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
111
-	}
112
-
113
-	/**
114
-	 * Checks if this is an eu purchase.
115
-	 *
116
-	 * @param string $customer_country
117
-	 * @since 1.0.19
118
-	 * @return bool
119
-	 */
120
-	public function is_eu_transaction( $customer_country ) {
121
-		return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
122
-	}
123
-
124
-	/**
125
-	 * Retrieves the vat number.
126
-	 *
127
-	 * @param GetPaid_Payment_Form_Submission $submission
128
-	 * @since 1.0.19
129
-	 * @return string
130
-	 */
131
-	public function get_vat_number( $submission ) {
132
-
133
-		// Retrieve from the posted number.
134
-		$vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
135
-		if ( ! empty( $vat_number ) ) {
136
-			return wpinv_clean( $vat_number );
137
-		}
138
-
139
-		// Retrieve from the invoice.
140
-		return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
141
-	}
142
-
143
-	/**
144
-	 * Retrieves the company.
145
-	 *
146
-	 * @param GetPaid_Payment_Form_Submission $submission
147
-	 * @since 1.0.19
148
-	 * @return string
149
-	 */
150
-	public function get_company( $submission ) {
151
-
152
-		// Retrieve from the posted data.
153
-		$company = $submission->get_field( 'wpinv_company', 'billing' );
154
-		if ( ! empty( $company ) ) {
155
-			return wpinv_clean( $company );
156
-		}
157
-
158
-		// Retrieve from the invoice.
159
-		return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
160
-	}
161
-
162
-	/**
163
-	 * Checks if we require a VAT number.
164
-	 *
165
-	 * @param bool $ip_in_eu Whether the customer IP is from the EU
166
-	 * @param bool $country_in_eu Whether the customer country is from the EU
167
-	 * @since 1.0.19
168
-	 * @return string
169
-	 */
170
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
171
-
172
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
173
-		$prevent_b2c = ! empty( $prevent_b2c );
174
-		$is_eu       = $ip_in_eu || $country_in_eu;
175
-
176
-		return $prevent_b2c && $is_eu;
177
-	}
178
-
179
-	/**
180
-	 * Validate VAT data.
181
-	 *
182
-	 * @param GetPaid_Payment_Form_Submission $submission
183
-	 * @since 1.0.19
184
-	 */
185
-	public function validate_vat( $submission ) {
186
-
187
-		$in_eu = $this->is_eu_transaction( $submission->country );
188
-
189
-		// Abort if we are not validating vat numbers.
190
-		if ( ! $in_eu ) {
73
+     * Checks if the submission has a digital item.
74
+     *
75
+     * @param GetPaid_Payment_Form_Submission $submission
76
+     * @since 1.0.19
77
+     * @return bool
78
+     */
79
+    public function has_digital_item( $submission ) {
80
+
81
+        foreach ( $submission->get_items() as $item ) {
82
+
83
+            if ( 'digital' == $item->get_vat_rule() ) {
84
+                return true;
85
+            }
86
+
87
+        }
88
+
89
+        return false;
90
+    }
91
+
92
+    /**
93
+     * Checks if this is an eu store.
94
+     *
95
+     * @since 1.0.19
96
+     * @return bool
97
+     */
98
+    public function is_eu_store() {
99
+        return $this->is_eu_country( wpinv_get_default_country() );
100
+    }
101
+
102
+    /**
103
+     * Checks if this is an eu country.
104
+     *
105
+     * @param string $country
106
+     * @since 1.0.19
107
+     * @return bool
108
+     */
109
+    public function is_eu_country( $country ) {
110
+        return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
111
+    }
112
+
113
+    /**
114
+     * Checks if this is an eu purchase.
115
+     *
116
+     * @param string $customer_country
117
+     * @since 1.0.19
118
+     * @return bool
119
+     */
120
+    public function is_eu_transaction( $customer_country ) {
121
+        return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
122
+    }
123
+
124
+    /**
125
+     * Retrieves the vat number.
126
+     *
127
+     * @param GetPaid_Payment_Form_Submission $submission
128
+     * @since 1.0.19
129
+     * @return string
130
+     */
131
+    public function get_vat_number( $submission ) {
132
+
133
+        // Retrieve from the posted number.
134
+        $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
135
+        if ( ! empty( $vat_number ) ) {
136
+            return wpinv_clean( $vat_number );
137
+        }
138
+
139
+        // Retrieve from the invoice.
140
+        return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
141
+    }
142
+
143
+    /**
144
+     * Retrieves the company.
145
+     *
146
+     * @param GetPaid_Payment_Form_Submission $submission
147
+     * @since 1.0.19
148
+     * @return string
149
+     */
150
+    public function get_company( $submission ) {
151
+
152
+        // Retrieve from the posted data.
153
+        $company = $submission->get_field( 'wpinv_company', 'billing' );
154
+        if ( ! empty( $company ) ) {
155
+            return wpinv_clean( $company );
156
+        }
157
+
158
+        // Retrieve from the invoice.
159
+        return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
160
+    }
161
+
162
+    /**
163
+     * Checks if we require a VAT number.
164
+     *
165
+     * @param bool $ip_in_eu Whether the customer IP is from the EU
166
+     * @param bool $country_in_eu Whether the customer country is from the EU
167
+     * @since 1.0.19
168
+     * @return string
169
+     */
170
+    public function requires_vat( $ip_in_eu, $country_in_eu ) {
171
+
172
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
173
+        $prevent_b2c = ! empty( $prevent_b2c );
174
+        $is_eu       = $ip_in_eu || $country_in_eu;
175
+
176
+        return $prevent_b2c && $is_eu;
177
+    }
178
+
179
+    /**
180
+     * Validate VAT data.
181
+     *
182
+     * @param GetPaid_Payment_Form_Submission $submission
183
+     * @since 1.0.19
184
+     */
185
+    public function validate_vat( $submission ) {
186
+
187
+        $in_eu = $this->is_eu_transaction( $submission->country );
188
+
189
+        // Abort if we are not validating vat numbers.
190
+        if ( ! $in_eu ) {
191 191
             return;
192
-		}
192
+        }
193 193
 
194
-		// Prepare variables.
195
-		$vat_number  = $this->get_vat_number( $submission );
196
-		$ip_country  = getpaid_get_ip_country();
194
+        // Prepare variables.
195
+        $vat_number  = $this->get_vat_number( $submission );
196
+        $ip_country  = getpaid_get_ip_country();
197 197
         $is_eu       = $this->is_eu_country( $submission->country );
198 198
         $is_ip_eu    = $this->is_eu_country( $ip_country );
199 199
 
200
-		// If we're preventing business to consumer purchases,
201
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
200
+        // If we're preventing business to consumer purchases,
201
+        if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
202 202
 
203
-			// Ensure that a vat number has been specified.
204
-			throw new Exception(
205
-				__( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' )
206
-			);
203
+            // Ensure that a vat number has been specified.
204
+            throw new Exception(
205
+                __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' )
206
+            );
207 207
 
208
-		}
208
+        }
209 209
 
210
-		// Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
211
-		if ( ! $in_eu ) {
210
+        // Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
211
+        if ( ! $in_eu ) {
212 212
             return;
213
-		}
213
+        }
214 214
 
215
-		if ( ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
216
-			throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) );
217
-		}
215
+        if ( ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
216
+            throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) );
217
+        }
218 218
 
219
-	}
219
+    }
220 220
 
221 221
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission taxes class
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		// Validate VAT number.
29
-		$this->validate_vat( $submission );
29
+		$this->validate_vat($submission);
30 30
 
31
-		foreach ( $submission->get_items() as $item ) {
32
-			$this->process_item_tax( $item, $submission );
31
+		foreach ($submission->get_items() as $item) {
32
+			$this->process_item_tax($item, $submission);
33 33
 		}
34 34
 
35 35
 		// Process any existing invoice taxes.
36
-		if ( $submission->has_invoice() ) {
37
-			$this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes );
36
+		if ($submission->has_invoice()) {
37
+			$this->taxes = array_replace($submission->get_invoice()->get_taxes(), $this->taxes);
38 38
 		}
39 39
 
40 40
 	}
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
 	 * @param GetPaid_Form_Item $item
47 47
 	 * @param GetPaid_Payment_Form_Submission $submission
48 48
 	 */
49
-	public function process_item_tax( $item, $submission ) {
49
+	public function process_item_tax($item, $submission) {
50 50
 
51
-		$rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
52
-		$rates    = getpaid_filter_item_tax_rates( $item, $rates );
53
-		$taxes    = getpaid_calculate_item_taxes( $item->get_sub_total(), $rates );
54
-		$r_taxes  = getpaid_calculate_item_taxes( $item->get_recurring_sub_total(), $rates );
51
+		$rates    = getpaid_get_item_tax_rates($item, $submission->country, $submission->state);
52
+		$rates    = getpaid_filter_item_tax_rates($item, $rates);
53
+		$taxes    = getpaid_calculate_item_taxes($item->get_sub_total(), $rates);
54
+		$r_taxes  = getpaid_calculate_item_taxes($item->get_recurring_sub_total(), $rates);
55 55
 
56
-		foreach ( $taxes as $name => $amount ) {
57
-			$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
58
-			$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
56
+		foreach ($taxes as $name => $amount) {
57
+			$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
58
+			$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
59 59
 
60
-			if ( ! isset( $this->taxes[ $name ] ) ) {
61
-				$this->taxes[ $name ] = $tax;
60
+			if (!isset($this->taxes[$name])) {
61
+				$this->taxes[$name] = $tax;
62 62
 				continue;
63 63
 			}
64 64
 
65
-			$this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
66
-			$this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
65
+			$this->taxes[$name]['initial_tax']   += $tax['initial_tax'];
66
+			$this->taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
67 67
 
68 68
 		}
69 69
 
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	 * @since 1.0.19
77 77
 	 * @return bool
78 78
 	 */
79
-	public function has_digital_item( $submission ) {
79
+	public function has_digital_item($submission) {
80 80
 
81
-		foreach ( $submission->get_items() as $item ) {
81
+		foreach ($submission->get_items() as $item) {
82 82
 
83
-			if ( 'digital' == $item->get_vat_rule() ) {
83
+			if ('digital' == $item->get_vat_rule()) {
84 84
 				return true;
85 85
 			}
86 86
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @return bool
97 97
 	 */
98 98
 	public function is_eu_store() {
99
-		return $this->is_eu_country( wpinv_get_default_country() );
99
+		return $this->is_eu_country(wpinv_get_default_country());
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	 * @since 1.0.19
107 107
 	 * @return bool
108 108
 	 */
109
-	public function is_eu_country( $country ) {
110
-		return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
109
+	public function is_eu_country($country) {
110
+		return getpaid_is_eu_state($country) || getpaid_is_gst_country($country);
111 111
 	}
112 112
 
113 113
 	/**
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 * @since 1.0.19
118 118
 	 * @return bool
119 119
 	 */
120
-	public function is_eu_transaction( $customer_country ) {
121
-		return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
120
+	public function is_eu_transaction($customer_country) {
121
+		return $this->is_eu_country($customer_country) && $this->is_eu_store();
122 122
 	}
123 123
 
124 124
 	/**
@@ -128,12 +128,12 @@  discard block
 block discarded – undo
128 128
 	 * @since 1.0.19
129 129
 	 * @return string
130 130
 	 */
131
-	public function get_vat_number( $submission ) {
131
+	public function get_vat_number($submission) {
132 132
 
133 133
 		// Retrieve from the posted number.
134
-		$vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
135
-		if ( ! empty( $vat_number ) ) {
136
-			return wpinv_clean( $vat_number );
134
+		$vat_number = $submission->get_field('wpinv_vat_number', 'billing');
135
+		if (!empty($vat_number)) {
136
+			return wpinv_clean($vat_number);
137 137
 		}
138 138
 
139 139
 		// Retrieve from the invoice.
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	 * @since 1.0.19
148 148
 	 * @return string
149 149
 	 */
150
-	public function get_company( $submission ) {
150
+	public function get_company($submission) {
151 151
 
152 152
 		// Retrieve from the posted data.
153
-		$company = $submission->get_field( 'wpinv_company', 'billing' );
154
-		if ( ! empty( $company ) ) {
155
-			return wpinv_clean( $company );
153
+		$company = $submission->get_field('wpinv_company', 'billing');
154
+		if (!empty($company)) {
155
+			return wpinv_clean($company);
156 156
 		}
157 157
 
158 158
 		// Retrieve from the invoice.
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 	 * @since 1.0.19
168 168
 	 * @return string
169 169
 	 */
170
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
170
+	public function requires_vat($ip_in_eu, $country_in_eu) {
171 171
 
172
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
173
-		$prevent_b2c = ! empty( $prevent_b2c );
172
+		$prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase');
173
+		$prevent_b2c = !empty($prevent_b2c);
174 174
 		$is_eu       = $ip_in_eu || $country_in_eu;
175 175
 
176 176
 		return $prevent_b2c && $is_eu;
@@ -182,38 +182,38 @@  discard block
 block discarded – undo
182 182
 	 * @param GetPaid_Payment_Form_Submission $submission
183 183
 	 * @since 1.0.19
184 184
 	 */
185
-	public function validate_vat( $submission ) {
185
+	public function validate_vat($submission) {
186 186
 
187
-		$in_eu = $this->is_eu_transaction( $submission->country );
187
+		$in_eu = $this->is_eu_transaction($submission->country);
188 188
 
189 189
 		// Abort if we are not validating vat numbers.
190
-		if ( ! $in_eu ) {
190
+		if (!$in_eu) {
191 191
             return;
192 192
 		}
193 193
 
194 194
 		// Prepare variables.
195
-		$vat_number  = $this->get_vat_number( $submission );
195
+		$vat_number  = $this->get_vat_number($submission);
196 196
 		$ip_country  = getpaid_get_ip_country();
197
-        $is_eu       = $this->is_eu_country( $submission->country );
198
-        $is_ip_eu    = $this->is_eu_country( $ip_country );
197
+        $is_eu       = $this->is_eu_country($submission->country);
198
+        $is_ip_eu    = $this->is_eu_country($ip_country);
199 199
 
200 200
 		// If we're preventing business to consumer purchases,
201
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
201
+		if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) {
202 202
 
203 203
 			// Ensure that a vat number has been specified.
204 204
 			throw new Exception(
205
-				__( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' )
205
+				__('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing')
206 206
 			);
207 207
 
208 208
 		}
209 209
 
210 210
 		// Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
211
-		if ( ! $in_eu ) {
211
+		if (!$in_eu) {
212 212
             return;
213 213
 		}
214 214
 
215
-		if ( ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
216
-			throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) );
215
+		if (!wpinv_validate_vat_number($vat_number, $submission->country)) {
216
+			throw new Exception(__('Your VAT number is invalid', 'invoicing'));
217 217
 		}
218 218
 
219 219
 	}
Please login to merge, or discard this patch.
includes/data/eu-states.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -9,32 +9,32 @@
 block discarded – undo
9 9
 defined( 'ABSPATH' ) || exit;
10 10
 
11 11
 return array(
12
-	'AT',
13
-	'BE',
14
-	'BG',
15
-	'HR',
16
-	'CY',
17
-	'CZ',
18
-	'DK',
19
-	'EE',
20
-	'FI',
21
-	'FR',
22
-	'DE',
23
-	'GB',
24
-	'GR',
25
-	'HU',
26
-	'IE',
27
-	'IT',
28
-	'LV',
29
-	'LT',
30
-	'LU',
31
-	'MT',
32
-	'NL',
33
-	'PL',
34
-	'PT',
35
-	'RO',
36
-	'SK',
37
-	'SI',
38
-	'ES',
39
-	'SE'
12
+    'AT',
13
+    'BE',
14
+    'BG',
15
+    'HR',
16
+    'CY',
17
+    'CZ',
18
+    'DK',
19
+    'EE',
20
+    'FI',
21
+    'FR',
22
+    'DE',
23
+    'GB',
24
+    'GR',
25
+    'HU',
26
+    'IE',
27
+    'IT',
28
+    'LV',
29
+    'LT',
30
+    'LU',
31
+    'MT',
32
+    'NL',
33
+    'PL',
34
+    'PT',
35
+    'RO',
36
+    'SK',
37
+    'SI',
38
+    'ES',
39
+    'SE'
40 40
 );
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @version 1.0.19
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 return array(
12 12
 	'AT',
Please login to merge, or discard this patch.
includes/data/item-schema.php 2 patches
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -13,233 +13,233 @@
 block discarded – undo
13 13
 
14 14
 return array(
15 15
 
16
-	'id'              => array(
17
-		'description' => __( 'Unique identifier for the item.', 'invoicing' ),
18
-		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
20
-		'readonly'    => true,
21
-	),
22
-
23
-	'parent_id'       => array(
24
-		'description' => __( 'Parent item ID.', 'invoicing' ),
25
-		'type'        => 'integer',
26
-		'context'     => array( 'view', 'edit', 'embed' ),
27
-		'default'     => 0,
28
-	),
29
-
30
-	'status'          => array(
31
-		'description' => __( 'A named status for the item.', 'invoicing' ),
32
-		'type'        => 'string',
33
-		'enum'        => array( 'draft', 'pending', 'publish' ),
34
-		'context'     => array( 'view', 'edit', 'embed' ),
35
-		'default'     => 'draft',
36
-	),
37
-
38
-	'version'         => array(
39
-		'description' => __( 'Plugin version when the item was created.', 'invoicing' ),
40
-		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit' ),
42
-		'readonly'    => true,
43
-	),
44
-
45
-	'date_created'    => array(
46
-		'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ),
47
-		'type'        => 'string',
48
-		'context'     => array( 'view', 'edit', 'embed' ),
49
-	),
50
-
51
-	'date_created_gmt'    => array(
52
-		'description' => __( 'The GMT date the item was created.', 'invoicing' ),
53
-		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
55
-		'readonly'    => true,
56
-	),
57
-
58
-	'date_modified'   => array(
59
-		'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ),
60
-		'type'        => 'string',
61
-		'context'     => array( 'view', 'edit', 'embed' ),
62
-		'readonly'    => true,
63
-	),
64
-
65
-	'date_modified_gmt'    => array(
66
-		'description' => __( 'The GMT date the item was last modified.', 'invoicing' ),
67
-		'type'        => 'string',
68
-		'context'     => array( 'view', 'edit', 'embed' ),
69
-		'readonly'    => true,
70
-	),
71
-
72
-	'name'			  => array(
73
-		'description' => __( "The item's name.", 'invoicing' ),
74
-		'type'        => 'string',
75
-		'context'     => array( 'view', 'edit', 'embed' ),
76
-		'required'    => true,
77
-	),
78
-
79
-	'description'     => array(
80
-		'description' => __( "The item's description.", 'invoicing' ),
81
-		'type'        => 'string',
82
-		'context'     => array( 'view', 'edit', 'embed' ),
83
-	),
84
-
85
-	'owner'           => array(
86
-		'description' => __( 'The owner of the item (user id).', 'invoicing' ),
87
-		'type'        => 'integer',
88
-		'context'     => array( 'view', 'edit', 'embed' ),
89
-	),
90
-
91
-	'price'           => array(
92
-		'description' => __( 'The price of the item.', 'invoicing' ),
93
-		'type'        => 'number',
94
-		'context'     => array( 'view', 'edit', 'embed' ),
95
-		'required'    => true,
96
-	),
97
-
98
-	'the_price'       => array(
99
-		'description' => __( 'The formatted price of the item.', 'invoicing' ),
100
-		'type'        => 'string',
101
-		'context'     => array( 'view', 'edit', 'embed' ),
102
-		'readonly'    => true,
103
-	),
104
-
105
-	'type'       => array(
106
-		'description' => __( 'The item type.', 'invoicing' ),
107
-		'type'        => 'string',
108
-		'enum'        => wpinv_item_types(),
109
-		'default'     => 'custom',
110
-		'context'     => array( 'view', 'edit', 'embed' ),
111
-	),
112
-
113
-	'vat_rule'       => array(
114
-		'description' => __( 'VAT rule applied to the item.', 'invoicing' ),
115
-		'type'        => 'string',
116
-		'enum'        => array_keys( getpaid_get_tax_rules() ),
117
-		'context'     => array( 'view', 'edit', 'embed' ),
118
-	),
119
-
120
-	'vat_class'       => array(
121
-		'description' => __( 'VAT class for the item.', 'invoicing' ),
122
-		'type'        => 'string',
123
-		'context'     => array( 'view', 'edit', 'embed' ),
124
-		'enum'        => array_keys( getpaid_get_tax_classes() ),
125
-	),
126
-
127
-	'custom_id'       => array(
128
-		'description' => __( 'Custom id for the item.', 'invoicing' ),
129
-		'type'        => 'string',
130
-		'context'     => array( 'view', 'edit', 'embed' ),
131
-	),
16
+    'id'              => array(
17
+        'description' => __( 'Unique identifier for the item.', 'invoicing' ),
18
+        'type'        => 'integer',
19
+        'context'     => array( 'view', 'edit', 'embed' ),
20
+        'readonly'    => true,
21
+    ),
22
+
23
+    'parent_id'       => array(
24
+        'description' => __( 'Parent item ID.', 'invoicing' ),
25
+        'type'        => 'integer',
26
+        'context'     => array( 'view', 'edit', 'embed' ),
27
+        'default'     => 0,
28
+    ),
29
+
30
+    'status'          => array(
31
+        'description' => __( 'A named status for the item.', 'invoicing' ),
32
+        'type'        => 'string',
33
+        'enum'        => array( 'draft', 'pending', 'publish' ),
34
+        'context'     => array( 'view', 'edit', 'embed' ),
35
+        'default'     => 'draft',
36
+    ),
37
+
38
+    'version'         => array(
39
+        'description' => __( 'Plugin version when the item was created.', 'invoicing' ),
40
+        'type'        => 'string',
41
+        'context'     => array( 'view', 'edit' ),
42
+        'readonly'    => true,
43
+    ),
44
+
45
+    'date_created'    => array(
46
+        'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ),
47
+        'type'        => 'string',
48
+        'context'     => array( 'view', 'edit', 'embed' ),
49
+    ),
50
+
51
+    'date_created_gmt'    => array(
52
+        'description' => __( 'The GMT date the item was created.', 'invoicing' ),
53
+        'type'        => 'string',
54
+        'context'     => array( 'view', 'edit', 'embed' ),
55
+        'readonly'    => true,
56
+    ),
57
+
58
+    'date_modified'   => array(
59
+        'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ),
60
+        'type'        => 'string',
61
+        'context'     => array( 'view', 'edit', 'embed' ),
62
+        'readonly'    => true,
63
+    ),
64
+
65
+    'date_modified_gmt'    => array(
66
+        'description' => __( 'The GMT date the item was last modified.', 'invoicing' ),
67
+        'type'        => 'string',
68
+        'context'     => array( 'view', 'edit', 'embed' ),
69
+        'readonly'    => true,
70
+    ),
71
+
72
+    'name'			  => array(
73
+        'description' => __( "The item's name.", 'invoicing' ),
74
+        'type'        => 'string',
75
+        'context'     => array( 'view', 'edit', 'embed' ),
76
+        'required'    => true,
77
+    ),
78
+
79
+    'description'     => array(
80
+        'description' => __( "The item's description.", 'invoicing' ),
81
+        'type'        => 'string',
82
+        'context'     => array( 'view', 'edit', 'embed' ),
83
+    ),
84
+
85
+    'owner'           => array(
86
+        'description' => __( 'The owner of the item (user id).', 'invoicing' ),
87
+        'type'        => 'integer',
88
+        'context'     => array( 'view', 'edit', 'embed' ),
89
+    ),
90
+
91
+    'price'           => array(
92
+        'description' => __( 'The price of the item.', 'invoicing' ),
93
+        'type'        => 'number',
94
+        'context'     => array( 'view', 'edit', 'embed' ),
95
+        'required'    => true,
96
+    ),
97
+
98
+    'the_price'       => array(
99
+        'description' => __( 'The formatted price of the item.', 'invoicing' ),
100
+        'type'        => 'string',
101
+        'context'     => array( 'view', 'edit', 'embed' ),
102
+        'readonly'    => true,
103
+    ),
104
+
105
+    'type'       => array(
106
+        'description' => __( 'The item type.', 'invoicing' ),
107
+        'type'        => 'string',
108
+        'enum'        => wpinv_item_types(),
109
+        'default'     => 'custom',
110
+        'context'     => array( 'view', 'edit', 'embed' ),
111
+    ),
112
+
113
+    'vat_rule'       => array(
114
+        'description' => __( 'VAT rule applied to the item.', 'invoicing' ),
115
+        'type'        => 'string',
116
+        'enum'        => array_keys( getpaid_get_tax_rules() ),
117
+        'context'     => array( 'view', 'edit', 'embed' ),
118
+    ),
119
+
120
+    'vat_class'       => array(
121
+        'description' => __( 'VAT class for the item.', 'invoicing' ),
122
+        'type'        => 'string',
123
+        'context'     => array( 'view', 'edit', 'embed' ),
124
+        'enum'        => array_keys( getpaid_get_tax_classes() ),
125
+    ),
126
+
127
+    'custom_id'       => array(
128
+        'description' => __( 'Custom id for the item.', 'invoicing' ),
129
+        'type'        => 'string',
130
+        'context'     => array( 'view', 'edit', 'embed' ),
131
+    ),
132 132
 	
133
-	'custom_name'       => array(
134
-		'description' => __( 'Custom name for the item.', 'invoicing' ),
135
-		'type'        => 'string',
136
-		'context'     => array( 'view', 'edit', 'embed' ),
137
-	),
138
-
139
-	'custom_singular_name'       => array(
140
-		'description' => __( 'Custom singular name for the item.', 'invoicing' ),
141
-		'type'        => 'string',
142
-		'context'     => array( 'view', 'edit', 'embed' ),
143
-	),
144
-
145
-	'is_dynamic_pricing'     => array(
146
-		'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ),
147
-		'type'        => 'integer',
148
-		'enum'        => array( 0, 1 ),
149
-		'context'     => array( 'view', 'edit', 'embed' ),
150
-	),
151
-
152
-	'minimum_price'   => array(
153
-		'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ),
154
-		'type'        => 'number',
155
-		'context'     => array( 'view', 'edit', 'embed' ),
156
-	),
157
-
158
-	'is_recurring'        => array(
159
-		'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ),
160
-		'type'        => 'integer',
161
-		'enum'        => array( 0, 1 ),
162
-		'context'     => array( 'view', 'edit', 'embed' ),
163
-	),
164
-
165
-	'initial_price'   => array(
166
-		'description' => __( 'The initial price of the item.', 'invoicing' ),
167
-		'type'        => 'number',
168
-		'context'     => array( 'view', 'edit', 'embed' ),
169
-		'readonly'    => true,
170
-	),
171
-
172
-	'the_initial_price'       => array(
173
-		'description' => __( 'The formatted initial price of the item.', 'invoicing' ),
174
-		'type'        => 'string',
175
-		'context'     => array( 'view', 'edit', 'embed' ),
176
-		'readonly'    => true,
177
-	),
178
-
179
-	'recurring_price' => array(
180
-		'description' => __( 'The recurring price of the item.', 'invoicing' ),
181
-		'type'        => 'number',
182
-		'context'     => array( 'view', 'edit', 'embed' ),
183
-		'readonly'    => true,
184
-	),
185
-
186
-	'the_recurring_price'       => array(
187
-		'description' => __( 'The formatted recurring price of the item.', 'invoicing' ),
188
-		'type'        => 'string',
189
-		'context'     => array( 'view', 'edit', 'embed' ),
190
-		'readonly'    => true,
191
-	),
192
-
193
-	'recurring_period'        => array(
194
-		'description' => __( 'The recurring period for a recurring item.', 'invoicing' ),
195
-		'type'        => 'string',
196
-		'context'     => array( 'view', 'edit', 'embed' ),
197
-		'enum'        => array( 'D', 'W', 'M', 'Y' ),
198
-	),
199
-
200
-	'recurring_interval'        => array(
201
-		'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ),
202
-		'type'        => 'integer',
203
-		'context'     => array( 'view', 'edit', 'embed' ),
204
-	),
205
-
206
-	'recurring_limit' => array(
207
-		'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ),
208
-		'type'        => 'integer',
209
-		'context'     => array( 'view', 'edit', 'embed' ),
210
-	),
211
-
212
-	'is_free_trial'   => array(
213
-		'description' => __( 'Whether the item has a free trial period.', 'invoicing' ),
214
-		'type'        => 'integer',
215
-		'enum'        => array( 0, 1 ),
216
-		'context'     => array( 'view', 'edit', 'embed' ),
217
-	),
218
-
219
-	'trial_period'    => array(
220
-		'description' => __( 'The trial period.', 'invoicing' ),
221
-		'type'        => 'string',
222
-		'context'     => array( 'view', 'edit', 'embed' ),
223
-		'enum'        => array( 'D', 'W', 'M', 'Y' ),
224
-	),
225
-
226
-	'trial_interval'  => array(
227
-		'description' => __( 'The trial interval.', 'invoicing' ),
228
-		'type'        => 'integer',
229
-		'context'     => array( 'view', 'edit', 'embed' ),
230
-	),
231
-
232
-	'first_renewal_date'       => array(
233
-		'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ),
234
-		'type'        => 'string',
235
-		'context'     => array( 'view', 'edit', 'embed' ),
236
-		'readonly'    => true,
237
-	),
238
-
239
-	'edit_url'        => array(
240
-		'description' => __( 'The URL to edit an item.', 'invoicing' ),
241
-		'type'        => 'string',
242
-		'context'     => array( 'view', 'edit', 'embed' ),
243
-		'readonly'    => true,
244
-	),
133
+    'custom_name'       => array(
134
+        'description' => __( 'Custom name for the item.', 'invoicing' ),
135
+        'type'        => 'string',
136
+        'context'     => array( 'view', 'edit', 'embed' ),
137
+    ),
138
+
139
+    'custom_singular_name'       => array(
140
+        'description' => __( 'Custom singular name for the item.', 'invoicing' ),
141
+        'type'        => 'string',
142
+        'context'     => array( 'view', 'edit', 'embed' ),
143
+    ),
144
+
145
+    'is_dynamic_pricing'     => array(
146
+        'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ),
147
+        'type'        => 'integer',
148
+        'enum'        => array( 0, 1 ),
149
+        'context'     => array( 'view', 'edit', 'embed' ),
150
+    ),
151
+
152
+    'minimum_price'   => array(
153
+        'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ),
154
+        'type'        => 'number',
155
+        'context'     => array( 'view', 'edit', 'embed' ),
156
+    ),
157
+
158
+    'is_recurring'        => array(
159
+        'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ),
160
+        'type'        => 'integer',
161
+        'enum'        => array( 0, 1 ),
162
+        'context'     => array( 'view', 'edit', 'embed' ),
163
+    ),
164
+
165
+    'initial_price'   => array(
166
+        'description' => __( 'The initial price of the item.', 'invoicing' ),
167
+        'type'        => 'number',
168
+        'context'     => array( 'view', 'edit', 'embed' ),
169
+        'readonly'    => true,
170
+    ),
171
+
172
+    'the_initial_price'       => array(
173
+        'description' => __( 'The formatted initial price of the item.', 'invoicing' ),
174
+        'type'        => 'string',
175
+        'context'     => array( 'view', 'edit', 'embed' ),
176
+        'readonly'    => true,
177
+    ),
178
+
179
+    'recurring_price' => array(
180
+        'description' => __( 'The recurring price of the item.', 'invoicing' ),
181
+        'type'        => 'number',
182
+        'context'     => array( 'view', 'edit', 'embed' ),
183
+        'readonly'    => true,
184
+    ),
185
+
186
+    'the_recurring_price'       => array(
187
+        'description' => __( 'The formatted recurring price of the item.', 'invoicing' ),
188
+        'type'        => 'string',
189
+        'context'     => array( 'view', 'edit', 'embed' ),
190
+        'readonly'    => true,
191
+    ),
192
+
193
+    'recurring_period'        => array(
194
+        'description' => __( 'The recurring period for a recurring item.', 'invoicing' ),
195
+        'type'        => 'string',
196
+        'context'     => array( 'view', 'edit', 'embed' ),
197
+        'enum'        => array( 'D', 'W', 'M', 'Y' ),
198
+    ),
199
+
200
+    'recurring_interval'        => array(
201
+        'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ),
202
+        'type'        => 'integer',
203
+        'context'     => array( 'view', 'edit', 'embed' ),
204
+    ),
205
+
206
+    'recurring_limit' => array(
207
+        'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ),
208
+        'type'        => 'integer',
209
+        'context'     => array( 'view', 'edit', 'embed' ),
210
+    ),
211
+
212
+    'is_free_trial'   => array(
213
+        'description' => __( 'Whether the item has a free trial period.', 'invoicing' ),
214
+        'type'        => 'integer',
215
+        'enum'        => array( 0, 1 ),
216
+        'context'     => array( 'view', 'edit', 'embed' ),
217
+    ),
218
+
219
+    'trial_period'    => array(
220
+        'description' => __( 'The trial period.', 'invoicing' ),
221
+        'type'        => 'string',
222
+        'context'     => array( 'view', 'edit', 'embed' ),
223
+        'enum'        => array( 'D', 'W', 'M', 'Y' ),
224
+    ),
225
+
226
+    'trial_interval'  => array(
227
+        'description' => __( 'The trial interval.', 'invoicing' ),
228
+        'type'        => 'integer',
229
+        'context'     => array( 'view', 'edit', 'embed' ),
230
+    ),
231
+
232
+    'first_renewal_date'       => array(
233
+        'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ),
234
+        'type'        => 'string',
235
+        'context'     => array( 'view', 'edit', 'embed' ),
236
+        'readonly'    => true,
237
+    ),
238
+
239
+    'edit_url'        => array(
240
+        'description' => __( 'The URL to edit an item.', 'invoicing' ),
241
+        'type'        => 'string',
242
+        'context'     => array( 'view', 'edit', 'embed' ),
243
+        'readonly'    => true,
244
+    ),
245 245
 );
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -9,237 +9,237 @@
 block discarded – undo
9 9
  * @version 1.0.19
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 return array(
15 15
 
16 16
 	'id'              => array(
17
-		'description' => __( 'Unique identifier for the item.', 'invoicing' ),
17
+		'description' => __('Unique identifier for the item.', 'invoicing'),
18 18
 		'type'        => 'integer',
19
-		'context'     => array( 'view', 'edit', 'embed' ),
19
+		'context'     => array('view', 'edit', 'embed'),
20 20
 		'readonly'    => true,
21 21
 	),
22 22
 
23 23
 	'parent_id'       => array(
24
-		'description' => __( 'Parent item ID.', 'invoicing' ),
24
+		'description' => __('Parent item ID.', 'invoicing'),
25 25
 		'type'        => 'integer',
26
-		'context'     => array( 'view', 'edit', 'embed' ),
26
+		'context'     => array('view', 'edit', 'embed'),
27 27
 		'default'     => 0,
28 28
 	),
29 29
 
30 30
 	'status'          => array(
31
-		'description' => __( 'A named status for the item.', 'invoicing' ),
31
+		'description' => __('A named status for the item.', 'invoicing'),
32 32
 		'type'        => 'string',
33
-		'enum'        => array( 'draft', 'pending', 'publish' ),
34
-		'context'     => array( 'view', 'edit', 'embed' ),
33
+		'enum'        => array('draft', 'pending', 'publish'),
34
+		'context'     => array('view', 'edit', 'embed'),
35 35
 		'default'     => 'draft',
36 36
 	),
37 37
 
38 38
 	'version'         => array(
39
-		'description' => __( 'Plugin version when the item was created.', 'invoicing' ),
39
+		'description' => __('Plugin version when the item was created.', 'invoicing'),
40 40
 		'type'        => 'string',
41
-		'context'     => array( 'view', 'edit' ),
41
+		'context'     => array('view', 'edit'),
42 42
 		'readonly'    => true,
43 43
 	),
44 44
 
45 45
 	'date_created'    => array(
46
-		'description' => __( "The date the item was created, in the site's timezone.", 'invoicing' ),
46
+		'description' => __("The date the item was created, in the site's timezone.", 'invoicing'),
47 47
 		'type'        => 'string',
48
-		'context'     => array( 'view', 'edit', 'embed' ),
48
+		'context'     => array('view', 'edit', 'embed'),
49 49
 	),
50 50
 
51 51
 	'date_created_gmt'    => array(
52
-		'description' => __( 'The GMT date the item was created.', 'invoicing' ),
52
+		'description' => __('The GMT date the item was created.', 'invoicing'),
53 53
 		'type'        => 'string',
54
-		'context'     => array( 'view', 'edit', 'embed' ),
54
+		'context'     => array('view', 'edit', 'embed'),
55 55
 		'readonly'    => true,
56 56
 	),
57 57
 
58 58
 	'date_modified'   => array(
59
-		'description' => __( "The date the item was last modified, in the site's timezone.", 'invoicing' ),
59
+		'description' => __("The date the item was last modified, in the site's timezone.", 'invoicing'),
60 60
 		'type'        => 'string',
61
-		'context'     => array( 'view', 'edit', 'embed' ),
61
+		'context'     => array('view', 'edit', 'embed'),
62 62
 		'readonly'    => true,
63 63
 	),
64 64
 
65 65
 	'date_modified_gmt'    => array(
66
-		'description' => __( 'The GMT date the item was last modified.', 'invoicing' ),
66
+		'description' => __('The GMT date the item was last modified.', 'invoicing'),
67 67
 		'type'        => 'string',
68
-		'context'     => array( 'view', 'edit', 'embed' ),
68
+		'context'     => array('view', 'edit', 'embed'),
69 69
 		'readonly'    => true,
70 70
 	),
71 71
 
72 72
 	'name'			  => array(
73
-		'description' => __( "The item's name.", 'invoicing' ),
73
+		'description' => __("The item's name.", 'invoicing'),
74 74
 		'type'        => 'string',
75
-		'context'     => array( 'view', 'edit', 'embed' ),
75
+		'context'     => array('view', 'edit', 'embed'),
76 76
 		'required'    => true,
77 77
 	),
78 78
 
79 79
 	'description'     => array(
80
-		'description' => __( "The item's description.", 'invoicing' ),
80
+		'description' => __("The item's description.", 'invoicing'),
81 81
 		'type'        => 'string',
82
-		'context'     => array( 'view', 'edit', 'embed' ),
82
+		'context'     => array('view', 'edit', 'embed'),
83 83
 	),
84 84
 
85 85
 	'owner'           => array(
86
-		'description' => __( 'The owner of the item (user id).', 'invoicing' ),
86
+		'description' => __('The owner of the item (user id).', 'invoicing'),
87 87
 		'type'        => 'integer',
88
-		'context'     => array( 'view', 'edit', 'embed' ),
88
+		'context'     => array('view', 'edit', 'embed'),
89 89
 	),
90 90
 
91 91
 	'price'           => array(
92
-		'description' => __( 'The price of the item.', 'invoicing' ),
92
+		'description' => __('The price of the item.', 'invoicing'),
93 93
 		'type'        => 'number',
94
-		'context'     => array( 'view', 'edit', 'embed' ),
94
+		'context'     => array('view', 'edit', 'embed'),
95 95
 		'required'    => true,
96 96
 	),
97 97
 
98 98
 	'the_price'       => array(
99
-		'description' => __( 'The formatted price of the item.', 'invoicing' ),
99
+		'description' => __('The formatted price of the item.', 'invoicing'),
100 100
 		'type'        => 'string',
101
-		'context'     => array( 'view', 'edit', 'embed' ),
101
+		'context'     => array('view', 'edit', 'embed'),
102 102
 		'readonly'    => true,
103 103
 	),
104 104
 
105 105
 	'type'       => array(
106
-		'description' => __( 'The item type.', 'invoicing' ),
106
+		'description' => __('The item type.', 'invoicing'),
107 107
 		'type'        => 'string',
108 108
 		'enum'        => wpinv_item_types(),
109 109
 		'default'     => 'custom',
110
-		'context'     => array( 'view', 'edit', 'embed' ),
110
+		'context'     => array('view', 'edit', 'embed'),
111 111
 	),
112 112
 
113 113
 	'vat_rule'       => array(
114
-		'description' => __( 'VAT rule applied to the item.', 'invoicing' ),
114
+		'description' => __('VAT rule applied to the item.', 'invoicing'),
115 115
 		'type'        => 'string',
116
-		'enum'        => array_keys( getpaid_get_tax_rules() ),
117
-		'context'     => array( 'view', 'edit', 'embed' ),
116
+		'enum'        => array_keys(getpaid_get_tax_rules()),
117
+		'context'     => array('view', 'edit', 'embed'),
118 118
 	),
119 119
 
120 120
 	'vat_class'       => array(
121
-		'description' => __( 'VAT class for the item.', 'invoicing' ),
121
+		'description' => __('VAT class for the item.', 'invoicing'),
122 122
 		'type'        => 'string',
123
-		'context'     => array( 'view', 'edit', 'embed' ),
124
-		'enum'        => array_keys( getpaid_get_tax_classes() ),
123
+		'context'     => array('view', 'edit', 'embed'),
124
+		'enum'        => array_keys(getpaid_get_tax_classes()),
125 125
 	),
126 126
 
127 127
 	'custom_id'       => array(
128
-		'description' => __( 'Custom id for the item.', 'invoicing' ),
128
+		'description' => __('Custom id for the item.', 'invoicing'),
129 129
 		'type'        => 'string',
130
-		'context'     => array( 'view', 'edit', 'embed' ),
130
+		'context'     => array('view', 'edit', 'embed'),
131 131
 	),
132 132
 	
133 133
 	'custom_name'       => array(
134
-		'description' => __( 'Custom name for the item.', 'invoicing' ),
134
+		'description' => __('Custom name for the item.', 'invoicing'),
135 135
 		'type'        => 'string',
136
-		'context'     => array( 'view', 'edit', 'embed' ),
136
+		'context'     => array('view', 'edit', 'embed'),
137 137
 	),
138 138
 
139 139
 	'custom_singular_name'       => array(
140
-		'description' => __( 'Custom singular name for the item.', 'invoicing' ),
140
+		'description' => __('Custom singular name for the item.', 'invoicing'),
141 141
 		'type'        => 'string',
142
-		'context'     => array( 'view', 'edit', 'embed' ),
142
+		'context'     => array('view', 'edit', 'embed'),
143 143
 	),
144 144
 
145 145
 	'is_dynamic_pricing'     => array(
146
-		'description' => __( 'Whether or not customers can enter their own prices when checking out.', 'invoicing' ),
146
+		'description' => __('Whether or not customers can enter their own prices when checking out.', 'invoicing'),
147 147
 		'type'        => 'integer',
148
-		'enum'        => array( 0, 1 ),
149
-		'context'     => array( 'view', 'edit', 'embed' ),
148
+		'enum'        => array(0, 1),
149
+		'context'     => array('view', 'edit', 'embed'),
150 150
 	),
151 151
 
152 152
 	'minimum_price'   => array(
153
-		'description' => __( 'For dynamic prices, this is the minimum price that a user can set.', 'invoicing' ),
153
+		'description' => __('For dynamic prices, this is the minimum price that a user can set.', 'invoicing'),
154 154
 		'type'        => 'number',
155
-		'context'     => array( 'view', 'edit', 'embed' ),
155
+		'context'     => array('view', 'edit', 'embed'),
156 156
 	),
157 157
 
158 158
 	'is_recurring'        => array(
159
-		'description' => __( 'Whether or not this is a subscription item.', 'invoicing' ),
159
+		'description' => __('Whether or not this is a subscription item.', 'invoicing'),
160 160
 		'type'        => 'integer',
161
-		'enum'        => array( 0, 1 ),
162
-		'context'     => array( 'view', 'edit', 'embed' ),
161
+		'enum'        => array(0, 1),
162
+		'context'     => array('view', 'edit', 'embed'),
163 163
 	),
164 164
 
165 165
 	'initial_price'   => array(
166
-		'description' => __( 'The initial price of the item.', 'invoicing' ),
166
+		'description' => __('The initial price of the item.', 'invoicing'),
167 167
 		'type'        => 'number',
168
-		'context'     => array( 'view', 'edit', 'embed' ),
168
+		'context'     => array('view', 'edit', 'embed'),
169 169
 		'readonly'    => true,
170 170
 	),
171 171
 
172 172
 	'the_initial_price'       => array(
173
-		'description' => __( 'The formatted initial price of the item.', 'invoicing' ),
173
+		'description' => __('The formatted initial price of the item.', 'invoicing'),
174 174
 		'type'        => 'string',
175
-		'context'     => array( 'view', 'edit', 'embed' ),
175
+		'context'     => array('view', 'edit', 'embed'),
176 176
 		'readonly'    => true,
177 177
 	),
178 178
 
179 179
 	'recurring_price' => array(
180
-		'description' => __( 'The recurring price of the item.', 'invoicing' ),
180
+		'description' => __('The recurring price of the item.', 'invoicing'),
181 181
 		'type'        => 'number',
182
-		'context'     => array( 'view', 'edit', 'embed' ),
182
+		'context'     => array('view', 'edit', 'embed'),
183 183
 		'readonly'    => true,
184 184
 	),
185 185
 
186 186
 	'the_recurring_price'       => array(
187
-		'description' => __( 'The formatted recurring price of the item.', 'invoicing' ),
187
+		'description' => __('The formatted recurring price of the item.', 'invoicing'),
188 188
 		'type'        => 'string',
189
-		'context'     => array( 'view', 'edit', 'embed' ),
189
+		'context'     => array('view', 'edit', 'embed'),
190 190
 		'readonly'    => true,
191 191
 	),
192 192
 
193 193
 	'recurring_period'        => array(
194
-		'description' => __( 'The recurring period for a recurring item.', 'invoicing' ),
194
+		'description' => __('The recurring period for a recurring item.', 'invoicing'),
195 195
 		'type'        => 'string',
196
-		'context'     => array( 'view', 'edit', 'embed' ),
197
-		'enum'        => array( 'D', 'W', 'M', 'Y' ),
196
+		'context'     => array('view', 'edit', 'embed'),
197
+		'enum'        => array('D', 'W', 'M', 'Y'),
198 198
 	),
199 199
 
200 200
 	'recurring_interval'        => array(
201
-		'description' => __( 'The recurring interval for a subscription item.', 'invoicing' ),
201
+		'description' => __('The recurring interval for a subscription item.', 'invoicing'),
202 202
 		'type'        => 'integer',
203
-		'context'     => array( 'view', 'edit', 'embed' ),
203
+		'context'     => array('view', 'edit', 'embed'),
204 204
 	),
205 205
 
206 206
 	'recurring_limit' => array(
207
-		'description' => __( 'The maximum number of renewals for a subscription item.', 'invoicing' ),
207
+		'description' => __('The maximum number of renewals for a subscription item.', 'invoicing'),
208 208
 		'type'        => 'integer',
209
-		'context'     => array( 'view', 'edit', 'embed' ),
209
+		'context'     => array('view', 'edit', 'embed'),
210 210
 	),
211 211
 
212 212
 	'is_free_trial'   => array(
213
-		'description' => __( 'Whether the item has a free trial period.', 'invoicing' ),
213
+		'description' => __('Whether the item has a free trial period.', 'invoicing'),
214 214
 		'type'        => 'integer',
215
-		'enum'        => array( 0, 1 ),
216
-		'context'     => array( 'view', 'edit', 'embed' ),
215
+		'enum'        => array(0, 1),
216
+		'context'     => array('view', 'edit', 'embed'),
217 217
 	),
218 218
 
219 219
 	'trial_period'    => array(
220
-		'description' => __( 'The trial period.', 'invoicing' ),
220
+		'description' => __('The trial period.', 'invoicing'),
221 221
 		'type'        => 'string',
222
-		'context'     => array( 'view', 'edit', 'embed' ),
223
-		'enum'        => array( 'D', 'W', 'M', 'Y' ),
222
+		'context'     => array('view', 'edit', 'embed'),
223
+		'enum'        => array('D', 'W', 'M', 'Y'),
224 224
 	),
225 225
 
226 226
 	'trial_interval'  => array(
227
-		'description' => __( 'The trial interval.', 'invoicing' ),
227
+		'description' => __('The trial interval.', 'invoicing'),
228 228
 		'type'        => 'integer',
229
-		'context'     => array( 'view', 'edit', 'embed' ),
229
+		'context'     => array('view', 'edit', 'embed'),
230 230
 	),
231 231
 
232 232
 	'first_renewal_date'       => array(
233
-		'description' => __( 'The first renewal date in case the item was to be bought today.', 'invoicing' ),
233
+		'description' => __('The first renewal date in case the item was to be bought today.', 'invoicing'),
234 234
 		'type'        => 'string',
235
-		'context'     => array( 'view', 'edit', 'embed' ),
235
+		'context'     => array('view', 'edit', 'embed'),
236 236
 		'readonly'    => true,
237 237
 	),
238 238
 
239 239
 	'edit_url'        => array(
240
-		'description' => __( 'The URL to edit an item.', 'invoicing' ),
240
+		'description' => __('The URL to edit an item.', 'invoicing'),
241 241
 		'type'        => 'string',
242
-		'context'     => array( 'view', 'edit', 'embed' ),
242
+		'context'     => array('view', 'edit', 'embed'),
243 243
 		'readonly'    => true,
244 244
 	),
245 245
 );
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-manual-gateway.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Manual_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'manual';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'addons' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 11;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 11;
35 35
     
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title        = __( 'Manual Payment', 'invoicing' );
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-	 * Process Payment.
50
-	 *
51
-	 *
52
-	 * @param WPInv_Invoice $invoice Invoice.
53
-	 * @param array $submission_data Posted checkout fields.
54
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55
-	 * @return array
56
-	 */
57
-	public function process_payment( $invoice, $submission_data, $submission ) {
49
+     * Process Payment.
50
+     *
51
+     *
52
+     * @param WPInv_Invoice $invoice Invoice.
53
+     * @param array $submission_data Posted checkout fields.
54
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55
+     * @return array
56
+     */
57
+    public function process_payment( $invoice, $submission_data, $submission ) {
58 58
 
59 59
         // Mark it as paid.
60 60
         $invoice->mark_paid();
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
     }
69 69
 
70 70
     /**
71
-	 * (Maybe) renews a manual subscription profile.
72
-	 *
73
-	 *
74
-	 * @param bool $should_expire
71
+     * (Maybe) renews a manual subscription profile.
72
+     *
73
+     *
74
+     * @param bool $should_expire
75 75
      * @param WPInv_Subscription $subscription
76
-	 */
77
-	public function maybe_renew_subscription( $should_expire, $subscription ) {
76
+     */
77
+    public function maybe_renew_subscription( $should_expire, $subscription ) {
78 78
 
79 79
         // Ensure its our subscription && it's active.
80 80
         if ( 'manual' != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) {
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
     }
103 103
 
104 104
     /**
105
-	 * Processes invoice addons.
106
-	 *
107
-	 * @param WPInv_Invoice $invoice
108
-	 * @param GetPaid_Form_Item[] $items
109
-	 * @return WPInv_Invoice
110
-	 */
111
-	public function process_addons( $invoice, $items ) {
105
+     * Processes invoice addons.
106
+     *
107
+     * @param WPInv_Invoice $invoice
108
+     * @param GetPaid_Form_Item[] $items
109
+     * @return WPInv_Invoice
110
+     */
111
+    public function process_addons( $invoice, $items ) {
112 112
 
113 113
         foreach ( $items as $item ) {
114 114
             $invoice->add_item( $item );
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 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
  * Manual Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'addons' );
27
+    protected $supports = array('subscription', 'addons');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 	public function __construct() {
40 40
         parent::__construct();
41 41
 
42
-        $this->title        = __( 'Manual Payment', 'invoicing' );
43
-        $this->method_title = __( 'Manual Payment', 'invoicing' );
42
+        $this->title        = __('Manual Payment', 'invoicing');
43
+        $this->method_title = __('Manual Payment', 'invoicing');
44 44
 
45
-        add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 );
45
+        add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2);
46 46
     }
47 47
 
48 48
     /**
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55 55
 	 * @return array
56 56
 	 */
57
-	public function process_payment( $invoice, $submission_data, $submission ) {
57
+	public function process_payment($invoice, $submission_data, $submission) {
58 58
 
59 59
         // Mark it as paid.
60 60
         $invoice->mark_paid();
61 61
 
62 62
         // (Maybe) activate subscription.
63
-        getpaid_activate_invoice_subscription( $invoice );
63
+        getpaid_activate_invoice_subscription($invoice);
64 64
 
65 65
         // Send to the success page.
66
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
66
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
67 67
 
68 68
     }
69 69
 
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
 	 * @param bool $should_expire
75 75
      * @param WPInv_Subscription $subscription
76 76
 	 */
77
-	public function maybe_renew_subscription( $should_expire, $subscription ) {
77
+	public function maybe_renew_subscription($should_expire, $subscription) {
78 78
 
79 79
         // Ensure its our subscription && it's active.
80
-        if ( 'manual' != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) {
80
+        if ('manual' != $subscription->get_gateway() || !$subscription->has_status('active trialling')) {
81 81
             return $should_expire;
82 82
         }
83 83
 
84 84
         // If this is the last renewal, complete the subscription.
85
-        if ( $subscription->is_last_renewal() ) {
85
+        if ($subscription->is_last_renewal()) {
86 86
             $subscription->complete();
87 87
             return false;
88 88
         }
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 * @param GetPaid_Form_Item[] $items
109 109
 	 * @return WPInv_Invoice
110 110
 	 */
111
-	public function process_addons( $invoice, $items ) {
111
+	public function process_addons($invoice, $items) {
112 112
 
113
-        foreach ( $items as $item ) {
114
-            $invoice->add_item( $item );
113
+        foreach ($items as $item) {
114
+            $invoice->add_item($item);
115 115
         }
116 116
 
117 117
         $invoice->recalculate_total();
Please login to merge, or discard this patch.
templates/wpinv-invoice-print.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Fetch the invoice.
13
-if ( empty( $invoice ) ) {
14
-    $invoice = new WPInv_Invoice( $GLOBALS['post'] );
13
+if (empty($invoice)) {
14
+    $invoice = new WPInv_Invoice($GLOBALS['post']);
15 15
 }
16 16
 
17 17
 // Abort if it does not exist.
18
-if ( $invoice->get_id() == 0 ) {
18
+if ($invoice->get_id() == 0) {
19 19
     exit;
20 20
 }
21 21
 
22 22
 // Fires before printing an invoice.
23
-do_action( 'wpinv_invoice_print_before_display', $invoice );
23
+do_action('wpinv_invoice_print_before_display', $invoice);
24 24
 
25 25
 ?><!DOCTYPE html>
26 26
 
@@ -29,24 +29,24 @@  discard block
 block discarded – undo
29 29
 
30 30
     <head>
31 31
 
32
-		<meta charset="<?php bloginfo( 'charset' ); ?>">
32
+		<meta charset="<?php bloginfo('charset'); ?>">
33 33
         <meta name="viewport" content="width=device-width, initial-scale=1.0" >
34 34
 
35 35
         <meta name="robots" content="noindex,nofollow">
36 36
 
37 37
 		<link rel="profile" href="https://gmpg.org/xfn/11">
38 38
 
39
-        <title>#<?php echo sanitize_text_field( $invoice->get_number() ); ?></title>
39
+        <title>#<?php echo sanitize_text_field($invoice->get_number()); ?></title>
40 40
 
41
-        <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?>
41
+        <?php do_action('wpinv_invoice_print_head', $invoice); ?>
42 42
 
43 43
     </head>
44 44
     
45 45
 
46 46
     <body class="body wpinv wpinv-print" style="font-weight: 400;">
47 47
 
48
-        <?php do_action( 'getpaid_invoice', $invoice ); ?>
49
-        <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?>
48
+        <?php do_action('getpaid_invoice', $invoice); ?>
49
+        <?php do_action('wpinv_invoice_print_body_end', $invoice); ?>
50 50
 
51 51
     </body>
52 52
 
Please login to merge, or discard this patch.