Passed
Push — master ( a15c21...706a80 )
by Stiofan
04:34
created
templates/payment-forms-admin/previews/billing_email.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/textarea.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/discount.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/paragraph.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/payment-forms-admin/previews/pay_button.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-forms.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -13,128 +13,128 @@
 block discarded – undo
13 13
 class GetPaid_Payment_Forms {
14 14
 
15 15
     /**
16
-	 * Class constructor
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-
21
-		// Update a payment form's revenue whenever an invoice is paid for or refunded.
22
-		add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) );
23
-		add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) );
24
-
25
-		// Sync form amount whenever invoice statuses change.
26
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 );
27
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 );
28
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 );
29
-
30
-	}
31
-
32
-	/**
33
-	 * Increments a form's revenue whenever there is a payment.
34
-	 *
35
-	 * @param WPInv_Invoice $invoice
36
-	 */
37
-	public function increment_form_revenue( $invoice ) {
38
-
39
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
40
-		if ( $form->get_id() ) {
41
-			$form->set_earned( $form->get_earned() + $invoice->get_total() );
42
-			$form->save();
43
-		}
44
-
45
-	}
46
-
47
-	/**
48
-	 * Decreases form revenue whenever invoice payment changes.
49
-	 *
50
-	 * @param WPInv_Invoice $invoice
51
-	 */
52
-	public function decrease_form_revenue( $invoice ) {
53
-
54
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
55
-		if ( $form->get_id() ) {
56
-			$form->set_earned( $form->get_earned() - $invoice->get_total() );
57
-			$form->save();
58
-		}
59
-
60
-	}
61
-
62
-	/**
63
-	 * Updates a form's failed amount.
64
-	 *
65
-	 * @param WPInv_Invoice $invoice
66
-	 * @param string $from
67
-	 * @param string $to
68
-	 */
69
-	public function update_form_failed_amount( $invoice, $from, $to ) {
70
-
71
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
72
-		if ( $form->get_id() ) {
73
-			return;
74
-		}
75
-
76
-		if ( 'wpi-failed' == $from ) {
77
-			$form->set_failed( $form->get_failed() - $invoice->get_total() );
78
-			$form->save();
79
-		}
80
-
81
-		if ( 'wpi-failed' == $to ) {
82
-			$form->set_failed( $form->get_failed() + $invoice->get_total() );
83
-			$form->save();
84
-		}
85
-
86
-	}
87
-
88
-	/**
89
-	 * Updates a form's refunded amount.
90
-	 *
91
-	 * @param WPInv_Invoice $invoice
92
-	 * @param string $from
93
-	 * @param string $to
94
-	 */
95
-	public function update_form_refunded_amount( $invoice, $from, $to ) {
96
-
97
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
98
-		if ( $form->get_id() ) {
99
-			return;
100
-		}
101
-
102
-		if ( 'wpi-refunded' == $from ) {
103
-			$form->set_refunded( $form->get_refunded() - $invoice->get_total() );
104
-			$form->save();
105
-		}
106
-
107
-		if ( 'wpi-refunded' == $to ) {
108
-			$form->set_refunded( $form->get_refunded() + $invoice->get_total() );
109
-			$form->save();
110
-		}
111
-
112
-	}
113
-
114
-	/**
115
-	 * Updates a form's cancelled amount.
116
-	 *
117
-	 * @param WPInv_Invoice $invoice
118
-	 * @param string $from
119
-	 * @param string $to
120
-	 */
121
-	public function update_form_cancelled_amount( $invoice, $from, $to ) {
122
-
123
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
124
-		if ( $form->get_id() ) {
125
-			return;
126
-		}
127
-
128
-		if ( 'wpi-cancelled' == $from ) {
129
-			$form->set_cancelled( $form->get_cancelled() - $invoice->get_total() );
130
-			$form->save();
131
-		}
132
-
133
-		if ( 'wpi-cancelled' == $to ) {
134
-			$form->set_cancelled( $form->get_cancelled() + $invoice->get_total() );
135
-			$form->save();
136
-		}
137
-
138
-	}
16
+     * Class constructor
17
+     *
18
+     */
19
+    public function __construct() {
20
+
21
+        // Update a payment form's revenue whenever an invoice is paid for or refunded.
22
+        add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) );
23
+        add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) );
24
+
25
+        // Sync form amount whenever invoice statuses change.
26
+        add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 );
27
+        add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 );
28
+        add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 );
29
+
30
+    }
31
+
32
+    /**
33
+     * Increments a form's revenue whenever there is a payment.
34
+     *
35
+     * @param WPInv_Invoice $invoice
36
+     */
37
+    public function increment_form_revenue( $invoice ) {
38
+
39
+        $form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
40
+        if ( $form->get_id() ) {
41
+            $form->set_earned( $form->get_earned() + $invoice->get_total() );
42
+            $form->save();
43
+        }
44
+
45
+    }
46
+
47
+    /**
48
+     * Decreases form revenue whenever invoice payment changes.
49
+     *
50
+     * @param WPInv_Invoice $invoice
51
+     */
52
+    public function decrease_form_revenue( $invoice ) {
53
+
54
+        $form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
55
+        if ( $form->get_id() ) {
56
+            $form->set_earned( $form->get_earned() - $invoice->get_total() );
57
+            $form->save();
58
+        }
59
+
60
+    }
61
+
62
+    /**
63
+     * Updates a form's failed amount.
64
+     *
65
+     * @param WPInv_Invoice $invoice
66
+     * @param string $from
67
+     * @param string $to
68
+     */
69
+    public function update_form_failed_amount( $invoice, $from, $to ) {
70
+
71
+        $form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
72
+        if ( $form->get_id() ) {
73
+            return;
74
+        }
75
+
76
+        if ( 'wpi-failed' == $from ) {
77
+            $form->set_failed( $form->get_failed() - $invoice->get_total() );
78
+            $form->save();
79
+        }
80
+
81
+        if ( 'wpi-failed' == $to ) {
82
+            $form->set_failed( $form->get_failed() + $invoice->get_total() );
83
+            $form->save();
84
+        }
85
+
86
+    }
87
+
88
+    /**
89
+     * Updates a form's refunded amount.
90
+     *
91
+     * @param WPInv_Invoice $invoice
92
+     * @param string $from
93
+     * @param string $to
94
+     */
95
+    public function update_form_refunded_amount( $invoice, $from, $to ) {
96
+
97
+        $form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
98
+        if ( $form->get_id() ) {
99
+            return;
100
+        }
101
+
102
+        if ( 'wpi-refunded' == $from ) {
103
+            $form->set_refunded( $form->get_refunded() - $invoice->get_total() );
104
+            $form->save();
105
+        }
106
+
107
+        if ( 'wpi-refunded' == $to ) {
108
+            $form->set_refunded( $form->get_refunded() + $invoice->get_total() );
109
+            $form->save();
110
+        }
111
+
112
+    }
113
+
114
+    /**
115
+     * Updates a form's cancelled amount.
116
+     *
117
+     * @param WPInv_Invoice $invoice
118
+     * @param string $from
119
+     * @param string $to
120
+     */
121
+    public function update_form_cancelled_amount( $invoice, $from, $to ) {
122
+
123
+        $form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
124
+        if ( $form->get_id() ) {
125
+            return;
126
+        }
127
+
128
+        if ( 'wpi-cancelled' == $from ) {
129
+            $form->set_cancelled( $form->get_cancelled() - $invoice->get_total() );
130
+            $form->save();
131
+        }
132
+
133
+        if ( 'wpi-cancelled' == $to ) {
134
+            $form->set_cancelled( $form->get_cancelled() + $invoice->get_total() );
135
+            $form->save();
136
+        }
137
+
138
+    }
139 139
 
140 140
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment forms controller class
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 	public function __construct() {
20 20
 
21 21
 		// Update a payment form's revenue whenever an invoice is paid for or refunded.
22
-		add_action( 'getpaid_invoice_payment_status_changed', array( $this, 'increment_form_revenue' ) );
23
-		add_action( 'getpaid_invoice_payment_status_reversed', array( $this, 'decrease_form_revenue' ) );
22
+		add_action('getpaid_invoice_payment_status_changed', array($this, 'increment_form_revenue'));
23
+		add_action('getpaid_invoice_payment_status_reversed', array($this, 'decrease_form_revenue'));
24 24
 
25 25
 		// Sync form amount whenever invoice statuses change.
26
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_failed_amount' ), 10, 3 );
27
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_refunded_amount' ), 10, 3 );
28
-		add_action( 'getpaid_invoice_status_changed', array( $this, 'update_form_cancelled_amount' ), 10, 3 );
26
+		add_action('getpaid_invoice_status_changed', array($this, 'update_form_failed_amount'), 10, 3);
27
+		add_action('getpaid_invoice_status_changed', array($this, 'update_form_refunded_amount'), 10, 3);
28
+		add_action('getpaid_invoice_status_changed', array($this, 'update_form_cancelled_amount'), 10, 3);
29 29
 
30 30
 	}
