Passed
Push — master ( 3f789e...c58b71 )
by Brian
04:52
created
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 1 patch
Indentation   +390 added lines, -390 removed lines patch added patch discarded remove patch
@@ -12,474 +12,474 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Paypal_Gateway_IPN_Handler {
14 14
 
15
-	/**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
20
-	protected $id = 'paypal';
21
-
22
-	/**
23
-	 * Payment method object.
24
-	 *
25
-	 * @var GetPaid_Paypal_Gateway
26
-	 */
27
-	protected $gateway;
28
-
29
-	/**
30
-	 * Class constructor.
31
-	 *
32
-	 * @param GetPaid_Paypal_Gateway $gateway
33
-	 */
34
-	public function __construct( $gateway ) {
35
-		$this->gateway = $gateway;
36
-		$this->verify_ipn();
37
-	}
38
-
39
-	/**
40
-	 * Processes ipns and marks payments as complete.
41
-	 *
42
-	 * @return void
43
-	 */
44
-	public function verify_ipn() {
45
-
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
-
48
-		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
51
-		}
52
-
53
-		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
56
-
57
-		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
61
-		}
62
-
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
-
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
-
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
73
-		}
74
-
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
77
-
78
-	}
79
-
80
-	/**
81
-	 * Retrieves IPN Invoice.
82
-	 *
83
-	 * @param array $posted
84
-	 * @return WPInv_Invoice
85
-	 */
86
-	protected function get_ipn_invoice( $posted ) {
87
-
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
-
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
92
-
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
-				return $invoice;
96
-			}
97
-
98
-		}
99
-
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
102
-	}
103
-
104
-	/**
105
-	 * Check PayPal IPN validity.
106
-	 */
107
-	protected function validate_ipn() {
108
-
109
-		wpinv_error_log( 'Validating PayPal IPN response', false );
110
-
111
-		// Retrieve the associated invoice.
112
-		$posted  = wp_unslash( $_POST );
113
-		$invoice = $this->get_ipn_invoice( $posted );
114
-
115
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
116
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
117
-		}
118
-
119
-		// Validate the IPN.
120
-		$posted['cmd'] = '_notify-validate';
121
-
122
-		// Send back post vars to paypal.
123
-		$params = array(
124
-			'body'        => $posted,
125
-			'timeout'     => 60,
126
-			'httpversion' => '1.1',
127
-			'compress'    => false,
128
-			'decompress'  => false,
129
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
130
-		);
131
-
132
-		// Post back to get a response.
133
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
134
-
135
-		// Check to see if the request was valid.
136
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
138
-			return true;
139
-		}
140
-
141
-		if ( is_wp_error( $response ) ) {
142
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
143
-			return false;
144
-		}
15
+    /**
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20
+    protected $id = 'paypal';
21
+
22
+    /**
23
+     * Payment method object.
24
+     *
25
+     * @var GetPaid_Paypal_Gateway
26
+     */
27
+    protected $gateway;
28
+
29
+    /**
30
+     * Class constructor.
31
+     *
32
+     * @param GetPaid_Paypal_Gateway $gateway
33
+     */
34
+    public function __construct( $gateway ) {
35
+        $this->gateway = $gateway;
36
+        $this->verify_ipn();
37
+    }
38
+
39
+    /**
40
+     * Processes ipns and marks payments as complete.
41
+     *
42
+     * @return void
43
+     */
44
+    public function verify_ipn() {
45
+
46
+        wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
+
48
+        // Validate the IPN.
49
+        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
+            wp_die( 'PayPal IPN Request Failure', 500 );
51
+        }
52
+
53
+        // Process the IPN.
54
+        $posted  = wp_unslash( $_POST );
55
+        $invoice = $this->get_ipn_invoice( $posted );
56
+
57
+        // Abort if it was not paid by our gateway.
58
+        if ( $this->id != $invoice->get_gateway() ) {
59
+            wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
+            wp_die( 'Invoice not paid via PayPal', 200 );
61
+        }
62
+
63
+        $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
+        $posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
+
66
+        wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
+        wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
+
69
+        if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
+            call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
+            wpinv_error_log( 'Done processing IPN', false );
72
+            wp_die( 'Processed', 200 );
73
+        }
74
+
75
+        wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
+        wp_die( 'Unsupported IPN type', 200 );
77
+
78
+    }
79
+
80
+    /**
81
+     * Retrieves IPN Invoice.
82
+     *
83
+     * @param array $posted
84
+     * @return WPInv_Invoice
85
+     */
86
+    protected function get_ipn_invoice( $posted ) {
87
+
88
+        wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
+
90
+        if ( ! empty( $posted['custom'] ) ) {
91
+            $invoice = new WPInv_Invoice( $posted['custom'] );
92
+
93
+            if ( $invoice->exists() ) {
94
+                wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
+                return $invoice;
96
+            }
97
+
98
+        }
99
+
100
+        wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
+        wp_die( 'Could not retrieve the associated invoice.', 200 );
102
+    }
103
+
104
+    /**
105
+     * Check PayPal IPN validity.
106
+     */
107
+    protected function validate_ipn() {
108
+
109
+        wpinv_error_log( 'Validating PayPal IPN response', false );
110
+
111
+        // Retrieve the associated invoice.
112
+        $posted  = wp_unslash( $_POST );
113
+        $invoice = $this->get_ipn_invoice( $posted );
114
+
115
+        if ( $this->gateway->is_sandbox( $invoice ) ) {
116
+            wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
117
+        }
118
+
119
+        // Validate the IPN.
120
+        $posted['cmd'] = '_notify-validate';
121
+
122
+        // Send back post vars to paypal.
123
+        $params = array(
124
+            'body'        => $posted,
125
+            'timeout'     => 60,
126
+            'httpversion' => '1.1',
127
+            'compress'    => false,
128
+            'decompress'  => false,
129
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
130
+        );
131
+
132
+        // Post back to get a response.
133
+        $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
134
+
135
+        // Check to see if the request was valid.
136
+        if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
+            wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
138
+            return true;
139
+        }
140
+
141
+        if ( is_wp_error( $response ) ) {
142
+            wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
143
+            return false;
144
+        }
145 145
 
146
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
147
-		return false;
148
-
149
-	}
146
+        wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
147
+        return false;
148
+
149
+    }
150 150
 
151
-	/**
152
-	 * Check currency from IPN matches the invoice.
153
-	 *
154
-	 * @param WPInv_Invoice $invoice          Invoice object.
155
-	 * @param string   $currency currency to validate.
156
-	 */
157
-	protected function validate_ipn_currency( $invoice, $currency ) {
151
+    /**
152
+     * Check currency from IPN matches the invoice.
153
+     *
154
+     * @param WPInv_Invoice $invoice          Invoice object.
155
+     * @param string   $currency currency to validate.
156
+     */
157
+    protected function validate_ipn_currency( $invoice, $currency ) {
158 158
 
159
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
160 160
 
161
-			/* translators: %s: currency code. */
162
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
161
+            /* translators: %s: currency code. */
162
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
163 163
 
164
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
165
-		}
164
+            wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
165
+        }
166 166
 
167
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
168
-	}
167
+        wpinv_error_log( $currency, 'Validated IPN Currency', false );
168
+    }
169 169
 
170
-	/**
171
-	 * Check payment amount from IPN matches the invoice.
172
-	 *
173
-	 * @param WPInv_Invoice $invoice          Invoice object.
174
-	 * @param float   $amount amount to validate.
175
-	 */
176
-	protected function validate_ipn_amount( $invoice, $amount ) {
177
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
170
+    /**
171
+     * Check payment amount from IPN matches the invoice.
172
+     *
173
+     * @param WPInv_Invoice $invoice          Invoice object.
174
+     * @param float   $amount amount to validate.
175
+     */
176
+    protected function validate_ipn_amount( $invoice, $amount ) {
177
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
178 178
 
179
-			/* translators: %s: Amount. */
180
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
179
+            /* translators: %s: Amount. */
180
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
181 181
 
182
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
183
-		}
182
+            wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
183
+        }
184 184
 
185
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
186
-	}
185
+        wpinv_error_log( $amount, 'Validated IPN Amount', false );
186
+    }
187 187
 
188
-	/**
189
-	 * Verify receiver email from PayPal.
190
-	 *
191
-	 * @param WPInv_Invoice $invoice          Invoice object.
192
-	 * @param string   $receiver_email Email to validate.
193
-	 */
194
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
-		$paypal_email = wpinv_get_option( 'paypal_email' );
188
+    /**
189
+     * Verify receiver email from PayPal.
190
+     *
191
+     * @param WPInv_Invoice $invoice          Invoice object.
192
+     * @param string   $receiver_email Email to validate.
193
+     */
194
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
+        $paypal_email = wpinv_get_option( 'paypal_email' );
196 196
 
197
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
197
+        if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
+            wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
199 199
 
200
-			/* translators: %s: email address . */
201
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
200
+            /* translators: %s: email address . */
201
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
202 202
 
203
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
204
-		}
203
+            return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
204
+        }
205 205
 
206
-		wpinv_error_log( 'Validated PayPal Email', false );
207
-	}
206
+        wpinv_error_log( 'Validated PayPal Email', false );
207
+    }
208 208
 
209
-	/**
210
-	 * Handles one time payments.
211
-	 *
212
-	 * @param WPInv_Invoice $invoice  Invoice object.
213
-	 * @param array    $posted Posted data.
214
-	 */
215
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
209
+    /**
210
+     * Handles one time payments.
211
+     *
212
+     * @param WPInv_Invoice $invoice  Invoice object.
213
+     * @param array    $posted Posted data.
214
+     */
215
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
216 216
 
217
-		// Collect payment details
218
-		$payment_status = strtolower( $posted['payment_status'] );
219
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
217
+        // Collect payment details
218
+        $payment_status = strtolower( $posted['payment_status'] );
219
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
220 220
 
221
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
222
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
221
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
222
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
223 223
 
224
-		// Update the transaction id.
225
-		if ( ! empty( $posted['txn_id'] ) ) {
226
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
227
-			$invoice->save();
228
-		}
224
+        // Update the transaction id.
225
+        if ( ! empty( $posted['txn_id'] ) ) {
226
+            $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
227
+            $invoice->save();
228
+        }
229 229
 
230
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
230
+        $invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
231 231
 
232
-		// Process a refund.
233
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
232
+        // Process a refund.
233
+        if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
234 234
 
235
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
235
+            update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
236 236
 
237
-			if ( ! $invoice->is_refunded() ) {
238
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
239
-			}
237
+            if ( ! $invoice->is_refunded() ) {
238
+                $invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
239
+            }
240 240
 
241
-			return wpinv_error_log( $posted['reason_code'], false );
242
-		}
241
+            return wpinv_error_log( $posted['reason_code'], false );
242
+        }
243 243
 
244
-		// Process payments.
245
-		if ( $payment_status == 'completed' ) {
244
+        // Process payments.
245
+        if ( $payment_status == 'completed' ) {
246 246
 
247
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
249
-			}
247
+            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
+                return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
249
+            }
250 250
 
251
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
251
+            $this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
252 252
 
253
-			$note = '';
253
+            $note = '';
254 254
 
255
-			if ( ! empty( $posted['mc_fee'] ) ) {
256
-				$note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
257
-			}
255
+            if ( ! empty( $posted['mc_fee'] ) ) {
256
+                $note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
257
+            }
258 258
 
259
-			if ( ! empty( $posted['payer_status'] ) ) {
260
-				$note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
261
-			}
259
+            if ( ! empty( $posted['payer_status'] ) ) {
260
+                $note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
261
+            }
262 262
 
263
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
-			return wpinv_error_log( 'Invoice marked as paid.', false );
263
+            $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
+            return wpinv_error_log( 'Invoice marked as paid.', false );
265 265
 
266
-		}
266
+        }
267 267
 
268
-		// Pending payments.
269
-		if ( $payment_status == 'pending' ) {
268
+        // Pending payments.
269
+        if ( $payment_status == 'pending' ) {
270 270
 
271
-			/* translators: %s: pending reason. */
272
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
271
+            /* translators: %s: pending reason. */
272
+            $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
273 273
 
274
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
275
-		}
274
+            return wpinv_error_log( 'Invoice marked as "payment held".', false );
275
+        }
276 276
 
277
-		/* translators: %s: payment status. */
278
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
277
+        /* translators: %s: payment status. */
278
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
279 279
 
280
-	}
280
+    }
281 281
 
282
-	/**
283
-	 * Handles one time payments.
284
-	 *
285
-	 * @param WPInv_Invoice $invoice  Invoice object.
286
-	 * @param array    $posted Posted data.
287
-	 */
288
-	protected function ipn_txn_cart( $invoice, $posted ) {
289
-		$this->ipn_txn_web_accept( $invoice, $posted );
290
-	}
282
+    /**
283
+     * Handles one time payments.
284
+     *
285
+     * @param WPInv_Invoice $invoice  Invoice object.
286
+     * @param array    $posted Posted data.
287
+     */
288
+    protected function ipn_txn_cart( $invoice, $posted ) {
289
+        $this->ipn_txn_web_accept( $invoice, $posted );
290
+    }
291 291
 
292
-	/**
293
-	 * Handles subscription sign ups.
294
-	 *
295
-	 * @param WPInv_Invoice $invoice  Invoice object.
296
-	 * @param array    $posted Posted data.
297
-	 */
298
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
292
+    /**
293
+     * Handles subscription sign ups.
294
+     *
295
+     * @param WPInv_Invoice $invoice  Invoice object.
296
+     * @param array    $posted Posted data.
297
+     */
298
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
299 299
 
300
-		wpinv_error_log( 'Processing subscription signup', false );
300
+        wpinv_error_log( 'Processing subscription signup', false );
301 301
 
302
-		// Make sure the invoice has a subscription.
303
-		$subscription = getpaid_get_invoice_subscription( $invoice );
302
+        // Make sure the invoice has a subscription.
303
+        $subscription = getpaid_get_invoice_subscription( $invoice );
304 304
 
305
-		if ( empty( $subscription ) ) {
306
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
307
-		}
305
+        if ( empty( $subscription ) ) {
306
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
307
+        }
308 308
 
309
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
309
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
310 310
 
311
-		// Validate the IPN.
312
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
314
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
311
+        // Validate the IPN.
312
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
314
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
315 315
 
316
-		// Activate the subscription.
317
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
-		$subscription->set_date_created( current_time( 'mysql' ) );
319
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
321
-		$subscription->activate();
316
+        // Activate the subscription.
317
+        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
+        $subscription->set_date_created( current_time( 'mysql' ) );
319
+        $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
+        $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
321
+        $subscription->activate();
322 322
 
323
-		// Set the transaction id.
324
-		if ( ! empty( $posted['txn_id'] ) ) {
325
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
-			$invoice->set_transaction_id( $posted['txn_id'] );
327
-		}
323
+        // Set the transaction id.
324
+        if ( ! empty( $posted['txn_id'] ) ) {
325
+            $invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
+            $invoice->set_transaction_id( $posted['txn_id'] );
327
+        }
328 328
 
329
-		// Update the payment status.
330
-		$invoice->mark_paid();
329
+        // Update the payment status.
330
+        $invoice->mark_paid();
331 331
 
332
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
332
+        $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
333 333
 
334
-		wpinv_error_log( 'Subscription started.', false );
335
-	}
334
+        wpinv_error_log( 'Subscription started.', false );
335
+    }
336 336
 
337
-	/**
338
-	 * Handles subscription renewals.
339
-	 *
340
-	 * @param WPInv_Invoice $invoice  Invoice object.
341
-	 * @param array    $posted Posted data.
342
-	 */
343
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
337
+    /**
338
+     * Handles subscription renewals.
339
+     *
340
+     * @param WPInv_Invoice $invoice  Invoice object.
341
+     * @param array    $posted Posted data.
342
+     */
343
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
344 344
 
345
-		// Make sure the invoice has a subscription.
346
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
345
+        // Make sure the invoice has a subscription.
346
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
347 347
 
348
-		if ( empty( $subscription ) ) {
349
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
350
-		}
348
+        if ( empty( $subscription ) ) {
349
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
350
+        }
351 351
 
352
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
352
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
353 353
 
354
-		// PayPal sends a subscr_payment for the first payment too.
355
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
357
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
359
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
354
+        // PayPal sends a subscr_payment for the first payment too.
355
+        $date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
+        $date_created   = getpaid_format_date( $invoice->get_date_created() );
357
+        $today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
+        $payment_date   = getpaid_format_date( $posted['payment_date'] );
359
+        $subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
+        $dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
361 361
 
362
-		foreach( $dates as $date ) {
362
+        foreach( $dates as $date ) {
363 363
 
364
-			if ( $date !== $today_date && $date !== $payment_date ) {
365
-				continue;
366
-			}
364
+            if ( $date !== $today_date && $date !== $payment_date ) {
365
+                continue;
366
+            }
367 367
 
368
-			if ( ! empty( $posted['txn_id'] ) ) {
369
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
371
-			}
368
+            if ( ! empty( $posted['txn_id'] ) ) {
369
+                $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
+                $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
371
+            }
372 372
 
373
-			return $invoice->mark_paid();
374
-
375
-		}
373
+            return $invoice->mark_paid();
374
+
375
+        }
376 376
 
