Passed
Push — master ( 59160c...9fabf9 )
by Kiran
10:03 queued 05:25
created
includes/class-getpaid-subscription-notification-emails.php 1 patch
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -13,325 +13,325 @@
 block discarded – undo
13 13
 class GetPaid_Subscription_Notification_Emails {
14 14
 
15 15
     /**
16
-	 * The array of subscription email actions.
17
-	 *
18
-	 * @param array
19
-	 */
20
-	public $subscription_actions;
16
+     * The array of subscription email actions.
17
+     *
18
+     * @param array
19
+     */
20
+    public $subscription_actions;
21 21
 
22 22
     /**
23
-	 * Class constructor
23
+     * Class constructor
24 24
      *
25
-	 */
26
-	public function __construct() {
27
-
28
-		$this->subscription_actions = apply_filters(
29
-			'getpaid_notification_email_subscription_triggers',
30
-			array(
31
-				'getpaid_subscription_active'    => 'subscription_active',
32
-				'getpaid_subscription_trialling' => 'subscription_trial',
33
-				'getpaid_subscription_cancelled' => 'subscription_cancelled',
34
-				'getpaid_subscription_expired'   => 'subscription_expired',
35
-				'getpaid_subscription_completed' => 'subscription_complete',
36
-				'getpaid_daily_maintenance'      => 'renewal_reminder'
37
-			)
38
-		);
39
-
40
-		$this->init_hooks();
25
+     */
26
+    public function __construct() {
27
+
28
+        $this->subscription_actions = apply_filters(
29
+            'getpaid_notification_email_subscription_triggers',
30
+            array(
31
+                'getpaid_subscription_active'    => 'subscription_active',
32
+                'getpaid_subscription_trialling' => 'subscription_trial',
33
+                'getpaid_subscription_cancelled' => 'subscription_cancelled',
34
+                'getpaid_subscription_expired'   => 'subscription_expired',
35
+                'getpaid_subscription_completed' => 'subscription_complete',
36
+                'getpaid_daily_maintenance'      => 'renewal_reminder'
37
+            )
38
+        );
39
+
40
+        $this->init_hooks();
41 41
 
42 42
     }
43 43
 
44 44
     /**
45
-	 * Registers email hooks.
46
-	 */
47
-	public function init_hooks() {
48
-
49
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
50
-		foreach ( $this->subscription_actions as $hook => $email_type ) {
51
-
52
-			$email = new GetPaid_Notification_Email( $email_type );
53
-
54
-			if ( ! $email->is_active() ) {
55
-				continue;
56
-			}
57
-
58
-			if ( method_exists( $this, $email_type ) ) {
59
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
60
-				continue;
61
-			}
62
-
63
-			do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
64
-
65
-		}
66
-
67
-	}
68
-
69
-	/**
70
-	 * Filters subscription merge tags.
71
-	 *
72
-	 * @param array $merge_tags
73
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
74
-	 */
75
-	public function subscription_merge_tags( $merge_tags, $object ) {
76
-
77
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
78
-			$merge_tags = array_merge(
79
-				$merge_tags,
80
-				$this->get_subscription_merge_tags( $object )
81
-			);
82
-		}
83
-
84
-		return $merge_tags;
85
-
86
-	}
87
-
88
-	/**
89
-	 * Generates subscription merge tags.
90
-	 *
91
-	 * @param WPInv_Subscription $subscription
92
-	 * @return array
93
-	 */
94
-	public function get_subscription_merge_tags( $subscription ) {
95
-
96
-		// Abort if it does not exist.
97
-		if ( ! $subscription->get_id() ) {
98
-			return array();
99
-		}
100
-
101
-		$invoice    = $subscription->get_parent_invoice();
102
-		return array(
103
-			'{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
104
-			'{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
105
-			'{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
106
-			'{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
107
-			'{subscription_id}'               => absint( $subscription->get_id() ),
108
-			'{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
109
-			'{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
110
-			'{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
111
-			'{subscription_bill_times}'       => $subscription->get_bill_times(),
112
-			'{subscription_url}'              => esc_url( $subscription->get_view_url() ),
113
-		);
114
-
115
-	}
116
-
117
-	/**
118
-	 * Checks if we should send a notification for a subscription.
119
-	 *
120
-	 * @param WPInv_Invoice $invoice
121
-	 * @return bool
122
-	 */
123
-	public function should_send_notification( $invoice ) {
124
-		return 0 != $invoice->get_id();
125
-	}
126
-
127
-	/**
128
-	 * Returns notification recipients.
129
-	 *
130
-	 * @param WPInv_Invoice $invoice
131
-	 * @return array
132
-	 */
133
-	public function get_recipients( $invoice ) {
134
-		$recipients = array( $invoice->get_email() );
135
-
136
-		$cc = $invoice->get_email_cc();
137
-
138
-		if ( ! empty( $cc ) ) {
139
-			$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
140
-			$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
141
-		}
142
-
143
-		return $recipients;
144
-	}
145
-
146
-	/**
147
-	 * Helper function to send an email.
148
-	 *
149
-	 * @param WPInv_Subscription $subscription
150
-	 * @param GetPaid_Notification_Email $email
151
-	 * @param string $type
152
-	 * @param array $extra_args Extra template args.
153
-	 */
154
-	public function send_email( $subscription, $email, $type, $extra_args = array() ) {
155
-
156
-		if ( empty( $subscription ) ) {
157
-			return;
158
-		}
159
-
160
-		if ( is_array( $subscription ) ) {
161
-			$subscription = current( $subscription );
162
-		}
163
-
164
-		if ( ! $subscription instanceof WPInv_Subscription ) {
165
-			return;
166
-		}
167
-
168
-		// Abort in case the parent invoice does not exist.
169
-		$invoice = $subscription->get_parent_invoice();
170
-		if ( ! $this->should_send_notification( $invoice ) ) {
171
-			return;
172
-		}
173
-
174
-		if ( apply_filters( 'getpaid_skip_subscription_email', false, $type, $subscription ) ) {
175
-			return;
176
-		}
177
-
178
-		do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
179
-
180
-		$recipients  = $this->get_recipients( $invoice );
181
-		$mailer      = new GetPaid_Notification_Email_Sender();
182
-		$merge_tags  = $email->get_merge_tags();
183
-		$content     = $email->get_content( $merge_tags, $extra_args );
184
-		$subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
185
-		$attachments = $email->get_attachments();
186
-
187
-		$result = $mailer->send(
188
-			apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
189
-			$subject,
190
-			$content,
191
-			$attachments
192
-		);
193
-
194
-		// Maybe send a copy to the admin.
195
-		if ( $email->include_admin_bcc() ) {
196
-			$mailer->send(
197
-				wpinv_get_admin_email(),
198
-				$subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
199
-				$content,
200
-				$attachments
201
-			);
202
-		}
203
-
204
-		if ( $result ) {
205
-			$invoice->add_system_note(
206
-				sprintf(
207
-					__( 'Successfully sent %1$s notification email to %2$s.', 'invoicing' ),
208
-					sanitize_key( $type ),
209
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
210
-				)
211
-			);
212
-		} else {
213
-			$invoice->add_system_note(
214
-				sprintf(
215
-					__( 'Failed sending %1$s notification email to %2$s.', 'invoicing' ),
216
-					sanitize_key( $type ),
217
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
218
-				)
219
-			);
220
-		}
221
-
222
-		do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
223
-
224
-	}
225
-
226
-	/**
227
-	 * Sends a subscription active.
228
-	 *
229
-	 * @since 2.8.4
230
-	 *
231
-	 * @param WPInv_Subscription $subscription
232
-	 */
233
-	public function subscription_active( $subscription ) {
234
-		$email = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
235
-
236
-		$this->send_email( $subscription, $email, __FUNCTION__ );
237
-	}
45
+     * Registers email hooks.
46
+     */
47
+    public function init_hooks() {
48
+
49
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 );
50
+        foreach ( $this->subscription_actions as $hook => $email_type ) {
51
+
52
+            $email = new GetPaid_Notification_Email( $email_type );
53
+
54
+            if ( ! $email->is_active() ) {
55
+                continue;
56
+            }
57
+
58
+            if ( method_exists( $this, $email_type ) ) {
59
+                add_action( $hook, array( $this, $email_type ), 100, 2 );
60
+                continue;
61
+            }
62
+
63
+            do_action( 'getpaid_subscription_notification_email_register_hook', $email_type, $hook );
64
+
65
+        }
66
+
67
+    }
238 68
 
239 69
     /**
240
-	 * Sends a new trial notification.
241
-	 *
242
-	 * @param WPInv_Subscription $subscription
243
-	 */
244
-	public function subscription_trial( $subscription ) {
70
+     * Filters subscription merge tags.
71
+     *
72
+     * @param array $merge_tags
73
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
74
+     */
75
+    public function subscription_merge_tags( $merge_tags, $object ) {
245 76
 
246
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
247
-		$this->send_email( $subscription, $email, __FUNCTION__ );
77
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
78
+            $merge_tags = array_merge(
79
+                $merge_tags,
80
+                $this->get_subscription_merge_tags( $object )
81
+            );
82
+        }
248 83
 
249
-	}
84
+        return $merge_tags;
250 85
 
251
-	/**
252
-	 * Sends a cancelled subscription notification.
253
-	 *
254
-	 * @param WPInv_Subscription $subscription
255
-	 */
256
-	public function subscription_cancelled( $subscription ) {
86
+    }
257 87
 
258
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
259
-		$this->send_email( $subscription, $email, __FUNCTION__ );
88
+    /**
89
+     * Generates subscription merge tags.
90
+     *
91
+     * @param WPInv_Subscription $subscription
92
+     * @return array
93
+     */
94
+    public function get_subscription_merge_tags( $subscription ) {
95
+
96
+        // Abort if it does not exist.
97
+        if ( ! $subscription->get_id() ) {
98
+            return array();
99
+        }
100
+
101
+        $invoice    = $subscription->get_parent_invoice();
102
+        return array(
103
+            '{subscription_renewal_date}'     => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ),
104
+            '{subscription_created}'          => getpaid_format_date_value( $subscription->get_date_created() ),
105
+            '{subscription_status}'           => sanitize_text_field( $subscription->get_status_label() ),
106
+            '{subscription_profile_id}'       => sanitize_text_field( $subscription->get_profile_id() ),
107
+            '{subscription_id}'               => absint( $subscription->get_id() ),
108
+            '{subscription_recurring_amount}' => sanitize_text_field( wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ) ),
109
+            '{subscription_initial_amount}'   => sanitize_text_field( wpinv_price( $subscription->get_initial_amount(), $invoice->get_currency() ) ),
110
+            '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ),
111
+            '{subscription_bill_times}'       => $subscription->get_bill_times(),
112
+            '{subscription_url}'              => esc_url( $subscription->get_view_url() ),
113
+        );
260 114
 
261
-	}
115
+    }
262 116
 
263
-	/**
264
-	 * Sends a subscription expired notification.
265
-	 *
266
-	 * @param WPInv_Subscription $subscription
267
-	 */
268
-	public function subscription_expired( $subscription ) {
117
+    /**
118
+     * Checks if we should send a notification for a subscription.
119
+     *
120
+     * @param WPInv_Invoice $invoice
121
+     * @return bool
122
+     */
123
+    public function should_send_notification( $invoice ) {
124
+        return 0 != $invoice->get_id();
125
+    }
269 126
 
270
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
271
-		$this->send_email( $subscription, $email, __FUNCTION__ );
127
+    /**
128
+     * Returns notification recipients.
129
+     *
130
+     * @param WPInv_Invoice $invoice
131
+     * @return array
132
+     */
133
+    public function get_recipients( $invoice ) {
134
+        $recipients = array( $invoice->get_email() );
272 135
 
273
-	}
136
+        $cc = $invoice->get_email_cc();
274 137
 
275
-	/**
276
-	 * Sends a completed subscription notification.
277
-	 *
278
-	 * @param WPInv_Subscription $subscription
279
-	 */
280
-	public function subscription_complete( $subscription ) {
138
+        if ( ! empty( $cc ) ) {
139
+            $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
140
+            $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
141
+        }
281 142
 
282
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
283
-		$this->send_email( $subscription, $email, __FUNCTION__ );
143
+        return $recipients;
144
+    }
284 145
 
285
-	}
146
+    /**
147
+     * Helper function to send an email.
148
+     *
149
+     * @param WPInv_Subscription $subscription
150
+     * @param GetPaid_Notification_Email $email
151
+     * @param string $type
152
+     * @param array $extra_args Extra template args.
153
+     */
154
+    public function send_email( $subscription, $email, $type, $extra_args = array() ) {
155
+
156
+        if ( empty( $subscription ) ) {
157
+            return;
158
+        }
159
+
160
+        if ( is_array( $subscription ) ) {
161
+            $subscription = current( $subscription );
162
+        }
163
+
164
+        if ( ! $subscription instanceof WPInv_Subscription ) {
165
+            return;
166
+        }
167
+
168
+        // Abort in case the parent invoice does not exist.
169
+        $invoice = $subscription->get_parent_invoice();
170
+        if ( ! $this->should_send_notification( $invoice ) ) {
171
+            return;
172
+        }
173
+
174
+        if ( apply_filters( 'getpaid_skip_subscription_email', false, $type, $subscription ) ) {
175
+            return;
176
+        }
177
+
178
+        do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email );
179
+
180
+        $recipients  = $this->get_recipients( $invoice );
181
+        $mailer      = new GetPaid_Notification_Email_Sender();
182
+        $merge_tags  = $email->get_merge_tags();
183
+        $content     = $email->get_content( $merge_tags, $extra_args );
184
+        $subject     = $email->add_merge_tags( $email->get_subject(), $merge_tags );
185
+        $attachments = $email->get_attachments();
186
+
187
+        $result = $mailer->send(
188
+            apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ),
189
+            $subject,
190
+            $content,
191
+            $attachments
192
+        );
193
+
194
+        // Maybe send a copy to the admin.
195
+        if ( $email->include_admin_bcc() ) {
196
+            $mailer->send(
197
+                wpinv_get_admin_email(),
198
+                $subject . __( ' - ADMIN BCC COPY', 'invoicing' ),
199
+                $content,
200
+                $attachments
201
+            );
202
+        }
203
+
204
+        if ( $result ) {
205
+            $invoice->add_system_note(
206
+                sprintf(
207
+                    __( 'Successfully sent %1$s notification email to %2$s.', 'invoicing' ),
208
+                    sanitize_key( $type ),
209
+                    $email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
210
+                )
211
+            );
212
+        } else {
213
+            $invoice->add_system_note(
214
+                sprintf(
215
+                    __( 'Failed sending %1$s notification email to %2$s.', 'invoicing' ),
216
+                    sanitize_key( $type ),
217
+                    $email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
218
+                )
219
+            );
220
+        }
221
+
222
+        do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email );
286 223
 
287
-	/**
288
-	 * Sends a subscription renewal reminder notification.
289
-	 *
290
-	 */
291
-	public function renewal_reminder() {
224
+    }
292 225
 
293
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
226
+    /**
227
+     * Sends a subscription active.
228
+     *
229
+     * @since 2.8.4
230
+     *
231
+     * @param WPInv_Subscription $subscription
232
+     */
233
+    public function subscription_active( $subscription ) {
234
+        $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
294 235
 
295
-		// Fetch reminder days.
296
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
236
+        $this->send_email( $subscription, $email, __FUNCTION__ );
237
+    }
297 238
 
298
-		// Abort if non is set.
299
-		if ( empty( $reminder_days ) ) {
300
-			return;
301
-		}
239
+    /**
240
+     * Sends a new trial notification.
241
+     *
242
+     * @param WPInv_Subscription $subscription
243
+     */
244
+    public function subscription_trial( $subscription ) {
302 245
 
303
-		// Fetch matching subscriptions.
246
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
247
+        $this->send_email( $subscription, $email, __FUNCTION__ );
248
+
249
+    }
250
+
251
+    /**
252
+     * Sends a cancelled subscription notification.
253
+     *
254
+     * @param WPInv_Subscription $subscription
255
+     */
256
+    public function subscription_cancelled( $subscription ) {
257
+
258
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
259
+        $this->send_email( $subscription, $email, __FUNCTION__ );
260
+
261
+    }
262
+
263
+    /**
264
+     * Sends a subscription expired notification.
265
+     *
266
+     * @param WPInv_Subscription $subscription
267
+     */
268
+    public function subscription_expired( $subscription ) {
269
+
270
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
271
+        $this->send_email( $subscription, $email, __FUNCTION__ );
272
+
273
+    }
274
+
275
+    /**
276
+     * Sends a completed subscription notification.
277
+     *
278
+     * @param WPInv_Subscription $subscription
279
+     */
280
+    public function subscription_complete( $subscription ) {
281
+
282
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $subscription );
283
+        $this->send_email( $subscription, $email, __FUNCTION__ );
284
+
285
+    }
286
+
287
+    /**
288
+     * Sends a subscription renewal reminder notification.
289
+     *
290
+     */
291
+    public function renewal_reminder() {
292
+
293
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
294
+
295
+        // Fetch reminder days.
296
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
297
+
298
+        // Abort if non is set.
299
+        if ( empty( $reminder_days ) ) {
300
+            return;
301
+        }
302
+
303
+        // Fetch matching subscriptions.
304 304
         $args  = array(
305 305
             'number'             => -1,
306
-			'count_total'        => false,
307
-			'status'             => 'trialling active',
306
+            'count_total'        => false,
307
+            'status'             => 'trialling active',
308 308
             'date_expires_query' => array(
309
-				'relation' => 'OR',
309
+                'relation' => 'OR',
310 310
             ),
311
-		);
311
+        );
312 312
 
313
-		foreach ( $reminder_days as $days ) {
314
-			$date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
313
+        foreach ( $reminder_days as $days ) {
314
+            $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) );
315 315
 
316
-			$args['date_expires_query'][] = array(
317
-				'year'  => $date['year'],
318
-				'month' => $date['month'],
319
-				'day'   => $date['day'],
320
-			);
316
+            $args['date_expires_query'][] = array(
317
+                'year'  => $date['year'],
318
+                'month' => $date['month'],
319
+                'day'   => $date['day'],
320
+            );
321 321
 
322
-		}
322
+        }
323 323
 
324
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
324
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
325 325
 
326 326
         foreach ( $subscriptions->get_results() as $subscription ) {
327 327
 
328
-			// Skip packages.
329
-			if ( apply_filters( 'getpaid_send_subscription_renewal_reminder_email', true ) ) {
330
-				$email->object = $subscription;
331
-            	$this->send_email( $subscription, $email, __FUNCTION__ );
332
-			}
333
-		}
328
+            // Skip packages.
329
+            if ( apply_filters( 'getpaid_send_subscription_renewal_reminder_email', true ) ) {
330
+                $email->object = $subscription;
331
+                $this->send_email( $subscription, $email, __FUNCTION__ );
332
+            }
333
+        }
334 334
 
335
-	}
335
+    }
336 336
 
