Passed
Push — master ( a15c21...706a80 )
by Stiofan
04:34
created
includes/gateways/class-getpaid-paypal-gateway.php 2 patches
Indentation   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -13,96 +13,96 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'paypal';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 1;
35 35
 
36 36
     /**
37
-	 * Stores line items to send to PayPal.
38
-	 *
39
-	 * @var array
40
-	 */
37
+     * Stores line items to send to PayPal.
38
+     *
39
+     * @var array
40
+     */
41 41
     protected $line_items = array();
42 42
 
43 43
     /**
44
-	 * Endpoint for requests from PayPal.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	protected $notify_url;
49
-
50
-	/**
51
-	 * Endpoint for requests to PayPal.
52
-	 *
53
-	 * @var string
54
-	 */
44
+     * Endpoint for requests from PayPal.
45
+     *
46
+     * @var string
47
+     */
48
+    protected $notify_url;
49
+
50
+    /**
51
+     * Endpoint for requests to PayPal.
52
+     *
53
+     * @var string
54
+     */
55 55
     protected $endpoint;
56 56
 
57 57
     /**
58
-	 * Currencies this gateway is allowed for.
59
-	 *
60
-	 * @var array
61
-	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
58
+     * Currencies this gateway is allowed for.
59
+     *
60
+     * @var array
61
+     */
62
+    public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
63 63
 
64 64
     /**
65
-	 * URL to view a transaction.
66
-	 *
67
-	 * @var string
68
-	 */
65
+     * URL to view a transaction.
66
+     *
67
+     * @var string
68
+     */
69 69
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
70 70
 
71 71
     /**
72
-	 * URL to view a subscription.
73
-	 *
74
-	 * @var string
75
-	 */
76
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
72
+     * URL to view a subscription.
73
+     *
74
+     * @var string
75
+     */
76
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
77 77
 