377
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
378
-
379
-		// Abort if the payment is already recorded.
380
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
382
-		}
383
-
384
-		$args = array(
385
-			'transaction_id' => $posted['txn_id'],
386
-			'gateway'        => $this->id,
387
-		);
388
-
389
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
377
+        wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
378
+
379
+        // Abort if the payment is already recorded.
380
+        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
+            return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
382
+        }
383
+
384
+        $args = array(
385
+            'transaction_id' => $posted['txn_id'],
386
+            'gateway'        => $this->id,
387
+        );
388
+
389
+        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
390 390
 
391
-		if ( empty( $invoice ) ) {
392
-			return;
393
-		}
391
+        if ( empty( $invoice ) ) {
392
+            return;
393
+        }
394 394
 
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
395
+        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
+        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
397 397
 
398
-		$subscription->renew();
399
-		wpinv_error_log( 'Subscription renewed.', false );
398
+        $subscription->renew();
399
+        wpinv_error_log( 'Subscription renewed.', false );
400 400
 
401
-	}
401
+    }
402 402
 
403
-	/**
404
-	 * Handles subscription cancelations.
405
-	 *
406
-	 * @param WPInv_Invoice $invoice  Invoice object.
407
-	 */
408
-	protected function ipn_txn_subscr_cancel( $invoice ) {
403
+    /**
404
+     * Handles subscription cancelations.
405
+     *
406
+     * @param WPInv_Invoice $invoice  Invoice object.
407
+     */
408
+    protected function ipn_txn_subscr_cancel( $invoice ) {
409 409
 
410
-		// Make sure the invoice has a subscription.
411
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
412
-
413
-		if ( empty( $subscription ) ) {
414
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415
-		}
416
-
417
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
418
-		$subscription->cancel();
419
-		wpinv_error_log( 'Subscription cancelled.', false );
410
+        // Make sure the invoice has a subscription.
411
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
412
+
413
+        if ( empty( $subscription ) ) {
414
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415
+        }
416
+
417
+        wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
418
+        $subscription->cancel();
419
+        wpinv_error_log( 'Subscription cancelled.', false );
420 420
 
421
-	}
421
+    }
422 422
 
423
-	/**
424
-	 * Handles subscription completions.
425
-	 *
426
-	 * @param WPInv_Invoice $invoice  Invoice object.
427
-	 * @param array    $posted Posted data.
428
-	 */
429
-	protected function ipn_txn_subscr_eot( $invoice ) {
423
+    /**
424
+     * Handles subscription completions.
425
+     *
426
+     * @param WPInv_Invoice $invoice  Invoice object.
427
+     * @param array    $posted Posted data.
428
+     */
429
+    protected function ipn_txn_subscr_eot( $invoice ) {
430 430
 
431
-		// Make sure the invoice has a subscription.
432
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
431
+        // Make sure the invoice has a subscription.
432
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
433 433
 
434
-		if ( empty( $subscription ) ) {
435
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
436
-		}
434
+        if ( empty( $subscription ) ) {
435
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
436
+        }
437 437
 
438
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
439
-		$subscription->complete();
440
-		wpinv_error_log( 'Subscription completed.', false );
438
+        wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
439
+        $subscription->complete();
440
+        wpinv_error_log( 'Subscription completed.', false );
441 441
 
442
-	}
442
+    }
443 443
 
444
-	/**
445
-	 * Handles subscription fails.
446
-	 *
447
-	 * @param WPInv_Invoice $invoice  Invoice object.
448
-	 * @param array    $posted Posted data.
449
-	 */
450
-	protected function ipn_txn_subscr_failed( $invoice ) {
444
+    /**
445
+     * Handles subscription fails.
446
+     *
447
+     * @param WPInv_Invoice $invoice  Invoice object.
448
+     * @param array    $posted Posted data.
449
+     */
450
+    protected function ipn_txn_subscr_failed( $invoice ) {
451 451
 
452
-		// Make sure the invoice has a subscription.
453
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
452
+        // Make sure the invoice has a subscription.
453
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
454 454
 
455
-		if ( empty( $subscription ) ) {
456
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
457
-		}
455
+        if ( empty( $subscription ) ) {
456
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
457
+        }
458 458
 
459
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
460
-		$subscription->failing();
461
-		wpinv_error_log( 'Subscription marked as failing.', false );
459
+        wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
460
+        $subscription->failing();
461
+        wpinv_error_log( 'Subscription marked as failing.', false );
462 462
 
463
-	}
463
+    }
464 464
 
465
-	/**
466
-	 * Handles subscription suspensions.
467
-	 *
468
-	 * @param WPInv_Invoice $invoice  Invoice object.
469
-	 * @param array    $posted Posted data.
470
-	 */
471
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
465
+    /**
466
+     * Handles subscription suspensions.
467
+     *
468
+     * @param WPInv_Invoice $invoice  Invoice object.
469
+     * @param array    $posted Posted data.
470
+     */
471
+    protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
472 472
 
473
-		// Make sure the invoice has a subscription.
474
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
473
+        // Make sure the invoice has a subscription.
474
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
475 475
 
476
-		if ( empty( $subscription ) ) {
477
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
478
-		}
479
-
480
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
481
-		$subscription->cancel();
482
-		wpinv_error_log( 'Subscription cancelled.', false );
483
-	}
476
+        if ( empty( $subscription ) ) {
477
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
478
+        }
479
+
480
+        wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
481
+        $subscription->cancel();
482
+        wpinv_error_log( 'Subscription cancelled.', false );
483
+    }
484 484
 
485 485
 }
Please login to merge, or discard this patch.
includes/admin/html-admin-page-addons.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 add_ThickBox();
10 10
 ?>
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 	<?php if ( $tabs ){ ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
-			}
20
-			do_action( 'wpi_addons_tabs' );
21
-			?>
17
+            foreach ( $tabs as $name => $label ) {
18
+                echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
+            }
20
+            do_action( 'wpi_addons_tabs' );
21
+            ?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+        if($current_tab == 'membership'){
27 27
 
28
-			?>
28
+            ?>
29 29
 
30 30
 			<div class="wpi-membership-tab-conatiner">
31 31
 				<div class="membership-content">
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 					<h2><?php _e("Have a membership key?","invoicing");?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
-						?>
39
+                        $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
+                        echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
+                        ?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51
-									$addon_obj = new WPInv_Admin_Addons();
52
-									if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
-										}
56
-									}
57
-									?>
51
+                                    $addon_obj = new WPInv_Admin_Addons();
52
+                                    if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
+                                        foreach ( $addons as $addon ) {
54
+                                            echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
+                                        }
56
+                                    }
57
+                                    ?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 									<h3><?php _e("Included Gateways:","invoicing");?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
-											}
72
-										}
73
-										?>
68
+                                        if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
+                                            foreach ( $addons as $addon ) {
70
+                                                echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
+                                            }
72
+                                        }
73
+                                        ?>
74 74
 								</ul>
75 75
 							</div>
76 76
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
-								?>
84
+                                    echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
+                                ?>
86 86
 							</div>
87 87
 							<div class="t-content">
88 88
 								<p>
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
-								?>
104
+                                    echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
+                                ?>
106 106
 							</div>
107 107
 							<div class="t-content">
108 108
 								<p>
@@ -126,21 +126,21 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
130
-			$installed_plugins = get_plugins();
129
+        }else{
130
+            $installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
-				//print_r($addons);
134
-				?>
132
+            if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
+                //print_r($addons);
134
+                ?>
135 135
 				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
136 136
                         if(965==$addon->info->id){continue;}// don't show quote add on
137
-						?><li class="wpi-product">
137
+                        ?><li class="wpi-product">
138 138
 								<div class="wpi-product-title">
139 139
 									<h3><?php
140
-										if ( ! empty( $addon->info->excerpt) ){
141
-											echo wpi_help_tip( $addon->info->excerpt );
142
-										}
143
-										echo esc_html( $addon->info->title ); ?></h3>
140
+                                        if ( ! empty( $addon->info->excerpt) ){
141
+                                            echo wpi_help_tip( $addon->info->excerpt );
142
+                                        }
143
+                                        echo esc_html( $addon->info->title ); ?></h3>
144 144
 								</div>
145 145
 
146 146
 								<span class="wpi-product-image">
@@ -148,32 +148,32 @@  discard block
 block discarded – undo
148 148
 										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
149 149
 									<?php endif;
150 150
 
151
-									if ( 'stripe-payment-gateway' == $addon->info->slug ) {
152
-										$addon->info->slug = 'getpaid-stripe-payments';
153
-										$addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154
-									}
155
-
156
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159
-										echo '</a>';
160
-									}elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
162
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
-										}else{
164
-											// if installed show activation link
165
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
-											}else{
168
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169
-											}
170
-										}
171
-										echo '<a href="'.$url.'" class="thickbox">';
172
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
-										echo '</a>';
174
-									}
175
-
176
-									?>
151
+                                    if ( 'stripe-payment-gateway' == $addon->info->slug ) {
152
+                                        $addon->info->slug = 'getpaid-stripe-payments';
153
+                                        $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154
+                                    }
155
+
156
+                                    if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
+                                        echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159
+                                        echo '</a>';
160
+                                    }elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
+                                        if(defined('WP_EASY_UPDATES_ACTIVE')){
162
+                                            $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
+                                        }else{
164
+                                            // if installed show activation link
165
+                                            if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
+                                            }else{
168
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169
+                                            }
170
+                                        }
171
+                                        echo '<a href="'.$url.'" class="thickbox">';
172
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
+                                        echo '</a>';
174
+                                    }
175
+
176
+                                    ?>
177 177
 
178 178
 								</span>
179 179
 
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 								<span class="wpi-product-button">
182 182
 									<?php
183 183
                                     $addon_obj->output_button( $addon );
184
-									?>
184
+                                    ?>
185 185
 								</span>
186 186
 
187 187
 								<span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul>
188 188
 			<?php endif;
189
-		}
189
+        }
190 190
 
191
-	}
192
-	?>
191
+    }
192
+    ?>
193 193
 
194 194
 
195 195
 	<div class="clearfix" ></div>
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
209 209
 			<br>
210 210
 			<?php
211
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
212
-			?>
211
+            echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
212
+            ?>
213 213
 		</span>
214 214
 	</div>
215 215
 
Please login to merge, or discard this patch.
includes/wpinv-address-functions.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+    $country = wpinv_get_option( 'default_country', 'UK' );
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+    return apply_filters( 'wpinv_default_country', $country );
19 19
 }
20 20
 
21 21
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function wpinv_sanitize_country( $country ) {
38 38
 
39
-	// Enure the country is specified
39
+    // Enure the country is specified
40 40
     if ( empty( $country ) ) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+    $state = wpinv_get_option( 'default_state', '' );
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+    return apply_filters( 'wpinv_default_state', $state );
72 72
 }
73 73
 
74 74
 function wpinv_state_name( $state_code = '', $country_code = '' ) {
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
 
306 306
     $country = wpinv_sanitize_country( $country );
307 307
     
308
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
309
-		if ( false !== array_search( $country, $countries, true ) ) {
310
-			return $continent_code;
311
-		}
312
-	}
308
+    foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
309
+        if ( false !== array_search( $country, $countries, true ) ) {
310
+            return $continent_code;
311
+        }
312
+    }
313 313
 
314 314
     return '';
315 315
     
@@ -601,33 +601,33 @@  discard block
 block discarded – undo
601 601
 }
602 602
 
603 603
 function wpinv_get_states_field() {
604
-	if( empty( $_POST['country'] ) ) {
605
-		$_POST['country'] = wpinv_get_default_country();
606
-	}
607
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
604
+    if( empty( $_POST['country'] ) ) {
605
+        $_POST['country'] = wpinv_get_default_country();
606
+    }
607
+    $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
608 608
 
609
-	if( !empty( $states ) ) {
610
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
609
+    if( !empty( $states ) ) {
610
+        $sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
611 611
 
612 612
         $class  = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : '';
613 613
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
614 614
 
615 615
         $args  = array(
616
-			'name'    => $sanitized_field_name,
617
-			'id'      => $sanitized_field_name,
618
-			'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
619
-			'options' => array_merge( array( '' => '' ), $states ),
620
-			'show_option_all'  => false,
621
-			'show_option_none' => false
622
-		);
623
-
624
-		$response = wpinv_html_select( $args );
625
-
626
-	} else {
627
-		$response = 'nostates';
628
-	}
616
+            'name'    => $sanitized_field_name,
617
+            'id'      => $sanitized_field_name,
618
+            'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
619
+            'options' => array_merge( array( '' => '' ), $states ),
620
+            'show_option_all'  => false,
621
+            'show_option_none' => false
622
+        );
623
+
624
+        $response = wpinv_html_select( $args );
625
+
626
+    } else {
627
+        $response = 'nostates';
628
+    }
629 629
 
630
-	return $response;
630
+    return $response;
631 631
 }
632 632
 
633 633
 function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
@@ -645,46 +645,46 @@  discard block
 block discarded – undo
645 645
  */
646 646
 function wpinv_get_address_formats() {
647 647
 
648
-		return apply_filters( 'wpinv_localisation_address_formats',
649
-			array(
650
-				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
651
-				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
652
-				'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
653
-				'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
-				'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}&nbsp;&nbsp;{{zip}}\n{{country}}",
655
-				'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
656
-				'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
657
-				'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
658
-				'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
-				'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
-				'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
-				'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
662
-				'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
663
-				'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
664
-				'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
665
-				'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
666
-				'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
667
-				'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
668
-				'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
669
-				'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
670
-				'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
671
-				'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
672
-				'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
-				'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
674
-				'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
-				'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
-				'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
-				'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
-				'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
679
-				'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
-				'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
681
-				'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
682
-				'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
683
-				'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
684
-				'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
685
-				'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
686
-			)
687
-		);
648
+        return apply_filters( 'wpinv_localisation_address_formats',
649
+            array(
650
+                'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
651
+                'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
652
+                'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
653
+                'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
+                'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}&nbsp;&nbsp;{{zip}}\n{{country}}",
655
+                'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
656
+                'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
657
+                'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
658
+                'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
+                'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
+                'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
+                'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
662
+                'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
663
+                'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
664
+                'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
665
+                'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
666
+                'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
667
+                'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
668
+                'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
669
+                'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
670
+                'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
671
+                'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
672
+                'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
+                'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
674
+                'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
+                'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
+                'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
+                'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
+                'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
679
+                'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
+                'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
681
+                'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
682
+                'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
683
+                'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
684
+                'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
685
+                'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
686
+            )
687
+        );
688 688
 }
689 689
 
690 690
 /**
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
     }
702 702
 
703 703
     // Get all formats.
704
-	$formats = wpinv_get_address_formats();
704
+    $formats = wpinv_get_address_formats();
705 705
 
706
-	// Get format for the specified country.
707
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
706
+    // Get format for the specified country.
707
+    $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
708 708
     
709 709
     /**
710
-	 * Filters the address format to use on Invoices.
710
+     * Filters the address format to use on Invoices.
711 711
      * 
712 712
      * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed.
713
-	 *
714
-	 * @since 1.0.13
715
-	 *
716
-	 * @param string $format  The address format to use.
713
+     *
714
+     * @since 1.0.13
715
+     *
716
+     * @param string $format  The address format to use.
717 717
      * @param string $country The country who's address format is being retrieved.
718
-	 */
718
+     */
719 719
     return apply_filters( 'wpinv_get_full_address_format', $format, $country );
720 720
 }
721 721
 
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
         'country'           => '',
737 737
         'zip'               => '',
738 738
         'first_name'        => '',
739
-		'last_name'         => '',
740
-		'company'           => '',
739
+        'last_name'         => '',
740
+        'company'           => '',
741 741
     );
742 742
 
743 743
     $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
     $args['country_code']= $country;
759 759
 
760 760
     /**
761
-	 * Filters the address format replacements to use on Invoices.
761
+     * Filters the address format replacements to use on Invoices.
762 762
      * 
763
-	 *
764
-	 * @since 1.0.13
765
-	 *
766
-	 * @param array $replacements  The address replacements to use.
763
+     *
764
+     * @since 1.0.13
765
+     *
766
+     * @param array $replacements  The address replacements to use.
767 767
      * @param array $billing_details  The billing details to use.
768
-	 */
768
+     */
769 769
     $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
770 770
 
771 771
     $return = array();
@@ -788,5 +788,5 @@  discard block
 block discarded – undo
788 788
  * @return string
789 789
  */
790 790
 function wpinv_trim_formatted_address_line( $line ) {
791
-	return trim( $line, ', ' );
791
+    return trim( $line, ', ' );
792 792
 }