337 337
 }
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 1 patch
Indentation   +1261 added lines, -1261 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,1284 +11,1284 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Input {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function input( $args = array() ) {
22
-		global $aui_bs5;
23
-
24
-		$defaults = array(
25
-			'type'                     => 'text',
26
-			'name'                     => '',
27
-			'class'                    => '',
28
-			'wrap_class'               => '',
29
-			'id'                       => '',
30
-			'placeholder'              => '',
31
-			'title'                    => '',
32
-			'value'                    => '',
33
-			'required'                 => false,
34
-			'size'                     => '', // sm, lg, small, large
35
-			'clear_icon'               => '', // true will show a clear icon, can't be used with input_group_right
36
-			'with_hidden'              => false, // Append hidden field for single checkbox.
37
-			'label'                    => '',
38
-			'label_after'              => false,
39
-			'label_class'              => '',
40
-			'label_col'                => '2',
41
-			'label_type'               => '', // top, horizontal, empty = hidden
42
-			'label_force_left'         => false, // used to force checkbox label left when using horizontal
43
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
44
-			'help_text'                => '',
45
-			'validation_text'          => '',
46
-			'validation_pattern'       => '',
47
-			'no_wrap'                  => false,
48
-			'input_group_right'        => '',
49
-			'input_group_left'         => '',
50
-			'input_group_right_inside' => false,
51
-			// forces the input group inside the input
52
-			'input_group_left_inside'  => false,
53
-			// forces the input group inside the input
54
-			'form_group_class'         => '',
55
-			'step'                     => '',
56
-			'switch'                   => false,
57
-			// to show checkbox as a switch
58
-			'checked'                  => false,
59
-			// set a checkbox or radio as selected
60
-			'password_toggle'          => true,
61
-			// toggle view/hide password
62
-			'element_require'          => '',
63
-			// [%element_id%] == "1"
64
-			'extra_attributes'         => array(),
65
-			// an array of extra attributes
66
-			'wrap_attributes'          => array()
67
-		);
68
-
69
-		/**
70
-		 * Parse incoming $args into an array and merge it with $defaults
71
-		 */
72
-		$args   = wp_parse_args( $args, $defaults );
73
-		$output = '';
74
-		if ( ! empty( $args['type'] ) ) {
75
-			// hidden label option needs to be empty
76
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
77
-
78
-			$type = sanitize_html_class( $args['type'] );
79
-
80
-			$help_text   = '';
81
-			$label       = '';
82
-			$label_after = $args['label_after'];
83
-			$label_args  = array(
84
-				'title'      => $args['label'],
85
-				'for'        => $args['id'],
86
-				'class'      => $args['label_class'] . " ",
87
-				'label_type' => $args['label_type'],
88
-				'label_col'  => $args['label_col']
89
-			);
90
-
91
-			// floating labels need label after
92
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
93
-				$label_after         = true;
94
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
95
-			}
96
-
97
-			// size
98
-			$size = '';
99
-			if ( $args['size'] == 'lg' || $args['size'] == 'large' ) {
100
-				$size = 'lg';
101
-				$args['class'] .= ' form-control-lg';
102
-			}elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) {
103
-				$size = 'sm';
104
-				$args['class'] .= ' form-control-sm';
105
-			}
106
-
107
-			// clear function
108
-			$clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');';
109
-
110
-			// Some special sauce for files
111
-			if ( $type == 'file' ) {
112
-				$label_after = true; // if type file we need the label after
113
-				$args['class'] .= ' custom-file-input ';
114
-			} elseif ( $type == 'checkbox' ) {
115
-				$label_after = true; // if type file we need the label after
116
-				$args['class'] .= $aui_bs5 ? ' form-check-input' : ' custom-control-input ';
117
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
118
-				$orig_type = $type;
119
-				$type = 'text';
120
-				$args['class'] .= ' bg-initial '; // @todo not sure why we have this?
121
-				$clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');";
122
-
123
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
124
-
125
-				// Disable native datetime inputs.
126
-				$disable_mobile_attr = isset( $args['extra_attributes']['data-disable-mobile'] ) ? $args['extra_attributes']['data-disable-mobile'] : 'true';
127
-				$disable_mobile_attr = apply_filters( 'aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args );
128
-
129
-				$args['extra_attributes']['data-disable-mobile'] = $disable_mobile_attr;
130
-
131
-				// set a way to clear field if empty
132
-				if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) {
133
-					$args['input_group_right_inside'] = true;
134
-					$args['clear_icon'] = true;
135
-				}
136
-
137
-				// enqueue the script
138
-				$aui_settings = AyeCode_UI_Settings::instance();
139
-				$aui_settings->enqueue_flatpickr();
140
-			} elseif ( $type == 'iconpicker' ) {
141
-				$type = 'text';
142
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function input( $args = array() ) {
22
+        global $aui_bs5;
23
+
24
+        $defaults = array(
25
+            'type'                     => 'text',
26
+            'name'                     => '',
27
+            'class'                    => '',
28
+            'wrap_class'               => '',
29
+            'id'                       => '',
30
+            'placeholder'              => '',
31
+            'title'                    => '',
32
+            'value'                    => '',
33
+            'required'                 => false,
34
+            'size'                     => '', // sm, lg, small, large
35
+            'clear_icon'               => '', // true will show a clear icon, can't be used with input_group_right
36
+            'with_hidden'              => false, // Append hidden field for single checkbox.
37
+            'label'                    => '',
38
+            'label_after'              => false,
39
+            'label_class'              => '',
40
+            'label_col'                => '2',
41
+            'label_type'               => '', // top, horizontal, empty = hidden
42
+            'label_force_left'         => false, // used to force checkbox label left when using horizontal
43
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
44
+            'help_text'                => '',
45
+            'validation_text'          => '',
46
+            'validation_pattern'       => '',
47
+            'no_wrap'                  => false,
48
+            'input_group_right'        => '',
49
+            'input_group_left'         => '',
50
+            'input_group_right_inside' => false,
51
+            // forces the input group inside the input
52
+            'input_group_left_inside'  => false,
53
+            // forces the input group inside the input
54
+            'form_group_class'         => '',
55
+            'step'                     => '',
56
+            'switch'                   => false,
57
+            // to show checkbox as a switch
58
+            'checked'                  => false,
59
+            // set a checkbox or radio as selected
60
+            'password_toggle'          => true,
61
+            // toggle view/hide password
62
+            'element_require'          => '',
63
+            // [%element_id%] == "1"
64
+            'extra_attributes'         => array(),
65
+            // an array of extra attributes
66
+            'wrap_attributes'          => array()
67
+        );
68
+
69
+        /**
70
+         * Parse incoming $args into an array and merge it with $defaults
71
+         */
72
+        $args   = wp_parse_args( $args, $defaults );
73
+        $output = '';
74
+        if ( ! empty( $args['type'] ) ) {
75
+            // hidden label option needs to be empty
76
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
77
+
78
+            $type = sanitize_html_class( $args['type'] );
79
+
80
+            $help_text   = '';
81
+            $label       = '';
82
+            $label_after = $args['label_after'];
83
+            $label_args  = array(
84
+                'title'      => $args['label'],
85
+                'for'        => $args['id'],
86
+                'class'      => $args['label_class'] . " ",
87
+                'label_type' => $args['label_type'],
88
+                'label_col'  => $args['label_col']
89
+            );
90
+
91
+            // floating labels need label after
92
+            if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
93
+                $label_after         = true;
94
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
95
+            }
96
+
97
+            // size
98
+            $size = '';
99
+            if ( $args['size'] == 'lg' || $args['size'] == 'large' ) {
100
+                $size = 'lg';
101
+                $args['class'] .= ' form-control-lg';
102
+            }elseif ( $args['size'] == 'sm' || $args['size'] == 'small' ) {
103
+                $size = 'sm';
104
+                $args['class'] .= ' form-control-sm';
105
+            }
106
+
107
+            // clear function
108
+            $clear_function = 'jQuery(this).parent().parent().find(\'input\').val(\'\');';
109
+
110
+            // Some special sauce for files
111
+            if ( $type == 'file' ) {
112
+                $label_after = true; // if type file we need the label after
113
+                $args['class'] .= ' custom-file-input ';
114
+            } elseif ( $type == 'checkbox' ) {
115
+                $label_after = true; // if type file we need the label after
116
+                $args['class'] .= $aui_bs5 ? ' form-check-input' : ' custom-control-input ';
117
+            } elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
118
+                $orig_type = $type;
119
+                $type = 'text';
120
+                $args['class'] .= ' bg-initial '; // @todo not sure why we have this?
121
+                $clear_function .= "jQuery(this).parent().parent().find('input[name=\'" . esc_attr( $args['name'] ) . "\']').trigger('change');";
122
+
123
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
124
+
125
+                // Disable native datetime inputs.
126
+                $disable_mobile_attr = isset( $args['extra_attributes']['data-disable-mobile'] ) ? $args['extra_attributes']['data-disable-mobile'] : 'true';
127
+                $disable_mobile_attr = apply_filters( 'aui_flatpickr_disable_disable_mobile_attr', $disable_mobile_attr, $args );
128
+
129
+                $args['extra_attributes']['data-disable-mobile'] = $disable_mobile_attr;
130
+
131
+                // set a way to clear field if empty
132
+                if ( $args['input_group_right'] === '' && $args['clear_icon'] !== false ) {
133
+                    $args['input_group_right_inside'] = true;
134
+                    $args['clear_icon'] = true;
135
+                }
136
+
137
+                // enqueue the script
138
+                $aui_settings = AyeCode_UI_Settings::instance();
139
+                $aui_settings->enqueue_flatpickr();
140
+            } elseif ( $type == 'iconpicker' ) {
141
+                $type = 'text';
142
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
143 143
 //				$args['class'] .= ' bg-initial ';
144 144
 
145
-				$args['extra_attributes']['data-aui-init'] = 'iconpicker';
146
-				$args['extra_attributes']['data-placement'] = 'bottomRight';
145
+                $args['extra_attributes']['data-aui-init'] = 'iconpicker';
146
+                $args['extra_attributes']['data-placement'] = 'bottomRight';
147 147
 
148
-				$args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
148
+                $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
149 149
 //				$args['input_group_right_inside'] = true;
150
-				// enqueue the script
151
-				$aui_settings = AyeCode_UI_Settings::instance();
152
-				$aui_settings->enqueue_iconpicker();
153
-			}
154
-
155
-			if ( $type == 'checkbox' && ( ( ! empty( $args['name'] ) && strpos( $args['name'], '[' ) === false ) || ! empty( $args['with_hidden'] ) ) ) {
156
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
157
-			}
158
-
159
-			// allow clear icon
160
-			if ( $args['input_group_right'] === '' && $args['clear_icon'] ) {
161
-				$font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' );
162
-				$args['input_group_right_inside'] = true;
163
-				$align_class = $aui_bs5 ? ' h-100 py-0' : '';
164
-				$args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ( $aui_bs5 ? 'btn-close' : 'close' ) . '">' . ( $aui_bs5 ? '' : '&times;' ) . '</span></span>';
165
-			}
166
-
167
-			// open/type
168
-			$output .= '<input type="' . $type . '" ';
169
-
170
-			// name
171
-			if ( ! empty( $args['name'] ) ) {
172
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
173
-			}
174
-
175
-			// id
176
-			if ( ! empty( $args['id'] ) ) {
177
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
178
-			}
179
-
180
-			// placeholder
181
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
182
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
183
-			}
184
-
185
-			// title
186
-			if ( ! empty( $args['title'] ) ) {
187
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
188
-			}
189
-
190
-			// value
191
-			if ( ! empty( $args['value'] ) ) {
192
-				$output .= AUI_Component_Helper::value( $args['value'] );
193
-			}
194
-
195
-			// checked, for radio and checkboxes
196
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
197
-				$output .= ' checked ';
198
-			}
199
-
200
-			// validation text
201
-			if ( ! empty( $args['validation_text'] ) ) {
202
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" ';
203
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
204
-			}
205
-
206
-			// validation_pattern
207
-			if ( ! empty( $args['validation_pattern'] ) ) {
208
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
209
-			}
210
-
211
-			// step (for numbers)
212
-			if ( ! empty( $args['step'] ) ) {
213
-				$output .= ' step="' . $args['step'] . '" ';
214
-			}
215
-
216
-			// required
217
-			if ( ! empty( $args['required'] ) ) {
218
-				$output .= ' required ';
219
-			}
220
-
221
-			// class
222
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
223
-			$output .= $aui_bs5 &&  $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" ';
224
-
225
-			// data-attributes
226
-			$output .= AUI_Component_Helper::data_attributes( $args );
227
-
228
-			// extra attributes
229
-			if ( ! empty( $args['extra_attributes'] ) ) {
230
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
231
-			}
232
-
233
-			// close
234
-			$output .= ' >';
235
-
236
-			// help text
237
-			if ( ! empty( $args['help_text'] ) ) {
238
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
239
-			}
240
-
241
-			// label
242
-			if ( ! empty( $args['label'] ) ) {
243
-				$label_base_class = '';
244
-				if ( $type == 'file' ) {
245
-					$label_base_class = ' custom-file-label';
246
-				} elseif ( $type == 'checkbox' ) {
247
-					if ( ! empty( $args['label_force_left'] ) ) {
248
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
249
-						$help_text = '';
250
-						//$label_args['class'] .= ' d-inline ';
251
-						$args['wrap_class'] .= ' align-items-center ';
252
-					}else{
253
-
254
-					}
255
-
256
-					$label_base_class = $aui_bs5 ? ' form-check-label' : ' custom-control-label';
257
-				}
258
-				$label_args['class'] .= $label_base_class;
259
-				$temp_label_args = $label_args;
260
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
261
-				$label = self::label( $temp_label_args, $type );
262
-			}
263
-
264
-
265
-
266
-
267
-			// set help text in the correct position
268
-			if ( $label_after ) {
269
-				$output .= $label . $help_text;
270
-			}
271
-
272
-			// some input types need a separate wrap
273
-			if ( $type == 'file' ) {
274
-				$output = self::wrap( array(
275
-					'content' => $output,
276
-					'class'   => $aui_bs5 ? 'mb-3 custom-file' : 'form-group custom-file'
277
-				) );
278
-			} elseif ( $type == 'checkbox' ) {
279
-
280
-				$label_args['title'] = $args['label'];
281
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
282
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
283
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
284
-				if ( $aui_bs5 ) {
285
-					$wrap_class = $args['switch'] ? 'form-check form-switch' . $switch_size_class : 'form-check';
286
-				}else{
287
-					$wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class :  'custom-checkbox' ;
288
-				}
289
-				if ( ! empty( $args['label_force_left'] ) ) {
290
-					$wrap_class .= $aui_bs5 ? '' : ' d-flex align-content-center';
291
-					$label = str_replace(array("form-check-label","custom-control-label"),"", self::label( $label_args, 'cb' ) );
292
-				}
293
-				$output     = self::wrap( array(
294
-					'content' => $output,
295
-					'class'   => $aui_bs5 ? $wrap_class : 'custom-control ' . $wrap_class
296
-				) );
297
-
298
-				if ( $args['label_type'] == 'horizontal' ) {
299
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
300
-					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
301
-				}
302
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
303
-
304
-
305
-				// allow password field to toggle view
306
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
150
+                // enqueue the script
151
+                $aui_settings = AyeCode_UI_Settings::instance();
152
+                $aui_settings->enqueue_iconpicker();
153
+            }
154
+
155
+            if ( $type == 'checkbox' && ( ( ! empty( $args['name'] ) && strpos( $args['name'], '[' ) === false ) || ! empty( $args['with_hidden'] ) ) ) {
156
+                $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
157
+            }
158
+
159
+            // allow clear icon
160
+            if ( $args['input_group_right'] === '' && $args['clear_icon'] ) {
161
+                $font_size = $size == 'sm' ? '1.3' : ( $size == 'lg' ? '1.65' : '1.5' );
162
+                $args['input_group_right_inside'] = true;
163
+                $align_class = $aui_bs5 ? ' h-100 py-0' : '';
164
+                $args['input_group_right'] = '<span class="input-group-text aui-clear-input c-pointer bg-initial border-0 px-2 d-none ' . $align_class . '" onclick="' . $clear_function . '"><span style="font-size: ' . $font_size . 'rem" aria-hidden="true" class="' . ( $aui_bs5 ? 'btn-close' : 'close' ) . '">' . ( $aui_bs5 ? '' : '&times;' ) . '</span></span>';
165
+            }
166
+
167
+            // open/type
168
+            $output .= '<input type="' . $type . '" ';
169
+
170
+            // name
171
+            if ( ! empty( $args['name'] ) ) {
172
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
173
+            }
174
+
175
+            // id
176
+            if ( ! empty( $args['id'] ) ) {
177
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
178
+            }
179
+
180
+            // placeholder
181
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
182
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
183
+            }
184
+
185
+            // title
186
+            if ( ! empty( $args['title'] ) ) {
187
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
188
+            }
189
+
190
+            // value
191
+            if ( ! empty( $args['value'] ) ) {
192
+                $output .= AUI_Component_Helper::value( $args['value'] );
193
+            }
194
+
195
+            // checked, for radio and checkboxes
196
+            if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
197
+                $output .= ' checked ';
198
+            }
199
+
200
+            // validation text
201
+            if ( ! empty( $args['validation_text'] ) ) {
202
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" ';
203
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
204
+            }
205
+
206
+            // validation_pattern
207
+            if ( ! empty( $args['validation_pattern'] ) ) {
208
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
209
+            }
210
+
211
+            // step (for numbers)
212
+            if ( ! empty( $args['step'] ) ) {
213
+                $output .= ' step="' . $args['step'] . '" ';
214
+            }
215
+
216
+            // required
217
+            if ( ! empty( $args['required'] ) ) {
218
+                $output .= ' required ';
219
+            }
220
+
221
+            // class
222
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
223
+            $output .= $aui_bs5 &&  $type == 'checkbox' ? ' class="' . $class . '" ' : ' class="form-control ' . $class . '" ';
224
+
225
+            // data-attributes
226
+            $output .= AUI_Component_Helper::data_attributes( $args );
227
+
228
+            // extra attributes
229
+            if ( ! empty( $args['extra_attributes'] ) ) {
230
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
231
+            }
232
+
233
+            // close
234
+            $output .= ' >';
235
+
236
+            // help text
237
+            if ( ! empty( $args['help_text'] ) ) {
238
+                $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
239
+            }
240
+
241
+            // label
242
+            if ( ! empty( $args['label'] ) ) {
243
+                $label_base_class = '';
244
+                if ( $type == 'file' ) {
245
+                    $label_base_class = ' custom-file-label';
246
+                } elseif ( $type == 'checkbox' ) {
247
+                    if ( ! empty( $args['label_force_left'] ) ) {
248
+                        $label_args['title'] = wp_kses_post( $args['help_text'] );
249
+                        $help_text = '';
250
+                        //$label_args['class'] .= ' d-inline ';
251
+                        $args['wrap_class'] .= ' align-items-center ';
252
+                    }else{
253
+
254
+                    }
255
+
256
+                    $label_base_class = $aui_bs5 ? ' form-check-label' : ' custom-control-label';
257
+                }
258
+                $label_args['class'] .= $label_base_class;
259
+                $temp_label_args = $label_args;
260
+                if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
261
+                $label = self::label( $temp_label_args, $type );
262
+            }
263
+
264
+
265
+
266
+
267
+            // set help text in the correct position
268
+            if ( $label_after ) {
269
+                $output .= $label . $help_text;
270
+            }
271
+
272
+            // some input types need a separate wrap
273
+            if ( $type == 'file' ) {
274
+                $output = self::wrap( array(
275
+                    'content' => $output,
276
+                    'class'   => $aui_bs5 ? 'mb-3 custom-file' : 'form-group custom-file'
277
+                ) );
278
+            } elseif ( $type == 'checkbox' ) {
279
+
280
+                $label_args['title'] = $args['label'];
281
+                $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
282
+                $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
283
+                $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
284
+                if ( $aui_bs5 ) {
285
+                    $wrap_class = $args['switch'] ? 'form-check form-switch' . $switch_size_class : 'form-check';
286
+                }else{
287
+                    $wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class :  'custom-checkbox' ;
288
+                }
289
+                if ( ! empty( $args['label_force_left'] ) ) {
290
+                    $wrap_class .= $aui_bs5 ? '' : ' d-flex align-content-center';
291
+                    $label = str_replace(array("form-check-label","custom-control-label"),"", self::label( $label_args, 'cb' ) );
292
+                }
293
+                $output     = self::wrap( array(
294
+                    'content' => $output,
295
+                    'class'   => $aui_bs5 ? $wrap_class : 'custom-control ' . $wrap_class
296
+                ) );
297
+
298
+                if ( $args['label_type'] == 'horizontal' ) {
299
+                    $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
300
+                    $output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
301
+                }
302
+            } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
303
+
304
+
305
+                // allow password field to toggle view
306
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
307 307
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
308 308
 var $eli = jQuery(this).parent().parent().find(\'input\');
309 309
 if($el.hasClass(\'fa-eye\'))
310 310
 {$eli.attr(\'type\',\'text\');}
311 311
 else{$eli.attr(\'type\',\'password\');}"
312 312
 ><i class="far fa-fw fa-eye-slash"></i></span>';
313
-			}
314
-
315
-			// input group wraps
316
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
317
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
318
-				$group_size = $size == 'lg' ? ' input-group-lg' : '';
319
-				$group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size;
320
-
321
-				if ( $args['input_group_left'] ) {
322
-					$output = self::wrap( array(
323
-						'content'                 => $output,
324
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
325
-						'input_group_left'        => $args['input_group_left'],
326
-						'input_group_left_inside' => $args['input_group_left_inside']
327
-					) );
328
-				}
329
-				if ( $args['input_group_right'] ) {
330
-					$output = self::wrap( array(
331
-						'content'                  => $output,
332
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
333
-						'input_group_right'        => $args['input_group_right'],
334
-						'input_group_right_inside' => $args['input_group_right_inside']
335
-					) );
336
-				}
337
-
338
-			}
339
-
340
-			if ( ! $label_after ) {
341
-				$output .= $help_text;
342
-			}
343
-
344
-
345
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
346
-				$output = self::wrap( array(
347
-					'content' => $output,
348
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
349
-				) );
350
-			}
351
-
352
-			if ( ! $label_after ) {
353
-				$output = $label . $output;
354
-			}
355
-
356
-			// wrap
357
-			if ( ! $args['no_wrap'] ) {
358
-				if ( ! empty( $args['form_group_class'] ) ) {
359
-					$fg_class = esc_attr( $args['form_group_class'] );
360
-				}else{
361
-					$fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
362
-				}
363
-				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : $fg_class;
364
-				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
365
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
366
-				$output           = self::wrap( array(
367
-					'content'         => $output,
368
-					'class'           => $wrap_class,
369
-					'element_require' => $args['element_require'],
370
-					'argument_id'     => $args['id'],
371
-					'wrap_attributes' => $args['wrap_attributes'],
372
-				) );
373
-			}
374
-		}
375
-
376
-		return $output;
377
-	}
378
-
379
-	public static function label( $args = array(), $type = '' ) {
380
-		global $aui_bs5;
381
-		//<label for="exampleInputEmail1">Email address</label>
382
-		$defaults = array(
383
-			'title'      => 'div',
384
-			'for'        => '',
385
-			'class'      => '',
386
-			'label_type' => '', // empty = hidden, top, horizontal
387
-			'label_col'  => '',
388
-		);
389
-
390
-		/**
391
-		 * Parse incoming $args into an array and merge it with $defaults
392
-		 */
393
-		$args   = wp_parse_args( $args, $defaults );
394
-		$output = '';
395
-
396
-		if ( $args['title'] ) {
397
-
398
-			// maybe hide labels //@todo set a global option for visibility class
399
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
400
-				$class = $args['class'];
401
-			} else {
402
-				$class = 'sr-only ' . $args['class'];
403
-			}
404
-
405
-			// maybe horizontal
406
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
407
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label '.$type;
408
-			}
409
-
410
-			if( $aui_bs5 ){ $class .= ' form-label'; }
411
-
412
-			// open
413
-			$output .= '<label ';
414
-
415
-			// for
416
-			if ( ! empty( $args['for'] ) ) {
417
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
418
-			}
419
-
420
-			// class
421
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
422
-			$output .= ' class="' . $class . '" ';
423
-
424
-			// close
425
-			$output .= '>';
426
-
427
-
428
-			// title, don't escape fully as can contain html
429
-			if ( ! empty( $args['title'] ) ) {
430
-				$output .= wp_kses_post( $args['title'] );
431
-			}
432
-
433
-			// close wrap
434
-			$output .= '</label>';
435
-
436
-
437
-		}
438
-
439
-
440
-		return $output;
441
-	}
442
-
443
-	/**
444
-	 * Wrap some content in a HTML wrapper.
445
-	 *
446
-	 * @param array $args
447
-	 *
448
-	 * @return string
449
-	 */
450
-	public static function wrap( $args = array() ) {
451
-		global $aui_bs5;
452
-		$defaults = array(
453
-			'type'                     => 'div',
454
-			'class'                    => $aui_bs5 ? 'mb-3' : 'form-group',
455
-			'content'                  => '',
456
-			'input_group_left'         => '',
457
-			'input_group_right'        => '',
458
-			'input_group_left_inside'  => false,
459
-			'input_group_right_inside' => false,
460
-			'element_require'          => '',
461
-			'argument_id'              => '',
462
-			'wrap_attributes'          => array()
463
-		);
464
-
465
-		/**
466
-		 * Parse incoming $args into an array and merge it with $defaults
467
-		 */
468
-		$args   = wp_parse_args( $args, $defaults );
469
-		$output = '';
470
-		if ( $args['type'] ) {
471
-
472
-			// open
473
-			$output .= '<' . sanitize_html_class( $args['type'] );
474
-
475
-			// element require
476
-			if ( ! empty( $args['element_require'] ) ) {
477
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
478
-				$args['class'] .= " aui-conditional-field";
479
-			}
480
-
481
-			// argument_id
482
-			if ( ! empty( $args['argument_id'] ) ) {
483
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
484
-			}
485
-
486
-			// class
487
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
488
-			$output .= ' class="' . $class . '" ';
489
-
490
-			// Attributes
491
-			if ( ! empty( $args['wrap_attributes'] ) ) {
492
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
493
-			}
494
-
495
-			// close wrap
496
-			$output .= ' >';
497
-
498
-
499
-			// Input group left
500
-			if ( ! empty( $args['input_group_left'] ) ) {
501
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
502
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
503
-				$output .= $aui_bs5 ? $input_group_left : '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
313
+            }
314
+
315
+            // input group wraps
316
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
317
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
318
+                $group_size = $size == 'lg' ? ' input-group-lg' : '';
319
+                $group_size = !$group_size && $size == 'sm' ? ' input-group-sm' : $group_size;
320
+
321
+                if ( $args['input_group_left'] ) {
322
+                    $output = self::wrap( array(
323
+                        'content'                 => $output,
324
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
325
+                        'input_group_left'        => $args['input_group_left'],
326
+                        'input_group_left_inside' => $args['input_group_left_inside']
327
+                    ) );
328
+                }
329
+                if ( $args['input_group_right'] ) {
330
+                    $output = self::wrap( array(
331
+                        'content'                  => $output,
332
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 . $group_size : 'input-group' . $group_size,
333
+                        'input_group_right'        => $args['input_group_right'],
334
+                        'input_group_right_inside' => $args['input_group_right_inside']
335
+                    ) );
336
+                }
337
+
338
+            }
339
+
340
+            if ( ! $label_after ) {
341
+                $output .= $help_text;
342
+            }
343
+
344
+
345
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
346
+                $output = self::wrap( array(
347
+                    'content' => $output,
348
+                    'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
349
+                ) );
350
+            }
351
+
352
+            if ( ! $label_after ) {
353
+                $output = $label . $output;
354
+            }
355
+
356
+            // wrap
357
+            if ( ! $args['no_wrap'] ) {
358
+                if ( ! empty( $args['form_group_class'] ) ) {
359
+                    $fg_class = esc_attr( $args['form_group_class'] );
360
+                }else{
361
+                    $fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
362
+                }
363
+                $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : $fg_class;
364
+                $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
365
+                $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
366
+                $output           = self::wrap( array(
367
+                    'content'         => $output,
368
+                    'class'           => $wrap_class,
369
+                    'element_require' => $args['element_require'],
370
+                    'argument_id'     => $args['id'],
371
+                    'wrap_attributes' => $args['wrap_attributes'],
372
+                ) );
373
+            }
374
+        }
375
+
376
+        return $output;
377
+    }
378
+
379
+    public static function label( $args = array(), $type = '' ) {
380
+        global $aui_bs5;
381
+        //<label for="exampleInputEmail1">Email address</label>
382
+        $defaults = array(
383
+            'title'      => 'div',
384
+            'for'        => '',
385
+            'class'      => '',
386
+            'label_type' => '', // empty = hidden, top, horizontal
387
+            'label_col'  => '',
388
+        );
389
+
390
+        /**
391
+         * Parse incoming $args into an array and merge it with $defaults
392
+         */
393
+        $args   = wp_parse_args( $args, $defaults );
394
+        $output = '';
395
+
396
+        if ( $args['title'] ) {
397
+
398
+            // maybe hide labels //@todo set a global option for visibility class
399
+            if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
400
+                $class = $args['class'];
401
+            } else {
402
+                $class = 'sr-only ' . $args['class'];
403
+            }
404
+
405
+            // maybe horizontal
406
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
407
+                $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label '.$type;
408
+            }
409
+
410
+            if( $aui_bs5 ){ $class .= ' form-label'; }
411
+
412
+            // open
413
+            $output .= '<label ';
414
+
415
+            // for
416
+            if ( ! empty( $args['for'] ) ) {
417
+                $output .= ' for="' . esc_attr( $args['for'] ) . '" ';
418
+            }
419
+
420
+            // class
421
+            $class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
422
+            $output .= ' class="' . $class . '" ';
423
+
424
+            // close
425
+            $output .= '>';
426
+
427
+
428
+            // title, don't escape fully as can contain html
429
+            if ( ! empty( $args['title'] ) ) {
430
+                $output .= wp_kses_post( $args['title'] );
431
+            }
432
+
433
+            // close wrap
434
+            $output .= '</label>';
435
+
436
+
437
+        }
438
+
439
+
440
+        return $output;
441
+    }
442
+
443
+    /**
444
+     * Wrap some content in a HTML wrapper.
445
+     *
446
+     * @param array $args
447
+     *
448
+     * @return string
449
+     */
450
+    public static function wrap( $args = array() ) {
451
+        global $aui_bs5;
452
+        $defaults = array(
453
+            'type'                     => 'div',
454
+            'class'                    => $aui_bs5 ? 'mb-3' : 'form-group',
455
+            'content'                  => '',
456
+            'input_group_left'         => '',
457
+            'input_group_right'        => '',
458
+            'input_group_left_inside'  => false,
459
+            'input_group_right_inside' => false,
460
+            'element_require'          => '',
461
+            'argument_id'              => '',
462
+            'wrap_attributes'          => array()
463
+        );
464
+
465
+        /**
466
+         * Parse incoming $args into an array and merge it with $defaults
467
+         */
468
+        $args   = wp_parse_args( $args, $defaults );
469
+        $output = '';
470
+        if ( $args['type'] ) {
471
+
472
+            // open
473
+            $output .= '<' . sanitize_html_class( $args['type'] );
474
+
475
+            // element require
476
+            if ( ! empty( $args['element_require'] ) ) {
477
+                $output .= AUI_Component_Helper::element_require( $args['element_require'] );
478
+                $args['class'] .= " aui-conditional-field";
479
+            }
480
+
481
+            // argument_id
482
+            if ( ! empty( $args['argument_id'] ) ) {
483
+                $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
484
+            }
485
+
486
+            // class
487
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
488
+            $output .= ' class="' . $class . '" ';
489
+
490
+            // Attributes
491
+            if ( ! empty( $args['wrap_attributes'] ) ) {
492
+                $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
493
+            }
494
+
495
+            // close wrap
496
+            $output .= ' >';
497
+
498
+
499
+            // Input group left
500
+            if ( ! empty( $args['input_group_left'] ) ) {
501
+                $position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
502
+                $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
503
+                $output .= $aui_bs5 ? $input_group_left : '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
504 504
 //				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
505
-			}
505
+            }
506 506
 
507
-			// content
508
-			$output .= $args['content'];
507
+            // content
508
+            $output .= $args['content'];
509 509
 
510
-			// Input group right
511
-			if ( ! empty( $args['input_group_right'] ) ) {
512
-				$position_class    = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : '';
513
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
514
-				$output .= $aui_bs5 ? str_replace( 'input-group-text','input-group-text top-0 end-0', $input_group_right ) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>';
510
+            // Input group right
511
+            if ( ! empty( $args['input_group_right'] ) ) {
512
+                $position_class    = ! empty( $args['input_group_right_inside'] ) ? 'position-absolute h-100' : '';
513
+                $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
514
+                $output .= $aui_bs5 ? str_replace( 'input-group-text','input-group-text top-0 end-0', $input_group_right ) : '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>';
515 515
 //				$output .= '<div class="input-group-append ' . $position_class . '" style="top:0;right:0;">' . $input_group_right . '</div>';
516
-			}
517
-
518
-
519
-			// close wrap
520
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
521
-
522
-
523
-		} else {
524
-			$output = $args['content'];
525
-		}
526
-
527
-		return $output;
528
-	}
529
-
530
-	/**
531
-	 * Build the component.
532
-	 *
533
-	 * @param array $args
534
-	 *
535
-	 * @return string The rendered component.
536
-	 */
537
-	public static function textarea( $args = array() ) {
538
-		global $aui_bs5;
539
-
540
-		$defaults = array(
541
-			'name'               => '',
542
-			'class'              => '',
543
-			'wrap_class'         => '',
544
-			'id'                 => '',
545
-			'placeholder'        => '',
546
-			'title'              => '',
547
-			'value'              => '',
548
-			'required'           => false,
549
-			'label'              => '',
550
-			'label_after'        => false,
551
-			'label_class'        => '',
552
-			'label_type'         => '',
553
-			'label_col'          => '',
554
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
555
-			'input_group_right'        => '',
556
-			'input_group_left'         => '',
557
-			'input_group_right_inside' => false,
558
-			'form_group_class'      => '',
559
-			'help_text'          => '',
560
-			'validation_text'    => '',
561
-			'validation_pattern' => '',
562
-			'no_wrap'            => false,
563
-			'rows'               => '',
564
-			'wysiwyg'            => false,
565
-			'allow_tags'         => false,
566
-			// Allow HTML tags
567
-			'element_require'    => '',
568
-			// [%element_id%] == "1"
569
-			'extra_attributes'   => array(),
570
-			// an array of extra attributes
571
-			'wrap_attributes'    => array(),
572
-		);
573
-
574
-		/**
575
-		 * Parse incoming $args into an array and merge it with $defaults
576
-		 */
577
-		$args   = wp_parse_args( $args, $defaults );
578
-		$output = '';
579
-		$label = '';
580
-
581
-		// hidden label option needs to be empty
582
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
583
-
584
-		// floating labels don't work with wysiwyg so set it as top
585
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
586
-			$args['label_type'] = 'top';
587
-		}
588
-
589
-		$label_after = $args['label_after'];
590
-
591
-		// floating labels need label after
592
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
593
-			$label_after         = true;
594
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
595
-		}
596
-
597
-		// label
598
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
599
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
600
-			$label_args = array(
601
-				'title'      => $args['label'],
602
-				'for'        => $args['id'],
603
-				'class'      => $args['label_class'] . " ",
604
-				'label_type' => $args['label_type'],
605
-				'label_col'  => $args['label_col']
606
-			);
607
-			$label .= self::label( $label_args );
608
-		}
609
-
610
-		// maybe horizontal label
611
-		if ( $args['label_type'] == 'horizontal' ) {
612
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
613
-			$label .= '<div class="' . $input_col . '">';
614
-		}
615
-
616
-		if ( ! empty( $args['wysiwyg'] ) ) {
617
-			ob_start();
618
-			$content   = $args['value'];
619
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
620
-			$settings  = array(
621
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
622
-				'quicktags'     => false,
623
-				'media_buttons' => false,
624
-				'editor_class'  => 'form-control',
625
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
626
-				'teeny'         => true,
627
-			);
628
-
629
-			// maybe set settings if array
630
-			if ( is_array( $args['wysiwyg'] ) ) {
631
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
632
-			}
633
-
634
-			wp_editor( $content, $editor_id, $settings );
635
-			$output .= ob_get_clean();
636
-		} else {
637
-
638
-			// open
639
-			$output .= '<textarea ';
640
-
641
-			// name
642
-			if ( ! empty( $args['name'] ) ) {
643
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
644
-			}
645
-
646
-			// id
647
-			if ( ! empty( $args['id'] ) ) {
648
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
649
-			}
650
-
651
-			// placeholder
652
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
653
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
654
-			}
655
-
656
-			// title
657
-			if ( ! empty( $args['title'] ) ) {
658
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
659
-			}
660
-
661
-			// validation text
662
-			if ( ! empty( $args['validation_text'] ) ) {
663
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" ';
664
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
665
-			}
666
-
667
-			// validation_pattern
668
-			if ( ! empty( $args['validation_pattern'] ) ) {
669
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
670
-			}
671
-
672
-			// required
673
-			if ( ! empty( $args['required'] ) ) {
674
-				$output .= ' required ';
675
-			}
676
-
677
-			// rows
678
-			if ( ! empty( $args['rows'] ) ) {
679
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
680
-			}
681
-
682
-
683
-			// class
684
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
685
-			$output .= ' class="form-control ' . $class . '" ';
686
-
687
-			// extra attributes
688
-			if ( ! empty( $args['extra_attributes'] ) ) {
689
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
690
-			}
691
-
692
-			// close tag
693
-			$output .= ' >';
694
-
695
-			// value
696
-			if ( ! empty( $args['value'] ) ) {
697
-				if ( ! empty( $args['allow_tags'] ) ) {
698
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
699
-				} else {
700
-					$output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
701
-				}
702
-			}
703
-
704
-			// closing tag
705
-			$output .= '</textarea>';
706
-
707
-
708
-			// input group wraps
709
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
710
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
711
-				if ( $args['input_group_left'] ) {
712
-					$output = self::wrap( array(
713
-						'content'                 => $output,
714
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
715
-						'input_group_left'        => $args['input_group_left'],
716
-						'input_group_left_inside' => $args['input_group_left_inside']
717
-					) );
718
-				}
719
-				if ( $args['input_group_right'] ) {
720
-					$output = self::wrap( array(
721
-						'content'                  => $output,
722
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
723
-						'input_group_right'        => $args['input_group_right'],
724
-						'input_group_right_inside' => $args['input_group_right_inside']
725
-					) );
726
-				}
727
-
728
-			}
729
-
730
-
731
-		}
732
-
733
-		if ( ! empty( $args['label'] ) && $label_after ) {
734
-			$label_args = array(
735
-				'title'      => $args['label'],
736
-				'for'        => $args['id'],
737
-				'class'      => $args['label_class'] . " ",
738
-				'label_type' => $args['label_type'],
739
-				'label_col'  => $args['label_col']
740
-			);
741
-			$output .= self::label( $label_args );
742
-		}
743
-
744
-		// help text
745
-		if ( ! empty( $args['help_text'] ) ) {
746
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
747
-		}
748
-
749
-		if ( ! $label_after ) {
750
-			$output = $label . $output;
751
-		}
752
-
753
-		// maybe horizontal label
754
-		if ( $args['label_type'] == 'horizontal' ) {
755
-			$output .= '</div>';
756
-		}
757
-
758
-
759
-		// wrap
760
-		if ( ! $args['no_wrap'] ) {
761
-			if ( ! empty( $args['form_group_class'] ) ) {
762
-				$fg_class = esc_attr( $args['form_group_class'] );
763
-			}else{
764
-				$fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
765
-			}
766
-			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : $fg_class;
767
-			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
768
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
769
-			$output           = self::wrap( array(
770
-				'content'         => $output,
771
-				'class'           => $wrap_class,
772
-				'element_require' => $args['element_require'],
773
-				'argument_id'     => $args['id'],
774
-				'wrap_attributes' => $args['wrap_attributes'],
775
-			) );
776
-		}
777
-
778
-
779
-		return $output;
780
-	}
781
-
782
-	/**
783
-	 * Build the component.
784
-	 *
785
-	 * @param array $args
786
-	 *
787
-	 * @return string The rendered component.
788
-	 */
789
-	public static function select( $args = array() ) {
790
-		global $aui_bs5;
791
-		$defaults = array(
792
-			'class'            => '',
793
-			'wrap_class'       => '',
794
-			'id'               => '',
795
-			'title'            => '',
796
-			'value'            => '',
797
-			// can be an array or a string
798
-			'required'         => false,
799
-			'label'            => '',
800
-			'label_after'      => false,
801
-			'label_type'       => '',
802
-			'label_col'        => '',
803
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
804
-			'label_class'      => '',
805
-			'help_text'        => '',
806
-			'placeholder'      => '',
807
-			'options'          => array(),
808
-			// array or string
809
-			'icon'             => '',
810
-			'multiple'         => false,
811
-			'select2'          => false,
812
-			'no_wrap'          => false,
813
-			'input_group_right' => '',
814
-			'input_group_left' => '',
815
-			'input_group_right_inside' => false, // forces the input group inside the input
816
-			'input_group_left_inside' => false, // forces the input group inside the input
817
-			'form_group_class'  => '',
818
-			'element_require'  => '',
819
-			// [%element_id%] == "1"
820
-			'extra_attributes' => array(),
821
-			// an array of extra attributes
822
-			'wrap_attributes'  => array(),
823
-		);
824
-
825
-		/**
826
-		 * Parse incoming $args into an array and merge it with $defaults
827
-		 */
828
-		$args   = wp_parse_args( $args, $defaults );
829
-		$output = '';
830
-
831
-		// for now lets hide floating labels
832
-		if ( $args['label_type'] == 'floating' ) {
833
-			$args['label_type'] = 'hidden';
834
-		}
835
-
836
-		// hidden label option needs to be empty
837
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
838
-
839
-
840
-		$label_after = $args['label_after'];
841
-
842
-		// floating labels need label after
843
-		if ( $args['label_type'] == 'floating' ) {
844
-			$label_after         = true;
845
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
846
-		}
847
-
848
-		// Maybe setup select2
849
-		$is_select2 = false;
850
-		if ( ! empty( $args['select2'] ) ) {
851
-			$args['class'] .= ' aui-select2';
852
-			$is_select2 = true;
853
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
854
-			$is_select2 = true;
855
-		}
856
-
857
-		// select2 tags
858
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
859
-			$args['data-tags']             = 'true';
860
-			$args['data-token-separators'] = "[',']";
861
-			$args['multiple']              = true;
862
-		}
863
-
864
-		// select2 placeholder
865
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
866
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
867
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
868
-		}
869
-
870
-		// Set hidden input to save empty value for multiselect.
871
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
872
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>';
873
-		}
874
-
875
-		// open/type
876
-		$output .= '<select ';
877
-
878
-		// style
879
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
880
-			$output .= " style='width:100%;' ";
881
-		}
882
-
883
-		// element require
884
-		if ( ! empty( $args['element_require'] ) ) {
885
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
886
-			$args['class'] .= " aui-conditional-field";
887
-		}
888
-
889
-		// class
890
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
891
-		$select_class = $aui_bs5 ? 'form-select ' : 'custom-select ';
892
-		$output .= AUI_Component_Helper::class_attr( $select_class . $class );
893
-
894
-		// name
895
-		if ( ! empty( $args['name'] ) ) {
896
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
897
-		}
898
-
899
-		// id
900
-		if ( ! empty( $args['id'] ) ) {
901
-			$output .= AUI_Component_Helper::id( $args['id'] );
902
-		}
903
-
904
-		// title
905
-		if ( ! empty( $args['title'] ) ) {
906
-			$output .= AUI_Component_Helper::title( $args['title'] );
907
-		}
908
-
909
-		// data-attributes
910
-		$output .= AUI_Component_Helper::data_attributes( $args );
911
-
912
-		// aria-attributes
913
-		$output .= AUI_Component_Helper::aria_attributes( $args );
914
-
915
-		// extra attributes
916
-		if ( ! empty( $args['extra_attributes'] ) ) {
917
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
918
-		}
919
-
920
-		// required
921
-		if ( ! empty( $args['required'] ) ) {
922
-			$output .= ' required ';
923
-		}
924
-
925
-		// multiple
926
-		if ( ! empty( $args['multiple'] ) ) {
927
-			$output .= ' multiple ';
928
-		}
929
-
930
-		// close opening tag
931
-		$output .= ' >';
932
-
933
-		// placeholder
934
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
935
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
936
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
937
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
938
-		}
939
-
940
-		// Options
941
-		if ( ! empty( $args['options'] ) ) {
942
-
943
-			if ( ! is_array( $args['options'] ) ) {
944
-				$output .= $args['options']; // not the preferred way but an option
945
-			} else {
946
-				foreach ( $args['options'] as $val => $name ) {
947
-					$selected = '';
948
-					if ( is_array( $name ) ) {
949
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
950
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
951
-
952
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
953
-						} else {
954
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
955
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
956
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
957
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
958
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
959
-							} elseif ( ! empty( $args['value'] ) ) {
960
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
961
-							} elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
962
-								$selected = selected( $option_value, $args['value'], false );
963
-							}
964
-
965
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
966
-						}
967
-					} else {
968
-						if ( ! empty( $args['value'] ) ) {
969
-							if ( is_array( $args['value'] ) ) {
970
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
971
-							} elseif ( ! empty( $args['value'] ) ) {
972
-								$selected = selected( $args['value'], $val, false );
973
-							}
974
-						} elseif ( $args['value'] === $val ) {
975
-							$selected = selected( $args['value'], $val, false );
976
-						}
977
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
978
-					}
979
-				}
980
-			}
981
-
982
-		}
983
-
984
-		// closing tag
985
-		$output .= '</select>';
986
-
987
-		$label = '';
988
-		$help_text = '';
989
-		// label
990
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
991
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
992
-			$label_args = array(
993
-				'title'      => $args['label'],
994
-				'for'        => $args['id'],
995
-				'class'      => $args['label_class'] . " ",
996
-				'label_type' => $args['label_type'],
997
-				'label_col'  => $args['label_col']
998
-			);
999
-			$label = self::label( $label_args );
1000
-		}
1001
-
1002
-		// help text
1003
-		if ( ! empty( $args['help_text'] ) ) {
1004
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
1005
-		}
1006
-
1007
-		// input group wraps
1008
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
1009
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
1010
-			if ( $args['input_group_left'] ) {
1011
-				$output = self::wrap( array(
1012
-					'content'                 => $output,
1013
-					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
1014
-					'input_group_left'        => $args['input_group_left'],
1015
-					'input_group_left_inside' => $args['input_group_left_inside']
1016
-				) );
1017
-			}
1018
-			if ( $args['input_group_right'] ) {
1019
-				$output = self::wrap( array(
1020
-					'content'                  => $output,
1021
-					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
1022
-					'input_group_right'        => $args['input_group_right'],
1023
-					'input_group_right_inside' => $args['input_group_right_inside']
1024
-				) );
1025
-			}
1026
-
1027
-		}
1028
-
1029
-		if ( ! $label_after ) {
1030
-			$output .= $help_text;
1031
-		}
1032
-
1033
-
1034
-		if ( $args['label_type'] == 'horizontal' ) {
1035
-			$output = self::wrap( array(
1036
-				'content' => $output,
1037
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
1038
-			) );
1039
-		}
1040
-
1041
-		if ( ! $label_after ) {
1042
-			$output = $label . $output;
1043
-		}
1044
-
1045
-		// maybe horizontal label
516
+            }
517
+
518
+
519
+            // close wrap
520
+            $output .= '</' . sanitize_html_class( $args['type'] ) . '>';
521
+
522
+
523
+        } else {
524
+            $output = $args['content'];
525
+        }
526
+
527
+        return $output;
528
+    }
529
+
530
+    /**
531
+     * Build the component.
532
+     *
533
+     * @param array $args
534
+     *
535
+     * @return string The rendered component.
536
+     */
537
+    public static function textarea( $args = array() ) {
538
+        global $aui_bs5;
539
+
540
+        $defaults = array(
541
+            'name'               => '',
542
+            'class'              => '',
543
+            'wrap_class'         => '',
544
+            'id'                 => '',
545
+            'placeholder'        => '',
546
+            'title'              => '',
547
+            'value'              => '',
548
+            'required'           => false,
549
+            'label'              => '',
550
+            'label_after'        => false,
551
+            'label_class'        => '',
552
+            'label_type'         => '',
553
+            'label_col'          => '',
554
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
555
+            'input_group_right'        => '',
556
+            'input_group_left'         => '',
557
+            'input_group_right_inside' => false,
558
+            'form_group_class'      => '',
559
+            'help_text'          => '',
560
+            'validation_text'    => '',
561
+            'validation_pattern' => '',
562
+            'no_wrap'            => false,
563
+            'rows'               => '',
564
+            'wysiwyg'            => false,
565
+            'allow_tags'         => false,
566
+            // Allow HTML tags
567
+            'element_require'    => '',
568
+            // [%element_id%] == "1"
569
+            'extra_attributes'   => array(),
570
+            // an array of extra attributes
571
+            'wrap_attributes'    => array(),
572
+        );
573
+
574
+        /**
575
+         * Parse incoming $args into an array and merge it with $defaults
576
+         */
577
+        $args   = wp_parse_args( $args, $defaults );
578
+        $output = '';
579
+        $label = '';
580
+
581
+        // hidden label option needs to be empty
582
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
583
+
584
+        // floating labels don't work with wysiwyg so set it as top
585
+        if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
586
+            $args['label_type'] = 'top';
587
+        }
588
+
589
+        $label_after = $args['label_after'];
590
+
591
+        // floating labels need label after
592
+        if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
593
+            $label_after         = true;
594
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
595
+        }
596
+
597
+        // label
598
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
599
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
600
+            $label_args = array(
601
+                'title'      => $args['label'],
602
+                'for'        => $args['id'],
603
+                'class'      => $args['label_class'] . " ",
604
+                'label_type' => $args['label_type'],
605
+                'label_col'  => $args['label_col']
606
+            );
607
+            $label .= self::label( $label_args );
608
+        }
609
+
610
+        // maybe horizontal label
611
+        if ( $args['label_type'] == 'horizontal' ) {
612
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
613
+            $label .= '<div class="' . $input_col . '">';
614
+        }
615
+
616
+        if ( ! empty( $args['wysiwyg'] ) ) {
617
+            ob_start();
618
+            $content   = $args['value'];
619
+            $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
620
+            $settings  = array(
621
+                'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
622
+                'quicktags'     => false,
623
+                'media_buttons' => false,
624
+                'editor_class'  => 'form-control',
625
+                'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
626
+                'teeny'         => true,
627
+            );
628
+
629
+            // maybe set settings if array
630
+            if ( is_array( $args['wysiwyg'] ) ) {
631
+                $settings = wp_parse_args( $args['wysiwyg'], $settings );
632
+            }
633
+
634
+            wp_editor( $content, $editor_id, $settings );
635
+            $output .= ob_get_clean();
636
+        } else {
637
+
638
+            // open
639
+            $output .= '<textarea ';
640
+
641
+            // name
642
+            if ( ! empty( $args['name'] ) ) {
643
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
644
+            }
645
+
646
+            // id
647
+            if ( ! empty( $args['id'] ) ) {
648
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
649
+            }
650
+
651
+            // placeholder
652
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
653
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
654
+            }
655
+
656
+            // title
657
+            if ( ! empty( $args['title'] ) ) {
658
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
659
+            }
660
+
661
+            // validation text
662
+            if ( ! empty( $args['validation_text'] ) ) {
663
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( addslashes( $args['validation_text'] ) ) . '\')" ';
664
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
665
+            }
666
+
667
+            // validation_pattern
668
+            if ( ! empty( $args['validation_pattern'] ) ) {
669
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
670
+            }
671
+
672
+            // required
673
+            if ( ! empty( $args['required'] ) ) {
674
+                $output .= ' required ';
675
+            }
676
+
677
+            // rows
678
+            if ( ! empty( $args['rows'] ) ) {
679
+                $output .= ' rows="' . absint( $args['rows'] ) . '" ';
680
+            }
681
+
682
+
683
+            // class
684
+            $class = ! empty( $args['class'] ) ? $args['class'] : '';
685
+            $output .= ' class="form-control ' . $class . '" ';
686
+
687
+            // extra attributes
688
+            if ( ! empty( $args['extra_attributes'] ) ) {
689
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
690
+            }
691
+
692
+            // close tag
693
+            $output .= ' >';
694
+
695
+            // value
696
+            if ( ! empty( $args['value'] ) ) {
697
+                if ( ! empty( $args['allow_tags'] ) ) {
698
+                    $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
699
+                } else {
700
+                    $output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
701
+                }
702
+            }
703
+
704
+            // closing tag
705
+            $output .= '</textarea>';
706
+
707
+
708
+            // input group wraps
709
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
710
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
711
+                if ( $args['input_group_left'] ) {
712
+                    $output = self::wrap( array(
713
+                        'content'                 => $output,
714
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
715
+                        'input_group_left'        => $args['input_group_left'],
716
+                        'input_group_left_inside' => $args['input_group_left_inside']
717
+                    ) );
718
+                }
719
+                if ( $args['input_group_right'] ) {
720
+                    $output = self::wrap( array(
721
+                        'content'                  => $output,
722
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
723
+                        'input_group_right'        => $args['input_group_right'],
724
+                        'input_group_right_inside' => $args['input_group_right_inside']
725
+                    ) );
726
+                }
727
+
728
+            }
729
+
730
+
731
+        }
732
+
733
+        if ( ! empty( $args['label'] ) && $label_after ) {
734
+            $label_args = array(
735
+                'title'      => $args['label'],
736
+                'for'        => $args['id'],
737
+                'class'      => $args['label_class'] . " ",
738
+                'label_type' => $args['label_type'],
739
+                'label_col'  => $args['label_col']
740
+            );
741
+            $output .= self::label( $label_args );
742
+        }
743
+
744
+        // help text
745
+        if ( ! empty( $args['help_text'] ) ) {
746
+            $output .= AUI_Component_Helper::help_text( $args['help_text'] );
747
+        }
748
+
749
+        if ( ! $label_after ) {
750
+            $output = $label . $output;
751
+        }
752
+
753
+        // maybe horizontal label
754
+        if ( $args['label_type'] == 'horizontal' ) {
755
+            $output .= '</div>';
756
+        }
757
+
758
+
759
+        // wrap
760
+        if ( ! $args['no_wrap'] ) {
761
+            if ( ! empty( $args['form_group_class'] ) ) {
762
+                $fg_class = esc_attr( $args['form_group_class'] );
763
+            }else{
764
+                $fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
765
+            }
766
+            $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : $fg_class;
767
+            $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
768
+            $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
769
+            $output           = self::wrap( array(
770
+                'content'         => $output,
771
+                'class'           => $wrap_class,
772
+                'element_require' => $args['element_require'],
773
+                'argument_id'     => $args['id'],
774
+                'wrap_attributes' => $args['wrap_attributes'],
775
+            ) );
776
+        }
777
+
778
+
779
+        return $output;
780
+    }
781
+
782
+    /**
783
+     * Build the component.
784
+     *
785
+     * @param array $args
786
+     *
787
+     * @return string The rendered component.
788
+     */
789
+    public static function select( $args = array() ) {
790
+        global $aui_bs5;
791
+        $defaults = array(
792
+            'class'            => '',
793
+            'wrap_class'       => '',
794
+            'id'               => '',
795
+            'title'            => '',
796
+            'value'            => '',
797
+            // can be an array or a string
798
+            'required'         => false,
799
+            'label'            => '',
800
+            'label_after'      => false,
801
+            'label_type'       => '',
802
+            'label_col'        => '',
803
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
804
+            'label_class'      => '',
805
+            'help_text'        => '',
806
+            'placeholder'      => '',
807
+            'options'          => array(),
808
+            // array or string
809
+            'icon'             => '',
810
+            'multiple'         => false,
811
+            'select2'          => false,
812
+            'no_wrap'          => false,
813
+            'input_group_right' => '',
814
+            'input_group_left' => '',
815
+            'input_group_right_inside' => false, // forces the input group inside the input
816
+            'input_group_left_inside' => false, // forces the input group inside the input
817
+            'form_group_class'  => '',
818
+            'element_require'  => '',
819
+            // [%element_id%] == "1"
820
+            'extra_attributes' => array(),
821
+            // an array of extra attributes
822
+            'wrap_attributes'  => array(),
823
+        );
824
+
825
+        /**
826
+         * Parse incoming $args into an array and merge it with $defaults
827
+         */
828
+        $args   = wp_parse_args( $args, $defaults );
829
+        $output = '';
830
+
831
+        // for now lets hide floating labels
832
+        if ( $args['label_type'] == 'floating' ) {
833
+            $args['label_type'] = 'hidden';
834
+        }
835
+
836
+        // hidden label option needs to be empty
837
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
838
+
839
+
840
+        $label_after = $args['label_after'];
841
+
842
+        // floating labels need label after
843
+        if ( $args['label_type'] == 'floating' ) {
844
+            $label_after         = true;
845
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
846
+        }
847
+
848
+        // Maybe setup select2
849
+        $is_select2 = false;
850
+        if ( ! empty( $args['select2'] ) ) {
851
+            $args['class'] .= ' aui-select2';
852
+            $is_select2 = true;
853
+        } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
854
+            $is_select2 = true;
855
+        }
856
+
857
+        // select2 tags
858
+        if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
859
+            $args['data-tags']             = 'true';
860
+            $args['data-token-separators'] = "[',']";
861
+            $args['multiple']              = true;
862
+        }
863
+
864
+        // select2 placeholder
865
+        if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
866
+            $args['data-placeholder'] = esc_attr( $args['placeholder'] );
867
+            $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
868
+        }
869
+
870
+        // Set hidden input to save empty value for multiselect.
871
+        if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
872
+            $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value="" data-ignore-rule/>';
873
+        }
874
+
875
+        // open/type
876
+        $output .= '<select ';
877
+
878
+        // style
879
+        if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
880
+            $output .= " style='width:100%;' ";
881
+        }
882
+
883
+        // element require
884
+        if ( ! empty( $args['element_require'] ) ) {
885
+            $output .= AUI_Component_Helper::element_require( $args['element_require'] );
886
+            $args['class'] .= " aui-conditional-field";
887
+        }
888
+
889
+        // class
890
+        $class = ! empty( $args['class'] ) ? $args['class'] : '';
891
+        $select_class = $aui_bs5 ? 'form-select ' : 'custom-select ';
892
+        $output .= AUI_Component_Helper::class_attr( $select_class . $class );
893
+
894
+        // name
895
+        if ( ! empty( $args['name'] ) ) {
896
+            $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
897
+        }
898
+
899
+        // id
900
+        if ( ! empty( $args['id'] ) ) {
901
+            $output .= AUI_Component_Helper::id( $args['id'] );
902
+        }
903
+
904
+        // title
905
+        if ( ! empty( $args['title'] ) ) {
906
+            $output .= AUI_Component_Helper::title( $args['title'] );
907
+        }
908
+
909
+        // data-attributes
910
+        $output .= AUI_Component_Helper::data_attributes( $args );
911
+
912
+        // aria-attributes
913
+        $output .= AUI_Component_Helper::aria_attributes( $args );
914
+
915
+        // extra attributes
916
+        if ( ! empty( $args['extra_attributes'] ) ) {
917
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
918
+        }
919
+
920
+        // required
921
+        if ( ! empty( $args['required'] ) ) {
922
+            $output .= ' required ';
923
+        }
924
+
925
+        // multiple
926
+        if ( ! empty( $args['multiple'] ) ) {
927
+            $output .= ' multiple ';
928
+        }
929
+
930
+        // close opening tag
931
+        $output .= ' >';
932
+
933
+        // placeholder
934
+        if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
935
+            $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
936
+        } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
937
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
938
+        }
939
+
940
+        // Options
941
+        if ( ! empty( $args['options'] ) ) {
942
+
943
+            if ( ! is_array( $args['options'] ) ) {
944
+                $output .= $args['options']; // not the preferred way but an option
945
+            } else {
946
+                foreach ( $args['options'] as $val => $name ) {
947
+                    $selected = '';
948
+                    if ( is_array( $name ) ) {
949
+                        if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
950
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
951
+
952
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
953
+                        } else {
954
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
955
+                            $option_value = isset( $name['value'] ) ? $name['value'] : '';
956
+                            $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
957
+                            if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
958
+                                $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
959
+                            } elseif ( ! empty( $args['value'] ) ) {
960
+                                $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
961
+                            } elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
962
+                                $selected = selected( $option_value, $args['value'], false );
963
+                            }
964
+
965
+                            $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
966
+                        }
967
+                    } else {
968
+                        if ( ! empty( $args['value'] ) ) {
969
+                            if ( is_array( $args['value'] ) ) {
970
+                                $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
971
+                            } elseif ( ! empty( $args['value'] ) ) {
972
+                                $selected = selected( $args['value'], $val, false );
973
+                            }
974
+                        } elseif ( $args['value'] === $val ) {
975
+                            $selected = selected( $args['value'], $val, false );
976
+                        }
977
+                        $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
978
+                    }
979
+                }
980
+            }
981
+
982
+        }
983
+
984
+        // closing tag
985
+        $output .= '</select>';
986
+
987
+        $label = '';
988
+        $help_text = '';
989
+        // label
990
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
991
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
992
+            $label_args = array(
993
+                'title'      => $args['label'],
994
+                'for'        => $args['id'],
995
+                'class'      => $args['label_class'] . " ",
996
+                'label_type' => $args['label_type'],
997
+                'label_col'  => $args['label_col']
998
+            );
999
+            $label = self::label( $label_args );
1000
+        }
1001
+
1002
+        // help text
1003
+        if ( ! empty( $args['help_text'] ) ) {
1004
+            $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
1005
+        }
1006
+
1007
+        // input group wraps
1008
+        if ( $args['input_group_left'] || $args['input_group_right'] ) {
1009
+            $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
1010
+            if ( $args['input_group_left'] ) {
1011
+                $output = self::wrap( array(
1012
+                    'content'                 => $output,
1013
+                    'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
1014
+                    'input_group_left'        => $args['input_group_left'],
1015
+                    'input_group_left_inside' => $args['input_group_left_inside']
1016
+                ) );
1017
+            }
1018
+            if ( $args['input_group_right'] ) {
1019
+                $output = self::wrap( array(
1020
+                    'content'                  => $output,
1021
+                    'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
1022
+                    'input_group_right'        => $args['input_group_right'],
1023
+                    'input_group_right_inside' => $args['input_group_right_inside']
1024
+                ) );
1025
+            }
1026
+
1027
+        }
1028
+
1029
+        if ( ! $label_after ) {
1030
+            $output .= $help_text;
1031
+        }
1032
+
1033
+
1034
+        if ( $args['label_type'] == 'horizontal' ) {
1035
+            $output = self::wrap( array(
1036
+                'content' => $output,
1037
+                'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
1038
+            ) );
1039
+        }
1040
+
1041
+        if ( ! $label_after ) {
1042
+            $output = $label . $output;
1043
+        }
1044
+
1045
+        // maybe horizontal label
1046 1046
 //		if ( $args['label_type'] == 'horizontal' ) {