78 78
     /**
79
-	 * Class constructor.
80
-	 */
81
-	public function __construct() {
79
+     * Class constructor.
80
+     */
81
+    public function __construct() {
82 82
 
83 83
         $this->title                = __( 'PayPal Standard', 'invoicing' );
84 84
         $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85 85
         $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86 86
         $this->notify_url           = wpinv_get_ipn_url( $this->id );
87 87
 
88
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
88
+        add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89 89
         add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
90
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
91
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
90
+        add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
91
+        add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
92 92
 
93 93
         parent::__construct();
94 94
     }
95 95
 
96 96
     /**
97
-	 * Process Payment.
98
-	 *
99
-	 *
100
-	 * @param WPInv_Invoice $invoice Invoice.
101
-	 * @param array $submission_data Posted checkout fields.
102
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
103
-	 * @return array
104
-	 */
105
-	public function process_payment( $invoice, $submission_data, $submission ) {
97
+     * Process Payment.
98
+     *
99
+     *
100
+     * @param WPInv_Invoice $invoice Invoice.
101
+     * @param array $submission_data Posted checkout fields.
102
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
103
+     * @return array
104
+     */
105
+    public function process_payment( $invoice, $submission_data, $submission ) {
106 106
 
107 107
         // Get redirect url.
108 108
         $paypal_redirect = $this->get_request_url( $invoice );
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
     }
126 126
 
127 127
     /**
128
-	 * Get the PayPal request URL for an invoice.
129
-	 *
130
-	 * @param  WPInv_Invoice $invoice Invoice object.
131
-	 * @return string
132
-	 */
133
-	public function get_request_url( $invoice ) {
128
+     * Get the PayPal request URL for an invoice.
129
+     *
130
+     * @param  WPInv_Invoice $invoice Invoice object.
131
+     * @return string
132
+     */
133
+    public function get_request_url( $invoice ) {
134 134
 
135 135
         // Endpoint for this request
136
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
136
+        $this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
137 137
 
138 138
         // Retrieve paypal args.
139 139
         $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
@@ -146,44 +146,44 @@  discard block
 block discarded – undo
146 146
 
147 147
         return add_query_arg( $paypal_args, $this->endpoint );
148 148
 
149
-	}
149
+    }
150 150
 
151 151
     /**
152
-	 * Get PayPal Args for passing to PP.
153
-	 *
154
-	 * @param  WPInv_Invoice $invoice Invoice object.
155
-	 * @return array
156
-	 */
157
-	protected function get_paypal_args( $invoice ) {
152
+     * Get PayPal Args for passing to PP.
153
+     *
154
+     * @param  WPInv_Invoice $invoice Invoice object.
155
+     * @return array
156
+     */
157
+    protected function get_paypal_args( $invoice ) {
158 158
 
159 159
         // Whether or not to send the line items as one item.
160
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
160
+        $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
161 161
 
162
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
163
-			$force_one_line_item = true;
164
-		}
162
+        if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
163
+            $force_one_line_item = true;
164
+        }
165 165
 
166
-		$paypal_args = apply_filters(
167
-			'getpaid_paypal_args',
168
-			array_merge(
169
-				$this->get_transaction_args( $invoice ),
170
-				$this->get_line_item_args( $invoice, $force_one_line_item )
171
-			),
172
-			$invoice
173
-		);
166
+        $paypal_args = apply_filters(
167
+            'getpaid_paypal_args',
168
+            array_merge(
169
+                $this->get_transaction_args( $invoice ),
170
+                $this->get_line_item_args( $invoice, $force_one_line_item )
171
+            ),
172
+            $invoice
173
+        );
174 174
 
175
-		return $this->fix_request_length( $invoice, $paypal_args );
175
+        return $this->fix_request_length( $invoice, $paypal_args );
176 176
     }
177 177
 
178 178
     /**
179
-	 * Get transaction args for paypal request.
180
-	 *
181
-	 * @param WPInv_Invoice $invoice Invoice object.
182
-	 * @return array
183
-	 */
184
-	protected function get_transaction_args( $invoice ) {
185
-
186
-		return array(
179
+     * Get transaction args for paypal request.
180
+     *
181
+     * @param WPInv_Invoice $invoice Invoice object.
182
+     * @return array
183
+     */
184
+    protected function get_transaction_args( $invoice ) {
185
+
186
+        return array(
187 187
             'cmd'           => '_cart',
188 188
             'business'      => wpinv_get_option( 'paypal_email', false ),
189 189
             'no_shipping'   => '1',
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
     }
209 209
 
210 210
     /**
211
-	 * Get line item args for paypal request.
212
-	 *
213
-	 * @param  WPInv_Invoice $invoice Invoice object.
214
-	 * @param  bool     $force_one_line_item Create only one item for this invoice.
215
-	 * @return array
216
-	 */
217
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
211
+     * Get line item args for paypal request.
212
+     *
213
+     * @param  WPInv_Invoice $invoice Invoice object.
214
+     * @param  bool     $force_one_line_item Create only one item for this invoice.
215
+     * @return array
216
+     */
217
+    protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
218 218
 
219 219
         // Maybe send invoice as a single item.
220
-		if ( $force_one_line_item ) {
220
+        if ( $force_one_line_item ) {
221 221
             return $this->get_line_item_args_single_item( $invoice );
222 222
         }
223 223
 
@@ -237,129 +237,129 @@  discard block
 block discarded – undo
237 237
             $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
238 238
         }
239 239
 
240
-		return array_merge( $line_item_args, $this->get_line_items() );
240
+        return array_merge( $line_item_args, $this->get_line_items() );
241 241
 
242 242
     }
243 243
 
244 244
     /**
245
-	 * Get line item args for paypal request as a single line item.
246
-	 *
247
-	 * @param  WPInv_Invoice $invoice Invoice object.
248
-	 * @return array
249
-	 */
250
-	protected function get_line_item_args_single_item( $invoice ) {
251
-		$this->delete_line_items();
245
+     * Get line item args for paypal request as a single line item.
246
+     *
247
+     * @param  WPInv_Invoice $invoice Invoice object.
248
+     * @return array
249
+     */
250
+    protected function get_line_item_args_single_item( $invoice ) {
251
+        $this->delete_line_items();
252 252
 
253 253
         $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
254
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
254
+        $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
255 255
 
256
-		return $this->get_line_items();
256
+        return $this->get_line_items();
257 257
     }
258 258
 
259 259
     /**
260
-	 * Return all line items.
261
-	 */
262
-	protected function get_line_items() {
263
-		return $this->line_items;
264
-	}
260
+     * Return all line items.
261
+     */
262
+    protected function get_line_items() {
263
+        return $this->line_items;
264
+    }
265 265
 
266 266
     /**
267
-	 * Remove all line items.
268
-	 */
269
-	protected function delete_line_items() {
270
-		$this->line_items = array();
267
+     * Remove all line items.
268
+     */
269
+    protected function delete_line_items() {
270
+        $this->line_items = array();
271 271
     }
272 272
 
273 273
     /**
274
-	 * Prepare line items to send to paypal.
275
-	 *
276
-	 * @param  WPInv_Invoice $invoice Invoice object.
277
-	 */
278
-	protected function prepare_line_items( $invoice ) {
279
-		$this->delete_line_items();
280
-
281
-		// Items.
282
-		foreach ( $invoice->get_items() as $item ) {
283
-			$amount   = $item->get_price();
284
-			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
285
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
274
+     * Prepare line items to send to paypal.
275
+     *
276
+     * @param  WPInv_Invoice $invoice Invoice object.
277
+     */
278
+    protected function prepare_line_items( $invoice ) {
279
+        $this->delete_line_items();
280
+
281
+        // Items.
282
+        foreach ( $invoice->get_items() as $item ) {
283
+            $amount   = $item->get_price();
284
+            $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
285
+            $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
286 286
         }
287 287
 
288 288
         // Fees.
289
-		foreach ( $invoice->get_fees() as $fee => $data ) {
289
+        foreach ( $invoice->get_fees() as $fee => $data ) {
290 290
             $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
291 291
         }
292 292
 
293 293
     }
294 294
 
295 295
     /**
296
-	 * Add PayPal Line Item.
297
-	 *
298
-	 * @param  string $item_name Item name.
299
-	 * @param  float    $quantity Item quantity.
300
-	 * @param  float  $amount Amount.
301
-	 * @param  string $item_number Item number.
302
-	 */
303
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
304
-		$index = ( count( $this->line_items ) / 4 ) + 1;
305
-
306
-		$item = apply_filters(
307
-			'getpaid_paypal_line_item',
308
-			array(
309
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
310
-				'quantity'    => (float) $quantity,
311
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
312
-				'item_number' => $item_number,
313
-			),
314
-			$item_name,
315
-			$quantity,
316
-			$amount,
317
-			$item_number
318
-		);
296
+     * Add PayPal Line Item.
297
+     *
298
+     * @param  string $item_name Item name.
299
+     * @param  float    $quantity Item quantity.
300
+     * @param  float  $amount Amount.
301
+     * @param  string $item_number Item number.
302
+     */
303
+    protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
304
+        $index = ( count( $this->line_items ) / 4 ) + 1;
319 305
 
320
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
306
+        $item = apply_filters(
307
+            'getpaid_paypal_line_item',
308
+            array(
309
+                'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
310
+                'quantity'    => (float) $quantity,
311
+                'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
312
+                'item_number' => $item_number,
313
+            ),
314
+            $item_name,
315
+            $quantity,
316
+            $amount,
317
+            $item_number
318
+        );
319
+
320
+        $this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
321 321
         $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
322 322
 
323 323
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
324
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
325
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
324
+        $this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
325
+        $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
326 326
     }
327 327
 
328 328
     /**
329
-	 * If the default request with line items is too long, generate a new one with only one line item.
330
-	 *
331
-	 * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
332
-	 *
333
-	 * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
334
-	 * @param array    $paypal_args Arguments sent to Paypal in the request.
335
-	 * @return array
336
-	 */
337
-	protected function fix_request_length( $invoice, $paypal_args ) {
338
-		$max_paypal_length = 2083;
339
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
340
-
341
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
342
-			return $paypal_args;
343
-		}
344
-
345
-		return apply_filters(
346
-			'getpaid_paypal_args',
347
-			array_merge(
348
-				$this->get_transaction_args( $invoice ),
349
-				$this->get_line_item_args( $invoice, true )
350
-			),
351
-			$invoice
352
-		);
329
+     * If the default request with line items is too long, generate a new one with only one line item.
330
+     *
331
+     * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
332
+     *
333
+     * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
334
+     * @param array    $paypal_args Arguments sent to Paypal in the request.
335
+     * @return array
336
+     */
337
+    protected function fix_request_length( $invoice, $paypal_args ) {
338
+        $max_paypal_length = 2083;
339
+        $query_candidate   = http_build_query( $paypal_args, '', '&' );
340
+
341
+        if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
342
+            return $paypal_args;
343
+        }
344
+
345
+        return apply_filters(
346
+            'getpaid_paypal_args',
347
+            array_merge(
348
+                $this->get_transaction_args( $invoice ),
349
+                $this->get_line_item_args( $invoice, true )
350
+            ),
351
+            $invoice
352
+        );
353 353
 
354 354
     }
355 355
 
356 356
     /**
357
-	 * Processes recurring invoices.
358
-	 *
359
-	 * @param  array $paypal_args PayPal args.
360
-	 * @param  WPInv_Invoice    $invoice Invoice object.
361
-	 */
362
-	public function process_subscription( $paypal_args, $invoice ) {
357
+     * Processes recurring invoices.
358
+     *
359
+     * @param  array $paypal_args PayPal args.
360
+     * @param  WPInv_Invoice    $invoice Invoice object.
361
+     */
362
+    public function process_subscription( $paypal_args, $invoice ) {
363 363
 
364 364
         // Make sure this is a subscription.
365 365
         if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 
385 385
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
386 386
 
387
-			// Trial period length.
388
-			$paypal_args['p1'] = $subscription_item->get_trial_interval();
387
+            // Trial period length.
388
+            $paypal_args['p1'] = $subscription_item->get_trial_interval();
389 389
 
390
-			// Trial period.
391
-			$paypal_args['t1'] = $subscription_item->get_trial_period();
390
+            // Trial period.
391
+            $paypal_args['t1'] = $subscription_item->get_trial_period();
392 392
 
393 393
         } else if ( $initial_amount != $recurring_amount ) {
394 394
 
@@ -411,40 +411,40 @@  discard block
 block discarded – undo
411 411
         }
412 412
 
413 413
         // We have a recurring payment
414
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
414
+        if ( ! isset( $param_number ) || 1 == $param_number ) {
415 415
 
416
-			// Subscription price
417
-			$paypal_args['a3'] = $recurring_amount;
416
+            // Subscription price
417
+            $paypal_args['a3'] = $recurring_amount;
418 418
 
419
-			// Subscription duration
420
-			$paypal_args['p3'] = $interval;
419
+            // Subscription duration
420
+            $paypal_args['p3'] = $interval;
421 421
 
422
-			// Subscription period
423
-			$paypal_args['t3'] = $period;
422
+            // Subscription period
423
+            $paypal_args['t3'] = $period;
424 424
 
425 425
         }
426 426
 
427 427
         // Recurring payments
428
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
428
+        if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
429 429
 
430
-			// Non-recurring payments
431
-			$paypal_args['src'] = 0;
430
+            // Non-recurring payments
431
+            $paypal_args['src'] = 0;
432 432
 
433
-		} else {
433
+        } else {
434 434
 
435
-			$paypal_args['src'] = 1;
435
+            $paypal_args['src'] = 1;
436 436
 
437
-			if ( $bill_times > 0 ) {
437
+            if ( $bill_times > 0 ) {
438 438
 
439
-				// An initial period is being used to charge a sign-up fee
440
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
441
-					$bill_times--;
442
-				}
439
+                // An initial period is being used to charge a sign-up fee
440
+                if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
441
+                    $bill_times--;
442
+                }
443 443
 
444 444
                 // Make sure it's not over the max of 52
445 445
                 $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
446 446
 
447
-			}
447
+            }
448 448
         }
449 449
 
450 450
         // Force return URL so that order description & instructions display
@@ -460,19 +460,19 @@  discard block
 block discarded – undo
460 460
         }
461 461
 
462 462
         return apply_filters(
463
-			'getpaid_paypal_subscription_args',
464
-			$paypal_args,
465
-			$invoice
463
+            'getpaid_paypal_subscription_args',
464
+            $paypal_args,
465
+            $invoice
466 466
         );
467 467
 
468 468
     }
469 469
 
470 470
     /**
471
-	 * Processes ipns and marks payments as complete.
472
-	 *
473
-	 * @return void
474
-	 */
475
-	public function verify_ipn() {
471
+     * Processes ipns and marks payments as complete.
472
+     *
473
+     * @return void
474
+     */
475
+    public function verify_ipn() {
476 476
         new GetPaid_Paypal_Gateway_IPN_Handler( $this );
477 477
     }
478 478
 
@@ -482,19 +482,19 @@  discard block
 block discarded – undo
482 482
     public function sandbox_notice() {
483 483
 
484 484
         return sprintf(
485
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
486
-			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
487
-			'</a>'
488
-		);
485
+            __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
486
+            '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
487
+            '</a>'
488
+        );
489 489
 
490 490
     }
491 491
 
492
-	/**
493
-	 * Filters the gateway settings.
494
-	 *
495
-	 * @param array $admin_settings
496
-	 */
497
-	public function admin_settings( $admin_settings ) {
492
+    /**
493
+     * Filters the gateway settings.
494
+     *
495
+     * @param array $admin_settings
496
+     */
497
+    public function admin_settings( $admin_settings ) {
498 498
 
499 499
         $currencies = sprintf(
500 500
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 
504 504
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
505 505
         $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
506
-		/*
506
+        /*
507 507
 		// Access tokens.
508 508
         $live_account    = wpinv_get_option( 'paypal_live_access_token' );
509 509
         $sandbox_account = wpinv_get_option( 'paypal_test_access_token' );
@@ -534,12 +534,12 @@  discard block
 block discarded – undo
534 534
 		*/
535 535
         $admin_settings['paypal_email'] = array(
536 536
             'type'  => 'text',
537
-			'class' => 'live-auth-data',
537
+            'class' => 'live-auth-data',
538 538
             'id'    => 'paypal_email',
539 539
             'name'  => __( 'Live Email Address', 'invoicing' ),
540 540
             'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
541 541
         );
542
-		/*
542
+        /*
543 543
 		$admin_settings['paypal_merchant_id'] = array(
544 544
             'type'  => 'text',
545 545
 			'class' => 'live-auth-data',
@@ -600,29 +600,29 @@  discard block
 block discarded – undo
600 600
             'readonly' => true,
601 601
         );
602 602
 
603
-		return $admin_settings;
604
-	}
603
+        return $admin_settings;
604
+    }
605 605
 
606
-	/**
607
-	 * Retrieves the PayPal connect URL when using the setup wizzard.
608
-	 *
609
-	 *
606
+    /**
607
+     * Retrieves the PayPal connect URL when using the setup wizzard.
608
+     *
609
+     *
610 610
      * @param array $data
611 611
      * @return string
612
-	 */
613
-	public static function maybe_get_connect_url( $url = '', $data ) {
614
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
615
-	}
616
-
617
-	/**
618
-	 * Retrieves the PayPal connect URL.
619
-	 *
620
-	 *
612
+     */
613
+    public static function maybe_get_connect_url( $url = '', $data ) {
614
+        return self::get_connect_url( false, urldecode( $data['redirect'] ) );
615
+    }
616
+
617
+    /**
618
+     * Retrieves the PayPal connect URL.
619
+     *
620
+     *
621 621
      * @param bool $is_sandbox
622
-	 * @param string $redirect
622
+     * @param string $redirect
623 623
      * @return string
624
-	 */
625
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
624
+     */
625
+    public static function get_connect_url( $is_sandbox, $redirect = '' ) {
626 626
 
627 627
         $redirect_url = add_query_arg(
628 628
             array(
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
                 'tab'                  => 'gateways',
633 633
                 'section'              => 'paypal',
634 634
                 'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
635
-				'redirect'             => urlencode( $redirect ),
635
+                'redirect'             => urlencode( $redirect ),
636 636
             ),
637 637
             admin_url( 'admin.php' )
638 638
         );
@@ -647,12 +647,12 @@  discard block
 block discarded – undo
647 647
 
648 648
     }
649 649
 
650
-	/**
651
-	 * Generates settings page js.
652
-	 *
650
+    /**
651
+     * Generates settings page js.
652
+     *
653 653
      * @return void
654
-	 */
655
-	public static function get_js() { return '';
654
+     */
655
+    public static function get_js() { return '';
656 656
         ob_start();
657 657
         ?>
658 658
             <script>
@@ -698,109 +698,109 @@  discard block
 block discarded – undo
698 698
         return ob_get_clean();
699 699
     }
700 700
 
701
-	/**
702
-	 * Connects to PayPal.
703
-	 *
704
-	 * @param array $data Connection data.
705
-	 * @return void
706
-	 */
707
-	public function connect_paypal( $data ) {
708
-
709
-		$sandbox      = $this->is_sandbox();
710
-		$data         = wp_unslash( $data );
711
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
712
-
713
-		if ( isset( $data['live_mode'] ) ) {
714
-			$sandbox = empty( $data['live_mode'] );
715
-		}
716
-
717
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
718
-		wpinv_update_option( 'paypal_active', 1 );
719
-
720
-		if ( ! empty( $data['error_description'] ) ) {
721
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
722
-		} else {
723
-
724
-			// Retrieve the user info.
725
-			$user_info = wp_remote_get(
726
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
727
-				array(
728
-
729
-					'headers' => array(
730
-						'Authorization' => 'Bearer ' . $access_token,
731
-						'Content-type'  => 'application/json',
732
-					)
733
-
734
-				)
735
-			);
736
-
737
-			if ( is_wp_error( $user_info ) ) {
738
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
739
-			} else {
740
-
741
-				// Create application.
742
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
743
-				$app       = wp_remote_post(
744
-					! $sandbox ? 'https://api-m.paypal.com/v1/identity/applications' : 'https://api-m.sandbox.paypal.com/v1/identity/applications',
745
-					array(
746
-
747
-						'body'    => array(
748
-							'application_type' => 'web',
749
-							'redirect_uris'    => array(
750
-								add_query_arg( 'getpaid_oauth', 'paypal', home_url() ),
751
-							),
752
-							'client_name'      => 'GetPaid',
753
-							'contacts'         => array( $user_info->emails[0]->value ),
754
-							'payer_id'         => $user_info->payer_id,
755
-							'migrated_app'     => '',
756
-						),
757
-						'headers' => array(
758
-							'Authorization' => 'Bearer ' . $access_token,
759
-							'Content-type'  => 'application/json',
760
-						)
761
-
762
-					)
763
-				);
764
-
765
-				if ( is_wp_error( $app ) ) {
766
-					getpaid_admin()->show_error( wp_kses_post( $app->get_error_message() ) );
767
-				} else {
768
-
769
-					$app = json_decode( wp_remote_retrieve_body( $app ) );
770
-					wpinv_error_log( $app );
771
-					if ( $sandbox ) {
772
-						wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
773
-						wpinv_update_option( 'paypal_sandbox_merchant_id', '' );
774
-						wpinv_update_option( 'paypal_sandbox_client_id', sanitize_text_field( '' ) );
775
-						wpinv_update_option( 'paypal_sandbox_client_secret', sanitize_text_field( '' ) );
776
-						wpinv_update_option( 'paypal_sandbox_client_secret_expires_at', sanitize_text_field( '' ) );
777
-						wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
778
-						set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
779
-						getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
780
-					} else {
781
-						wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
782
-						wpinv_update_option( 'paypal_merchant_id', '' );
783
-						wpinv_update_option( 'paypal_client_id', sanitize_text_field( '' ) );
784
-						wpinv_update_option( 'paypal_client_secret', sanitize_text_field( '' ) );
785
-						wpinv_update_option( 'paypal_client_secret_expires_at', sanitize_text_field( '' ) );
786
-						wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
787
-						set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
788
-						getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
789
-					}
701
+    /**
702
+     * Connects to PayPal.
703
+     *
704
+     * @param array $data Connection data.
705
+     * @return void
706
+     */
707
+    public function connect_paypal( $data ) {
790 708
 
791
-				}
709
+        $sandbox      = $this->is_sandbox();
710
+        $data         = wp_unslash( $data );
711
+        $access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
792 712
 
793
-			}
713
+        if ( isset( $data['live_mode'] ) ) {
714
+            $sandbox = empty( $data['live_mode'] );
715
+        }
794 716
 
795
-		}
717
+        wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
718
+        wpinv_update_option( 'paypal_active', 1 );
796 719
 
797
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
720
+        if ( ! empty( $data['error_description'] ) ) {
721
+            getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
722
+        } else {
723
+
724
+            // Retrieve the user info.
725
+            $user_info = wp_remote_get(
726
+                ! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
727
+                array(
728
+
729
+                    'headers' => array(
730
+                        'Authorization' => 'Bearer ' . $access_token,
731
+                        'Content-type'  => 'application/json',
732
+                    )
798 733
 
799
-		if ( isset( $data['step'] ) ) {
800
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
801
-		}
802
-		wp_redirect( $redirect );
803
-		exit;
804
-	}
734
+                )
735
+            );
736
+
737
+            if ( is_wp_error( $user_info ) ) {
738
+                getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
739
+            } else {
740
+
741
+                // Create application.
742
+                $user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
743
+                $app       = wp_remote_post(
744
+                    ! $sandbox ? 'https://api-m.paypal.com/v1/identity/applications' : 'https://api-m.sandbox.paypal.com/v1/identity/applications',
745
+                    array(
746
+
747
+                        'body'    => array(
748
+                            'application_type' => 'web',
749
+                            'redirect_uris'    => array(
750
+                                add_query_arg( 'getpaid_oauth', 'paypal', home_url() ),
751
+                            ),
752
+                            'client_name'      => 'GetPaid',
753
+                            'contacts'         => array( $user_info->emails[0]->value ),
754
+                            'payer_id'         => $user_info->payer_id,
755
+                            'migrated_app'     => '',
756
+                        ),
757
+                        'headers' => array(
758
+                            'Authorization' => 'Bearer ' . $access_token,
759
+                            'Content-type'  => 'application/json',
760
+                        )
761
+
762
+                    )
763
+                );
764
+
765
+                if ( is_wp_error( $app ) ) {
766
+                    getpaid_admin()->show_error( wp_kses_post( $app->get_error_message() ) );
767
+                } else {
768
+
769
+                    $app = json_decode( wp_remote_retrieve_body( $app ) );
770
+                    wpinv_error_log( $app );
771
+                    if ( $sandbox ) {
772
+                        wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
773
+                        wpinv_update_option( 'paypal_sandbox_merchant_id', '' );
774
+                        wpinv_update_option( 'paypal_sandbox_client_id', sanitize_text_field( '' ) );
775
+                        wpinv_update_option( 'paypal_sandbox_client_secret', sanitize_text_field( '' ) );
776
+                        wpinv_update_option( 'paypal_sandbox_client_secret_expires_at', sanitize_text_field( '' ) );
777
+                        wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
778
+                        set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
779
+                        getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
780
+                    } else {
781
+                        wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
782
+                        wpinv_update_option( 'paypal_merchant_id', '' );
783
+                        wpinv_update_option( 'paypal_client_id', sanitize_text_field( '' ) );
784
+                        wpinv_update_option( 'paypal_client_secret', sanitize_text_field( '' ) );
785
+                        wpinv_update_option( 'paypal_client_secret_expires_at', sanitize_text_field( '' ) );
786
+                        wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
787
+                        set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
788
+                        getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
789
+                    }
790
+
791
+                }
792
+
793
+            }
794
+
795
+        }
796
+
797
+        $redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
798
+
799
+        if ( isset( $data['step'] ) ) {
800
+            $redirect = add_query_arg( 'step', $data['step'], $redirect );
801
+        }
802
+        wp_redirect( $redirect );
803
+        exit;
804
+    }
805 805
 
806 806
 }
Please login to merge, or discard this patch.
Spacing   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' );
27
+    protected $supports = array('subscription', 'sandbox', 'single_subscription_group');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function __construct() {
82 82
 
83
-        $this->title                = __( 'PayPal Standard', 'invoicing' );
84
-        $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85
-        $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
83
+        $this->title                = __('PayPal Standard', 'invoicing');
84
+        $this->method_title         = __('PayPal Standard', 'invoicing');
85
+        $this->checkout_button_text = __('Proceed to PayPal', 'invoicing');
86
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
87 87
 
88
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89
-        add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
90
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
91
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
88
+		add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
89
+        add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice'));
90
+		add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2);
91
+		add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal'));
92 92
 
93 93
         parent::__construct();
94 94
     }
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
103 103
 	 * @return array
104 104
 	 */
105
-	public function process_payment( $invoice, $submission_data, $submission ) {
105
+	public function process_payment($invoice, $submission_data, $submission) {
106 106
 
107 107
         // Get redirect url.
108
-        $paypal_redirect = $this->get_request_url( $invoice );
108
+        $paypal_redirect = $this->get_request_url($invoice);
109 109
 
110 110
         // Add a note about the request url.
111 111
         $invoice->add_note(
112 112
             sprintf(
113
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
114
-                esc_url( $paypal_redirect )
113
+                __('Redirecting to PayPal: %s', 'invoicing'),
114
+                esc_url($paypal_redirect)
115 115
             ),
116 116
             false,
117 117
             false,
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         );
120 120
 
121 121
         // Redirect to PayPal
122
-        wp_redirect( $paypal_redirect );
122
+        wp_redirect($paypal_redirect);
123 123
         exit;
124 124
 
125 125
     }
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
 	 * @param  WPInv_Invoice $invoice Invoice object.
131 131
 	 * @return string
132 132
 	 */
133
-	public function get_request_url( $invoice ) {
133
+	public function get_request_url($invoice) {
134 134
 
135 135
         // Endpoint for this request
136
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
136
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
137 137
 
138 138
         // Retrieve paypal args.
139
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
139
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
140 140
 
141
-        if ( $invoice->is_recurring() ) {
141
+        if ($invoice->is_recurring()) {
142 142
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
143 143
         } else {
144 144
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
145 145
         }
146 146
 
147
-        return add_query_arg( $paypal_args, $this->endpoint );
147
+        return add_query_arg($paypal_args, $this->endpoint);
148 148
 
149 149
 	}
150 150
 
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
 	 * @param  WPInv_Invoice $invoice Invoice object.
155 155
 	 * @return array
156 156
 	 */
157
-	protected function get_paypal_args( $invoice ) {
157
+	protected function get_paypal_args($invoice) {
158 158
 
159 159
         // Whether or not to send the line items as one item.
160
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
160
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice);
161 161
 
162
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
162
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
163 163
 			$force_one_line_item = true;
164 164
 		}
165 165
 
166 166
 		$paypal_args = apply_filters(
167 167
 			'getpaid_paypal_args',
168 168
 			array_merge(
169
-				$this->get_transaction_args( $invoice ),
170
-				$this->get_line_item_args( $invoice, $force_one_line_item )
169
+				$this->get_transaction_args($invoice),
170
+				$this->get_line_item_args($invoice, $force_one_line_item)
171 171
 			),
172 172
 			$invoice
173 173
 		);
174 174
 
175
-		return $this->fix_request_length( $invoice, $paypal_args );
175
+		return $this->fix_request_length($invoice, $paypal_args);
176 176
     }
177 177
 
178 178
     /**
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 	 * @param WPInv_Invoice $invoice Invoice object.
182 182
 	 * @return array
183 183
 	 */
184
-	protected function get_transaction_args( $invoice ) {
184
+	protected function get_transaction_args($invoice) {
185 185
 
186 186
 		return array(
187 187
             'cmd'           => '_cart',
188
-            'business'      => wpinv_get_option( 'paypal_email', false ),
188
+            'business'      => wpinv_get_option('paypal_email', false),
189 189
             'no_shipping'   => '1',
190 190
             'shipping'      => '0',
191 191
             'no_note'       => '1',
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
             'rm'            => is_ssl() ? 2 : 1,
194 194
             'upload'        => 1,
195 195
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
196
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
197
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
198
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
199
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
196
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
197
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
198
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
199
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
200 200
             'custom'        => $invoice->get_id(),
201
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
202
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
203
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
204
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
205
-            'cbt'           => get_bloginfo( 'name' )
201
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
202
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
203
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
204
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
205
+            'cbt'           => get_bloginfo('name')
206 206
         );
207 207
 
208 208
     }
@@ -214,30 +214,30 @@  discard block
 block discarded – undo
214 214
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
215 215
 	 * @return array
216 216
 	 */
217
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
217
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
218 218
 
219 219
         // Maybe send invoice as a single item.
220
-		if ( $force_one_line_item ) {
221
-            return $this->get_line_item_args_single_item( $invoice );
220
+		if ($force_one_line_item) {
221
+            return $this->get_line_item_args_single_item($invoice);
222 222
         }
223 223
 
224 224
         // Send each line item individually.
225 225
         $line_item_args = array();
226 226
 
227 227
         // Prepare line items.
228
-        $this->prepare_line_items( $invoice );
228
+        $this->prepare_line_items($invoice);
229 229
 
230 230
         // Add taxes to the cart
231
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
232
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
231
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
232
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
233 233
         }
234 234
 
235 235
         // Add discount.
236
-        if ( $invoice->get_total_discount() > 0 ) {
237
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
236
+        if ($invoice->get_total_discount() > 0) {
237
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
238 238
         }
239 239
 
240
-		return array_merge( $line_item_args, $this->get_line_items() );
240
+		return array_merge($line_item_args, $this->get_line_items());
241 241
 
242 242
     }
243 243
 
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 	 * @param  WPInv_Invoice $invoice Invoice object.
248 248
 	 * @return array
249 249
 	 */
250
-	protected function get_line_item_args_single_item( $invoice ) {
250
+	protected function get_line_item_args_single_item($invoice) {
251 251
 		$this->delete_line_items();
252 252
 
253
-        $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
254
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
253
+        $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
254
+		$this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id());
255 255
 
256 256
 		return $this->get_line_items();
257 257
     }
@@ -275,19 +275,19 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @param  WPInv_Invoice $invoice Invoice object.
277 277
 	 */
278
-	protected function prepare_line_items( $invoice ) {
278
+	protected function prepare_line_items($invoice) {
279 279
 		$this->delete_line_items();
280 280
 
281 281
 		// Items.
282
-		foreach ( $invoice->get_items() as $item ) {
282
+		foreach ($invoice->get_items() as $item) {
283 283
 			$amount   = $item->get_price();
284 284
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
285
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
285
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
286 286
         }
287 287
 
288 288
         // Fees.
289
-		foreach ( $invoice->get_fees() as $fee => $data ) {
290
-            $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
289
+		foreach ($invoice->get_fees() as $fee => $data) {
290
+            $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee']));
291 291
         }
292 292
 
293 293
     }
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
 	 * @param  float  $amount Amount.
301 301
 	 * @param  string $item_number Item number.
302 302
 	 */
303
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
304
-		$index = ( count( $this->line_items ) / 4 ) + 1;
303
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
304
+		$index = (count($this->line_items) / 4) + 1;
305 305
 
306 306
 		$item = apply_filters(
307 307
 			'getpaid_paypal_line_item',
308 308
 			array(
309
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
309
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
310 310
 				'quantity'    => (float) $quantity,
311
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
311
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
312 312
 				'item_number' => $item_number,
313 313
 			),
314 314
 			$item_name,
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 			$item_number
318 318
 		);
319 319
 
320
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
321
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
320
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
321
+        $this->line_items['quantity_' . $index] = $item['quantity'];
322 322
 
323 323
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
324
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
325
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
324
+		$this->line_items['amount_' . $index]      = $item['amount'] * $item['quantity'];
325
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
326 326
     }
327 327
 
328 328
     /**
@@ -334,19 +334,19 @@  discard block
 block discarded – undo
334 334
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
335 335
 	 * @return array
336 336
 	 */
337
-	protected function fix_request_length( $invoice, $paypal_args ) {
337
+	protected function fix_request_length($invoice, $paypal_args) {
338 338
 		$max_paypal_length = 2083;
339
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
339
+		$query_candidate   = http_build_query($paypal_args, '', '&');
340 340
 
341
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
341
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
342 342
 			return $paypal_args;
343 343
 		}
344 344
 
345 345
 		return apply_filters(
346 346
 			'getpaid_paypal_args',
347 347
 			array_merge(
348
-				$this->get_transaction_args( $invoice ),
349
-				$this->get_line_item_args( $invoice, true )
348
+				$this->get_transaction_args($invoice),
349
+				$this->get_line_item_args($invoice, true)
350 350
 			),
351 351
 			$invoice
352 352
 		);
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
 	 * @param  array $paypal_args PayPal args.
360 360
 	 * @param  WPInv_Invoice    $invoice Invoice object.
361 361
 	 */
362
-	public function process_subscription( $paypal_args, $invoice ) {
362
+	public function process_subscription($paypal_args, $invoice) {
363 363
 
364 364
         // Make sure this is a subscription.
365
-        if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
365
+        if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) {
366 366
             return $paypal_args;
367 367
         }
368 368
 
@@ -370,17 +370,17 @@  discard block
 block discarded – undo
370 370
         $paypal_args['cmd'] = '_xclick-subscriptions';
371 371
 
372 372
         // Subscription name.
373
-        $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
373
+        $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
374 374
 
375 375
         // Get subscription args.
376
-        $period                 = strtoupper( substr( $subscription->get_period(), 0, 1) );
376
+        $period                 = strtoupper(substr($subscription->get_period(), 0, 1));
377 377
         $interval               = (int) $subscription->get_frequency();
378 378
         $bill_times             = (int) $subscription->get_bill_times();
379
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
380
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
381
-        $subscription_item      = $invoice->get_recurring( true );
379
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
380
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
381
+        $subscription_item      = $invoice->get_recurring(true);
382 382
 
383
-        if ( $subscription_item->has_free_trial() ) {
383
+        if ($subscription_item->has_free_trial()) {
384 384
 
385 385
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
386 386
 
@@ -390,28 +390,28 @@  discard block
 block discarded – undo
390 390
 			// Trial period.
391 391
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
392 392
 
393
-        } else if ( $initial_amount != $recurring_amount ) {
393
+        } else if ($initial_amount != $recurring_amount) {
394 394
 
395 395
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
396 396
 
397
-            if ( 1 == $bill_times ) {
397
+            if (1 == $bill_times) {
398 398
                 $param_number = 3;
399 399
             } else {
400 400
                 $param_number = 1;
401 401
             }
402 402
 
403
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0;
403
+            $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0;
404 404
 
405 405
             // Sign Up interval
406
-            $paypal_args[ 'p' . $param_number ] = $interval;
406
+            $paypal_args['p' . $param_number] = $interval;
407 407
 
408 408
             // Sign Up unit of duration
409
-            $paypal_args[ 't' . $param_number ] = $period;
409
+            $paypal_args['t' . $param_number] = $period;
410 410
 
411 411
         }
412 412
 
413 413
         // We have a recurring payment
414
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
414
+		if (!isset($param_number) || 1 == $param_number) {
415 415
 
416 416
 			// Subscription price
417 417
 			$paypal_args['a3'] = $recurring_amount;
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
         }
426 426
 
427 427
         // Recurring payments
428
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
428
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
429 429
 
430 430
 			// Non-recurring payments
431 431
 			$paypal_args['src'] = 0;
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
 
435 435
 			$paypal_args['src'] = 1;
436 436
 
437
-			if ( $bill_times > 0 ) {
437
+			if ($bill_times > 0) {
438 438
 
439 439
 				// An initial period is being used to charge a sign-up fee
440
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
440
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
441 441
 					$bill_times--;
442 442
 				}
443 443
 
444 444
                 // Make sure it's not over the max of 52
445
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
445
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
446 446
 
447 447
 			}
448 448
         }
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
         $paypal_args['rm'] = 2;
452 452
 
453 453
         // Get rid of redudant items.
454
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
454
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
455 455
 
456
-            if ( isset( $paypal_args[ $arg ] ) ) {
457
-                unset( $paypal_args[ $arg ] );
456
+            if (isset($paypal_args[$arg])) {
457
+                unset($paypal_args[$arg]);
458 458
             }
459 459
 
460 460
         }
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	 * @return void
474 474
 	 */
475 475
 	public function verify_ipn() {
476
-        new GetPaid_Paypal_Gateway_IPN_Handler( $this );
476
+        new GetPaid_Paypal_Gateway_IPN_Handler($this);
477 477
     }
478 478
 
479 479
     /**
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     public function sandbox_notice() {
483 483
 
484 484
         return sprintf(
485
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
485
+			__('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'),
486 486
 			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
487 487
 			'</a>'
488 488
 		);
@@ -494,15 +494,15 @@  discard block
 block discarded – undo
494 494
 	 *
495 495
 	 * @param array $admin_settings
496 496
 	 */
497
-	public function admin_settings( $admin_settings ) {
497
+	public function admin_settings($admin_settings) {
498 498
 
499 499
         $currencies = sprintf(
500
-            __( 'Supported Currencies: %s', 'invoicing' ),
501
-            implode( ', ', $this->currencies )
500
+            __('Supported Currencies: %s', 'invoicing'),
501
+            implode(', ', $this->currencies)
502 502
         );
503 503
 
504 504
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
505
-        $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
505
+        $admin_settings['paypal_desc']['std']     = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
506 506
 		/*
507 507
 		// Access tokens.
508 508
         $live_account    = wpinv_get_option( 'paypal_live_access_token' );
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
             'type'  => 'text',
537 537
 			'class' => 'live-auth-data',
538 538
             'id'    => 'paypal_email',
539
-            'name'  => __( 'Live Email Address', 'invoicing' ),
540
-            'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
539
+            'name'  => __('Live Email Address', 'invoicing'),
540
+            'desc'  => __('The email address of your PayPal account.', 'invoicing'),
541 541
         );
542 542
 		/*
543 543
 		$admin_settings['paypal_merchant_id'] = array(
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
         $admin_settings['paypal_ipn_url'] = array(
595 595
             'type'     => 'ipn_url',
596 596
             'id'       => 'paypal_ipn_url',
597
-            'name'     => __( 'IPN Url', 'invoicing' ),
597
+            'name'     => __('IPN Url', 'invoicing'),
598 598
             'std'      => $this->notify_url,
599
-            'desc'     => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
599
+            'desc'     => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
600 600
             'readonly' => true,
601 601
         );
602 602
 
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
      * @param array $data
611 611
      * @return string
612 612
 	 */
613
-	public static function maybe_get_connect_url( $url = '', $data ) {
614
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
613
+	public static function maybe_get_connect_url($url = '', $data) {
614
+		return self::get_connect_url(false, urldecode($data['redirect']));
615 615
 	}
616 616
 
617 617
 	/**
@@ -622,25 +622,25 @@  discard block
 block discarded – undo
622 622
 	 * @param string $redirect
623 623
      * @return string
624 624
 	 */
625
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
625
+	public static function get_connect_url($is_sandbox, $redirect = '') {
626 626
 
627 627
         $redirect_url = add_query_arg(
628 628
             array(
629 629
                 'getpaid-admin-action' => 'connect_paypal',
630 630
                 'page'                 => 'wpinv-settings',
631
-                'live_mode'            => (int) empty( $is_sandbox ),
631
+                'live_mode'            => (int) empty($is_sandbox),
632 632
                 'tab'                  => 'gateways',
633 633
                 'section'              => 'paypal',
634
-                'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
635
-				'redirect'             => urlencode( $redirect ),
634
+                'getpaid-nonce'        => wp_create_nonce('getpaid-nonce'),
635
+				'redirect'             => urlencode($redirect),
636 636
             ),
637
-            admin_url( 'admin.php' )
637
+            admin_url('admin.php')
638 638
         );
639 639
 
640 640
         return add_query_arg(
641 641
             array(
642
-                'live_mode'    => (int) empty( $is_sandbox ),
643
-                'redirect_url' => urlencode( str_replace( '&amp;', '&', $redirect_url ) )
642
+                'live_mode'    => (int) empty($is_sandbox),
643
+                'redirect_url' => urlencode(str_replace('&amp;', '&', $redirect_url))
644 644
             ),
645 645
             'https://ayecode.io/oauth/paypal'
646 646
         );
@@ -704,26 +704,26 @@  discard block
 block discarded – undo
704 704
 	 * @param array $data Connection data.
705 705
 	 * @return void
706 706
 	 */
707
-	public function connect_paypal( $data ) {
707
+	public function connect_paypal($data) {
708 708
 
709 709
 		$sandbox      = $this->is_sandbox();
710
-		$data         = wp_unslash( $data );
711
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
710
+		$data         = wp_unslash($data);
711
+		$access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']);
712 712
 
713
-		if ( isset( $data['live_mode'] ) ) {
714
-			$sandbox = empty( $data['live_mode'] );
713
+		if (isset($data['live_mode'])) {
714
+			$sandbox = empty($data['live_mode']);
715 715
 		}
716 716
 
717
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
718
-		wpinv_update_option( 'paypal_active', 1 );
717
+		wpinv_update_option('paypal_sandbox', (int) $sandbox);
718
+		wpinv_update_option('paypal_active', 1);
719 719
 
720
-		if ( ! empty( $data['error_description'] ) ) {
721
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
720
+		if (!empty($data['error_description'])) {
721
+			getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description'])));
722 722
 		} else {
723 723
 
724 724
 			// Retrieve the user info.
725 725
 			$user_info = wp_remote_get(
726
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
726
+				!$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
727 727
 				array(
728 728
 
729 729
 					'headers' => array(
@@ -734,23 +734,23 @@  discard block
 block discarded – undo
734 734
 				)
735 735
 			);
736 736
 
737
-			if ( is_wp_error( $user_info ) ) {
738
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
737
+			if (is_wp_error($user_info)) {
738
+				getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message()));
739 739
 			} else {
740 740
 
741 741
 				// Create application.
742
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
742
+				$user_info = json_decode(wp_remote_retrieve_body($user_info));
743 743
 				$app       = wp_remote_post(
744
-					! $sandbox ? 'https://api-m.paypal.com/v1/identity/applications' : 'https://api-m.sandbox.paypal.com/v1/identity/applications',
744
+					!$sandbox ? 'https://api-m.paypal.com/v1/identity/applications' : 'https://api-m.sandbox.paypal.com/v1/identity/applications',
745 745
 					array(
746 746
 
747 747
 						'body'    => array(
748 748
 							'application_type' => 'web',
749 749
 							'redirect_uris'    => array(
750
-								add_query_arg( 'getpaid_oauth', 'paypal', home_url() ),
750
+								add_query_arg('getpaid_oauth', 'paypal', home_url()),
751 751
 							),
752 752
 							'client_name'      => 'GetPaid',
753
-							'contacts'         => array( $user_info->emails[0]->value ),
753
+							'contacts'         => array($user_info->emails[0]->value),
754 754
 							'payer_id'         => $user_info->payer_id,
755 755
 							'migrated_app'     => '',
756 756
 						),
@@ -762,30 +762,30 @@  discard block
 block discarded – undo
762 762
 					)
763 763
 				);
764 764
 
765
-				if ( is_wp_error( $app ) ) {
766
-					getpaid_admin()->show_error( wp_kses_post( $app->get_error_message() ) );
765
+				if (is_wp_error($app)) {
766
+					getpaid_admin()->show_error(wp_kses_post($app->get_error_message()));
767 767
 				} else {
768 768
 
769
-					$app = json_decode( wp_remote_retrieve_body( $app ) );
770
-					wpinv_error_log( $app );
771
-					if ( $sandbox ) {
772
-						wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
773
-						wpinv_update_option( 'paypal_sandbox_merchant_id', '' );
774
-						wpinv_update_option( 'paypal_sandbox_client_id', sanitize_text_field( '' ) );
775
-						wpinv_update_option( 'paypal_sandbox_client_secret', sanitize_text_field( '' ) );
776
-						wpinv_update_option( 'paypal_sandbox_client_secret_expires_at', sanitize_text_field( '' ) );
777
-						wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
778
-						set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
779
-						getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
769
+					$app = json_decode(wp_remote_retrieve_body($app));
770
+					wpinv_error_log($app);
771
+					if ($sandbox) {
772
+						wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value));
773
+						wpinv_update_option('paypal_sandbox_merchant_id', '');
774
+						wpinv_update_option('paypal_sandbox_client_id', sanitize_text_field(''));
775
+						wpinv_update_option('paypal_sandbox_client_secret', sanitize_text_field(''));
776
+						wpinv_update_option('paypal_sandbox_client_secret_expires_at', sanitize_text_field(''));
777
+						wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
778
+						set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
779
+						getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'invoicing'));
780 780
 					} else {
781
-						wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
782
-						wpinv_update_option( 'paypal_merchant_id', '' );
783
-						wpinv_update_option( 'paypal_client_id', sanitize_text_field( '' ) );
784
-						wpinv_update_option( 'paypal_client_secret', sanitize_text_field( '' ) );
785
-						wpinv_update_option( 'paypal_client_secret_expires_at', sanitize_text_field( '' ) );
786
-						wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
787
-						set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
788
-						getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
781
+						wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value));
782
+						wpinv_update_option('paypal_merchant_id', '');
783
+						wpinv_update_option('paypal_client_id', sanitize_text_field(''));
784
+						wpinv_update_option('paypal_client_secret', sanitize_text_field(''));
785
+						wpinv_update_option('paypal_client_secret_expires_at', sanitize_text_field(''));
786
+						wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
787
+						set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
788
+						getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'invoicing'));
789 789
 					}
790 790
 
791 791
 				}
@@ -794,12 +794,12 @@  discard block
 block discarded – undo
794 794
 
795 795
 		}
796 796
 
797
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
797
+		$redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways&section=paypal') : urldecode($data['redirect']);
798 798
 
799
-		if ( isset( $data['step'] ) ) {
800
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
799
+		if (isset($data['step'])) {
800
+			$redirect = add_query_arg('step', $data['step'], $redirect);
801 801
 		}
802
-		wp_redirect( $redirect );
802
+		wp_redirect($redirect);
803 803
 		exit;
804 804
 	}
805 805
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +543 added lines, -543 removed lines patch added patch discarded remove patch
@@ -14,89 +14,89 @@  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_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
74
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
75
-		do_action( 'getpaid_init_admin_hooks', $this );
76
-
77
-		// Setup/welcome
78
-		if ( ! empty( $_GET['page'] ) ) {
79
-			switch ( $_GET['page'] ) {
80
-				case 'gp-setup' :
81
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
82
-					break;
83
-			}
84
-		}
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_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
74
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
75
+        do_action( 'getpaid_init_admin_hooks', $this );
76
+
77
+        // Setup/welcome
78
+        if ( ! empty( $_GET['page'] ) ) {
79
+            switch ( $_GET['page'] ) {
80
+                case 'gp-setup' :
81
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
82
+                    break;
83
+            }
84
+        }
85 85
 
86 86
     }
87 87
 
88 88
     /**
89
-	 * Register admin scripts
90
-	 *
91
-	 */
92
-	public function enqeue_scripts() {
89
+     * Register admin scripts
90
+     *
91
+     */
92
+    public function enqeue_scripts() {
93 93
         global $current_screen, $pagenow;
94 94
 
95
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
96
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
95
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
96
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
97 97
 
98 98
         if ( ! empty( $current_screen->post_type ) ) {
99
-			$page = $current_screen->post_type;
99
+            $page = $current_screen->post_type;
100 100
         }
101 101
 
102 102
         // General styles.
@@ -117,54 +117,54 @@  discard block
 block discarded – undo
117 117
         }
118 118
 
119 119
         // Payment form scripts.
120
-		if ( 'wpi_payment_form' == $page && $editing ) {
120
+        if ( 'wpi_payment_form' == $page && $editing ) {
121 121
             $this->load_payment_form_scripts();
122 122
         }
123 123
 
124
-		if ( $page == 'wpinv-subscriptions' ) {
125
-			wp_enqueue_script( 'postbox' );
126
-		}
124
+        if ( $page == 'wpinv-subscriptions' ) {
125
+            wp_enqueue_script( 'postbox' );
126
+        }
127 127
 
128 128
     }
129 129
 
130 130
     /**
131
-	 * Returns admin js translations.
132
-	 *
133
-	 */
134
-	protected function get_admin_i18() {
131
+     * Returns admin js translations.
132
+     *
133
+     */
134
+    protected function get_admin_i18() {
135 135
         global $post;
136 136
 
137
-		$date_range = array(
138
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
139
-		);
137
+        $date_range = array(
138
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
139
+        );
140 140
 
141
-		if ( $date_range['period'] == 'custom' ) {
141
+        if ( $date_range['period'] == 'custom' ) {
142 142
 			
143
-			if ( isset( $_GET['from'] ) ) {
144
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
145
-			}
143
+            if ( isset( $_GET['from'] ) ) {
144
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
145
+            }
146 146
 
147
-			if ( isset( $_GET['to'] ) ) {
148
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
149
-			}
147
+            if ( isset( $_GET['to'] ) ) {
148
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
149
+            }
150 150
 
151
-		}
151
+        }
152 152
 
153 153
         $i18n = array(
154 154
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
155 155
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
156
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
157
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
158
-			'rest_root'                 => esc_url_raw( rest_url() ),
159
-			'date_range'                => $date_range,
156
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
157
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
158
+            'rest_root'                 => esc_url_raw( rest_url() ),
159
+            'date_range'                => $date_range,
160 160
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
161 161
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
162 162
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
163 163
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
164 164
             'tax'                       => wpinv_tax_amount(),
165 165
             'discount'                  => 0,
166
-			'currency_symbol'           => wpinv_currency_symbol(),
167
-			'currency'                  => wpinv_get_currency(),
166
+            'currency_symbol'           => wpinv_currency_symbol(),
167
+            'currency'                  => wpinv_get_currency(),
168 168
             'currency_pos'              => wpinv_currency_position(),
169 169
             'thousand_sep'              => wpinv_thousands_separator(),
170 170
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -184,118 +184,118 @@  discard block
 block discarded – undo
184 184
             'item_description'          => __( 'Item Description', 'invoicing' ),
185 185
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
186 186
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
187
-			'searching'                 => __( 'Searching', 'invoicing' ),
188
-			'loading'                   => __( 'Loading...', 'invoicing' ),
189
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
190
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
187
+            'searching'                 => __( 'Searching', 'invoicing' ),
188
+            'loading'                   => __( 'Loading...', 'invoicing' ),
189
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
190
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
191 191
         );
192 192
 
193
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
193
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
194 194
 
195
-			$invoice              = new WPInv_Invoice( $post );
196
-			$i18n['save_invoice'] = sprintf(
197
-				__( 'Save %s', 'invoicing' ),
198
-				ucfirst( $invoice->get_invoice_quote_type() )
199
-			);
195
+            $invoice              = new WPInv_Invoice( $post );
196
+            $i18n['save_invoice'] = sprintf(
197
+                __( 'Save %s', 'invoicing' ),
198
+                ucfirst( $invoice->get_invoice_quote_type() )
199
+            );
200 200
 
201
-			$i18n['invoice_description'] = sprintf(
202
-				__( '%s Description', 'invoicing' ),
203
-				ucfirst( $invoice->get_invoice_quote_type() )
204
-			);
201
+            $i18n['invoice_description'] = sprintf(
202
+                __( '%s Description', 'invoicing' ),
203
+                ucfirst( $invoice->get_invoice_quote_type() )
204
+            );
205 205
 
206
-		}
207
-		return $i18n;
208
-	}
206
+        }
207
+        return $i18n;
208
+    }
209 209
 
210
-	/**
211
-	 * Change the admin footer text on GetPaid admin pages.
212
-	 *
213
-	 * @since  2.0.0
214
-	 * @param  string $footer_text
215
-	 * @return string
216
-	 */
217
-	public function admin_footer_text( $footer_text ) {
218
-		global $current_screen;
210
+    /**
211
+     * Change the admin footer text on GetPaid admin pages.
212
+     *
213
+     * @since  2.0.0
214
+     * @param  string $footer_text
215
+     * @return string
216
+     */
217
+    public function admin_footer_text( $footer_text ) {
218
+        global $current_screen;
219 219
 
220
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
220
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
221 221
 
222 222
         if ( ! empty( $current_screen->post_type ) ) {
223
-			$page = $current_screen->post_type;
223
+            $page = $current_screen->post_type;
224 224
         }
225 225
 
226 226
         // General styles.
227 227
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
228 228
 
229
-			// Change the footer text
230
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
231
-
232
-				$rating_url  = esc_url(
233
-					wp_nonce_url(
234
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
235
-						'getpaid-nonce',
236
-						'getpaid-nonce'
237
-						)
238
-				);
239
-
240
-				$footer_text = sprintf(
241
-					/* translators: %s: five stars */
242
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
243
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
244
-				);
245
-
246
-			} else {
247
-
248
-				$footer_text = sprintf(
249
-					/* translators: %s: GetPaid */
250
-					__( 'Thank you for using %s!', 'invoicing' ),
251
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
252
-				);
253
-
254
-			}
255
-
256
-		}
257
-
258
-		return $footer_text;
259
-	}
260
-
261
-	/**
262
-	 * Redirects to wp.org to rate the plugin.
263
-	 *
264
-	 * @since  2.0.0
265
-	 */
266
-	public function redirect_to_wordpress_rating_page() {
267
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
268
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
269
-		exit;
270
-	}
271
-
272
-    /**
273
-	 * Loads payment form js.
274
-	 *
275
-	 */
276
-	protected function load_payment_form_scripts() {
229
+            // Change the footer text
230
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
231
+
232
+                $rating_url  = esc_url(
233
+                    wp_nonce_url(
234
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
235
+                        'getpaid-nonce',
236
+                        'getpaid-nonce'
237
+                        )
238
+                );
239
+
240
+                $footer_text = sprintf(
241
+                    /* translators: %s: five stars */
242
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
243
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
244
+                );
245
+
246
+            } else {
247
+
248
+                $footer_text = sprintf(
249
+                    /* translators: %s: GetPaid */
250
+                    __( 'Thank you for using %s!', 'invoicing' ),
251
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
252
+                );
253
+
254
+            }
255
+
256
+        }
257
+
258
+        return $footer_text;
259
+    }
260
+
261
+    /**
262
+     * Redirects to wp.org to rate the plugin.
263
+     *
264
+     * @since  2.0.0
265
+     */
266
+    public function redirect_to_wordpress_rating_page() {
267
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
268
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
269
+        exit;
270
+    }
271
+
272
+    /**
273
+     * Loads payment form js.
274
+     *
275
+     */
276
+    protected function load_payment_form_scripts() {
277 277
         global $post;
278 278
 
279 279
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
280
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
280
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
281
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
282 282
 
283
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
284
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
283
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
284
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
285 285
 
286
-		wp_localize_script(
286
+        wp_localize_script(
287 287
             'wpinv-admin-payment-form-script',
288 288
             'wpinvPaymentFormAdmin',
289 289
             array(
290
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
291
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
292
-				'currency'      => wpinv_currency_symbol(),
293
-				'position'      => wpinv_currency_position(),
294
-				'decimals'      => (int) wpinv_decimals(),
295
-				'thousands_sep' => wpinv_thousands_separator(),
296
-				'decimals_sep'  => wpinv_decimal_separator(),
297
-				'form_items'    => gepaid_get_form_items( $post->ID ),
298
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
290
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
291
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
292
+                'currency'      => wpinv_currency_symbol(),
293
+                'position'      => wpinv_currency_position(),
294
+                'decimals'      => (int) wpinv_decimals(),
295
+                'thousands_sep' => wpinv_thousands_separator(),
296
+                'decimals_sep'  => wpinv_decimal_separator(),
297
+                'form_items'    => gepaid_get_form_items( $post->ID ),
298
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
299 299
             )
300 300
         );
301 301
 
@@ -304,20 +304,20 @@  discard block
 block discarded – undo
304 304
     }
305 305
 
306 306
     /**
307
-	 * Add our classes to admin pages.
307
+     * Add our classes to admin pages.
308 308
      *
309 309
      * @param string $classes
310 310
      * @return string
311
-	 *
312
-	 */
311
+     *
312
+     */
313 313
     public function admin_body_class( $classes ) {
314
-		global $pagenow, $post, $current_screen;
314
+        global $pagenow, $post, $current_screen;
315 315
 
316 316
 
317 317
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
318 318
 
319 319
         if ( ! empty( $current_screen->post_type ) ) {
320
-			$page = $current_screen->post_type;
320
+            $page = $current_screen->post_type;
321 321
         }
322 322
 
323 323
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -326,68 +326,68 @@  discard block
 block discarded – undo
326 326
 
327 327
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
328 328
             $classes .= ' wpinv-cpt wpinv';
329
-		}
329
+        }
330 330
 		
331
-		if ( getpaid_is_invoice_post_type( $page ) ) {
331
+        if ( getpaid_is_invoice_post_type( $page ) ) {
332 332
             $classes .= ' getpaid-is-invoice-cpt';
333 333
         }
334 334
 
335
-		return $classes;
335
+        return $classes;
336 336
     }
337 337
 
338 338
     /**
339
-	 * Maybe show the AyeCode Connect Notice.
340
-	 */
341
-	public function init_ayecode_connect_helper(){
339
+     * Maybe show the AyeCode Connect Notice.
340
+     */
341
+    public function init_ayecode_connect_helper(){
342 342
 
343
-		// Register with the deactivation survey class.
344
-		AyeCode_Deactivation_Survey::instance(array(
345
-			'slug'		        => 'invoicing',
346
-			'version'	        => WPINV_VERSION,
347
-			'support_url'       => 'https://wpgetpaid.com/support/',
348
-			'documentation_url' => 'https://docs.wpgetpaid.com/',
349
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
350
-		));
343
+        // Register with the deactivation survey class.
344
+        AyeCode_Deactivation_Survey::instance(array(
345
+            'slug'		        => 'invoicing',
346
+            'version'	        => WPINV_VERSION,
347
+            'support_url'       => 'https://wpgetpaid.com/support/',
348
+            'documentation_url' => 'https://docs.wpgetpaid.com/',
349
+            'activated'         => (int) get_option( 'gepaid_installed_on' ),
350
+        ));
351 351
 
352 352
         new AyeCode_Connect_Helper(
353 353
             array(
354
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
355
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
356
-				'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>" ),
357
-				'connect_button'    => __("Connect Site","invoicing"),
358
-				'connecting_button'    => __("Connecting...","invoicing"),
359
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
360
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
354
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
355
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
356
+                '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>" ),
357
+                'connect_button'    => __("Connect Site","invoicing"),
358
+                'connecting_button'    => __("Connecting...","invoicing"),
359
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
360
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
361 361
             ),
362 362
             array( 'wpi-addons' )
363 363
         );
364 364
 
365 365
     }
366 366
 
367
-	/**
368
-	 * Redirect users to settings on activation.
369
-	 *
370
-	 * @return void
371
-	 */
372
-	public function activation_redirect() {
367
+    /**
368
+     * Redirect users to settings on activation.
369
+     *
370
+     * @return void
371
+     */
372
+    public function activation_redirect() {
373 373
 
374
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
374
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
375 375
 
376
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
377
-			return;
378
-		}
376
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
377
+            return;
378
+        }
379 379
 
380
-		// Bail if activating from network, or bulk
381
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
382
-			return;
383
-		}
380
+        // Bail if activating from network, or bulk
381
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
382
+            return;
383
+        }
384 384
 
385
-	    update_option( 'wpinv_redirected_to_settings', 1 );
385
+        update_option( 'wpinv_redirected_to_settings', 1 );
386 386
 
387 387
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
388 388
         exit;
389 389
 
390
-	}
390
+    }
391 391
 
392 392
     /**
393 393
      * Fires an admin action after verifying that a user can fire them.
@@ -401,458 +401,458 @@  discard block
 block discarded – undo
401 401
 
402 402
     }
403 403
 
404
-	/**
404
+    /**
405 405
      * Sends a payment reminder to a customer.
406
-	 * 
407
-	 * @param array $args
406
+     * 
407
+     * @param array $args
408 408
      */
409 409
     public function send_customer_invoice( $args ) {
410
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
410
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
411 411
 
412
-		if ( $sent ) {
413
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
414
-		} else {
415
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
416
-		}
412
+        if ( $sent ) {
413
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
414
+        } else {
415
+            $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
416
+        }
417 417
 
418
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
419
-		exit;
420
-	}
418
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
419
+        exit;
420
+    }
421 421
 
422
-	/**
422
+    /**
423 423
      * Sends a payment reminder to a customer.
424
-	 * 
425
-	 * @param array $args
424
+     * 
425
+     * @param array $args
426 426
      */
427 427
     public function send_customer_payment_reminder( $args ) {
428
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
428
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
429 429
 
430
-		if ( $sent ) {
431
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
432
-		} else {
433
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
434
-		}
430
+        if ( $sent ) {
431
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
432
+        } else {
433
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
434
+        }
435 435
 
436
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
437
-		exit;
438
-	}
436
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
437
+        exit;
438
+    }
439 439
 
440
-	/**
440
+    /**
441 441
      * Resets tax rates.
442
-	 * 
442
+     * 
443 443
      */
444 444
     public function admin_reset_tax_rates() {
445 445
 
446
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
447
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
448
-		exit;
446
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
447
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
448
+        exit;
449 449
 
450
-	}
450
+    }
451 451
 
452
-	/**
452
+    /**
453 453
      * Resets admin pages.
454
-	 * 
454
+     * 
455 455
      */
456 456
     public function admin_create_missing_pages() {
457
-		$installer = new GetPaid_Installer();
458
-		$installer->create_pages();
459
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
460
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
461
-		exit;
462
-	}
463
-
464
-	/**
457
+        $installer = new GetPaid_Installer();
458
+        $installer->create_pages();
459
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
460
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
461
+        exit;
462
+    }
463
+
464
+    /**
465 465
      * Creates an missing admin tables.
466
-	 * 
466
+     * 
467 467
      */
468 468
     public function admin_create_missing_tables() {
469
-		global $wpdb;
470
-		$installer = new GetPaid_Installer();
469
+        global $wpdb;
470
+        $installer = new GetPaid_Installer();
471 471
 
472
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
473
-			$installer->create_subscriptions_table();
472
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
473
+            $installer->create_subscriptions_table();
474 474
 
475
-			if ( $wpdb->last_error !== '' ) {
476
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
477
-			}
478
-		}
475
+            if ( $wpdb->last_error !== '' ) {
476
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
477
+            }
478
+        }
479 479
 
480
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
481
-			$installer->create_invoices_table();
480
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
481
+            $installer->create_invoices_table();
482 482
 
483
-			if ( $wpdb->last_error !== '' ) {
484
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
485
-			}
486
-		}
483
+            if ( $wpdb->last_error !== '' ) {
484
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
485
+            }
486
+        }
487 487
 
488
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
489
-			$installer->create_invoice_items_table();
488
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
489
+            $installer->create_invoice_items_table();
490 490
 
491
-			if ( $wpdb->last_error !== '' ) {
492
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
493
-			}
494
-		}
491
+            if ( $wpdb->last_error !== '' ) {
492
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
493
+            }
494
+        }
495 495
 