793 793
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/class-getpaid-checkout.php 1 patch
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -12,180 +12,180 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Checkout {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Payment_Form_Submission
17
-	 */
18
-	protected $payment_form_submission;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 * 
23
-	 * @param GetPaid_Payment_Form_Submission $submission
24
-	 */
25
-	public function __construct( $submission ) {
26
-		$this->payment_form_submission = $submission;
27
-	}
28
-
29
-	/**
30
-	 * Processes the checkout.
31
-	 *
32
-	 */
33
-	public function process_checkout() {
34
-
35
-		// Validate the submission.
36
-		$this->validate_submission();
37
-
38
-		// Prepare the invoice.
39
-		$items      = $this->get_submission_items();
40
-		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
42
-		$prepared   = $this->prepare_submission_data_for_saving();
43
-
44
-		$this->prepare_billing_info( $invoice );
45
-
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
47
-
48
-		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
50
-		$invoice->recalculate_total();
15
+    /**
16
+     * @var GetPaid_Payment_Form_Submission
17
+     */
18
+    protected $payment_form_submission;
19
+
20
+    /**
21
+     * Class constructor.
22
+     * 
23
+     * @param GetPaid_Payment_Form_Submission $submission
24
+     */
25
+    public function __construct( $submission ) {
26
+        $this->payment_form_submission = $submission;
27
+    }
28
+
29
+    /**
30
+     * Processes the checkout.
31
+     *
32
+     */
33
+    public function process_checkout() {
34
+
35
+        // Validate the submission.
36
+        $this->validate_submission();
37
+
38
+        // Prepare the invoice.
39
+        $items      = $this->get_submission_items();
40
+        $invoice    = $this->get_submission_invoice();
41
+        $invoice    = $this->process_submission_invoice( $invoice, $items );
42
+        $prepared   = $this->prepare_submission_data_for_saving();
43
+
44
+        $this->prepare_billing_info( $invoice );
45
+
46
+        $shipping   = $this->prepare_shipping_info( $invoice );
47
+
48
+        // Save the invoice.
49
+        $invoice->set_is_viewed( true );
50
+        $invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+        do_action( 'getpaid_checkout_invoice_updated', $invoice );
54 54
 
55
-		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
57
-	}
55
+        // Send to the gateway.
56
+        $this->post_process_submission( $invoice, $prepared, $shipping );
57
+    }
58 58
 
59
-	/**
60
-	 * Validates the submission.
61
-	 *
62
-	 */
63
-	protected function validate_submission() {
59
+    /**
60
+     * Validates the submission.
61
+     *
62
+     */
63
+    protected function validate_submission() {
64 64
 
65
-		$submission = $this->payment_form_submission;
66
-		$data       = $submission->get_data();
65
+        $submission = $this->payment_form_submission;
66
+        $data       = $submission->get_data();
67 67
 
68
-		// Do we have an error?
68
+        // Do we have an error?
69 69
         if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
70
+            wp_send_json_error( $submission->last_error );
71 71
         }
72 72
 
73
-		// We need a billing email.
73
+        // We need a billing email.
74 74
         if ( ! $submission->has_billing_email() ) {
75 75
             wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
76
-		}
76
+        }
77 77
 
78
-		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
-		}
78
+        // Non-recurring gateways should not be allowed to process recurring invoices.
79
+        if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
+            wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
+        }
82 82
 
83
-		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
86
-		}
83
+        // Ensure the gateway is active.
84
+        if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
+            wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
86
+        }
87 87
 
88
-		// Clear any existing errors.
89
-		wpinv_clear_errors();
88
+        // Clear any existing errors.
89
+        wpinv_clear_errors();
90 90
 
91
-		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
91
+        // Allow themes and plugins to hook to errors
92
+        do_action( 'getpaid_checkout_error_checks', $submission );
93 93
 
94
-		// Do we have any errors?
94
+        // Do we have any errors?
95 95
         if ( wpinv_get_errors() ) {
96 96
             wp_send_json_error( getpaid_get_errors_html() );
97
-		}
97
+        }
98 98
 
99
-	}
99
+    }
100 100
 
101
-	/**
102
-	 * Retrieves submission items.
103
-	 *
104
-	 * @return GetPaid_Form_Item[]
105
-	 */
106
-	protected function get_submission_items() {
101
+    /**
102
+     * Retrieves submission items.
103
+     *
104
+     * @return GetPaid_Form_Item[]
105
+     */
106
+    protected function get_submission_items() {
107 107
 
108
-		$items = $this->payment_form_submission->get_items();
108
+        $items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111 111
         if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112 112
             wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
113
-		}
114
-
115
-		return $items;
116
-	}
117
-
118
-	/**
119
-	 * Retrieves submission invoice.
120
-	 *
121
-	 * @return WPInv_Invoice
122
-	 */
123
-	protected function get_submission_invoice() {
124
-		$submission = $this->payment_form_submission;
125
-
126
-		if ( ! $submission->has_invoice() ) {
127
-			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
129
-			return $invoice;
130 113
         }
131 114
 
132
-		$invoice = $submission->get_invoice();
115
+        return $items;
116
+    }
133 117
 
134
-		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
-		}
118
+    /**
119
+     * Retrieves submission invoice.
120
+     *
121
+     * @return WPInv_Invoice
122
+     */
123
+    protected function get_submission_invoice() {
124
+        $submission = $this->payment_form_submission;
138 125
 
139
-		return $invoice;
140
-	}
126
+        if ( ! $submission->has_invoice() ) {
127
+            $invoice = new WPInv_Invoice();
128
+            $invoice->set_created_via( 'payment_form' );
129
+            return $invoice;
130
+        }
141 131
 
142
-	/**
143
-	 * Processes the submission invoice.
144
-	 *
145
-	 * @param WPInv_Invoice $invoice
146
-	 * @param GetPaid_Form_Item[] $items
147
-	 * @return WPInv_Invoice
148
-	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
132
+        $invoice = $submission->get_invoice();
150 133
 
151
-		$submission = $this->payment_form_submission;
152
-		$data       = $submission->get_data();
134
+        // Make sure that it is neither paid or refunded.
135
+        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
+            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
+        }
153 138
 
154
-		// Set-up the invoice details.
155
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
156
-		$invoice->set_user_id( $this->get_submission_customer() );
157
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
139
+        return $invoice;
140
+    }
141
+
142
+    /**
143
+     * Processes the submission invoice.
144
+     *
145
+     * @param WPInv_Invoice $invoice
146
+     * @param GetPaid_Form_Item[] $items
147
+     * @return WPInv_Invoice
148
+     */
149
+    protected function process_submission_invoice( $invoice, $items ) {
150
+
151
+        $submission = $this->payment_form_submission;
152
+        $data       = $submission->get_data();
153
+
154
+        // Set-up the invoice details.
155
+        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
156
+        $invoice->set_user_id( $this->get_submission_customer() );
157
+        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
158 158
         $invoice->set_items( $items );
159 159
         $invoice->set_fees( $submission->get_fees() );
160 160
         $invoice->set_taxes( $submission->get_taxes() );
161
-		$invoice->set_discounts( $submission->get_discounts() );
162
-		$invoice->set_gateway( $data['wpi-gateway'] );
161
+        $invoice->set_discounts( $submission->get_discounts() );
162
+        $invoice->set_gateway( $data['wpi-gateway'] );
163 163
 
164
-		$address_confirmed = $submission->get_field( 'confirm-address' );
165
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
164
+        $address_confirmed = $submission->get_field( 'confirm-address' );
165
+        $invoice->set_address_confirmed( ! empty( $address_confirmed ) );
166 166
 
167
-		if ( $submission->has_discount_code() ) {
167
+        if ( $submission->has_discount_code() ) {
168 168
             $invoice->set_discount_code( $submission->get_discount_code() );
169
-		}
170
-
171
-		getpaid_maybe_add_default_address( $invoice );
172
-		return $invoice;
173
-	}
174
-
175
-	/**
176
-	 * Retrieves the submission's customer.
177
-	 *
178
-	 * @return int The customer id.
179
-	 */
180
-	protected function get_submission_customer() {
181
-		$submission = $this->payment_form_submission;
182
-
183
-		// If this is an existing invoice...
184
-		if ( $submission->has_invoice() ) {
185
-			return $submission->get_invoice()->get_user_id();
186
-		}
187
-
188
-		// (Maybe) create the user.
169
+        }
170
+
171
+        getpaid_maybe_add_default_address( $invoice );
172
+        return $invoice;
173
+    }
174
+
175
+    /**
176
+     * Retrieves the submission's customer.
177
+     *
178
+     * @return int The customer id.
179
+     */
180
+    protected function get_submission_customer() {
181
+        $submission = $this->payment_form_submission;
182
+
183
+        // If this is an existing invoice...
184
+        if ( $submission->has_invoice() ) {
185
+            return $submission->get_invoice()->get_user_id();
186
+        }
187
+
188
+        // (Maybe) create the user.
189 189
         $user = get_current_user_id();
190 190
 
191 191
         if ( empty( $user ) ) {
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
         if ( empty( $user ) ) {
196 196
             $user = wpinv_create_user( $submission->get_billing_email() );
197 197
 
198
-			// (Maybe) send new user notification.
199
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
201
-				wp_send_new_user_notifications( $user, 'user' );
202
-			}
198
+            // (Maybe) send new user notification.
199
+            $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
+            if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
201
+                wp_send_new_user_notifications( $user, 'user' );
202
+            }
203 203
 
204 204
         }
205 205
 
@@ -209,31 +209,31 @@  discard block
 block discarded – undo
209 209
 
210 210
         if ( is_numeric( $user ) ) {
211 211
             return $user;
212
-		}
212
+        }
213 213
 
214
-		return $user->ID;
214
+        return $user->ID;
215 215
 
216
-	}
216
+    }
217 217
 
218
-	/**
218
+    /**
219 219
      * Prepares submission data for saving to the database.
220 220
      *
221
-	 * @return array
221
+     * @return array
222 222
      */
223 223
     public function prepare_submission_data_for_saving() {
224 224
 
225
-		$submission = $this->payment_form_submission;
225
+        $submission = $this->payment_form_submission;
226 226
 
227
-		// Prepared submission details.
227
+        // Prepared submission details.
228 228
         $prepared = array();
229 229
 
230 230
         // Raw submission details.
231
-		$data     = $submission->get_data();
231
+        $data     = $submission->get_data();
232 232
 
233
-		// Loop through the submitted details.
233
+        // Loop through the submitted details.
234 234
         foreach ( $submission->get_payment_form()->get_elements() as $field ) {
235 235
 
236
-			// Skip premade fields.
236
+            // Skip premade fields.
237 237
             if ( ! empty( $field['premade'] ) || $field['type'] == 'address' ) {
238 238
                 continue;
239 239
             }
@@ -251,176 +251,176 @@  discard block
 block discarded – undo
251 251
                     $label = $field['label'];
252 252
                 }
253 253
 
254
-				$prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] );
254
+                $prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] );
255 255
 
256 256
             }
257 257
 
258
-		}
258
+        }
259 259
 
260
-		return $prepared;
260
+        return $prepared;
261 261
 
262
-	}
262
+    }
263 263
 
264
-	/**
264
+    /**
265 265
      * Retrieves address details.
266 266
      *
267
-	 * @return array
268
-	 * @param WPInv_Invoice $invoice
269
-	 * @param string $type
267
+     * @return array
268
+     * @param WPInv_Invoice $invoice
269
+     * @param string $type
270 270
      */
271 271
     public function prepare_address_details( $invoice, $type = 'billing' ) {
272 272
 
273
-		$data     = $this->payment_form_submission->get_data();
274
-		$type     = sanitize_key( $type );
275
-		$address  = array();
276
-		$prepared = array();
273
+        $data     = $this->payment_form_submission->get_data();
274
+        $type     = sanitize_key( $type );
275
+        $address  = array();
276
+        $prepared = array();
277 277
 
278
-		if ( ! empty( $data[ $type ] ) ) {
279
-			$address = $data[ $type ];
280
-		}
278
+        if ( ! empty( $data[ $type ] ) ) {
279
+            $address = $data[ $type ];
280
+        }
281 281
 
282
-		// Clean address details.
283
-		foreach ( $address as $key => $value ) {
284
-			$key             = sanitize_key( $key );
285
-			$key             = str_replace( 'wpinv_', '', $key );
286
-			$value           = wpinv_clean( $value );
287
-			$prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
288
-		}
282
+        // Clean address details.
283
+        foreach ( $address as $key => $value ) {
284
+            $key             = sanitize_key( $key );
285
+            $key             = str_replace( 'wpinv_', '', $key );
286
+            $value           = wpinv_clean( $value );
287
+            $prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
288
+        }
289 289
 
290
-		// Filter address details.
291
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
290
+        // Filter address details.
291
+        $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
292 292
 
293
-		// Remove non-whitelisted values.
294
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
293
+        // Remove non-whitelisted values.
294
+        return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
295 295
 
296
-	}
296
+    }
297 297
 
298
-	/**
298
+    /**
299 299
      * Prepares the billing details.
300 300
      *
301
-	 * @return array
302
-	 * @param WPInv_Invoice $invoice
301
+     * @return array
302
+     * @param WPInv_Invoice $invoice
303 303
      */
304 304
     protected function prepare_billing_info( &$invoice ) {
305 305
 
306
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
306
+        $billing_address = $this->prepare_address_details( $invoice, 'billing' );
307 307
 
308
-		// Update the invoice with the billing details.
309
-		$invoice->set_props( $billing_address );
308
+        // Update the invoice with the billing details.
309
+        $invoice->set_props( $billing_address );
310 310
 
311
-	}
311
+    }
312 312
 
313
-	/**
313
+    /**
314 314
      * Prepares the shipping details.
315 315
      *
316
-	 * @return array
317
-	 * @param WPInv_Invoice $invoice
316
+     * @return array
317
+     * @param WPInv_Invoice $invoice
318 318
      */
319 319
     protected function prepare_shipping_info( $invoice ) {
320 320
 
321
-		$data = $this->payment_form_submission->get_data();
321
+        $data = $this->payment_form_submission->get_data();
322 322
 
323
-		if ( empty( $data['same-shipping-address'] ) ) {
324
-			return $this->prepare_address_details( $invoice, 'shipping' );
325
-		}
323
+        if ( empty( $data['same-shipping-address'] ) ) {
324
+            return $this->prepare_address_details( $invoice, 'shipping' );
325
+        }
326 326
 
327
-		return $this->prepare_address_details( $invoice, 'billing' );
327
+        return $this->prepare_address_details( $invoice, 'billing' );
328 328
 
329
-	}
329
+    }
330 330
 
331
-	/**
332
-	 * Confirms the submission is valid and send users to the gateway.
333
-	 *
334
-	 * @param WPInv_Invoice $invoice
335
-	 * @param array $prepared_payment_form_data
336
-	 * @param array $shipping
337
-	 */
338
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
331
+    /**
332
+     * Confirms the submission is valid and send users to the gateway.
333
+     *
334
+     * @param WPInv_Invoice $invoice
335
+     * @param array $prepared_payment_form_data
336
+     * @param array $shipping
337
+     */
338
+    protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
339 339
 
340
-		// Ensure the invoice exists.
340
+        // Ensure the invoice exists.
341 341
         if ( ! $invoice->exists() ) {
342 342
             wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
343 343
         }
344 344
 
345
-		// Save payment form data.
346
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
345
+        // Save payment form data.
346
+        $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
347 347
         if ( ! empty( $prepared_payment_form_data ) ) {
348 348
             update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data );
349
-		}
349
+        }
350 350
 
351
-		// Save payment form data.
351
+        // Save payment form data.
352 352
         if ( ! empty( $shipping ) ) {
353 353
             update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
354
-		}
354
+        }
355 355
 
356
-		// Backwards compatibility.
356
+        // Backwards compatibility.
357 357
         add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
358 358
 
359
-		$this->process_payment( $invoice );
359
+        $this->process_payment( $invoice );
360 360
 
361 361
         // If we are here, there was an error.
362
-		wpinv_send_back_to_checkout( $invoice );
362
+        wpinv_send_back_to_checkout( $invoice );
363 363
 
364
-	}
364
+    }
365 365
 
366
-	/**
367
-	 * Processes the actual payment.
368
-	 *
369
-	 * @param WPInv_Invoice $invoice
370
-	 */
371
-	protected function process_payment( $invoice ) {
366
+    /**
367
+     * Processes the actual payment.
368
+     *
369
+     * @param WPInv_Invoice $invoice
370
+     */
371
+    protected function process_payment( $invoice ) {
372 372
 
373
-		// Clear any checkout errors.
374
-		wpinv_clear_errors();
373
+        // Clear any checkout errors.
374
+        wpinv_clear_errors();
375 375
 
376
-		// No need to send free invoices to the gateway.
377
-		if ( $invoice->is_free() ) {
378
-			$this->process_free_payment( $invoice );
379
-		}
376
+        // No need to send free invoices to the gateway.
377
+        if ( $invoice->is_free() ) {
378
+            $this->process_free_payment( $invoice );
379
+        }
380 380
 
381
-		$submission = $this->payment_form_submission;
381
+        $submission = $this->payment_form_submission;
382 382
 
383
-		// Fires before sending to the gateway.
384
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
383
+        // Fires before sending to the gateway.
384
+        do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
385 385
 
386
-		// Allow the sumission data to be modified before it is sent to the gateway.
387
-		$submission_data    = $submission->get_data();
388
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
389
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
386
+        // Allow the sumission data to be modified before it is sent to the gateway.
387
+        $submission_data    = $submission->get_data();
388
+        $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
389
+        $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
390 390
 
391
-		// Validate the currency.
392
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
393
-			wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
394
-		}
391
+        // Validate the currency.
392
+        if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
393
+            wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
394
+        }
395 395
 