31 31
 
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @param WPInv_Invoice $invoice
36 36
 	 */
37
-	public function increment_form_revenue( $invoice ) {
37
+	public function increment_form_revenue($invoice) {
38 38
 
39
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
40
-		if ( $form->get_id() ) {
41
-			$form->set_earned( $form->get_earned() + $invoice->get_total() );
39
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
40
+		if ($form->get_id()) {
41
+			$form->set_earned($form->get_earned() + $invoice->get_total());
42 42
 			$form->save();
43 43
 		}
44 44
 
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @param WPInv_Invoice $invoice
51 51
 	 */
52
-	public function decrease_form_revenue( $invoice ) {
52
+	public function decrease_form_revenue($invoice) {
53 53
 
54
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
55
-		if ( $form->get_id() ) {
56
-			$form->set_earned( $form->get_earned() - $invoice->get_total() );
54
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
55
+		if ($form->get_id()) {
56
+			$form->set_earned($form->get_earned() - $invoice->get_total());
57 57
 			$form->save();
58 58
 		}
59 59
 
@@ -66,20 +66,20 @@  discard block
 block discarded – undo
66 66
 	 * @param string $from
67 67
 	 * @param string $to
68 68
 	 */
69
-	public function update_form_failed_amount( $invoice, $from, $to ) {
69
+	public function update_form_failed_amount($invoice, $from, $to) {
70 70
 
71
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
72
-		if ( $form->get_id() ) {
71
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
72
+		if ($form->get_id()) {
73 73
 			return;
74 74
 		}
75 75
 
76
-		if ( 'wpi-failed' == $from ) {
77
-			$form->set_failed( $form->get_failed() - $invoice->get_total() );
76
+		if ('wpi-failed' == $from) {
77
+			$form->set_failed($form->get_failed() - $invoice->get_total());
78 78
 			$form->save();
79 79
 		}
80 80
 
81
-		if ( 'wpi-failed' == $to ) {
82
-			$form->set_failed( $form->get_failed() + $invoice->get_total() );
81
+		if ('wpi-failed' == $to) {
82
+			$form->set_failed($form->get_failed() + $invoice->get_total());
83 83
 			$form->save();
84 84
 		}
85 85
 
@@ -92,20 +92,20 @@  discard block
 block discarded – undo
92 92
 	 * @param string $from
93 93
 	 * @param string $to
94 94
 	 */
95
-	public function update_form_refunded_amount( $invoice, $from, $to ) {
95
+	public function update_form_refunded_amount($invoice, $from, $to) {
96 96
 
97
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
98
-		if ( $form->get_id() ) {
97
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
98
+		if ($form->get_id()) {
99 99
 			return;
100 100
 		}
101 101
 
102
-		if ( 'wpi-refunded' == $from ) {
103
-			$form->set_refunded( $form->get_refunded() - $invoice->get_total() );
102
+		if ('wpi-refunded' == $from) {
103
+			$form->set_refunded($form->get_refunded() - $invoice->get_total());
104 104
 			$form->save();
105 105
 		}
106 106
 
107
-		if ( 'wpi-refunded' == $to ) {
108
-			$form->set_refunded( $form->get_refunded() + $invoice->get_total() );
107
+		if ('wpi-refunded' == $to) {
108
+			$form->set_refunded($form->get_refunded() + $invoice->get_total());
109 109
 			$form->save();
110 110
 		}
111 111
 
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
 	 * @param string $from
119 119
 	 * @param string $to
120 120
 	 */
121
-	public function update_form_cancelled_amount( $invoice, $from, $to ) {
121
+	public function update_form_cancelled_amount($invoice, $from, $to) {
122 122
 
123
-		$form = new GetPaid_Payment_Form( $invoice->get_payment_form() );
124
-		if ( $form->get_id() ) {
123
+		$form = new GetPaid_Payment_Form($invoice->get_payment_form());
124
+		if ($form->get_id()) {
125 125
 			return;
126 126
 		}
127 127
 
128
-		if ( 'wpi-cancelled' == $from ) {
129
-			$form->set_cancelled( $form->get_cancelled() - $invoice->get_total() );
128
+		if ('wpi-cancelled' == $from) {
129
+			$form->set_cancelled($form->get_cancelled() - $invoice->get_total());
130 130
 			$form->save();
131 131
 		}
132 132
 
133
-		if ( 'wpi-cancelled' == $to ) {
134
-			$form->set_cancelled( $form->get_cancelled() + $invoice->get_total() );
133
+		if ('wpi-cancelled' == $to) {
134
+			$form->set_cancelled($form->get_cancelled() + $invoice->get_total());
135 135
 			$form->save();
136 136
 		}
137 137
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-discount-details.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Discount_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the discount.
@@ -368,34 +368,34 @@  discard block
 block discarded – undo
368 368
     }
369 369
 
370 370
     /**
371
-	 * Save meta box data.
372
-	 *
373
-	 * @param int $post_id
374
-	 */
375
-	public static function save( $post_id ) {
371
+     * Save meta box data.
372
+     *
373
+     * @param int $post_id
374
+     */
375
+    public static function save( $post_id ) {
376 376
 
377 377
         // Prepare the discount.
378 378
         $discount = new WPInv_Discount( $post_id );
379 379
 
380 380
         // Load new data.
381 381
         $discount->set_props(
382
-			array(
383
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null,
384
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null,
385
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
386
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
387
-				'is_single_use'        => isset( $_POST['wpinv_discount_single_use'] ),
382
+            array(
383
+                'code'                 => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null,
384
+                'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null,
385
+                'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
386
+                'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
387
+                'is_single_use'        => isset( $_POST['wpinv_discount_single_use'] ),
388 388
                 'type'                 => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null,
389
-				'is_recurring'         => isset( $_POST['wpinv_discount_recurring'] ),
390
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(),
391
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(),
392
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null,
393
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null,
394
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null,
395
-			)
389
+                'is_recurring'         => isset( $_POST['wpinv_discount_recurring'] ),
390
+                'items'                => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(),
391
+                'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(),
392
+                'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null,
393
+                'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null,
394
+                'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null,
395
+            )
396 396
         );
397 397
 
398
-		$discount->save();
399
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
400
-	}
398
+        $discount->save();
399
+        do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
400
+    }
401 401
 }
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the discount.
27
-        $discount = new WPInv_Discount( $post );
27
+        $discount = new WPInv_Discount($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32
-        do_action( 'wpinv_discount_form_top', $discount );
32
+        do_action('wpinv_discount_form_top', $discount);
33 33
 
34 34
         // Set the currency position.
35 35
         $position = wpinv_currency_position();
36 36
 
37
-        if ( $position == 'left_space' ) {
37
+        if ($position == 'left_space') {
38 38
             $position = 'left';
39 39
         }
40 40
 
41
-        if ( $position == 'right_space' ) {
41
+        if ($position == 'right_space') {
42 42
             $position = 'right';
43 43
         }
44 44
 
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
         </style>
53 53
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
54 54
 
55
-            <?php do_action( 'wpinv_discount_form_first', $discount ); ?>
55
+            <?php do_action('wpinv_discount_form_first', $discount); ?>
56 56
 
57
-            <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?>
57
+            <?php do_action('wpinv_discount_form_before_code', $discount); ?>
58 58
             <div class="form-group row">
59 59
                 <label for="wpinv_discount_code" class="col-sm-3 col-form-label">
60
-                    <?php _e( 'Discount Code', 'invoicing' );?>
60
+                    <?php _e('Discount Code', 'invoicing'); ?>
61 61
                 </label>
62 62
                 <div class="col-sm-8">
63 63
                     <div class="row">
64 64
                         <div class="col-sm-12 form-group">
65
-                            <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
65
+                            <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
66 66
                         </div>
67 67
                         <div class="col-sm-12">
68 68
                             <?php
69
-                                do_action( 'wpinv_discount_form_before_single_use', $discount );
69
+                                do_action('wpinv_discount_form_before_single_use', $discount);
70 70
 
71 71
                                 echo aui()->input(
72 72
                                     array(
73 73
                                         'id'          => 'wpinv_discount_single_use',
74 74
                                         'name'        => 'wpinv_discount_single_use',
75 75
                                         'type'        => 'checkbox',
76
-                                        'label'       => __( 'Each customer can only use this discount once', 'invoicing' ),
76
+                                        'label'       => __('Each customer can only use this discount once', 'invoicing'),
77 77
                                         'value'       => '1',
78 78
                                         'checked'     => $discount->is_single_use(),
79 79
                                     )
80 80
                                 );
81 81
 
82
-                                do_action( 'wpinv_discount_form_single_use', $discount );
82
+                                do_action('wpinv_discount_form_single_use', $discount);
83 83
                             ?>
84 84
                         </div>
85 85
                         <div class="col-sm-12">
86 86
                             <?php
87
-                                do_action( 'wpinv_discount_form_before_recurring', $discount );
87
+                                do_action('wpinv_discount_form_before_recurring', $discount);
88 88
 
89 89
                                 echo aui()->input(
90 90
                                     array(
91 91
                                         'id'          => 'wpinv_discount_recurring',
92 92
                                         'name'        => 'wpinv_discount_recurring',
93 93
                                         'type'        => 'checkbox',
94
-                                        'label'       => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ),
94
+                                        'label'       => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'),
95 95
                                         'value'       => '1',
96 96
                                         'checked'     => $discount->is_recurring(),
97 97
                                     )
98 98
                                 );
99 99
 
100
-                                do_action( 'wpinv_discount_form_recurring', $discount );
100
+                                do_action('wpinv_discount_form_recurring', $discount);
101 101
                             ?>
102 102
                         </div>
103 103
                     </div>
104 104
                 </div>
105 105
                 <div class="col-sm-1 pt-2 pl-0">
106
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span>
106
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span>
107 107
                 </div>
108 108
             </div>
109
-            <?php do_action( 'wpinv_discount_form_code', $discount ); ?>
109
+            <?php do_action('wpinv_discount_form_code', $discount); ?>
110 110
 
111
-            <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?>
111
+            <?php do_action('wpinv_discount_form_before_type', $discount); ?>
112 112
             <div class="form-group row">
113 113
                 <label for="wpinv_discount_type" class="col-sm-3 col-form-label">
114
-                    <?php _e( 'Discount Type', 'invoicing' );?>
114
+                    <?php _e('Discount Type', 'invoicing'); ?>
115 115
                 </label>
116 116
                 <div class="col-sm-8">
117 117
                     <?php
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
                             array(
120 120
                                 'id'               => 'wpinv_discount_type',
121 121
                                 'name'             => 'wpinv_discount_type',
122
-                                'label'            => __( 'Discount Type', 'invoicing' ),
123
-                                'placeholder'      => __( 'Select Discount Type', 'invoicing' ),
124
-                                'value'            => $discount->get_type( 'edit' ),
122
+                                'label'            => __('Discount Type', 'invoicing'),
123
+                                'placeholder'      => __('Select Discount Type', 'invoicing'),
124
+                                'value'            => $discount->get_type('edit'),
125 125
                                 'select2'          => true,
126 126
                                 'data-allow-clear' => 'false',
127 127
                                 'options'          => wpinv_get_discount_types()
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
                     ?>
131 131
                 </div>
132 132
                 <div class="col-sm-1 pt-2 pl-0">
133
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span>
133
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span>
134 134
                 </div>
135 135
             </div>
136
-            <?php do_action( 'wpinv_discount_form_type', $discount ); ?>
136
+            <?php do_action('wpinv_discount_form_type', $discount); ?>
137 137
 
138
-            <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?>
139
-            <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap">
138
+            <?php do_action('wpinv_discount_form_before_amount', $discount); ?>
139
+            <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap">
140 140
                 <label for="wpinv_discount_amount" class="col-sm-3 col-form-label">
141
-                    <?php _e( 'Discount Amount', 'invoicing' );?>
141
+                    <?php _e('Discount Amount', 'invoicing'); ?>
142 142
                 </label>
143 143
                 <div class="col-sm-8">
144 144
                     <div class="input-group input-group-sm">
145
-                        <?php if( 'left' == $position ) : ?>
145
+                        <?php if ('left' == $position) : ?>
146 146
                             <div class="input-group-prepend left wpinv-if-flat">
147 147
                                 <span class="input-group-text">
148 148
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                             </div>
151 151
                         <?php endif; ?>
152 152
 
153
-                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control">
153
+                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control">
154 154
 
155
-                        <?php if( 'right' == $position ) : ?>
155
+                        <?php if ('right' == $position) : ?>
156 156
                             <div class="input-group-prepend left wpinv-if-flat">
157 157
                                 <span class="input-group-text">
158 158
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
                     </div>
166 166
                 </div>
167 167
                 <div class="col-sm-1 pt-2 pl-0">
168
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span>
168
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span>
169 169
                 </div>
170 170
             </div>
171
-            <?php do_action( 'wpinv_discount_form_amount', $discount ); ?>
171
+            <?php do_action('wpinv_discount_form_amount', $discount); ?>
172 172
 
173
-            <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?>
173
+            <?php do_action('wpinv_discount_form_before_items', $discount); ?>
174 174
             <div class="form-group row">
175 175
                 <label for="wpinv_discount_items" class="col-sm-3 col-form-label">
176
-                    <?php _e( 'Items', 'invoicing' );?>
176
+                    <?php _e('Items', 'invoicing'); ?>
177 177
                 </label>
178 178
                 <div class="col-sm-8">
179 179
                     <?php
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
                             array(
182 182
                                 'id'               => 'wpinv_discount_items',
183 183
                                 'name'             => 'wpinv_discount_items[]',
184
-                                'label'            => __( 'Items', 'invoicing' ),
185
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
186
-                                'value'            => $discount->get_items( 'edit' ),
184
+                                'label'            => __('Items', 'invoicing'),
185
+                                'placeholder'      => __('Select Items', 'invoicing'),
186
+                                'value'            => $discount->get_items('edit'),
187 187
                                 'select2'          => true,
188 188
                                 'multiple'         => true,
189 189
                                 'data-allow-clear' => 'false',
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
                     ?>
194 194
                 </div>
195 195
                 <div class="col-sm-1 pt-2 pl-0">
196
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span>
196
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span>
197 197
                 </div>
198 198
             </div>
199
-            <?php do_action( 'wpinv_discount_form_items', $discount ); ?>
199
+            <?php do_action('wpinv_discount_form_items', $discount); ?>
200 200
 
201
-            <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?>
201
+            <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?>
202 202
             <div class="form-group row">
203 203
                 <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label">
204
-                    <?php _e( 'Excluded Items', 'invoicing' );?>
204
+                    <?php _e('Excluded Items', 'invoicing'); ?>
205 205
                 </label>
206 206
                 <div class="col-sm-8">
207 207
                     <?php
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             array(
210 210
                                 'id'               => 'wpinv_discount_excluded_items',
211 211
                                 'name'             => 'wpinv_discount_excluded_items[]',
212
-                                'label'            => __( 'Excluded Items', 'invoicing' ),
213
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
214
-                                'value'            => $discount->get_excluded_items( 'edit' ),
212
+                                'label'            => __('Excluded Items', 'invoicing'),
213
+                                'placeholder'      => __('Select Items', 'invoicing'),
214
+                                'value'            => $discount->get_excluded_items('edit'),
215 215
                                 'select2'          => true,
216 216
                                 'multiple'         => true,
217 217
                                 'data-allow-clear' => 'false',
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
                     ?>
222 222
                 </div>
223 223
                 <div class="col-sm-1 pt-2 pl-0">
224
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span>
224
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span>
225 225
                 </div>
226 226
             </div>
227
-            <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?>
227
+            <?php do_action('wpinv_discount_form_excluded_items', $discount); ?>
228 228
 
229
-            <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?>
229
+            <?php do_action('wpinv_discount_form_before_start', $discount); ?>
230 230
             <div class="form-group row">
231 231
                 <label for="wpinv_discount_start" class="col-sm-3 col-form-label">
232
-                    <?php _e( 'Start Date', 'invoicing' );?>
232
+                    <?php _e('Start Date', 'invoicing'); ?>
233 233
                 </label>
234 234
                 <div class="col-sm-8">
235 235
                     <?php
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
                                 'type'        => 'datepicker',
239 239
                                 'id'          => 'wpinv_discount_start',
240 240
                                 'name'        => 'wpinv_discount_start',
241
-                                'label'       => __( 'Start Date', 'invoicing' ),
241
+                                'label'       => __('Start Date', 'invoicing'),
242 242
                                 'placeholder' => 'YYYY-MM-DD 00:00',
243 243
                                 'class'       => 'form-control-sm',
244
-                                'value'       => $discount->get_start_date( 'edit' ),
244
+                                'value'       => $discount->get_start_date('edit'),
245 245
                                 'extra_attributes' => array(
246 246
                                     'data-enable-time' => 'true',
247 247
                                     'data-time_24hr'   => 'true',
@@ -252,15 +252,15 @@  discard block
 block discarded – undo
252 252
                     ?>
253 253
                 </div>
254 254
                 <div class="col-sm-1 pt-2 pl-0">
255
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span>
255
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span>
256 256
                 </div>
257 257
             </div>
258
-            <?php do_action( 'wpinv_discount_form_start', $discount ); ?>
258
+            <?php do_action('wpinv_discount_form_start', $discount); ?>
259 259
 
260
-            <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?>
260
+            <?php do_action('wpinv_discount_form_before_expiration', $discount); ?>
261 261
             <div class="form-group row">
262 262
                 <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label">
263
-                    <?php _e( 'Expiration Date', 'invoicing' );?>
263
+                    <?php _e('Expiration Date', 'invoicing'); ?>
264 264
                 </label>
265 265
                 <div class="col-sm-8">
266 266
                     <?php
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
                                 'type'        => 'datepicker',
270 270
                                 'id'          => 'wpinv_discount_expiration',
271 271
                                 'name'        => 'wpinv_discount_expiration',
272
-                                'label'       => __( 'Expiration Date', 'invoicing' ),
272
+                                'label'       => __('Expiration Date', 'invoicing'),
273 273
                                 'placeholder' => 'YYYY-MM-DD 00:00',
274 274
                                 'class'       => 'form-control-sm',
275
-                                'value'       => $discount->get_end_date( 'edit' ),
275
+                                'value'       => $discount->get_end_date('edit'),
276 276
                                 'extra_attributes' => array(
277 277
                                     'data-enable-time' => 'true',
278 278
                                     'data-time_24hr'   => 'true',
@@ -285,27 +285,27 @@  discard block
 block discarded – undo
285 285
                     ?>
286 286
                 </div>
287 287
                 <div class="col-sm-1 pt-2 pl-0">
288
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span>
288
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span>
289 289
                 </div>
290 290
             </div>
291
-            <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?>
291
+            <?php do_action('wpinv_discount_form_expiration', $discount); ?>
292 292
 
293
-            <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?>
293
+            <?php do_action('wpinv_discount_form_before_min_total', $discount); ?>
294 294
             <div class="form-group row">
295 295
                 <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label">
296
-                    <?php _e( 'Minimum Amount', 'invoicing' );?>
296
+                    <?php _e('Minimum Amount', 'invoicing'); ?>
297 297
                 </label>
298 298
                 <div class="col-sm-8">
299 299
                     <div class="input-group input-group-sm">
300
-                        <?php if( 'left' == $position ) : ?>
300
+                        <?php if ('left' == $position) : ?>
301 301
                             <div class="input-group-prepend">
302 302
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
303 303
                             </div>
304 304
                         <?php endif; ?>
305 305
 
306
-                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control">
306
+                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control">
307 307
 
308
-                        <?php if( 'left' != $position ) : ?>
308
+                        <?php if ('left' != $position) : ?>
309 309
                             <div class="input-group-append">
310 310
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
311 311
                             </div>
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
                     </div>
314 314
                 </div>
315 315
                 <div class="col-sm-1 pt-2 pl-0">
316
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span>
316
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span>
317 317
                 </div>
318 318
             </div>
319
-            <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?>
319
+            <?php do_action('wpinv_discount_form_min_total', $discount); ?>
320 320
 
321
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
321
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
322 322
             <div class="form-group row">
323 323
                 <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label">
324
-                    <?php _e( 'Maximum Amount', 'invoicing' );?>
324
+                    <?php _e('Maximum Amount', 'invoicing'); ?>
325 325
                 </label>
326 326
                 <div class="col-sm-8">
327 327
                     <div class="input-group input-group-sm">
328
-                        <?php if( 'left' == $position ) : ?>
328
+                        <?php if ('left' == $position) : ?>
329 329
                             <div class="input-group-prepend">
330 330
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
331 331
                             </div>
332 332
                         <?php endif; ?>
333 333
 
334
-                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control">
334
+                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control">
335 335
 
336
-                        <?php if( 'left' != $position ) : ?>
336
+                        <?php if ('left' != $position) : ?>
337 337
                             <div class="input-group-append">
338 338
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
339 339
                             </div>
@@ -341,30 +341,30 @@  discard block
 block discarded – undo
341 341
                     </div>
342 342
                 </div>
343 343
                 <div class="col-sm-1 pt-2 pl-0">
344
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span>
344
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span>
345 345
                 </div>
346 346
             </div>
347
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
347
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
348 348
 
349
-            <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?>
349
+            <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?>
350 350
             <div class="form-group row">
351 351
                 <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label">
352
-                    <?php _e( 'Maximum Uses', 'invoicing' );?>
352
+                    <?php _e('Maximum Uses', 'invoicing'); ?>
353 353
                 </label>
354 354
                 <div class="col-sm-8">
355
-                    <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
355
+                    <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
356 356
                 </div>
357 357
                 <div class="col-sm-1 pt-2 pl-0">
358
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span>
358
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span>
359 359
                 </div>
360 360
             </div>
361
-            <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?>
361
+            <?php do_action('wpinv_discount_form_max_uses', $discount); ?>
362 362
 
363
-            <?php do_action( 'wpinv_discount_form_last', $discount ); ?>
363
+            <?php do_action('wpinv_discount_form_last', $discount); ?>
364 364
 
365 365
         </div>
366 366
         <?php
367
-        do_action( 'wpinv_discount_form_bottom', $post );
367
+        do_action('wpinv_discount_form_bottom', $post);
368 368
     }
369 369
 
370 370
     /**
@@ -372,30 +372,30 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
 	 * @param int $post_id
374 374
 	 */
375
-	public static function save( $post_id ) {
375
+	public static function save($post_id) {
376 376
 
377 377
         // Prepare the discount.
378
-        $discount = new WPInv_Discount( $post_id );
378
+        $discount = new WPInv_Discount($post_id);
379 379
 
380 380
         // Load new data.
381 381
         $discount->set_props(
382 382
 			array(
383
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null,
384
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null,
385
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
386
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
387
-				'is_single_use'        => isset( $_POST['wpinv_discount_single_use'] ),
388
-                'type'                 => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null,
389
-				'is_recurring'         => isset( $_POST['wpinv_discount_recurring'] ),
390
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : array(),
391
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : array(),
392
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null,
393
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null,
394
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null,
383
+				'code'                 => isset($_POST['wpinv_discount_code']) ? $_POST['wpinv_discount_code'] : null,
384
+				'amount'               => isset($_POST['wpinv_discount_amount']) ? $_POST['wpinv_discount_amount'] : null,
385
+				'start'                => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null,
386
+				'expiration'           => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null,
387
+				'is_single_use'        => isset($_POST['wpinv_discount_single_use']),
388
+                'type'                 => isset($_POST['wpinv_discount_type']) ? $_POST['wpinv_discount_type'] : null,
389
+				'is_recurring'         => isset($_POST['wpinv_discount_recurring']),
390
+				'items'                => isset($_POST['wpinv_discount_items']) ? $_POST['wpinv_discount_items'] : array(),
391
+				'excluded_items'       => isset($_POST['wpinv_discount_excluded_items']) ? $_POST['wpinv_discount_excluded_items'] : array(),
392
+				'max_uses'             => isset($_POST['wpinv_discount_max_uses']) ? $_POST['wpinv_discount_max_uses'] : null,
393
+				'min_total'            => isset($_POST['wpinv_discount_min_total']) ? $_POST['wpinv_discount_min_total'] : null,
394
+				'max_total'            => isset($_POST['wpinv_discount_max_total']) ? $_POST['wpinv_discount_max_total'] : null,
395 395
 			)
396 396
         );
397 397
 
398 398
 		$discount->save();
399
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
399
+		do_action('getpaid_discount_metabox_save', $post_id, $discount);
400 400
 	}
401 401
 }
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/alert.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='form-group'>
15 15
     <label class="d-block">
16
-        <span><?php esc_html_e( 'Alert Text', 'invoicing' ); ?></span>
16
+        <span><?php esc_html_e('Alert Text', 'invoicing'); ?></span>
17 17
         <textarea v-model='active_form_element.text' class='form-control' rows='3'></textarea>
18 18
     </label>
19 19
 </div>
20 20
 
21 21
 <div class='form-group form-check'>
22 22
     <input :id="active_form_element.id + '_edit_dismissible'" v-model='active_form_element.dismissible' type='checkbox' class='form-check-input' />
23
-    <label class='form-check-label' :for="active_form_element.id + '_edit_dismissible'"><?php esc_html_e( 'Is Dismissible?', 'invoicing' ); ?></label>
23
+    <label class='form-check-label' :for="active_form_element.id + '_edit_dismissible'"><?php esc_html_e('Is Dismissible?', 'invoicing'); ?></label>
24 24
 </div>
25 25
 
26 26
 <div class='form-group'>
27
-    <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e( 'Alert Type', 'invoicing' ) ?></label>
27
+    <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e('Alert Type', 'invoicing') ?></label>
28 28
     <select class='form-control custom-select' :id="active_form_element.id + '_edit_type'" v-model='active_form_element.class'>
29
-        <option value='alert-primary'><?php esc_html_e( 'Primary', 'invoicing' ); ?></option>
30
-        <option value='alert-secondary'><?php esc_html_e( 'Secondary', 'invoicing' ); ?></option>
31
-        <option value='alert-success'><?php esc_html_e( 'Success', 'invoicing' ); ?></option>
32
-        <option value='alert-danger'><?php esc_html_e( 'Danger', 'invoicing' ); ?></option>
33
-        <option value='alert-warning'><?php esc_html_e( 'Warning', 'invoicing' ); ?></option>
34
-        <option value='alert-info'><?php esc_html_e( 'Info', 'invoicing' ); ?></option>
35
-        <option value='alert-light'><?php esc_html_e( 'Light', 'invoicing' ); ?></option>
36
-        <option value='alert-dark'><?php esc_html_e( 'Dark', 'invoicing' ); ?></option>
37
-        <option value='alert-link'><?php esc_html_e( 'Link', 'invoicing' ); ?></option>
29
+        <option value='alert-primary'><?php esc_html_e('Primary', 'invoicing'); ?></option>
30
+        <option value='alert-secondary'><?php esc_html_e('Secondary', 'invoicing'); ?></option>
31
+        <option value='alert-success'><?php esc_html_e('Success', 'invoicing'); ?></option>
32
+        <option value='alert-danger'><?php esc_html_e('Danger', 'invoicing'); ?></option>
33
+        <option value='alert-warning'><?php esc_html_e('Warning', 'invoicing'); ?></option>
34
+        <option value='alert-info'><?php esc_html_e('Info', 'invoicing'); ?></option>
35
+        <option value='alert-light'><?php esc_html_e('Light', 'invoicing'); ?></option>
36
+        <option value='alert-dark'><?php esc_html_e('Dark', 'invoicing'); ?></option>
37
+        <option value='alert-link'><?php esc_html_e('Link', 'invoicing'); ?></option>
38 38
     </select>
39 39
 </div>
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 2 patches
Indentation   +385 added lines, -385 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,294 +21,294 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 * @since 1.0.10 Now able to pass wp.org theme check.
29
-	 * @since 1.0.11 Font Awesome Pro now supported.
30
-	 * @since 1.0.11 Font Awesome Kits now supported.
31
-	 * @ver 1.0.11
32
-	 * @todo decide how to implement textdomain
33
-	 */
34
-	class WP_Font_Awesome_Settings {
35
-
36
-		/**
37
-		 * Class version version.
38
-		 *
39
-		 * @var string
40
-		 */
41
-		public $version = '1.0.12';
42
-
43
-		/**
44
-		 * Class textdomain.
45
-		 *
46
-		 * @var string
47
-		 */
48
-		public $textdomain = 'font-awesome-settings';
49
-
50
-		/**
51
-		 * Latest version of Font Awesome at time of publish published.
52
-		 *
53
-		 * @var string
54
-		 */
55
-		public $latest = "5.8.2";
56
-
57
-		/**
58
-		 * The title.
59
-		 *
60
-		 * @var string
61
-		 */
62
-		public $name = 'Font Awesome';
63
-
64
-		/**
65
-		 * Holds the settings values.
66
-		 *
67
-		 * @var array
68
-		 */
69
-		private $settings;
70
-
71
-		/**
72
-		 * WP_Font_Awesome_Settings instance.
73
-		 *
74
-		 * @access private
75
-		 * @since  1.0.0
76
-		 * @var    WP_Font_Awesome_Settings There can be only one!
77
-		 */
78
-		private static $instance = null;
79
-
80
-		/**
81
-		 * Main WP_Font_Awesome_Settings Instance.
82
-		 *
83
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
84
-		 *
85
-		 * @since 1.0.0
86
-		 * @static
87
-		 * @return WP_Font_Awesome_Settings - Main instance.
88
-		 */
89
-		public static function instance() {
90
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
91
-				self::$instance = new WP_Font_Awesome_Settings;
92
-
93
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
94
-
95
-				if ( is_admin() ) {
96
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
97
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
98
-				}
99
-
100
-				do_action( 'wp_font_awesome_settings_loaded' );
101
-			}
102
-
103
-			return self::$instance;
104
-		}
105
-
106
-		/**
107
-		 * Initiate the settings and add the required action hooks.
108
-		 *
109
-		 * @since 1.0.8 Settings name wrong - FIXED
110
-		 */
111
-		public function init() {
112
-			$this->settings = $this->get_settings();
113
-
114
-			if ( $this->settings['type'] == 'CSS' ) {
115
-
116
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
118
-				}
119
-
120
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
122
-				}
123
-
124
-			} else {
125
-
126
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
127
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
128
-				}
129
-
130
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
131
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
132
-				}
133
-			}
134
-
135
-			// remove font awesome if set to do so
136
-			if ( $this->settings['dequeue'] == '1' ) {
137
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
138
-			}
139
-
140
-		}
141
-
142
-		/**
143
-		 * Adds the Font Awesome styles.
144
-		 */
145
-		public function enqueue_style() {
146
-			// build url
147
-			$url = $this->get_url();
148
-
149
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
150
-			wp_register_style( 'font-awesome', $url, array(), null );
151
-			wp_enqueue_style( 'font-awesome' );
152
-
153
-			if ( $this->settings['shims'] ) {
154
-				$url = $this->get_url( true );
155
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
156
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
157
-				wp_enqueue_style( 'font-awesome-shims' );
158
-			}
159
-		}
160
-
161
-		/**
162
-		 * Adds the Font Awesome JS.
163
-		 */
164
-		public function enqueue_scripts() {
165
-			// build url
166
-			$url = $this->get_url();
167
-
168
-			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
169
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
170
-			wp_register_script( 'font-awesome', $url, array(), null );
171
-			wp_enqueue_script( 'font-awesome' );
172
-
173
-			if ( $this->settings['shims'] ) {
174
-				$url = $this->get_url( true );
175
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
176
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
177
-				wp_enqueue_script( 'font-awesome-shims' );
178
-			}
179
-		}
180
-
181
-		/**
182
-		 * Get the url of the Font Awesome files.
183
-		 *
184
-		 * @param bool $shims If this is a shim file or not.
185
-		 *
186
-		 * @return string The url to the file.
187
-		 */
188
-		public function get_url( $shims = false ) {
189
-			$script  = $shims ? 'v4-shims' : 'all';
190
-			$sub     = $this->settings['pro'] ? 'pro' : 'use';
191
-			$type    = $this->settings['type'];
192
-			$version = $this->settings['version'];
193
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
194
-			$url     = '';
195
-
196
-			if ( $type == 'KIT' && $kit_url ) {
197
-				if ( $shims ) {
198
-					// if its a kit then we don't add shims here
199
-					return '';
200
-				}
201
-				$url .= $kit_url; // CDN
202
-				$url .= "?wpfas=true"; // set our var so our version is not removed
203
-			} else {
204
-				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
205
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
206
-				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
207
-				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
208
-				$url .= "?wpfas=true"; // set our var so our version is not removed
209
-			}
210
-
211
-			return $url;
212
-		}
213
-
214
-		/**
215
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
216
-		 *
217
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
218
-		 *
219
-		 * @param $url
220
-		 * @param $original_url
221
-		 * @param $_context
222
-		 *
223
-		 * @return string The filtered url.
224
-		 */
225
-		public function remove_font_awesome( $url, $original_url, $_context ) {
226
-
227
-			if ( $_context == 'display'
228
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
229
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
230
-			) {// it's a font-awesome-url (probably)
231
-
232
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
233
-					if ( $this->settings['type'] == 'JS' ) {
234
-						if ( $this->settings['js-pseudo'] ) {
235
-							$url .= "' data-search-pseudo-elements defer='defer";
236
-						} else {
237
-							$url .= "' defer='defer";
238
-						}
239
-					}
240
-				} else {
241
-					$url = ''; // removing the url removes the file
242
-				}
243
-
244
-			}
245
-
246
-			return $url;
247
-		}
248
-
249
-		/**
250
-		 * Register the database settings with WordPress.
251
-		 */
252
-		public function register_settings() {
253
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
254
-		}
255
-
256
-		/**
257
-		 * Add the WordPress settings menu item.
258
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
259
-		 */
260
-		public function menu_item() {
261
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
262
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
263
-				$this,
264
-				'settings_page'
265
-			) );
266
-		}
267
-
268
-		/**
269
-		 * Get the current Font Awesome output settings.
270
-		 *
271
-		 * @return array The array of settings.
272
-		 */
273
-		public function get_settings() {
274
-
275
-			$db_settings = get_option( 'wp-font-awesome-settings' );
276
-
277
-			$defaults = array(
278
-				'type'      => 'CSS', // type to use, CSS or JS or KIT
279
-				'version'   => '', // latest
280
-				'enqueue'   => '', // front and backend
281
-				'shims'     => '0', // default OFF now in 2020
282
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
283
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
284
-				'pro'       => '0', // if pro CDN url should be used
285
-				'kit-url'   => '', // the kit url
286
-			);
287
-
288
-			$settings = wp_parse_args( $db_settings, $defaults );
289
-
290
-			/**
291
-			 * Filter the Font Awesome settings.
292
-			 *
293
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
294
-			 */
295
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
296
-		}
297
-
298
-
299
-		/**
300
-		 * The settings page html output.
301
-		 */
302
-		public function settings_page() {
303
-			if ( ! current_user_can( 'manage_options' ) ) {
304
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
305
-			}
306
-
307
-			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
308
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
309
-				$this->get_latest_version( $force_api = true );
310
-			}
311
-			?>
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     * @since 1.0.10 Now able to pass wp.org theme check.
29
+     * @since 1.0.11 Font Awesome Pro now supported.
30
+     * @since 1.0.11 Font Awesome Kits now supported.
31
+     * @ver 1.0.11
32
+     * @todo decide how to implement textdomain
33
+     */
34
+    class WP_Font_Awesome_Settings {
35
+
36
+        /**
37
+         * Class version version.
38
+         *
39
+         * @var string
40
+         */
41
+        public $version = '1.0.12';
42
+
43
+        /**
44
+         * Class textdomain.
45
+         *
46
+         * @var string
47
+         */
48
+        public $textdomain = 'font-awesome-settings';
49
+
50
+        /**
51
+         * Latest version of Font Awesome at time of publish published.
52
+         *
53
+         * @var string
54
+         */
55
+        public $latest = "5.8.2";
56
+
57
+        /**
58
+         * The title.
59
+         *
60
+         * @var string
61
+         */
62
+        public $name = 'Font Awesome';
63
+
64
+        /**
65
+         * Holds the settings values.
66
+         *
67
+         * @var array
68
+         */
69
+        private $settings;
70
+
71
+        /**
72
+         * WP_Font_Awesome_Settings instance.
73
+         *
74
+         * @access private
75
+         * @since  1.0.0
76
+         * @var    WP_Font_Awesome_Settings There can be only one!
77
+         */
78
+        private static $instance = null;
79
+
80
+        /**
81
+         * Main WP_Font_Awesome_Settings Instance.
82
+         *
83
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
84
+         *
85
+         * @since 1.0.0
86
+         * @static
87
+         * @return WP_Font_Awesome_Settings - Main instance.
88
+         */
89
+        public static function instance() {
90
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
91
+                self::$instance = new WP_Font_Awesome_Settings;
92
+
93
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
94
+
95
+                if ( is_admin() ) {
96
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
97
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
98
+                }
99
+
100
+                do_action( 'wp_font_awesome_settings_loaded' );
101
+            }
102
+
103
+            return self::$instance;
104
+        }
105
+
106
+        /**
107
+         * Initiate the settings and add the required action hooks.
108
+         *
109
+         * @since 1.0.8 Settings name wrong - FIXED
110
+         */
111
+        public function init() {
112
+            $this->settings = $this->get_settings();
113
+
114
+            if ( $this->settings['type'] == 'CSS' ) {
115
+
116
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
118
+                }
119
+
120
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
122
+                }
123
+
124
+            } else {
125
+
126
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
127
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
128
+                }
129
+
130
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
131
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
132
+                }
133
+            }
134
+
135
+            // remove font awesome if set to do so
136
+            if ( $this->settings['dequeue'] == '1' ) {
137
+                add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
138
+            }
139
+
140
+        }
141
+
142
+        /**
143
+         * Adds the Font Awesome styles.
144
+         */
145
+        public function enqueue_style() {
146
+            // build url
147
+            $url = $this->get_url();
148
+
149
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
150
+            wp_register_style( 'font-awesome', $url, array(), null );
151
+            wp_enqueue_style( 'font-awesome' );
152
+
153
+            if ( $this->settings['shims'] ) {
154
+                $url = $this->get_url( true );
155
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
156
+                wp_register_style( 'font-awesome-shims', $url, array(), null );
157
+                wp_enqueue_style( 'font-awesome-shims' );
158
+            }
159
+        }
160
+
161
+        /**
162
+         * Adds the Font Awesome JS.
163
+         */
164
+        public function enqueue_scripts() {
165
+            // build url
166
+            $url = $this->get_url();
167
+
168
+            $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
169
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
170
+            wp_register_script( 'font-awesome', $url, array(), null );
171
+            wp_enqueue_script( 'font-awesome' );
172
+
173
+            if ( $this->settings['shims'] ) {
174
+                $url = $this->get_url( true );
175
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
176
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
177
+                wp_enqueue_script( 'font-awesome-shims' );
178
+            }
179
+        }
180
+
181
+        /**
182
+         * Get the url of the Font Awesome files.
183
+         *
184
+         * @param bool $shims If this is a shim file or not.
185
+         *
186
+         * @return string The url to the file.
187
+         */
188
+        public function get_url( $shims = false ) {
189
+            $script  = $shims ? 'v4-shims' : 'all';
190
+            $sub     = $this->settings['pro'] ? 'pro' : 'use';
191
+            $type    = $this->settings['type'];
192
+            $version = $this->settings['version'];
193
+            $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
194
+            $url     = '';
195
+
196
+            if ( $type == 'KIT' && $kit_url ) {
197
+                if ( $shims ) {
198
+                    // if its a kit then we don't add shims here
199
+                    return '';
200
+                }
201
+                $url .= $kit_url; // CDN
202
+                $url .= "?wpfas=true"; // set our var so our version is not removed
203
+            } else {
204
+                $url .= "https://$sub.fontawesome.com/releases/"; // CDN
205
+                $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
206
+                $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
207
+                $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
208
+                $url .= "?wpfas=true"; // set our var so our version is not removed
209
+            }
210
+
211
+            return $url;
212
+        }
213
+
214
+        /**
215
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
216
+         *
217
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
218
+         *
219
+         * @param $url
220
+         * @param $original_url
221
+         * @param $_context
222
+         *
223
+         * @return string The filtered url.
224
+         */
225
+        public function remove_font_awesome( $url, $original_url, $_context ) {
226
+
227
+            if ( $_context == 'display'
228
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
229
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
230
+            ) {// it's a font-awesome-url (probably)
231
+
232
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
233
+                    if ( $this->settings['type'] == 'JS' ) {
234
+                        if ( $this->settings['js-pseudo'] ) {
235
+                            $url .= "' data-search-pseudo-elements defer='defer";
236
+                        } else {
237
+                            $url .= "' defer='defer";
238
+                        }
239
+                    }
240
+                } else {
241
+                    $url = ''; // removing the url removes the file
242
+                }
243
+
244
+            }
245
+
246
+            return $url;
247
+        }
248
+
249
+        /**
250
+         * Register the database settings with WordPress.
251
+         */
252
+        public function register_settings() {
253
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
254
+        }
255
+
256
+        /**
257
+         * Add the WordPress settings menu item.
258
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
259
+         */
260
+        public function menu_item() {
261
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
262
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
263
+                $this,
264
+                'settings_page'
265
+            ) );
266
+        }
267
+
268
+        /**
269
+         * Get the current Font Awesome output settings.
270
+         *
271
+         * @return array The array of settings.
272
+         */
273
+        public function get_settings() {
274
+
275
+            $db_settings = get_option( 'wp-font-awesome-settings' );
276
+
277
+            $defaults = array(
278
+                'type'      => 'CSS', // type to use, CSS or JS or KIT
279
+                'version'   => '', // latest
280
+                'enqueue'   => '', // front and backend
281
+                'shims'     => '0', // default OFF now in 2020
282
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
283
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
284
+                'pro'       => '0', // if pro CDN url should be used
285
+                'kit-url'   => '', // the kit url
286
+            );
287
+
288
+            $settings = wp_parse_args( $db_settings, $defaults );
289
+
290
+            /**
291
+             * Filter the Font Awesome settings.
292
+             *
293
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
294
+             */
295
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
296
+        }
297
+
298
+
299
+        /**
300
+         * The settings page html output.
301
+         */
302
+        public function settings_page() {
303
+            if ( ! current_user_can( 'manage_options' ) ) {
304
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
305
+            }
306
+
307
+            // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
308
+            if ( isset( $_REQUEST['force-version-check'] ) ) {
309
+                $this->get_latest_version( $force_api = true );
310
+            }
311
+            ?>
312 312
 			<style>
313 313
 				.wpfas-kit-show {
314 314
 					display: none;
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 				<h1><?php echo $this->name; ?></h1>
327 327
 				<form method="post" action="options.php">
328 328
 					<?php
329
-					settings_fields( 'wp-font-awesome-settings' );
330
-					do_settings_sections( 'wp-font-awesome-settings' );
331
-					$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
332
-					?>
329
+                    settings_fields( 'wp-font-awesome-settings' );
330
+                    do_settings_sections( 'wp-font-awesome-settings' );
331
+                    $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
332
+                    ?>
333 333
 					<table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
334 334
 						<tr valign="top">
335 335
 							<th scope="row"><label
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
 								       value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
356 356
 								       placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
357 357
 								<span><?php
358
-									echo sprintf(
359
-										__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
360
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
361
-										'</a>'
362
-									);
363
-									?></span>
358
+                                    echo sprintf(
359
+                                        __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
360
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
361
+                                        '</a>'
362
+                                    );
363
+                                    ?></span>
364 364
 							</td>
365 365
 						</tr>
366 366
 
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
 								<input type="checkbox" name="wp-font-awesome-settings[pro]"
421 421
 								       value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
422 422
 								<span><?php
423
-									echo sprintf(
424
-										__( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
425
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
426
-										'</a>',
427
-										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
428
-										'</a>'
429
-									);
430
-									?></span>
423
+                                    echo sprintf(
424
+                                        __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
425
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
426
+                                        '</a>',
427
+                                        '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
428
+                                        '</a>'
429
+                                    );
430
+                                    ?></span>
431 431
 							</td>
432 432
 						</tr>
433 433
 
@@ -470,88 +470,88 @@  discard block
 block discarded – undo
470 470
 
471 471
 					</table>
472 472
 					<?php
473
-					submit_button();
474
-					?>
473
+                    submit_button();
474
+                    ?>
475 475
 				</form>
476 476
 
477 477
 				<div id="wpfas-version"><?php echo $this->version; ?></div>
478 478
 			</div>
479 479
 
480 480
 			<?php
481
-		}
482
-
483
-		/**
484
-		 * Check a version number is valid and if so return it or else return an empty string.
485
-		 *
486
-		 * @param $version string The version number to check.
487
-		 *
488
-		 * @since 1.0.6
489
-		 *
490
-		 * @return string Either a valid version number or an empty string.
491
-		 */
492
-		public function validate_version_number( $version ) {
493
-
494
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
495
-				// valid
496
-			} else {
497
-				$version = '';// not validated
498
-			}
499
-
500
-			return $version;
501
-		}
502
-
503
-
504
-		/**
505
-		 * Get the latest version of Font Awesome.
506
-		 *
507
-		 * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
508
-		 *
509
-		 * @since 1.0.7
510
-		 * @return mixed|string The latest version number found.
511
-		 */
512
-		public function get_latest_version( $force_api = false ) {
513
-			$latest_version = $this->latest;
514
-
515
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
516
-
517
-			if ( $cache === false || $force_api ) { // its not set
518
-				$api_ver = $this->get_latest_version_from_api();
519
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
520
-					$latest_version = $api_ver;
521
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
522
-				}
523
-			} elseif ( $this->validate_version_number( $cache ) ) {
524
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
525
-					$latest_version = $cache;
526
-				}
527
-			}
528
-
529
-			return $latest_version;
530
-		}
531
-
532
-		/**
533
-		 * Get the latest Font Awesome version from the github API.
534
-		 *
535
-		 * @since 1.0.7
536
-		 * @return string The latest version number or `0` on API fail.
537
-		 */
538
-		public function get_latest_version_from_api() {
539
-			$version  = "0";
540
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
541
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
542
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
543
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
544
-					$version = $api_response['tag_name'];
545
-				}
546
-			}
547
-
548
-			return $version;
549
-		}
550
-
551
-	}
552
-
553
-	/**
554
-	 * Run the class if found.
555
-	 */
556
-	WP_Font_Awesome_Settings::instance();
481
+        }
482
+
483
+        /**
484
+         * Check a version number is valid and if so return it or else return an empty string.
485
+         *
486
+         * @param $version string The version number to check.
487
+         *
488
+         * @since 1.0.6
489
+         *
490
+         * @return string Either a valid version number or an empty string.
491
+         */
492
+        public function validate_version_number( $version ) {
493
+
494
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
495
+                // valid
496
+            } else {
497
+                $version = '';// not validated
498
+            }
499
+
500
+            return $version;
501
+        }
502
+
503
+
504
+        /**
505
+         * Get the latest version of Font Awesome.
506
+         *
507
+         * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
508
+         *
509
+         * @since 1.0.7
510
+         * @return mixed|string The latest version number found.
511
+         */
512
+        public function get_latest_version( $force_api = false ) {
513
+            $latest_version = $this->latest;
514
+
515
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
516
+
517
+            if ( $cache === false || $force_api ) { // its not set
518
+                $api_ver = $this->get_latest_version_from_api();
519
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
520
+                    $latest_version = $api_ver;
521
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
522
+                }
523
+            } elseif ( $this->validate_version_number( $cache ) ) {
524
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
525
+                    $latest_version = $cache;
526
+                }
527
+            }
528
+
529
+            return $latest_version;
530
+        }
531
+
532
+        /**
533
+         * Get the latest Font Awesome version from the github API.
534
+         *
535
+         * @since 1.0.7
536
+         * @return string The latest version number or `0` on API fail.
537
+         */
538
+        public function get_latest_version_from_api() {
539
+            $version  = "0";
540
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
541
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
542
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
543
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
544
+                    $version = $api_response['tag_name'];
545
+                }
546
+            }
547
+
548
+            return $version;
549
+        }
550
+
551
+    }
552
+
553
+    /**
554
+     * Run the class if found.
555
+     */
556
+    WP_Font_Awesome_Settings::instance();
557 557
 }