1047 1047
 //			$output .= '</div>';
1048 1048
 //		}
1049 1049
 
1050 1050
 
1051
-		// wrap
1052
-		if ( ! $args['no_wrap'] ) {
1053
-			if ( ! empty( $args['form_group_class'] ) ) {
1054
-				$fg_class = esc_attr( $args['form_group_class'] );
1055
-			}else{
1056
-				$fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
1057
-			}
1058
-			$wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class;
1059
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1060
-			$output     = self::wrap( array(
1061
-				'content'         => $output,
1062
-				'class'           => $wrap_class,
1063
-				'element_require' => $args['element_require'],
1064
-				'argument_id'     => $args['id'],
1065
-				'wrap_attributes' => $args['wrap_attributes'],
1066
-			) );
1067
-		}
1068
-
1069
-
1070
-		return $output;
1071
-	}
1072
-
1073
-	/**
1074
-	 * Build the component.
1075
-	 *
1076
-	 * @param array $args
1077
-	 *
1078
-	 * @return string The rendered component.
1079
-	 */
1080
-	public static function radio( $args = array() ) {
1081
-		global $aui_bs5;
1082
-
1083
-		$defaults = array(
1084
-			'class'            => '',
1085
-			'wrap_class'       => '',
1086
-			'id'               => '',
1087
-			'title'            => '',
1088
-			'horizontal'       => false,
1089
-			// sets the lable horizontal
1090
-			'value'            => '',
1091
-			'label'            => '',
1092
-			'label_class'      => '',
1093
-			'label_type'       => '',
1094
-			'label_col'        => '',
1095
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
1096
-			'help_text'        => '',
1097
-			'inline'           => true,
1098
-			'required'         => false,
1099
-			'options'          => array(),
1100
-			'icon'             => '',
1101
-			'no_wrap'          => false,
1102
-			'element_require'  => '',
1103
-			// [%element_id%] == "1"
1104
-			'extra_attributes' => array(),
1105
-			// an array of extra attributes
1106
-			'wrap_attributes'  => array()
1107
-		);
1108
-
1109
-		/**
1110
-		 * Parse incoming $args into an array and merge it with $defaults
1111
-		 */
1112
-		$args = wp_parse_args( $args, $defaults );
1113
-
1114
-		// for now lets use horizontal for floating
1115
-		if ( $args['label_type'] == 'floating' ) {
1116
-			$args['label_type'] = 'horizontal';
1117
-		}
1118
-
1119
-		$label_args = array(
1120
-			'title'      => $args['label'],
1121
-			'class'      => $args['label_class'] . " pt-0 ",
1122
-			'label_type' => $args['label_type'],
1123
-			'label_col'  => $args['label_col']
1124
-		);
1125
-
1126
-		$output = '';
1127
-
1128
-
1129
-		// label before
1130
-		if ( ! empty( $args['label'] ) ) {
1131
-			$output .= self::label( $label_args, 'radio' );
1132
-		}
1133
-
1134
-		// maybe horizontal label
1135
-		if ( $args['label_type'] == 'horizontal' ) {
1136
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1137
-			$output .= '<div class="' . $input_col . '">';
1138
-		}
1139
-
1140
-		if ( ! empty( $args['options'] ) ) {
1141
-			$count = 0;
1142
-			foreach ( $args['options'] as $value => $label ) {
1143
-				$option_args            = $args;
1144
-				$option_args['value']   = $value;
1145
-				$option_args['label']   = $label;
1146
-				$option_args['checked'] = $value == $args['value'] ? true : false;
1147
-				$output .= self::radio_option( $option_args, $count );
1148
-				$count ++;
1149
-			}
1150
-		}
1151
-
1152
-		// help text
1153
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1154
-		$output .= $help_text;
1155
-
1156
-		// maybe horizontal label
1157
-		if ( $args['label_type'] == 'horizontal' ) {
1158
-			$output .= '</div>';
1159
-		}
1160
-
1161
-		// wrap
1162
-		$fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
1163
-		$wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class;
1164
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1165
-		$output     = self::wrap( array(
1166
-			'content'         => $output,
1167
-			'class'           => $wrap_class,
1168
-			'element_require' => $args['element_require'],
1169
-			'argument_id'     => $args['id'],
1170
-			'wrap_attributes' => $args['wrap_attributes'],
1171
-		) );
1172
-
1173
-
1174
-		return $output;
1175
-	}
1176
-
1177
-	/**
1178
-	 * Build the component.
1179
-	 *
1180
-	 * @param array $args
1181
-	 *
1182
-	 * @return string The rendered component.
1183
-	 */
1184
-	public static function radio_option( $args = array(), $count = '' ) {
1185
-		$defaults = array(
1186
-			'class'            => '',
1187
-			'id'               => '',
1188
-			'title'            => '',
1189
-			'value'            => '',
1190
-			'required'         => false,
1191
-			'inline'           => true,
1192
-			'label'            => '',
1193
-			'options'          => array(),
1194
-			'icon'             => '',
1195
-			'no_wrap'          => false,
1196
-			'extra_attributes' => array() // an array of extra attributes
1197
-		);
1198
-
1199
-		/**
1200
-		 * Parse incoming $args into an array and merge it with $defaults
1201
-		 */
1202
-		$args = wp_parse_args( $args, $defaults );
1203
-
1204
-		$output = '';
1205
-
1206
-		// open/type
1207
-		$output .= '<input type="radio"';
1208
-
1209
-		// class
1210
-		$output .= ' class="form-check-input" ';
1211
-
1212
-		// name
1213
-		if ( ! empty( $args['name'] ) ) {
1214
-			$output .= AUI_Component_Helper::name( $args['name'] );
1215
-		}
1216
-
1217
-		// id
1218
-		if ( ! empty( $args['id'] ) ) {
1219
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1220
-		}
1221
-
1222
-		// title
1223
-		if ( ! empty( $args['title'] ) ) {
1224
-			$output .= AUI_Component_Helper::title( $args['title'] );
1225
-		}
1226
-
1227
-		// value
1228
-		if ( isset( $args['value'] ) ) {
1229
-			$output .= AUI_Component_Helper::value( $args['value'] );
1230
-		}
1231
-
1232
-		// checked, for radio and checkboxes
1233
-		if ( $args['checked'] ) {
1234
-			$output .= ' checked ';
1235
-		}
1236
-
1237
-		// data-attributes
1238
-		$output .= AUI_Component_Helper::data_attributes( $args );
1239
-
1240
-		// aria-attributes
1241
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1242
-
1243
-		// extra attributes
1244
-		if ( ! empty( $args['extra_attributes'] ) ) {
1245
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1246
-		}
1247
-
1248
-		// required
1249
-		if ( ! empty( $args['required'] ) ) {
1250
-			$output .= ' required ';
1251
-		}
1252
-
1253
-		// close opening tag
1254
-		$output .= ' >';
1255
-
1256
-		// label
1257
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1258
-		} elseif ( ! empty( $args['label'] ) ) {
1259
-			$output .= self::label( array(
1260
-				'title' => $args['label'],
1261
-				'for'   => $args['id'] . $count,
1262
-				'class' => 'form-check-label'
1263
-			), 'radio' );
1264
-		}
1265
-
1266
-		// wrap
1267
-		if ( ! $args['no_wrap'] ) {
1268
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1269
-
1270
-			// Unique wrap class
1271
-			$uniq_class = 'fwrap';
1272
-			if ( ! empty( $args['name'] ) ) {
1273
-				$uniq_class .= '-' . $args['name'];
1274
-			} else if ( ! empty( $args['id'] ) ) {
1275
-				$uniq_class .= '-' . $args['id'];
1276
-			}
1277
-
1278
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1279
-				$uniq_class .= '-' . $args['value'];
1280
-			} else {
1281
-				$uniq_class .= '-' . $count;
1282
-			}
1283
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1284
-
1285
-			$output = self::wrap( array(
1286
-				'content' => $output,
1287
-				'class'   => $wrap_class
1288
-			) );
1289
-		}
1290
-
1291
-		return $output;
1292
-	}
1051
+        // wrap
1052
+        if ( ! $args['no_wrap'] ) {
1053
+            if ( ! empty( $args['form_group_class'] ) ) {
1054
+                $fg_class = esc_attr( $args['form_group_class'] );
1055
+            }else{
1056
+                $fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
1057
+            }
1058
+            $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class;
1059
+            $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1060
+            $output     = self::wrap( array(
1061
+                'content'         => $output,
1062
+                'class'           => $wrap_class,
1063
+                'element_require' => $args['element_require'],
1064
+                'argument_id'     => $args['id'],
1065
+                'wrap_attributes' => $args['wrap_attributes'],
1066
+            ) );
1067
+        }
1068
+
1069
+
1070
+        return $output;
1071
+    }
1072
+
1073
+    /**
1074
+     * Build the component.
1075
+     *
1076
+     * @param array $args
1077
+     *
1078
+     * @return string The rendered component.
1079
+     */
1080
+    public static function radio( $args = array() ) {
1081
+        global $aui_bs5;
1082
+
1083
+        $defaults = array(
1084
+            'class'            => '',
1085
+            'wrap_class'       => '',
1086
+            'id'               => '',
1087
+            'title'            => '',
1088
+            'horizontal'       => false,
1089
+            // sets the lable horizontal
1090
+            'value'            => '',
1091
+            'label'            => '',
1092
+            'label_class'      => '',
1093
+            'label_type'       => '',
1094
+            'label_col'        => '',
1095
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
1096
+            'help_text'        => '',
1097
+            'inline'           => true,
1098
+            'required'         => false,
1099
+            'options'          => array(),
1100
+            'icon'             => '',
1101
+            'no_wrap'          => false,
1102
+            'element_require'  => '',
1103
+            // [%element_id%] == "1"
1104
+            'extra_attributes' => array(),
1105
+            // an array of extra attributes
1106
+            'wrap_attributes'  => array()
1107
+        );
1108
+
1109
+        /**
1110
+         * Parse incoming $args into an array and merge it with $defaults
1111
+         */
1112
+        $args = wp_parse_args( $args, $defaults );
1113
+
1114
+        // for now lets use horizontal for floating
1115
+        if ( $args['label_type'] == 'floating' ) {
1116
+            $args['label_type'] = 'horizontal';
1117
+        }
1118
+
1119
+        $label_args = array(
1120
+            'title'      => $args['label'],
1121
+            'class'      => $args['label_class'] . " pt-0 ",
1122
+            'label_type' => $args['label_type'],
1123
+            'label_col'  => $args['label_col']
1124
+        );
1125
+
1126
+        $output = '';
1127
+
1128
+
1129
+        // label before
1130
+        if ( ! empty( $args['label'] ) ) {
1131
+            $output .= self::label( $label_args, 'radio' );
1132
+        }
1133
+
1134
+        // maybe horizontal label
1135
+        if ( $args['label_type'] == 'horizontal' ) {
1136
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1137
+            $output .= '<div class="' . $input_col . '">';
1138
+        }
1139
+
1140
+        if ( ! empty( $args['options'] ) ) {
1141
+            $count = 0;
1142
+            foreach ( $args['options'] as $value => $label ) {
1143
+                $option_args            = $args;
1144
+                $option_args['value']   = $value;
1145
+                $option_args['label']   = $label;
1146
+                $option_args['checked'] = $value == $args['value'] ? true : false;
1147
+                $output .= self::radio_option( $option_args, $count );
1148
+                $count ++;
1149
+            }
1150
+        }
1151
+
1152
+        // help text
1153
+        $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1154
+        $output .= $help_text;
1155
+
1156
+        // maybe horizontal label
1157
+        if ( $args['label_type'] == 'horizontal' ) {
1158
+            $output .= '</div>';
1159
+        }
1160
+
1161
+        // wrap
1162
+        $fg_class = $aui_bs5 ? 'mb-3' : 'form-group';
1163
+        $wrap_class = $args['label_type'] == 'horizontal' ? $fg_class . ' row' : $fg_class;
1164
+        $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1165
+        $output     = self::wrap( array(
1166
+            'content'         => $output,
1167
+            'class'           => $wrap_class,
1168
+            'element_require' => $args['element_require'],
1169
+            'argument_id'     => $args['id'],
1170
+            'wrap_attributes' => $args['wrap_attributes'],
1171
+        ) );
1172
+
1173
+
1174
+        return $output;
1175
+    }
1176
+
1177
+    /**
1178
+     * Build the component.
1179
+     *
1180
+     * @param array $args
1181
+     *
1182
+     * @return string The rendered component.
1183
+     */
1184
+    public static function radio_option( $args = array(), $count = '' ) {
1185
+        $defaults = array(
1186
+            'class'            => '',
1187
+            'id'               => '',
1188
+            'title'            => '',
1189
+            'value'            => '',
1190
+            'required'         => false,
1191
+            'inline'           => true,
1192
+            'label'            => '',
1193
+            'options'          => array(),
1194
+            'icon'             => '',
1195
+            'no_wrap'          => false,
1196
+            'extra_attributes' => array() // an array of extra attributes
1197
+        );
1198
+
1199
+        /**
1200
+         * Parse incoming $args into an array and merge it with $defaults
1201
+         */
1202
+        $args = wp_parse_args( $args, $defaults );
1203
+
1204
+        $output = '';
1205
+
1206
+        // open/type
1207
+        $output .= '<input type="radio"';
1208
+
1209
+        // class
1210
+        $output .= ' class="form-check-input" ';
1211
+
1212
+        // name
1213
+        if ( ! empty( $args['name'] ) ) {
1214
+            $output .= AUI_Component_Helper::name( $args['name'] );
1215
+        }
1216
+
1217
+        // id
1218
+        if ( ! empty( $args['id'] ) ) {
1219
+            $output .= AUI_Component_Helper::id( $args['id'] . $count );
1220
+        }
1221
+
1222
+        // title
1223
+        if ( ! empty( $args['title'] ) ) {
1224
+            $output .= AUI_Component_Helper::title( $args['title'] );
1225
+        }
1226
+
1227
+        // value
1228
+        if ( isset( $args['value'] ) ) {
1229
+            $output .= AUI_Component_Helper::value( $args['value'] );
1230
+        }
1231
+
1232
+        // checked, for radio and checkboxes
1233
+        if ( $args['checked'] ) {
1234
+            $output .= ' checked ';
1235
+        }
1236
+
1237
+        // data-attributes
1238
+        $output .= AUI_Component_Helper::data_attributes( $args );
1239
+
1240
+        // aria-attributes
1241
+        $output .= AUI_Component_Helper::aria_attributes( $args );
1242
+
1243
+        // extra attributes
1244
+        if ( ! empty( $args['extra_attributes'] ) ) {
1245
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1246
+        }
1247
+
1248
+        // required
1249
+        if ( ! empty( $args['required'] ) ) {
1250
+            $output .= ' required ';
1251
+        }
1252
+
1253
+        // close opening tag
1254
+        $output .= ' >';
1255
+
1256
+        // label
1257
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1258
+        } elseif ( ! empty( $args['label'] ) ) {
1259
+            $output .= self::label( array(
1260
+                'title' => $args['label'],
1261
+                'for'   => $args['id'] . $count,
1262
+                'class' => 'form-check-label'
1263
+            ), 'radio' );
1264
+        }
1265
+
1266
+        // wrap
1267
+        if ( ! $args['no_wrap'] ) {
1268
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1269
+
1270
+            // Unique wrap class
1271
+            $uniq_class = 'fwrap';
1272
+            if ( ! empty( $args['name'] ) ) {
1273
+                $uniq_class .= '-' . $args['name'];
1274
+            } else if ( ! empty( $args['id'] ) ) {
1275
+                $uniq_class .= '-' . $args['id'];
1276
+            }
1277
+
1278
+            if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1279
+                $uniq_class .= '-' . $args['value'];
1280
+            } else {
1281
+                $uniq_class .= '-' . $count;
1282
+            }
1283
+            $wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1284
+
1285
+            $output = self::wrap( array(
1286
+                'content' => $output,
1287
+                'class'   => $wrap_class
1288
+            ) );
1289
+        }
1290
+
1291
+        return $output;
1292
+    }
1293 1293
 