396
-		// Check to see if we have any errors.
397
-		if ( wpinv_get_errors() ) {
398
-			wpinv_send_back_to_checkout( $invoice );
399
-		}
396
+        // Check to see if we have any errors.
397
+        if ( wpinv_get_errors() ) {
398
+            wpinv_send_back_to_checkout( $invoice );
399
+        }
400 400
 
401
-		// Send info to the gateway for payment processing
402
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
401
+        // Send info to the gateway for payment processing
402
+        do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
403 403
 
404
-		// Backwards compatibility.
405
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
404
+        // Backwards compatibility.
405
+        wpinv_send_to_gateway( $submission_gateway, $invoice );
406 406
 
407
-	}
407
+    }
408 408
 
409
-	/**
410
-	 * Marks the invoice as paid in case the checkout is free.
411
-	 *
412
-	 * @param WPInv_Invoice $invoice
413
-	 */
414
-	protected function process_free_payment( $invoice ) {
409
+    /**
410
+     * Marks the invoice as paid in case the checkout is free.
411
+     *
412
+     * @param WPInv_Invoice $invoice
413
+     */
414
+    protected function process_free_payment( $invoice ) {
415 415
 
416
-		$invoice->set_gateway( 'none' );
417
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
418
-		$invoice->mark_paid();
419
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
416
+        $invoice->set_gateway( 'none' );
417
+        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
418
+        $invoice->mark_paid();
419
+        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
420 420
 
421
-	}
421
+    }
422 422
 
423
-	/**
423
+    /**
424 424
      * Sends a redrect response to payment details.
425 425
      *
426 426
      */
Please login to merge, or discard this patch.
includes/admin/views/wizard-header.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 			<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
21 21
 			<?php
22 22
                 getpaid_admin()->enqeue_scripts();
23
-				wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
-				wp_print_styles( 'select2' );
23
+                wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
+                wp_print_styles( 'select2' );
25 25
                 wp_print_scripts( 'select2' );
26
-				wp_print_scripts( 'wpinv-admin-script' );
26
+                wp_print_scripts( 'wpinv-admin-script' );
27 27
                 do_action( 'admin_print_styles' );
28 28
                 do_action( 'admin_head' );
29
-			?>
29
+            ?>
30 30
 			<style>
31 31
 				body, p{
32 32
 					font-size: 16px;
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin-setup-wizard.php 1 patch
Indentation   +382 added lines, -382 removed lines patch added patch discarded remove patch
@@ -17,394 +17,394 @@
 block discarded – undo
17 17
  */
18 18
 class GetPaid_Admin_Setup_Wizard {
19 19
 
20
-	/**
21
-	 * @var string Current Step
22
-	 */
23
-	protected $step = '';
24
-
25
-	/**
26
-	 * @var string|false Previous Step
27
-	 */
28
-	protected $previous_step = '';
29
-
30
-	/**
31
-	 * @var string|false Next Step
32
-	 */
33
-	protected $next_step = '';
34
-
35
-	/**
36
-	 * @var array All available steps for the setup wizard 
37
-	 */
38
-	protected $steps = array();
39
-
40
-	/**
41
-	 * Class constructor.
42
-	 *
43
-	 * @since 2.4.0
44
-	 */
45
-	public function __construct() {
46
-
47
-		if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) {
48
-			add_action( 'admin_menu', array( $this, 'add_menu' ) );
49
-			add_action( 'current_screen', array( $this, 'setup_wizard' ) );
50
-		}
51
-
52
-	}
53
-
54
-	/**
55
-	 * Add admin menus/screens.
56
-	 *
57
-	 * @since 2.4.0
58
-	 */
59
-	public function add_menu() {
60
-		add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' );
61
-	}
62
-
63
-	/**
64
-	 * Sets up the setup wizard.
65
-	 *
66
-	 * @since 2.4.0
67
-	 */
68
-	public function setup_wizard() {
69
-
70
-		if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) {
71
-			$this->setup_globals();
72
-			$this->maybe_save_current_step();
73
-			$this->display_wizard();
74
-			exit;
75
-		}
76
-
77
-	}
78
-
79
-	/**
80
-	 * Sets up class variables.
81
-	 *
82
-	 * @since 2.4.0
83
-	 */
84
-	protected function setup_globals() {
85
-		$this->steps         = $this->get_setup_steps();
86
-		$this->step          = $this->get_current_step();
87
-		$this->previous_step = $this->get_previous_step();
88
-		$this->next_step     = $this->get_next_step();
89
-	}
90
-
91
-	/**
92
-	 * Saves the current step.
93
-	 *
94
-	 * @since 2.4.0
95
-	 */
96
-	protected function maybe_save_current_step() {
97
-		if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) {
98
-			call_user_func( $this->steps[ $this->step ]['handler'], $this );
99
-		}
100
-	}
101
-
102
-	/**
103
-	 * Returns the setup steps.
104
-	 *
105
-	 * @since 2.4.0
106
-	 * @return array
107
-	 */
108
-	protected function get_setup_steps() {
109
-
110
-		$steps = array(
111
-
112
-			'introduction'     => array(
113
-				'name'    => __( 'Introduction', 'invoicing' ),
114
-				'view'    => array( $this, 'setup_introduction' ),
115
-				'handler' => '',
116
-			),
117
-
118
-			'business_details'             => array(
119
-				'name'    => __( "Business Details", 'invoicing' ),
120
-				'view'    => array( $this, 'setup_business' ),
121
-				'handler' => array( $this, 'setup_business_save' ),
122
-			),
123
-
124
-			'currency' => array(
125
-				'name'    => __( 'Currency', 'invoicing' ),
126
-				'view'    => array( $this, 'setup_currency' ),
127
-				'handler' => array( $this, 'setup_currency_save' ),
128
-			),
129
-
130
-			'payments'        => array(
131
-				'name'    => __( 'Payment Gateways', 'invoicing' ),
132
-				'view'    => array( $this, 'setup_payments' ),
133
-				'handler' => array( $this, 'setup_payments_save' ),
134
-			),
135
-
136
-			'recommend'          => array(
137
-				'name'    => __( 'Recommend', 'invoicing' ),
138
-				'view'    => array( $this, 'setup_recommend' ),
139
-				'handler' => array( $this, 'setup_recommend_save' ),
140
-			),
141
-
142
-			'next_steps'       => array(
143
-				'name'    => __( 'Get Paid', 'invoicing' ),
144
-				'view'    => array( $this, 'setup_ready' ),
145
-				'handler' => '',
146
-			),
147
-
148
-		);
149
-
150
-		return apply_filters( 'getpaid_setup_wizard_steps', $steps );
151
-
152
-	}
153
-
154
-	/**
155
-	 * Returns the current step.
156
-	 *
157
-	 * @since 2.4.0
158
-	 * @return string
159
-	 */
160
-	protected function get_current_step() {
161
-		$step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : '';
162
-		return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) );
163
-	}
164
-
165
-	/**
166
-	 * Returns the previous step.
167
-	 *
168
-	 * @since 2.4.0
169
-	 * @return string|false
170
-	 */
171
-	protected function get_previous_step() {
172
-
173
-		$previous = false;
174
-		$current  = $this->step;
175
-		foreach ( array_keys( $this->steps ) as $step ) {
176
-			if ( $current === $step ) {
177
-				return $previous;
178
-			}
179
-
180
-			$previous = $step;
181
-		}
182
-
183
-		return false;
184
-	}
185
-
186
-	/**
187
-	 * Returns the next step.
188
-	 *
189
-	 * @since 2.4.0
190
-	 * @return string|false
191
-	 */
192
-	protected function get_next_step() {
193
-
194
-		$on_current = false;
195
-		$current    = $this->step;
196
-		foreach ( array_keys( $this->steps ) as $step ) {
197
-
198
-			if ( $on_current ) {
199
-				return $step;
200
-			}
201
-
202
-			if ( $current === $step ) {
203
-				return $on_current = true;
204
-			}
205
-
206
-		}
207
-
208
-		return false;
209
-	}
210
-
211
-	/**
212
-	 * Displays the setup wizard.
213
-	 *
214
-	 * @since 2.4.0
215
-	 */
216
-	public function display_wizard() {
217
-		$this->display_header();
218
-		$this->display_current_step();
219
-		$this->display_footer();
220
-	}
221
-
222
-	/**
223
-	 * Displays the Wizard Header.
224
-	 *
225
-	 * @since 2.0.0
226
-	 */
227
-	public function display_header() {
228
-		$steps     = $this->steps;
229
-		$current   = $this->step;
230
-		$next_step = $this->next_step;
231
-		array_shift( $steps );
232
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php';
233
-	}
234
-
235
-	/**
236
-	 * Displays the content for the current step.
237
-	 *
238
-	 * @since 2.4.0
239
-	 */
240
-	public function display_current_step() {
241
-		?>
20
+    /**
21
+     * @var string Current Step
22
+     */
23
+    protected $step = '';
24
+
25
+    /**
26
+     * @var string|false Previous Step
27
+     */
28
+    protected $previous_step = '';
29
+
30
+    /**
31
+     * @var string|false Next Step
32
+     */
33
+    protected $next_step = '';
34
+
35
+    /**
36
+     * @var array All available steps for the setup wizard 
37
+     */
38
+    protected $steps = array();
39
+
40
+    /**
41
+     * Class constructor.
42
+     *
43
+     * @since 2.4.0
44
+     */
45
+    public function __construct() {
46
+
47
+        if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) {
48
+            add_action( 'admin_menu', array( $this, 'add_menu' ) );
49
+            add_action( 'current_screen', array( $this, 'setup_wizard' ) );
50
+        }
51
+
52
+    }
53
+
54
+    /**
55
+     * Add admin menus/screens.
56
+     *
57
+     * @since 2.4.0
58
+     */
59
+    public function add_menu() {
60
+        add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' );
61
+    }
62
+
63
+    /**
64
+     * Sets up the setup wizard.
65
+     *
66
+     * @since 2.4.0
67
+     */
68
+    public function setup_wizard() {
69
+
70
+        if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) {
71
+            $this->setup_globals();
72
+            $this->maybe_save_current_step();
73
+            $this->display_wizard();
74
+            exit;
75
+        }
76
+
77
+    }
78
+
79
+    /**
80
+     * Sets up class variables.
81
+     *
82
+     * @since 2.4.0
83
+     */
84
+    protected function setup_globals() {
85
+        $this->steps         = $this->get_setup_steps();
86
+        $this->step          = $this->get_current_step();
87
+        $this->previous_step = $this->get_previous_step();
88
+        $this->next_step     = $this->get_next_step();
89
+    }
90
+
91
+    /**
92
+     * Saves the current step.
93
+     *
94
+     * @since 2.4.0
95
+     */
96
+    protected function maybe_save_current_step() {
97
+        if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) {
98
+            call_user_func( $this->steps[ $this->step ]['handler'], $this );
99
+        }
100
+    }
101
+
102
+    /**
103
+     * Returns the setup steps.
104
+     *
105
+     * @since 2.4.0
106
+     * @return array
107
+     */
108
+    protected function get_setup_steps() {
109
+
110
+        $steps = array(
111
+
112
+            'introduction'     => array(
113
+                'name'    => __( 'Introduction', 'invoicing' ),
114
+                'view'    => array( $this, 'setup_introduction' ),
115
+                'handler' => '',
116
+            ),
117
+
118
+            'business_details'             => array(
119
+                'name'    => __( "Business Details", 'invoicing' ),
120
+                'view'    => array( $this, 'setup_business' ),
121
+                'handler' => array( $this, 'setup_business_save' ),
122
+            ),
123
+
124
+            'currency' => array(
125
+                'name'    => __( 'Currency', 'invoicing' ),
126
+                'view'    => array( $this, 'setup_currency' ),
127
+                'handler' => array( $this, 'setup_currency_save' ),
128
+            ),
129
+
130
+            'payments'        => array(
131
+                'name'    => __( 'Payment Gateways', 'invoicing' ),
132
+                'view'    => array( $this, 'setup_payments' ),
133
+                'handler' => array( $this, 'setup_payments_save' ),
134
+            ),
135
+
136
+            'recommend'          => array(
137
+                'name'    => __( 'Recommend', 'invoicing' ),
138
+                'view'    => array( $this, 'setup_recommend' ),
139
+                'handler' => array( $this, 'setup_recommend_save' ),
140
+            ),
141
+
142
+            'next_steps'       => array(
143
+                'name'    => __( 'Get Paid', 'invoicing' ),
144
+                'view'    => array( $this, 'setup_ready' ),
145
+                'handler' => '',
146
+            ),
147
+
148
+        );
149
+
150
+        return apply_filters( 'getpaid_setup_wizard_steps', $steps );
151
+
152
+    }
153
+
154
+    /**
155
+     * Returns the current step.
156
+     *
157
+     * @since 2.4.0
158
+     * @return string
159
+     */
160
+    protected function get_current_step() {
161
+        $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : '';
162
+        return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) );
163
+    }
164
+
165
+    /**
166
+     * Returns the previous step.
167
+     *
168
+     * @since 2.4.0
169
+     * @return string|false
170
+     */
171
+    protected function get_previous_step() {
172
+
173
+        $previous = false;
174
+        $current  = $this->step;
175
+        foreach ( array_keys( $this->steps ) as $step ) {
176
+            if ( $current === $step ) {
177
+                return $previous;
178
+            }
179
+
180
+            $previous = $step;
181
+        }
182
+
183
+        return false;
184
+    }
185
+
186
+    /**
187
+     * Returns the next step.
188
+     *
189
+     * @since 2.4.0
190
+     * @return string|false
191
+     */
192
+    protected function get_next_step() {
193
+
194
+        $on_current = false;
195
+        $current    = $this->step;
196
+        foreach ( array_keys( $this->steps ) as $step ) {
197
+
198
+            if ( $on_current ) {
199
+                return $step;
200
+            }
201
+
202
+            if ( $current === $step ) {
203
+                return $on_current = true;
204
+            }
205
+
206
+        }
207
+
208
+        return false;
209
+    }
210
+
211
+    /**
212
+     * Displays the setup wizard.
213
+     *
214
+     * @since 2.4.0
215
+     */
216
+    public function display_wizard() {
217
+        $this->display_header();
218
+        $this->display_current_step();
219
+        $this->display_footer();
220
+    }
221
+
222
+    /**
223
+     * Displays the Wizard Header.
224
+     *
225
+     * @since 2.0.0
226
+     */
227
+    public function display_header() {
228
+        $steps     = $this->steps;
229
+        $current   = $this->step;
230
+        $next_step = $this->next_step;
231
+        array_shift( $steps );
232
+        include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php';
233
+    }
234
+
235
+    /**
236
+     * Displays the content for the current step.
237
+     *
238
+     * @since 2.4.0
239
+     */
240
+    public function display_current_step() {
241
+        ?>
242 242
 			<div class="gp-setup-content rowx mw-100 text-center mb-3">
243 243
 				<div class="col-12 col-md-5 m-auto">
244 244
 					<?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?>
245 245
 				</div>
246 246
 			</div>
247 247
 		<?php
248
-	}
249
-
250
-	/**
251
-	 * Setup Wizard Footer.
252
-	 *
253
-	 * @since 2.4.0
254
-	 */
255
-	public function display_footer() {
256
-		echo '</body></html>';
257
-	}
258
-
259
-	/**
260
-	 * Introduction step.
261
-	 *
262
-	 * @since 2.0.0
263
-	 */
264
-	public function setup_introduction() {
265
-		$next_url = $this->get_next_step_link();
266
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php';
267
-	}
268
-
269
-	/**
270
-	 * Get the URL for the next step's screen.
271
-	 *
272
-	 * @param string step   slug (default: current step)
273
-	 *
274
-	 * @return string       URL for next step if a next step exists.
275
-	 *                      Admin URL if it's the last step.
276
-	 *                      Empty string on failure.
277
-	 * @since 3.0.0
278
-	 */
279
-	public function get_next_step_link( $step = '' ) {
280
-		if ( ! $step ) {
281
-			$step = $this->step;
282
-		}
283
-
284
-		$keys = array_keys( $this->steps );
285
-		if ( end( $keys ) === $step ) {
286
-			return admin_url();
287
-		}
288
-
289
-		$step_index = array_search( $step, $keys );
290
-		if ( false === $step_index ) {
291
-			return '';
292
-		}
293
-
294
-		return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ));
295
-	}
296
-
297
-	/**
298
-	 * Setup maps api.
299
-	 *
300
-	 * @since 2.0.0
301
-	 */
302
-	public function setup_business() {
303
-		$next_url = $this->get_next_step_link();
304
-		$wizard   = $this;
305
-		$page     = 'wpinv_settings_general_main';
306
-		$section  = 'wpinv_settings_general_main';
307
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
308
-	}
309
-
310
-	/**
311
-	 * Default Location settings.
312
-	 *
313
-	 * @since 2.0.0
314
-	 */
315
-	public function setup_currency() {
316
-		$next_url = $this->get_next_step_link();
317
-		$wizard   = $this;
318
-		$page     = 'wpinv_settings_general_currency_section';
319
-		$section  = 'wpinv_settings_general_currency_section';
320
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
321
-	}
322
-
323
-	/**
324
-	 * Installation of recommended plugins.
325
-	 *
326
-	 * @since 1.0.0
327
-	 */
328
-	public function setup_recommend() {
329
-		$next_url            = $this->get_next_step_link();
330
-		$recommended_plugins = self::get_recommend_wp_plugins();
331
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php';
332
-	}
333
-
334
-	/**
335
-	 * A list of recommended wp.org plugins.
336
-	 * @return array
337
-	 */
338
-	public static function get_recommend_wp_plugins(){
339
-		return array(
340
-			'ayecode-connect' => array(
341
-				'file'   => 'ayecode-connect/ayecode-connect.php',
342
-				'url'    => 'https://wordpress.org/plugins/ayecode-connect/',
343
-				'slug'   => 'ayecode-connect',
344
-				'name'   => 'AyeCode Connect',
345
-				'desc'   => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ),
346
-			),
347
-			'invoicing-quotes' => array(
348
-				'file'   => 'invoicing-quotes/wpinv-quote.php',
349
-				'url'    => 'https://wordpress.org/plugins/invoicing-quotes/',
350
-				'slug'   => 'invoicing-quotes',
351
-				'name'   => 'Customer Quotes',
352
-				'desc'   => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'),
353
-			),
354
-			'userswp'    => array(
355
-				'file'   => 'userswp/userswp.php',
356
-				'url'    => 'https://wordpress.org/plugins/userswp/',
357
-				'slug'   => 'userswp',
358
-				'name'   => 'UsersWP',
359
-				'desc'   => __('Frontend user login and registration as well as slick profile pages.','geodirectory'),
360
-			),
361
-		);
362
-	}
363
-
364
-	/**
365
-	 * Dummy data save.
366
-	 *
367
-	 * This is done via ajax so we just pass onto the next step.
368
-	 *
369
-	 * @since 2.0.0
370
-	 */
371
-	public function setup_recommend_save() {
372
-		check_admin_referer( 'gp-setup' );
373
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
374
-		exit;
375
-	}
376
-
377
-	/**
378
-	 * Dummy Data setup.
379
-	 *
380
-	 * @since 2.4.0
381
-	 */
382
-	public function setup_payments() {
383
-		$next_url = $this->get_next_step_link();
384
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php';
385
-	}
386
-
387
-	/**
388
-	 * Dummy data save.
389
-	 *
390
-	 * This is done via ajax so we just pass onto the next step.
391
-	 *
392
-	 * @since 2.0.0
393
-	 */
394
-	public function setup_payments_save() {
395
-		check_admin_referer( 'gp-setup' );
396
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
397
-		exit;
398
-	}
399
-
400
-	/**
401
-	 * Final step.
402
-	 *
403
-	 * @since 2.0.0
404
-	 */
405
-	public function setup_ready() {
406
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php';
407
-	}
248
+    }
249
+
250
+    /**
251
+     * Setup Wizard Footer.
252
+     *
253
+     * @since 2.4.0
254
+     */
255
+    public function display_footer() {
256
+        echo '</body></html>';
257
+    }
258
+
259
+    /**
260
+     * Introduction step.
261
+     *
262
+     * @since 2.0.0
263
+     */
264
+    public function setup_introduction() {
265
+        $next_url = $this->get_next_step_link();
266
+        include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php';
267
+    }
268
+
269
+    /**
270
+     * Get the URL for the next step's screen.
271
+     *
272
+     * @param string step   slug (default: current step)
273
+     *
274
+     * @return string       URL for next step if a next step exists.
275
+     *                      Admin URL if it's the last step.
276
+     *                      Empty string on failure.
277
+     * @since 3.0.0
278
+     */
279
+    public function get_next_step_link( $step = '' ) {
280
+        if ( ! $step ) {
281
+            $step = $this->step;
282
+        }
283
+
284
+        $keys = array_keys( $this->steps );
285
+        if ( end( $keys ) === $step ) {
286
+            return admin_url();
287
+        }
288
+
289
+        $step_index = array_search( $step, $keys );
290
+        if ( false === $step_index ) {
291
+            return '';
292
+        }
293
+
294
+        return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ));
295
+    }
296
+
297
+    /**
298
+     * Setup maps api.
299
+     *
300
+     * @since 2.0.0
301
+     */
302
+    public function setup_business() {
303
+        $next_url = $this->get_next_step_link();
304
+        $wizard   = $this;
305
+        $page     = 'wpinv_settings_general_main';
306
+        $section  = 'wpinv_settings_general_main';
307
+        include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
308
+    }
309
+
310
+    /**
311
+     * Default Location settings.
312
+     *
313
+     * @since 2.0.0
314
+     */
315
+    public function setup_currency() {
316
+        $next_url = $this->get_next_step_link();
317
+        $wizard   = $this;
318
+        $page     = 'wpinv_settings_general_currency_section';
319
+        $section  = 'wpinv_settings_general_currency_section';
320
+        include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
321
+    }
322
+
323
+    /**
324
+     * Installation of recommended plugins.
325
+     *
326
+     * @since 1.0.0
327
+     */
328
+    public function setup_recommend() {
329
+        $next_url            = $this->get_next_step_link();
330
+        $recommended_plugins = self::get_recommend_wp_plugins();
331
+        include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php';
332
+    }
333
+
334
+    /**
335
+     * A list of recommended wp.org plugins.
336
+     * @return array
337
+     */
338
+    public static function get_recommend_wp_plugins(){
339
+        return array(
340
+            'ayecode-connect' => array(
341
+                'file'   => 'ayecode-connect/ayecode-connect.php',
342
+                'url'    => 'https://wordpress.org/plugins/ayecode-connect/',
343
+                'slug'   => 'ayecode-connect',
344
+                'name'   => 'AyeCode Connect',
345
+                'desc'   => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ),
346
+            ),
347
+            'invoicing-quotes' => array(
348
+                'file'   => 'invoicing-quotes/wpinv-quote.php',
349
+                'url'    => 'https://wordpress.org/plugins/invoicing-quotes/',
350
+                'slug'   => 'invoicing-quotes',
351
+                'name'   => 'Customer Quotes',
352
+                'desc'   => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'),
353
+            ),
354
+            'userswp'    => array(
355
+                'file'   => 'userswp/userswp.php',
356
+                'url'    => 'https://wordpress.org/plugins/userswp/',
357
+                'slug'   => 'userswp',
358
+                'name'   => 'UsersWP',
359
+                'desc'   => __('Frontend user login and registration as well as slick profile pages.','geodirectory'),
360
+            ),
361
+        );
362
+    }
363
+
364
+    /**
365
+     * Dummy data save.
366
+     *
367
+     * This is done via ajax so we just pass onto the next step.
368
+     *
369
+     * @since 2.0.0
370
+     */
371
+    public function setup_recommend_save() {
372
+        check_admin_referer( 'gp-setup' );
373
+        wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
374
+        exit;
375
+    }
376
+
377
+    /**
378
+     * Dummy Data setup.
379
+     *
380
+     * @since 2.4.0
381
+     */
382
+    public function setup_payments() {
383
+        $next_url = $this->get_next_step_link();
384
+        include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php';
385
+    }
386
+
387
+    /**
388
+     * Dummy data save.
389
+     *
390
+     * This is done via ajax so we just pass onto the next step.
391
+     *
392
+     * @since 2.0.0
393
+     */
394
+    public function setup_payments_save() {
395
+        check_admin_referer( 'gp-setup' );
396
+        wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
397
+        exit;
398
+    }
399
+
400
+    /**
401
+     * Final step.
402
+     *
403
+     * @since 2.0.0
404
+     */
405
+    public function setup_ready() {
406
+        include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php';
407
+    }
408 408
 