558 558
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 		 * @return WP_Font_Awesome_Settings - Main instance.
88 88
 		 */
89 89
 		public static function instance() {
90
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
90
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
91 91
 				self::$instance = new WP_Font_Awesome_Settings;
92 92
 
93
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
93
+				add_action('init', array(self::$instance, 'init')); // set settings
94 94
 
95
-				if ( is_admin() ) {
96
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
97
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
95
+				if (is_admin()) {
96
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
97
+					add_action('admin_init', array(self::$instance, 'register_settings'));
98 98
 				}
99 99
 
100
-				do_action( 'wp_font_awesome_settings_loaded' );
100
+				do_action('wp_font_awesome_settings_loaded');
101 101
 			}
102 102
 
103 103
 			return self::$instance;
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 		public function init() {
112 112
 			$this->settings = $this->get_settings();
113 113
 
114
-			if ( $this->settings['type'] == 'CSS' ) {
114
+			if ($this->settings['type'] == 'CSS') {
115 115
 
116
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
116
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
117
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000);
118 118
 				}
119 119
 
120
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
120
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
121
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
122 122
 				}
123 123
 
124 124
 			} else {
125 125
 
126
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
127
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
126
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
127
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
128 128
 				}
129 129
 
130
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
131
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
130
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
131
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
132 132
 				}