1294 1294
 }
1295 1295
\ No newline at end of file
Please login to merge, or discard this patch.
wp-ayecode-ui/includes/components/class-aui-component-pagination.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,112 +11,112 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Pagination {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get( $args = array() ) {
22
-		global $wp_query, $aui_bs5;
23
-
24
-		$defaults = array(
25
-			'class'              => '',
26
-			'mid_size'           => 2,
27
-			'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
-			'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
-			'screen_reader_text' => __( 'Posts navigation', 'ayecode-connect' ),
30
-			'before_paging'      => '',
31
-			'after_paging'       => '',
32
-			'type'               => 'array',
33
-			'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
-			'links'              => array(), // an array of links if using custom links, this includes the a tag.
35
-			'rounded_style'      => false,
36
-			'custom_next_text'   => '', // Custom next page text
37
-			'custom_prev_text'   => '', // Custom prev page text
38
-		);
39
-
40
-		/**
41
-		 * Parse incoming $args into an array and merge it with $defaults
42
-		 */
43
-		$args = wp_parse_args( $args, $defaults );
44
-
45
-		$output = '';
46
-
47
-		// Don't print empty markup if there's only one page.
48
-		if ( $args['total'] > 1 ) {
49
-			// Set up paginated links.
50
-			$links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
51
-
52
-			$class = !empty($args['class']) ? $args['class'] : '';
53
-
54
-			$custom_prev_link = '';
55
-			$custom_next_link = '';
56
-
57
-			// make the output bootstrap ready
58
-			$links_html = "<ul class='pagination m-0 p-0 $class'>";
59
-			if ( ! empty( $links ) ) {
60
-				foreach ( $links as $link ) {
61
-					$_link = $link;
62
-
63
-					if ( $aui_bs5 ) {
64
-						$link_class = $args['rounded_style'] ? 'page-link badge rounded-pill border-0 mx-1 fs-base text-dark link-primary' : 'page-link';
65
-						$link_class_active = $args['rounded_style'] ? ' current active fw-bold badge rounded-pill' : ' current active';
66
-						$links_html .= "<li class='page-item mx-0'>";
67
-						$link = str_replace( array( "page-numbers", " current" ), array( $link_class, $link_class_active ), $link );
68
-						$link = str_replace( 'text-dark link-primary current', 'current', $link );
69
-						$links_html .=  $link;
70
-						$links_html .= "</li>";
71
-					} else {
72
-						$active = strpos( $link, 'current' ) !== false ? 'active' : '';
73
-						$links_html .= "<li class='page-item $active'>";
74
-						$links_html .= str_replace( "page-numbers", "page-link", $link );
75
-						$links_html .= "</li>";
76
-					}
77
-
78
-					if ( strpos( $_link, 'next page-numbers' ) || strpos( $_link, 'prev page-numbers' ) ) {
79
-						$link = str_replace( array( "page-numbers", " current" ), array( 'btn btn-outline-primary rounded' . ( $args['rounded_style'] ? '-pill' : '' ) . ' mx-1 fs-base text-dark link-primary', ' current active fw-bold badge rounded-pill' ), $_link );
80
-						$link = str_replace( 'text-dark link-primary current', 'current', $link );
81
-
82
-						if ( strpos( $_link, 'next page-numbers' ) && ! empty( $args['custom_next_text'] ) ) {
83
-							$custom_next_link = str_replace( $args['next_text'], $args['custom_next_text'], $link );
84
-						} else if ( strpos( $_link, 'prev page-numbers' ) && ! empty( $args['custom_prev_text'] ) ) {
85
-							$custom_prev_link = str_replace( $args['prev_text'], $args['custom_prev_text'], $link );
86
-						}
87
-					}
88
-				}
89
-			}
90
-			$links_html .= "</ul>";
91
-
92
-			if ( $links ) {
93
-				$output .= '<section class="px-0 py-2 w-100">';
94
-				$output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
95
-				$output .= '</section>';
96
-			}
97
-
98
-			$output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
99
-			$output = str_replace( "nav-links", "aui-nav-links", $output );
100
-		}
101
-
102
-		if ( $output ) {
103
-			if ( $custom_next_link || $custom_prev_link ) {
104
-				$total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
105
-				$current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
106
-
107
-				$output = '<div class="row d-flex align-items-center justify-content-between"><div class="col text-start">' . $custom_prev_link . '</div><div class="col text-center d-none d-md-block">' . $output . '</div><div class="col text-center d-md-none">' . $current . '/' . $args['total'] . '</div><div class="col text-end">' . $custom_next_link . '</div></div>';
108
-			}
109
-
110
-			if ( ! empty( $args['before_paging'] ) ) {
111
-				$output = $args['before_paging'] . $output;
112
-			}
113
-
114
-			if ( ! empty( $args['after_paging'] ) ) {
115
-				$output = $output . $args['after_paging'];
116
-			}
117
-		}
118
-
119
-		return $output;
120
-	}
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get( $args = array() ) {
22
+        global $wp_query, $aui_bs5;
23
+
24
+        $defaults = array(
25
+            'class'              => '',
26
+            'mid_size'           => 2,
27
+            'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
+            'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
+            'screen_reader_text' => __( 'Posts navigation', 'ayecode-connect' ),
30
+            'before_paging'      => '',
31
+            'after_paging'       => '',
32
+            'type'               => 'array',
33
+            'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
+            'links'              => array(), // an array of links if using custom links, this includes the a tag.
35
+            'rounded_style'      => false,
36
+            'custom_next_text'   => '', // Custom next page text
37
+            'custom_prev_text'   => '', // Custom prev page text
38
+        );
39
+
40
+        /**
41
+         * Parse incoming $args into an array and merge it with $defaults
42
+         */
43
+        $args = wp_parse_args( $args, $defaults );
44
+
45
+        $output = '';
46
+
47
+        // Don't print empty markup if there's only one page.
48
+        if ( $args['total'] > 1 ) {
49
+            // Set up paginated links.
50
+            $links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
51
+
52
+            $class = !empty($args['class']) ? $args['class'] : '';
53
+
54
+            $custom_prev_link = '';
55
+            $custom_next_link = '';
56
+
57
+            // make the output bootstrap ready
58
+            $links_html = "<ul class='pagination m-0 p-0 $class'>";
59
+            if ( ! empty( $links ) ) {
60
+                foreach ( $links as $link ) {
61
+                    $_link = $link;
62
+
63
+                    if ( $aui_bs5 ) {
64
+                        $link_class = $args['rounded_style'] ? 'page-link badge rounded-pill border-0 mx-1 fs-base text-dark link-primary' : 'page-link';
65
+                        $link_class_active = $args['rounded_style'] ? ' current active fw-bold badge rounded-pill' : ' current active';
66
+                        $links_html .= "<li class='page-item mx-0'>";
67
+                        $link = str_replace( array( "page-numbers", " current" ), array( $link_class, $link_class_active ), $link );
68
+                        $link = str_replace( 'text-dark link-primary current', 'current', $link );
69
+                        $links_html .=  $link;
70
+                        $links_html .= "</li>";
71
+                    } else {
72
+                        $active = strpos( $link, 'current' ) !== false ? 'active' : '';
73
+                        $links_html .= "<li class='page-item $active'>";
74
+                        $links_html .= str_replace( "page-numbers", "page-link", $link );
75
+                        $links_html .= "</li>";
76
+                    }
77
+
78
+                    if ( strpos( $_link, 'next page-numbers' ) || strpos( $_link, 'prev page-numbers' ) ) {
79
+                        $link = str_replace( array( "page-numbers", " current" ), array( 'btn btn-outline-primary rounded' . ( $args['rounded_style'] ? '-pill' : '' ) . ' mx-1 fs-base text-dark link-primary', ' current active fw-bold badge rounded-pill' ), $_link );
80
+                        $link = str_replace( 'text-dark link-primary current', 'current', $link );
81
+
82
+                        if ( strpos( $_link, 'next page-numbers' ) && ! empty( $args['custom_next_text'] ) ) {
83
+                            $custom_next_link = str_replace( $args['next_text'], $args['custom_next_text'], $link );
84
+                        } else if ( strpos( $_link, 'prev page-numbers' ) && ! empty( $args['custom_prev_text'] ) ) {
85
+                            $custom_prev_link = str_replace( $args['prev_text'], $args['custom_prev_text'], $link );
86
+                        }
87
+                    }
88
+                }
89
+            }
90
+            $links_html .= "</ul>";
91
+
92
+            if ( $links ) {
93
+                $output .= '<section class="px-0 py-2 w-100">';
94
+                $output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
95
+                $output .= '</section>';
96
+            }
97
+
98
+            $output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
99
+            $output = str_replace( "nav-links", "aui-nav-links", $output );
100
+        }
101
+
102
+        if ( $output ) {
103
+            if ( $custom_next_link || $custom_prev_link ) {
104
+                $total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
105
+                $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
106
+
107
+                $output = '<div class="row d-flex align-items-center justify-content-between"><div class="col text-start">' . $custom_prev_link . '</div><div class="col text-center d-none d-md-block">' . $output . '</div><div class="col text-center d-md-none">' . $current . '/' . $args['total'] . '</div><div class="col text-end">' . $custom_next_link . '</div></div>';
108
+            }
109
+
110
+            if ( ! empty( $args['before_paging'] ) ) {
111
+                $output = $args['before_paging'] . $output;
112
+            }
113
+
114
+            if ( ! empty( $args['after_paging'] ) ) {
115
+                $output = $output . $args['after_paging'];
116
+            }
117
+        }
118
+
119
+        return $output;
120
+    }
121 121
 
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/inc/bs5-js.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1001,8 +1001,8 @@
 block discarded – undo
1001 1001
     aui_flip_color_scheme_on_scroll();
1002 1002
 
1003 1003
 	<?php
1004
-	// FSE tweaks.
1005
-	if(!empty($_REQUEST['postType'])){ ?>
1004
+    // FSE tweaks.
1005
+    if(!empty($_REQUEST['postType'])){ ?>
1006 1006
     function aui_fse_set_data_scroll() {
1007 1007
         console.log('init scroll');
1008 1008
         let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas");
Please login to merge, or discard this patch.
vendor/ayecode/ayecode-connect-helper/ayecode-connect-helper.php 1 patch
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -1,264 +1,264 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( ! class_exists( "AyeCode_Connect_Helper" ) ) {
7
-	/**
8
-	 * Allow the quick setup and connection of our AyeCode Connect plugin.
9
-	 *
10
-	 * Class AyeCode_Connect_Helper
11
-	 */
12
-	class AyeCode_Connect_Helper {
13
-
14
-		// Hold the version number
15
-		var $version = "1.0.4";
16
-
17
-		// Hold the default strings.
18
-		var $strings = array();
19
-
20
-		// Hold the default pages.
21
-		var $pages = array();
22
-
23
-		/**
24
-		 * The constructor.
25
-		 *
26
-		 * AyeCode_Connect_Helper constructor.
27
-		 *
28
-		 * @param array $strings
29
-		 * @param array $pages
30
-		 */
31
-		public function __construct( $strings = array(), $pages = array() ) {
32
-			// Only fire if not localhost and the current user has the right permissions.
33
-			if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) {
34
-				// set default strings
35
-				$default_strings = array(
36
-					'connect_title'     => __( "Thanks for choosing an AyeCode Product!", 'ayecode-connect' ),
37
-					'connect_external'  => __( "Please confirm you wish to connect your site?", 'ayecode-connect' ),
38
-					'connect'           => wp_sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", 'ayecode-connect' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ),
39
-					'connect_button'    => __( "Connect Site", 'ayecode-connect' ),
40
-					'connecting_button' => __( "Connecting...", 'ayecode-connect' ),
41
-					'error_localhost'   => __( "This service will only work with a live domain, not a localhost.", 'ayecode-connect' ),
42
-					'error'             => __( "Something went wrong, please refresh and try again.", 'ayecode-connect' ),
43
-				);
44
-				$this->strings   = array_merge( $default_strings, $strings );
45
-
46
-				// set default pages
47
-				$default_pages = array();
48
-				$this->pages   = array_merge( $default_pages, $pages );
49
-
50
-				// maybe show connect site notice
51
-				add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) );
52
-
53
-				// add ajax action if not already added
54
-				if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) {
55
-					add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) );
56
-				}
57
-			}
58
-
59
-			// add ajax action if not already added
60
-			if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) {
61
-				add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) );
62
-			}
63
-		}
64
-
65
-		/**
66
-		 * Give a way to check we can connect via a external redirect.
67
-		 */
68
-		public function ayecode_connect_helper_installed(){
69
-			$active = array(
70
-				'gd'    =>  defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0,
71
-				'uwp'    =>  defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0,
72
-				'wpi'    =>  defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0,
73
-			);
74
-			wp_send_json_success( $active );
75
-			wp_die();
76
-		}
77
-
78
-		/**
79
-		 * Get slug from path
80
-		 *
81
-		 * @param  string $key
82
-		 *
83
-		 * @return string
84
-		 */
85
-		private function format_plugin_slug( $key ) {
86
-			$slug = explode( '/', $key );
87
-			$slug = explode( '.', end( $slug ) );
88
-
89
-			return $slug[0];
90
-		}
91
-
92
-		/**
93
-		 * Install and activate the AyeCode Connect Plugin
94
-		 */
95
-		public function ayecode_connect_install() {
96
-			// bail if localhost
97
-			if ( $this->is_localhost() ) {
98
-				wp_send_json_error( $this->strings['error_localhost'] );
99
-			}
100
-
101
-			// Explicitly clear the event.
102
-			wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() );
103
-
104
-			$success     = true;
105
-			$plugin_slug = "ayecode-connect";
106
-			if ( ! empty( $plugin_slug ) ) {
107
-				require_once( ABSPATH . 'wp-admin/includes/file.php' );
108
-				require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
109
-				require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
110
-				require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
111
-
112
-				WP_Filesystem();
113
-
114
-				$skin              = new Automatic_Upgrader_Skin;
115
-				$upgrader          = new WP_Upgrader( $skin );
116
-				$installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) );
117
-				$plugin_slug       = $plugin_slug;
118
-				$plugin            = $plugin_slug . '/' . $plugin_slug . '.php';
119
-				$installed         = false;
120
-				$activate          = false;
121
-
122
-				// See if the plugin is installed already
123
-				if ( in_array( $plugin_slug, $installed_plugins ) ) {
124
-					$installed = true;
125
-					$activate  = ! is_plugin_active( $plugin );
126
-				}
127
-
128
-				// Install this thing!
129
-				if ( ! $installed ) {
130
-
131
-					// Suppress feedback
132
-					ob_start();
133
-
134
-					try {
135
-						$plugin_information = plugins_api( 'plugin_information', array(
136
-							'slug'   => $plugin_slug,
137
-							'fields' => array(
138
-								'short_description' => false,
139
-								'sections'          => false,
140
-								'requires'          => false,
141
-								'rating'            => false,
142
-								'ratings'           => false,
143
-								'downloaded'        => false,
144
-								'last_updated'      => false,
145
-								'added'             => false,
146
-								'tags'              => false,
147
-								'homepage'          => false,
148
-								'donate_link'       => false,
149
-								'author_profile'    => false,
150
-								'author'            => false,
151
-							),
152
-						) );
153
-
154
-						if ( is_wp_error( $plugin_information ) ) {
155
-							throw new Exception( $plugin_information->get_error_message() );
156
-						}
157
-
158
-						$package  = $plugin_information->download_link;
159
-						$download = $upgrader->download_package( $package );
160
-
161
-						if ( is_wp_error( $download ) ) {
162
-							throw new Exception( $download->get_error_message() );
163
-						}
164
-
165
-						$working_dir = $upgrader->unpack_package( $download, true );
166
-
167
-						if ( is_wp_error( $working_dir ) ) {
168
-							throw new Exception( $working_dir->get_error_message() );
169
-						}
170
-
171
-						$result = $upgrader->install_package( array(
172
-							'source'                      => $working_dir,
173
-							'destination'                 => WP_PLUGIN_DIR,
174
-							'clear_destination'           => false,
175
-							'abort_if_destination_exists' => false,
176
-							'clear_working'               => true,
177
-							'hook_extra'                  => array(
178
-								'type'   => 'plugin',
179
-								'action' => 'install',
180
-							),
181
-						) );
182
-
183
-						if ( is_wp_error( $result ) ) {
184
-							throw new Exception( $result->get_error_message() );
185
-						}
186
-
187
-						$activate = true;
188
-
189
-					} catch ( Exception $e ) {
190
-						$success = false;
191
-					}
192
-
193
-					// Discard feedback
194
-					ob_end_clean();
195
-				}
196
-
197
-				wp_clean_plugins_cache();
198
-
199
-				// Activate this thing
200
-				if ( $activate ) {
201
-					try {
202
-						$result = activate_plugin( $plugin );
203
-
204
-						if ( is_wp_error( $result ) ) {
205
-							$success = false;
206
-						} else {
207
-							$success = true;
208
-						}
209
-					} catch ( Exception $e ) {
210
-						$success = false;
211
-					}
212
-				}
213
-			}
214
-
215
-			if ( $success && function_exists( 'ayecode_connect_args' ) ) {
216
-				ayecode_connect();// init
217
-				$args        = ayecode_connect_args();
218
-				$client      = new AyeCode_Connect( $args );
219
-				$redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : '';
220
-				$redirect    = $client->build_connect_url( $redirect_to );
221
-				wp_send_json_success( array( 'connect_url' => $redirect ) );
222
-			} else {
223
-				wp_send_json_error( $this->strings['error_localhost'] );
224
-			}
225
-			wp_die();
226
-		}
227
-
228
-		/**
229
-		 * Check if maybe localhost.
230
-		 *
231
-		 * @return bool
232
-		 */
233
-		public function is_localhost() {
234
-			$localhost = false;
235
-
236
-			$host              = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
237
-			$localhost_domains = array(
238
-				'localhost',
239
-				'localhost.localdomain',
240
-				'127.0.0.1',
241
-				'::1'
242
-			);
243
-
244
-			if ( in_array( $host, $localhost_domains ) ) {
245
-				$localhost = true;
246
-			}
247
-
248
-			return $localhost;
249
-		}
250
-
251
-		/**
252
-		 * Show notice to connect site.
253
-		 */
254
-		public function ayecode_connect_install_notice() {
255
-			if ( $this->maybe_show() ) {
256
-				$connect_title_string     = $this->strings['connect_title'];
257
-				$connect_external_string  = $this->strings['connect_external'];
258
-				$connect_string           = $this->strings['connect'];
259
-				$connect_button_string    = $this->strings['connect_button'];
260
-				$connecting_button_string = $this->strings['connecting_button'];
261
-				?>
7
+    /**
8
+     * Allow the quick setup and connection of our AyeCode Connect plugin.
9
+     *
10
+     * Class AyeCode_Connect_Helper
11
+     */
12
+    class AyeCode_Connect_Helper {
13
+
14
+        // Hold the version number
15
+        var $version = "1.0.4";
16
+
17
+        // Hold the default strings.
18
+        var $strings = array();
19
+
20
+        // Hold the default pages.
21
+        var $pages = array();
22
+
23
+        /**
24
+         * The constructor.
25
+         *
26
+         * AyeCode_Connect_Helper constructor.
27
+         *
28
+         * @param array $strings
29
+         * @param array $pages
30
+         */
31
+        public function __construct( $strings = array(), $pages = array() ) {
32
+            // Only fire if not localhost and the current user has the right permissions.
33
+            if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) {
34
+                // set default strings
35
+                $default_strings = array(
36
+                    'connect_title'     => __( "Thanks for choosing an AyeCode Product!", 'ayecode-connect' ),
37
+                    'connect_external'  => __( "Please confirm you wish to connect your site?", 'ayecode-connect' ),
38
+                    'connect'           => wp_sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", 'ayecode-connect' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ),
39
+                    'connect_button'    => __( "Connect Site", 'ayecode-connect' ),
40
+                    'connecting_button' => __( "Connecting...", 'ayecode-connect' ),
41
+                    'error_localhost'   => __( "This service will only work with a live domain, not a localhost.", 'ayecode-connect' ),
42
+                    'error'             => __( "Something went wrong, please refresh and try again.", 'ayecode-connect' ),
43
+                );
44
+                $this->strings   = array_merge( $default_strings, $strings );
45
+
46
+                // set default pages
47
+                $default_pages = array();
48
+                $this->pages   = array_merge( $default_pages, $pages );
49
+
50
+                // maybe show connect site notice
51
+                add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) );
52
+
53
+                // add ajax action if not already added
54
+                if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) {
55
+                    add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) );
56
+                }
57
+            }
58
+
59
+            // add ajax action if not already added
60
+            if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) {
61
+                add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) );
62
+            }
63
+        }
64
+
65
+        /**
66
+         * Give a way to check we can connect via a external redirect.
67
+         */
68
+        public function ayecode_connect_helper_installed(){
69
+            $active = array(
70
+                'gd'    =>  defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0,
71
+                'uwp'    =>  defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0,
72
+                'wpi'    =>  defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0,
73
+            );
74
+            wp_send_json_success( $active );
75
+            wp_die();
76
+        }
77
+
78
+        /**
79
+         * Get slug from path
80
+         *
81
+         * @param  string $key
82
+         *
83
+         * @return string
84
+         */
85
+        private function format_plugin_slug( $key ) {
86
+            $slug = explode( '/', $key );
87
+            $slug = explode( '.', end( $slug ) );
88
+
89
+            return $slug[0];
90
+        }
91
+
92
+        /**
93
+         * Install and activate the AyeCode Connect Plugin
94
+         */
95
+        public function ayecode_connect_install() {
96
+            // bail if localhost
97
+            if ( $this->is_localhost() ) {
98
+                wp_send_json_error( $this->strings['error_localhost'] );
99
+            }
100
+
101
+            // Explicitly clear the event.
102
+            wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() );
103
+
104
+            $success     = true;
105
+            $plugin_slug = "ayecode-connect";
106
+            if ( ! empty( $plugin_slug ) ) {
107
+                require_once( ABSPATH . 'wp-admin/includes/file.php' );
108
+                require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
109
+                require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
110
+                require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
111
+
112
+                WP_Filesystem();
113
+
114
+                $skin              = new Automatic_Upgrader_Skin;
115
+                $upgrader          = new WP_Upgrader( $skin );
116
+                $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) );
117
+                $plugin_slug       = $plugin_slug;
118
+                $plugin            = $plugin_slug . '/' . $plugin_slug . '.php';
119
+                $installed         = false;
120
+                $activate          = false;
121
+
122
+                // See if the plugin is installed already
123
+                if ( in_array( $plugin_slug, $installed_plugins ) ) {
124
+                    $installed = true;
125
+                    $activate  = ! is_plugin_active( $plugin );
126
+                }
127
+
128
+                // Install this thing!
129
+                if ( ! $installed ) {
130
+
131
+                    // Suppress feedback
132
+                    ob_start();
133
+
134
+                    try {
135
+                        $plugin_information = plugins_api( 'plugin_information', array(
136
+                            'slug'   => $plugin_slug,
137
+                            'fields' => array(
138
+                                'short_description' => false,
139
+                                'sections'          => false,
140
+                                'requires'          => false,
141
+                                'rating'            => false,
142
+                                'ratings'           => false,
143
+                                'downloaded'        => false,
144
+                                'last_updated'      => false,
145
+                                'added'             => false,
146
+                                'tags'              => false,
147
+                                'homepage'          => false,
148
+                                'donate_link'       => false,
149
+                                'author_profile'    => false,
150
+                                'author'            => false,
151
+                            ),
152
+                        ) );
153
+
154
+                        if ( is_wp_error( $plugin_information ) ) {
155
+                            throw new Exception( $plugin_information->get_error_message() );
156
+                        }
157
+
158
+                        $package  = $plugin_information->download_link;
159
+                        $download = $upgrader->download_package( $package );
160
+
161
+                        if ( is_wp_error( $download ) ) {
162
+                            throw new Exception( $download->get_error_message() );
163
+                        }
164
+
165
+                        $working_dir = $upgrader->unpack_package( $download, true );
166
+
167
+                        if ( is_wp_error( $working_dir ) ) {
168
+                            throw new Exception( $working_dir->get_error_message() );
169
+                        }
170
+
171
+                        $result = $upgrader->install_package( array(
172
+                            'source'                      => $working_dir,
173
+                            'destination'                 => WP_PLUGIN_DIR,
174
+                            'clear_destination'           => false,
175
+                            'abort_if_destination_exists' => false,
176
+                            'clear_working'               => true,
177
+                            'hook_extra'                  => array(
178
+                                'type'   => 'plugin',
179
+                                'action' => 'install',
180
+                            ),
181
+                        ) );
182
+
183
+                        if ( is_wp_error( $result ) ) {
184
+                            throw new Exception( $result->get_error_message() );
185
+                        }
186
+
187
+                        $activate = true;
188
+
189
+                    } catch ( Exception $e ) {
190
+                        $success = false;
191
+                    }
192
+
193
+                    // Discard feedback
194
+                    ob_end_clean();
195
+                }
196
+
197
+                wp_clean_plugins_cache();
198
+
199
+                // Activate this thing
200
+                if ( $activate ) {
201
+                    try {
202
+                        $result = activate_plugin( $plugin );
203
+
204
+                        if ( is_wp_error( $result ) ) {
205
+                            $success = false;
206
+                        } else {
207
+                            $success = true;
208
+                        }
209
+                    } catch ( Exception $e ) {
210
+                        $success = false;
211
+                    }
212
+                }
213
+            }
214
+
215
+            if ( $success && function_exists( 'ayecode_connect_args' ) ) {
216
+                ayecode_connect();// init
217
+                $args        = ayecode_connect_args();
218
+                $client      = new AyeCode_Connect( $args );
219
+                $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : '';
220
+                $redirect    = $client->build_connect_url( $redirect_to );
221
+                wp_send_json_success( array( 'connect_url' => $redirect ) );
222
+            } else {
223
+                wp_send_json_error( $this->strings['error_localhost'] );
224
+            }
225
+            wp_die();
226
+        }
227
+
228
+        /**
229
+         * Check if maybe localhost.
230
+         *
231
+         * @return bool
232
+         */
233
+        public function is_localhost() {
234
+            $localhost = false;
235
+
236
+            $host              = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
237
+            $localhost_domains = array(
238
+                'localhost',
239
+                'localhost.localdomain',
240
+                '127.0.0.1',
241
+                '::1'
242
+            );
243
+
244
+            if ( in_array( $host, $localhost_domains ) ) {
245
+                $localhost = true;
246
+            }
247
+
248
+            return $localhost;
249
+        }
250
+
251
+        /**
252
+         * Show notice to connect site.
253
+         */
254
+        public function ayecode_connect_install_notice() {
255
+            if ( $this->maybe_show() ) {
256
+                $connect_title_string     = $this->strings['connect_title'];
257
+                $connect_external_string  = $this->strings['connect_external'];
258
+                $connect_string           = $this->strings['connect'];
259
+                $connect_button_string    = $this->strings['connect_button'];
260
+                $connecting_button_string = $this->strings['connecting_button'];
261
+                ?>
262 262
 				<div class="notice notice-info acch-notice">
263 263
 					<span class="acch-float-left">
264 264
 						<svg width="61px" height="61px" viewBox="0 0 61 61" version="1.1"
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 				</div>
306 306
 
307 307
 				<?php
308
-				// only include the popup HTML if needed.
309
-				if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
310
-					?>
308
+                // only include the popup HTML if needed.
309
+                if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
310
+                    ?>
311 311
 					<div id="ayecode-connect-helper-external-confirm" style="display:none;">
312 312
 						<div class="noticex notice-info acch-notice" style="border: none;">
313 313
 					<span class="acch-float-left">
@@ -353,23 +353,23 @@  discard block
 block discarded – undo
353 353
 						</div>
354 354
 					</div>
355 355
 					<?php
356
-				}
357
-
358
-				// add required scripts
359
-				$this->script();
360
-			}
361
-		}
362
-
363
-		/**
364
-		 * Get the JS Script.
365
-		 */
366
-		public function script() {
367
-
368
-			// add thickbox if external request is requested
369
-			if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
370
-				add_thickbox();
371
-			}
372
-			?>
356
+                }
357
+
358
+                // add required scripts
359
+                $this->script();
360
+            }
361
+        }
362
+
363
+        /**
364
+         * Get the JS Script.
365
+         */
366
+        public function script() {
367
+
368
+            // add thickbox if external request is requested
369
+            if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
370
+                add_thickbox();
371
+            }
372
+            ?>
373 373
 			<style>