409 409
 }
410 410
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Indentation   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -14,88 +14,88 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66 66
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
73
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
74
-		do_action( 'getpaid_init_admin_hooks', $this );
75
-
76
-		// Setup/welcome
77
-		if ( ! empty( $_GET['page'] ) ) {
78
-			switch ( $_GET['page'] ) {
79
-				case 'gp-setup' :
80
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
81
-					break;
82
-			}
83
-		}
67
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
73
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
74
+        do_action( 'getpaid_init_admin_hooks', $this );
75
+
76
+        // Setup/welcome
77
+        if ( ! empty( $_GET['page'] ) ) {
78
+            switch ( $_GET['page'] ) {
79
+                case 'gp-setup' :
80
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
81
+                    break;
82
+            }
83
+        }
84 84
 
85 85
     }
86 86
 
87 87
     /**
88
-	 * Register admin scripts
89
-	 *
90
-	 */
91
-	public function enqeue_scripts() {
88
+     * Register admin scripts
89
+     *
90
+     */
91
+    public function enqeue_scripts() {
92 92
         global $current_screen, $pagenow;
93 93
 
94
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
95
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
94
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
95
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
96 96
 
97 97
         if ( ! empty( $current_screen->post_type ) ) {
98
-			$page = $current_screen->post_type;
98
+            $page = $current_screen->post_type;
99 99
         }
100 100
 
101 101
         // General styles.
@@ -116,54 +116,54 @@  discard block
 block discarded – undo
116 116
         }
117 117
 
118 118
         // Payment form scripts.
119
-		if ( 'wpi_payment_form' == $page && $editing ) {
119
+        if ( 'wpi_payment_form' == $page && $editing ) {
120 120
             $this->load_payment_form_scripts();
121 121
         }
122 122
 
123
-		if ( $page == 'wpinv-subscriptions' ) {
124
-			wp_enqueue_script( 'postbox' );
125
-		}
123
+        if ( $page == 'wpinv-subscriptions' ) {
124
+            wp_enqueue_script( 'postbox' );
125
+        }
126 126
 
127 127
     }
128 128
 
129 129
     /**
130
-	 * Returns admin js translations.
131
-	 *
132
-	 */
133
-	protected function get_admin_i18() {
130
+     * Returns admin js translations.
131
+     *
132
+     */
133
+    protected function get_admin_i18() {
134 134
         global $post;
135 135
 
136
-		$date_range = array(
137
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
138
-		);
136
+        $date_range = array(
137
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
138
+        );
139 139
 
140
-		if ( $date_range['period'] == 'custom' ) {
140
+        if ( $date_range['period'] == 'custom' ) {
141 141
 			
142
-			if ( isset( $_GET['from'] ) ) {
143
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
144
-			}
142
+            if ( isset( $_GET['from'] ) ) {
143
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
144
+            }
145 145
 
146
-			if ( isset( $_GET['to'] ) ) {
147
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
148
-			}
146
+            if ( isset( $_GET['to'] ) ) {
147
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
148
+            }
149 149
 
150
-		}
150
+        }
151 151
 
152 152
         $i18n = array(
153 153
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
154 154
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
155
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
156
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
157
-			'rest_root'                 => esc_url_raw( rest_url() ),
158
-			'date_range'                => $date_range,
155
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
156
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
157
+            'rest_root'                 => esc_url_raw( rest_url() ),
158
+            'date_range'                => $date_range,
159 159
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
160 160
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
161 161
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
162 162
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
163 163
             'tax'                       => wpinv_tax_amount(),
164 164
             'discount'                  => 0,
165
-			'currency_symbol'           => wpinv_currency_symbol(),
166
-			'currency'                  => wpinv_get_currency(),
165
+            'currency_symbol'           => wpinv_currency_symbol(),
166
+            'currency'                  => wpinv_get_currency(),
167 167
             'currency_pos'              => wpinv_currency_position(),
168 168
             'thousand_sep'              => wpinv_thousands_separator(),
169 169
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -183,118 +183,118 @@  discard block
 block discarded – undo
183 183
             'item_description'          => __( 'Item Description', 'invoicing' ),
184 184
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
185 185
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
186
-			'searching'                 => __( 'Searching', 'invoicing' ),
187
-			'loading'                   => __( 'Loading...', 'invoicing' ),
188
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
189
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
186
+            'searching'                 => __( 'Searching', 'invoicing' ),
187
+            'loading'                   => __( 'Loading...', 'invoicing' ),
188
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
189
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
190 190
         );
191 191
 
192
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
192
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
193 193
 
194
-			$invoice              = new WPInv_Invoice( $post );
195
-			$i18n['save_invoice'] = sprintf(
196
-				__( 'Save %s', 'invoicing' ),
197
-				ucfirst( $invoice->get_invoice_quote_type() )
198
-			);
194
+            $invoice              = new WPInv_Invoice( $post );
195
+            $i18n['save_invoice'] = sprintf(
196
+                __( 'Save %s', 'invoicing' ),
197
+                ucfirst( $invoice->get_invoice_quote_type() )
198
+            );
199 199
 
200
-			$i18n['invoice_description'] = sprintf(
201
-				__( '%s Description', 'invoicing' ),
202
-				ucfirst( $invoice->get_invoice_quote_type() )
203
-			);
200
+            $i18n['invoice_description'] = sprintf(
201
+                __( '%s Description', 'invoicing' ),
202
+                ucfirst( $invoice->get_invoice_quote_type() )
203
+            );
204 204
 
205
-		}
206
-		return $i18n;
207
-	}
205
+        }
206
+        return $i18n;
207
+    }
208 208
 
209
-	/**
210
-	 * Change the admin footer text on GetPaid admin pages.
211
-	 *
212
-	 * @since  2.0.0
213
-	 * @param  string $footer_text
214
-	 * @return string
215
-	 */
216
-	public function admin_footer_text( $footer_text ) {
217
-		global $current_screen;
209
+    /**
210
+     * Change the admin footer text on GetPaid admin pages.
211
+     *
212
+     * @since  2.0.0
213
+     * @param  string $footer_text
214
+     * @return string
215
+     */
216
+    public function admin_footer_text( $footer_text ) {
217
+        global $current_screen;
218 218
 
219
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
219
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
220 220
 
221 221
         if ( ! empty( $current_screen->post_type ) ) {
222
-			$page = $current_screen->post_type;
222
+            $page = $current_screen->post_type;
223 223
         }
224 224
 
225 225
         // General styles.
226 226
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
227 227
 
228
-			// Change the footer text
229
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
230
-
231
-				$rating_url  = esc_url(
232
-					wp_nonce_url(
233
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
234
-						'getpaid-nonce',
235
-						'getpaid-nonce'
236
-						)
237
-				);
238
-
239
-				$footer_text = sprintf(
240
-					/* translators: %s: five stars */
241
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
242
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
243
-				);
244
-
245
-			} else {
246
-
247
-				$footer_text = sprintf(
248
-					/* translators: %s: GetPaid */
249
-					__( 'Thank you for using %s!', 'invoicing' ),
250
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
251
-				);
252
-
253
-			}
254
-
255
-		}
256
-
257
-		return $footer_text;
258
-	}
259
-
260
-	/**
261
-	 * Redirects to wp.org to rate the plugin.
262
-	 *
263
-	 * @since  2.0.0
264
-	 */
265
-	public function redirect_to_wordpress_rating_page() {
266
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
267
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
268
-		exit;
269
-	}
270
-
271
-    /**
272
-	 * Loads payment form js.
273
-	 *
274
-	 */
275
-	protected function load_payment_form_scripts() {
228
+            // Change the footer text
229
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
230
+
231
+                $rating_url  = esc_url(
232
+                    wp_nonce_url(
233
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
234
+                        'getpaid-nonce',
235
+                        'getpaid-nonce'
236
+                        )
237
+                );
238
+
239
+                $footer_text = sprintf(
240
+                    /* translators: %s: five stars */
241
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
242
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
243
+                );
244
+
245
+            } else {
246
+
247
+                $footer_text = sprintf(
248
+                    /* translators: %s: GetPaid */
249
+                    __( 'Thank you for using %s!', 'invoicing' ),
250
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
251
+                );
252
+
253
+            }
254
+
255
+        }
256
+
257
+        return $footer_text;
258
+    }
259
+
260
+    /**
261
+     * Redirects to wp.org to rate the plugin.
262
+     *
263
+     * @since  2.0.0
264
+     */
265
+    public function redirect_to_wordpress_rating_page() {
266
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
267
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
268
+        exit;
269
+    }
270
+
271
+    /**
272
+     * Loads payment form js.
273
+     *
274
+     */
275
+    protected function load_payment_form_scripts() {
276 276
         global $post;
277 277
 
278 278
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
279
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
280
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
279
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
280
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
281 281
 
282
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
283
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
282
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
283
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
284 284
 
285
-		wp_localize_script(
285
+        wp_localize_script(
286 286
             'wpinv-admin-payment-form-script',
287 287
             'wpinvPaymentFormAdmin',
288 288
             array(
289
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
290
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
291
-				'currency'      => wpinv_currency_symbol(),
292
-				'position'      => wpinv_currency_position(),
293
-				'decimals'      => (int) wpinv_decimals(),
294
-				'thousands_sep' => wpinv_thousands_separator(),
295
-				'decimals_sep'  => wpinv_decimal_separator(),
296
-				'form_items'    => gepaid_get_form_items( $post->ID ),
297
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
289
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
290
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
291
+                'currency'      => wpinv_currency_symbol(),
292
+                'position'      => wpinv_currency_position(),
293
+                'decimals'      => (int) wpinv_decimals(),
294
+                'thousands_sep' => wpinv_thousands_separator(),
295
+                'decimals_sep'  => wpinv_decimal_separator(),
296
+                'form_items'    => gepaid_get_form_items( $post->ID ),
297
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
298 298
             )
299 299
         );
300 300
 
@@ -303,20 +303,20 @@  discard block
 block discarded – undo
303 303
     }
304 304
 
305 305
     /**
306
-	 * Add our classes to admin pages.
306
+     * Add our classes to admin pages.
307 307
      *
308 308
      * @param string $classes
309 309
      * @return string
310
-	 *
311
-	 */
310
+     *
311
+     */
312 312
     public function admin_body_class( $classes ) {
313
-		global $pagenow, $post, $current_screen;
313
+        global $pagenow, $post, $current_screen;
314 314
 
315 315
 
316 316
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
317 317
 
318 318
         if ( ! empty( $current_screen->post_type ) ) {
319
-			$page = $current_screen->post_type;
319
+            $page = $current_screen->post_type;
320 320
         }
321 321
 
322 322
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -325,59 +325,59 @@  discard block
 block discarded – undo
325 325
 
326 326
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
327 327
             $classes .= ' wpinv-cpt wpinv';
328
-		}
328
+        }
329 329
 		