496
-		if ( ! $this->has_notices() ) {
497
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
498
-		}
496
+        if ( ! $this->has_notices() ) {
497
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
498
+        }
499 499
 
500
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
501
-		exit;
502
-	}
500
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
501
+        exit;
502
+    }
503 503
 
504
-	/**
504
+    /**
505 505
      * Migrates old invoices to the new database tables.
506
-	 * 
506
+     * 
507 507
      */
508 508
     public function admin_migrate_old_invoices() {
509 509
 
510
-		// Migrate the invoices.
511
-		$installer = new GetPaid_Installer();
512
-		$installer->migrate_old_invoices();
510
+        // Migrate the invoices.
511
+        $installer = new GetPaid_Installer();
512
+        $installer->migrate_old_invoices();
513 513
 
514
-		// Show an admin message.
515
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
514
+        // Show an admin message.
515
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
516 516
 
517
-		// Redirect the admin.
518
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
519
-		exit;
517
+        // Redirect the admin.
518
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
519
+        exit;
520 520
 
521
-	}
521
+    }
522 522
 
523
-	/**
523
+    /**
524 524
      * Download customers.
525
-	 * 
525
+     * 
526 526
      */
527 527
     public function admin_download_customers() {
528
-		global $wpdb;
528
+        global $wpdb;
529 529
 
530
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
530
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
531 531
 
532
-		header( "Content-Type:text/csv" );
533
-		header( "Content-Disposition:attachment;filename=customers.csv" );
532
+        header( "Content-Type:text/csv" );
533
+        header( "Content-Disposition:attachment;filename=customers.csv" );
534 534
 
535
-		$post_types = '';
535
+        $post_types = '';
536 536
 
537
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
538
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
539
-		}
537
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
538
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
539
+        }
540 540
 
541
-		$post_types = rtrim( $post_types, ' OR' );
541
+        $post_types = rtrim( $post_types, ' OR' );
542 542
 
543
-		$customers = $wpdb->get_col(
544
-			$wpdb->prepare(
545
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
546
-			)
547
-		);
543
+        $customers = $wpdb->get_col(
544
+            $wpdb->prepare(
545
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
546
+            )
547
+        );
548 548
 
549
-		$columns = array(
550
-			'name'     => __( 'Name', 'invoicing' ),
551
-			'email'    => __( 'Email', 'invoicing' ),
552
-			'country'  => __( 'Country', 'invoicing' ),
553
-			'state'    => __( 'State', 'invoicing' ),
554
-			'city'     => __( 'City', 'invoicing' ),
555
-			'zip'      => __( 'ZIP', 'invoicing' ),
556
-			'address'  => __( 'Address', 'invoicing' ),
557
-			'phone'    => __( 'Phone', 'invoicing' ),
558
-			'company'  => __( 'Company', 'invoicing' ),
559
-			'invoices' => __( 'Invoices', 'invoicing' ),
560
-			'total'    => __( 'Total Spend', 'invoicing' ),
561
-			'signup'   => __( 'Date created', 'invoicing' ),
562
-		);
549
+        $columns = array(
550
+            'name'     => __( 'Name', 'invoicing' ),
551
+            'email'    => __( 'Email', 'invoicing' ),
552
+            'country'  => __( 'Country', 'invoicing' ),
553
+            'state'    => __( 'State', 'invoicing' ),
554
+            'city'     => __( 'City', 'invoicing' ),
555
+            'zip'      => __( 'ZIP', 'invoicing' ),
556
+            'address'  => __( 'Address', 'invoicing' ),
557
+            'phone'    => __( 'Phone', 'invoicing' ),
558
+            'company'  => __( 'Company', 'invoicing' ),
559
+            'invoices' => __( 'Invoices', 'invoicing' ),
560
+            'total'    => __( 'Total Spend', 'invoicing' ),
561
+            'signup'   => __( 'Date created', 'invoicing' ),
562
+        );
563 563
 