374 374
 				.acch-title {
375 375
 					margin: 0;
@@ -435,38 +435,38 @@  discard block
 block discarded – undo
435 435
 					});
436 436
 				} 
437 437
 				<?php
438
-				// add thickbox if external request is requested
439
-				if(! empty( $_REQUEST['external-connect-request'] )) {
440
-				?>
438
+                // add thickbox if external request is requested
439
+                if(! empty( $_REQUEST['external-connect-request'] )) {
440
+                ?>
441 441
 				jQuery(function () {
442 442
 					setTimeout(function () {
443 443
 						tb_show("AyeCode Connect", "?TB_inline?width=300&height=80&inlineId=ayecode-connect-helper-external-confirm");
444 444
 					}, 200);
445 445
 				});
446 446
 				<?php
447
-				}
448
-				?>
447
+                }
448
+                ?>
449 449
 			</script>
450 450
 			<?php
451
-		}
452
-
453
-		/**
454
-		 * Decide what pages to show on.
455
-		 *
456
-		 * @return bool
457
-		 */
458
-		public function maybe_show() {
459
-			$show = false;
460
-
461
-			// check if on a page set to show
462
-			if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) {
463
-				// check if not active and connected
464
-				if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) {
465
-					$show = true;
466
-				}
467
-			}
468
-
469
-			return $show;
470
-		}
471
-	}
451
+        }
452
+
453
+        /**
454
+         * Decide what pages to show on.
455
+         *
456
+         * @return bool
457
+         */
458
+        public function maybe_show() {
459
+            $show = false;
460
+
461
+            // check if on a page set to show
462
+            if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) {
463
+                // check if not active and connected
464
+                if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) {
465
+                    $show = true;
466
+                }
467
+            }
468
+
469
+            return $show;
470
+        }
471
+    }
472 472
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Indentation   +821 added lines, -821 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,406 +21,406 @@  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
-	 */
29
-	class WP_Font_Awesome_Settings {
30
-
31
-		/**
32
-		 * Class version version.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public $version = '1.1.7';
37
-
38
-		/**
39
-		 * Class textdomain.
40
-		 *
41
-		 * @var string
42
-		 */
43
-		public $textdomain = 'font-awesome-settings';
44
-
45
-		/**
46
-		 * Latest version of Font Awesome at time of publish published.
47
-		 *
48
-		 * @var string
49
-		 */
50
-		public $latest = "6.4.2";
51
-
52
-		/**
53
-		 * The title.
54
-		 *
55
-		 * @var string
56
-		 */
57
-		public $name = 'Font Awesome';
58
-
59
-		/**
60
-		 * Holds the settings values.
61
-		 *
62
-		 * @var array
63
-		 */
64
-		private $settings;
65
-
66
-		/**
67
-		 * WP_Font_Awesome_Settings instance.
68
-		 *
69
-		 * @access private
70
-		 * @since  1.0.0
71
-		 * @var    WP_Font_Awesome_Settings There can be only one!
72
-		 */
73
-		private static $instance = null;
74
-
75
-		/**
76
-		 * Main WP_Font_Awesome_Settings Instance.
77
-		 *
78
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
79
-		 *
80
-		 * @since 1.0.0
81
-		 * @static
82
-		 * @return WP_Font_Awesome_Settings - Main instance.
83
-		 */
84
-		public static function instance() {
85
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
86
-				self::$instance = new WP_Font_Awesome_Settings;
87
-
88
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
89
-
90
-				if ( is_admin() ) {
91
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
92
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
-					add_action( 'admin_init', array( self::$instance, 'constants' ) );
94
-					add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
95
-				}
96
-
97
-				do_action( 'wp_font_awesome_settings_loaded' );
98
-			}
99
-
100
-			return self::$instance;
101
-		}
102
-
103
-		/**
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     */
29
+    class WP_Font_Awesome_Settings {
30
+
31
+        /**
32
+         * Class version version.
33
+         *
34
+         * @var string
35
+         */
36
+        public $version = '1.1.7';
37
+
38
+        /**
39
+         * Class textdomain.
40
+         *
41
+         * @var string
42
+         */
43
+        public $textdomain = 'font-awesome-settings';
44
+
45
+        /**
46
+         * Latest version of Font Awesome at time of publish published.
47
+         *
48
+         * @var string
49
+         */
50
+        public $latest = "6.4.2";
51
+
52
+        /**
53
+         * The title.
54
+         *
55
+         * @var string
56
+         */
57
+        public $name = 'Font Awesome';
58
+
59
+        /**
60
+         * Holds the settings values.
61
+         *
62
+         * @var array
63
+         */
64
+        private $settings;
65
+
66
+        /**
67
+         * WP_Font_Awesome_Settings instance.
68
+         *
69
+         * @access private
70
+         * @since  1.0.0
71
+         * @var    WP_Font_Awesome_Settings There can be only one!
72
+         */
73
+        private static $instance = null;
74
+
75
+        /**
76
+         * Main WP_Font_Awesome_Settings Instance.
77
+         *
78
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
79
+         *
80
+         * @since 1.0.0
81
+         * @static
82
+         * @return WP_Font_Awesome_Settings - Main instance.
83
+         */
84
+        public static function instance() {
85
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
86
+                self::$instance = new WP_Font_Awesome_Settings;
87
+
88
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
89
+
90
+                if ( is_admin() ) {
91
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
92
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
+                    add_action( 'admin_init', array( self::$instance, 'constants' ) );
94
+                    add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
95
+                }
96
+
97
+                do_action( 'wp_font_awesome_settings_loaded' );
98
+            }
99
+
100
+            return self::$instance;
101
+        }
102
+
103
+        /**
104 104
          * Define any constants that may be needed by other packages.
105 105
          *
106
-		 * @return void
107
-		 */
108
-		public function constants(){
106
+         * @return void
107
+         */
108
+        public function constants(){
109 109
 
110
-			// register iconpicker constant
111
-			if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
112
-				$url = $this->get_path_url();
113
-				$version = $this->settings['version'];
110
+            // register iconpicker constant
111
+            if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
112
+                $url = $this->get_path_url();
113
+                $version = $this->settings['version'];
114 114
 
115
-				if( !$version || version_compare($version,'5.999','>')){
116
-					$url .= 'assets/js/fa-iconpicker-v6.min.js';
117
-				}else{
118
-					$url .= 'assets/js/fa-iconpicker-v5.min.js';
119
-				}
115
+                if( !$version || version_compare($version,'5.999','>')){
116
+                    $url .= 'assets/js/fa-iconpicker-v6.min.js';
117
+                }else{
118
+                    $url .= 'assets/js/fa-iconpicker-v5.min.js';
119
+                }
120 120
 
121
-				define( 'FAS_ICONPICKER_JS_URL', $url );
121
+                define( 'FAS_ICONPICKER_JS_URL', $url );
122 122
 
123
-			}
123
+            }
124 124
 