330
-		if ( getpaid_is_invoice_post_type( $page ) ) {
330
+        if ( getpaid_is_invoice_post_type( $page ) ) {
331 331
             $classes .= ' getpaid-is-invoice-cpt';
332 332
         }
333 333
 
334
-		return $classes;
334
+        return $classes;
335 335
     }
336 336
 
337 337
     /**
338
-	 * Maybe show the AyeCode Connect Notice.
339
-	 */
340
-	public function init_ayecode_connect_helper(){
338
+     * Maybe show the AyeCode Connect Notice.
339
+     */
340
+    public function init_ayecode_connect_helper(){
341 341
 
342 342
         new AyeCode_Connect_Helper(
343 343
             array(
344
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
345
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
346
-				'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>" ),
347
-				'connect_button'    => __("Connect Site","invoicing"),
348
-				'connecting_button'    => __("Connecting...","invoicing"),
349
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
350
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
344
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
345
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
346
+                '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>" ),
347
+                'connect_button'    => __("Connect Site","invoicing"),
348
+                'connecting_button'    => __("Connecting...","invoicing"),
349
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
350
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
351 351
             ),
352 352
             array( 'wpi-addons' )
353 353
         );
354 354
 
355 355
     }
356 356
 
357
-	/**
358
-	 * Redirect users to settings on activation.
359
-	 *
360
-	 * @return void
361
-	 */
362
-	public function activation_redirect() {
357
+    /**
358
+     * Redirect users to settings on activation.
359
+     *
360
+     * @return void
361
+     */
362
+    public function activation_redirect() {
363 363
 
364
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
364
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
365 365
 
366
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
367
-			return;
368
-		}
366
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
367
+            return;
368
+        }
369 369
 
370
-		// Bail if activating from network, or bulk
371
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
372
-			return;
373
-		}
370
+        // Bail if activating from network, or bulk
371
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
372
+            return;
373
+        }
374 374
 
375
-	    update_option( 'wpinv_redirected_to_settings', 1 );
375
+        update_option( 'wpinv_redirected_to_settings', 1 );
376 376
 
377 377
         wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
378 378
         exit;
379 379
 
380
-	}
380
+    }
381 381
 
382 382
     /**
383 383
      * Fires an admin action after verifying that a user can fire them.
@@ -391,416 +391,416 @@  discard block
 block discarded – undo
391 391
 
392 392
     }
393 393
 
394
-	/**
394
+    /**
395 395
      * Sends a payment reminder to a customer.
396
-	 * 
397
-	 * @param array $args
396
+     * 
397
+     * @param array $args
398 398
      */
399 399
     public function send_customer_invoice( $args ) {
400
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
400
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
401 401
 
402
-		if ( $sent ) {
403
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
404
-		} else {
405
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
406
-		}
402
+        if ( $sent ) {
403
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
404
+        } else {
405
+            $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
406
+        }
407 407
 
408
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
409
-		exit;
410
-	}
408
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
409
+        exit;
410
+    }
411 411
 
412
-	/**
412
+    /**
413 413
      * Sends a payment reminder to a customer.
414
-	 * 
415
-	 * @param array $args
414
+     * 
415
+     * @param array $args
416 416
      */
417 417
     public function send_customer_payment_reminder( $args ) {
418
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
418
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
419 419
 
420
-		if ( $sent ) {
421
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
422
-		} else {
423
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
424
-		}
420
+        if ( $sent ) {
421
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
422
+        } else {
423
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
424
+        }
425 425
 
426
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
427
-		exit;
428
-	}
426
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
427
+        exit;
428
+    }
429 429
 
430
-	/**
430
+    /**
431 431
      * Resets tax rates.
432
-	 * 
432
+     * 
433 433
      */
434 434
     public function admin_reset_tax_rates() {
435 435
 
436
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
437
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
438
-		exit;
436
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
437
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
438
+        exit;
439 439
 
440
-	}
440
+    }
441 441
 
442
-	/**
442
+    /**
443 443
      * Resets admin pages.
444
-	 * 
444
+     * 
445 445
      */
446 446
     public function admin_create_missing_pages() {
447
-		$installer = new GetPaid_Installer();
448
-		$installer->create_pages();
449
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
450
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
451
-		exit;
452
-	}
453
-
454
-	/**
447
+        $installer = new GetPaid_Installer();
448
+        $installer->create_pages();
449
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
450
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
451
+        exit;
452
+    }
453
+
454
+    /**
455 455
      * Creates an missing admin tables.
456
-	 * 
456
+     * 
457 457
      */
458 458
     public function admin_create_missing_tables() {
459
-		global $wpdb;
460
-		$installer = new GetPaid_Installer();
459
+        global $wpdb;
460
+        $installer = new GetPaid_Installer();
461 461
 
462
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
463
-			$installer->create_subscriptions_table();
462
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
463
+            $installer->create_subscriptions_table();
464 464
 
465
-			if ( $wpdb->last_error !== '' ) {
466
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
467
-			}
468
-		}
465
+            if ( $wpdb->last_error !== '' ) {
466
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
467
+            }
468
+        }
469 469
 
470
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
471
-			$installer->create_invoices_table();
470
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
471
+            $installer->create_invoices_table();
472 472
 
473
-			if ( $wpdb->last_error !== '' ) {
474
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
475
-			}
476
-		}
473
+            if ( $wpdb->last_error !== '' ) {
474
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
475
+            }
476
+        }
477 477
 
478
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
479
-			$installer->create_invoice_items_table();
478
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
479
+            $installer->create_invoice_items_table();
480 480
 
481
-			if ( $wpdb->last_error !== '' ) {
482
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
483
-			}
484
-		}
481
+            if ( $wpdb->last_error !== '' ) {
482
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
483
+            }
484
+        }
485 485
 
486
-		if ( ! $this->has_notices() ) {
487
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
488
-		}
486
+        if ( ! $this->has_notices() ) {
487
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
488
+        }
489 489
 
490
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
491
-		exit;
492
-	}
490
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
491
+        exit;
492
+    }
493 493
 
494
-	/**
494
+    /**
495 495
      * Migrates old invoices to the new database tables.
496
-	 * 
496
+     * 
497 497
      */
498 498
     public function admin_migrate_old_invoices() {
499 499
 
500
-		// Migrate the invoices.
501
-		$installer = new GetPaid_Installer();
502
-		$installer->migrate_old_invoices();
500
+        // Migrate the invoices.
501
+        $installer = new GetPaid_Installer();
502
+        $installer->migrate_old_invoices();
503 503
 
504
-		// Show an admin message.
505
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
504
+        // Show an admin message.
505
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
506 506
 
507
-		// Redirect the admin.
508
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
509
-		exit;
507
+        // Redirect the admin.
508
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
509
+        exit;
510 510
 
511
-	}
511
+    }
512 512
 
513
-	/**
513
+    /**
514 514
      * Download customers.
515
-	 * 
515
+     * 
516 516
      */
517 517
     public function admin_download_customers() {
518
-		global $wpdb;
518
+        global $wpdb;
519 519
 
520
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
520
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
521 521
 
522
-		header( "Content-Type:text/csv" );
523
-		header( "Content-Disposition:attachment;filename=customers.csv" );
522
+        header( "Content-Type:text/csv" );
523
+        header( "Content-Disposition:attachment;filename=customers.csv" );
524 524
 
525
-		$post_types = '';
525
+        $post_types = '';
526 526
 
527
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
528
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
529
-		}
527
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
528
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
529
+        }
530 530
 
531
-		$post_types = rtrim( $post_types, ' OR' );
531
+        $post_types = rtrim( $post_types, ' OR' );
532 532
 
533
-		$customers = $wpdb->get_col(
534
-			$wpdb->prepare(
535
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
536
-			)
537
-		);
533
+        $customers = $wpdb->get_col(
534
+            $wpdb->prepare(
535
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
536
+            )
537
+        );
538 538
 
539
-		$columns = array(
540
-			'name'     => __( 'Name', 'invoicing' ),
541
-			'email'    => __( 'Email', 'invoicing' ),
542
-			'country'  => __( 'Country', 'invoicing' ),
543
-			'state'    => __( 'State', 'invoicing' ),
544
-			'city'     => __( 'City', 'invoicing' ),
545
-			'zip'      => __( 'ZIP', 'invoicing' ),
546
-			'address'  => __( 'Address', 'invoicing' ),
547
-			'phone'    => __( 'Phone', 'invoicing' ),
548
-			'company'  => __( 'Company', 'invoicing' ),
549
-			'invoices' => __( 'Invoices', 'invoicing' ),
550
-			'total'    => __( 'Total Spend', 'invoicing' ),
551
-			'signup'   => __( 'Date created', 'invoicing' ),
552
-		);
539
+        $columns = array(
540
+            'name'     => __( 'Name', 'invoicing' ),
541
+            'email'    => __( 'Email', 'invoicing' ),
542
+            'country'  => __( 'Country', 'invoicing' ),
543
+            'state'    => __( 'State', 'invoicing' ),
544
+            'city'     => __( 'City', 'invoicing' ),
545
+            'zip'      => __( 'ZIP', 'invoicing' ),
546
+            'address'  => __( 'Address', 'invoicing' ),
547
+            'phone'    => __( 'Phone', 'invoicing' ),
548
+            'company'  => __( 'Company', 'invoicing' ),
549
+            'invoices' => __( 'Invoices', 'invoicing' ),
550
+            'total'    => __( 'Total Spend', 'invoicing' ),
551
+            'signup'   => __( 'Date created', 'invoicing' ),
552
+        );
553 553
 
554
-		// Output the csv column headers.
555
-		fputcsv( $output, array_values( $columns ) );
554
+        // Output the csv column headers.
555
+        fputcsv( $output, array_values( $columns ) );
556 556
 
557
-		// Loop through
558
-		$table = new WPInv_Customers_Table();
559
-		foreach ( $customers as $customer_id ) {
557
+        // Loop through
558
+        $table = new WPInv_Customers_Table();
559
+        foreach ( $customers as $customer_id ) {
560 560
 
561
-			$user = get_user_by( 'id', $customer_id );
562
-			$row  = array();
563
-			if ( empty( $user ) ) {
564
-				continue;
565
-			}
561
+            $user = get_user_by( 'id', $customer_id );
562
+            $row  = array();
563
+            if ( empty( $user ) ) {
564
+                continue;
565
+            }
566 566
 
567
-			foreach ( array_keys( $columns ) as $column ) {
567
+            foreach ( array_keys( $columns ) as $column ) {
568 568
 
569
-				$method = 'column_' . $column;
569
+                $method = 'column_' . $column;
570 570
 
571
-				if ( 'name' == $column ) {
572
-					$value = sanitize_text_field( $user->display_name );
573
-				} else if( 'email' == $column ) {
574
-					$value = sanitize_email( $user->user_email );
575
-				} else if ( is_callable( array( $table, $method ) ) ) {
576
-					$value = strip_tags( $table->$method( $user ) );
577
-				}
571
+                if ( 'name' == $column ) {
572
+                    $value = sanitize_text_field( $user->display_name );
573
+                } else if( 'email' == $column ) {
574
+                    $value = sanitize_email( $user->user_email );
575
+                } else if ( is_callable( array( $table, $method ) ) ) {
576
+                    $value = strip_tags( $table->$method( $user ) );
577
+                }
578 578
 
579
-				if ( empty( $value ) ) {
580
-					$value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
581
-				}
579
+                if ( empty( $value ) ) {
580
+                    $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
581
+                }
582 582
 
583
-				$row[] = $value;
583
+                $row[] = $value;
584 584
 
585
-			}
585
+            }
586 586
 
587
-			fputcsv( $output, $row );
588
-		}
587
+            fputcsv( $output, $row );
588
+        }
589 589
 
590
-		fclose( $output );
591
-		exit;
590
+        fclose( $output );
591
+        exit;
592 592
 
593
-	}
593
+    }
594 594
 
595
-	/**
595
+    /**
596 596
      * Installs a plugin.
597
-	 *
598
-	 * @param array $data
597
+     *
598
+     * @param array $data
599 599
      */
600 600
     public function admin_install_plugin( $data ) {
601 601
 
602
-		if ( ! empty( $data['plugins'] ) ) {
603
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
604
-			wp_cache_flush();
602
+        if ( ! empty( $data['plugins'] ) ) {
603
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
604
+            wp_cache_flush();
605 605
 
606
-			foreach ( $data['plugins'] as $slug => $file ) {
607
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
608
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
609
-				$installed  = $upgrader->install( $plugin_zip );
606
+            foreach ( $data['plugins'] as $slug => $file ) {
607
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
608
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
609
+                $installed  = $upgrader->install( $plugin_zip );
610 610
 
611
-				if ( ! is_wp_error( $installed ) && $installed ) {
612
-					activate_plugin( $file, '', false, true );
613
-				} else {
614
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
615
-				}
611
+                if ( ! is_wp_error( $installed ) && $installed ) {
612
+                    activate_plugin( $file, '', false, true );
613
+                } else {
614
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
615
+                }
616 616
 
617
-			}
617
+            }
618 618
 
619
-		}
619
+        }
620 620
 
621
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'wp-admin/plugins.php' );
622
-		wp_safe_redirect( $redirect );
623
-		exit;
621
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'wp-admin/plugins.php' );
622
+        wp_safe_redirect( $redirect );
623
+        exit;
624 624
 
625
-	}
625
+    }
626 626
 
627
-	/**
627
+    /**
628 628
      * Recalculates discounts.
629
-	 * 
629
+     * 
630 630
      */
631 631
     public function admin_recalculate_discounts() {
632
-		global $wpdb;
632
+        global $wpdb;
633 633
 
634
-		// Fetch all invoices that have discount codes.
635
-		$table    = $wpdb->prefix . 'getpaid_invoices';
636
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
634
+        // Fetch all invoices that have discount codes.
635
+        $table    = $wpdb->prefix . 'getpaid_invoices';
636
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
637 637
 
638
-		foreach ( $invoices as $invoice ) {
638
+        foreach ( $invoices as $invoice ) {
639 639
 
640
-			$invoice = new WPInv_Invoice( $invoice );
640
+            $invoice = new WPInv_Invoice( $invoice );
641 641
 
642
-			if ( ! $invoice->exists() ) {
643
-				continue;
644
-			}
642
+            if ( ! $invoice->exists() ) {
643
+                continue;
644
+            }
645 645
 
646
-			// Abort if the discount does not exist or does not apply here.
647
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
648
-			if ( ! $discount->exists() ) {
649
-				continue;
650
-			}
646
+            // Abort if the discount does not exist or does not apply here.
647
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
648
+            if ( ! $discount->exists() ) {
649
+                continue;
650
+            }
651 651
 
652
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
653
-			$invoice->recalculate_total();
652
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
653
+            $invoice->recalculate_total();
654 654
 
655
-			if ( $invoice->get_total_discount() > 0 ) {
656
-				$invoice->save();
657
-			}
655
+            if ( $invoice->get_total_discount() > 0 ) {
656
+                $invoice->save();
657
+            }
658 658
 
659
-		}
659
+        }
660 660
 
661
-		// Show an admin message.
662
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
661
+        // Show an admin message.
662
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
663 663
 
664
-		// Redirect the admin.
665
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
666
-		exit;
664
+        // Redirect the admin.
665
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
666
+        exit;
667 667
 
668
-	}
668
+    }
669 669
 