133 133
 			}
134 134
 
135 135
 			// remove font awesome if set to do so
136
-			if ( $this->settings['dequeue'] == '1' ) {
137
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
136
+			if ($this->settings['dequeue'] == '1') {
137
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
138 138
 			}
139 139
 
140 140
 		}
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 			// build url
147 147
 			$url = $this->get_url();
148 148
 
149
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
150
-			wp_register_style( 'font-awesome', $url, array(), null );
151
-			wp_enqueue_style( 'font-awesome' );
149
+			wp_deregister_style('font-awesome'); // deregister in case its already there
150
+			wp_register_style('font-awesome', $url, array(), null);
151
+			wp_enqueue_style('font-awesome');
152 152
 
153
-			if ( $this->settings['shims'] ) {
154
-				$url = $this->get_url( true );
155
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
156
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
157
-				wp_enqueue_style( 'font-awesome-shims' );
153
+			if ($this->settings['shims']) {
154
+				$url = $this->get_url(true);
155
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
156
+				wp_register_style('font-awesome-shims', $url, array(), null);
157
+				wp_enqueue_style('font-awesome-shims');
158 158
 			}
159 159
 		}
160 160
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			$url = $this->get_url();
167 167
 
168 168
 			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
169
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
170
-			wp_register_script( 'font-awesome', $url, array(), null );
171
-			wp_enqueue_script( 'font-awesome' );
172
-
173
-			if ( $this->settings['shims'] ) {
174
-				$url = $this->get_url( true );
175
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
176
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
177
-				wp_enqueue_script( 'font-awesome-shims' );
169
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
170
+			wp_register_script('font-awesome', $url, array(), null);
171
+			wp_enqueue_script('font-awesome');
172
+
173
+			if ($this->settings['shims']) {
174
+				$url = $this->get_url(true);
175
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
176
+				wp_register_script('font-awesome-shims', $url, array(), null);
177
+				wp_enqueue_script('font-awesome-shims');
178 178
 			}
179 179
 		}