125 125
             // Set a constant if pro enbaled
126
-			if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
127
-				define( 'FAS_PRO', true );
128
-			}
129
-		}
130
-
131
-		/**
132
-		 * Get the url path to the current folder.
133
-		 *
134
-		 * @return string
135
-		 */
136
-		public function get_path_url() {
137
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138
-			$content_url = untrailingslashit( WP_CONTENT_URL );
139
-
140
-			// Replace http:// to https://.
141
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
142
-				$content_url = str_replace( 'http://', 'https://', $content_url );
143
-			}
144
-
145
-			// Check if we are inside a plugin
146
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
147
-			$url = str_replace( $content_dir, $content_url, $file_dir );
148
-
149
-			return trailingslashit( $url );
150
-		}
151
-
152
-		/**
153
-		 * Initiate the settings and add the required action hooks.
154
-		 *
155
-		 * @since 1.0.8 Settings name wrong - FIXED
156
-		 */
157
-		public function init() {
158
-			// Download fontawesome locally.
159
-			add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
160
-			add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
161
-
162
-			$this->settings = $this->get_settings();
163
-
164
-			// Check if the official plugin is active and use that instead if so.
165
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
166
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
167
-					add_action( 'admin_head', array( $this, 'add_generator' ), 99 );
168
-				}
169
-
170
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171
-					add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
172
-				}
173
-
174
-				if ( $this->settings['type'] == 'CSS' ) {
175
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
176
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
177
-						//add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178
-					}
179
-
180
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
181
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
182
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
183
-					}
184
-				} else {
185
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
186
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
187
-					}
188
-
189
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
190
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
191
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
192
-					}
193
-				}
194
-
195
-				// remove font awesome if set to do so
196
-				if ( $this->settings['dequeue'] == '1' ) {
197
-					add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
198
-				}
199
-			}
200
-
201
-		}
202
-
203
-		/**
204
-		 * Add FA to the FSE.
205
-		 *
206
-		 * @param $editor_settings
207
-		 * @param $block_editor_context
208
-		 *
209
-		 * @return array
210
-		 */
211
-		public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
212
-
213
-			if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
214
-				$url = $this->get_url();
215
-				$editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
216
-			}
217
-
218
-			return $editor_settings;
219
-		}
220
-
221
-		/**
222
-		 * Add FA to the FSE.
223
-		 *
224
-		 * @param $editor_settings
225
-		 * @param $block_editor_context
226
-		 *
227
-		 * @return array
228
-		 */
229
-		public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
230
-
231
-			$url = $this->get_url();
232
-			$editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
233
-
234
-			return $editor_settings;
235
-		}
236
-
237
-		/**
238
-		 * Adds the Font Awesome styles.
239
-		 */
240
-		public function enqueue_style() {
241
-			// build url
242
-			$url = $this->get_url();
243
-			$version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
244
-
245
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
246
-			wp_register_style( 'font-awesome', $url, array(), $version );
247
-			wp_enqueue_style( 'font-awesome' );
248
-
249
-			// RTL language support CSS.
250
-			if ( is_rtl() ) {
251
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
252
-			}
253
-
254
-			if ( $this->settings['shims'] ) {
255
-				$url = $this->get_url( true );
256
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
257
-				wp_register_style( 'font-awesome-shims', $url, array(), $version );
258
-				wp_enqueue_style( 'font-awesome-shims' );
259
-			}
260
-		}
261
-
262
-		/**
263
-		 * Adds the Font Awesome JS.
264
-		 */
265
-		public function enqueue_scripts() {
266
-			// build url
267
-			$url = $this->get_url();
268
-
269
-			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
270
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
271
-			wp_register_script( 'font-awesome', $url, array(), null );
272
-			wp_enqueue_script( 'font-awesome' );
273
-
274
-			if ( $this->settings['shims'] ) {
275
-				$url = $this->get_url( true );
276
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
277
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
278
-				wp_enqueue_script( 'font-awesome-shims' );
279
-			}
280
-		}
281
-
282
-		/**
283
-		 * Get the url of the Font Awesome files.
284
-		 *
285
-		 * @param bool $shims If this is a shim file or not.
286
-		 * @param bool $local Load locally if allowed.
287
-		 *
288
-		 * @return string The url to the file.
289
-		 */
290
-		public function get_url( $shims = false, $local = true ) {
291
-			$script  = $shims ? 'v4-shims' : 'all';
292
-			$sub     = $this->settings['pro'] ? 'pro' : 'use';
293
-			$type    = $this->settings['type'];
294
-			$version = $this->settings['version'];
295
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
296
-			$url     = '';
297
-
298
-			if ( $type == 'KIT' && $kit_url ) {
299
-				if ( $shims ) {
300
-					// if its a kit then we don't add shims here
301
-					return '';
302
-				}
303
-				$url .= $kit_url; // CDN
304
-				$url .= "?wpfas=true"; // set our var so our version is not removed
305
-			} else {
306
-				$v = '';
307
-				// Check and load locally.
308
-				if ( $local && $this->has_local() ) {
309
-					$script .= ".min";
310
-					$v .= '&ver=' . strip_tags( $this->settings['local_version'] );
311
-					$url .= $this->get_fonts_url(); // Local fonts url.
312
-				} else {
313
-					$url .= "https://$sub.fontawesome.com/releases/"; // CDN
314
-					$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
315
-				}
316
-				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
317
-				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
318
-				$url .= "?wpfas=true" . $v; // set our var so our version is not removed
319
-			}
320
-
321
-			return $url;
322
-		}
323
-
324
-		/**
325
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
326
-		 *
327
-		 * 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.
328
-		 *
329
-		 * @param $url
330
-		 * @param $original_url
331
-		 * @param $_context
332
-		 *
333
-		 * @return string The filtered url.
334
-		 */
335
-		public function remove_font_awesome( $url, $original_url, $_context ) {
336
-
337
-			if ( $_context == 'display'
338
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
339
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
340
-			) {// it's a font-awesome-url (probably)
341
-
342
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
343
-					if ( $this->settings['type'] == 'JS' ) {
344
-						if ( $this->settings['js-pseudo'] ) {
345
-							$url .= "' data-search-pseudo-elements defer='defer";
346
-						} else {
347
-							$url .= "' defer='defer";
348
-						}
349
-					}
350
-				} else {
351
-					$url = ''; // removing the url removes the file
352
-				}
353
-
354
-			}
355
-
356
-			return $url;
357
-		}
358
-
359
-		/**
360
-		 * Register the database settings with WordPress.
361
-		 */
362
-		public function register_settings() {
363
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
364
-		}
365
-
366
-		/**
367
-		 * Add the WordPress settings menu item.
368
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
369
-		 */
370
-		public function menu_item() {
371
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
372
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
373
-				$this,
374
-				'settings_page'
375
-			) );
376
-		}
377
-
378
-		/**
379
-		 * Get the current Font Awesome output settings.
380
-		 *
381
-		 * @return array The array of settings.
382
-		 */
383
-		public function get_settings() {
384
-			$db_settings = get_option( 'wp-font-awesome-settings' );
385
-
386
-			$defaults = array(
387
-				'type'      => 'CSS', // type to use, CSS or JS or KIT
388
-				'version'   => '', // latest
389
-				'enqueue'   => '', // front and backend
390
-				'shims'     => '0', // default OFF now in 2020
391
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
392
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
393
-				'pro'       => '0', // if pro CDN url should be used
394
-				'local'     => '0', // Store fonts locally.
395
-				'local_version' => '', // Local fonts version.
396
-				'kit-url'   => '', // the kit url
397
-			);
398
-
399
-			$settings = wp_parse_args( $db_settings, $defaults );
400
-
401
-			/**
402
-			 * Filter the Font Awesome settings.
403
-			 *
404
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
405
-			 */
406
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
407
-		}
408
-
409
-		/**
410
-		 * The settings page html output.
411
-		 */
412
-		public function settings_page() {
413
-			if ( ! current_user_can( 'manage_options' ) ) {
414
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
415
-			}
416
-
417
-			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
418
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
419
-				$this->get_latest_version( $force_api = true );
420
-			}
421
-
422
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
423
-				?>
126
+            if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
127
+                define( 'FAS_PRO', true );
128
+            }
129
+        }
130
+
131
+        /**
132
+         * Get the url path to the current folder.
133
+         *
134
+         * @return string
135
+         */
136
+        public function get_path_url() {
137
+            $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138
+            $content_url = untrailingslashit( WP_CONTENT_URL );
139
+
140
+            // Replace http:// to https://.
141
+            if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
142
+                $content_url = str_replace( 'http://', 'https://', $content_url );
143
+            }
144
+
145
+            // Check if we are inside a plugin
146
+            $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
147
+            $url = str_replace( $content_dir, $content_url, $file_dir );
148
+
149
+            return trailingslashit( $url );
150
+        }
151
+
152
+        /**
153
+         * Initiate the settings and add the required action hooks.
154
+         *
155
+         * @since 1.0.8 Settings name wrong - FIXED
156
+         */
157
+        public function init() {
158
+            // Download fontawesome locally.
159
+            add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
160
+            add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
161
+
162
+            $this->settings = $this->get_settings();
163
+
164
+            // Check if the official plugin is active and use that instead if so.
165
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
166
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
167
+                    add_action( 'admin_head', array( $this, 'add_generator' ), 99 );
168
+                }
169
+
170
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171
+                    add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
172
+                }
173
+
174
+                if ( $this->settings['type'] == 'CSS' ) {
175
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
176
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
177
+                        //add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178
+                    }
179
+
180
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
181
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
182
+                        add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
183
+                    }
184
+                } else {
185
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
186
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
187
+                    }
188
+
189
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
190
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
191
+                        add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
192
+                    }
193
+                }
194
+
195
+                // remove font awesome if set to do so
196
+                if ( $this->settings['dequeue'] == '1' ) {
197
+                    add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
198
+                }
199
+            }
200
+
201
+        }
202
+
203
+        /**
204
+         * Add FA to the FSE.
205
+         *
206
+         * @param $editor_settings
207
+         * @param $block_editor_context
208
+         *
209
+         * @return array
210
+         */
211
+        public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
212
+
213
+            if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
214
+                $url = $this->get_url();
215
+                $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
216
+            }
217
+
218
+            return $editor_settings;
219
+        }
220
+
221
+        /**
222
+         * Add FA to the FSE.
223
+         *
224
+         * @param $editor_settings
225
+         * @param $block_editor_context
226
+         *
227
+         * @return array
228
+         */
229
+        public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
230
+
231
+            $url = $this->get_url();
232
+            $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
233
+
234
+            return $editor_settings;
235
+        }
236
+
237
+        /**
238
+         * Adds the Font Awesome styles.
239
+         */
240
+        public function enqueue_style() {
241
+            // build url
242
+            $url = $this->get_url();
243
+            $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
244
+
245
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
246
+            wp_register_style( 'font-awesome', $url, array(), $version );
247
+            wp_enqueue_style( 'font-awesome' );
248
+
249
+            // RTL language support CSS.
250
+            if ( is_rtl() ) {
251
+                wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
252
+            }
253
+
254
+            if ( $this->settings['shims'] ) {
255
+                $url = $this->get_url( true );
256
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
257
+                wp_register_style( 'font-awesome-shims', $url, array(), $version );
258
+                wp_enqueue_style( 'font-awesome-shims' );
259
+            }
260
+        }
261
+
262
+        /**
263
+         * Adds the Font Awesome JS.
264
+         */
265
+        public function enqueue_scripts() {
266
+            // build url
267
+            $url = $this->get_url();
268
+
269
+            $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
270
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
271
+            wp_register_script( 'font-awesome', $url, array(), null );
272
+            wp_enqueue_script( 'font-awesome' );
273
+
274
+            if ( $this->settings['shims'] ) {
275
+                $url = $this->get_url( true );
276
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
277
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
278
+                wp_enqueue_script( 'font-awesome-shims' );
279
+            }
280
+        }
281
+
282
+        /**
283
+         * Get the url of the Font Awesome files.
284
+         *
285
+         * @param bool $shims If this is a shim file or not.
286
+         * @param bool $local Load locally if allowed.
287
+         *
288
+         * @return string The url to the file.
289
+         */
290
+        public function get_url( $shims = false, $local = true ) {
291
+            $script  = $shims ? 'v4-shims' : 'all';
292
+            $sub     = $this->settings['pro'] ? 'pro' : 'use';
293
+            $type    = $this->settings['type'];
294
+            $version = $this->settings['version'];
295
+            $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
296
+            $url     = '';
297
+
298
+            if ( $type == 'KIT' && $kit_url ) {
299
+                if ( $shims ) {
300
+                    // if its a kit then we don't add shims here
301
+                    return '';
302
+                }
303
+                $url .= $kit_url; // CDN
304
+                $url .= "?wpfas=true"; // set our var so our version is not removed
305
+            } else {
306
+                $v = '';
307
+                // Check and load locally.
308
+                if ( $local && $this->has_local() ) {
309
+                    $script .= ".min";
310
+                    $v .= '&ver=' . strip_tags( $this->settings['local_version'] );
311
+                    $url .= $this->get_fonts_url(); // Local fonts url.
312
+                } else {
313
+                    $url .= "https://$sub.fontawesome.com/releases/"; // CDN
314
+                    $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
315
+                }
316
+                $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
317
+                $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
318
+                $url .= "?wpfas=true" . $v; // set our var so our version is not removed
319
+            }
320
+
321
+            return $url;
322
+        }
323
+
324
+        /**
325
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
326
+         *
327
+         * 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.
328
+         *
329
+         * @param $url
330
+         * @param $original_url
331
+         * @param $_context
332
+         *
333
+         * @return string The filtered url.
334
+         */
335
+        public function remove_font_awesome( $url, $original_url, $_context ) {
336
+
337
+            if ( $_context == 'display'
338
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
339
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
340
+            ) {// it's a font-awesome-url (probably)
341
+
342
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
343
+                    if ( $this->settings['type'] == 'JS' ) {
344
+                        if ( $this->settings['js-pseudo'] ) {
345
+                            $url .= "' data-search-pseudo-elements defer='defer";
346
+                        } else {
347
+                            $url .= "' defer='defer";
348
+                        }
349
+                    }
350
+                } else {
351
+                    $url = ''; // removing the url removes the file
352
+                }
353
+
354
+            }
355
+
356
+            return $url;
357
+        }
358
+
359
+        /**
360
+         * Register the database settings with WordPress.
361
+         */
362
+        public function register_settings() {
363
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
364
+        }
365
+
366
+        /**
367
+         * Add the WordPress settings menu item.
368
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
369
+         */
370
+        public function menu_item() {
371
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
372
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
373
+                $this,
374
+                'settings_page'
375
+            ) );
376
+        }
377
+
378
+        /**
379
+         * Get the current Font Awesome output settings.
380
+         *
381
+         * @return array The array of settings.
382
+         */
383
+        public function get_settings() {
384
+            $db_settings = get_option( 'wp-font-awesome-settings' );
385
+
386
+            $defaults = array(
387
+                'type'      => 'CSS', // type to use, CSS or JS or KIT
388
+                'version'   => '', // latest
389
+                'enqueue'   => '', // front and backend
390
+                'shims'     => '0', // default OFF now in 2020
391
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
392
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
393
+                'pro'       => '0', // if pro CDN url should be used
394
+                'local'     => '0', // Store fonts locally.
395
+                'local_version' => '', // Local fonts version.
396
+                'kit-url'   => '', // the kit url
397
+            );
398
+
399
+            $settings = wp_parse_args( $db_settings, $defaults );
400
+
401
+            /**
402
+             * Filter the Font Awesome settings.
403
+             *
404
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
405
+             */
406
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
407
+        }
408
+
409
+        /**
410
+         * The settings page html output.
411
+         */
412
+        public function settings_page() {
413
+            if ( ! current_user_can( 'manage_options' ) ) {
414
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
415
+            }
416
+
417
+            // a hidden way to force the update of the version number via api instead of waiting the 48 hours
418
+            if ( isset( $_REQUEST['force-version-check'] ) ) {
419
+                $this->get_latest_version( $force_api = true );
420
+            }
421
+
422
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
423
+                ?>
424 424
                 <style>
425 425
                     .wpfas-kit-show {
426 426
                         display: none;
@@ -446,16 +446,16 @@  discard block
 block discarded – undo
446 446
                     <h1><?php echo $this->name; ?></h1>
447 447
                     <form method="post" action="options.php" class="fas-settings-form">
448 448
 						<?php
449
-						settings_fields( 'wp-font-awesome-settings' );
450
-						do_settings_sections( 'wp-font-awesome-settings' );
451
-						$table_class = '';
452
-						if ( $this->settings['type'] ) {
453
-							$table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
454
-						}
455
-						if ( ! empty( $this->settings['pro'] ) ) {
456
-							$table_class .= ' wpfas-has-pro';
457
-						}
458
-						?>
449
+                        settings_fields( 'wp-font-awesome-settings' );
450
+                        do_settings_sections( 'wp-font-awesome-settings' );
451
+                        $table_class = '';
452
+                        if ( $this->settings['type'] ) {
453
+                            $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
454
+                        }
455
+                        if ( ! empty( $this->settings['pro'] ) ) {
456
+                            $table_class .= ' wpfas-has-pro';
457
+                        }
458
+                        ?>
459 459
 						<?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?>
460 460
 							<?php if ( $this->has_local() ) { ?>
461 461
                                 <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'ayecode-connect' ); ?></strong></p></div>
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
                                 <td>
481 481
                                     <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
482 482
                                     <span><?php
483
-										echo wp_sprintf(
484
-											__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
485
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
486
-											'</a>'
487
-										);
488
-										?></span>
483
+                                        echo wp_sprintf(
484
+                                            __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
485
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
486
+                                            '</a>'
487
+                                        );
488
+                                        ?></span>
489 489
                                 </td>
490 490
                             </tr>
491 491
 
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
                                     <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
527 527
                                     <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/>
528 528
                                     <span><?php
529
-										echo wp_sprintf(
530
-											__( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
531
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
532
-											' <i class="fas fa-external-link-alt"></i></a>',
533
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
534
-											' <i class="fas fa-external-link-alt"></i></a>'
535
-										);
536
-										?></span>
529
+                                        echo wp_sprintf(
530
+                                            __( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
531
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
532
+                                            ' <i class="fas fa-external-link-alt"></i></a>',
533
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
534
+                                            ' <i class="fas fa-external-link-alt"></i></a>'
535
+                                        );
536
+                                        ?></span>
537 537
                                 </td>
538 538
                             </tr>
539 539
 
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
                         </table>
588 588
                         <div class="fas-buttons">
589 589
 							<?php
590
-							submit_button();
591
-							?>
590
+                            submit_button();
591
+                            ?>
592 592
                             <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 24,000+ more icons with Font Awesome Pro','ayecode-connect'); ?> <i class="fas fa-external-link-alt"></i></a></p>
593 593
 
594 594
                         </div>
@@ -597,414 +597,414 @@  discard block
 block discarded – undo
597 597
                     <div id="wpfas-version"><?php echo wp_sprintf(__( 'Version: %s (affiliate links provided)', 'ayecode-connect' ), $this->version ); ?></div>
598 598
                 </div>
599 599
 				<?php
600
-			}
601
-		}
602
-
603
-		/**
604
-		 * Check a version number is valid and if so return it or else return an empty string.
605
-		 *
606
-		 * @param $version string The version number to check.
607
-		 *
608
-		 * @since 1.0.6
609
-		 *
610
-		 * @return string Either a valid version number or an empty string.
611
-		 */
612
-		public function validate_version_number( $version ) {
613
-
614
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
615
-				// valid
616
-			} else {
617
-				$version = '';// not validated
618
-			}
619
-
620
-			return $version;
621
-		}
622
-
623
-
624
-		/**
625
-		 * Get the latest version of Font Awesome.
626
-		 *
627
-		 * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
628
-		 *
629
-		 * @since 1.0.7
630
-		 * @return mixed|string The latest version number found.
631
-		 */
632
-		public function get_latest_version( $force_api = false ) {
633
-			$latest_version = $this->latest;
634
-
635
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
636
-
637
-			if ( $cache === false || $force_api ) { // its not set
638
-				$api_ver = $this->get_latest_version_from_api();
639
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
640
-					$latest_version = $api_ver;
641
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
642
-				}
643
-			} elseif ( $this->validate_version_number( $cache ) ) {
644
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
645
-					$latest_version = $cache;
646
-				}
647
-			}
648
-
649
-			// Check and auto download fonts locally.
650
-			if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) {
651
-				if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
652
-					$this->download_package( $latest_version );
653
-				}
654
-			}
655
-
656
-			return $latest_version;
657
-		}
658
-
659
-		/**
660
-		 * Get the latest Font Awesome version from the github API.
661
-		 *
662
-		 * @since 1.0.7
663
-		 * @return string The latest version number or `0` on API fail.
664
-		 */
665
-		public function get_latest_version_from_api() {
666
-			$version  = "0";
667
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
668
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
669
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
670
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
671
-					$version = $api_response['tag_name'];
672
-				}
673
-			}
674
-
675
-			return $version;
676
-		}
677
-
678
-		/**
679
-		 * Inline CSS for RTL language support.
680
-		 *
681
-		 * @since 1.0.13
682
-		 * @return string Inline CSS.
683
-		 */
684
-		public function rtl_inline_css() {
685
-			$inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
686
-
687
-			return $inline_css;
688
-		}
689
-
690
-		/**
691
-		 * Show any warnings as an admin notice.
692
-		 *
693
-		 * @return void
694
-		 */
695
-		public function admin_notices() {
696
-			$settings = $this->settings;
697
-
698
-			if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
699
-				if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
700
-					?>
600
+            }
601
+        }
602
+
603
+        /**
604
+         * Check a version number is valid and if so return it or else return an empty string.
605
+         *
606
+         * @param $version string The version number to check.
607
+         *
608
+         * @since 1.0.6
609
+         *
610
+         * @return string Either a valid version number or an empty string.
611
+         */
612
+        public function validate_version_number( $version ) {
613
+
614
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
615
+                // valid
616
+            } else {
617
+                $version = '';// not validated
618
+            }
619
+
620
+            return $version;
621
+        }
622
+
623
+
624
+        /**
625
+         * Get the latest version of Font Awesome.
626
+         *
627
+         * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
628
+         *
629
+         * @since 1.0.7
630
+         * @return mixed|string The latest version number found.
631
+         */
632
+        public function get_latest_version( $force_api = false ) {
633
+            $latest_version = $this->latest;
634
+
635
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
636
+
637
+            if ( $cache === false || $force_api ) { // its not set
638
+                $api_ver = $this->get_latest_version_from_api();
639
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
640
+                    $latest_version = $api_ver;
641
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
642
+                }
643
+            } elseif ( $this->validate_version_number( $cache ) ) {
644
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
645
+                    $latest_version = $cache;
646
+                }
647
+            }
648
+
649
+            // Check and auto download fonts locally.
650
+            if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) {
651
+                if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
652
+                    $this->download_package( $latest_version );
653
+                }
654
+            }
655
+
656
+            return $latest_version;
657
+        }
658
+
659
+        /**
660
+         * Get the latest Font Awesome version from the github API.
661
+         *
662
+         * @since 1.0.7
663
+         * @return string The latest version number or `0` on API fail.
664
+         */
665
+        public function get_latest_version_from_api() {
666
+            $version  = "0";
667
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
668
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
669
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
670
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
671
+                    $version = $api_response['tag_name'];
672
+                }
673
+            }
674
+
675
+            return $version;
676
+        }
677
+
678
+        /**
679
+         * Inline CSS for RTL language support.
680
+         *
681
+         * @since 1.0.13
682
+         * @return string Inline CSS.
683
+         */
684
+        public function rtl_inline_css() {
685
+            $inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
686
+
687
+            return $inline_css;
688
+        }
689
+
690
+        /**
691
+         * Show any warnings as an admin notice.
692
+         *
693
+         * @return void
694
+         */
695
+        public function admin_notices() {
696
+            $settings = $this->settings;
697
+
698
+            if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
699
+                if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
700
+                    ?>
701 701
                     <div class="notice  notice-error is-dismissible">
702 702
                         <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect' ); ?></p>
703 703
                     </div>
704 704
 					<?php
705
-				}
706
-			} else {
707
-				if ( ! empty( $settings ) ) {
708
-					if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
709
-						$link = admin_url('options-general.php?page=wp-font-awesome-settings');
710
-						?>
705
+                }
706
+            } else {
707
+                if ( ! empty( $settings ) ) {
708
+                    if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
709
+                        $link = admin_url('options-general.php?page=wp-font-awesome-settings');
710
+                        ?>
711 711
                         <div class="notice  notice-error is-dismissible">
712 712
                             <p><?php echo wp_sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'ayecode-connect' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p>
713 713
                         </div>
714 714
 						<?php
715
-					}
716
-				}
717
-			}
718
-		}
719
-
720
-		/**
721
-		 * Handle fontawesome add settings to download fontawesome to store locally.
722
-		 *
723
-		 * @since 1.1.1
724
-		 *
725
-		 * @param string $option The option name.
726
-		 * @param mixed  $value  The option value.
727
-		 */
728
-		public function add_option_wp_font_awesome_settings( $option, $value ) {
729
-			// Do nothing if WordPress is being installed.
730
-			if ( wp_installing() ) {
731
-				return;
732
-			}
733
-
734
-			if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
735
-				$version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
736
-
737
-				if ( ! empty( $version ) ) {
738
-					$response = $this->download_package( $version, $value );
739
-
740
-					if ( is_wp_error( $response ) ) {
741
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
742
-					}
743
-				}
744
-			}
745
-		}
746
-
747
-		/**
748
-		 * Handle fontawesome update settings to download fontawesome to store locally.
749
-		 *
750
-		 * @since 1.1.0
751
-		 *
752
-		 * @param mixed $old_value The old option value.
753
-		 * @param mixed $value     The new option value.
754
-		 */
755
-		public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
756
-			// Do nothing if WordPress is being installed.
757
-			if ( wp_installing() ) {
758
-				return;
759
-			}
760
-
761
-			if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
762
-				// Old values
763
-				$old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
764
-				$old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
765
-
766
-				// New values
767
-				$new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
768
-
769
-				if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
770
-					$response = $this->download_package( $new_version, $new_value );
771
-
772
-					if ( is_wp_error( $response ) ) {
773
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
774
-					}
775
-				}
776
-			}
777
-		}
778
-
779
-		/**
780
-		 * Get the fonts directory local path.
781
-		 *
782
-		 * @since 1.1.0
783
-		 *
784
-		 * @param string Fonts directory local path.
785
-		 */
786
-		public function get_fonts_dir() {
787
-			$upload_dir = wp_upload_dir( null, false );
788
-
789
-			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
790
-		}
791
-
792
-		/**
793
-		 * Get the fonts directory local url.
794
-		 *
795
-		 * @since 1.1.0
796
-		 *
797
-		 * @param string Fonts directory local url.
798
-		 */
799
-		public function get_fonts_url() {
800
-			$upload_dir = wp_upload_dir( null, false );
801
-
802
-			return $upload_dir['baseurl'] .  '/ayefonts/fa/';
803
-		}
804
-
805
-		/**
806
-		 * Check whether load locally active.
807
-		 *
808
-		 * @since 1.1.0
809
-		 *
810
-		 * @return bool True if active else false.
811
-		 */
812
-		public function has_local() {
813
-			if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
814
-				return true;
815
-			}
816
-
817
-			return false;
818
-		}
819
-
820
-		/**
821
-		 * Get the WP Filesystem access.
822
-		 *
823
-		 * @since 1.1.0
824
-		 *
825
-		 * @return object The WP Filesystem.
826
-		 */
827
-		public function get_wp_filesystem() {
828
-			if ( ! function_exists( 'get_filesystem_method' ) ) {
829
-				require_once( ABSPATH . "/wp-admin/includes/file.php" );
830
-			}
831
-
832
-			$access_type = get_filesystem_method();
833
-
834
-			if ( $access_type === 'direct' ) {
835
-				/* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
836
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
837
-
838
-				/* Initialize the API */
839
-				if ( ! WP_Filesystem( $creds ) ) {
840
-					/* Any problems and we exit */
841
-					return false;
842
-				}
843
-
844
-				global $wp_filesystem;
845
-
846
-				return $wp_filesystem;
847
-				/* Do our file manipulations below */
848
-			} else if ( defined( 'FTP_USER' ) ) {
849
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
850
-
851
-				/* Initialize the API */
852
-				if ( ! WP_Filesystem( $creds ) ) {
853
-					/* Any problems and we exit */
854
-					return false;
855
-				}
856
-
857
-				global $wp_filesystem;
858
-
859
-				return $wp_filesystem;
860
-			} else {
861
-				/* Don't have direct write access. Prompt user with our notice */
862
-				return false;
863
-			}
864
-		}
865
-
866
-		/**
867
-		 * Download the fontawesome package file.
868
-		 *
869
-		 * @since 1.1.0
870
-		 *
871
-		 * @param mixed $version The font awesome.
872
-		 * @param array $option Fontawesome settings.
873
-		 * @return WP_ERROR|bool Error on fail and true on success.
874
-		 */
875
-		public function download_package( $version, $option = array() ) {
876
-			$filename = 'fontawesome-free-' . $version . '-web';
877
-			$url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
878
-
879
-			if ( ! function_exists( 'wp_handle_upload' ) ) {
880
-				require_once ABSPATH . 'wp-admin/includes/file.php';
881
-			}
882
-
883
-			$download_file = download_url( esc_url_raw( $url ) );
884
-
885
-			if ( is_wp_error( $download_file ) ) {
886
-				return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
887
-			} else if ( empty( $download_file ) ) {
888
-				return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
889
-			}
890
-
891
-			$response = $this->extract_package( $download_file, $filename, true );
892
-
893
-			// Update local version.
894
-			if ( is_wp_error( $response ) ) {
895
-				return $response;
896
-			} else if ( $response ) {
897
-				if ( empty( $option ) ) {
898
-					$option = get_option( 'wp-font-awesome-settings' );
899
-				}
900
-
901
-				$option['local_version'] = $version;
902
-
903
-				// Remove action to prevent looping.
904
-				remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
905
-
906
-				update_option( 'wp-font-awesome-settings', $option );
907
-
908
-				return true;
909
-			}
910
-
911
-			return false;
912
-		}
913
-
914
-		/**
915
-		 * Extract the fontawesome package file.
916
-		 *
917
-		 * @since 1.1.0
918
-		 *
919
-		 * @param string $package The package file path.
920
-		 * @param string $dirname Package file name.
921
-		 * @param bool   $delete_package Delete temp file or not.
922
-		 * @return WP_Error|bool True on success WP_Error on fail.
923
-		 */
924
-		public function extract_package( $package, $dirname = '', $delete_package = false ) {
925
-			global $wp_filesystem;
926
-
927
-			$wp_filesystem = $this->get_wp_filesystem();
928
-
929
-			if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
930
-				return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
931
-			} else if ( empty( $wp_filesystem ) ) {
932
-				return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
933
-			}
934
-
935
-			$fonts_dir = $this->get_fonts_dir();
936
-			$fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
937
-
938
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
939
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
940
-			}
941
-
942
-			// Unzip package to working directory.
943
-			$result = unzip_file( $package, $fonts_tmp_dir );
944
-
945
-			if ( is_wp_error( $result ) ) {
946
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
947
-
948
-				if ( 'incompatible_archive' === $result->get_error_code() ) {
949
-					return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
950
-				}
951
-
952
-				return $result;
953
-			}
954
-
955
-			if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
956
-				$wp_filesystem->delete( $fonts_dir, true );
957
-			}
958
-
959
-			$extract_dir = $fonts_tmp_dir;
960
-
961
-			if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
962
-				$extract_dir .= $dirname . DIRECTORY_SEPARATOR;
963
-			}
964
-
965
-			try {
966
-				$return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
967
-			} catch ( Exception $e ) {
968
-				$return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
969
-			}
970
-
971
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
972
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
973
-			}
974
-
975
-			// Once extracted, delete the package if required.
976
-			if ( $delete_package ) {
977
-				unlink( $package );
978
-			}
979
-
980
-			return $return;
981
-		}
982
-
983
-		/**
984
-		 * Output the version in the header.
985
-		 */
986
-		public function add_generator() {
987
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
988
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
989
-
990
-			// Find source plugin/theme.
991
-			$source = array();
992
-			if ( strpos( $file, $plugins_dir ) !== false ) {
993
-				$source = explode( "/", plugin_basename( $file ) );
994
-			} else if ( function_exists( 'get_theme_root' ) ) {
995
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
996
-
997
-				if ( strpos( $file, $themes_dir ) !== false ) {
998
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
999
-				}
1000
-			}
1001
-
1002
-			echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1003
-		}
1004
-	}
1005
-
1006
-	/**
1007
-	 * Run the class if found.
1008
-	 */
1009
-	WP_Font_Awesome_Settings::instance();
715
+                    }
716
+                }
717
+            }
718
+        }
719
+
720
+        /**
721
+         * Handle fontawesome add settings to download fontawesome to store locally.
722
+         *
723
+         * @since 1.1.1
724
+         *
725
+         * @param string $option The option name.
726
+         * @param mixed  $value  The option value.
727
+         */
728
+        public function add_option_wp_font_awesome_settings( $option, $value ) {
729
+            // Do nothing if WordPress is being installed.
730
+            if ( wp_installing() ) {
731
+                return;
732
+            }
733
+
734
+            if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
735
+                $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
736
+
737
+                if ( ! empty( $version ) ) {
738
+                    $response = $this->download_package( $version, $value );
739
+
740
+                    if ( is_wp_error( $response ) ) {
741
+                        add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
742
+                    }
743
+                }
744
+            }
745
+        }
746
+
747
+        /**
748
+         * Handle fontawesome update settings to download fontawesome to store locally.
749
+         *
750
+         * @since 1.1.0
751
+         *
752
+         * @param mixed $old_value The old option value.
753
+         * @param mixed $value     The new option value.
754
+         */
755
+        public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
756
+            // Do nothing if WordPress is being installed.
757
+            if ( wp_installing() ) {
758
+                return;
759
+            }
760
+
761
+            if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
762
+                // Old values
763
+                $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
764
+                $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
765
+
766
+                // New values
767
+                $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
768
+
769
+                if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
770
+                    $response = $this->download_package( $new_version, $new_value );
771
+
772
+                    if ( is_wp_error( $response ) ) {
773
+                        add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
774
+                    }
775
+                }
776
+            }
777
+        }
778
+
779
+        /**
780
+         * Get the fonts directory local path.
781
+         *
782
+         * @since 1.1.0
783
+         *
784
+         * @param string Fonts directory local path.
785
+         */
786
+        public function get_fonts_dir() {
787
+            $upload_dir = wp_upload_dir( null, false );
788
+
789
+            return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
790
+        }
791
+
792
+        /**
793
+         * Get the fonts directory local url.
794
+         *
795
+         * @since 1.1.0
796
+         *
797
+         * @param string Fonts directory local url.
798
+         */
799
+        public function get_fonts_url() {
800
+            $upload_dir = wp_upload_dir( null, false );
801
+
802
+            return $upload_dir['baseurl'] .  '/ayefonts/fa/';
803
+        }
804
+
805
+        /**
806
+         * Check whether load locally active.
807
+         *
808
+         * @since 1.1.0
809
+         *
810
+         * @return bool True if active else false.
811
+         */
812
+        public function has_local() {
813
+            if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
814
+                return true;
815
+            }
816
+
817
+            return false;
818
+        }
819
+
820
+        /**
821
+         * Get the WP Filesystem access.
822
+         *
823
+         * @since 1.1.0
824
+         *
825
+         * @return object The WP Filesystem.
826
+         */
827
+        public function get_wp_filesystem() {
828
+            if ( ! function_exists( 'get_filesystem_method' ) ) {
829
+                require_once( ABSPATH . "/wp-admin/includes/file.php" );
830
+            }
831
+
832
+            $access_type = get_filesystem_method();
833
+
834
+            if ( $access_type === 'direct' ) {
835
+                /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
836
+                $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
837
+
838
+                /* Initialize the API */
839
+                if ( ! WP_Filesystem( $creds ) ) {
840
+                    /* Any problems and we exit */
841
+                    return false;
842
+                }
843
+
844
+                global $wp_filesystem;
845
+
846
+                return $wp_filesystem;
847
+                /* Do our file manipulations below */
848
+            } else if ( defined( 'FTP_USER' ) ) {
849
+                $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
850
+
851
+                /* Initialize the API */
852
+                if ( ! WP_Filesystem( $creds ) ) {
853
+                    /* Any problems and we exit */
854
+                    return false;
855
+                }
856
+
857
+                global $wp_filesystem;
858
+
859
+                return $wp_filesystem;
860
+            } else {
861
+                /* Don't have direct write access. Prompt user with our notice */
862
+                return false;
863
+            }
864
+        }
865
+
866
+        /**
867
+         * Download the fontawesome package file.
868
+         *
869
+         * @since 1.1.0
870
+         *
871
+         * @param mixed $version The font awesome.
872
+         * @param array $option Fontawesome settings.
873
+         * @return WP_ERROR|bool Error on fail and true on success.
874
+         */
875
+        public function download_package( $version, $option = array() ) {
876
+            $filename = 'fontawesome-free-' . $version . '-web';
877
+            $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
878
+
879
+            if ( ! function_exists( 'wp_handle_upload' ) ) {
880
+                require_once ABSPATH . 'wp-admin/includes/file.php';
881
+            }
882
+
883
+            $download_file = download_url( esc_url_raw( $url ) );
884
+
885
+            if ( is_wp_error( $download_file ) ) {
886
+                return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
887
+            } else if ( empty( $download_file ) ) {
888
+                return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
889
+            }
890
+
891
+            $response = $this->extract_package( $download_file, $filename, true );
892
+
893
+            // Update local version.
894
+            if ( is_wp_error( $response ) ) {
895
+                return $response;
896
+            } else if ( $response ) {
897
+                if ( empty( $option ) ) {
898
+                    $option = get_option( 'wp-font-awesome-settings' );
899
+                }
900
+
901
+                $option['local_version'] = $version;
902
+
903
+                // Remove action to prevent looping.
904
+                remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
905
+
906
+                update_option( 'wp-font-awesome-settings', $option );
907
+
908
+                return true;
909
+            }
910
+
911
+            return false;
912
+        }
913
+
914
+        /**
915
+         * Extract the fontawesome package file.
916
+         *
917
+         * @since 1.1.0
918
+         *
919
+         * @param string $package The package file path.
920
+         * @param string $dirname Package file name.
921
+         * @param bool   $delete_package Delete temp file or not.
922
+         * @return WP_Error|bool True on success WP_Error on fail.
923
+         */
924
+        public function extract_package( $package, $dirname = '', $delete_package = false ) {
925
+            global $wp_filesystem;
926
+
927
+            $wp_filesystem = $this->get_wp_filesystem();
928
+
929
+            if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
930
+                return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
931
+            } else if ( empty( $wp_filesystem ) ) {
932
+                return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
933
+            }
934
+
935
+            $fonts_dir = $this->get_fonts_dir();
936
+            $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
937
+
938
+            if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
939
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
940
+            }
941
+
942
+            // Unzip package to working directory.
943
+            $result = unzip_file( $package, $fonts_tmp_dir );
944
+
945
+            if ( is_wp_error( $result ) ) {
946
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
947
+
948
+                if ( 'incompatible_archive' === $result->get_error_code() ) {
949
+                    return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
950
+                }
951
+
952
+                return $result;
953
+            }
954
+
955
+            if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
956
+                $wp_filesystem->delete( $fonts_dir, true );
957
+            }
958
+
959
+            $extract_dir = $fonts_tmp_dir;
960
+
961
+            if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
962
+                $extract_dir .= $dirname . DIRECTORY_SEPARATOR;
963
+            }
964
+
965
+            try {
966
+                $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
967
+            } catch ( Exception $e ) {
968
+                $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
969
+            }
970
+
971
+            if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
972
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
973
+            }
974
+
975
+            // Once extracted, delete the package if required.
976
+            if ( $delete_package ) {
977
+                unlink( $package );
978
+            }
979
+
980
+            return $return;
981
+        }
982
+
983
+        /**
984
+         * Output the version in the header.
985
+         */
986
+        public function add_generator() {
987
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
988
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
989
+
990
+            // Find source plugin/theme.
991
+            $source = array();
992
+            if ( strpos( $file, $plugins_dir ) !== false ) {
993
+                $source = explode( "/", plugin_basename( $file ) );
994
+            } else if ( function_exists( 'get_theme_root' ) ) {
995
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
996
+
997
+                if ( strpos( $file, $themes_dir ) !== false ) {
998
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
999
+                }
1000
+            }
1001
+
1002
+            echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1003
+        }
1004
+    }
1005
+
1006
+    /**
1007
+     * Run the class if found.
1008
+     */
1009
+    WP_Font_Awesome_Settings::instance();
1010 1010
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/wp-deactivation-survey.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -1,99 +1,99 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
8 8
 