670 670
     /**
671
-	 * Returns an array of admin notices.
672
-	 *
673
-	 * @since       1.0.19
671
+     * Returns an array of admin notices.
672
+     *
673
+     * @since       1.0.19
674 674
      * @return array
675
-	 */
676
-	public function get_notices() {
677
-		$notices = get_option( 'wpinv_admin_notices' );
675
+     */
676
+    public function get_notices() {
677
+        $notices = get_option( 'wpinv_admin_notices' );
678 678
         return is_array( $notices ) ? $notices : array();
679
-	}
679
+    }
680 680
 
681
-	/**
682
-	 * Checks if we have any admin notices.
683
-	 *
684
-	 * @since       2.0.4
681
+    /**
682
+     * Checks if we have any admin notices.
683
+     *
684
+     * @since       2.0.4
685 685
      * @return array
686
-	 */
687
-	public function has_notices() {
688
-		return count( $this->get_notices() ) > 0;
689
-	}
690
-
691
-	/**
692
-	 * Clears all admin notices
693
-	 *
694
-	 * @access      public
695
-	 * @since       1.0.19
696
-	 */
697
-	public function clear_notices() {
698
-		delete_option( 'wpinv_admin_notices' );
699
-	}
700
-
701
-	/**
702
-	 * Saves a new admin notice
703
-	 *
704
-	 * @access      public
705
-	 * @since       1.0.19
706
-	 */
707
-	public function save_notice( $type, $message ) {
708
-		$notices = $this->get_notices();
709
-
710
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
711
-			$notices[ $type ] = array();
712
-		}
713
-
714
-		$notices[ $type ][] = $message;
715
-
716
-		update_option( 'wpinv_admin_notices', $notices );
717
-	}
718
-
719
-	/**
720
-	 * Displays a success notice
721
-	 *
722
-	 * @param       string $msg The message to qeue.
723
-	 * @access      public
724
-	 * @since       1.0.19
725
-	 */
726
-	public function show_success( $msg ) {
727
-		$this->save_notice( 'success', $msg );
728
-	}
729
-
730
-	/**
731
-	 * Displays a error notice
732
-	 *
733
-	 * @access      public
734
-	 * @param       string $msg The message to qeue.
735
-	 * @since       1.0.19
736
-	 */
737
-	public function show_error( $msg ) {
738
-		$this->save_notice( 'error', $msg );
739
-	}
740
-
741
-	/**
742
-	 * Displays a warning notice
743
-	 *
744
-	 * @access      public
745
-	 * @param       string $msg The message to qeue.
746
-	 * @since       1.0.19
747
-	 */
748
-	public function show_warning( $msg ) {
749
-		$this->save_notice( 'warning', $msg );
750
-	}
751
-
752
-	/**
753
-	 * Displays a info notice
754
-	 *
755
-	 * @access      public
756
-	 * @param       string $msg The message to qeue.
757
-	 * @since       1.0.19
758
-	 */
759
-	public function show_info( $msg ) {
760
-		$this->save_notice( 'info', $msg );
761
-	}
762
-
763
-	/**
764
-	 * Show notices
765
-	 *
766
-	 * @access      public
767
-	 * @since       1.0.19
768
-	 */
769
-	public function show_notices() {
686
+     */
687
+    public function has_notices() {
688
+        return count( $this->get_notices() ) > 0;
689
+    }
690
+
691
+    /**
692
+     * Clears all admin notices
693
+     *
694
+     * @access      public
695
+     * @since       1.0.19
696
+     */
697
+    public function clear_notices() {
698
+        delete_option( 'wpinv_admin_notices' );
699
+    }
700
+
701
+    /**
702
+     * Saves a new admin notice
703
+     *
704
+     * @access      public
705
+     * @since       1.0.19
706
+     */
707
+    public function save_notice( $type, $message ) {
708
+        $notices = $this->get_notices();
709
+
710
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
711
+            $notices[ $type ] = array();
712
+        }
713
+
714
+        $notices[ $type ][] = $message;
715
+
716
+        update_option( 'wpinv_admin_notices', $notices );
717
+    }
718
+
719
+    /**
720
+     * Displays a success notice
721
+     *
722
+     * @param       string $msg The message to qeue.
723
+     * @access      public
724
+     * @since       1.0.19
725
+     */
726
+    public function show_success( $msg ) {
727
+        $this->save_notice( 'success', $msg );
728
+    }
729
+
730
+    /**
731
+     * Displays a error notice
732
+     *
733
+     * @access      public
734
+     * @param       string $msg The message to qeue.
735
+     * @since       1.0.19
736
+     */
737
+    public function show_error( $msg ) {
738
+        $this->save_notice( 'error', $msg );
739
+    }
740
+
741
+    /**
742
+     * Displays a warning notice
743
+     *
744
+     * @access      public
745
+     * @param       string $msg The message to qeue.
746
+     * @since       1.0.19
747
+     */
748
+    public function show_warning( $msg ) {
749
+        $this->save_notice( 'warning', $msg );
750
+    }
751
+
752
+    /**
753
+     * Displays a info notice
754
+     *
755
+     * @access      public
756
+     * @param       string $msg The message to qeue.
757
+     * @since       1.0.19
758
+     */
759
+    public function show_info( $msg ) {
760
+        $this->save_notice( 'info', $msg );
761
+    }
762
+
763
+    /**
764
+     * Show notices
765
+     *
766
+     * @access      public
767
+     * @since       1.0.19
768
+     */
769
+    public function show_notices() {
770 770
 
771 771
         $notices = $this->get_notices();
772 772
         $this->clear_notices();
773 773
 
774
-		foreach ( $notices as $type => $messages ) {
774
+        foreach ( $notices as $type => $messages ) {
775 775
 
776
-			if ( ! is_array( $messages ) ) {
777
-				continue;
778
-			}
776
+            if ( ! is_array( $messages ) ) {
777
+                continue;
778
+            }
779 779
 
780 780
             $type  = sanitize_key( $type );
781
-			foreach ( $messages as $message ) {
781
+            foreach ( $messages as $message ) {
782 782
                 $message = wp_kses_post( $message );
783
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
783
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
784 784
             }
785 785
 
786 786
         }
787 787
 
788
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
789
-
790
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
791
-				$url     = wp_nonce_url(
792
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
793
-					'getpaid-nonce',
794
-					'getpaid-nonce'
795
-				);
796
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
797
-				$message2 = __( 'Generate Pages', 'invoicing' );
798
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
799
-				break;
800
-			}
788
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
789
+
790
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
791
+                $url     = wp_nonce_url(
792
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
793
+                    'getpaid-nonce',
794
+                    'getpaid-nonce'
795
+                );
796
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
797
+                $message2 = __( 'Generate Pages', 'invoicing' );
798
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
799
+                break;
800
+            }
801 801
 
802
-		}
802
+        }
803 803
 
804
-	}
804
+    }
805 805
 
806 806
 }
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
             'getpaid-nonce',
58 58
             'getpaid-nonce'
59 59
         );
60
-		$anchor = __( 'Deactivate', 'invoicing' );
61
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
60
+        $anchor = __( 'Deactivate', 'invoicing' );
61
+        $title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
62 62
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
63 63
 
64 64
     } else if( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
             'getpaid-nonce',
74 74
             'getpaid-nonce'
75 75
         );
76
-		$anchor = __( 'Activate', 'invoicing' );
77
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
76
+        $anchor = __( 'Activate', 'invoicing' );
77
+        $title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
78 78
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
79 79
 
80 80
     }
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
             'getpaid-nonce'
92 92
         )
93 93
     );
94
-	$anchor = __( 'Delete', 'invoicing' );
95
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
94
+    $anchor = __( 'Delete', 'invoicing' );
95
+    $title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
96 96
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
97 97
 
98 98
     $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
     $name       = isset( $option['name'] ) ? $option['name'] : '';
196 196
     $cb         = "wpinv_{$option['type']}_callback";
197 197
     $section    = "wpinv_settings_{$tab}_$section";
198
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
198
+    $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
199 199
 
200
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
201
-		$tip   = wpinv_clean( $option['desc'] );
202
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
203
-		unset( $option['desc'] );
204
-	}
200
+    if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
201
+        $tip   = wpinv_clean( $option['desc'] );
202
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
203
+        unset( $option['desc'] );
204
+    }
205 205
 
206 206
     // Loop through all tabs.
207 207
     add_settings_field(
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
             'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
229 229
             'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
230 230
             'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
231
-			'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
232
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
233
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
231
+            'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
232
+            'class'       => isset( $option['class'] )     ? $option['class']         : '',
233
+            'style'       => isset( $option['style'] )     ? $option['style']         : '',
234 234
             'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
235 235
             'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
236 236
         )
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
  * @return array
245 245
  */
246 246
 function wpinv_get_registered_settings() {
247
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
247
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
248 248
 }
249 249
 
250 250
 /**
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
  */
264 264
 function wpinv_settings_sanitize( $input = array() ) {
265 265
 
266
-	$wpinv_options = wpinv_get_options();
267
-	$raw_referrer  = wp_get_raw_referer();
266
+    $wpinv_options = wpinv_get_options();
267
+    $raw_referrer  = wp_get_raw_referer();
268 268
 
269 269
     if ( empty( $raw_referrer ) ) {
270
-		return array_merge( $wpinv_options, $input );
270
+        return array_merge( $wpinv_options, $input );
271 271
     }
272 272
 
273 273
     wp_parse_str( $raw_referrer, $referrer );
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
         }
293 293
 
294 294
         // General filter
295
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
295
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
296 296
 
297
-		// Key specific filter.
298
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
297
+        // Key specific filter.
298
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
299 299
     }
300 300
 
301 301
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 
339 339
     foreach ( $new_rates as $rate ) {
340 340
 
341
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
342
-		$rate['name']    = sanitize_text_field( $rate['name'] );
343
-		$rate['state']   = sanitize_text_field( $rate['state'] );
344
-		$rate['country'] = sanitize_text_field( $rate['country'] );
345
-		$rate['global']  = empty( $rate['state'] );
346
-		$tax_rates[]     = $rate;
341
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
342
+        $rate['name']    = sanitize_text_field( $rate['name'] );
343
+        $rate['state']   = sanitize_text_field( $rate['state'] );
344
+        $rate['country'] = sanitize_text_field( $rate['country'] );
345
+        $rate['global']  = empty( $rate['state'] );
346
+        $tax_rates[]     = $rate;
347 347
 
348
-	}
348
+    }
349 349
 
350 350
     update_option( 'wpinv_tax_rates', $tax_rates );
351 351
 
@@ -358,11 +358,11 @@  discard block
 block discarded – undo
358 358
     $tabs['general']  = __( 'General', 'invoicing' );
359 359
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
360 360
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
361
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
361
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
362 362
 
363
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
364
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
365
-	}
363
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
364
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
365
+    }
366 366
 
367 367
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
368 368
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
         ) ),
402 402
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
403 403
             'main'  => __( 'Tax Settings', 'invoicing' ),
404
-			'rates' => __( 'Tax Rates', 'invoicing' ),
405
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
404
+            'rates' => __( 'Tax Rates', 'invoicing' ),
405
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
406 406
         ) ),
407 407
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
408 408
             'main' => __( 'Email Settings', 'invoicing' ),
409
-		) ),
409
+        ) ),
410 410
 
411
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
411
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
412 412
 
413 413
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
414 414
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -428,48 +428,48 @@  discard block
 block discarded – undo
428 428
 }
429 429
 
430 430
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
431
-	$pages_options = array();
431
+    $pages_options = array();
432 432
 
433
-	if( $default_label !== NULL && $default_label !== false ) {
434
-		$pages_options = array( '' => $default_label ); // Blank option
435
-	}
433
+    if( $default_label !== NULL && $default_label !== false ) {
434
+        $pages_options = array( '' => $default_label ); // Blank option
435
+    }
436 436
 
437
-	$pages = get_pages();
438
-	if ( $pages ) {
439
-		foreach ( $pages as $page ) {
440
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
437
+    $pages = get_pages();
438
+    if ( $pages ) {
439
+        foreach ( $pages as $page ) {
440
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
441 441
             $pages_options[ $page->ID ] = $title;
442
-		}
443
-	}
442
+        }
443
+    }
444 444
 
445
-	return $pages_options;
445
+    return $pages_options;
446 446
 }
447 447
 
448 448
 function wpinv_header_callback( $args ) {
449
-	if ( !empty( $args['desc'] ) ) {
449
+    if ( !empty( $args['desc'] ) ) {
450 450
         echo $args['desc'];
451 451
     }
452 452
 }
453 453
 
454 454
 function wpinv_hidden_callback( $args ) {
455 455
 
456
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
457
-	$value   = wpinv_get_option( $args['id'], $std );
456
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
457
+    $value   = wpinv_get_option( $args['id'], $std );
458 458
 
459
-	if ( isset( $args['set_value'] ) ) {
460
-		$value = $args['set_value'];
461
-	}
459
+    if ( isset( $args['set_value'] ) ) {
460
+        $value = $args['set_value'];
461
+    }
462 462
 
463
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
464
-		$args['readonly'] = true;
465
-		$name  = '';
466
-	} else {
467
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
468
-	}
463
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
464
+        $args['readonly'] = true;
465
+        $name  = '';
466
+    } else {
467
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
468
+    }
469 469
 
470
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
470
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
471 471
     
472
-	echo $html;
472
+    echo $html;
473 473
 }
474 474
 
475 475
 /**
@@ -477,12 +477,12 @@  discard block
 block discarded – undo
477 477
  */
478 478
 function wpinv_checkbox_callback( $args ) {
479 479
 
480
-	$std = isset( $args['std'] ) ? $args['std'] : '';
481
-	$std = wpinv_get_option( $args['id'], $std );
482
-	$id  = esc_attr( $args['id'] );
480
+    $std = isset( $args['std'] ) ? $args['std'] : '';
481
+    $std = wpinv_get_option( $args['id'], $std );
482
+    $id  = esc_attr( $args['id'] );
483 483
 
484
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
485
-	?>
484
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
485
+    ?>
486 486
 		<fieldset>
487 487
 			<label>
488 488
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -494,75 +494,75 @@  discard block
 block discarded – undo
494 494
 
495 495
 function wpinv_multicheck_callback( $args ) {
496 496
 
497
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
498
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
497
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
498
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
499 499
 
500
-	if ( ! empty( $args['options'] ) ) {
500
+    if ( ! empty( $args['options'] ) ) {
501 501
 
502
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
503
-		$value   = wpinv_get_option( $args['id'], $std );
502
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
503
+        $value   = wpinv_get_option( $args['id'], $std );
504 504
 
505
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
505
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
506 506
         foreach( $args['options'] as $key => $option ):
507
-			$sanitize_key = wpinv_sanitize_key( $key );
508
-			if ( in_array( $sanitize_key, $value ) ) { 
509
-				$enabled = $sanitize_key;
510
-			} else { 
511
-				$enabled = NULL; 
512
-			}
513
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
514
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
515
-		endforeach;
516
-		echo '</div>';
517
-		echo '<p class="description">' . $args['desc'] . '</p>';
518
-	}
507
+            $sanitize_key = wpinv_sanitize_key( $key );
508
+            if ( in_array( $sanitize_key, $value ) ) { 
509
+                $enabled = $sanitize_key;
510
+            } else { 
511
+                $enabled = NULL; 
512
+            }
513
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
514
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
515
+        endforeach;
516
+        echo '</div>';
517
+        echo '<p class="description">' . $args['desc'] . '</p>';
518
+    }
519 519
 }
520 520
 
521 521
 function wpinv_payment_icons_callback( $args ) {
522 522
     
523 523
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
524
-	$value   = wpinv_get_option( $args['id'], false);
524
+    $value   = wpinv_get_option( $args['id'], false);
525 525
 
526
-	if ( ! empty( $args['options'] ) ) {
527
-		foreach( $args['options'] as $key => $option ) {
526
+    if ( ! empty( $args['options'] ) ) {
527
+        foreach( $args['options'] as $key => $option ) {
528 528
             $sanitize_key = wpinv_sanitize_key( $key );
529 529
             
530
-			if( empty( $value ) ) {
531
-				$enabled = $option;
532
-			} else {
533
-				$enabled = NULL;
534
-			}
535
-
536
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
537
-
538
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
539
-
540
-				if ( wpinv_string_is_image_url( $key ) ) {
541
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
542
-				} else {
543
-					$card = strtolower( str_replace( ' ', '', $option ) );
544
-
545
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
546
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
547
-					} else {
548
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
549
-						$content_dir = WP_CONTENT_DIR;
550
-
551
-						if ( function_exists( 'wp_normalize_path' ) ) {
552
-							// Replaces backslashes with forward slashes for Windows systems
553
-							$image = wp_normalize_path( $image );
554
-							$content_dir = wp_normalize_path( $content_dir );
555
-						}
556
-
557
-						$image = str_replace( $content_dir, content_url(), $image );
558
-					}
559
-
560
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
-				}
562
-			echo $option . '</label>';
563
-		}
564
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
565
-	}
530
+            if( empty( $value ) ) {
531
+                $enabled = $option;
532
+            } else {
533
+                $enabled = NULL;
534
+            }
535
+
536
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
537
+
538
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
539
+
540
+                if ( wpinv_string_is_image_url( $key ) ) {
541
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
542
+                } else {
543
+                    $card = strtolower( str_replace( ' ', '', $option ) );
544
+
545
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
546
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
547
+                    } else {
548
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
549
+                        $content_dir = WP_CONTENT_DIR;
550
+
551
+                        if ( function_exists( 'wp_normalize_path' ) ) {
552
+                            // Replaces backslashes with forward slashes for Windows systems
553
+                            $image = wp_normalize_path( $image );
554
+                            $content_dir = wp_normalize_path( $content_dir );
555
+                        }
556
+
557
+                        $image = str_replace( $content_dir, content_url(), $image );
558
+                    }
559
+
560
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561
+                }
562
+            echo $option . '</label>';
563
+        }
564
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
565
+    }
566 566
 }