564
-		// Output the csv column headers.
565
-		fputcsv( $output, array_values( $columns ) );
564
+        // Output the csv column headers.
565
+        fputcsv( $output, array_values( $columns ) );
566 566
 
567
-		// Loop through
568
-		$table = new WPInv_Customers_Table();
569
-		foreach ( $customers as $customer_id ) {
567
+        // Loop through
568
+        $table = new WPInv_Customers_Table();
569
+        foreach ( $customers as $customer_id ) {
570 570
 
571
-			$user = get_user_by( 'id', $customer_id );
572
-			$row  = array();
573
-			if ( empty( $user ) ) {
574
-				continue;
575
-			}
571
+            $user = get_user_by( 'id', $customer_id );
572
+            $row  = array();
573
+            if ( empty( $user ) ) {
574
+                continue;
575
+            }
576 576
 
577
-			foreach ( array_keys( $columns ) as $column ) {
577
+            foreach ( array_keys( $columns ) as $column ) {
578 578
 
579
-				$method = 'column_' . $column;
579
+                $method = 'column_' . $column;
580 580
 
581
-				if ( 'name' == $column ) {
582
-					$value = sanitize_text_field( $user->display_name );
583
-				} else if( 'email' == $column ) {
584
-					$value = sanitize_email( $user->user_email );
585
-				} else if ( is_callable( array( $table, $method ) ) ) {
586
-					$value = strip_tags( $table->$method( $user ) );
587
-				}
581
+                if ( 'name' == $column ) {
582
+                    $value = sanitize_text_field( $user->display_name );
583
+                } else if( 'email' == $column ) {
584
+                    $value = sanitize_email( $user->user_email );
585
+                } else if ( is_callable( array( $table, $method ) ) ) {
586
+                    $value = strip_tags( $table->$method( $user ) );
587
+                }
588 588
 
589
-				if ( empty( $value ) ) {
590
-					$value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
591
-				}
589
+                if ( empty( $value ) ) {
590
+                    $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
591
+                }
592 592
 
593
-				$row[] = $value;
593
+                $row[] = $value;
594 594
 
595
-			}
595
+            }
596 596
 
597
-			fputcsv( $output, $row );
598
-		}
597
+            fputcsv( $output, $row );
598
+        }
599 599
 
600
-		fclose( $output );
601
-		exit;
600
+        fclose( $output );
601
+        exit;
602 602
 
603
-	}
603
+    }
604 604
 
605
-	/**
605
+    /**
606 606
      * Installs a plugin.
607
-	 *
608
-	 * @param array $data
607
+     *
608
+     * @param array $data
609 609
      */
610 610
     public function admin_install_plugin( $data ) {
611 611
 
612
-		if ( ! empty( $data['plugins'] ) ) {
613
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
614
-			wp_cache_flush();
612
+        if ( ! empty( $data['plugins'] ) ) {
613
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
614
+            wp_cache_flush();
615 615
 
616
-			foreach ( $data['plugins'] as $slug => $file ) {
617
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
618
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
619
-				$installed  = $upgrader->install( $plugin_zip );
616
+            foreach ( $data['plugins'] as $slug => $file ) {
617
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
618
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
619
+                $installed  = $upgrader->install( $plugin_zip );
620 620
 
621
-				if ( ! is_wp_error( $installed ) && $installed ) {
622
-					activate_plugin( $file, '', false, true );
623
-				} else {
624
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
625
-				}
621
+                if ( ! is_wp_error( $installed ) && $installed ) {
622
+                    activate_plugin( $file, '', false, true );
623
+                } else {
624
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
625
+                }
626 626
 
627
-			}
627
+            }
628 628
 
629
-		}
629
+        }
630 630
 
631
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
632
-		wp_safe_redirect( $redirect );
633
-		exit;
631
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
632
+        wp_safe_redirect( $redirect );
633
+        exit;
634 634
 
635
-	}
635
+    }
636 636
 
637
-	/**
637
+    /**
638 638
      * Connects a gateway.
639
-	 *
640
-	 * @param array $data
639
+     *
640
+     * @param array $data
641 641
      */
642 642
     public function admin_connect_gateway( $data ) {
643 643
 
644
-		if ( ! empty( $data['plugin'] ) ) {
644
+        if ( ! empty( $data['plugin'] ) ) {
645 645
 
646
-			$gateway     = sanitize_key( $data['plugin'] );
647
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
646
+            $gateway     = sanitize_key( $data['plugin'] );
647
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
648 648
 
649
-			if ( ! empty( $connect_url ) ) {
650
-				wp_redirect( $connect_url );
651
-				exit;
652
-			}
649
+            if ( ! empty( $connect_url ) ) {
650
+                wp_redirect( $connect_url );
651
+                exit;
652
+            }
653 653
 
654
-			if ( 'stripe' == $data['plugin'] ) {
655
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
654
+            if ( 'stripe' == $data['plugin'] ) {
655
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
656 656
 
657
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
658
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
659
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
660
-					$upgrader->install( $plugin_zip );
661
-				}
657
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
658
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
659
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
660
+                    $upgrader->install( $plugin_zip );
661
+                }
662 662
 
663
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
664
-			}
663
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
664
+            }
665 665
 
666
-			if ( ! empty( $connect_url ) ) {
667
-				wp_redirect( $connect_url );
668
-				exit;
669
-			}
666
+            if ( ! empty( $connect_url ) ) {
667
+                wp_redirect( $connect_url );
668
+                exit;
669
+            }
670 670
 
671
-		}
671
+        }
672 672
 
673
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
674
-		wp_safe_redirect( $redirect );
675
-		exit;
673
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
674
+        wp_safe_redirect( $redirect );
675
+        exit;
676 676
 
677
-	}
677
+    }
678 678
 
679
-	/**
679
+    /**
680 680
      * Recalculates discounts.
681
-	 * 
681
+     * 
682 682
      */
683 683
     public function admin_recalculate_discounts() {
684
-		global $wpdb;
684
+        global $wpdb;
685 685
 
686
-		// Fetch all invoices that have discount codes.
687
-		$table    = $wpdb->prefix . 'getpaid_invoices';
688
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
686
+        // Fetch all invoices that have discount codes.
687
+        $table    = $wpdb->prefix . 'getpaid_invoices';
688
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
689 689
 
690
-		foreach ( $invoices as $invoice ) {
690
+        foreach ( $invoices as $invoice ) {
691 691
 
692
-			$invoice = new WPInv_Invoice( $invoice );
692
+            $invoice = new WPInv_Invoice( $invoice );
693 693
 
694
-			if ( ! $invoice->exists() ) {
695
-				continue;
696
-			}
694
+            if ( ! $invoice->exists() ) {
695
+                continue;
696
+            }
697 697
 
698
-			// Abort if the discount does not exist or does not apply here.
699
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
700
-			if ( ! $discount->exists() ) {
701
-				continue;
702
-			}
698
+            // Abort if the discount does not exist or does not apply here.
699
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
700
+            if ( ! $discount->exists() ) {
701
+                continue;
702
+            }
703 703
 
704
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
705
-			$invoice->recalculate_total();
704
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
705
+            $invoice->recalculate_total();
706 706
 
707
-			if ( $invoice->get_total_discount() > 0 ) {
708
-				$invoice->save();
709
-			}
707
+            if ( $invoice->get_total_discount() > 0 ) {
708
+                $invoice->save();
709
+            }
710 710
 
711
-		}
711
+        }
712 712
 
713
-		// Show an admin message.
714
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
713
+        // Show an admin message.
714
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
715 715
 
716
-		// Redirect the admin.
717
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
718
-		exit;
716
+        // Redirect the admin.
717
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
718
+        exit;
719 719
 
720
-	}
720
+    }
721 721
 
722 722
     /**
723
-	 * Returns an array of admin notices.
724
-	 *
725
-	 * @since       1.0.19
723
+     * Returns an array of admin notices.
724
+     *
725
+     * @since       1.0.19
726 726
      * @return array
727
-	 */
728
-	public function get_notices() {
729
-		$notices = get_option( 'wpinv_admin_notices' );
727
+     */
728
+    public function get_notices() {
729
+        $notices = get_option( 'wpinv_admin_notices' );
730 730
         return is_array( $notices ) ? $notices : array();
731
-	}
731
+    }
732 732
 
733
-	/**
734
-	 * Checks if we have any admin notices.
735
-	 *
736
-	 * @since       2.0.4
733
+    /**
734
+     * Checks if we have any admin notices.
735
+     *
736
+     * @since       2.0.4
737 737
      * @return array
738
-	 */
739
-	public function has_notices() {
740
-		return count( $this->get_notices() ) > 0;
741
-	}
742
-
743
-	/**
744
-	 * Clears all admin notices
745
-	 *
746
-	 * @access      public
747
-	 * @since       1.0.19
748
-	 */
749
-	public function clear_notices() {
750
-		delete_option( 'wpinv_admin_notices' );
751
-	}
752
-
753
-	/**
754
-	 * Saves a new admin notice
755
-	 *
756
-	 * @access      public
757
-	 * @since       1.0.19
758
-	 */
759
-	public function save_notice( $type, $message ) {
760
-		$notices = $this->get_notices();
761
-
762
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
763
-			$notices[ $type ] = array();
764
-		}
765
-
766
-		$notices[ $type ][] = $message;
767
-
768
-		update_option( 'wpinv_admin_notices', $notices );
769
-	}
770
-
771
-	/**
772
-	 * Displays a success notice
773
-	 *
774
-	 * @param       string $msg The message to qeue.
775
-	 * @access      public
776
-	 * @since       1.0.19
777
-	 */
778
-	public function show_success( $msg ) {
779
-		$this->save_notice( 'success', $msg );
780
-	}
781
-
782
-	/**
783
-	 * Displays a error notice
784
-	 *
785
-	 * @access      public
786
-	 * @param       string $msg The message to qeue.
787
-	 * @since       1.0.19
788
-	 */
789
-	public function show_error( $msg ) {
790
-		$this->save_notice( 'error', $msg );
791
-	}
792
-
793
-	/**
794
-	 * Displays a warning notice
795
-	 *
796
-	 * @access      public
797
-	 * @param       string $msg The message to qeue.
798
-	 * @since       1.0.19
799
-	 */
800
-	public function show_warning( $msg ) {
801
-		$this->save_notice( 'warning', $msg );
802
-	}
803
-
804
-	/**
805
-	 * Displays a info notice
806
-	 *
807
-	 * @access      public
808
-	 * @param       string $msg The message to qeue.
809
-	 * @since       1.0.19
810
-	 */
811
-	public function show_info( $msg ) {
812
-		$this->save_notice( 'info', $msg );
813
-	}
814
-
815
-	/**
816
-	 * Show notices
817
-	 *
818
-	 * @access      public
819
-	 * @since       1.0.19
820
-	 */
821
-	public function show_notices() {
738
+     */
739
+    public function has_notices() {
740
+        return count( $this->get_notices() ) > 0;
741
+    }
742
+
743
+    /**
744
+     * Clears all admin notices
745
+     *
746
+     * @access      public
747
+     * @since       1.0.19
748
+     */
749
+    public function clear_notices() {
750
+        delete_option( 'wpinv_admin_notices' );
751
+    }
752
+
753
+    /**
754
+     * Saves a new admin notice
755
+     *
756
+     * @access      public
757
+     * @since       1.0.19
758
+     */
759
+    public function save_notice( $type, $message ) {
760
+        $notices = $this->get_notices();
761
+
762
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
763
+            $notices[ $type ] = array();
764
+        }
765
+
766
+        $notices[ $type ][] = $message;
767
+
768
+        update_option( 'wpinv_admin_notices', $notices );
769
+    }
770
+
771
+    /**
772
+     * Displays a success notice
773
+     *
774
+     * @param       string $msg The message to qeue.
775
+     * @access      public
776
+     * @since       1.0.19
777
+     */
778
+    public function show_success( $msg ) {
779
+        $this->save_notice( 'success', $msg );
780
+    }
781
+
782
+    /**
783
+     * Displays a error notice
784
+     *
785
+     * @access      public
786
+     * @param       string $msg The message to qeue.
787
+     * @since       1.0.19
788
+     */
789
+    public function show_error( $msg ) {
790
+        $this->save_notice( 'error', $msg );
791
+    }
792
+
793
+    /**
794
+     * Displays a warning notice
795
+     *
796
+     * @access      public
797
+     * @param       string $msg The message to qeue.
798
+     * @since       1.0.19
799
+     */
800
+    public function show_warning( $msg ) {
801
+        $this->save_notice( 'warning', $msg );
802
+    }
803
+
804
+    /**
805
+     * Displays a info notice
806
+     *
807
+     * @access      public
808
+     * @param       string $msg The message to qeue.
809
+     * @since       1.0.19
810
+     */
811
+    public function show_info( $msg ) {
812
+        $this->save_notice( 'info', $msg );
813
+    }
814
+
815
+    /**
816
+     * Show notices
817
+     *
818
+     * @access      public
819
+     * @since       1.0.19
820
+     */
821
+    public function show_notices() {
822 822
 
823 823
         $notices = $this->get_notices();
824 824
         $this->clear_notices();
825 825
 
826
-		foreach ( $notices as $type => $messages ) {
826
+        foreach ( $notices as $type => $messages ) {
827 827
 
828
-			if ( ! is_array( $messages ) ) {
829
-				continue;
830
-			}
828
+            if ( ! is_array( $messages ) ) {
829
+                continue;
830
+            }
831 831
 
832 832
             $type  = sanitize_key( $type );
833
-			foreach ( $messages as $message ) {
833
+            foreach ( $messages as $message ) {
834 834
                 $message = wp_kses_post( $message );
835
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
835
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
836 836
             }
837 837
 
838 838
         }
839 839
 
840
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
841
-
842
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
843
-				$url     = wp_nonce_url(
844
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
845
-					'getpaid-nonce',
846
-					'getpaid-nonce'
847
-				);
848
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
849
-				$message2 = __( 'Generate Pages', 'invoicing' );
850
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
851
-				break;
852
-			}
840
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
841
+
842
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
843
+                $url     = wp_nonce_url(
844
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
845
+                    'getpaid-nonce',
846
+                    'getpaid-nonce'
847
+                );
848
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
849
+                $message2 = __( 'Generate Pages', 'invoicing' );
850
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
851
+                break;
852
+            }
853 853
 
854
-		}
854
+        }
855 855
 
856
-	}
856
+    }
857 857
 
858 858
 }
Please login to merge, or discard this patch.
Spacing   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,31 +54,31 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_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_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
74
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
75
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
65
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
66
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
67
+		add_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_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
74
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
75
+		do_action('getpaid_init_admin_hooks', $this);
76 76
 
77 77
 		// Setup/welcome