9
-	class AyeCode_Deactivation_Survey {
9
+    class AyeCode_Deactivation_Survey {
10 10
 
11
-		/**
12
-		 * AyeCode_Deactivation_Survey instance.
13
-		 *
14
-		 * @access private
15
-		 * @since  1.0.0
16
-		 * @var    AyeCode_Deactivation_Survey There can be only one!
17
-		 */
18
-		private static $instance = null;
11
+        /**
12
+         * AyeCode_Deactivation_Survey instance.
13
+         *
14
+         * @access private
15
+         * @since  1.0.0
16
+         * @var    AyeCode_Deactivation_Survey There can be only one!
17
+         */
18
+        private static $instance = null;
19 19
 
20
-		public static $plugins;
20
+        public static $plugins;
21 21
 
22
-		public $version = "1.0.7";
22
+        public $version = "1.0.7";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
-				self::$instance = new AyeCode_Deactivation_Survey;
27
-				self::$plugins = array();
24
+        public static function instance( $plugin = array() ) {
25
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
+                self::$instance = new AyeCode_Deactivation_Survey;
27
+                self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+                add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
32
-			}
31
+                do_action( 'ayecode_deactivation_survey_loaded' );
32
+            }
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
36
-			}
34
+            if(!empty($plugin)){
35
+                self::$plugins[] = (object)$plugin;
36
+            }
37 37
 
38
-			return self::$instance;
39
-		}
38
+            return self::$instance;
39
+        }
40 40
 
41
-		public function scripts() {
42
-			global $pagenow;
41
+        public function scripts() {
42
+            global $pagenow;
43 43
 
44
-			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
46
-				return;
47
-			}
44
+            // Bail if we are not on the plugins page
45
+            if ( $pagenow != "plugins.php" ) {
46
+                return;
47
+            }
48 48
 
49
-			// Enqueue scripts
50
-			add_thickbox();
51
-			wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
49
+            // Enqueue scripts
50
+            add_thickbox();
51
+            wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
52 52
 
53
-			/*
53
+            /*
54 54
 			 * Localized strings. Strings can be localised by plugins using this class.
55 55
 			 * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review.
56 56
 			 */
57
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
-				'quick_feedback'			=> __( 'Quick Feedback', 'ayecode-connect' ),
59
-				'foreword'					=> __( 'If you would be kind enough, please tell us why you\'re deactivating?', 'ayecode-connect' ),
60
-				'better_plugins_name'		=> __( 'Please tell us which plugin?', 'ayecode-connect' ),
61
-				'please_tell_us'			=> __( 'Please tell us the reason so we can improve the plugin', 'ayecode-connect' ),
62
-				'do_not_attach_email'		=> __( 'Do not send my e-mail address with this feedback', 'ayecode-connect' ),
63
-				'brief_description'			=> __( 'Please give us any feedback that could help us improve', 'ayecode-connect' ),
64
-				'cancel'					=> __( 'Cancel', 'ayecode-connect' ),
65
-				'skip_and_deactivate'		=> __( 'Skip &amp; Deactivate', 'ayecode-connect' ),
66
-				'submit_and_deactivate'		=> __( 'Submit &amp; Deactivate', 'ayecode-connect' ),
67
-				'please_wait'				=> __( 'Please wait', 'ayecode-connect' ),
68
-				'get_support'				=> __( 'Get Support', 'ayecode-connect' ),
69
-				'documentation'				=> __( 'Documentation', 'ayecode-connect' ),
70
-				'thank_you'					=> __( 'Thank you!', 'ayecode-connect' ),
71
-			));
72
-
73
-			// Plugins
74
-			$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
-
76
-			// Reasons
77
-			$defaultReasons = array(
78
-				'suddenly-stopped-working'	=> __( 'The plugin suddenly stopped working', 'ayecode-connect' ),
79
-				'plugin-broke-site'			=> __( 'The plugin broke my site', 'ayecode-connect' ),
80
-				'plugin-setup-difficult'	=> __( 'Too difficult to setup', 'ayecode-connect' ),
81
-				'plugin-design-difficult'	=> __( 'Too difficult to get the design i want', 'ayecode-connect' ),
82
-				'no-longer-needed'			=> __( 'I don\'t need this plugin any more', 'ayecode-connect' ),
83
-				'found-better-plugin'		=> __( 'I found a better plugin', 'ayecode-connect' ),
84
-				'temporary-deactivation'	=> __( 'It\'s a temporary deactivation, I\'m troubleshooting', 'ayecode-connect' ),
85
-				'other'						=> __( 'Other', 'ayecode-connect' ),
86
-			);
87
-
88
-			foreach( $plugins as $plugin ) {
89
-				$plugin->reasons = apply_filters( 'ayecode_deactivation_survey_reasons', $defaultReasons, $plugin );
90
-				$plugin->url = home_url();
91
-				$plugin->activated = 0;
92
-			}
93
-
94
-			// Send plugin data
95
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
96
-		}
97
-	}
57
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
+                'quick_feedback'			=> __( 'Quick Feedback', 'ayecode-connect' ),
59
+                'foreword'					=> __( 'If you would be kind enough, please tell us why you\'re deactivating?', 'ayecode-connect' ),
60
+                'better_plugins_name'		=> __( 'Please tell us which plugin?', 'ayecode-connect' ),
61
+                'please_tell_us'			=> __( 'Please tell us the reason so we can improve the plugin', 'ayecode-connect' ),
62
+                'do_not_attach_email'		=> __( 'Do not send my e-mail address with this feedback', 'ayecode-connect' ),
63
+                'brief_description'			=> __( 'Please give us any feedback that could help us improve', 'ayecode-connect' ),
64
+                'cancel'					=> __( 'Cancel', 'ayecode-connect' ),
65
+                'skip_and_deactivate'		=> __( 'Skip &amp; Deactivate', 'ayecode-connect' ),
66
+                'submit_and_deactivate'		=> __( 'Submit &amp; Deactivate', 'ayecode-connect' ),
67
+                'please_wait'				=> __( 'Please wait', 'ayecode-connect' ),
68
+                'get_support'				=> __( 'Get Support', 'ayecode-connect' ),
69
+                'documentation'				=> __( 'Documentation', 'ayecode-connect' ),
70
+                'thank_you'					=> __( 'Thank you!', 'ayecode-connect' ),
71
+            ));
72
+
73
+            // Plugins
74
+            $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
+
76
+            // Reasons
77
+            $defaultReasons = array(
78
+                'suddenly-stopped-working'	=> __( 'The plugin suddenly stopped working', 'ayecode-connect' ),
79
+                'plugin-broke-site'			=> __( 'The plugin broke my site', 'ayecode-connect' ),
80
+                'plugin-setup-difficult'	=> __( 'Too difficult to setup', 'ayecode-connect' ),
81
+                'plugin-design-difficult'	=> __( 'Too difficult to get the design i want', 'ayecode-connect' ),
82
+                'no-longer-needed'			=> __( 'I don\'t need this plugin any more', 'ayecode-connect' ),
83
+                'found-better-plugin'		=> __( 'I found a better plugin', 'ayecode-connect' ),
84
+                'temporary-deactivation'	=> __( 'It\'s a temporary deactivation, I\'m troubleshooting', 'ayecode-connect' ),
85
+                'other'						=> __( 'Other', 'ayecode-connect' ),
86
+            );
87
+
88
+            foreach( $plugins as $plugin ) {
89
+                $plugin->reasons = apply_filters( 'ayecode_deactivation_survey_reasons', $defaultReasons, $plugin );
90
+                $plugin->url = home_url();
91
+                $plugin->activated = 0;
92
+            }
93
+
94
+            // Send plugin data
95
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
96
+        }
97
+    }
98 98
 