567 567
 
568 568
 /**
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
  */
571 571
 function wpinv_radio_callback( $args ) {
572 572
 
573
-	$std = isset( $args['std'] ) ? $args['std'] : '';
574
-	$std = wpinv_get_option( $args['id'], $std );
575
-	?>
573
+    $std = isset( $args['std'] ) ? $args['std'] : '';
574
+    $std = wpinv_get_option( $args['id'], $std );
575
+    ?>
576 576
 		<fieldset>
577 577
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
578 578
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 			</ul>
587 587
 		</fieldset>
588 588
 	<?php
589
-	getpaid_settings_description_callback( $args );
589
+    getpaid_settings_description_callback( $args );
590 590
 }
591 591
 
592 592
 /**
@@ -594,10 +594,10 @@  discard block
 block discarded – undo
594 594
  */
595 595
 function getpaid_settings_description_callback( $args ) {
596 596
 
597
-	if ( ! empty( $args['desc'] ) ) {
598
-		$description = wp_kses_post( $args['desc'] );
599
-		echo "<p class='description'>$description</p>";
600
-	}
597
+    if ( ! empty( $args['desc'] ) ) {
598
+        $description = wp_kses_post( $args['desc'] );
599
+        echo "<p class='description'>$description</p>";
600
+    }
601 601
 
602 602
 }
603 603
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
  */
607 607
 function wpinv_gateways_callback() {
608 608
 
609
-	?>
609
+    ?>
610 610
 		</td>
611 611
 	</tr>
612 612
 	<tr class="bsui">
@@ -620,22 +620,22 @@  discard block
 block discarded – undo
620 620
     
621 621
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
622 622
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
623
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
624
-	$value   = wpinv_get_option( $args['id'], $std );
623
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
624
+    $value   = wpinv_get_option( $args['id'], $std );
625 625
 
626
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
626
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
627 627
 
628
-	foreach ( $args['options'] as $key => $option ) :
629
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
628
+    foreach ( $args['options'] as $key => $option ) :
629
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
630 630
             $selected = selected( $key, $args['selected'], false );
631 631
         } else {
632 632
             $selected = selected( $key, $value, false );
633 633
         }
634
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
635
-	endforeach;
634
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
635
+    endforeach;
636 636
 
637
-	echo '</select>';
638
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
637
+    echo '</select>';
638
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
639 639
 }
640 640
 
641 641
 /**
@@ -646,29 +646,29 @@  discard block
 block discarded – undo
646 646
  */
647 647
 function wpinv_settings_attrs_helper( $args ) {
648 648
 
649
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
650
-	$id           = esc_attr( $args['id'] );
651
-	$placeholder  = esc_attr( $args['placeholder'] );
649
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
650
+    $id           = esc_attr( $args['id'] );
651
+    $placeholder  = esc_attr( $args['placeholder'] );
652 652
 
653
-	if ( ! empty( $args['faux'] ) ) {
654
-		$args['readonly'] = true;
655
-		$name             = '';
656
-	} else {
657
-		$value  = wpinv_get_option( $args['id'], $value );
658
-		$name   = "wpinv_settings[$id]";
659
-	}
653
+    if ( ! empty( $args['faux'] ) ) {
654
+        $args['readonly'] = true;
655
+        $name             = '';
656
+    } else {
657
+        $value  = wpinv_get_option( $args['id'], $value );
658
+        $name   = "wpinv_settings[$id]";
659
+    }
660 660
 
661
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
662
-	$class    = esc_attr( $args['class'] );
663
-	$style    = esc_attr( $args['style'] );
664
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
661
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
662
+    $class    = esc_attr( $args['class'] );
663
+    $style    = esc_attr( $args['style'] );
664
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
665 665
 
666
-	$onchange = '';
666
+    $onchange = '';
667 667
     if ( ! empty( $args['onchange'] ) ) {
668 668
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
669
-	}
669
+    }
670 670
 
671
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
671
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
672 672
 }
673 673
 
674 674
 /**
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
  */
677 677
 function wpinv_text_callback( $args ) {
678 678
 
679
-	$desc = wp_kses_post( $args['desc'] );
680
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
681
-	$attr = wpinv_settings_attrs_helper( $args );
679
+    $desc = wp_kses_post( $args['desc'] );
680
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
681
+    $attr = wpinv_settings_attrs_helper( $args );
682 682
 
683
-	?>
683
+    ?>
684 684
 		<label style="width: 100%;">
685 685
 			<input type="text" <?php echo $attr; ?>>
686 686
 			<?php echo $desc; ?>
@@ -694,14 +694,14 @@  discard block
 block discarded – undo
694 694
  */
695 695
 function wpinv_number_callback( $args ) {
696 696
 
697
-	$desc = wp_kses_post( $args['desc'] );
698
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
699
-	$attr = wpinv_settings_attrs_helper( $args );
700
-	$max  = intval( $args['max'] );
701
-	$min  = intval( $args['min'] );
702
-	$step = floatval( $args['step'] );
697
+    $desc = wp_kses_post( $args['desc'] );
698
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
699
+    $attr = wpinv_settings_attrs_helper( $args );
700
+    $max  = intval( $args['max'] );
701
+    $min  = intval( $args['min'] );
702
+    $step = floatval( $args['step'] );
703 703
 
704
-	?>
704
+    ?>
705 705
 		<label style="width: 100%;">
706 706
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
707 707
 			<?php echo $desc; ?>
@@ -713,36 +713,36 @@  discard block
 block discarded – undo
713 713
 function wpinv_textarea_callback( $args ) {
714 714
     
715 715
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
716
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
717
-	$value   = wpinv_get_option( $args['id'], $std );
716
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
717
+    $value   = wpinv_get_option( $args['id'], $std );
718 718
 
719 719
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
720 720
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
721 721
 
722
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
723
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
722
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
723
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
724 724
 
725
-	echo $html;
725
+    echo $html;
726 726
 }
727 727
 
728 728
 function wpinv_password_callback( $args ) {
729 729
     
730 730
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
731
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
732
-	$value   = wpinv_get_option( $args['id'], $std );
731
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
732
+    $value   = wpinv_get_option( $args['id'], $std );
733 733
 
734
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
735
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
736
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
734
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
735
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
736
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
737 737
 
738
-	echo $html;
738
+    echo $html;
739 739
 }
740 740
 
741 741
 function wpinv_missing_callback($args) {
742
-	printf(
743
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
744
-		'<strong>' . $args['id'] . '</strong>'
745
-	);
742
+    printf(
743
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
744
+        '<strong>' . $args['id'] . '</strong>'
745
+    );
746 746
 }
747 747
 
748 748
 /**
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
  */
751 751
 function wpinv_select_callback( $args ) {
752 752
 
753
-	$desc   = wp_kses_post( $args['desc'] );
754
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
755
-	$attr   = wpinv_settings_attrs_helper( $args );
756
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
757
-	$value  = wpinv_get_option( $args['id'], $value );
758
-	$rand   = uniqid( 'random_id' );
753
+    $desc   = wp_kses_post( $args['desc'] );
754
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
755
+    $attr   = wpinv_settings_attrs_helper( $args );
756
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
757
+    $value  = wpinv_get_option( $args['id'], $value );
758
+    $rand   = uniqid( 'random_id' );
759 759
 
760
-	?>
760
+    ?>
761 761
 		<label style="width: 100%;">
762 762
 			<select <?php echo $attr; ?>>
763 763
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -790,104 +790,104 @@  discard block
 block discarded – undo
790 790
 function wpinv_color_select_callback( $args ) {
791 791
     
792 792
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
793
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
794
-	$value   = wpinv_get_option( $args['id'], $std );
793
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
794
+    $value   = wpinv_get_option( $args['id'], $std );
795 795
 
796
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
796
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
797 797
 
798
-	foreach ( $args['options'] as $option => $color ) {
799
-		$selected = selected( $option, $value, false );
800
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
801
-	}
798
+    foreach ( $args['options'] as $option => $color ) {
799
+        $selected = selected( $option, $value, false );
800
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
801
+    }
802 802
 
803
-	$html .= '</select>';
804
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
803
+    $html .= '</select>';
804
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
805 805
 
806
-	echo $html;
806
+    echo $html;
807 807
 }
808 808
 
809 809
 function wpinv_rich_editor_callback( $args ) {
810
-	global $wp_version;
810
+    global $wp_version;
811 811
     
812 812
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
813 813
 
814
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
815
-	$value   = wpinv_get_option( $args['id'], $std );
814
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
815
+    $value   = wpinv_get_option( $args['id'], $std );
816 816
 	
817
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
818
-		$value = $std;
819
-	}
817
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
818
+        $value = $std;
819
+    }
820 820
 
821
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
821
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
822 822
 
823
-	$html = '<div class="getpaid-settings-editor-input">';
824
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
825
-		ob_start();
826
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
827
-		$html .= ob_get_clean();
828
-	} else {
829
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
830
-	}
823
+    $html = '<div class="getpaid-settings-editor-input">';
824
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
825
+        ob_start();
826
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
827
+        $html .= ob_get_clean();
828
+    } else {
829
+        $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
830
+    }
831 831
 
832
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
832
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
833 833
 
834
-	echo $html;
834
+    echo $html;
835 835
 }
836 836
 
837 837
 function wpinv_upload_callback( $args ) {
838 838
     
839 839
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
840 840
 
841
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
842
-	$value   = wpinv_get_option( $args['id'], $std );
841
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
842
+    $value   = wpinv_get_option( $args['id'], $std );
843 843
 
844
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
845
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
846
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
847
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
844
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
845
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
846
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
847
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
848 848
 
849
-	echo $html;
849
+    echo $html;
850 850
 }
851 851
 
852 852
 function wpinv_color_callback( $args ) {
853 853
 
854
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
855
-	$value       = wpinv_get_option( $args['id'], $std );
854
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
855
+    $value       = wpinv_get_option( $args['id'], $std );
856 856
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
857 857
 
858
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
859
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
858
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
859
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
860 860
 
861
-	echo $html;
861
+    echo $html;
862 862
 }
863 863
 
864 864
 function wpinv_country_states_callback($args) {
865 865
 
866
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
867
-	$value   = wpinv_get_option( $args['id'], $std );
866
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
867
+    $value   = wpinv_get_option( $args['id'], $std );
868 868
 
869 869
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
870 870
 
871
-	if ( isset( $args['placeholder'] ) ) {
872
-		$placeholder = $args['placeholder'];
873
-	} else {
874
-		$placeholder = '';
875
-	}
871
+    if ( isset( $args['placeholder'] ) ) {
872
+        $placeholder = $args['placeholder'];
873
+    } else {
874
+        $placeholder = '';
875
+    }
876 876
 
877
-	$states = wpinv_get_country_states();
877
+    $states = wpinv_get_country_states();
878 878
 
879
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
880
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
879
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
880
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
881 881
 
882
-	foreach ( $states as $option => $name ) {
883
-		$selected = selected( $option, $value, false );
884
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
885
-	}
882
+    foreach ( $states as $option => $name ) {
883
+        $selected = selected( $option, $value, false );
884
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
885
+    }
886 886
 
887
-	$html .= '</select>';
888
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
887
+    $html .= '</select>';
888
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
889 889
 
890
-	echo $html;
890
+    echo $html;
891 891
 }
892 892
 
893 893
 /**
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
  */
896 896
 function wpinv_tax_rates_callback() {
897 897
 	
898
-	?>
898
+    ?>
899 899
 		</td>
900 900
 	</tr>
901 901
 	<tr class="bsui">
@@ -910,17 +910,17 @@  discard block
 block discarded – undo
910 910
  * Displays a tax rate' edit row.
911 911
  */
912 912
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
913
-	ob_start();
913
+    ob_start();
914 914
 
915
-	$key                      = sanitize_key( $key );
916
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
917
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
915
+    $key                      = sanitize_key( $key );
916
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
917
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
918 918
 
919
-	if ( $echo ) {
920
-		echo ob_get_clean();
921
-	} else {
922
-		return ob_get_clean(); 
923
-	}
919
+    if ( $echo ) {
920
+        echo ob_get_clean();
921
+    } else {
922
+        return ob_get_clean(); 
923
+    }
924 924
 
925 925
 }
926 926
 
@@ -948,14 +948,14 @@  discard block
 block discarded – undo
948 948
                 </td>
949 949
                 <td>
950 950
 					<a href="<?php
951
-						echo esc_url(
952
-							wp_nonce_url(
953
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
954
-								'getpaid-nonce',
955
-								'getpaid-nonce'
956
-							)
957
-						);
958
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
951
+                        echo esc_url(
952
+                            wp_nonce_url(
953
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
954
+                                'getpaid-nonce',
955
+                                'getpaid-nonce'
956
+                            )
957
+                        );
958
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
959 959
                 </td>
960 960
             </tr>
961 961
 			<tr>
@@ -965,14 +965,14 @@  discard block
 block discarded – undo
965 965
                 </td>
966 966
                 <td>
967 967
 					<a href="<?php
968
-						echo esc_url(
969
-							wp_nonce_url(
970
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
971
-								'getpaid-nonce',
972
-								'getpaid-nonce'
973
-							)
974
-						);
975
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
968
+                        echo esc_url(
969
+                            wp_nonce_url(
970
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
971
+                                'getpaid-nonce',
972
+                                'getpaid-nonce'
973
+                            )
974
+                        );
975
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
976 976
                 </td>
977 977
             </tr>
978 978
 			<tr>
@@ -982,14 +982,14 @@  discard block
 block discarded – undo
982 982
                 </td>
983 983
                 <td>
984 984
 					<a href="<?php
985
-						echo esc_url(
986
-							wp_nonce_url(
987
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
988
-								'getpaid-nonce',
989
-								'getpaid-nonce'
990
-							)
991
-						);
992
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
985
+                        echo esc_url(
986
+                            wp_nonce_url(
987
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
988
+                                'getpaid-nonce',
989
+                                'getpaid-nonce'
990
+                            )
991
+                        );
992
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
993 993
                 </td>
994 994
             </tr>
995 995
 
@@ -1000,14 +1000,14 @@  discard block
 block discarded – undo
1000 1000
                 </td>
1001 1001
                 <td>
1002 1002
 					<a href="<?php
1003
-						echo esc_url(
1004
-							wp_nonce_url(
1005
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1006
-								'getpaid-nonce',
1007
-								'getpaid-nonce'
1008
-							)
1009
-						);
1010
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1003
+                        echo esc_url(
1004
+                            wp_nonce_url(
1005
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1006
+                                'getpaid-nonce',
1007
+                                'getpaid-nonce'
1008
+                            )
1009
+                        );
1010
+                    ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1011 1011
                 </td>
1012 1012
             </tr>
1013 1013
 
@@ -1021,19 +1021,19 @@  discard block
 block discarded – undo
1021 1021
 
1022 1022
 
1023 1023
 function wpinv_descriptive_text_callback( $args ) {
1024
-	echo wp_kses_post( $args['desc'] );
1024
+    echo wp_kses_post( $args['desc'] );
1025 1025
 }
1026 1026
 
1027 1027
 function wpinv_raw_html_callback( $args ) {
1028
-	echo $args['desc'];
1028
+    echo $args['desc'];
1029 1029
 }
1030 1030
 
1031 1031
 function wpinv_hook_callback( $args ) {
1032
-	do_action( 'wpinv_' . $args['id'], $args );
1032
+    do_action( 'wpinv_' . $args['id'], $args );
1033 1033
 }
1034 1034
 
1035 1035
 function wpinv_set_settings_cap() {
1036
-	return wpinv_get_capability();
1036
+    return wpinv_get_capability();
1037 1037
 }
1038 1038
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1039 1039
 
@@ -1057,15 +1057,15 @@  discard block
 block discarded – undo
1057 1057
  */
1058 1058
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1059 1059
 
1060
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1061
-	$link = sprintf(
1062
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1063
-		$url,
1064
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1065
-	);
1060
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1061
+    $link = sprintf(
1062
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1063
+        $url,
1064
+        esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1065
+    );
1066 1066
 
1067
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1067
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1068 1068
 
1069
-	return "$description $link";
1069
+    return "$description $link";
1070 1070
 
1071 1071
 }
Please login to merge, or discard this patch.