180 180
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
 		 *
186 186
 		 * @return string The url to the file.
187 187
 		 */
188
-		public function get_url( $shims = false ) {
188
+		public function get_url($shims = false) {
189 189
 			$script  = $shims ? 'v4-shims' : 'all';
190 190
 			$sub     = $this->settings['pro'] ? 'pro' : 'use';
191 191
 			$type    = $this->settings['type'];
192 192
 			$version = $this->settings['version'];
193
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
193
+			$kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : '';
194 194
 			$url     = '';
195 195
 
196
-			if ( $type == 'KIT' && $kit_url ) {
197
-				if ( $shims ) {
196
+			if ($type == 'KIT' && $kit_url) {
197
+				if ($shims) {
198 198
 					// if its a kit then we don't add shims here
199 199
 					return '';
200 200
 				}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				$url .= "?wpfas=true"; // set our var so our version is not removed
203 203
 			} else {
204 204
 				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
205
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
205
+				$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
206 206
 				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
207 207
 				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
208 208
 				$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
 		 *
223 223
 		 * @return string The filtered url.
224 224
 		 */
225
-		public function remove_font_awesome( $url, $original_url, $_context ) {
225
+		public function remove_font_awesome($url, $original_url, $_context) {
226 226
 
227
-			if ( $_context == 'display'
228
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
229
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
227
+			if ($_context == 'display'
228
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
229
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
230 230
 			) {// it's a font-awesome-url (probably)
231 231
 
232
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
233
-					if ( $this->settings['type'] == 'JS' ) {
234
-						if ( $this->settings['js-pseudo'] ) {
232
+				if (strstr($url, "wpfas=true") !== false) {
233
+					if ($this->settings['type'] == 'JS') {
234
+						if ($this->settings['js-pseudo']) {
235 235
 							$url .= "' data-search-pseudo-elements defer='defer";
236 236
 						} else {
237 237
 							$url .= "' defer='defer";
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * Register the database settings with WordPress.
251 251
 		 */
252 252
 		public function register_settings() {
253
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
253
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
254 254
 		}
255 255
 
256 256
 		/**
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 		 */
260 260
 		public function menu_item() {
261 261
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
262
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
262
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
263 263
 				$this,
264 264
 				'settings_page'
265
-			) );
265
+			));
266 266
 		}
267 267
 
268 268
 		/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		 */
273 273
 		public function get_settings() {
274 274
 
275
-			$db_settings = get_option( 'wp-font-awesome-settings' );
275
+			$db_settings = get_option('wp-font-awesome-settings');
276 276
 
277 277
 			$defaults = array(
278 278
 				'type'      => 'CSS', // type to use, CSS or JS or KIT
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 				'kit-url'   => '', // the kit url
286 286
 			);
287 287
 
288
-			$settings = wp_parse_args( $db_settings, $defaults );
288
+			$settings = wp_parse_args($db_settings, $defaults);
289 289
 
290 290
 			/**
291 291
 			 * Filter the Font Awesome settings.
292 292
 			 *
293 293
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
294 294
 			 */
295
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
295
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
296 296
 		}
297 297
 
298 298
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 		 * The settings page html output.
301 301
 		 */
302 302
 		public function settings_page() {
303
-			if ( ! current_user_can( 'manage_options' ) ) {
304
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
303
+			if (!current_user_can('manage_options')) {
304
+				wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings'));
305 305
 			}
306 306
 
307 307
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
308
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
309
-				$this->get_latest_version( $force_api = true );
308
+			if (isset($_REQUEST['force-version-check'])) {
309
+				$this->get_latest_version($force_api = true);
310 310
 			}
311 311
 			?>
312 312
 			<style>
@@ -326,37 +326,37 @@  discard block
 block discarded – undo
326 326
 				<h1><?php echo $this->name; ?></h1>
327 327
 				<form method="post" action="options.php">
328 328
 					<?php
329
-					settings_fields( 'wp-font-awesome-settings' );
330
-					do_settings_sections( 'wp-font-awesome-settings' );
329
+					settings_fields('wp-font-awesome-settings');
330
+					do_settings_sections('wp-font-awesome-settings');
331 331
 					$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
332 332
 					?>
333
-					<table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
333
+					<table class="form-table wpfas-table-settings <?php echo esc_attr($kit_set); ?>">
334 334
 						<tr valign="top">
335 335
 							<th scope="row"><label
336
-									for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
336
+									for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th>
337 337
 							<td>
338 338
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type"
339 339
 								        onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}">
340 340
 									<option
341
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option>
342
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
341
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option>
342
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
343 343
 									<option
344
-										value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option>
344
+										value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option>
345 345
 								</select>
346 346
 							</td>
347 347
 						</tr>
348 348
 
349 349
 						<tr valign="top" class="wpfas-kit-show">
350 350
 							<th scope="row"><label
351
-									for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th>
351
+									for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th>
352 352
 							<td>
353 353
 								<input class="regular-text" id="wpfas-kit-url" type="url"
354 354
 								       name="wp-font-awesome-settings[kit-url]"
355
-								       value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
356
-								       placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
355
+								       value="<?php echo esc_attr($this->settings['kit-url']); ?>"
356
+								       placeholder="<?php echo 'https://kit.font'; echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
357 357
 								<span><?php
358 358
 									echo sprintf(
359
-										__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
359
+										__('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'),
360 360
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
361 361
 										'</a>'
362 362
 									);
@@ -366,31 +366,31 @@  discard block
 block discarded – undo
366 366
 
367 367
 						<tr valign="top" class="wpfas-kit-hide">
368 368
 							<th scope="row"><label
369
-									for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th>
369
+									for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th>
370 370
 							<td>
371 371
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
372 372
 									<option
373
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?>
373
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?>
374 374
 									</option>
375
-									<option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>
375
+									<option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>
376 376
 										5.6.0
377 377
 									</option>
378
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
378
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
379 379
 										5.5.0
380 380
 									</option>
381
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
381
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
382 382
 										5.4.0
383 383
 									</option>
384
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
384
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
385 385
 										5.3.0
386 386
 									</option>
387
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
387
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
388 388
 										5.2.0
389 389
 									</option>
390
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
390
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
391 391
 										5.1.0
392 392
 									</option>
393
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
393
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
394 394
 										4.7.1 (CSS only)
395 395
 									</option>
396 396
 								</select>
@@ -399,29 +399,29 @@  discard block
 block discarded – undo
399 399
 
400 400
 						<tr valign="top">
401 401
 							<th scope="row"><label
402
-									for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th>
402
+									for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th>
403 403
 							<td>
404 404
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
405 405
 									<option
406
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option>
406
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option>
407 407
 									<option
408
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option>
408
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option>
409 409
 									<option
410
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option>
410
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option>
411 411
 								</select>
412 412
 							</td>
413 413
 						</tr>
414 414
 
415 415
 						<tr valign="top" class="wpfas-kit-hide">
416 416
 							<th scope="row"><label
417
-									for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th>
417
+									for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th>
418 418
 							<td>
419 419
 								<input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
420 420
 								<input type="checkbox" name="wp-font-awesome-settings[pro]"
421
-								       value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
421
+								       value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro"/>
422 422
 								<span><?php
423 423
 									echo sprintf(
424
-										__( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
424
+										__('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'),
425 425
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
426 426
 										'</a>',
427 427
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
@@ -433,38 +433,38 @@  discard block
 block discarded – undo
433 433
 
434 434
 						<tr valign="top" class="wpfas-kit-hide">
435 435
 							<th scope="row"><label
436
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label>
436
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label>
437 437
 							</th>
438 438
 							<td>
439 439
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
440 440
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
441
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
442
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span>
441
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
442
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span>
443 443
 							</td>
444 444
 						</tr>
445 445
 
446 446
 						<tr valign="top" class="wpfas-kit-hide">
447 447
 							<th scope="row"><label
448
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label>
448
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label>
449 449
 							</th>
450 450
 							<td>
451 451
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
452 452
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
453
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
453
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
454 454
 								       id="wpfas-js-pseudo"/>
455
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span>
455
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span>
456 456
 							</td>
457 457
 						</tr>
458 458
 
459 459
 						<tr valign="top">
460 460
 							<th scope="row"><label
461
-									for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th>
461
+									for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th>
462 462
 							<td>
463 463
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
464 464
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
465
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
465
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
466 466
 								       id="wpfas-dequeue"/>
467
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span>
467
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span>
468 468
 							</td>
469 469
 						</tr>
470 470
 
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
 		 *
490 490
 		 * @return string Either a valid version number or an empty string.
491 491
 		 */
492
-		public function validate_version_number( $version ) {
492
+		public function validate_version_number($version) {
493 493
 
494
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
494
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
495 495
 				// valid
496 496
 			} else {
497
-				$version = '';// not validated
497
+				$version = ''; // not validated
498 498
 			}
499 499
 
500 500
 			return $version;
@@ -509,19 +509,19 @@  discard block
 block discarded – undo
509 509
 		 * @since 1.0.7
510 510
 		 * @return mixed|string The latest version number found.
511 511
 		 */
512
-		public function get_latest_version( $force_api = false ) {
512
+		public function get_latest_version($force_api = false) {
513 513
 			$latest_version = $this->latest;
514 514
 
515
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
515
+			$cache = get_transient('wp-font-awesome-settings-version');
516 516
 
517
-			if ( $cache === false || $force_api ) { // its not set
517
+			if ($cache === false || $force_api) { // its not set
518 518
 				$api_ver = $this->get_latest_version_from_api();
519
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
519
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
520 520
 					$latest_version = $api_ver;
521
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
521
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
522 522
 				}
523
-			} elseif ( $this->validate_version_number( $cache ) ) {
524
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
523
+			} elseif ($this->validate_version_number($cache)) {
524
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
525 525
 					$latest_version = $cache;
526 526
 				}
527 527
 			}
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
 		 */
538 538
 		public function get_latest_version_from_api() {
539 539
 			$version  = "0";
540
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
541
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
542
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
543
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
540
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
541
+			if (!is_wp_error($response) && is_array($response)) {
542
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
543
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
544 544
 					$version = $api_response['tag_name'];
545 545
 				}
546 546
 			}
Please login to merge, or discard this patch.