99 99
 }
100 100
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/hello-world.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -3,102 +3,102 @@  discard block
 block discarded – undo
3 3
 class SD_Hello_World extends WP_Super_Duper {
4 4
 
5 5
 
6
-	public $arguments;
7
-
8
-	/**
9
-	 * Sets up the widgets name etc
10
-	 */
11
-	public function __construct() {
12
-
13
-		$options = array(
14
-			'textdomain'     => 'super-duper',
15
-			// textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
-			'block-icon'     => 'fas fa-globe-americas',
17
-			// Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
-			// OR font-awesome 5 class name: fas fa-globe-americas
19
-			'block-category' => 'widgets',
20
-			// the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
21
-			'block-keywords' => "['hello','world']",
22
-			// used in the block search, MAX 3
23
-			'block-output'   => array( // the block visual output elements as an array
24
-				array(
25
-					'element' => 'p',
26
-					'title'   => __( 'Placeholder', 'ayecode-connect' ),
27
-					'class'   => '[%className%]',
28
-					'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
29
-				)
30
-			),
31
-			'block-wrap'    => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all.
32
-			'class_name'     => __CLASS__,
33
-			// The calling class name
34
-			'base_id'        => 'hello_world',
35
-			// this is used as the widget id and the shortcode id.
36
-			'name'           => __( 'Hello World', 'ayecode-connect' ),
37
-			// the name of the widget/block
38
-			'widget_ops'     => array(
39
-				'classname'   => 'hello-world-class',
40
-				// widget class
41
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ),
42
-				// widget description
43
-			),
44
-			'no_wrap'       => true, // This will prevent the widget being wrapped in the containing widget class div.
45
-			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
46
-				'after_text' => array( // this is the input name=''
47
-					'title'       => __( 'Text after hello:', 'ayecode-connect' ),
48
-					// input title
49
-					'desc'        => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ),
50
-					// input description
51
-					'type'        => 'text',
52
-					// the type of input, test, select, checkbox etc.
53
-					'placeholder' => 'World',
54
-					// the input placeholder text.
55
-					'desc_tip'    => true,
56
-					// if the input should show the widget description text as a tooltip.
57
-					'default'     => 'World',
58
-					// the input default value.
59
-					'advanced'    => false
60
-					// not yet implemented
61
-				),
62
-			)
63
-		);
64
-
65
-		parent::__construct( $options );
66
-	}
67
-
68
-
69
-	/**
70
-	 * This is the output function for the widget, shortcode and block (front end).
71
-	 *
72
-	 * @param array $args The arguments values.
73
-	 * @param array $widget_args The widget arguments when used.
74
-	 * @param string $content The shortcode content argument
75
-	 *
76
-	 * @return string
77
-	 */
78
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
79
-
80
-		/**
81
-		 * @var string $after_text
82
-		 * @var string $another_input This is added by filter below.
83
-		 */
84
-		extract( $args, EXTR_SKIP );
85
-
86
-		/*
6
+    public $arguments;
7
+
8
+    /**
9
+     * Sets up the widgets name etc
10
+     */
11
+    public function __construct() {
12
+
13
+        $options = array(
14
+            'textdomain'     => 'super-duper',
15
+            // textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
+            'block-icon'     => 'fas fa-globe-americas',
17
+            // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
+            // OR font-awesome 5 class name: fas fa-globe-americas
19
+            'block-category' => 'widgets',
20
+            // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
21
+            'block-keywords' => "['hello','world']",
22
+            // used in the block search, MAX 3
23
+            'block-output'   => array( // the block visual output elements as an array
24
+                array(
25
+                    'element' => 'p',
26
+                    'title'   => __( 'Placeholder', 'ayecode-connect' ),
27
+                    'class'   => '[%className%]',
28
+                    'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
29
+                )
30
+            ),
31
+            'block-wrap'    => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all.
32
+            'class_name'     => __CLASS__,
33
+            // The calling class name
34
+            'base_id'        => 'hello_world',
35
+            // this is used as the widget id and the shortcode id.
36
+            'name'           => __( 'Hello World', 'ayecode-connect' ),
37
+            // the name of the widget/block
38
+            'widget_ops'     => array(
39
+                'classname'   => 'hello-world-class',
40
+                // widget class
41
+                'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ),
42
+                // widget description
43
+            ),
44
+            'no_wrap'       => true, // This will prevent the widget being wrapped in the containing widget class div.
45
+            'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
46
+                'after_text' => array( // this is the input name=''
47
+                    'title'       => __( 'Text after hello:', 'ayecode-connect' ),
48
+                    // input title
49
+                    'desc'        => __( 'This is the text that will appear after `Hello:`.', 'ayecode-connect' ),
50
+                    // input description
51
+                    'type'        => 'text',
52
+                    // the type of input, test, select, checkbox etc.
53
+                    'placeholder' => 'World',
54
+                    // the input placeholder text.
55
+                    'desc_tip'    => true,
56
+                    // if the input should show the widget description text as a tooltip.
57
+                    'default'     => 'World',
58
+                    // the input default value.
59
+                    'advanced'    => false
60
+                    // not yet implemented
61
+                ),
62
+            )
63
+        );
64
+
65
+        parent::__construct( $options );
66
+    }
67
+
68
+
69
+    /**
70
+     * This is the output function for the widget, shortcode and block (front end).
71
+     *
72
+     * @param array $args The arguments values.
73
+     * @param array $widget_args The widget arguments when used.
74
+     * @param string $content The shortcode content argument
75
+     *
76
+     * @return string
77
+     */
78
+    public function output( $args = array(), $widget_args = array(), $content = '' ) {
79
+
80
+        /**
81
+         * @var string $after_text
82
+         * @var string $another_input This is added by filter below.
83
+         */
84
+        extract( $args, EXTR_SKIP );
85
+
86
+        /*
87 87
 		 * This value is added by filter so might not exist if filter is removed so we check.
88 88
 		 */
89
-		if ( ! isset( $another_input ) ) {
90
-			$another_input = '';
91
-		}
89
+        if ( ! isset( $another_input ) ) {
90
+            $another_input = '';
91
+        }
92 92
 
93
-		return "Hello: " . $after_text . "" . $another_input;
93
+        return "Hello: " . $after_text . "" . $another_input;
94 94
 
95
-	}
95
+    }
96 96
 
97 97
 }
98 98
 
99 99
 // register it.
100 100
 add_action( 'widgets_init', function () {
101
-	register_widget( 'SD_Hello_World' );
101
+    register_widget( 'SD_Hello_World' );
102 102
 } );
103 103
 
104 104
 
@@ -111,26 +111,26 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function _my_extra_arguments( $options ) {
113 113
 
114
-	/*
114
+    /*
115 115
 	 * Add a new input option.
116 116
 	 */
117
-	$options['arguments']['another_input'] = array(
118
-		'name'        => 'another_input', // this is the input name=''
119
-		'title'       => __( 'Another input:', 'ayecode-connect' ), // input title
120
-		'desc'        => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description
121
-		'type'        => 'text', // the type of input, test, select, checkbox etc.
122
-		'placeholder' => 'Placeholder text', // the input placeholder text.
123
-		'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
124
-		'default'     => '', // the input default value.
125
-		'advanced'    => false // not yet implemented
126
-	);
127
-
128
-	/*
117
+    $options['arguments']['another_input'] = array(
118
+        'name'        => 'another_input', // this is the input name=''
119
+        'title'       => __( 'Another input:', 'ayecode-connect' ), // input title
120
+        'desc'        => __( 'This is an input added via filter.', 'ayecode-connect' ), // input description
121
+        'type'        => 'text', // the type of input, test, select, checkbox etc.
122
+        'placeholder' => 'Placeholder text', // the input placeholder text.
123
+        'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
124
+        'default'     => '', // the input default value.
125
+        'advanced'    => false // not yet implemented
126
+    );
127
+
128
+    /*
129 129
 	 * Output the new option in the block output also.
130 130
 	 */
131
-	$options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
131
+    $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
132 132
 
133
-	return $options;
133
+    return $options;
134 134
 }
135 135
 
136 136
 //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' );
137 137
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/map.php 1 patch
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -3,241 +3,241 @@
 block discarded – undo
3 3
 class SD_Map extends WP_Super_Duper {
4 4
 
5 5
 
6
-	public $arguments;
7
-
8
-	/**
9
-	 * Sets up the widgets name etc
10
-	 */
11
-	public function __construct() {
12
-
13
-		$options = array(
14
-			'textdomain'     => 'super-duper',
15
-			// textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
-			'block-icon'     => 'admin-site',
17
-			// Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
-			'block-category' => 'widgets',
19
-			// the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
20
-			'block-keywords' => "['map','super','google']",
21
-			// used in the block search, MAX 3
22
-			'block-output'   => array( // the block visual output elements as an array
23
-				array(
24
-					'element' => 'p',
25
-					'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ', 'ayecode-connect' ),
26
-					//'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"',
27
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
28
-				),
29
-				array(
30
-					'element' => 'a',
31
-					'content' => __('API KEY for Google Maps', 'ayecode-connect' ),
32
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
33
-					'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/',
34
-				),
35
-				array(
36
-					'element' => 'img',
37
-					'class'   => '[%className%]',
38
-					//'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
39
-					'element_require' => '[%type%]=="image"',
40
-					'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]"
41
-				),
42
-				array(
43
-					'element' => 'div',
44
-					'class'   => 'sd-map-iframe-cover',
45
-					'style'   => '{overflow:"hidden", position:"relative"}',
46
-					array(
47
-						'element' => 'iframe',
48
-						'title'   => __( 'Placeholderx', 'ayecode-connect' ),
49
-						'class'   => '[%className%]',
50
-						'width'   => '[%width%]',
51
-						'height'  => '[%height%]',
52
-						'frameborder' => '0',
53
-						'allowfullscreen' => 'true',
54
-						'style' => '{border:0}',
55
-						'element_require' => '[%type%]!="image"',
56
-						'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]"
57
-					),
58
-				),
59
-				array(
60
-					'element' => 'style',
61
-					'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__( 'Click here, Settings are in the block settings sidebar', 'ayecode-connect' ).'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center;  color: #fff; font-size: 20px; font-weight: bold;}',
62
-					'element_require' => '[%type%]!="image"',
63
-				),
64
-			),
65
-			'class_name'     => __CLASS__,
66
-			// The calling class name
67
-			'base_id'        => 'sd_map',
68
-			// this is used as the widget id and the shortcode id.
69
-			'name'           => __( 'Map', 'ayecode-connect' ),
70
-			// the name of the widget/block
71
-			'widget_ops'     => array(
72
-				'classname'   => 'sd-map-class',
73
-				// widget class
74
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ),
75
-				// widget description
76
-			),
77
-			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
78
-				'type'  => array(
79
-					'title' => __('Map Type:', 'ayecode-connect'),
80
-					'desc' => __('Select the map type to use.', 'ayecode-connect'),
81
-					'type' => 'select',
82
-					'options'   =>  array(
83
-						"image" => __('Static Image', 'ayecode-connect'),
84
-						"place" => __('Place', 'ayecode-connect'),
6
+    public $arguments;
7
+
8
+    /**
9
+     * Sets up the widgets name etc
10
+     */
11
+    public function __construct() {
12
+
13
+        $options = array(
14
+            'textdomain'     => 'super-duper',
15
+            // textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
+            'block-icon'     => 'admin-site',
17
+            // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
+            'block-category' => 'widgets',
19
+            // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
20
+            'block-keywords' => "['map','super','google']",
21
+            // used in the block search, MAX 3
22
+            'block-output'   => array( // the block visual output elements as an array
23
+                array(
24
+                    'element' => 'p',
25
+                    'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ', 'ayecode-connect' ),
26
+                    //'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"',
27
+                    'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
28
+                ),
29
+                array(
30
+                    'element' => 'a',
31
+                    'content' => __('API KEY for Google Maps', 'ayecode-connect' ),
32
+                    'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
33
+                    'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/',
34
+                ),
35
+                array(
36
+                    'element' => 'img',
37
+                    'class'   => '[%className%]',
38
+                    //'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
39
+                    'element_require' => '[%type%]=="image"',
40
+                    'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]"
41
+                ),
42
+                array(
43
+                    'element' => 'div',
44
+                    'class'   => 'sd-map-iframe-cover',
45
+                    'style'   => '{overflow:"hidden", position:"relative"}',
46
+                    array(
47
+                        'element' => 'iframe',
48
+                        'title'   => __( 'Placeholderx', 'ayecode-connect' ),
49
+                        'class'   => '[%className%]',
50
+                        'width'   => '[%width%]',
51
+                        'height'  => '[%height%]',
52
+                        'frameborder' => '0',
53
+                        'allowfullscreen' => 'true',
54
+                        'style' => '{border:0}',
55
+                        'element_require' => '[%type%]!="image"',
56
+                        'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]"
57
+                    ),
58
+                ),
59
+                array(
60
+                    'element' => 'style',
61
+                    'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__( 'Click here, Settings are in the block settings sidebar', 'ayecode-connect' ).'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center;  color: #fff; font-size: 20px; font-weight: bold;}',
62
+                    'element_require' => '[%type%]!="image"',
63
+                ),
64
+            ),
65
+            'class_name'     => __CLASS__,
66
+            // The calling class name
67
+            'base_id'        => 'sd_map',
68
+            // this is used as the widget id and the shortcode id.
69
+            'name'           => __( 'Map', 'ayecode-connect' ),
70
+            // the name of the widget/block
71
+            'widget_ops'     => array(
72
+                'classname'   => 'sd-map-class',
73
+                // widget class
74
+                'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'ayecode-connect' ),
75
+                // widget description
76
+            ),
77
+            'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
78
+                'type'  => array(
79
+                    'title' => __('Map Type:', 'ayecode-connect'),
80
+                    'desc' => __('Select the map type to use.', 'ayecode-connect'),
81
+                    'type' => 'select',
82
+                    'options'   =>  array(
83
+                        "image" => __('Static Image', 'ayecode-connect'),
84
+                        "place" => __('Place', 'ayecode-connect'),
85 85
 //						"directions" => __('Directions', 'ayecode-connect'),
86 86
 //						"search" => __('Search', 'ayecode-connect'),
87 87
 //						"view" => __('View', 'ayecode-connect'),
88 88
 //						"streetview" => __('Streetview', 'ayecode-connect'),
89
-					),
90
-					'default'  => 'image',
91
-					'desc_tip' => true,
92
-					'advanced' => false
93
-				),
94
-				'location'            => array(
95
-					'type'        => 'text',
96
-					'title'       => __( 'Location:', 'ayecode-connect' ),
97
-					'desc'        => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'ayecode-connect' ),
98
-					'placeholder' => 'Place, city, zip code or GPS',
99
-					'desc_tip'    => true,
100
-					'default'     => 'Ireland',
101
-					'advanced'    => false
102
-				),
103
-				'static_width'            => array(
104
-					'type'        => 'number',
105
-					'title'       => __( 'Width:', 'ayecode-connect' ),
106
-					'desc'        => __( 'This is the width of the map, for static maps you can only use px values.', 'ayecode-connect' ),
107
-					'placeholder' => '600',
108
-					'desc_tip'    => true,
109
-					'default'     => '600',
110
-					'custom_attributes' => array(
111
-						'max'         => '2000',
112
-						'min'         => '100',
113
-					),
114
-					'element_require' => '[%type%]=="image"',
115
-					'advanced'    => false
116
-				),
117
-				'static_height'           => array(
118
-					'type'        => 'number',
119
-					'title'       => __( 'Height:', 'ayecode-connect' ),
120
-					'desc'        => __( 'This is the height of the map, for static maps you can only use px values.', 'ayecode-connect' ),
121
-					'placeholder' => '400',
122
-					'desc_tip'    => true,
123
-					'default'     => '400',
124
-					'custom_attributes' => array(
125
-						'max'         => '2000',
126
-						'min'         => '100',
127
-						'required'         => 'required',
128
-					),
129
-					'element_require' => '[%type%]=="image"',
130
-					'advanced'    => false
131
-				),
132
-				'width'            => array(
133
-					'type'        => 'text',
134
-					'title'       => __( 'Width:', 'ayecode-connect' ),
135
-					'desc'        => __( 'This is the width of the map, you can use % or px here.', 'ayecode-connect' ),
136
-					'placeholder' => '100%',
137
-					'desc_tip'    => true,
138
-					'default'     => '100%',
139
-					'element_require' => '[%type%]!="image"',
140
-					'advanced'    => false
141
-				),
142
-				'height'           => array(
143
-					'type'        => 'text',
144
-					'title'       => __( 'Height:', 'ayecode-connect' ),
145
-					'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'ayecode-connect' ),
146
-					'placeholder' => '425px',
147
-					'desc_tip'    => true,
148
-					'default'     => '425px',
149
-					'element_require' => '[%type%]!="image"',
150
-					'advanced'    => false
151
-				),
152
-				'maptype'          => array(
153
-					'type'     => 'select',
154
-					'title'    => __( 'Mapview:', 'ayecode-connect' ),
155
-					'desc'     => __( 'This is the type of map view that will be used by default.', 'ayecode-connect' ),
156
-					'options'  => array(
157
-						"roadmap"   => __( 'Road Map', 'ayecode-connect' ),
158
-						"satellite" => __( 'Satellite Map', 'ayecode-connect' ),
89
+                    ),
90
+                    'default'  => 'image',
91
+                    'desc_tip' => true,
92
+                    'advanced' => false
93
+                ),
94
+                'location'            => array(
95
+                    'type'        => 'text',
96
+                    'title'       => __( 'Location:', 'ayecode-connect' ),
97
+                    'desc'        => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'ayecode-connect' ),
98
+                    'placeholder' => 'Place, city, zip code or GPS',
99
+                    'desc_tip'    => true,
100
+                    'default'     => 'Ireland',
101
+                    'advanced'    => false
102
+                ),
103
+                'static_width'            => array(
104
+                    'type'        => 'number',
105
+                    'title'       => __( 'Width:', 'ayecode-connect' ),
106
+                    'desc'        => __( 'This is the width of the map, for static maps you can only use px values.', 'ayecode-connect' ),
107
+                    'placeholder' => '600',
108
+                    'desc_tip'    => true,
109
+                    'default'     => '600',
110
+                    'custom_attributes' => array(
111
+                        'max'         => '2000',
112
+                        'min'         => '100',
113
+                    ),
114
+                    'element_require' => '[%type%]=="image"',
115
+                    'advanced'    => false
116
+                ),
117
+                'static_height'           => array(
118
+                    'type'        => 'number',
119
+                    'title'       => __( 'Height:', 'ayecode-connect' ),
120
+                    'desc'        => __( 'This is the height of the map, for static maps you can only use px values.', 'ayecode-connect' ),
121
+                    'placeholder' => '400',
122
+                    'desc_tip'    => true,
123
+                    'default'     => '400',
124
+                    'custom_attributes' => array(
125
+                        'max'         => '2000',
126
+                        'min'         => '100',
127
+                        'required'         => 'required',
128
+                    ),
129
+                    'element_require' => '[%type%]=="image"',
130
+                    'advanced'    => false
131
+                ),
132
+                'width'            => array(
133
+                    'type'        => 'text',
134
+                    'title'       => __( 'Width:', 'ayecode-connect' ),
135
+                    'desc'        => __( 'This is the width of the map, you can use % or px here.', 'ayecode-connect' ),
136
+                    'placeholder' => '100%',
137
+                    'desc_tip'    => true,
138
+                    'default'     => '100%',
139
+                    'element_require' => '[%type%]!="image"',
140
+                    'advanced'    => false
141
+                ),
142
+                'height'           => array(
143
+                    'type'        => 'text',
144
+                    'title'       => __( 'Height:', 'ayecode-connect' ),
145
+                    'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'ayecode-connect' ),
146
+                    'placeholder' => '425px',
147
+                    'desc_tip'    => true,
148
+                    'default'     => '425px',
149
+                    'element_require' => '[%type%]!="image"',
150
+                    'advanced'    => false
151
+                ),
152
+                'maptype'          => array(
153
+                    'type'     => 'select',
154
+                    'title'    => __( 'Mapview:', 'ayecode-connect' ),
155
+                    'desc'     => __( 'This is the type of map view that will be used by default.', 'ayecode-connect' ),
156
+                    'options'  => array(
157
+                        "roadmap"   => __( 'Road Map', 'ayecode-connect' ),
158
+                        "satellite" => __( 'Satellite Map', 'ayecode-connect' ),
159 159
 //						"hybrid"    => __( 'Hybrid Map', 'ayecode-connect' ),
160 160
 //						"terrain"   => __( 'Terrain Map', 'ayecode-connect' ),
161
-					),
162
-					'desc_tip' => true,
163
-					'default'  => 'roadmap',
164
-					'advanced' => true
165
-				),
166
-				'zoom'             => array(
167
-					'type'        => 'select',
168
-					'title'       => __( 'Zoom level:', 'ayecode-connect' ),
169
-					'desc'        => __( 'This is the zoom level of the map, `auto` is recommended.', 'ayecode-connect' ),
170
-					'options'     => range( 1, 19 ),
171
-					'placeholder' => '',
172
-					'desc_tip'    => true,
173
-					'default'     => '7',
174
-					'advanced'    => true
175
-				),
176
-				'api_key'           => array(
177
-					'type'        => 'text',
178
-					'title'       => __( 'Api Key:', 'ayecode-connect' ),
179
-					'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'ayecode-connect' ),
180
-					'placeholder' => '',
181
-					'desc_tip'    => true,
182
-					'default'     => '',
183
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1',
184
-					'advanced'    => false
185
-				),
186
-			)
187
-		);
188
-
189
-		parent::__construct( $options );
190
-	}
191
-
192
-
193
-	/**
194
-	 * This is the output function for the widget, shortcode and block (front end).
195
-	 *
196
-	 * @param array $args The arguments values.
197
-	 * @param array $widget_args The widget arguments when used.
198
-	 * @param string $content The shortcode content argument
199
-	 *
200
-	 * @return string
201
-	 */
202
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
203
-
204
-		// options
205
-		$defaults = array(
206
-			'type'      => 'image', // image, place
207
-			'location' => 'Ireland',
208
-			'static_width' => '600',
209
-			'static_height' => '400',
210
-			'width'=> '100%',
211
-			'height'=> '425px',
212
-			'maptype'     => 'roadmap',
213
-			'zoom'     => '7',
214
-			'api_key'     => 'AIzaSyBK3ZcmK0ljxl5agNyJNQh_G24Thq1btuE',
215
-		);
216
-
217
-		/**
218
-		 * Parse incoming $args into an array and merge it with $defaults
219
-		 */
220
-		$args = wp_parse_args($args, $defaults );
221
-
222
-		$output = '';
223
-
224
-
225
-		// check if we have a global API key
226
-		$args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key'];
227
-
228
-		if($args['type']=='image'){
229
-			$output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />";
230
-		}else{
231
-			$output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> ";
232
-		}
233
-
234
-		return $output;
235
-
236
-	}
161
+                    ),
162
+                    'desc_tip' => true,
163
+                    'default'  => 'roadmap',
164
+                    'advanced' => true
165
+                ),
166
+                'zoom'             => array(
167
+                    'type'        => 'select',
168
+                    'title'       => __( 'Zoom level:', 'ayecode-connect' ),
169
+                    'desc'        => __( 'This is the zoom level of the map, `auto` is recommended.', 'ayecode-connect' ),
170
+                    'options'     => range( 1, 19 ),
171
+                    'placeholder' => '',
172
+                    'desc_tip'    => true,
173
+                    'default'     => '7',
174
+                    'advanced'    => true
175
+                ),
176
+                'api_key'           => array(
177
+                    'type'        => 'text',
178
+                    'title'       => __( 'Api Key:', 'ayecode-connect' ),
179
+                    'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'ayecode-connect' ),
180
+                    'placeholder' => '',
181
+                    'desc_tip'    => true,
182
+                    'default'     => '',
183
+                    'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1',
184
+                    'advanced'    => false
185
+                ),
186
+            )
187
+        );
188
+
189
+        parent::__construct( $options );
190
+    }
191
+
192
+
193
+    /**
194
+     * This is the output function for the widget, shortcode and block (front end).
195
+     *
196
+     * @param array $args The arguments values.
197
+     * @param array $widget_args The widget arguments when used.
198
+     * @param string $content The shortcode content argument
199
+     *
200
+     * @return string
201
+     */
202
+    public function output( $args = array(), $widget_args = array(), $content = '' ) {
203
+
204
+        // options
205
+        $defaults = array(
206
+            'type'      => 'image', // image, place
207
+            'location' => 'Ireland',
208
+            'static_width' => '600',
209
+            'static_height' => '400',
210
+            'width'=> '100%',
211
+            'height'=> '425px',
212
+            'maptype'     => 'roadmap',
213
+            'zoom'     => '7',
214
+            'api_key'     => 'AIzaSyBK3ZcmK0ljxl5agNyJNQh_G24Thq1btuE',
215
+        );
216
+
217
+        /**
218
+         * Parse incoming $args into an array and merge it with $defaults
219
+         */
220
+        $args = wp_parse_args($args, $defaults );
221
+
222
+        $output = '';
223
+
224
+
225
+        // check if we have a global API key
226
+        $args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key'];
227
+
228
+        if($args['type']=='image'){
229
+            $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />";
230
+        }else{
231
+            $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> ";
232
+        }
233
+
234
+        return $output;
235
+
236
+    }
237 237
 
238 238
 }
239 239
 
240 240
 // register it.
241 241
 add_action( 'widgets_init', function () {
242
-	register_widget( 'SD_Map' );
242
+    register_widget( 'SD_Map' );
243 243
 } );
Please login to merge, or discard this patch.