78
-		if ( ! empty( $_GET['page'] ) ) {
79
-			switch ( $_GET['page'] ) {
78
+		if (!empty($_GET['page'])) {
79
+			switch ($_GET['page']) {
80 80
 				case 'gp-setup' :
81
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
81
+					include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');
82 82
 					break;
83 83
 			}
84 84
 		}
@@ -92,37 +92,37 @@  discard block
 block discarded – undo
92 92
 	public function enqeue_scripts() {
93 93
         global $current_screen, $pagenow;
94 94
 
95
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
95
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
96 96
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
97 97
 
98
-        if ( ! empty( $current_screen->post_type ) ) {
98
+        if (!empty($current_screen->post_type)) {
99 99
 			$page = $current_screen->post_type;
100 100
         }
101 101
 
102 102
         // General styles.
103
-        if ( false !== stripos( $page, 'wpi' ) || 'gp-setup' == $page ) {
103
+        if (false !== stripos($page, 'wpi') || 'gp-setup' == $page) {
104 104
 
105 105
             // Styles.
106
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
107
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
108
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
106
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
107
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
108
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
109 109
 
110 110
             // Scripts.
111
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
111
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
112 112
 
113
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
114
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ),  $version );
115
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
113
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
114
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
115
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
116 116
 
117 117
         }
118 118
 
119 119
         // Payment form scripts.
120
-		if ( 'wpi_payment_form' == $page && $editing ) {
120
+		if ('wpi_payment_form' == $page && $editing) {
121 121
             $this->load_payment_form_scripts();
122 122
         }
123 123
 
124
-		if ( $page == 'wpinv-subscriptions' ) {
125
-			wp_enqueue_script( 'postbox' );
124
+		if ($page == 'wpinv-subscriptions') {
125
+			wp_enqueue_script('postbox');
126 126
 		}
127 127
 
128 128
     }
@@ -135,32 +135,32 @@  discard block
 block discarded – undo
135 135
         global $post;
136 136
 
137 137
 		$date_range = array(
138
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
138
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
139 139
 		);
140 140
 
141
-		if ( $date_range['period'] == 'custom' ) {
141
+		if ($date_range['period'] == 'custom') {
142 142
 			
143
-			if ( isset( $_GET['from'] ) ) {
144
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
143
+			if (isset($_GET['from'])) {
144
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
145 145
 			}
146 146
 
147
-			if ( isset( $_GET['to'] ) ) {
148
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
147
+			if (isset($_GET['to'])) {
148
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
149 149
 			}
150 150
 
151 151
 		}
152 152
 
153 153
         $i18n = array(
154
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
155
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
156
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
157
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
158
-			'rest_root'                 => esc_url_raw( rest_url() ),
154
+            'ajax_url'                  => admin_url('admin-ajax.php'),
155
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
156
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
157
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
158
+			'rest_root'                 => esc_url_raw(rest_url()),
159 159
 			'date_range'                => $date_range,
160
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
161
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
162
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
163
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
160
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
161
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
162
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
163
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
164 164
             'tax'                       => wpinv_tax_amount(),
165 165
             'discount'                  => 0,
166 166
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -169,38 +169,38 @@  discard block
 block discarded – undo
169 169
             'thousand_sep'              => wpinv_thousands_separator(),
170 170
             'decimal_sep'               => wpinv_decimal_separator(),
171 171
             'decimals'                  => wpinv_decimals(),
172
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
173
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
174
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
175
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
176
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
177
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
178
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
179
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
180
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
181
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
182
-            'action_edit'               => __( 'Edit', 'invoicing' ),
183
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
184
-            'item_description'          => __( 'Item Description', 'invoicing' ),
185
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
186
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
187
-			'searching'                 => __( 'Searching', 'invoicing' ),
188
-			'loading'                   => __( 'Loading...', 'invoicing' ),
189
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
190
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
172
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
173
+            'status_publish'            => wpinv_status_nicename('publish'),
174
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
175
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
176
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
177
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
178
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
179
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
180
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
181
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
182
+            'action_edit'               => __('Edit', 'invoicing'),
183
+            'action_cancel'             => __('Cancel', 'invoicing'),
184
+            'item_description'          => __('Item Description', 'invoicing'),
185
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
186
+            'discount_description'      => __('Discount Description', 'invoicing'),
187
+			'searching'                 => __('Searching', 'invoicing'),
188
+			'loading'                   => __('Loading...', 'invoicing'),
189
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
190
+			'search_items'              => __('Enter item name', 'invoicing'),
191 191
         );
192 192
 
193
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
193
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
194 194
 
195
-			$invoice              = new WPInv_Invoice( $post );
195
+			$invoice              = new WPInv_Invoice($post);
196 196
 			$i18n['save_invoice'] = sprintf(
197
-				__( 'Save %s', 'invoicing' ),
198
-				ucfirst( $invoice->get_invoice_quote_type() )
197
+				__('Save %s', 'invoicing'),
198
+				ucfirst($invoice->get_invoice_quote_type())
199 199
 			);
200 200
 
201 201
 			$i18n['invoice_description'] = sprintf(
202
-				__( '%s Description', 'invoicing' ),
203
-				ucfirst( $invoice->get_invoice_quote_type() )
202
+				__('%s Description', 'invoicing'),
203
+				ucfirst($invoice->get_invoice_quote_type())
204 204
 			);
205 205
 
206 206
 		}
@@ -214,24 +214,24 @@  discard block
 block discarded – undo
214 214
 	 * @param  string $footer_text
215 215
 	 * @return string
216 216
 	 */
217
-	public function admin_footer_text( $footer_text ) {
217
+	public function admin_footer_text($footer_text) {
218 218
 		global $current_screen;
219 219
 
220
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
220
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
221 221
 
222
-        if ( ! empty( $current_screen->post_type ) ) {
222
+        if (!empty($current_screen->post_type)) {
223 223
 			$page = $current_screen->post_type;
224 224
         }
225 225
 
226 226
         // General styles.
227
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
227
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
228 228
 
229 229
 			// Change the footer text
230
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
230
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
231 231
 
232
-				$rating_url  = esc_url(
232
+				$rating_url = esc_url(
233 233
 					wp_nonce_url(
234
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
234
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
235 235
 						'getpaid-nonce',
236 236
 						'getpaid-nonce'
237 237
 						)
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 				$footer_text = sprintf(
241 241
 					/* translators: %s: five stars */
242
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
242
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
243 243
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
244 244
 				);
245 245
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 				$footer_text = sprintf(
249 249
 					/* translators: %s: GetPaid */
250
-					__( 'Thank you for using %s!', 'invoicing' ),
250
+					__('Thank you for using %s!', 'invoicing'),
251 251
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
252 252
 				);
253 253
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 	 * @since  2.0.0
265 265
 	 */
266 266
 	public function redirect_to_wordpress_rating_page() {
267
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
268
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
267
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
268
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
269 269
 		exit;
270 270
 	}
271 271
 
@@ -276,30 +276,30 @@  discard block
 block discarded – undo
276 276
 	protected function load_payment_form_scripts() {
277 277
         global $post;
278 278
 
279
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
280
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
279
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
280
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
281
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
282 282
 
283
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
284
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
283
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
284
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
285 285
 
286 286
 		wp_localize_script(
287 287
             'wpinv-admin-payment-form-script',
288 288
             'wpinvPaymentFormAdmin',
289 289
             array(
290
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
291
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
290
+				'elements'      => wpinv_get_data('payment-form-elements'),
291
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
292 292
 				'currency'      => wpinv_currency_symbol(),
293 293
 				'position'      => wpinv_currency_position(),
294 294
 				'decimals'      => (int) wpinv_decimals(),
295 295
 				'thousands_sep' => wpinv_thousands_separator(),
296 296
 				'decimals_sep'  => wpinv_decimal_separator(),
297
-				'form_items'    => gepaid_get_form_items( $post->ID ),
297
+				'form_items'    => gepaid_get_form_items($post->ID),
298 298
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
299 299
             )
300 300
         );
301 301
 
302
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
302
+        wp_enqueue_script('wpinv-admin-payment-form-script');
303 303
 
304 304
     }
305 305
 
@@ -310,25 +310,25 @@  discard block
 block discarded – undo
310 310
      * @return string
311 311
 	 *
312 312
 	 */
313
-    public function admin_body_class( $classes ) {
313
+    public function admin_body_class($classes) {
314 314
 		global $pagenow, $post, $current_screen;
315 315
 
316 316
 
317
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
317
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
318 318
 
319
-        if ( ! empty( $current_screen->post_type ) ) {
319
+        if (!empty($current_screen->post_type)) {
320 320
 			$page = $current_screen->post_type;
321 321
         }
322 322
 
323
-        if ( false !== stripos( $page, 'wpi' ) ) {
324
-            $classes .= ' wpi-' . sanitize_key( $page );
323
+        if (false !== stripos($page, 'wpi')) {
324
+            $classes .= ' wpi-' . sanitize_key($page);
325 325
         }
326 326
 
327
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
327
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
328 328
             $classes .= ' wpinv-cpt wpinv';
329 329
 		}
330 330
 		
331
-		if ( getpaid_is_invoice_post_type( $page ) ) {
331
+		if (getpaid_is_invoice_post_type($page)) {
332 332
             $classes .= ' getpaid-is-invoice-cpt';
333 333
         }
334 334
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
     /**
339 339
 	 * Maybe show the AyeCode Connect Notice.
340 340
 	 */
341
-	public function init_ayecode_connect_helper(){
341
+	public function init_ayecode_connect_helper() {
342 342
 
343 343
 		// Register with the deactivation survey class.
344 344
 		AyeCode_Deactivation_Survey::instance(array(
@@ -346,20 +346,20 @@  discard block
 block discarded – undo
346 346
 			'version'	        => WPINV_VERSION,
347 347
 			'support_url'       => 'https://wpgetpaid.com/support/',
348 348
 			'documentation_url' => 'https://docs.wpgetpaid.com/',
349
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
349
+			'activated'         => (int) get_option('gepaid_installed_on'),
350 350
 		));
351 351
 
352 352
         new AyeCode_Connect_Helper(
353 353
             array(
354
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
355
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
356
-				'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>" ),
357
-				'connect_button'    => __("Connect Site","invoicing"),
358
-				'connecting_button'    => __("Connecting...","invoicing"),
359
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
360
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
354
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
355
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
356
+				'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>"),
357
+				'connect_button'    => __("Connect Site", "invoicing"),
358
+				'connecting_button'    => __("Connecting...", "invoicing"),
359
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
360
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
361 361
             ),
362
-            array( 'wpi-addons' )
362
+            array('wpi-addons')
363 363
         );
364 364
 
365 365
     }
@@ -371,20 +371,20 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	public function activation_redirect() {
373 373
 
374
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
374
+		$redirected = get_option('wpinv_redirected_to_settings');
375 375
 
376
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
376
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
377 377
 			return;
378 378
 		}
379 379
 
380 380
 		// Bail if activating from network, or bulk
381
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
381
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
382 382
 			return;
383 383
 		}
384 384
 
385
-	    update_option( 'wpinv_redirected_to_settings', 1 );
385
+	    update_option('wpinv_redirected_to_settings', 1);
386 386
 
387
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
387
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
388 388
         exit;
389 389
 
390 390
 	}
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
      */
395 395
     public function maybe_do_admin_action() {
396 396
 
397
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
398
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
399
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
397
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
398
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
399
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
400 400
         }
401 401
 
402 402
     }
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
 	 * 
407 407
 	 * @param array $args
408 408
      */
409
-    public function send_customer_invoice( $args ) {
410
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
409
+    public function send_customer_invoice($args) {
410
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
411 411
 
412
-		if ( $sent ) {
413
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
412
+		if ($sent) {
413
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
414 414
 		} else {
415
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
415
+			$this->show_error(__('Could not send the invoice to the customer', 'invoicing'));
416 416
 		}
417 417
 
418
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
418
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
419 419
 		exit;
420 420
 	}
421 421
 
@@ -424,16 +424,16 @@  discard block
 block discarded – undo
424 424
 	 * 
425 425
 	 * @param array $args
426 426
      */
427
-    public function send_customer_payment_reminder( $args ) {
428
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
427
+    public function send_customer_payment_reminder($args) {
428
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
429 429
 
430
-		if ( $sent ) {
431
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
430
+		if ($sent) {
431
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
432 432
 		} else {
433
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
433
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
434 434
 		}
435 435
 
436
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
436
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
437 437
 		exit;
438 438
 	}
439 439
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
      */
444 444
     public function admin_reset_tax_rates() {
445 445
 
446
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
447
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
446
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
447
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
448 448
 		exit;
449 449
 
450 450
 	}
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
     public function admin_create_missing_pages() {
457 457
 		$installer = new GetPaid_Installer();
458 458
 		$installer->create_pages();
459
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
460
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
459
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
460
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
461 461
 		exit;
462 462
 	}
463 463
 
@@ -469,35 +469,35 @@  discard block
 block discarded – undo
469 469
 		global $wpdb;
470 470
 		$installer = new GetPaid_Installer();
471 471
 
472
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
472
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
473 473
 			$installer->create_subscriptions_table();
474 474
 
475
-			if ( $wpdb->last_error !== '' ) {
476
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
475
+			if ($wpdb->last_error !== '') {
476
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
477 477
 			}
478 478
 		}
479 479
 
480
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
480
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
481 481
 			$installer->create_invoices_table();
482 482
 
483
-			if ( $wpdb->last_error !== '' ) {
484
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
483
+			if ($wpdb->last_error !== '') {
484
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
485 485
 			}
486 486
 		}
487 487
 
488
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
488
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
489 489
 			$installer->create_invoice_items_table();
490 490
 
491
-			if ( $wpdb->last_error !== '' ) {
492
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
491
+			if ($wpdb->last_error !== '') {
492
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
493 493
 			}
494 494
 		}
495 495
 
496
-		if ( ! $this->has_notices() ) {
497
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
496
+		if (!$this->has_notices()) {
497
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
498 498
 		}
499 499
 
500
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
500
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
501 501
 		exit;
502 502
 	}
503 503
 
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
 		$installer->migrate_old_invoices();
513 513
 
514 514
 		// Show an admin message.
515
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
515
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
516 516
 
517 517
 		// Redirect the admin.
518
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
518
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
519 519
 		exit;
520 520
 
521 521
 	}
@@ -527,18 +527,18 @@  discard block
 block discarded – undo
527 527
     public function admin_download_customers() {
528 528
 		global $wpdb;
529 529
 
530
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
530
+		$output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing'));
531 531
 
532
-		header( "Content-Type:text/csv" );
533
-		header( "Content-Disposition:attachment;filename=customers.csv" );
532
+		header("Content-Type:text/csv");
533
+		header("Content-Disposition:attachment;filename=customers.csv");
534 534
 
535 535
 		$post_types = '';
536 536
 
537
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
538
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
537
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
538
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
539 539
 		}
540 540
 
541
-		$post_types = rtrim( $post_types, ' OR' );
541
+		$post_types = rtrim($post_types, ' OR');
542 542
 
543 543
 		$customers = $wpdb->get_col(
544 544
 			$wpdb->prepare(
@@ -547,57 +547,57 @@  discard block
 block discarded – undo
547 547
 		);
548 548
 
549 549
 		$columns = array(
550
-			'name'     => __( 'Name', 'invoicing' ),
551
-			'email'    => __( 'Email', 'invoicing' ),
552
-			'country'  => __( 'Country', 'invoicing' ),
553
-			'state'    => __( 'State', 'invoicing' ),
554
-			'city'     => __( 'City', 'invoicing' ),
555
-			'zip'      => __( 'ZIP', 'invoicing' ),
556
-			'address'  => __( 'Address', 'invoicing' ),
557
-			'phone'    => __( 'Phone', 'invoicing' ),
558
-			'company'  => __( 'Company', 'invoicing' ),
559
-			'invoices' => __( 'Invoices', 'invoicing' ),
560
-			'total'    => __( 'Total Spend', 'invoicing' ),
561
-			'signup'   => __( 'Date created', 'invoicing' ),
550
+			'name'     => __('Name', 'invoicing'),
551
+			'email'    => __('Email', 'invoicing'),
552
+			'country'  => __('Country', 'invoicing'),
553
+			'state'    => __('State', 'invoicing'),
554
+			'city'     => __('City', 'invoicing'),
555
+			'zip'      => __('ZIP', 'invoicing'),
556
+			'address'  => __('Address', 'invoicing'),
557
+			'phone'    => __('Phone', 'invoicing'),
558
+			'company'  => __('Company', 'invoicing'),
559
+			'invoices' => __('Invoices', 'invoicing'),
560
+			'total'    => __('Total Spend', 'invoicing'),
561
+			'signup'   => __('Date created', 'invoicing'),
562 562
 		);
563 563
 
564 564
 		// Output the csv column headers.
565
-		fputcsv( $output, array_values( $columns ) );
565
+		fputcsv($output, array_values($columns));
566 566
 
567 567
 		// Loop through
568 568
 		$table = new WPInv_Customers_Table();
569
-		foreach ( $customers as $customer_id ) {
569
+		foreach ($customers as $customer_id) {
570 570
 
571
-			$user = get_user_by( 'id', $customer_id );
571
+			$user = get_user_by('id', $customer_id);
572 572
 			$row  = array();
573
-			if ( empty( $user ) ) {
573
+			if (empty($user)) {
574 574
 				continue;
575 575
 			}
576 576
 
577
-			foreach ( array_keys( $columns ) as $column ) {
577
+			foreach (array_keys($columns) as $column) {
578 578
 
579 579
 				$method = 'column_' . $column;
580 580
 
581
-				if ( 'name' == $column ) {
582
-					$value = sanitize_text_field( $user->display_name );
583
-				} else if( 'email' == $column ) {
584
-					$value = sanitize_email( $user->user_email );
585
-				} else if ( is_callable( array( $table, $method ) ) ) {
586
-					$value = strip_tags( $table->$method( $user ) );
581
+				if ('name' == $column) {
582
+					$value = sanitize_text_field($user->display_name);
583
+				} else if ('email' == $column) {
584
+					$value = sanitize_email($user->user_email);
585
+				} else if (is_callable(array($table, $method))) {
586
+					$value = strip_tags($table->$method($user));
587 587
 				}
588 588
 
589
-				if ( empty( $value ) ) {
590
-					$value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
589
+				if (empty($value)) {
590
+					$value = sanitize_text_field(get_user_meta($user->ID, '_wpinv_' . $column, true));
591 591
 				}
592 592
 
593 593
 				$row[] = $value;
594 594
 
595 595
 			}
596 596
 
597
-			fputcsv( $output, $row );
597
+			fputcsv($output, $row);
598 598
 		}
599 599
 
600
-		fclose( $output );
600
+		fclose($output);
601 601
 		exit;
602 602
 
603 603
 	}
@@ -607,29 +607,29 @@  discard block
 block discarded – undo
607 607
 	 *
608 608
 	 * @param array $data
609 609
      */
610
-    public function admin_install_plugin( $data ) {
610
+    public function admin_install_plugin($data) {
611 611
 
612
-		if ( ! empty( $data['plugins'] ) ) {
612
+		if (!empty($data['plugins'])) {
613 613
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
614 614
 			wp_cache_flush();
615 615
 
616
-			foreach ( $data['plugins'] as $slug => $file ) {
617
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
618
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
619
-				$installed  = $upgrader->install( $plugin_zip );
616
+			foreach ($data['plugins'] as $slug => $file) {
617
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
618
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
619
+				$installed  = $upgrader->install($plugin_zip);
620 620
 
621
-				if ( ! is_wp_error( $installed ) && $installed ) {
622
-					activate_plugin( $file, '', false, true );
621
+				if (!is_wp_error($installed) && $installed) {
622
+					activate_plugin($file, '', false, true);
623 623
 				} else {
624
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
624
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
625 625
 				}
626 626
 
627 627
 			}
628 628
 
629 629
 		}
630 630
 
631
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
632
-		wp_safe_redirect( $redirect );
631
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
632
+		wp_safe_redirect($redirect);
633 633
 		exit;
634 634
 
635 635
 	}
@@ -639,39 +639,39 @@  discard block
 block discarded – undo
639 639
 	 *
640 640
 	 * @param array $data
641 641
      */
642
-    public function admin_connect_gateway( $data ) {
642
+    public function admin_connect_gateway($data) {
643 643
 
644
-		if ( ! empty( $data['plugin'] ) ) {
644
+		if (!empty($data['plugin'])) {
645 645
 
646
-			$gateway     = sanitize_key( $data['plugin'] );
647
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
646
+			$gateway     = sanitize_key($data['plugin']);
647
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
648 648
 
649
-			if ( ! empty( $connect_url ) ) {
650
-				wp_redirect( $connect_url );
649
+			if (!empty($connect_url)) {
650
+				wp_redirect($connect_url);
651 651
 				exit;
652 652
 			}
653 653
 
654
-			if ( 'stripe' == $data['plugin'] ) {
654
+			if ('stripe' == $data['plugin']) {
655 655
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
656 656
 
657
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
658
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
659
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
660
-					$upgrader->install( $plugin_zip );
657
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
658
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
659
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
660
+					$upgrader->install($plugin_zip);
661 661
 				}
662 662
 
663
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
663
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
664 664
 			}
665 665
 
666
-			if ( ! empty( $connect_url ) ) {
667
-				wp_redirect( $connect_url );
666
+			if (!empty($connect_url)) {
667
+				wp_redirect($connect_url);
668 668
 				exit;
669 669
 			}
670 670
 
671 671
 		}
672 672
 
673
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
674
-		wp_safe_redirect( $redirect );
673
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
674
+		wp_safe_redirect($redirect);
675 675
 		exit;
676 676
 
677 677
 	}
@@ -685,36 +685,36 @@  discard block
 block discarded – undo
685 685
 
686 686
 		// Fetch all invoices that have discount codes.
687 687
 		$table    = $wpdb->prefix . 'getpaid_invoices';
688
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
688
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
689 689
 
690
-		foreach ( $invoices as $invoice ) {
690
+		foreach ($invoices as $invoice) {
691 691
 
692
-			$invoice = new WPInv_Invoice( $invoice );
692
+			$invoice = new WPInv_Invoice($invoice);
693 693
 
694
-			if ( ! $invoice->exists() ) {
694
+			if (!$invoice->exists()) {
695 695
 				continue;
696 696
 			}
697 697
 
698 698
 			// Abort if the discount does not exist or does not apply here.
699
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
700
-			if ( ! $discount->exists() ) {
699
+			$discount = new WPInv_Discount($invoice->get_discount_code());
700
+			if (!$discount->exists()) {
701 701
 				continue;
702 702
 			}
703 703
 
704
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
704
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
705 705
 			$invoice->recalculate_total();
706 706
 
707
-			if ( $invoice->get_total_discount() > 0 ) {
707
+			if ($invoice->get_total_discount() > 0) {
708 708
 				$invoice->save();
709 709
 			}
710 710
 
711 711
 		}
712 712
 
713 713
 		// Show an admin message.
714
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
714
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
715 715
 
716 716
 		// Redirect the admin.
717
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
717
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
718 718
 		exit;
719 719
 
720 720
 	}
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
      * @return array
727 727
 	 */
728 728
 	public function get_notices() {
729
-		$notices = get_option( 'wpinv_admin_notices' );
730
-        return is_array( $notices ) ? $notices : array();
729
+		$notices = get_option('wpinv_admin_notices');
730
+        return is_array($notices) ? $notices : array();
731 731
 	}
732 732
 
733 733
 	/**
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
      * @return array
738 738
 	 */
739 739
 	public function has_notices() {
740
-		return count( $this->get_notices() ) > 0;
740
+		return count($this->get_notices()) > 0;
741 741
 	}
742 742
 
743 743
 	/**
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 	 * @since       1.0.19
748 748
 	 */
749 749
 	public function clear_notices() {
750
-		delete_option( 'wpinv_admin_notices' );
750
+		delete_option('wpinv_admin_notices');
751 751
 	}
752 752
 
753 753
 	/**
@@ -756,16 +756,16 @@  discard block
 block discarded – undo
756 756
 	 * @access      public
757 757
 	 * @since       1.0.19
758 758
 	 */
759
-	public function save_notice( $type, $message ) {
759
+	public function save_notice($type, $message) {
760 760
 		$notices = $this->get_notices();
761 761
 
762
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
763
-			$notices[ $type ] = array();
762
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
763
+			$notices[$type] = array();
764 764
 		}
765 765
 
766
-		$notices[ $type ][] = $message;
766
+		$notices[$type][] = $message;
767 767
 
768
-		update_option( 'wpinv_admin_notices', $notices );
768
+		update_option('wpinv_admin_notices', $notices);
769 769
 	}
770 770
 
771 771
 	/**
@@ -775,8 +775,8 @@  discard block
 block discarded – undo
775 775
 	 * @access      public
776 776
 	 * @since       1.0.19
777 777
 	 */
778
-	public function show_success( $msg ) {
779
-		$this->save_notice( 'success', $msg );
778
+	public function show_success($msg) {
779
+		$this->save_notice('success', $msg);
780 780
 	}
781 781
 
782 782
 	/**
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
 	 * @param       string $msg The message to qeue.
787 787
 	 * @since       1.0.19
788 788
 	 */
789
-	public function show_error( $msg ) {
790
-		$this->save_notice( 'error', $msg );
789
+	public function show_error($msg) {
790
+		$this->save_notice('error', $msg);
791 791
 	}
792 792
 
793 793
 	/**
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
 	 * @param       string $msg The message to qeue.
798 798
 	 * @since       1.0.19
799 799
 	 */
800
-	public function show_warning( $msg ) {
801
-		$this->save_notice( 'warning', $msg );
800
+	public function show_warning($msg) {
801
+		$this->save_notice('warning', $msg);
802 802
 	}
803 803
 
804 804
 	/**
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 	 * @param       string $msg The message to qeue.
809 809
 	 * @since       1.0.19
810 810
 	 */
811
-	public function show_info( $msg ) {
812
-		$this->save_notice( 'info', $msg );
811
+	public function show_info($msg) {
812
+		$this->save_notice('info', $msg);
813 813
 	}
814 814
 
815 815
 	/**
@@ -823,30 +823,30 @@  discard block
 block discarded – undo
823 823
         $notices = $this->get_notices();
824 824
         $this->clear_notices();
825 825
 
826
-		foreach ( $notices as $type => $messages ) {
826
+		foreach ($notices as $type => $messages) {
827 827
 
828
-			if ( ! is_array( $messages ) ) {
828
+			if (!is_array($messages)) {
829 829
 				continue;
830 830
 			}
831 831
 
832
-            $type  = sanitize_key( $type );
833
-			foreach ( $messages as $message ) {
834
-                $message = wp_kses_post( $message );
832
+            $type = sanitize_key($type);
833
+			foreach ($messages as $message) {
834
+                $message = wp_kses_post($message);
835 835
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
836 836
             }
837 837
 
838 838
         }
839 839
 
840
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
840
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
841 841
 
842
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
843
-				$url     = wp_nonce_url(
844
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
842
+			if (!is_numeric(wpinv_get_option($page, false))) {
843
+				$url = wp_nonce_url(
844
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
845 845
 					'getpaid-nonce',
846 846
 					'getpaid-nonce'
847 847
 				);
848
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
849
-				$message2 = __( 'Generate Pages', 'invoicing' );
848
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
849
+				$message2 = __('Generate Pages', 'invoicing');
850 850
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
851 851
 				break;
852 852
 			}
Please login to merge, or discard this patch.
invoicing.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.4.0' );
26
+    define( 'WPINV_VERSION', '2.4.0' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @package GetPaid
16 16
  */
17 17
 
18
-defined( 'ABSPATH' ) || exit;
18
+defined('ABSPATH') || exit;
19 19
 
20 20
 // Define constants.
21
-if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+	define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.4.0' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.4.0');
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30
-if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
30
+if (!class_exists('WPInv_Plugin', false)) {
31
+	require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function getpaid() {
41 41
 
42
-    if ( empty( $GLOBALS['invoicing'] ) ) {
42
+    if (empty($GLOBALS['invoicing'])) {
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
  * @since  2.0.8
53 53
  */
54 54
 function getpaid_deactivation_hook() {
55
-    update_option( 'wpinv_flush_permalinks', 1 );
55
+    update_option('wpinv_flush_permalinks', 1);
56 56
 }
57
-register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' );
57
+register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook');
58 58
 
59 59
 /**
60 60
  * @deprecated
@@ -64,4 +64,4 @@  discard block
 block discarded – undo
64 64
 }
65 65
 
66 66
 // Kickstart the plugin.
67
-add_action( 'plugins_loaded', 'getpaid', -100 );
67
+add_action('plugins_loaded', 'getpaid', -100);
Please login to merge, or discard this patch.
includes/admin/register-settings.php 2 patches
Indentation   +301 added lines, -301 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,18 +263,18 @@  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 );
274 274
 
275
-	if ( in_array( 'gp-setup', $referrer ) ) {
276
-		return array_merge( $wpinv_options, $input );
277
-	}
275
+    if ( in_array( 'gp-setup', $referrer ) ) {
276
+        return array_merge( $wpinv_options, $input );
277
+    }
278 278
 
279 279
     $settings = wpinv_get_registered_settings();
280 280
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
         }
297 297
 
298 298
         // General filter
299
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
299
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
300 300
 
301
-		// Key specific filter.
302
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
301
+        // Key specific filter.
302
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
303 303
     }
304 304
 
305 305
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 
343 343
     foreach ( $new_rates as $rate ) {
344 344
 
345
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
346
-		$rate['name']    = sanitize_text_field( $rate['name'] );
347
-		$rate['state']   = sanitize_text_field( $rate['state'] );
348
-		$rate['country'] = sanitize_text_field( $rate['country'] );
349
-		$rate['global']  = empty( $rate['state'] );
350
-		$tax_rates[]     = $rate;
345
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
346
+        $rate['name']    = sanitize_text_field( $rate['name'] );
347
+        $rate['state']   = sanitize_text_field( $rate['state'] );
348
+        $rate['country'] = sanitize_text_field( $rate['country'] );
349
+        $rate['global']  = empty( $rate['state'] );
350
+        $tax_rates[]     = $rate;
351 351
 
352
-	}
352
+    }
353 353
 
354 354
     update_option( 'wpinv_tax_rates', $tax_rates );
355 355
 
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
     $tabs['general']  = __( 'General', 'invoicing' );
363 363
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
364 364
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
365
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
365
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
366 366
 
367
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
368
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
369
-	}
367
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
368
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
369
+    }
370 370
 
371 371
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
372 372
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -405,14 +405,14 @@  discard block
 block discarded – undo
405 405
         ) ),
406 406
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
407 407
             'main'  => __( 'Tax Settings', 'invoicing' ),
408
-			'rates' => __( 'Tax Rates', 'invoicing' ),
409
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
408
+            'rates' => __( 'Tax Rates', 'invoicing' ),
409
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
410 410
         ) ),
411 411
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
412 412
             'main' => __( 'Email Settings', 'invoicing' ),
413
-		) ),
413
+        ) ),
414 414
 
415
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
415
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
416 416
 
417 417
         'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
418 418
             'main' => __( 'Privacy policy', 'invoicing' ),
@@ -432,48 +432,48 @@  discard block
 block discarded – undo
432 432
 }
433 433
 
434 434
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
435
-	$pages_options = array();
435
+    $pages_options = array();
436 436
 
437
-	if( $default_label !== NULL && $default_label !== false ) {
438
-		$pages_options = array( '' => $default_label ); // Blank option
439
-	}
437
+    if( $default_label !== NULL && $default_label !== false ) {
438
+        $pages_options = array( '' => $default_label ); // Blank option
439
+    }
440 440
 
441
-	$pages = get_pages();
442
-	if ( $pages ) {
443
-		foreach ( $pages as $page ) {
444
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
441
+    $pages = get_pages();
442
+    if ( $pages ) {
443
+        foreach ( $pages as $page ) {
444
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
445 445
             $pages_options[ $page->ID ] = $title;
446
-		}
447
-	}
446
+        }
447
+    }
448 448
 
449
-	return $pages_options;
449
+    return $pages_options;
450 450
 }
451 451
 
452 452
 function wpinv_header_callback( $args ) {
453
-	if ( !empty( $args['desc'] ) ) {
453
+    if ( !empty( $args['desc'] ) ) {
454 454
         echo $args['desc'];
455 455
     }
456 456
 }
457 457
 
458 458
 function wpinv_hidden_callback( $args ) {
459 459
 
460
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
461
-	$value   = wpinv_get_option( $args['id'], $std );
460
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
461
+    $value   = wpinv_get_option( $args['id'], $std );
462 462
 
463
-	if ( isset( $args['set_value'] ) ) {
464
-		$value = $args['set_value'];
465
-	}
463
+    if ( isset( $args['set_value'] ) ) {
464
+        $value = $args['set_value'];
465
+    }
466 466
 
467
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
468
-		$args['readonly'] = true;
469
-		$name  = '';
470
-	} else {
471
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
472
-	}
467
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
468
+        $args['readonly'] = true;
469
+        $name  = '';
470
+    } else {
471
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
472
+    }
473 473
 
474
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
474
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
475 475
     
476
-	echo $html;
476
+    echo $html;
477 477
 }
478 478
 
479 479
 /**
@@ -481,12 +481,12 @@  discard block
 block discarded – undo
481 481
  */
482 482
 function wpinv_checkbox_callback( $args ) {
483 483
 
484
-	$std = isset( $args['std'] ) ? $args['std'] : '';
485
-	$std = wpinv_get_option( $args['id'], $std );
486
-	$id  = esc_attr( $args['id'] );
484
+    $std = isset( $args['std'] ) ? $args['std'] : '';
485
+    $std = wpinv_get_option( $args['id'], $std );
486
+    $id  = esc_attr( $args['id'] );
487 487
 
488
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
489
-	?>
488
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
489
+    ?>
490 490
 		<fieldset>
491 491
 			<label>
492 492
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -498,75 +498,75 @@  discard block
 block discarded – undo
498 498
 
499 499
 function wpinv_multicheck_callback( $args ) {
500 500
 
501
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
502
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
501
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
502
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
503 503
 
504
-	if ( ! empty( $args['options'] ) ) {
504
+    if ( ! empty( $args['options'] ) ) {
505 505
 
506
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
507
-		$value   = wpinv_get_option( $args['id'], $std );
506
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
507
+        $value   = wpinv_get_option( $args['id'], $std );
508 508
 
509
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
509
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
510 510
         foreach( $args['options'] as $key => $option ):
511
-			$sanitize_key = wpinv_sanitize_key( $key );
512
-			if ( in_array( $sanitize_key, $value ) ) { 
513
-				$enabled = $sanitize_key;
514
-			} else { 
515
-				$enabled = NULL; 
516
-			}
517
-			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;';
518
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
519
-		endforeach;
520
-		echo '</div>';
521
-		echo '<p class="description">' . $args['desc'] . '</p>';
522
-	}
511
+            $sanitize_key = wpinv_sanitize_key( $key );
512
+            if ( in_array( $sanitize_key, $value ) ) { 
513
+                $enabled = $sanitize_key;
514
+            } else { 
515
+                $enabled = NULL; 
516
+            }
517
+            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;';
518
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
519
+        endforeach;
520
+        echo '</div>';
521
+        echo '<p class="description">' . $args['desc'] . '</p>';
522
+    }
523 523
 }
524 524
 
525 525
 function wpinv_payment_icons_callback( $args ) {
526 526
     
527 527
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
528
-	$value   = wpinv_get_option( $args['id'], false);
528
+    $value   = wpinv_get_option( $args['id'], false);
529 529
 
530
-	if ( ! empty( $args['options'] ) ) {
531
-		foreach( $args['options'] as $key => $option ) {
530
+    if ( ! empty( $args['options'] ) ) {
531
+        foreach( $args['options'] as $key => $option ) {
532 532
             $sanitize_key = wpinv_sanitize_key( $key );
533 533
             
534
-			if( empty( $value ) ) {
535
-				$enabled = $option;
536
-			} else {
537
-				$enabled = NULL;
538
-			}
539
-
540
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
541
-
542
-				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;';
543
-
544
-				if ( wpinv_string_is_image_url( $key ) ) {
545
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
546
-				} else {
547
-					$card = strtolower( str_replace( ' ', '', $option ) );
548
-
549
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
550
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
551
-					} else {
552
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
553
-						$content_dir = WP_CONTENT_DIR;
554
-
555
-						if ( function_exists( 'wp_normalize_path' ) ) {
556
-							// Replaces backslashes with forward slashes for Windows systems
557
-							$image = wp_normalize_path( $image );
558
-							$content_dir = wp_normalize_path( $content_dir );
559
-						}
560
-
561
-						$image = str_replace( $content_dir, content_url(), $image );
562
-					}
563
-
564
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565
-				}
566
-			echo $option . '</label>';
567
-		}
568
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
569
-	}
534
+            if( empty( $value ) ) {
535
+                $enabled = $option;
536
+            } else {
537
+                $enabled = NULL;
538
+            }
539
+
540
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
541
+
542
+                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;';
543
+
544
+                if ( wpinv_string_is_image_url( $key ) ) {
545
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
546
+                } else {
547
+                    $card = strtolower( str_replace( ' ', '', $option ) );
548
+
549
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
550
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
551
+                    } else {
552
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
553
+                        $content_dir = WP_CONTENT_DIR;
554
+
555
+                        if ( function_exists( 'wp_normalize_path' ) ) {
556
+                            // Replaces backslashes with forward slashes for Windows systems
557
+                            $image = wp_normalize_path( $image );
558
+                            $content_dir = wp_normalize_path( $content_dir );
559
+                        }
560
+
561
+                        $image = str_replace( $content_dir, content_url(), $image );
562
+                    }
563
+
564
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565
+                }
566
+            echo $option . '</label>';
567
+        }
568
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
569
+    }
570 570
 }
571 571
 
572 572
 /**
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
  */
575 575
 function wpinv_radio_callback( $args ) {
576 576
 
577
-	$std = isset( $args['std'] ) ? $args['std'] : '';
578
-	$std = wpinv_get_option( $args['id'], $std );
579
-	?>
577
+    $std = isset( $args['std'] ) ? $args['std'] : '';
578
+    $std = wpinv_get_option( $args['id'], $std );
579
+    ?>
580 580
 		<fieldset>
581 581
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
582 582
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 			</ul>
591 591
 		</fieldset>
592 592
 	<?php
593
-	getpaid_settings_description_callback( $args );
593
+    getpaid_settings_description_callback( $args );
594 594
 }
595 595
 
596 596
 /**
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
  */
599 599
 function getpaid_settings_description_callback( $args ) {
600 600
 
601
-	if ( ! empty( $args['desc'] ) ) {
602
-		$description = wp_kses_post( $args['desc'] );
603
-		echo "<p class='description'>$description</p>";
604
-	}
601
+    if ( ! empty( $args['desc'] ) ) {
602
+        $description = wp_kses_post( $args['desc'] );
603
+        echo "<p class='description'>$description</p>";
604
+    }
605 605
 
606 606
 }
607 607
 
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
  */
611 611
 function wpinv_gateways_callback() {
612 612
 
613
-	?>
613
+    ?>
614 614
 		</td>
615 615
 	</tr>
616 616
 	<tr class="bsui">
@@ -624,22 +624,22 @@  discard block
 block discarded – undo
624 624
     
625 625
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
626 626
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
627
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
628
-	$value   = wpinv_get_option( $args['id'], $std );
627
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
628
+    $value   = wpinv_get_option( $args['id'], $std );
629 629
 
630
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
630
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
631 631
 
632
-	foreach ( $args['options'] as $key => $option ) :
633
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
632
+    foreach ( $args['options'] as $key => $option ) :
633
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
634 634
             $selected = selected( $key, $args['selected'], false );
635 635
         } else {
636 636
             $selected = selected( $key, $value, false );
637 637
         }
638
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
639
-	endforeach;
638
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
639
+    endforeach;
640 640
 
641
-	echo '</select>';
642
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
641
+    echo '</select>';
642
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
643 643
 }
644 644
 
645 645
 /**
@@ -650,29 +650,29 @@  discard block
 block discarded – undo
650 650
  */
651 651
 function wpinv_settings_attrs_helper( $args ) {
652 652
 
653
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
654
-	$id           = esc_attr( $args['id'] );
655
-	$placeholder  = esc_attr( $args['placeholder'] );
653
+    $value        = isset( $args['std'] ) ? $args['std'] : '';
654
+    $id           = esc_attr( $args['id'] );
655
+    $placeholder  = esc_attr( $args['placeholder'] );
656 656
 
657
-	if ( ! empty( $args['faux'] ) ) {
658
-		$args['readonly'] = true;
659
-		$name             = '';
660
-	} else {
661
-		$value  = wpinv_get_option( $args['id'], $value );
662
-		$name   = "wpinv_settings[$id]";
663
-	}
657
+    if ( ! empty( $args['faux'] ) ) {
658
+        $args['readonly'] = true;
659
+        $name             = '';
660
+    } else {
661
+        $value  = wpinv_get_option( $args['id'], $value );
662
+        $name   = "wpinv_settings[$id]";
663
+    }
664 664
 
665
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
666
-	$class    = esc_attr( $args['class'] );
667
-	$style    = esc_attr( $args['style'] );
668
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
665
+    $value    = is_scalar( $value ) ? esc_attr( $value ) : '';
666
+    $class    = esc_attr( $args['class'] );
667
+    $style    = esc_attr( $args['style'] );
668
+    $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
669 669
 
670
-	$onchange = '';
670
+    $onchange = '';
671 671
     if ( ! empty( $args['onchange'] ) ) {
672 672
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
673
-	}
673
+    }
674 674
 
675
-	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
675
+    return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
676 676
 }
677 677
 
678 678
 /**
@@ -680,11 +680,11 @@  discard block
 block discarded – undo
680 680
  */
681 681
 function wpinv_text_callback( $args ) {
682 682
 
683
-	$desc = wp_kses_post( $args['desc'] );
684
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
685
-	$attr = wpinv_settings_attrs_helper( $args );
683
+    $desc = wp_kses_post( $args['desc'] );
684
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
685
+    $attr = wpinv_settings_attrs_helper( $args );
686 686
 
687
-	?>
687
+    ?>
688 688
 		<label style="width: 100%;">
689 689
 			<input type="text" <?php echo $attr; ?>>
690 690
 			<?php echo $desc; ?>
@@ -698,14 +698,14 @@  discard block
 block discarded – undo
698 698
  */
699 699
 function wpinv_number_callback( $args ) {
700 700
 
701
-	$desc = wp_kses_post( $args['desc'] );
702
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
703
-	$attr = wpinv_settings_attrs_helper( $args );
704
-	$max  = intval( $args['max'] );
705
-	$min  = intval( $args['min'] );
706
-	$step = floatval( $args['step'] );
701
+    $desc = wp_kses_post( $args['desc'] );
702
+    $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
703
+    $attr = wpinv_settings_attrs_helper( $args );
704
+    $max  = intval( $args['max'] );
705
+    $min  = intval( $args['min'] );
706
+    $step = floatval( $args['step'] );
707 707
 
708
-	?>
708
+    ?>
709 709
 		<label style="width: 100%;">
710 710
 			<input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>>
711 711
 			<?php echo $desc; ?>
@@ -717,36 +717,36 @@  discard block
 block discarded – undo
717 717
 function wpinv_textarea_callback( $args ) {
718 718
     
719 719
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
720
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
721
-	$value   = wpinv_get_option( $args['id'], $std );
720
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
721
+    $value   = wpinv_get_option( $args['id'], $std );
722 722
 
723 723
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
724 724
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
725 725
 
726
-	$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>';
727
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
726
+    $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>';
727
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
728 728
 
729
-	echo $html;
729
+    echo $html;
730 730
 }
731 731
 
732 732
 function wpinv_password_callback( $args ) {
733 733
     
734 734
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
735
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
736
-	$value   = wpinv_get_option( $args['id'], $std );
735
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
736
+    $value   = wpinv_get_option( $args['id'], $std );
737 737
 
738
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
739
-	$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 ) . '"/>';
740
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
738
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
739
+    $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 ) . '"/>';
740
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
741 741
 
742
-	echo $html;
742
+    echo $html;
743 743
 }
744 744
 
745 745
 function wpinv_missing_callback($args) {
746
-	printf(
747
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
748
-		'<strong>' . $args['id'] . '</strong>'
749
-	);
746
+    printf(
747
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
748
+        '<strong>' . $args['id'] . '</strong>'
749
+    );
750 750
 }
751 751
 
752 752
 /**
@@ -754,14 +754,14 @@  discard block
 block discarded – undo
754 754
  */
755 755
 function wpinv_select_callback( $args ) {
756 756
 
757
-	$desc   = wp_kses_post( $args['desc'] );
758
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
759
-	$attr   = wpinv_settings_attrs_helper( $args );
760
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
761
-	$value  = wpinv_get_option( $args['id'], $value );
762
-	$rand   = uniqid( 'random_id' );
757
+    $desc   = wp_kses_post( $args['desc'] );
758
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
759
+    $attr   = wpinv_settings_attrs_helper( $args );
760
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
761
+    $value  = wpinv_get_option( $args['id'], $value );
762
+    $rand   = uniqid( 'random_id' );
763 763
 
764
-	?>
764
+    ?>
765 765
 		<label style="width: 100%;">
766 766
 			<select <?php echo $attr; ?>>
767 767
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -794,104 +794,104 @@  discard block
 block discarded – undo
794 794
 function wpinv_color_select_callback( $args ) {
795 795
     
796 796
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
797
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
798
-	$value   = wpinv_get_option( $args['id'], $std );
797
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
798
+    $value   = wpinv_get_option( $args['id'], $std );
799 799
 
800
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
800
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
801 801
 
802
-	foreach ( $args['options'] as $option => $color ) {
803
-		$selected = selected( $option, $value, false );
804
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
805
-	}
802
+    foreach ( $args['options'] as $option => $color ) {
803
+        $selected = selected( $option, $value, false );
804
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
805
+    }
806 806
 
807
-	$html .= '</select>';
808
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
807
+    $html .= '</select>';
808
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
809 809
 
810
-	echo $html;
810
+    echo $html;
811 811
 }
812 812
 
813 813
 function wpinv_rich_editor_callback( $args ) {
814
-	global $wp_version;
814
+    global $wp_version;
815 815
     
816 816
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
817 817
 
818
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
819
-	$value   = wpinv_get_option( $args['id'], $std );
818
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
819
+    $value   = wpinv_get_option( $args['id'], $std );
820 820
 	
821
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
822
-		$value = $std;
823
-	}
821
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
822
+        $value = $std;
823
+    }
824 824
 
825
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
825
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
826 826
 
827
-	$html = '<div class="getpaid-settings-editor-input">';
828
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
829
-		ob_start();
830
-		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 ) );
831
-		$html .= ob_get_clean();
832
-	} else {
833
-		$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>';
834
-	}
827
+    $html = '<div class="getpaid-settings-editor-input">';
828
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
829
+        ob_start();
830
+        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 ) );
831
+        $html .= ob_get_clean();
832
+    } else {
833
+        $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>';
834
+    }
835 835
 
836
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
836
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
837 837
 
838
-	echo $html;
838
+    echo $html;
839 839
 }
840 840
 
841 841
 function wpinv_upload_callback( $args ) {
842 842
     
843 843
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
844 844
 
845
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
846
-	$value   = wpinv_get_option( $args['id'], $std );
845
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
846
+    $value   = wpinv_get_option( $args['id'], $std );
847 847
 
848
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
849
-	$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 ) ) . '"/>';
850
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
851
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
848
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
849
+    $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 ) ) . '"/>';
850
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
851
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
852 852
 
853
-	echo $html;
853
+    echo $html;
854 854
 }
855 855
 
856 856
 function wpinv_color_callback( $args ) {
857 857
 
858
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
859
-	$value       = wpinv_get_option( $args['id'], $std );
858
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
859
+    $value       = wpinv_get_option( $args['id'], $std );
860 860
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
861 861
 
862
-	$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 ) . '" />';
863
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
862
+    $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 ) . '" />';
863
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
864 864
 
865
-	echo $html;
865
+    echo $html;
866 866
 }
867 867
 
868 868
 function wpinv_country_states_callback($args) {
869 869
 
870
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
871
-	$value   = wpinv_get_option( $args['id'], $std );
870
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
871
+    $value   = wpinv_get_option( $args['id'], $std );
872 872
 
873 873
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
874 874
 
875
-	if ( isset( $args['placeholder'] ) ) {
876
-		$placeholder = $args['placeholder'];
877
-	} else {
878
-		$placeholder = '';
879
-	}
875
+    if ( isset( $args['placeholder'] ) ) {
876
+        $placeholder = $args['placeholder'];
877
+    } else {
878
+        $placeholder = '';
879
+    }
880 880
 
881
-	$states = wpinv_get_country_states();
881
+    $states = wpinv_get_country_states();
882 882
 
883
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
883
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
885 885
 
886
-	foreach ( $states as $option => $name ) {
887
-		$selected = selected( $option, $value, false );
888
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
889
-	}
886
+    foreach ( $states as $option => $name ) {
887
+        $selected = selected( $option, $value, false );
888
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
889
+    }
890 890
 
891
-	$html .= '</select>';
892
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
891
+    $html .= '</select>';
892
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
893 893
 
894
-	echo $html;
894
+    echo $html;
895 895
 }
896 896
 
897 897
 /**
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
  */
900 900
 function wpinv_tax_rates_callback() {
901 901
 	
902
-	?>
902
+    ?>
903 903
 		</td>
904 904
 	</tr>
905 905
 	<tr class="bsui">
@@ -914,17 +914,17 @@  discard block
 block discarded – undo
914 914
  * Displays a tax rate' edit row.
915 915
  */
916 916
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
917
-	ob_start();
917
+    ob_start();
918 918
 
919
-	$key                      = sanitize_key( $key );
920
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
921
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
919
+    $key                      = sanitize_key( $key );
920
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
921
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
922 922
 
923
-	if ( $echo ) {
924
-		echo ob_get_clean();
925
-	} else {
926
-		return ob_get_clean(); 
927
-	}
923
+    if ( $echo ) {
924
+        echo ob_get_clean();
925
+    } else {
926
+        return ob_get_clean(); 
927
+    }
928 928
 
929 929
 }
930 930
 
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
                 </td>
953 953
                 <td>
954 954
 					<a href="<?php
955
-						echo esc_url(
956
-							wp_nonce_url(
957
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
958
-								'getpaid-nonce',
959
-								'getpaid-nonce'
960
-							)
961
-						);
962
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
955
+                        echo esc_url(
956
+                            wp_nonce_url(
957
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
958
+                                'getpaid-nonce',
959
+                                'getpaid-nonce'
960
+                            )
961
+                        );
962
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
963 963
                 </td>
964 964
             </tr>
965 965
 			<tr>
@@ -969,14 +969,14 @@  discard block
 block discarded – undo
969 969
                 </td>
970 970
                 <td>
971 971
 					<a href="<?php
972
-						echo esc_url(
973
-							wp_nonce_url(
974
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
975
-								'getpaid-nonce',
976
-								'getpaid-nonce'
977
-							)
978
-						);
979
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
972
+                        echo esc_url(
973
+                            wp_nonce_url(
974
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
975
+                                'getpaid-nonce',
976
+                                'getpaid-nonce'
977
+                            )
978
+                        );
979
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
980 980
                 </td>
981 981
             </tr>
982 982
 			<tr>
@@ -986,14 +986,14 @@  discard block
 block discarded – undo
986 986
                 </td>
987 987
                 <td>
988 988
 					<a href="<?php
989
-						echo esc_url(
990
-							wp_nonce_url(
991
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
992
-								'getpaid-nonce',
993
-								'getpaid-nonce'
994
-							)
995
-						);
996
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
989
+                        echo esc_url(
990
+                            wp_nonce_url(
991
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
992
+                                'getpaid-nonce',
993
+                                'getpaid-nonce'
994
+                            )
995
+                        );
996
+                    ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
997 997
                 </td>
998 998
             </tr>
999 999
 
@@ -1004,14 +1004,14 @@  discard block
 block discarded – undo
1004 1004
                 </td>
1005 1005
                 <td>
1006 1006
 					<a href="<?php
1007
-						echo esc_url(
1008
-							wp_nonce_url(
1009
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1010
-								'getpaid-nonce',
1011
-								'getpaid-nonce'
1012
-							)
1013
-						);
1014
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1007
+                        echo esc_url(
1008
+                            wp_nonce_url(
1009
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1010
+                                'getpaid-nonce',
1011
+                                'getpaid-nonce'
1012
+                            )
1013
+                        );
1014
+                    ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1015 1015
                 </td>
1016 1016
             </tr>
1017 1017
 
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
                 </td>
1023 1023
                 <td>
1024 1024
 					<a href="<?php
1025
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1026
-					?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a>
1025
+                        echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1026
+                    ?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a>
1027 1027
                 </td>
1028 1028
             </tr>
1029 1029
 
@@ -1037,19 +1037,19 @@  discard block
 block discarded – undo
1037 1037
 
1038 1038
 
1039 1039
 function wpinv_descriptive_text_callback( $args ) {
1040
-	echo wp_kses_post( $args['desc'] );
1040
+    echo wp_kses_post( $args['desc'] );
1041 1041
 }
1042 1042
 
1043 1043
 function wpinv_raw_html_callback( $args ) {
1044
-	echo $args['desc'];
1044
+    echo $args['desc'];
1045 1045
 }
1046 1046
 
1047 1047
 function wpinv_hook_callback( $args ) {
1048
-	do_action( 'wpinv_' . $args['id'], $args );
1048
+    do_action( 'wpinv_' . $args['id'], $args );
1049 1049
 }
1050 1050
 
1051 1051
 function wpinv_set_settings_cap() {
1052
-	return wpinv_get_capability();
1052
+    return wpinv_get_capability();
1053 1053
 }
1054 1054
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1055 1055
 
@@ -1073,15 +1073,15 @@  discard block
 block discarded – undo
1073 1073
  */
1074 1074
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1075 1075
 
1076
-	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1077
-	$link = sprintf(
1078
-		'<strong><a href="%s" target="_blank">%s</a></strong>',
1079
-		$url,
1080
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1081
-	);
1076
+    $url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1077
+    $link = sprintf(
1078
+        '<strong><a href="%s" target="_blank">%s</a></strong>',
1079
+        $url,
1080
+        esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1081
+    );
1082 1082
 
1083
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1083
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1084 1084
 
1085
-	return "$description $link";
1085
+    return "$description $link";
1086 1086
 
1087 1087
 }
Please login to merge, or discard this patch.
Spacing   +373 added lines, -373 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( empty( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (empty($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,49 +190,49 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name       = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name       = isset($option['name']) ? $option['name'] : '';
196 196
     $cb         = "wpinv_{$option['type']}_callback";
197 197
     $section    = "wpinv_settings_{$tab}_$section";
198
-	$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'] );
200
+	if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) {
201
+		$tip   = wpinv_clean($option['desc']);
202 202
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
203
-		unset( $option['desc'] );
203
+		unset($option['desc']);
204 204
 	}
205 205
 
206 206
     // Loop through all tabs.
207 207
     add_settings_field(
208 208
         'wpinv_settings[' . $option['id'] . ']',
209 209
         $name,
210
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
210
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
211 211
         $section,
212 212
         $section,
213 213
         array(
214 214
             'section'     => $section,
215
-            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
216
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
215
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
216
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
217 217
             'name'        => $name,
218
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
219
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
220
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
221
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
222
-            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
223
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
224
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
225
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
226
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
227
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
228
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
229
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
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']         : '',
234
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
235
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
218
+            'size'        => isset($option['size']) ? $option['size'] : null,
219
+            'options'     => isset($option['options']) ? $option['options'] : '',
220
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
221
+            'std'         => isset($option['std']) ? $option['std'] : '',
222
+            'min'         => isset($option['min']) ? $option['min'] : 0,
223
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
224
+            'step'        => isset($option['step']) ? $option['step'] : 1,
225
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
226
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
227
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
228
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
229
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
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'] : '',
234
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
235
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
236 236
         )
237 237
     );
238 238
 
@@ -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
 /**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
  * @return array
254 254
  */
255 255
 function getpaid_get_integration_settings() {
256
-    return apply_filters( 'getpaid_integration_settings', array() );
256
+    return apply_filters('getpaid_integration_settings', array());
257 257
 }
258 258
 
259 259
 /**
@@ -261,126 +261,126 @@  discard block
 block discarded – undo
261 261
  * 
262 262
  * @return array
263 263
  */
264
-function wpinv_settings_sanitize( $input = array() ) {
264
+function wpinv_settings_sanitize($input = array()) {
265 265
 
266 266
 	$wpinv_options = wpinv_get_options();
267 267
 	$raw_referrer  = wp_get_raw_referer();
268 268
 
269
-    if ( empty( $raw_referrer ) ) {
270
-		return array_merge( $wpinv_options, $input );
269
+    if (empty($raw_referrer)) {
270
+		return array_merge($wpinv_options, $input);
271 271
     }
272 272
 
273
-    wp_parse_str( $raw_referrer, $referrer );
273
+    wp_parse_str($raw_referrer, $referrer);
274 274
 
275
-	if ( in_array( 'gp-setup', $referrer ) ) {
276
-		return array_merge( $wpinv_options, $input );
275
+	if (in_array('gp-setup', $referrer)) {
276
+		return array_merge($wpinv_options, $input);
277 277
 	}
278 278
 
279 279
     $settings = wpinv_get_registered_settings();
280
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
281
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
280
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
281
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
282 282
 
283 283
     $input = $input ? $input : array();
284
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
285
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
284
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
285
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
286 286
 
287 287
     // Loop through each setting being saved and pass it through a sanitization filter
288
-    foreach ( $input as $key => $value ) {
288
+    foreach ($input as $key => $value) {
289 289
 
290 290
         // Get the setting type (checkbox, select, etc)
291
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
291
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
292 292
 
293
-        if ( $type ) {
293
+        if ($type) {
294 294
             // Field type specific filter
295
-            $input[$key] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key );
295
+            $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key);
296 296
         }
297 297
 
298 298
         // General filter
299
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
299
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
300 300
 
301 301
 		// Key specific filter.
302
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
302
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
303 303
     }
304 304
 
305 305
     // Loop through the whitelist and unset any that are empty for the tab being saved
306
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
307
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
306
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
307
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
308 308
 
309
-    $found_settings   = array_merge( $main_settings, $section_settings );
309
+    $found_settings   = array_merge($main_settings, $section_settings);
310 310
 
311
-    if ( ! empty( $found_settings ) ) {
312
-        foreach ( $found_settings as $key => $value ) {
311
+    if (!empty($found_settings)) {
312
+        foreach ($found_settings as $key => $value) {
313 313
 
314 314
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
315
-            if ( is_numeric( $key ) ) {
315
+            if (is_numeric($key)) {
316 316
                 $key = $value['id'];
317 317
             }
318 318
 
319
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
320
-                unset( $wpinv_options[ $key ] );
319
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
320
+                unset($wpinv_options[$key]);
321 321
             }
322 322
         }
323 323
     }
324 324
 
325 325
     // Merge our new settings with the existing
326
-    $output = array_merge( $wpinv_options, $input );
326
+    $output = array_merge($wpinv_options, $input);
327 327
 
328
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
328
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
329 329
 
330 330
     return $output;
331 331
 }
332
-add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 );
333
-add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' );
332
+add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1);
333
+add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount');
334 334
 
335
-function wpinv_settings_sanitize_tax_rates( $input ) {
336
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
335
+function wpinv_settings_sanitize_tax_rates($input) {
336
+    if (!wpinv_current_user_can_manage_invoicing()) {
337 337
         return $input;
338 338
     }
339 339
 
340
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
340
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
341 341
     $tax_rates = array();
342 342
 
343
-    foreach ( $new_rates as $rate ) {
343
+    foreach ($new_rates as $rate) {
344 344
 
345
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
346
-		$rate['name']    = sanitize_text_field( $rate['name'] );
347
-		$rate['state']   = sanitize_text_field( $rate['state'] );
348
-		$rate['country'] = sanitize_text_field( $rate['country'] );
349
-		$rate['global']  = empty( $rate['state'] );
345
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
346
+		$rate['name']    = sanitize_text_field($rate['name']);
347
+		$rate['state']   = sanitize_text_field($rate['state']);
348
+		$rate['country'] = sanitize_text_field($rate['country']);
349
+		$rate['global']  = empty($rate['state']);
350 350
 		$tax_rates[]     = $rate;
351 351
 
352 352
 	}
353 353
 
354
-    update_option( 'wpinv_tax_rates', $tax_rates );
354
+    update_option('wpinv_tax_rates', $tax_rates);
355 355
 
356 356
     return $input;
357 357
 }
358
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
358
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
359 359
 
360 360
 function wpinv_get_settings_tabs() {
361 361
     $tabs             = array();
362
-    $tabs['general']  = __( 'General', 'invoicing' );
363
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
364
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
365
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
362
+    $tabs['general']  = __('General', 'invoicing');
363
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
364
+    $tabs['taxes']    = __('Taxes', 'invoicing');
365
+	$tabs['emails'] = __('Emails', 'invoicing');
366 366
 
367
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
368
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
367
+	if (count(getpaid_get_integration_settings()) > 0) {
368
+		$tabs['integrations'] = __('Integrations', 'invoicing');
369 369
 	}
370 370
 
371
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
372
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
373
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
371
+    $tabs['privacy']  = __('Privacy', 'invoicing');
372
+    $tabs['misc']     = __('Misc', 'invoicing');
373
+    $tabs['tools']    = __('Tools', 'invoicing');
374 374
 
375
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
375
+    return apply_filters('wpinv_settings_tabs', $tabs);
376 376
 }
377 377
 
378
-function wpinv_get_settings_tab_sections( $tab = false ) {
378
+function wpinv_get_settings_tab_sections($tab = false) {
379 379
     $tabs     = false;
380 380
     $sections = wpinv_get_registered_settings_sections();
381 381
 
382
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
383
-        $tabs = $sections[ $tab ];
382
+    if ($tab && !empty($sections[$tab])) {
383
+        $tabs = $sections[$tab];
384 384
     }
385 385
 
386 386
     return $tabs;
@@ -389,89 +389,89 @@  discard block
 block discarded – undo
389 389
 function wpinv_get_registered_settings_sections() {
390 390
     static $sections = false;
391 391
 
392
-    if ( false !== $sections ) {
392
+    if (false !== $sections) {
393 393
         return $sections;
394 394
     }
395 395
 
396 396
     $sections = array(
397
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
398
-            'main' => __( 'General Settings', 'invoicing' ),
399
-            'page_section' => __( 'Page Settings', 'invoicing' ),
400
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
401
-            'labels' => __( 'Label Texts', 'invoicing' ),
402
-        ) ),
403
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
404
-            'main' => __( 'Gateway Settings', 'invoicing' ),
405
-        ) ),
406
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
407
-            'main'  => __( 'Tax Settings', 'invoicing' ),
408
-			'rates' => __( 'Tax Rates', 'invoicing' ),
409
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
410
-        ) ),
411
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
412
-            'main' => __( 'Email Settings', 'invoicing' ),
413
-		) ),
414
-
415
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
416
-
417
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
418
-            'main' => __( 'Privacy policy', 'invoicing' ),
419
-        ) ),
420
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
421
-            'main' => __( 'Miscellaneous', 'invoicing' ),
422
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
423
-        ) ),
424
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
425
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
426
-        ) ),
397
+        'general' => apply_filters('wpinv_settings_sections_general', array(
398
+            'main' => __('General Settings', 'invoicing'),
399
+            'page_section' => __('Page Settings', 'invoicing'),
400
+            'currency_section' => __('Currency Settings', 'invoicing'),
401
+            'labels' => __('Label Texts', 'invoicing'),
402
+        )),
403
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
404
+            'main' => __('Gateway Settings', 'invoicing'),
405
+        )),
406
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
407
+            'main'  => __('Tax Settings', 'invoicing'),
408
+			'rates' => __('Tax Rates', 'invoicing'),
409
+			'vat'   => __('EU VAT Settings', 'invoicing')
410
+        )),
411
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
412
+            'main' => __('Email Settings', 'invoicing'),
413
+		)),
414
+
415
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
416
+
417
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
418
+            'main' => __('Privacy policy', 'invoicing'),
419
+        )),
420
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
421
+            'main' => __('Miscellaneous', 'invoicing'),
422
+            'custom-css' => __('Custom CSS', 'invoicing'),
423
+        )),
424
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
425
+            'main' => __('Diagnostic Tools', 'invoicing'),
426
+        )),
427 427
     );
428 428
 
429
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
429
+    $sections = apply_filters('wpinv_settings_sections', $sections);
430 430
 
431 431
     return $sections;
432 432
 }
433 433
 
434
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
434
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
435 435
 	$pages_options = array();
436 436
 
437
-	if( $default_label !== NULL && $default_label !== false ) {
438
-		$pages_options = array( '' => $default_label ); // Blank option
437
+	if ($default_label !== NULL && $default_label !== false) {
438
+		$pages_options = array('' => $default_label); // Blank option
439 439
 	}
440 440
 
441 441
 	$pages = get_pages();
442
-	if ( $pages ) {
443
-		foreach ( $pages as $page ) {
442
+	if ($pages) {
443
+		foreach ($pages as $page) {
444 444
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
445
-            $pages_options[ $page->ID ] = $title;
445
+            $pages_options[$page->ID] = $title;
446 446
 		}
447 447
 	}
448 448
 
449 449
 	return $pages_options;
450 450
 }
451 451
 
452
-function wpinv_header_callback( $args ) {
453
-	if ( !empty( $args['desc'] ) ) {
452
+function wpinv_header_callback($args) {
453
+	if (!empty($args['desc'])) {
454 454
         echo $args['desc'];
455 455
     }
456 456
 }
457 457
 
458
-function wpinv_hidden_callback( $args ) {
458
+function wpinv_hidden_callback($args) {
459 459
 
460
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
461
-	$value   = wpinv_get_option( $args['id'], $std );
460
+	$std     = isset($args['std']) ? $args['std'] : '';
461
+	$value   = wpinv_get_option($args['id'], $std);
462 462
 
463
-	if ( isset( $args['set_value'] ) ) {
463
+	if (isset($args['set_value'])) {
464 464
 		$value = $args['set_value'];
465 465
 	}
466 466
 
467
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
467
+	if (isset($args['faux']) && true === $args['faux']) {
468 468
 		$args['readonly'] = true;
469
-		$name  = '';
469
+		$name = '';
470 470
 	} else {
471
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
471
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
472 472
 	}
473 473
 
474
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
474
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
475 475
     
476 476
 	echo $html;
477 477
 }
@@ -479,59 +479,59 @@  discard block
 block discarded – undo
479 479
 /**
480 480
  * Displays a checkbox settings callback.
481 481
  */
482
-function wpinv_checkbox_callback( $args ) {
482
+function wpinv_checkbox_callback($args) {
483 483
 
484
-	$std = isset( $args['std'] ) ? $args['std'] : '';
485
-	$std = wpinv_get_option( $args['id'], $std );
486
-	$id  = esc_attr( $args['id'] );
484
+	$std = isset($args['std']) ? $args['std'] : '';
485
+	$std = wpinv_get_option($args['id'], $std);
486
+	$id  = esc_attr($args['id']);
487 487
 
488
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
488
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
489 489
 	?>
490 490
 		<fieldset>
491 491
 			<label>
492
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
493
-				<?php echo wp_kses_post( $args['desc'] ); ?>
492
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
493
+				<?php echo wp_kses_post($args['desc']); ?>
494 494
 			</label>
495 495
 		</fieldset>
496 496
 	<?php
497 497
 }
498 498
 
499
-function wpinv_multicheck_callback( $args ) {
499
+function wpinv_multicheck_callback($args) {
500 500
 
501
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
502
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
501
+	$sanitize_id = wpinv_sanitize_key($args['id']);
502
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
503 503
 
504
-	if ( ! empty( $args['options'] ) ) {
504
+	if (!empty($args['options'])) {
505 505
 
506
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
507
-		$value   = wpinv_get_option( $args['id'], $std );
506
+		$std     = isset($args['std']) ? $args['std'] : array();
507
+		$value   = wpinv_get_option($args['id'], $std);
508 508
 
509 509
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
510
-        foreach( $args['options'] as $key => $option ):
511
-			$sanitize_key = wpinv_sanitize_key( $key );
512
-			if ( in_array( $sanitize_key, $value ) ) { 
510
+        foreach ($args['options'] as $key => $option):
511
+			$sanitize_key = wpinv_sanitize_key($key);
512
+			if (in_array($sanitize_key, $value)) { 
513 513
 				$enabled = $sanitize_key;
514 514
 			} else { 
515 515
 				$enabled = NULL; 
516 516
 			}
517
-			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;';
518
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
517
+			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;';
518
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
519 519
 		endforeach;
520 520
 		echo '</div>';
521 521
 		echo '<p class="description">' . $args['desc'] . '</p>';
522 522
 	}
523 523
 }
524 524
 
525
-function wpinv_payment_icons_callback( $args ) {
525
+function wpinv_payment_icons_callback($args) {
526 526
     
527
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
528
-	$value   = wpinv_get_option( $args['id'], false);
527
+    $sanitize_id = wpinv_sanitize_key($args['id']);
528
+	$value = wpinv_get_option($args['id'], false);
529 529
 
530
-	if ( ! empty( $args['options'] ) ) {
531
-		foreach( $args['options'] as $key => $option ) {
532
-            $sanitize_key = wpinv_sanitize_key( $key );
530
+	if (!empty($args['options'])) {
531
+		foreach ($args['options'] as $key => $option) {
532
+            $sanitize_key = wpinv_sanitize_key($key);
533 533
             
534
-			if( empty( $value ) ) {
534
+			if (empty($value)) {
535 535
 				$enabled = $option;
536 536
 			} else {
537 537
 				$enabled = NULL;
@@ -539,67 +539,67 @@  discard block
 block discarded – undo
539 539
 
540 540
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
541 541
 
542
-				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;';
542
+				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;';
543 543
 
544
-				if ( wpinv_string_is_image_url( $key ) ) {
545
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
544
+				if (wpinv_string_is_image_url($key)) {
545
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
546 546
 				} else {
547
-					$card = strtolower( str_replace( ' ', '', $option ) );
547
+					$card = strtolower(str_replace(' ', '', $option));
548 548
 
549
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
550
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
549
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
550
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
551 551
 					} else {
552
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
552
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
553 553
 						$content_dir = WP_CONTENT_DIR;
554 554
 
555
-						if ( function_exists( 'wp_normalize_path' ) ) {
555
+						if (function_exists('wp_normalize_path')) {
556 556
 							// Replaces backslashes with forward slashes for Windows systems
557
-							$image = wp_normalize_path( $image );
558
-							$content_dir = wp_normalize_path( $content_dir );
557
+							$image = wp_normalize_path($image);
558
+							$content_dir = wp_normalize_path($content_dir);
559 559
 						}
560 560
 
561
-						$image = str_replace( $content_dir, content_url(), $image );
561
+						$image = str_replace($content_dir, content_url(), $image);
562 562
 					}
563 563
 
564
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
564
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
565 565
 				}
566 566
 			echo $option . '</label>';
567 567
 		}
568
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
568
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
569 569
 	}
570 570
 }
571 571
 
572 572
 /**
573 573
  * Displays a radio settings field.
574 574
  */
575
-function wpinv_radio_callback( $args ) {
575
+function wpinv_radio_callback($args) {
576 576
 
577
-	$std = isset( $args['std'] ) ? $args['std'] : '';
578
-	$std = wpinv_get_option( $args['id'], $std );
577
+	$std = isset($args['std']) ? $args['std'] : '';
578
+	$std = wpinv_get_option($args['id'], $std);
579 579
 	?>
580 580
 		<fieldset>
581
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
582
-				<?php foreach( $args['options'] as $key => $option ) : ?>
581
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
582
+				<?php foreach ($args['options'] as $key => $option) : ?>
583 583
 					<li>
584 584
 						<label>
585
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
586
-							<?php echo wp_kses_post( $option ); ?>
585
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
586
+							<?php echo wp_kses_post($option); ?>
587 587
 						</label>
588 588
 					</li>
589 589
 				<?php endforeach; ?>
590 590
 			</ul>
591 591
 		</fieldset>
592 592
 	<?php
593
-	getpaid_settings_description_callback( $args );
593
+	getpaid_settings_description_callback($args);
594 594
 }
595 595
 
596 596
 /**
597 597
  * Displays a description if available.
598 598
  */
599
-function getpaid_settings_description_callback( $args ) {
599
+function getpaid_settings_description_callback($args) {
600 600
 
601
-	if ( ! empty( $args['desc'] ) ) {
602
-		$description = wp_kses_post( $args['desc'] );
601
+	if (!empty($args['desc'])) {
602
+		$description = wp_kses_post($args['desc']);
603 603
 		echo "<p class='description'>$description</p>";
604 604
 	}
605 605
 
@@ -615,31 +615,31 @@  discard block
 block discarded – undo
615 615
 	</tr>
616 616
 	<tr class="bsui">
617 617
     	<td colspan="2" class="p-0">
618
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
618
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
619 619
 
620 620
 	<?php
621 621
 }
622 622
 
623 623
 function wpinv_gateway_select_callback($args) {
624 624
     
625
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
626
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
627
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
628
-	$value   = wpinv_get_option( $args['id'], $std );
625
+    $sanitize_id = wpinv_sanitize_key($args['id']);
626
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
627
+	$std     = isset($args['std']) ? $args['std'] : '';
628
+	$value   = wpinv_get_option($args['id'], $std);
629 629
 
630
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
630
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
631 631
 
632
-	foreach ( $args['options'] as $key => $option ) :
633
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
634
-            $selected = selected( $key, $args['selected'], false );
632
+	foreach ($args['options'] as $key => $option) :
633
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
634
+            $selected = selected($key, $args['selected'], false);
635 635
         } else {
636
-            $selected = selected( $key, $value, false );
636
+            $selected = selected($key, $value, false);
637 637
         }
638
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
638
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
639 639
 	endforeach;
640 640
 
641 641
 	echo '</select>';
642
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
642
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
643 643
 }
644 644
 
645 645
 /**
@@ -648,28 +648,28 @@  discard block
 block discarded – undo
648 648
  * @param array $args
649 649
  * @return string
650 650
  */
651
-function wpinv_settings_attrs_helper( $args ) {
651
+function wpinv_settings_attrs_helper($args) {
652 652
 
653
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
654
-	$id           = esc_attr( $args['id'] );
655
-	$placeholder  = esc_attr( $args['placeholder'] );
653
+	$value        = isset($args['std']) ? $args['std'] : '';
654
+	$id           = esc_attr($args['id']);
655
+	$placeholder  = esc_attr($args['placeholder']);
656 656
 
657
-	if ( ! empty( $args['faux'] ) ) {
657
+	if (!empty($args['faux'])) {
658 658
 		$args['readonly'] = true;
659 659
 		$name             = '';
660 660
 	} else {
661
-		$value  = wpinv_get_option( $args['id'], $value );
661
+		$value  = wpinv_get_option($args['id'], $value);
662 662
 		$name   = "wpinv_settings[$id]";
663 663
 	}
664 664
 
665
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
666
-	$class    = esc_attr( $args['class'] );
667
-	$style    = esc_attr( $args['style'] );
668
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
665
+	$value    = is_scalar($value) ? esc_attr($value) : '';
666
+	$class    = esc_attr($args['class']);
667
+	$style    = esc_attr($args['style']);
668
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
669 669
 
670 670
 	$onchange = '';
671
-    if ( ! empty( $args['onchange'] ) ) {
672
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
671
+    if (!empty($args['onchange'])) {
672
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
673 673
 	}
674 674
 
675 675
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -678,11 +678,11 @@  discard block
 block discarded – undo
678 678
 /**
679 679
  * Displays a text input settings callback.
680 680
  */
681
-function wpinv_text_callback( $args ) {
681
+function wpinv_text_callback($args) {
682 682
 
683
-	$desc = wp_kses_post( $args['desc'] );
684
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
685
-	$attr = wpinv_settings_attrs_helper( $args );
683
+	$desc = wp_kses_post($args['desc']);
684
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
685
+	$attr = wpinv_settings_attrs_helper($args);
686 686
 
687 687
 	?>
688 688
 		<label style="width: 100%;">
@@ -696,14 +696,14 @@  discard block
 block discarded – undo
696 696
 /**
697 697
  * Displays a number input settings callback.
698 698
  */
699
-function wpinv_number_callback( $args ) {
699
+function wpinv_number_callback($args) {
700 700
 
701
-	$desc = wp_kses_post( $args['desc'] );
702
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
703
-	$attr = wpinv_settings_attrs_helper( $args );
704
-	$max  = intval( $args['max'] );
705
-	$min  = intval( $args['min'] );
706
-	$step = floatval( $args['step'] );
701
+	$desc = wp_kses_post($args['desc']);
702
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
703
+	$attr = wpinv_settings_attrs_helper($args);
704
+	$max  = intval($args['max']);
705
+	$min  = intval($args['min']);
706
+	$step = floatval($args['step']);
707 707
 
708 708
 	?>
709 709
 		<label style="width: 100%;">
@@ -714,37 +714,37 @@  discard block
 block discarded – undo
714 714
 
715 715
 }
716 716
 
717
-function wpinv_textarea_callback( $args ) {
717
+function wpinv_textarea_callback($args) {
718 718
     
719
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
720
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
721
-	$value   = wpinv_get_option( $args['id'], $std );
719
+    $sanitize_id = wpinv_sanitize_key($args['id']);
720
+	$std     = isset($args['std']) ? $args['std'] : '';
721
+	$value   = wpinv_get_option($args['id'], $std);
722 722
 
723
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
724
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
723
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
724
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
725 725
 
726
-	$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>';
727
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
726
+	$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>';
727
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
728 728
 
729 729
 	echo $html;
730 730
 }
731 731
 
732
-function wpinv_password_callback( $args ) {
732
+function wpinv_password_callback($args) {
733 733
     
734
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
735
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
736
-	$value   = wpinv_get_option( $args['id'], $std );
734
+    $sanitize_id = wpinv_sanitize_key($args['id']);
735
+	$std     = isset($args['std']) ? $args['std'] : '';
736
+	$value   = wpinv_get_option($args['id'], $std);
737 737
 
738
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
739
-	$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 ) . '"/>';
740
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
738
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
739
+	$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) . '"/>';
740
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
741 741
 
742 742
 	echo $html;
743 743
 }
744 744
 
745 745
 function wpinv_missing_callback($args) {
746 746
 	printf(
747
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
747
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
748 748
 		'<strong>' . $args['id'] . '</strong>'
749 749
 	);
750 750
 }
@@ -752,35 +752,35 @@  discard block
 block discarded – undo
752 752
 /**
753 753
  * Displays a number input settings callback.
754 754
  */
755
-function wpinv_select_callback( $args ) {
755
+function wpinv_select_callback($args) {
756 756
 
757
-	$desc   = wp_kses_post( $args['desc'] );
758
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
759
-	$attr   = wpinv_settings_attrs_helper( $args );
760
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
761
-	$value  = wpinv_get_option( $args['id'], $value );
762
-	$rand   = uniqid( 'random_id' );
757
+	$desc   = wp_kses_post($args['desc']);
758
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
759
+	$attr   = wpinv_settings_attrs_helper($args);
760
+	$value  = isset($args['std']) ? $args['std'] : '';
761
+	$value  = wpinv_get_option($args['id'], $value);
762
+	$rand   = uniqid('random_id');
763 763
 
764 764
 	?>
765 765
 		<label style="width: 100%;">
766 766
 			<select <?php echo $attr; ?>>
767
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
768
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
769
-				<?php endforeach;?>
767
+				<?php foreach ($args['options'] as $option => $name) : ?>
768
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option>
769
+				<?php endforeach; ?>
770 770
 			</select>
771 771
 
772
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
773
-				<a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a>
772
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
773
+				<a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing') ?></a>
774 774
 			<?php endif; ?>
775 775
 
776
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
777
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ) ?></a>
776
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
777
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing') ?></a>
778 778
 				<div id='<?php echo $rand; ?>' style='display:none;'>
779 779
 					<div>
780
-						<h3><?php _e( 'Original Content', 'invoicing' ) ?></h3>
781
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea>
782
-						<h3><?php _e( 'Current Content', 'invoicing' ) ?></h3>
783
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea>
780
+						<h3><?php _e('Original Content', 'invoicing') ?></h3>
781
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea>
782
+						<h3><?php _e('Current Content', 'invoicing') ?></h3>
783
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea>
784 784
 					</div>
785 785
 				</div>
786 786
 			<?php endif; ?>
@@ -791,88 +791,88 @@  discard block
 block discarded – undo
791 791
 
792 792
 }
793 793
 
794
-function wpinv_color_select_callback( $args ) {
794
+function wpinv_color_select_callback($args) {
795 795
     
796
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
797
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
798
-	$value   = wpinv_get_option( $args['id'], $std );
796
+    $sanitize_id = wpinv_sanitize_key($args['id']);
797
+	$std     = isset($args['std']) ? $args['std'] : '';
798
+	$value   = wpinv_get_option($args['id'], $std);
799 799
 
800
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
800
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
801 801
 
802
-	foreach ( $args['options'] as $option => $color ) {
803
-		$selected = selected( $option, $value, false );
804
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
802
+	foreach ($args['options'] as $option => $color) {
803
+		$selected = selected($option, $value, false);
804
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
805 805
 	}
806 806
 
807 807
 	$html .= '</select>';
808
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
808
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
809 809
 
810 810
 	echo $html;
811 811
 }
812 812
 
813
-function wpinv_rich_editor_callback( $args ) {
813
+function wpinv_rich_editor_callback($args) {
814 814
 	global $wp_version;
815 815
     
816
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
816
+    $sanitize_id = wpinv_sanitize_key($args['id']);
817 817
 
818
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
819
-	$value   = wpinv_get_option( $args['id'], $std );
818
+	$std     = isset($args['std']) ? $args['std'] : '';
819
+	$value   = wpinv_get_option($args['id'], $std);
820 820
 	
821
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
821
+	if (!empty($args['allow_blank']) && empty($value)) {
822 822
 		$value = $std;
823 823
 	}
824 824
 
825
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
825
+	$rows = isset($args['size']) ? $args['size'] : 20;
826 826
 
827 827
 	$html = '<div class="getpaid-settings-editor-input">';
828
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
828
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
829 829
 		ob_start();
830
-		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 ) );
830
+		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));
831 831
 		$html .= ob_get_clean();
832 832
 	} else {
833
-		$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>';
833
+		$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>';
834 834
 	}
835 835
 
836
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
836
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
837 837
 
838 838
 	echo $html;
839 839
 }
840 840
 
841
-function wpinv_upload_callback( $args ) {
841
+function wpinv_upload_callback($args) {
842 842
     
843
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
843
+    $sanitize_id = wpinv_sanitize_key($args['id']);
844 844
 
845
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
846
-	$value   = wpinv_get_option( $args['id'], $std );
845
+	$std     = isset($args['std']) ? $args['std'] : '';
846
+	$value   = wpinv_get_option($args['id'], $std);
847 847
 
848
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
849
-	$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 ) ) . '"/>';
850
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
851
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
848
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
849
+	$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)) . '"/>';
850
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
851
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
852 852
 
853 853
 	echo $html;
854 854
 }
855 855
 
856
-function wpinv_color_callback( $args ) {
856
+function wpinv_color_callback($args) {
857 857
 
858
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
859
-	$value       = wpinv_get_option( $args['id'], $std );
860
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
858
+	$std         = isset($args['std']) ? $args['std'] : '';
859
+	$value       = wpinv_get_option($args['id'], $std);
860
+    $sanitize_id = wpinv_sanitize_key($args['id']);
861 861
 
862
-	$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 ) . '" />';
863
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
862
+	$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) . '" />';
863
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
864 864
 
865 865
 	echo $html;
866 866
 }
867 867
 
868 868
 function wpinv_country_states_callback($args) {
869 869
 
870
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
871
-	$value   = wpinv_get_option( $args['id'], $std );
870
+	$std     = isset($args['std']) ? $args['std'] : '';
871
+	$value   = wpinv_get_option($args['id'], $std);
872 872
 
873
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
873
+    $sanitize_id = wpinv_sanitize_key($args['id']);
874 874
 
875
-	if ( isset( $args['placeholder'] ) ) {
875
+	if (isset($args['placeholder'])) {
876 876
 		$placeholder = $args['placeholder'];
877 877
 	} else {
878 878
 		$placeholder = '';
@@ -880,16 +880,16 @@  discard block
 block discarded – undo
880 880
 
881 881
 	$states = wpinv_get_country_states();
882 882
 
883
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
883
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
884
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
885 885
 
886
-	foreach ( $states as $option => $name ) {
887
-		$selected = selected( $option, $value, false );
888
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
886
+	foreach ($states as $option => $name) {
887
+		$selected = selected($option, $value, false);
888
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
889 889
 	}
890 890
 
891 891
 	$html .= '</select>';
892
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
892
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
893 893
 
894 894
 	echo $html;
895 895
 }
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 	</tr>
905 905
 	<tr class="bsui">
906 906
     	<td colspan="2" class="p-0">
907
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
907
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
908 908
 
909 909
 	<?php
910 910
 
@@ -913,14 +913,14 @@  discard block
 block discarded – undo
913 913
 /**
914 914
  * Displays a tax rate' edit row.
915 915
  */
916
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
916
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
917 917
 	ob_start();
918 918
 
919
-	$key                      = sanitize_key( $key );
920
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
921
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
919
+	$key                      = sanitize_key($key);
920
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
921
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
922 922
 
923
-	if ( $echo ) {
923
+	if ($echo) {
924 924
 		echo ob_get_clean();
925 925
 	} else {
926 926
 		return ob_get_clean(); 
@@ -933,136 +933,136 @@  discard block
 block discarded – undo
933 933
     ob_start(); ?>
934 934
     </td><tr>
935 935
     <td colspan="2" class="wpinv_tools_tdbox">
936
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
937
-    <?php do_action( 'wpinv_tools_before' ); ?>
936
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
937
+    <?php do_action('wpinv_tools_before'); ?>
938 938
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
939 939
         <thead>
940 940
             <tr>
941
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
942
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
943
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
941
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
942
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
943
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
944 944
             </tr>
945 945
         </thead>
946 946
 
947 947
         <tbody>
948 948
 			<tr>
949
-                <td><?php _e( 'Check Pages', 'invoicing' );?></td>
949
+                <td><?php _e('Check Pages', 'invoicing'); ?></td>
950 950
                 <td>
951
-                    <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
951
+                    <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
952 952
                 </td>
953 953
                 <td>
954 954
 					<a href="<?php
955 955
 						echo esc_url(
956 956
 							wp_nonce_url(
957
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
957
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
958 958
 								'getpaid-nonce',
959 959
 								'getpaid-nonce'
960 960
 							)
961 961
 						);
962
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
962
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
963 963
                 </td>
964 964
             </tr>
965 965
 			<tr>
966
-                <td><?php _e( 'Create Database Tables', 'invoicing' );?></td>
966
+                <td><?php _e('Create Database Tables', 'invoicing'); ?></td>
967 967
                 <td>
968
-                    <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
968
+                    <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
969 969
                 </td>
970 970
                 <td>
971 971
 					<a href="<?php
972 972
 						echo esc_url(
973 973
 							wp_nonce_url(
974
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
974
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
975 975
 								'getpaid-nonce',
976 976
 								'getpaid-nonce'
977 977
 							)
978 978
 						);
979
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
979
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
980 980
                 </td>
981 981
             </tr>
982 982
 			<tr>
983
-                <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td>
983
+                <td><?php _e('Migrate old invoices', 'invoicing'); ?></td>
984 984
                 <td>
985
-                    <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
985
+                    <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
986 986
                 </td>
987 987
                 <td>
988 988
 					<a href="<?php
989 989
 						echo esc_url(
990 990
 							wp_nonce_url(
991
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
991
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
992 992
 								'getpaid-nonce',
993 993
 								'getpaid-nonce'
994 994
 							)
995 995
 						);
996
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
996
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
997 997
                 </td>
998 998
             </tr>
999 999
 
1000 1000
 			<tr>
1001
-                <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td>
1001
+                <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td>
1002 1002
                 <td>
1003
-                    <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1003
+                    <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1004 1004
                 </td>
1005 1005
                 <td>
1006 1006
 					<a href="<?php
1007 1007
 						echo esc_url(
1008 1008
 							wp_nonce_url(
1009
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1009
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1010 1010
 								'getpaid-nonce',
1011 1011
 								'getpaid-nonce'
1012 1012
 							)
1013 1013
 						);
1014
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1014
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1015 1015
                 </td>
1016 1016
             </tr>
1017 1017
 
1018 1018
 			<tr>
1019
-                <td><?php _e( 'Set-up Wizard', 'invoicing' );?></td>
1019
+                <td><?php _e('Set-up Wizard', 'invoicing'); ?></td>
1020 1020
                 <td>
1021
-                    <small><?php _e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small>
1021
+                    <small><?php _e('Launch the quick set-up wizard.', 'invoicing'); ?></small>
1022 1022
                 </td>
1023 1023
                 <td>
1024 1024
 					<a href="<?php
1025
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1026
-					?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a>
1025
+						echo esc_url(admin_url('index.php?page=gp-setup'));
1026
+					?>" class="button button-primary"><?php _e('Launch', 'invoicing'); ?></a>
1027 1027
                 </td>
1028 1028
             </tr>
1029 1029
 
1030
-			<?php do_action( 'wpinv_tools_row' ); ?>
1030
+			<?php do_action('wpinv_tools_row'); ?>
1031 1031
         </tbody>
1032 1032
     </table>
1033
-    <?php do_action( 'wpinv_tools_after' ); ?>
1033
+    <?php do_action('wpinv_tools_after'); ?>
1034 1034
     <?php
1035 1035
     echo ob_get_clean();
1036 1036
 }
1037 1037
 
1038 1038
 
1039
-function wpinv_descriptive_text_callback( $args ) {
1040
-	echo wp_kses_post( $args['desc'] );
1039
+function wpinv_descriptive_text_callback($args) {
1040
+	echo wp_kses_post($args['desc']);
1041 1041
 }
1042 1042
 
1043
-function wpinv_raw_html_callback( $args ) {
1043
+function wpinv_raw_html_callback($args) {
1044 1044
 	echo $args['desc'];
1045 1045
 }
1046 1046
 
1047
-function wpinv_hook_callback( $args ) {
1048
-	do_action( 'wpinv_' . $args['id'], $args );
1047
+function wpinv_hook_callback($args) {
1048
+	do_action('wpinv_' . $args['id'], $args);
1049 1049
 }
1050 1050
 
1051 1051
 function wpinv_set_settings_cap() {
1052 1052
 	return wpinv_get_capability();
1053 1053
 }
1054
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1054
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1055 1055
 
1056 1056
 
1057
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1058
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1059
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1057
+function wpinv_on_update_settings($old_value, $value, $option) {
1058
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1059
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1060 1060
     
1061
-    if ( $old != $new ) {
1062
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1061
+    if ($old != $new) {
1062
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1063 1063
     }
1064 1064
 }
1065
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1065
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1066 1066
 
1067 1067
 /**
1068 1068
  * Returns the merge tags help text.
@@ -1071,16 +1071,16 @@  discard block
 block discarded – undo
1071 1071
  * 
1072 1072
  * @return string
1073 1073
  */
1074
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1074
+function wpinv_get_merge_tags_help_text($subscription = false) {
1075 1075
 
1076 1076
 	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1077 1077
 	$link = sprintf(
1078 1078
 		'<strong><a href="%s" target="_blank">%s</a></strong>',
1079 1079
 		$url,
1080
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1080
+		esc_html__('View available merge tags.', 'wpinv-quotes')
1081 1081
 	);
1082 1082
 
1083
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1083
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1084 1084
 
1085 1085
 	return "$description $link";
1086 1086
 
Please login to merge, or discard this patch.
includes/admin/views/wizard-introduction.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -4,78 +4,78 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 
11 11
 <div class="card shadow-sm my-5">
12 12
 
13 13
     <h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1">
14
-        <?php esc_html_e( 'Welcome to the GetPaid Setup Wizard!', 'invoicing' ); ?>
14
+        <?php esc_html_e('Welcome to the GetPaid Setup Wizard!', 'invoicing'); ?>
15 15
     </h1>
16 16
 
17 17
     <div class="card-body text-muted ">
18
-        <p><?php _e( 'Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing' ); ?></p>
18
+        <p><?php _e('Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing'); ?></p>
19 19
         <hr class="mt-4 pt-3 pb-0" />
20
-        <p class="small"><?php _e( 'This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes</b>.', 'invoicing' ); ?></p>
20
+        <p class="small"><?php _e('This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes</b>.', 'invoicing'); ?></p>
21 21
     </div>
22 22
 
23 23
     <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0">
24 24
         <a
25
-            href="<?php echo esc_url( $next_url ); ?>"
26
-            class="btn btn-primary button-next"><?php esc_html_e( "Let's go!", 'invoicing' ); ?></a>
25
+            href="<?php echo esc_url($next_url); ?>"
26
+            class="btn btn-primary button-next"><?php esc_html_e("Let's go!", 'invoicing'); ?></a>
27 27
         <a
28
-            href="<?php echo esc_url( admin_url() ); ?>"
29
-            class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
28
+            href="<?php echo esc_url(admin_url()); ?>"
29
+            class="btn btn-link d-block mt-2 "><?php esc_html_e('Not right now', 'invoicing'); ?></a>
30 30
     </div>
31 31
 </div>
32 32
 
33 33
 <div class="card shadow-sm my-5 overflow-hidden">
34 34
     <h1 class="h4 card-header bg-white border-bottom-0  pt-4 pb-1">
35
-        <?php esc_html_e( 'GetPaid Features & Addons!', 'invoicing' ); ?>
35
+        <?php esc_html_e('GetPaid Features & Addons!', 'invoicing'); ?>
36 36
     </h1>
37 37
 
38 38
     <div class="card-body text-muted overflow-hidden">
39
-		<p><?php _e( 'Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing' ); ?></p>
39
+		<p><?php _e('Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing'); ?></p>
40 40
 		<hr>
41 41
 
42 42
 		<div class="row row-cols-2 text-left">
43 43
 			<div class="col mt-3">
44 44
 				<div class="media">
45
-                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/buy.svg';?>" class="mr-3" alt="...">
45
+                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/buy.svg'; ?>" class="mr-3" alt="...">
46 46
                     <div class="media-body">
47
-                        <h6 class="mt-0 font-weight-bold"><?php _e( 'GetPaid via Buy Now Buttons', 'invoicing' );?></h6>
48
-                        <small><?php _e( 'Sell via buy now buttons anywhere on your site', 'invoicing' );?></small>
47
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Buy Now Buttons', 'invoicing'); ?></h6>
48
+                        <small><?php _e('Sell via buy now buttons anywhere on your site', 'invoicing'); ?></small>
49 49
                     </div>
50 50
                 </div>
51 51
 			</div>
52 52
 
53 53
             <div class="col mt-3">
54 54
                 <div class="media">
55
-                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/report.svg';?>" class="mr-3" alt="...">
55
+                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/report.svg'; ?>" class="mr-3" alt="...">
56 56
                         <div class="media-body">
57
-                        <h6 class="mt-0 font-weight-bold"><?php _e( 'GetPaid via payment form', 'invoicing' );?></h6>
58
-                        <small><?php _e( 'Payment forms are conversion-optimized checkout forms', 'invoicing' );?></small>
57
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via payment form', 'invoicing'); ?></h6>
58
+                        <small><?php _e('Payment forms are conversion-optimized checkout forms', 'invoicing'); ?></small>
59 59
                     </div>
60 60
                 </div>
61 61
 		    </div>
62 62
 
63 63
             <div class="col mt-3">
64 64
                 <div class="media">
65
-                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/invoices.svg';?>" class="mr-3" alt="...">
65
+                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/invoices.svg'; ?>" class="mr-3" alt="...">
66 66
                     <div class="media-body">
67
-                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice','invoicing');?></h6>
68
-                        <small><?php _e('Create and send invoices for just about anything from the WordPress dashboard','invoicing');?></small>
67
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice', 'invoicing'); ?></h6>
68
+                        <small><?php _e('Create and send invoices for just about anything from the WordPress dashboard', 'invoicing'); ?></small>
69 69
                     </div>
70 70
                 </div>
71 71
 		    </div>
72 72
 
73 73
             <div class="col mt-3">
74 74
                 <div class="media">
75
-                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/payment.svg';?>" class="mr-3" alt="...">
75
+                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/payment.svg'; ?>" class="mr-3" alt="...">
76 76
                     <div class="media-body">
77
-                        <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways','invoicing');?></h6>
78
-                        <small><?php _e('On average our gateways are over 66% cheaper than our competition','invoicing');?></small>
77
+                        <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways', 'invoicing'); ?></h6>
78
+                        <small><?php _e('On average our gateways are over 66% cheaper than our competition', 'invoicing'); ?></small>
79 79
                     </div>
80 80
                 </div>
81 81
 		    </div>
@@ -86,51 +86,51 @@  discard block
 block discarded – undo
86 86
 	<div class="mt-5">
87 87
 		<a
88 88
             href="https://wpgetpaid.com/features-list/"
89
-			class="btn btn-primary"><?php esc_html_e( 'View All Features!', 'invoicing' ); ?></a>
89
+			class="btn btn-primary"><?php esc_html_e('View All Features!', 'invoicing'); ?></a>
90 90
 	</div>
91 91
 
92 92
 	<div class="mt-5 mx-n4 py-4" style="background:#eafaf6;">
93
-		<h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e( 'More with Membership!' , 'invoicing' );?></h4>
93
+		<h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e('More with Membership!', 'invoicing'); ?></h4>
94 94
 		<div class="row row-cols-2 text-left px-5">
95 95
 
96 96
 			<div class="col">
97 97
 				<ul class="list-unstyled">
98
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'PDF Invoices' , 'invoicing' );?></li>
99
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Gravity Forms' , 'invoicing' );?></li>
100
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Contact form 7' , 'invoicing' );?></li>
101
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'AffiliateWP Integration' , 'invoicing' );?></li>
98
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('PDF Invoices', 'invoicing'); ?></li>
99
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Gravity Forms', 'invoicing'); ?></li>
100
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Contact form 7', 'invoicing'); ?></li>
101
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('AffiliateWP Integration', 'invoicing'); ?></li>
102 102
 				</ul>
103 103
 			</div>
104 104
 
105 105
 			<div class="col">
106 106
 				<ul class="list-unstyled">
107
-			    	<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Ninja forms' , 'invoicing' );?></li>
108
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Digital Downloads' , 'invoicing' );?></li>
109
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Wallet' , 'invoicing' );?></li>
107
+			    	<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Ninja forms', 'invoicing'); ?></li>
108
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Digital Downloads', 'invoicing'); ?></li>
109
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Wallet', 'invoicing'); ?></li>
110 110
 				</ul>
111 111
 			</div>
112 112
 		</div>
113 113
 
114
-		<h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From','invoicing');?></h5>
115
-		<h1 class="mt-0 font-weight-bold text-dark mb-4 display-3"><?php esc_html_e( '$49', 'invoicing' ); ?></h1>
114
+		<h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From', 'invoicing'); ?></h5>
115
+		<h1 class="mt-0 font-weight-bold text-dark mb-4 display-3"><?php esc_html_e('$49', 'invoicing'); ?></h1>
116 116
 
117 117
 		<div class="mt-2">
118 118
 			<a
119 119
                 href="https://wpgetpaid.com/downloads/membership/"
120
-				class="btn btn-primary"><?php esc_html_e( 'Buy Membership Now!', 'invoicing' ); ?></a>
120
+				class="btn btn-primary"><?php esc_html_e('Buy Membership Now!', 'invoicing'); ?></a>
121 121
 		</div>
122 122
 
123 123
 	</div>
124 124
 
125 125
     <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0">
126 126
         <a
127
-            href="<?php echo esc_url( $next_url ); ?>"
128
-            class="btn btn-outline-primary button-next"><?php esc_html_e( 'Launch the Setup Wizard!', 'invoicing' ); ?></a>
127
+            href="<?php echo esc_url($next_url); ?>"
128
+            class="btn btn-outline-primary button-next"><?php esc_html_e('Launch the Setup Wizard!', 'invoicing'); ?></a>
129 129
         <a
130 130
             href="https://docs.wpgetpaid.com/"
131
-            class="btn btn-outline-primary ml-4"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a>
131
+            class="btn btn-outline-primary ml-4"><?php esc_html_e('Documentation', 'invoicing'); ?></a>
132 132
         <a
133
-            href="<?php echo esc_url( admin_url() ); ?>"
134
-            class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
133
+            href="<?php echo esc_url(admin_url()); ?>"
134
+            class="btn btn-link d-block mt-2 "><?php esc_html_e('Not right now', 'invoicing'); ?></a>
135 135
     </div>
136 136
 </div>
Please login to merge, or discard this patch.