Passed
Pull Request — master (#781)
by Kiran
04:57
created
templates/invoice/line-totals.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,27 +52,27 @@
 block discarded – undo
52 52
 
53 53
                                 // Total Fee.
54 54
                                 if ( 'fee' === $key ) {
55
-								wpinv_the_price( $invoice->get_total_fees(), $invoice->get_currency() );
55
+                                wpinv_the_price( $invoice->get_total_fees(), $invoice->get_currency() );
56 56
                                 }
57 57
 
58 58
                                 // Total discount.
59 59
                                 if ( 'discount' === $key ) {
60
-								wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() );
60
+                                wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() );
61 61
                                 }
62 62
 
63 63
                                 // Shipping.
64 64
                                 if ( 'shipping' === $key ) {
65
-								wpinv_the_price( $invoice->get_shipping(), $invoice->get_currency() );
65
+                                wpinv_the_price( $invoice->get_shipping(), $invoice->get_currency() );
66 66
                                 }
67 67
 
68 68
                                 // Sub total.
69 69
                                 if ( 'subtotal' === $key ) {
70
-								wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() );
70
+                                wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() );
71 71
                                 }
72 72
 
73 73
                                 // Total.
74 74
                                 if ( 'total' === $key ) {
75
-								wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );
75
+                                wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );
76 76
                                 }
77 77
 
78 78
                                 // Fires when printing a cart total.
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -9,26 +9,26 @@  discard block
 block discarded – undo
9 9
  * @var WPInv_Invoice $invoice
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 // Totals rows.
15
-$totals = getpaid_invoice_totals_rows( $invoice );
15
+$totals = getpaid_invoice_totals_rows($invoice);
16 16
 
17
-do_action( 'getpaid_before_invoice_line_totals', $invoice, $totals );
17
+do_action('getpaid_before_invoice_line_totals', $invoice, $totals);
18 18
 
19 19
 ?>
20 20
 <div class='getpaid-invoice-line-totals'>
21 21
     <div class="row">
22 22
         <div class="col-12 offset-sm-6 col-sm-6 border-sm-left pl-sm-0">
23 23
 
24
-            <?php foreach ( $totals as $key => $label ) : ?>
24
+            <?php foreach ($totals as $key => $label) : ?>
25 25
 
26
-                <div class="getpaid-invoice-line-totals-col <?php echo esc_attr( $key ); ?>">
26
+                <div class="getpaid-invoice-line-totals-col <?php echo esc_attr($key); ?>">
27 27
 
28 28
                     <div class="form-row row">
29 29
 
30 30
                         <div class="col-8 getpaid-invoice-line-totals-label">
31
-                            <?php echo esc_html( $label ); ?>
31
+                            <?php echo esc_html($label); ?>
32 32
                         </div>
33 33
 
34 34
                         <div class="col-4 getpaid-invoice-line-totals-value pl-0">
@@ -36,62 +36,62 @@  discard block
 block discarded – undo
36 36
                             <?php
37 37
 
38 38
                                 // Total tax.
39
-                                if ( 'tax' === $key ) {
40
-                                    wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() );
39
+                                if ('tax' === $key) {
40
+                                    wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency());
41 41
 
42
-                                    if ( wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) {
42
+                                    if (wpinv_use_taxes() && !$invoice->get_disable_taxes()) {
43 43
 
44 44
                                         $taxes = $invoice->get_total_tax();
45
-                                        if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) {
45
+                                        if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) {
46 46
                                             echo ' <em class="text-muted small">';
47
-                                            _x( '(Reverse charged)', 'This is a legal term for reverse charging tax in the EU', 'invoicing' );
47
+                                            _x('(Reverse charged)', 'This is a legal term for reverse charging tax in the EU', 'invoicing');
48 48
                                             echo '</em>';
49 49
                                         }
50 50
                                     }
51 51
                                 }
52 52
 
53 53
                                 // Check if field starts with tax__.
54
-                                if ( 0 === strpos( $key, 'tax__' ) ) {
55
-                                    $tax_amount = $invoice->get_tax_total_by_name( str_replace( 'tax__', '', $key ) );
56
-                                    wpinv_the_price( $tax_amount, $invoice->get_currency() );
54
+                                if (0 === strpos($key, 'tax__')) {
55
+                                    $tax_amount = $invoice->get_tax_total_by_name(str_replace('tax__', '', $key));
56
+                                    wpinv_the_price($tax_amount, $invoice->get_currency());
57 57
 
58
-                                    if ( wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) {
58
+                                    if (wpinv_use_taxes() && !$invoice->get_disable_taxes()) {
59 59
 
60
-                                        if ( empty( $tax_amount ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) {
60
+                                        if (empty($tax_amount) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) {
61 61
                                             echo ' <em class="text-muted small">';
62
-                                            _x( '(Reverse charged)', 'This is a legal term for reverse charging tax in the EU', 'invoicing' );
62
+                                            _x('(Reverse charged)', 'This is a legal term for reverse charging tax in the EU', 'invoicing');
63 63
                                             echo '</em>';
64 64
                                         }
65 65
                                     }
66 66
                                 }
67 67
 
68 68
                                 // Total Fee.
69
-                                if ( 'fee' === $key ) {
70
-								wpinv_the_price( $invoice->get_total_fees(), $invoice->get_currency() );
69
+                                if ('fee' === $key) {
70
+								wpinv_the_price($invoice->get_total_fees(), $invoice->get_currency());
71 71
                                 }
72 72
 
73 73
                                 // Total discount.
74
-                                if ( 'discount' === $key ) {
75
-								wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() );
74
+                                if ('discount' === $key) {
75
+								wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency());
76 76
                                 }
77 77
 
78 78
                                 // Shipping.
79
-                                if ( 'shipping' === $key ) {
80
-								wpinv_the_price( $invoice->get_shipping(), $invoice->get_currency() );
79
+                                if ('shipping' === $key) {
80
+								wpinv_the_price($invoice->get_shipping(), $invoice->get_currency());
81 81
                                 }
82 82
 
83 83
                                 // Sub total.
84
-                                if ( 'subtotal' === $key ) {
85
-								wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() );
84
+                                if ('subtotal' === $key) {
85
+								wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency());
86 86
                                 }
87 87
 
88 88
                                 // Total.
89
-                                if ( 'total' === $key ) {
90
-								wpinv_the_price( $invoice->get_total(), $invoice->get_currency() );
89
+                                if ('total' === $key) {
90
+								wpinv_the_price($invoice->get_total(), $invoice->get_currency());
91 91
                                 }
92 92
 
93 93
                                 // Fires when printing a cart total.
94
-                                do_action( "getpaid_invoice_cart_totals_$key", $invoice );
94
+                                do_action("getpaid_invoice_cart_totals_$key", $invoice);
95 95
 
96 96
                             ?>
97 97
 
@@ -105,4 +105,4 @@  discard block
 block discarded – undo
105 105
     </div>
106 106
 </div> <!-- end .getpaid-invoice-line-totals -->
107 107
 
108
-<?php do_action( 'getpaid_after_invoice_line_totals', $invoice, $totals ); ?>
108
+<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?>
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-helper.php 2 patches
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -12,294 +12,294 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports_Helper {
14 14
 
15
-	/**
16
-	 * Get report totals such as invoice totals and discount amounts.
17
-	 *
18
-	 * Data example:
19
-	 *
20
-	 * 'subtotal' => array(
21
-	 *     'type'     => 'invoice_data',
22
-	 *     'function' => 'SUM',
23
-	 *     'name'     => 'subtotal'
24
-	 * )
25
-	 *
26
-	 * @param  array $args
27
-	 * @return mixed depending on query_type
28
-	 */
29
-	public static function get_invoice_report_data( $args = array() ) {
30
-		global $wpdb;
31
-
32
-		$default_args = array(
33
-			'data'                  => array(), // The data to retrieve.
34
-			'where'                 => array(), // An array of where queries.
35
-			'query_type'            => 'get_row', // wpdb query to run.
36
-			'group_by'              => '', // What to group results by.
37
-			'order_by'              => '', // What to order by.
38
-			'limit'                 => '', // Results limit.
39
-			'filter_range'          => array(), // An array of before and after dates to limit results by.
40
-			'invoice_types'         => array( 'wpi_invoice' ), // An array of post types to retrieve.
41
-			'invoice_status'        => array( 'publish', 'wpi-processing', 'wpi-onhold' ),
42
-			'parent_invoice_status' => false, // Optionally filter by parent invoice status.
43
-		);
44
-
45
-		$args         = apply_filters( 'getpaid_reports_get_invoice_report_data_args', $args );
46
-		$args         = wp_parse_args( $args, $default_args );
47
-
48
-		extract( $args );
49
-
50
-		if ( empty( $data ) ) {
51
-			return '';
52
-		}
53
-
54
-		$query           = array();
55
-		$query['select'] = 'SELECT ' . implode( ',', self::prepare_invoice_data( $data ) );
56
-		$query['from']   = "FROM {$wpdb->posts} AS posts";
57
-		$query['join']   = implode( ' ', self::prepare_invoice_joins( $data + $where, ! empty( $parent_invoice_status ) ) );
58
-
59
-		$query['where']  = "
15
+    /**
16
+     * Get report totals such as invoice totals and discount amounts.
17
+     *
18
+     * Data example:
19
+     *
20
+     * 'subtotal' => array(
21
+     *     'type'     => 'invoice_data',
22
+     *     'function' => 'SUM',
23
+     *     'name'     => 'subtotal'
24
+     * )
25
+     *
26
+     * @param  array $args
27
+     * @return mixed depending on query_type
28
+     */
29
+    public static function get_invoice_report_data( $args = array() ) {
30
+        global $wpdb;
31
+
32
+        $default_args = array(
33
+            'data'                  => array(), // The data to retrieve.
34
+            'where'                 => array(), // An array of where queries.
35
+            'query_type'            => 'get_row', // wpdb query to run.
36
+            'group_by'              => '', // What to group results by.
37
+            'order_by'              => '', // What to order by.
38
+            'limit'                 => '', // Results limit.
39
+            'filter_range'          => array(), // An array of before and after dates to limit results by.
40
+            'invoice_types'         => array( 'wpi_invoice' ), // An array of post types to retrieve.
41
+            'invoice_status'        => array( 'publish', 'wpi-processing', 'wpi-onhold' ),
42
+            'parent_invoice_status' => false, // Optionally filter by parent invoice status.
43
+        );
44
+
45
+        $args         = apply_filters( 'getpaid_reports_get_invoice_report_data_args', $args );
46
+        $args         = wp_parse_args( $args, $default_args );
47
+
48
+        extract( $args );
49
+
50
+        if ( empty( $data ) ) {
51
+            return '';
52
+        }
53
+
54
+        $query           = array();
55
+        $query['select'] = 'SELECT ' . implode( ',', self::prepare_invoice_data( $data ) );
56
+        $query['from']   = "FROM {$wpdb->posts} AS posts";
57
+        $query['join']   = implode( ' ', self::prepare_invoice_joins( $data + $where, ! empty( $parent_invoice_status ) ) );
58
+
59
+        $query['where']  = "
60 60
 			WHERE 	posts.post_type 	IN ( '" . implode( "','", $invoice_types ) . "' )
61 61
 			";
62 62
 
63
-		if ( ! empty( $invoice_status ) ) {
64
-			$query['where'] .= "
63
+        if ( ! empty( $invoice_status ) ) {
64
+            $query['where'] .= "
65 65
 				AND 	posts.post_status 	IN ( '" . implode( "','", $invoice_status ) . "' )
66 66
 			";
67
-		}
68
-
69
-		if ( ! empty( $parent_invoice_status ) ) {
70
-			if ( ! empty( $invoice_status ) ) {
71
-				$query['where'] .= " AND ( parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) OR parent.ID IS NULL ) ";
72
-			} else {
73
-				$query['where'] .= " AND parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) ";
74
-			}
75
-		}
76
-
77
-		if ( ! empty( $filter_range['before'] ) ) {
78
-			$query['where'] .= "
67
+        }
68
+
69
+        if ( ! empty( $parent_invoice_status ) ) {
70
+            if ( ! empty( $invoice_status ) ) {
71
+                $query['where'] .= " AND ( parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) OR parent.ID IS NULL ) ";
72
+            } else {
73
+                $query['where'] .= " AND parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) ";
74
+            }
75
+        }
76
+
77
+        if ( ! empty( $filter_range['before'] ) ) {
78
+            $query['where'] .= "
79 79
 				AND 	posts.post_date <= '" . gmdate( 'Y-m-d 23:59:59', strtotime( $filter_range['before'] ) ) . "'
80 80
 			";
81
-		}
81
+        }
82 82
 
83
-		if ( ! empty( $filter_range['after'] ) ) {
84
-			$query['where'] .= "
83
+        if ( ! empty( $filter_range['after'] ) ) {
84
+            $query['where'] .= "
85 85
 				AND 	posts.post_date >= '" . gmdate( 'Y-m-d 00:00:00', strtotime( $filter_range['after'] ) ) . "'
86 86
 			";
87
-		}
87
+        }
88 88
 
89
-		if ( ! empty( $where ) ) {
89
+        if ( ! empty( $where ) ) {
90 90
 
91
-			foreach ( $where as $value ) {
91
+            foreach ( $where as $value ) {
92 92
 
93
-				if ( strtolower( $value['operator'] ) === 'in' || strtolower( $value['operator'] ) === 'not in' ) {
94
-
95
-					if ( is_array( $value['value'] ) ) {
96
-						$value['value'] = implode( "','", $value['value'] );
97
-					}
98
-
99
-					if ( ! empty( $value['value'] ) ) {
100
-						$where_value = "{$value['operator']} ('{$value['value']}')";
101
-					}
102
-				} else {
103
-					$where_value = "{$value['operator']} '{$value['value']}'";
104
-				}
105
-
106
-				if ( ! empty( $where_value ) ) {
107
-					$query['where'] .= " AND {$value['key']} {$where_value}";
108
-				}
109
-			}
110
-		}
111
-
112
-		if ( $group_by ) {
113
-			$query['group_by'] = "GROUP BY {$group_by}";
114
-		}
115
-
116
-		if ( $order_by ) {
117
-			$query['order_by'] = "ORDER BY {$order_by}";
118
-		}
119
-
120
-		if ( $limit ) {
121
-			$query['limit'] = "LIMIT {$limit}";
122
-		}
123
-
124
-		$query = apply_filters( 'getpaid_reports_get_invoice_report_query', $query, $data );
125
-		$query = implode( ' ', $query );
126
-
127
-		return self::execute( $query_type, $query );
128
-
129
-	}
130
-
131
-	/**
132
-	 * Prepares the data to select.
133
-	 *
134
-	 *
135
-	 * @param  array $data
136
-	 * @return array
137
-	 */
138
-	public static function prepare_invoice_data( $data ) {
139
-
140
-		$prepared = array();
141
-
142
-		foreach ( $data as $raw_key => $value ) {
143
-			$key      = sanitize_key( $raw_key );
144
-			$distinct = '';
145
-
146
-			if ( isset( $value['distinct'] ) ) {
147
-				$distinct = 'DISTINCT';
148
-			}
149
-
150
-			$get_key = self::get_invoice_table_key( $key, $value['type'] );
151
-
152
-			if ( false === $get_key ) {
153
-				// Skip to the next foreach iteration else the query will be invalid.
154
-				continue;
155
-			}
156
-
157
-			if ( ! empty( $value['function'] ) ) {
158
-				$get = "{$value['function']}({$distinct} {$get_key})";
159
-			} else {
160
-				$get = "{$distinct} {$get_key}";
161
-			}
162
-
163
-			$prepared[] = "{$get} as {$value['name']}";
164
-		}
165
-
166
-		return $prepared;
167
-
168
-	}
169
-
170
-	/**
171
-	 * Prepares the joins to use.
172
-	 *
173
-	 *
174
-	 * @param  array $data
175
-	 * @param  bool $with_parent
176
-	 * @return array
177
-	 */
178
-	public static function prepare_invoice_joins( $data, $with_parent ) {
179
-		global $wpdb;
180
-
181
-		$prepared = array();
182
-
183
-		foreach ( $data as $raw_key => $value ) {
184
-			$join_type = isset( $value['join_type'] ) ? $value['join_type'] : 'INNER';
185
-			$type      = isset( $value['type'] ) ? $value['type'] : false;
186
-			$key       = sanitize_key( $raw_key );
187
-
188
-			switch ( $type ) {
189
-				case 'meta':
190
-					$prepared[ "meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$raw_key}' )";
191
-					break;
192
-				case 'parent_meta':
193
-					$prepared[ "parent_meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$raw_key}')";
194
-					break;
195
-				case 'invoice_data':
196
-					$prepared['invoices'] = "{$join_type} JOIN {$wpdb->prefix}getpaid_invoices AS invoices ON posts.ID = invoices.post_id";
197
-					break;
198
-				case 'invoice_item':
199
-					$prepared['invoice_items'] = "{$join_type} JOIN {$wpdb->prefix}getpaid_invoice_items AS invoice_items ON posts.ID = invoice_items.post_id";
200
-					break;
201
-			}
202
-		}
203
-
204
-		if ( $with_parent ) {
205
-			$prepared['parent'] = "LEFT JOIN {$wpdb->posts} AS parent ON posts.post_parent = parent.ID";
206
-		}
207
-
208
-		return $prepared;
209
-
210
-	}
211
-
212
-	/**
213
-	 * Retrieves the appropriate table key to use.
214
-	 *
215
-	 *
216
-	 * @param  string $key
217
-	 * @param  string $table
218
-	 * @return string|false
219
-	 */
220
-	public static function get_invoice_table_key( $key, $table ) {
221
-
222
-		$keys = array(
223
-			'meta'         => "meta_{$key}.meta_value",
224
-			'parent_meta'  => "parent_meta_{$key}.meta_value",
225
-			'post_data'    => "posts.{$key}",
226
-			'invoice_data' => "invoices.{$key}",
227
-			'invoice_item' => "invoice_items.{$key}",
228
-		);
229
-
230
-		return isset( $keys[ $table ] ) ? $keys[ $table ] : false;
231
-
232
-	}
233
-
234
-	/**
235
-	 * Executes a query and caches the result for a minute.
236
-	 *
237
-	 *
238
-	 * @param  string $query_type
239
-	 * @param  string $query
240
-	 * @return mixed depending on query_type
241
-	 */
242
-	public static function execute( $query_type, $query ) {
243
-		global $wpdb;
244
-
245
-		$query_hash = md5( $query_type . $query );
246
-		$result     = self::get_cached_query( $query_hash );
247
-		if ( $result === false ) {
248
-			self::enable_big_selects();
249
-
250
-			$result = $wpdb->$query_type( $query );
251
-			self::set_cached_query( $query_hash, $result );
252
-		}
253
-
254
-		return $result;
255
-
256
-	}
257
-
258
-	/**
259
-	 * Enables big mysql selects for reports, just once for this session.
260
-	 */
261
-	protected static function enable_big_selects() {
262
-		static $big_selects = false;
263
-
264
-		global $wpdb;
265
-
266
-		if ( ! $big_selects ) {
267
-			$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
268
-			$big_selects = true;
269
-		}
270
-	}
271
-
272
-	/**
273
-	 * Get the cached query result or null if it's not in the cache.
274
-	 *
275
-	 * @param string $query_hash The query hash.
276
-	 *
277
-	 * @return mixed|false The cache contents on success, false on failure to retrieve contents.
278
-	 */
279
-	protected static function get_cached_query( $query_hash ) {
280
-
281
-		return wp_cache_get(
282
-			$query_hash,
283
-			strtolower( __CLASS__ )
284
-		);
285
-
286
-	}
287
-
288
-	/**
289
-	 * Set the cached query result.
290
-	 *
291
-	 * @param string $query_hash The query hash.
292
-	 * @param mixed  $data The data to cache.
293
-	 */
294
-	protected static function set_cached_query( $query_hash, $data ) {
295
-
296
-		wp_cache_set(
297
-			$query_hash,
298
-			$data,
299
-			strtolower( __CLASS__ ),
300
-			MINUTE_IN_SECONDS
301
-		);
302
-
303
-	}
93
+                if ( strtolower( $value['operator'] ) === 'in' || strtolower( $value['operator'] ) === 'not in' ) {
94
+
95
+                    if ( is_array( $value['value'] ) ) {
96
+                        $value['value'] = implode( "','", $value['value'] );
97
+                    }
98
+
99
+                    if ( ! empty( $value['value'] ) ) {
100
+                        $where_value = "{$value['operator']} ('{$value['value']}')";
101
+                    }
102
+                } else {
103
+                    $where_value = "{$value['operator']} '{$value['value']}'";
104
+                }
105
+
106
+                if ( ! empty( $where_value ) ) {
107
+                    $query['where'] .= " AND {$value['key']} {$where_value}";
108
+                }
109
+            }
110
+        }
111
+
112
+        if ( $group_by ) {
113
+            $query['group_by'] = "GROUP BY {$group_by}";
114
+        }
115
+
116
+        if ( $order_by ) {
117
+            $query['order_by'] = "ORDER BY {$order_by}";
118
+        }
119
+
120
+        if ( $limit ) {
121
+            $query['limit'] = "LIMIT {$limit}";
122
+        }
123
+
124
+        $query = apply_filters( 'getpaid_reports_get_invoice_report_query', $query, $data );
125
+        $query = implode( ' ', $query );
126
+
127
+        return self::execute( $query_type, $query );
128
+
129
+    }
130
+
131
+    /**
132
+     * Prepares the data to select.
133
+     *
134
+     *
135
+     * @param  array $data
136
+     * @return array
137
+     */
138
+    public static function prepare_invoice_data( $data ) {
139
+
140
+        $prepared = array();
141
+
142
+        foreach ( $data as $raw_key => $value ) {
143
+            $key      = sanitize_key( $raw_key );
144
+            $distinct = '';
145
+
146
+            if ( isset( $value['distinct'] ) ) {
147
+                $distinct = 'DISTINCT';
148
+            }
149
+
150
+            $get_key = self::get_invoice_table_key( $key, $value['type'] );
151
+
152
+            if ( false === $get_key ) {
153
+                // Skip to the next foreach iteration else the query will be invalid.
154
+                continue;
155
+            }
156
+
157
+            if ( ! empty( $value['function'] ) ) {
158
+                $get = "{$value['function']}({$distinct} {$get_key})";
159
+            } else {
160
+                $get = "{$distinct} {$get_key}";
161
+            }
162
+
163
+            $prepared[] = "{$get} as {$value['name']}";
164
+        }
165
+
166
+        return $prepared;
167
+
168
+    }
169
+
170
+    /**
171
+     * Prepares the joins to use.
172
+     *
173
+     *
174
+     * @param  array $data
175
+     * @param  bool $with_parent
176
+     * @return array
177
+     */
178
+    public static function prepare_invoice_joins( $data, $with_parent ) {
179
+        global $wpdb;
180
+
181
+        $prepared = array();
182
+
183
+        foreach ( $data as $raw_key => $value ) {
184
+            $join_type = isset( $value['join_type'] ) ? $value['join_type'] : 'INNER';
185
+            $type      = isset( $value['type'] ) ? $value['type'] : false;
186
+            $key       = sanitize_key( $raw_key );
187
+
188
+            switch ( $type ) {
189
+                case 'meta':
190
+                    $prepared[ "meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$raw_key}' )";
191
+                    break;
192
+                case 'parent_meta':
193
+                    $prepared[ "parent_meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$raw_key}')";
194
+                    break;
195
+                case 'invoice_data':
196
+                    $prepared['invoices'] = "{$join_type} JOIN {$wpdb->prefix}getpaid_invoices AS invoices ON posts.ID = invoices.post_id";
197
+                    break;
198
+                case 'invoice_item':
199
+                    $prepared['invoice_items'] = "{$join_type} JOIN {$wpdb->prefix}getpaid_invoice_items AS invoice_items ON posts.ID = invoice_items.post_id";
200
+                    break;
201
+            }
202
+        }
203
+
204
+        if ( $with_parent ) {
205
+            $prepared['parent'] = "LEFT JOIN {$wpdb->posts} AS parent ON posts.post_parent = parent.ID";
206
+        }
207
+
208
+        return $prepared;
209
+
210
+    }
211
+
212
+    /**
213
+     * Retrieves the appropriate table key to use.
214
+     *
215
+     *
216
+     * @param  string $key
217
+     * @param  string $table
218
+     * @return string|false
219
+     */
220
+    public static function get_invoice_table_key( $key, $table ) {
221
+
222
+        $keys = array(
223
+            'meta'         => "meta_{$key}.meta_value",
224
+            'parent_meta'  => "parent_meta_{$key}.meta_value",
225
+            'post_data'    => "posts.{$key}",
226
+            'invoice_data' => "invoices.{$key}",
227
+            'invoice_item' => "invoice_items.{$key}",
228
+        );
229
+
230
+        return isset( $keys[ $table ] ) ? $keys[ $table ] : false;
231
+
232
+    }
233
+
234
+    /**
235
+     * Executes a query and caches the result for a minute.
236
+     *
237
+     *
238
+     * @param  string $query_type
239
+     * @param  string $query
240
+     * @return mixed depending on query_type
241
+     */
242
+    public static function execute( $query_type, $query ) {
243
+        global $wpdb;
244
+
245
+        $query_hash = md5( $query_type . $query );
246
+        $result     = self::get_cached_query( $query_hash );
247
+        if ( $result === false ) {
248
+            self::enable_big_selects();
249
+
250
+            $result = $wpdb->$query_type( $query );
251
+            self::set_cached_query( $query_hash, $result );
252
+        }
253
+
254
+        return $result;
255
+
256
+    }
257
+
258
+    /**
259
+     * Enables big mysql selects for reports, just once for this session.
260
+     */
261
+    protected static function enable_big_selects() {
262
+        static $big_selects = false;
263
+
264
+        global $wpdb;
265
+
266
+        if ( ! $big_selects ) {
267
+            $wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
268
+            $big_selects = true;
269
+        }
270
+    }
271
+
272
+    /**
273
+     * Get the cached query result or null if it's not in the cache.
274
+     *
275
+     * @param string $query_hash The query hash.
276
+     *
277
+     * @return mixed|false The cache contents on success, false on failure to retrieve contents.
278
+     */
279
+    protected static function get_cached_query( $query_hash ) {
280
+
281
+        return wp_cache_get(
282
+            $query_hash,
283
+            strtolower( __CLASS__ )
284
+        );
285
+
286
+    }
287
+
288
+    /**
289
+     * Set the cached query result.
290
+     *
291
+     * @param string $query_hash The query hash.
292
+     * @param mixed  $data The data to cache.
293
+     */
294
+    protected static function set_cached_query( $query_hash, $data ) {
295
+
296
+        wp_cache_set(
297
+            $query_hash,
298
+            $data,
299
+            strtolower( __CLASS__ ),
300
+            MINUTE_IN_SECONDS
301
+        );
302
+
303
+    }
304 304
 
305 305
 }
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Helper Class.
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param  array $args
27 27
 	 * @return mixed depending on query_type
28 28
 	 */
29
-	public static function get_invoice_report_data( $args = array() ) {
29
+	public static function get_invoice_report_data($args = array()) {
30 30
 		global $wpdb;
31 31
 
32 32
 		$default_args = array(
@@ -37,94 +37,94 @@  discard block
 block discarded – undo
37 37
 			'order_by'              => '', // What to order by.
38 38
 			'limit'                 => '', // Results limit.
39 39
 			'filter_range'          => array(), // An array of before and after dates to limit results by.
40
-			'invoice_types'         => array( 'wpi_invoice' ), // An array of post types to retrieve.
41
-			'invoice_status'        => array( 'publish', 'wpi-processing', 'wpi-onhold' ),
40
+			'invoice_types'         => array('wpi_invoice'), // An array of post types to retrieve.
41
+			'invoice_status'        => array('publish', 'wpi-processing', 'wpi-onhold'),
42 42
 			'parent_invoice_status' => false, // Optionally filter by parent invoice status.
43 43
 		);
44 44
 
45
-		$args         = apply_filters( 'getpaid_reports_get_invoice_report_data_args', $args );
46
-		$args         = wp_parse_args( $args, $default_args );
45
+		$args         = apply_filters('getpaid_reports_get_invoice_report_data_args', $args);
46
+		$args         = wp_parse_args($args, $default_args);
47 47
 
48
-		extract( $args );
48
+		extract($args);
49 49
 
50
-		if ( empty( $data ) ) {
50
+		if (empty($data)) {
51 51
 			return '';
52 52
 		}
53 53
 
54 54
 		$query           = array();
55
-		$query['select'] = 'SELECT ' . implode( ',', self::prepare_invoice_data( $data ) );
55
+		$query['select'] = 'SELECT ' . implode(',', self::prepare_invoice_data($data));
56 56
 		$query['from']   = "FROM {$wpdb->posts} AS posts";
57
-		$query['join']   = implode( ' ', self::prepare_invoice_joins( $data + $where, ! empty( $parent_invoice_status ) ) );
57
+		$query['join']   = implode(' ', self::prepare_invoice_joins($data + $where, !empty($parent_invoice_status)));
58 58
 
59 59
 		$query['where']  = "
60
-			WHERE 	posts.post_type 	IN ( '" . implode( "','", $invoice_types ) . "' )
60
+			WHERE 	posts.post_type 	IN ( '" . implode("','", $invoice_types) . "' )
61 61
 			";
62 62
 
63
-		if ( ! empty( $invoice_status ) ) {
63
+		if (!empty($invoice_status)) {
64 64
 			$query['where'] .= "
65
-				AND 	posts.post_status 	IN ( '" . implode( "','", $invoice_status ) . "' )
65
+				AND 	posts.post_status 	IN ( '" . implode("','", $invoice_status) . "' )
66 66
 			";
67 67
 		}
68 68
 
69
-		if ( ! empty( $parent_invoice_status ) ) {
70
-			if ( ! empty( $invoice_status ) ) {
71
-				$query['where'] .= " AND ( parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) OR parent.ID IS NULL ) ";
69
+		if (!empty($parent_invoice_status)) {
70
+			if (!empty($invoice_status)) {
71
+				$query['where'] .= " AND ( parent.post_status IN ( '" . implode("','", $parent_invoice_status) . "' ) OR parent.ID IS NULL ) ";
72 72
 			} else {
73
-				$query['where'] .= " AND parent.post_status IN ( '" . implode( "','", $parent_invoice_status ) . "' ) ";
73
+				$query['where'] .= " AND parent.post_status IN ( '" . implode("','", $parent_invoice_status) . "' ) ";
74 74
 			}
75 75
 		}
76 76
 
77
-		if ( ! empty( $filter_range['before'] ) ) {
77
+		if (!empty($filter_range['before'])) {
78 78
 			$query['where'] .= "
79
-				AND 	posts.post_date <= '" . gmdate( 'Y-m-d 23:59:59', strtotime( $filter_range['before'] ) ) . "'
79
+				AND 	posts.post_date <= '" . gmdate('Y-m-d 23:59:59', strtotime($filter_range['before'])) . "'
80 80
 			";
81 81
 		}
82 82
 
83
-		if ( ! empty( $filter_range['after'] ) ) {
83
+		if (!empty($filter_range['after'])) {
84 84
 			$query['where'] .= "
85
-				AND 	posts.post_date >= '" . gmdate( 'Y-m-d 00:00:00', strtotime( $filter_range['after'] ) ) . "'
85
+				AND 	posts.post_date >= '" . gmdate('Y-m-d 00:00:00', strtotime($filter_range['after'])) . "'
86 86
 			";
87 87
 		}
88 88
 
89
-		if ( ! empty( $where ) ) {
89
+		if (!empty($where)) {
90 90
 
91
-			foreach ( $where as $value ) {
91
+			foreach ($where as $value) {
92 92
 
93
-				if ( strtolower( $value['operator'] ) === 'in' || strtolower( $value['operator'] ) === 'not in' ) {
93
+				if (strtolower($value['operator']) === 'in' || strtolower($value['operator']) === 'not in') {
94 94
 
95
-					if ( is_array( $value['value'] ) ) {
96
-						$value['value'] = implode( "','", $value['value'] );
95
+					if (is_array($value['value'])) {
96
+						$value['value'] = implode("','", $value['value']);
97 97
 					}
98 98
 
99
-					if ( ! empty( $value['value'] ) ) {
99
+					if (!empty($value['value'])) {
100 100
 						$where_value = "{$value['operator']} ('{$value['value']}')";
101 101
 					}
102 102
 				} else {
103 103
 					$where_value = "{$value['operator']} '{$value['value']}'";
104 104
 				}
105 105
 
106
-				if ( ! empty( $where_value ) ) {
106
+				if (!empty($where_value)) {
107 107
 					$query['where'] .= " AND {$value['key']} {$where_value}";
108 108
 				}
109 109
 			}
110 110
 		}
111 111
 
112
-		if ( $group_by ) {
112
+		if ($group_by) {
113 113
 			$query['group_by'] = "GROUP BY {$group_by}";
114 114
 		}
115 115
 
116
-		if ( $order_by ) {
116
+		if ($order_by) {
117 117
 			$query['order_by'] = "ORDER BY {$order_by}";
118 118
 		}
119 119
 
120
-		if ( $limit ) {
120
+		if ($limit) {
121 121
 			$query['limit'] = "LIMIT {$limit}";
122 122
 		}
123 123
 
124
-		$query = apply_filters( 'getpaid_reports_get_invoice_report_query', $query, $data );
125
-		$query = implode( ' ', $query );
124
+		$query = apply_filters('getpaid_reports_get_invoice_report_query', $query, $data);
125
+		$query = implode(' ', $query);
126 126
 
127
-		return self::execute( $query_type, $query );
127
+		return self::execute($query_type, $query);
128 128
 
129 129
 	}
130 130
 
@@ -135,26 +135,26 @@  discard block
 block discarded – undo
135 135
 	 * @param  array $data
136 136
 	 * @return array
137 137
 	 */
138
-	public static function prepare_invoice_data( $data ) {
138
+	public static function prepare_invoice_data($data) {
139 139
 
140 140
 		$prepared = array();
141 141
 
142
-		foreach ( $data as $raw_key => $value ) {
143
-			$key      = sanitize_key( $raw_key );
142
+		foreach ($data as $raw_key => $value) {
143
+			$key      = sanitize_key($raw_key);
144 144
 			$distinct = '';
145 145
 
146
-			if ( isset( $value['distinct'] ) ) {
146
+			if (isset($value['distinct'])) {
147 147
 				$distinct = 'DISTINCT';
148 148
 			}
149 149
 
150
-			$get_key = self::get_invoice_table_key( $key, $value['type'] );
150
+			$get_key = self::get_invoice_table_key($key, $value['type']);
151 151
 
152
-			if ( false === $get_key ) {
152
+			if (false === $get_key) {
153 153
 				// Skip to the next foreach iteration else the query will be invalid.
154 154
 				continue;
155 155
 			}
156 156
 
157
-			if ( ! empty( $value['function'] ) ) {
157
+			if (!empty($value['function'])) {
158 158
 				$get = "{$value['function']}({$distinct} {$get_key})";
159 159
 			} else {
160 160
 				$get = "{$distinct} {$get_key}";
@@ -175,22 +175,22 @@  discard block
 block discarded – undo
175 175
 	 * @param  bool $with_parent
176 176
 	 * @return array
177 177
 	 */
178
-	public static function prepare_invoice_joins( $data, $with_parent ) {
178
+	public static function prepare_invoice_joins($data, $with_parent) {
179 179
 		global $wpdb;
180 180
 
181 181
 		$prepared = array();
182 182
 
183
-		foreach ( $data as $raw_key => $value ) {
184
-			$join_type = isset( $value['join_type'] ) ? $value['join_type'] : 'INNER';
185
-			$type      = isset( $value['type'] ) ? $value['type'] : false;
186
-			$key       = sanitize_key( $raw_key );
183
+		foreach ($data as $raw_key => $value) {
184
+			$join_type = isset($value['join_type']) ? $value['join_type'] : 'INNER';
185
+			$type      = isset($value['type']) ? $value['type'] : false;
186
+			$key       = sanitize_key($raw_key);
187 187
 
188
-			switch ( $type ) {
188
+			switch ($type) {
189 189
 				case 'meta':
190
-					$prepared[ "meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$raw_key}' )";
190
+					$prepared["meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS meta_{$key} ON ( posts.ID = meta_{$key}.post_id AND meta_{$key}.meta_key = '{$raw_key}' )";
191 191
 					break;
192 192
 				case 'parent_meta':
193
-					$prepared[ "parent_meta_{$key}" ] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$raw_key}')";
193
+					$prepared["parent_meta_{$key}"] = "{$join_type} JOIN {$wpdb->postmeta} AS parent_meta_{$key} ON (posts.post_parent = parent_meta_{$key}.post_id) AND (parent_meta_{$key}.meta_key = '{$raw_key}')";
194 194
 					break;
195 195
 				case 'invoice_data':
196 196
 					$prepared['invoices'] = "{$join_type} JOIN {$wpdb->prefix}getpaid_invoices AS invoices ON posts.ID = invoices.post_id";
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			}
202 202
 		}
203 203
 
204
-		if ( $with_parent ) {
204
+		if ($with_parent) {
205 205
 			$prepared['parent'] = "LEFT JOIN {$wpdb->posts} AS parent ON posts.post_parent = parent.ID";
206 206
 		}
207 207
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 * @param  string $table
218 218
 	 * @return string|false
219 219
 	 */
220
-	public static function get_invoice_table_key( $key, $table ) {
220
+	public static function get_invoice_table_key($key, $table) {
221 221
 
222 222
 		$keys = array(
223 223
 			'meta'         => "meta_{$key}.meta_value",
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			'invoice_item' => "invoice_items.{$key}",
228 228
 		);
229 229
 
230
-		return isset( $keys[ $table ] ) ? $keys[ $table ] : false;
230
+		return isset($keys[$table]) ? $keys[$table] : false;
231 231
 
232 232
 	}
233 233
 
@@ -239,16 +239,16 @@  discard block
 block discarded – undo
239 239
 	 * @param  string $query
240 240
 	 * @return mixed depending on query_type
241 241
 	 */
242
-	public static function execute( $query_type, $query ) {
242
+	public static function execute($query_type, $query) {
243 243
 		global $wpdb;
244 244
 
245
-		$query_hash = md5( $query_type . $query );
246
-		$result     = self::get_cached_query( $query_hash );
247
-		if ( $result === false ) {
245
+		$query_hash = md5($query_type . $query);
246
+		$result     = self::get_cached_query($query_hash);
247
+		if ($result === false) {
248 248
 			self::enable_big_selects();
249 249
 
250
-			$result = $wpdb->$query_type( $query );
251
-			self::set_cached_query( $query_hash, $result );
250
+			$result = $wpdb->$query_type($query);
251
+			self::set_cached_query($query_hash, $result);
252 252
 		}
253 253
 
254 254
 		return $result;
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 
264 264
 		global $wpdb;
265 265
 
266
-		if ( ! $big_selects ) {
267
-			$wpdb->query( 'SET SESSION SQL_BIG_SELECTS=1' );
266
+		if (!$big_selects) {
267
+			$wpdb->query('SET SESSION SQL_BIG_SELECTS=1');
268 268
 			$big_selects = true;
269 269
 		}
270 270
 	}
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return mixed|false The cache contents on success, false on failure to retrieve contents.
278 278
 	 */
279
-	protected static function get_cached_query( $query_hash ) {
279
+	protected static function get_cached_query($query_hash) {
280 280
 
281 281
 		return wp_cache_get(
282 282
 			$query_hash,
283
-			strtolower( __CLASS__ )
283
+			strtolower(__CLASS__)
284 284
 		);
285 285
 
286 286
 	}
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 	 * @param string $query_hash The query hash.
292 292
 	 * @param mixed  $data The data to cache.
293 293
 	 */
294
-	protected static function set_cached_query( $query_hash, $data ) {
294
+	protected static function set_cached_query($query_hash, $data) {
295 295
 
296 296
 		wp_cache_set(
297 297
 			$query_hash,
298 298
 			$data,
299
-			strtolower( __CLASS__ ),
299
+			strtolower(__CLASS__),
300 300
 			MINUTE_IN_SECONDS
301 301
 		);
302 302
 
Please login to merge, or discard this patch.
includes/class-getpaid-daily-maintenance.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -12,144 +12,144 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Daily_Maintenance {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 */
18
-	public function __construct() {
19
-
20
-		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
-
23
-		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
-
26
-		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
32
-
33
-	}
34
-
35
-	/**
36
-	 * Schedules a cron to run every day at 7 a.m
37
-	 *
38
-	 */
39
-	public function maybe_create_scheduled_event() {
40
-
41
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
44
-		}
45
-
46
-	}
47
-
48
-	/**
49
-	 * Clears deprecated events.
50
-	 *
51
-	 */
52
-	public function maybe_clear_deprecated_events() {
53
-
54
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
-			update_option( 'wpinv_cleared_old_events', 1 );
58
-		}
59
-
60
-	}
61
-
62
-	/**
63
-	 * Fires the old hook for backwards compatibility.
64
-	 *
65
-	 */
66
-	public function backwards_compat() {
67
-		do_action( 'wpinv_register_schedule_event_daily' );
68
-	}
69
-
70
-	/**
71
-	 * Checks for subscriptions that are scheduled to renew.
72
-	 *
73
-	 */
74
-	public function check_renewing_subscriptions() {
75
-
76
-		// Fetch subscriptions that expire today.
77
-		$args  = array(
78
-			'number'             => -1,
79
-			'count_total'        => false,
80
-			'status'             => 'trialling active',
81
-			'date_expires_query' => array(
82
-				array(
83
-					'year'    => gmdate( 'Y' ),
84
-					'month'   => gmdate( 'n' ),
85
-					'day'     => gmdate( 'j' ),
86
-					'compare' => '=',
87
-				),
88
-			),
89
-		);
90
-
91
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
92
-
93
-		foreach ( $subscriptions->get_results() as $subscription ) {
94
-
95
-			/** @var WPInv_Subscription $subscription */
96
-			if ( $subscription->is_last_renewal() ) {
97
-				$subscription->complete();
98
-			} else {
99
-				do_action( 'getpaid_should_renew_subscription', $subscription );
100
-			}
101
-		}
102
-
103
-	}
104
-
105
-	/**
106
-	 * Expires expired subscriptions.
107
-	 *
108
-	 */
109
-	public function maybe_expire_subscriptions() {
110
-
111
-		// Fetch expired subscriptions (skips those that expire today).
112
-		$args  = array(
113
-			'number'             => -1,
114
-			'count_total'        => false,
115
-			'status'             => 'trialling active failing cancelled',
116
-			'date_expires_query' => array(
117
-				'before'    => 'yesterday',
118
-				'inclusive' => false,
119
-			),
120
-		);
121
-
122
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
123
-
124
-		foreach ( $subscriptions->get_results() as $subscription ) {
125
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
126
-				$subscription->set_status( 'expired' );
127
-				$subscription->save();
128
-			}
129
-		}
130
-
131
-	}
132
-
133
-	/**
134
-	 * Logs cron runs.
135
-	 *
136
-	 */
137
-	public function log_cron_run() {
138
-		wpinv_error_log( 'GetPaid Daily Cron', false );
139
-	}
140
-
141
-	/**
142
-	 * Updates GeoIP databases.
143
-	 *
144
-	 */
145
-	public function maybe_update_geoip_databases() {
146
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
147
-
148
-		if ( false === $updated ) {
149
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
150
-			do_action( 'getpaid_update_geoip_databases' );
151
-		}
152
-
153
-	}
15
+    /**
16
+     * Class constructor.
17
+     */
18
+    public function __construct() {
19
+
20
+        // Clear deprecated events.
21
+        add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
+
23
+        // (Maybe) schedule a cron that runs daily.
24
+        add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
+
26
+        // Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
+        add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
+        add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
+        add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
32
+
33
+    }
34
+
35
+    /**
36
+     * Schedules a cron to run every day at 7 a.m
37
+     *
38
+     */
39
+    public function maybe_create_scheduled_event() {
40
+
41
+        if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
+            $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
+            wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
44
+        }
45
+
46
+    }
47
+
48
+    /**
49
+     * Clears deprecated events.
50
+     *
51
+     */
52
+    public function maybe_clear_deprecated_events() {
53
+
54
+        if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
+            update_option( 'wpinv_cleared_old_events', 1 );
58
+        }
59
+
60
+    }
61
+
62
+    /**
63
+     * Fires the old hook for backwards compatibility.
64
+     *
65
+     */
66
+    public function backwards_compat() {
67
+        do_action( 'wpinv_register_schedule_event_daily' );
68
+    }
69
+
70
+    /**
71
+     * Checks for subscriptions that are scheduled to renew.
72
+     *
73
+     */
74
+    public function check_renewing_subscriptions() {
75
+
76
+        // Fetch subscriptions that expire today.
77
+        $args  = array(
78
+            'number'             => -1,
79
+            'count_total'        => false,
80
+            'status'             => 'trialling active',
81
+            'date_expires_query' => array(
82
+                array(
83
+                    'year'    => gmdate( 'Y' ),
84
+                    'month'   => gmdate( 'n' ),
85
+                    'day'     => gmdate( 'j' ),
86
+                    'compare' => '=',
87
+                ),
88
+            ),
89
+        );
90
+
91
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
92
+
93
+        foreach ( $subscriptions->get_results() as $subscription ) {
94
+
95
+            /** @var WPInv_Subscription $subscription */
96
+            if ( $subscription->is_last_renewal() ) {
97
+                $subscription->complete();
98
+            } else {
99
+                do_action( 'getpaid_should_renew_subscription', $subscription );
100
+            }
101
+        }
102
+
103
+    }
104
+
105
+    /**
106
+     * Expires expired subscriptions.
107
+     *
108
+     */
109
+    public function maybe_expire_subscriptions() {
110
+
111
+        // Fetch expired subscriptions (skips those that expire today).
112
+        $args  = array(
113
+            'number'             => -1,
114
+            'count_total'        => false,
115
+            'status'             => 'trialling active failing cancelled',
116
+            'date_expires_query' => array(
117
+                'before'    => 'yesterday',
118
+                'inclusive' => false,
119
+            ),
120
+        );
121
+
122
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
123
+
124
+        foreach ( $subscriptions->get_results() as $subscription ) {
125
+            if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
126
+                $subscription->set_status( 'expired' );
127
+                $subscription->save();
128
+            }
129
+        }
130
+
131
+    }
132
+
133
+    /**
134
+     * Logs cron runs.
135
+     *
136
+     */
137
+    public function log_cron_run() {
138
+        wpinv_error_log( 'GetPaid Daily Cron', false );
139
+    }
140
+
141
+    /**
142
+     * Updates GeoIP databases.
143
+     *
144
+     */
145
+    public function maybe_update_geoip_databases() {
146
+        $updated = get_transient( 'getpaid_updated_geoip_databases' );
147
+
148
+        if ( false === $updated ) {
149
+            set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
150
+            do_action( 'getpaid_update_geoip_databases' );
151
+        }
152
+
153
+    }
154 154
 
155 155
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Daily maintenance class.
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 	public function __construct() {
19 19
 
20 20
 		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
21
+		add_action('wp', array($this, 'maybe_clear_deprecated_events'));
22 22
 
23 23
 		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
24
+		add_action('wp', array($this, 'maybe_create_scheduled_event'));
25 25
 
26 26
 		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
27
+		add_action('getpaid_daily_maintenance', array($this, 'log_cron_run'));
28
+		add_action('getpaid_daily_maintenance', array($this, 'backwards_compat'));
29
+		add_action('getpaid_daily_maintenance', array($this, 'maybe_expire_subscriptions'));
30
+		add_action('getpaid_daily_maintenance', array($this, 'check_renewing_subscriptions'));
31
+		add_action('getpaid_daily_maintenance', array($this, 'maybe_update_geoip_databases'));
32 32
 
33 33
 	}
34 34
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function maybe_create_scheduled_event() {
40 40
 
41
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
41
+		if (!wp_next_scheduled('getpaid_daily_maintenance')) {
42
+			$timestamp = strtotime('tomorrow 07:00:00', current_time('timestamp'));
43
+			wp_schedule_event($timestamp, 'daily', 'getpaid_daily_maintenance');
44 44
 		}
45 45
 
46 46
 	}
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function maybe_clear_deprecated_events() {
53 53
 
54
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
-			update_option( 'wpinv_cleared_old_events', 1 );
54
+		if (!get_option('wpinv_cleared_old_events')) {
55
+			wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily');
56
+			wp_clear_scheduled_hook('wpinv_register_schedule_event_daily');
57
+			update_option('wpinv_cleared_old_events', 1);
58 58
 		}
59 59
 
60 60
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 */
66 66
 	public function backwards_compat() {
67
-		do_action( 'wpinv_register_schedule_event_daily' );
67
+		do_action('wpinv_register_schedule_event_daily');
68 68
 	}
69 69
 
70 70
 	/**
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 	public function check_renewing_subscriptions() {
75 75
 
76 76
 		// Fetch subscriptions that expire today.
77
-		$args  = array(
77
+		$args = array(
78 78
 			'number'             => -1,
79 79
 			'count_total'        => false,
80 80
 			'status'             => 'trialling active',
81 81
 			'date_expires_query' => array(
82 82
 				array(
83
-					'year'    => gmdate( 'Y' ),
84
-					'month'   => gmdate( 'n' ),
85
-					'day'     => gmdate( 'j' ),
83
+					'year'    => gmdate('Y'),
84
+					'month'   => gmdate('n'),
85
+					'day'     => gmdate('j'),
86 86
 					'compare' => '=',
87 87
 				),
88 88
 			),
89 89
 		);
90 90
 
91
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
91
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
92 92
 
93
-		foreach ( $subscriptions->get_results() as $subscription ) {
93
+		foreach ($subscriptions->get_results() as $subscription) {
94 94
 
95 95
 			/** @var WPInv_Subscription $subscription */
96
-			if ( $subscription->is_last_renewal() ) {
96
+			if ($subscription->is_last_renewal()) {
97 97
 				$subscription->complete();
98 98
 			} else {
99
-				do_action( 'getpaid_should_renew_subscription', $subscription );
99
+				do_action('getpaid_should_renew_subscription', $subscription);
100 100
 			}
101 101
 		}
102 102
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	public function maybe_expire_subscriptions() {
110 110
 
111 111
 		// Fetch expired subscriptions (skips those that expire today).
112
-		$args  = array(
112
+		$args = array(
113 113
 			'number'             => -1,
114 114
 			'count_total'        => false,
115 115
 			'status'             => 'trialling active failing cancelled',
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 			),
120 120
 		);
121 121
 
122
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
122
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
123 123
 
124
-		foreach ( $subscriptions->get_results() as $subscription ) {
125
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
126
-				$subscription->set_status( 'expired' );
124
+		foreach ($subscriptions->get_results() as $subscription) {
125
+			if (apply_filters('getpaid_daily_maintenance_should_expire_subscription', false, $subscription)) {
126
+				$subscription->set_status('expired');
127 127
 				$subscription->save();
128 128
 			}
129 129
 		}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 */
137 137
 	public function log_cron_run() {
138
-		wpinv_error_log( 'GetPaid Daily Cron', false );
138
+		wpinv_error_log('GetPaid Daily Cron', false);
139 139
 	}
140 140
 
141 141
 	/**
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 	 *
144 144
 	 */
145 145
 	public function maybe_update_geoip_databases() {
146
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
146
+		$updated = get_transient('getpaid_updated_geoip_databases');
147 147
 
148
-		if ( false === $updated ) {
149
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
150
-			do_action( 'getpaid_update_geoip_databases' );
148
+		if (false === $updated) {
149
+			set_transient('getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS);
150
+			do_action('getpaid_update_geoip_databases');
151 151
 		}
152 152
 
153 153
 	}
Please login to merge, or discard this patch.
templates/subscriptions/subscription-details.php 3 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -39,62 +39,62 @@  discard block
 block discarded – undo
39 39
 				<td style="width: 65%">
40 40
 					<?php
41 41
 
42
-						switch ( $key ) {
42
+                        switch ( $key ) {
43 43
 
44
-						case 'status':
45
-							echo esc_html( $subscription->get_status_label() );
46
-							break;
44
+                        case 'status':
45
+                            echo esc_html( $subscription->get_status_label() );
46
+                            break;
47 47
 
48
-						case 'start_date':
49
-							echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
50
-							break;
48
+                        case 'start_date':
49
+                            echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
50
+                            break;
51 51
 
52
-						case 'expiry_date':
53
-							echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
54
-							break;
52
+                        case 'expiry_date':
53
+                            echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
54
+                            break;
55 55
 
56
-						case 'initial_amount':
57
-							echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
56
+                        case 'initial_amount':
57
+                            echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
58 58
 
59
-							if ( $subscription->has_trial_period() ) {
59
+                            if ( $subscription->has_trial_period() ) {
60 60
 
61
-								echo "<small class='text-muted'>&nbsp;";
62
-								printf(
63
-									esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
64
-									esc_html( $subscription->get_trial_period() )
65
-								);
66
-								echo '</small>';
61
+                                echo "<small class='text-muted'>&nbsp;";
62
+                                printf(
63
+                                    esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
64
+                                    esc_html( $subscription->get_trial_period() )
65
+                                );
66
+                                echo '</small>';
67 67
 
68
-							}
68
+                            }
69 69
 
70
-							break;
70
+                            break;
71 71
 
72
-						case 'recurring_amount':
73
-							$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
74
-							$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
75
-							echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
76
-							break;
72
+                        case 'recurring_amount':
73
+                            $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
74
+                            $amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
75
+                            echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
76
+                            break;
77 77
 
78
-						case 'item':
79
-							if ( empty( $subscription_group ) ) {
80
-								echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
81
-							} else {
82
-								$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
83
-								echo wp_kses_post( implode( ' | ', $markup ) );
84
-							}
78
+                        case 'item':
79
+                            if ( empty( $subscription_group ) ) {
80
+                                echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
81
+                            } else {
82
+                                $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
83
+                                echo wp_kses_post( implode( ' | ', $markup ) );
84
+                            }
85 85
 
86
-							break;
86
+                            break;
87 87
 
88
-						case 'payments':
89
-							$max_activations = (int) $subscription->get_bill_times();
90
-							echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
88
+                        case 'payments':
89
+                            $max_activations = (int) $subscription->get_bill_times();
90
+                            echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
91 91
 
92
-							break;
92
+                            break;
93 93
 
94
-						}
95
-						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
94
+                        }
95
+                        do_action( "getpaid_render_single_subscription_column_$key", $subscription );
96 96
 
97
-					?>
97
+                    ?>
98 98
 				</td>
99 99
 
100 100
 			</tr>
@@ -121,17 +121,17 @@  discard block
 block discarded – undo
121 121
 <span class="form-text">
122 122
 
123 123
 	<?php
124
-		if ( $subscription->can_cancel() ) {
125
-		printf(
124
+        if ( $subscription->can_cancel() ) {
125
+        printf(
126 126
             '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
127 127
             esc_url( $subscription->get_cancel_url() ),
128 128
             esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
129 129
             esc_html__( 'Cancel Subscription', 'invoicing' )
130 130
         );
131
-		}
131
+        }
132 132
 
133
-		do_action( 'getpaid-single-subscription-page-actions', $subscription );
134
-	?>
133
+        do_action( 'getpaid-single-subscription-page-actions', $subscription );
134
+    ?>
135 135
 
136 136
 	<a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php esc_html_e( 'Go Back', 'invoicing' ); ?></a>
137 137
 </span>
Please login to merge, or discard this patch.
Switch Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php
1
+    <?php
2 2
 
3 3
 /**
4 4
  * Template that prints a single subscription's details
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
  * @var WPInv_Subscriptions_Widget $widget
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+    defined( 'ABSPATH' ) || exit;
14 14
 
15
-do_action( 'getpaid_single_subscription_before_notices', $subscription );
15
+    do_action( 'getpaid_single_subscription_before_notices', $subscription );
16 16
 
17
-// Display errors and notices.
18
-wpinv_print_errors();
17
+    // Display errors and notices.
18
+    wpinv_print_errors();
19 19
 
20
-$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() );
21
-$subscription_group  = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() );
20
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() );
21
+    $subscription_group  = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() );
22 22
 
23
-do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups );
23
+    do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups );
24 24
 
25
-?>
25
+    ?>
26 26
 
27 27
 <h2 class="mb-1 h4"><?php esc_html_e( 'Subscription Details', 'invoicing' ); ?></h2>
28 28
 <table class="table table-bordered">
@@ -39,59 +39,59 @@  discard block
 block discarded – undo
39 39
 				<td style="width: 65%">
40 40
 					<?php
41 41
 
42
-						switch ( $key ) {
42
+						    switch ( $key ) {
43 43
 
44
-						case 'status':
45
-							echo esc_html( $subscription->get_status_label() );
46
-							break;
44
+						        case 'status':
45
+							        echo esc_html( $subscription->get_status_label() );
46
+							        break;
47 47
 
48
-						case 'start_date':
49
-							echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
50
-							break;
48
+						        case 'start_date':
49
+							        echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
50
+							        break;
51 51
 
52
-						case 'expiry_date':
53
-							echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
54
-							break;
52
+						        case 'expiry_date':
53
+							        echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
54
+							        break;
55 55
 
56
-						case 'initial_amount':
57
-							echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
56
+						        case 'initial_amount':
57
+							        echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
58 58
 
59
-							if ( $subscription->has_trial_period() ) {
59
+							        if ( $subscription->has_trial_period() ) {
60 60
 
61
-								echo "<small class='text-muted'>&nbsp;";
62
-								printf(
63
-									esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
64
-									esc_html( $subscription->get_trial_period() )
65
-								);
66
-								echo '</small>';
61
+								        echo "<small class='text-muted'>&nbsp;";
62
+								        printf(
63
+									        esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
64
+									        esc_html( $subscription->get_trial_period() )
65
+								        );
66
+								        echo '</small>';
67 67
 
68
-							}
68
+							        }
69 69
 
70
-							break;
70
+							        break;
71 71
 
72
-						case 'recurring_amount':
73
-							$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
74
-							$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
75
-							echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
76
-							break;
72
+						        case 'recurring_amount':
73
+							        $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
74
+							        $amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
75
+							        echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
76
+							        break;
77 77
 
78
-						case 'item':
79
-							if ( empty( $subscription_group ) ) {
80
-								echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
81
-							} else {
82
-								$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
83
-								echo wp_kses_post( implode( ' | ', $markup ) );
84
-							}
78
+						        case 'item':
79
+							        if ( empty( $subscription_group ) ) {
80
+								        echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
81
+							        } else {
82
+								        $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
83
+								        echo wp_kses_post( implode( ' | ', $markup ) );
84
+							        }
85 85
 
86
-							break;
86
+							        break;
87 87
 
88
-						case 'payments':
89
-							$max_activations = (int) $subscription->get_bill_times();
90
-							echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
88
+						        case 'payments':
89
+							        $max_activations = (int) $subscription->get_bill_times();
90
+							        echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
91 91
 
92
-							break;
92
+							        break;
93 93
 
94
-						}
94
+						    }
95 95
 						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
96 96
 
97 97
 					?>
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -10,58 +10,58 @@  discard block
 block discarded – undo
10 10
  * @var WPInv_Subscriptions_Widget $widget
11 11
  */
12 12
 
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15
-do_action( 'getpaid_single_subscription_before_notices', $subscription );
15
+do_action('getpaid_single_subscription_before_notices', $subscription);
16 16
 
17 17
 // Display errors and notices.
18 18
 wpinv_print_errors();
19 19
 
20
-$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() );
21
-$subscription_group  = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() );
20
+$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_invoice_id());
21
+$subscription_group  = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id());
22 22
 
23
-do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups );
23
+do_action('getpaid_before_single_subscription', $subscription, $subscription_groups);
24 24
 
25 25
 ?>
26 26
 
27
-<h2 class="mb-1 h4"><?php esc_html_e( 'Subscription Details', 'invoicing' ); ?></h2>
27
+<h2 class="mb-1 h4"><?php esc_html_e('Subscription Details', 'invoicing'); ?></h2>
28 28
 <table class="table table-bordered">
29 29
 	<tbody>
30 30
 
31
-		<?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?>
31
+		<?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?>
32 32
 
33
-			<tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>">
33
+			<tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>">
34 34
 
35 35
 				<th class="font-weight-bold" style="width: 35%">
36
-					<?php echo esc_html( $label ); ?>
36
+					<?php echo esc_html($label); ?>
37 37
 				</th>
38 38
 
39 39
 				<td style="width: 65%">
40 40
 					<?php
41 41
 
42
-						switch ( $key ) {
42
+						switch ($key) {
43 43
 
44 44
 						case 'status':
45
-							echo esc_html( $subscription->get_status_label() );
45
+							echo esc_html($subscription->get_status_label());
46 46
 							break;
47 47
 
48 48
 						case 'start_date':
49
-							echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
49
+							echo esc_html(getpaid_format_date_value($subscription->get_date_created()));
50 50
 							break;
51 51
 
52 52
 						case 'expiry_date':
53
-							echo esc_html( getpaid_format_date_value( $subscription->get_next_renewal_date() ) );
53
+							echo esc_html(getpaid_format_date_value($subscription->get_next_renewal_date()));
54 54
 							break;
55 55
 
56 56
 						case 'initial_amount':
57
-							echo wp_kses_post( wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ) );
57
+							echo wp_kses_post(wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()));
58 58
 
59
-							if ( $subscription->has_trial_period() ) {
59
+							if ($subscription->has_trial_period()) {
60 60
 
61 61
 								echo "<small class='text-muted'>&nbsp;";
62 62
 								printf(
63
-									esc_html_x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ),
64
-									esc_html( $subscription->get_trial_period() )
63
+									esc_html_x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'),
64
+									esc_html($subscription->get_trial_period())
65 65
 								);
66 66
 								echo '</small>';
67 67
 
@@ -70,29 +70,29 @@  discard block
 block discarded – undo
70 70
 							break;
71 71
 
72 72
 						case 'recurring_amount':
73
-							$frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
74
-							$amount    = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
75
-							echo wp_kses_post( strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ) );
73
+							$frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), '');
74
+							$amount    = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency());
75
+							echo wp_kses_post(strtolower("<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>"));
76 76
 							break;
77 77
 
78 78
 						case 'item':
79
-							if ( empty( $subscription_group ) ) {
80
-								echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
79
+							if (empty($subscription_group)) {
80
+								echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()));
81 81
 							} else {
82
-								$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
83
-								echo wp_kses_post( implode( ' | ', $markup ) );
82
+								$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
83
+								echo wp_kses_post(implode(' | ', $markup));
84 84
 							}
85 85
 
86 86
 							break;
87 87
 
88 88
 						case 'payments':
89 89
 							$max_activations = (int) $subscription->get_bill_times();
90
-							echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_activations ) ? '&infin;' : (int) $max_activations );
90
+							echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_activations) ? '&infin;' : (int) $max_activations);
91 91
 
92 92
 							break;
93 93
 
94 94
 						}
95
-						do_action( "getpaid_render_single_subscription_column_$key", $subscription );
95
+						do_action("getpaid_render_single_subscription_column_$key", $subscription);
96 96
 
97 97
 					?>
98 98
 				</td>
@@ -104,34 +104,34 @@  discard block
 block discarded – undo
104 104
 	</tbody>
105 105
 </table>
106 106
 
107
-<?php if ( ! empty( $subscription_group ) ) : ?>
108
-	<h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Subscription Items', 'invoicing' ); ?></h2>
109
-	<?php getpaid_admin_subscription_item_details_metabox( $subscription ); ?>
107
+<?php if (!empty($subscription_group)) : ?>
108
+	<h2 class='mt-5 mb-1 h4'><?php esc_html_e('Subscription Items', 'invoicing'); ?></h2>
109
+	<?php getpaid_admin_subscription_item_details_metabox($subscription); ?>
110 110
 <?php endif; ?>
111 111
 
112
-<h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Related Invoices', 'invoicing' ); ?></h2>
112
+<h2 class='mt-5 mb-1 h4'><?php esc_html_e('Related Invoices', 'invoicing'); ?></h2>
113 113
 
114
-<?php echo wp_kses_post( getpaid_admin_subscription_invoice_details_metabox( $subscription ) ); ?>
114
+<?php echo wp_kses_post(getpaid_admin_subscription_invoice_details_metabox($subscription)); ?>
115 115
 
116
-<?php if ( 1 < count( $subscription_groups ) ) : ?>
117
-	<h2 class='mt-5 mb-1 h4'><?php esc_html_e( 'Related Subscriptions', 'invoicing' ); ?></h2>
118
-	<?php getpaid_admin_subscription_related_subscriptions_metabox( $subscription ); ?>
116
+<?php if (1 < count($subscription_groups)) : ?>
117
+	<h2 class='mt-5 mb-1 h4'><?php esc_html_e('Related Subscriptions', 'invoicing'); ?></h2>
118
+	<?php getpaid_admin_subscription_related_subscriptions_metabox($subscription); ?>
119 119
 <?php endif; ?>
120 120
 
121 121
 <span class="form-text">
122 122
 
123 123
 	<?php
124
-		if ( $subscription->can_cancel() ) {
124
+		if ($subscription->can_cancel()) {
125 125
 		printf(
126 126
             '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a>&nbsp;&nbsp;',
127
-            esc_url( $subscription->get_cancel_url() ),
128
-            esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ),
129
-            esc_html__( 'Cancel Subscription', 'invoicing' )
127
+            esc_url($subscription->get_cancel_url()),
128
+            esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'),
129
+            esc_html__('Cancel Subscription', 'invoicing')
130 130
         );
131 131
 		}
132 132
 
133
-		do_action( 'getpaid-single-subscription-page-actions', $subscription );
133
+		do_action('getpaid-single-subscription-page-actions', $subscription);
134 134
 	?>
135 135
 
136
-	<a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php esc_html_e( 'Go Back', 'invoicing' ); ?></a>
136
+	<a href="<?php echo esc_url(getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')))); ?>" class="btn btn-secondary btn-sm"><?php esc_html_e('Go Back', 'invoicing'); ?></a>
137 137
 </span>
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 2 patches
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -16,85 +16,85 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Address {
18 18
 
19
-	/**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
24
-	public static function output( $post ) {
25
-
26
-		// Prepare the invoice.
27
-		$invoice  = new WPInv_Invoice( $post );
28
-		$customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-		$customer = new WP_User( $customer );
30
-		$display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-		wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
32
-
33
-		// Address fields.
34
-		$address_fields = array(
35
-			'first_name' => array(
36
-				'label' => __( 'First Name', 'invoicing' ),
37
-				'type'  => 'text',
38
-			),
39
-			'last_name'  => array(
40
-				'label' => __( 'Last Name', 'invoicing' ),
41
-				'type'  => 'text',
42
-			),
43
-			'company'    => array(
44
-				'label' => __( 'Company', 'invoicing' ),
45
-				'type'  => 'text',
46
-				'class' => 'getpaid-recalculate-prices-on-change',
47
-			),
48
-			'vat_number' => array(
49
-				'label' => __( 'VAT Number', 'invoicing' ),
50
-				'type'  => 'text',
51
-				'class' => 'getpaid-recalculate-prices-on-change',
52
-			),
53
-			'address'    => array(
54
-				'label' => __( 'Address', 'invoicing' ),
55
-				'type'  => 'text',
56
-			),
57
-			'city'       => array(
58
-				'label' => __( 'City', 'invoicing' ),
59
-				'type'  => 'text',
60
-			),
61
-			'country'    => array(
62
-				'label'       => __( 'Country', 'invoicing' ),
63
-				'type'        => 'select',
64
-				'class'       => 'getpaid-recalculate-prices-on-change',
65
-				'options'     => wpinv_get_country_list(),
66
-				'placeholder' => __( 'Choose a country', 'invoicing' ),
67
-			),
68
-			'state'      => array(
69
-				'label' => __( 'State', 'invoicing' ),
70
-				'type'  => 'text',
71
-				'class' => 'getpaid-recalculate-prices-on-change',
72
-			),
73
-			'zip'        => array(
74
-				'label' => __( 'Zip', 'invoicing' ),
75
-				'type'  => 'text',
76
-			),
77
-			'phone'      => array(
78
-				'label' => __( 'Phone', 'invoicing' ),
79
-				'type'  => 'text',
80
-			),
81
-		);
82
-
83
-		$states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
84
-
85
-		if ( ! empty( $states ) ) {
86
-			$address_fields['state']['type']        = 'select';
87
-			$address_fields['state']['options']     = $states;
88
-			$address_fields['state']['placeholder'] = __( 'Choose a state', 'invoicing' );
89
-		}
90
-
91
-		// Maybe remove the VAT field.
92
-		if ( ! wpinv_use_taxes() ) {
93
-			unset( $address_fields['vat_number'] );
94
-		}
95
-
96
-		$address_fields = apply_filters( 'getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice );
97
-		?>
19
+    /**
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24
+    public static function output( $post ) {
25
+
26
+        // Prepare the invoice.
27
+        $invoice  = new WPInv_Invoice( $post );
28
+        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
+        $customer = new WP_User( $customer );
30
+        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
+        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
32
+
33
+        // Address fields.
34
+        $address_fields = array(
35
+            'first_name' => array(
36
+                'label' => __( 'First Name', 'invoicing' ),
37
+                'type'  => 'text',
38
+            ),
39
+            'last_name'  => array(
40
+                'label' => __( 'Last Name', 'invoicing' ),
41
+                'type'  => 'text',
42
+            ),
43
+            'company'    => array(
44
+                'label' => __( 'Company', 'invoicing' ),
45
+                'type'  => 'text',
46
+                'class' => 'getpaid-recalculate-prices-on-change',
47
+            ),
48
+            'vat_number' => array(
49
+                'label' => __( 'VAT Number', 'invoicing' ),
50
+                'type'  => 'text',
51
+                'class' => 'getpaid-recalculate-prices-on-change',
52
+            ),
53
+            'address'    => array(
54
+                'label' => __( 'Address', 'invoicing' ),
55
+                'type'  => 'text',
56
+            ),
57
+            'city'       => array(
58
+                'label' => __( 'City', 'invoicing' ),
59
+                'type'  => 'text',
60
+            ),
61
+            'country'    => array(
62
+                'label'       => __( 'Country', 'invoicing' ),
63
+                'type'        => 'select',
64
+                'class'       => 'getpaid-recalculate-prices-on-change',
65
+                'options'     => wpinv_get_country_list(),
66
+                'placeholder' => __( 'Choose a country', 'invoicing' ),
67
+            ),
68
+            'state'      => array(
69
+                'label' => __( 'State', 'invoicing' ),
70
+                'type'  => 'text',
71
+                'class' => 'getpaid-recalculate-prices-on-change',
72
+            ),
73
+            'zip'        => array(
74
+                'label' => __( 'Zip', 'invoicing' ),
75
+                'type'  => 'text',
76
+            ),
77
+            'phone'      => array(
78
+                'label' => __( 'Phone', 'invoicing' ),
79
+                'type'  => 'text',
80
+            ),
81
+        );
82
+
83
+        $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
84
+
85
+        if ( ! empty( $states ) ) {
86
+            $address_fields['state']['type']        = 'select';
87
+            $address_fields['state']['options']     = $states;
88
+            $address_fields['state']['placeholder'] = __( 'Choose a state', 'invoicing' );
89
+        }
90
+
91
+        // Maybe remove the VAT field.
92
+        if ( ! wpinv_use_taxes() ) {
93
+            unset( $address_fields['vat_number'] );
94
+        }
95
+
96
+        $address_fields = apply_filters( 'getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice );
97
+        ?>
98 98
 
99 99
 		<style>
100 100
 			#wpinv-address label {
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 							<div id="getpaid-invoice-email-wrapper" class="d-none">
120 120
 								<input type="hidden" id="getpaid-invoice-create-new-user" name="wpinv_new_user" value="" />
121 121
 								<?php
122
-									aui()->input(
123
-										array(
124
-											'type'        => 'text',
125
-											'id'          => 'getpaid-invoice-new-user-email',
126
-											'name'        => 'wpinv_email',
127
-											'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
128
-											'label_type'  => 'vertical',
129
-											'placeholder' => '[email protected]',
130
-											'class'       => 'form-control-sm',
131
-										),
132
-										true
133
-									);
134
-								?>
122
+                                    aui()->input(
123
+                                        array(
124
+                                            'type'        => 'text',
125
+                                            'id'          => 'getpaid-invoice-new-user-email',
126
+                                            'name'        => 'wpinv_email',
127
+                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
128
+                                            'label_type'  => 'vertical',
129
+                                            'placeholder' => '[email protected]',
130
+                                            'class'       => 'form-control-sm',
131
+                                        ),
132
+                                        true
133
+                                    );
134
+                                ?>
135 135
 							</div>
136 136
 						</div>
137 137
 						<div class="col-12 col-sm-6 form-group mb-3 mt-sm-4">
@@ -155,39 +155,39 @@  discard block
 block discarded – undo
155 155
 							<div class="col-12 col-sm-6 getpaid-invoice-address-field__<?php echo esc_attr( $key ); ?>--wrapper">
156 156
 								<?php
157 157
 
158
-									if ( 'select' === $field['type'] ) {
159
-										aui()->select(
160
-											array(
161
-												'id'               => 'wpinv_' . $key,
162
-												'name'             => 'wpinv_' . $key,
163
-												'label'            => $field['label'],
164
-												'label_type'       => 'vertical',
165
-												'placeholder'      => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
166
-												'class'            => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
167
-												'value'            => $invoice->get( $key, 'edit' ),
168
-												'options'          => $field['options'],
169
-												'data-allow-clear' => 'false',
170
-												'select2'          => true,
171
-											),
172
-											true
173
-										);
174
-									} else {
175
-										aui()->input(
176
-											array(
177
-												'type'        => $field['type'],
178
-												'id'          => 'wpinv_' . $key,
179
-												'name'        => 'wpinv_' . $key,
180
-												'label'       => $field['label'],
181
-												'label_type'  => 'vertical',
182
-												'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
183
-												'class'       => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
184
-												'value'       => $invoice->get( $key, 'edit' ),
185
-											),
186
-											true
187
-										);
188
-									}
189
-
190
-								?>
158
+                                    if ( 'select' === $field['type'] ) {
159
+                                        aui()->select(
160
+                                            array(
161
+                                                'id'               => 'wpinv_' . $key,
162
+                                                'name'             => 'wpinv_' . $key,
163
+                                                'label'            => $field['label'],
164
+                                                'label_type'       => 'vertical',
165
+                                                'placeholder'      => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
166
+                                                'class'            => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
167
+                                                'value'            => $invoice->get( $key, 'edit' ),
168
+                                                'options'          => $field['options'],
169
+                                                'data-allow-clear' => 'false',
170
+                                                'select2'          => true,
171
+                                            ),
172
+                                            true
173
+                                        );
174
+                                    } else {
175
+                                        aui()->input(
176
+                                            array(
177
+                                                'type'        => $field['type'],
178
+                                                'id'          => 'wpinv_' . $key,
179
+                                                'name'        => 'wpinv_' . $key,
180
+                                                'label'       => $field['label'],
181
+                                                'label_type'  => 'vertical',
182
+                                                'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
183
+                                                'class'       => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
184
+                                                'value'       => $invoice->get( $key, 'edit' ),
185
+                                            ),
186
+                                            true
187
+                                        );
188
+                                    }
189
+
190
+                                ?>
191 191
 							</div>
192 192
 						<?php endforeach; ?>
193 193
 					</div>
@@ -198,48 +198,48 @@  discard block
 block discarded – undo
198 198
 						<div class="row">
199 199
 							<div class="col-12 col-sm-6">
200 200
 								<?php
201
-									aui()->select(
202
-										array(
203
-											'id'          => 'wpinv_template',
204
-											'name'        => 'wpinv_template',
205
-											'label'       => __( 'Template', 'invoicing' ),
206
-											'label_type'  => 'vertical',
207
-											'placeholder' => __( 'Choose a template', 'invoicing' ),
208
-											'class'       => 'form-control-sm',
209
-											'value'       => $invoice->get_template( 'edit' ),
210
-											'options'     => array(
211
-												'quantity' => __( 'Quantity', 'invoicing' ),
212
-												'hours'    => __( 'Hours', 'invoicing' ),
213
-											),
214
-											'data-allow-clear' => 'false',
215
-											'select2'     => true,
216
-										),
217
-										true
218
-									);
219
-								?>
201
+                                    aui()->select(
202
+                                        array(
203
+                                            'id'          => 'wpinv_template',
204
+                                            'name'        => 'wpinv_template',
205
+                                            'label'       => __( 'Template', 'invoicing' ),
206
+                                            'label_type'  => 'vertical',
207
+                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
208
+                                            'class'       => 'form-control-sm',
209
+                                            'value'       => $invoice->get_template( 'edit' ),
210
+                                            'options'     => array(
211
+                                                'quantity' => __( 'Quantity', 'invoicing' ),
212
+                                                'hours'    => __( 'Hours', 'invoicing' ),
213
+                                            ),
214
+                                            'data-allow-clear' => 'false',
215
+                                            'select2'     => true,
216
+                                        ),
217
+                                        true
218
+                                    );
219
+                                ?>
220 220
 							</div>
221 221
 							<div class="col-12 col-sm-6">
222 222
 								<?php
223 223
 
224
-									// Set currency.
225
-									aui()->select(
226
-										array(
227
-											'id'          => 'wpinv_currency',
228
-											'name'        => 'wpinv_currency',
229
-											'label'       => __( 'Currency', 'invoicing' ),
230
-											'label_type'  => 'vertical',
231
-											'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
232
-											'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
233
-											'value'       => $invoice->get_currency( 'edit' ),
234
-											'required'    => false,
235
-											'data-allow-clear' => 'false',
236
-											'select2'     => true,
237
-											'options'     => wpinv_get_currencies(),
238
-										),
239
-										true
240
-									);
241
-
242
-								?>
224
+                                    // Set currency.
225
+                                    aui()->select(
226
+                                        array(
227
+                                            'id'          => 'wpinv_currency',
228
+                                            'name'        => 'wpinv_currency',
229
+                                            'label'       => __( 'Currency', 'invoicing' ),
230
+                                            'label_type'  => 'vertical',
231
+                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
232
+                                            'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
233
+                                            'value'       => $invoice->get_currency( 'edit' ),
234
+                                            'required'    => false,
235
+                                            'data-allow-clear' => 'false',
236
+                                            'select2'     => true,
237
+                                            'options'     => wpinv_get_currencies(),
238
+                                        ),
239
+                                        true
240
+                                    );
241
+
242
+                                ?>
243 243
 							</div>
244 244
 						</div>
245 245
 
@@ -249,123 +249,123 @@  discard block
 block discarded – undo
249 249
 					<div class="row">
250 250
 						<div class="col-12 col-sm-6">
251 251
 							<?php
252
-								aui()->input(
253
-									array(
254
-										'type'        => 'text',
255
-										'id'          => 'wpinv_company_id',
256
-										'name'        => 'wpinv_company_id',
257
-										'label'       => __( 'Company ID', 'invoicing' ),
258
-										'label_type'  => 'vertical',
259
-										'placeholder' => '',
260
-										'class'       => 'form-control-sm',
261
-										'value'       => $invoice->get_company_id( 'edit' ),
262
-									),
263
-									true
264
-								);
265
-							?>
252
+                                aui()->input(
253
+                                    array(
254
+                                        'type'        => 'text',
255
+                                        'id'          => 'wpinv_company_id',
256
+                                        'name'        => 'wpinv_company_id',
257
+                                        'label'       => __( 'Company ID', 'invoicing' ),
258
+                                        'label_type'  => 'vertical',
259
+                                        'placeholder' => '',
260
+                                        'class'       => 'form-control-sm',
261
+                                        'value'       => $invoice->get_company_id( 'edit' ),
262
+                                    ),
263
+                                    true
264
+                                );
265
+                            ?>
266 266
 						</div>
267 267
 					</div>
268 268
 
269 269
 					<?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
270 270
 			</div>
271 271
 		<?php
272
-	}
273
-
274
-	/**
275
-	 * Save meta box data.
276
-	 *
277
-	 * @param int $post_id
278
-	 * @param array $posted the posted data.
279
-	 */
280
-	public static function save( $post_id, $posted ) {
281
-
282
-		// Prepare the invoice.
283
-		$invoice = new WPInv_Invoice( $post_id );
284
-
285
-		// Load new data.
286
-		$invoice->set_props(
287
-			array(
288
-				'template'       => isset( $posted['wpinv_template'] ) ? wpinv_clean( $posted['wpinv_template'] ) : null,
289
-				'email_cc'       => isset( $posted['wpinv_cc'] ) ? wpinv_clean( $posted['wpinv_cc'] ) : null,
290
-				'disable_taxes'  => ! empty( $posted['disable_taxes'] ),
291
-				'currency'       => isset( $posted['wpinv_currency'] ) ? wpinv_clean( $posted['wpinv_currency'] ) : null,
292
-				'gateway'        => ( $invoice->needs_payment() && isset( $posted['wpinv_gateway'] ) ) ? wpinv_clean( $posted['wpinv_gateway'] ) : null,
293
-				'address'        => isset( $posted['wpinv_address'] ) ? wpinv_clean( $posted['wpinv_address'] ) : null,
294
-				'vat_number'     => isset( $posted['wpinv_vat_number'] ) ? wpinv_clean( $posted['wpinv_vat_number'] ) : null,
295
-				'company'        => isset( $posted['wpinv_company'] ) ? wpinv_clean( $posted['wpinv_company'] ) : null,
296
-				'company_id'     => isset( $posted['wpinv_company_id'] ) ? wpinv_clean( $posted['wpinv_company_id'] ) : null,
297
-				'zip'            => isset( $posted['wpinv_zip'] ) ? wpinv_clean( $posted['wpinv_zip'] ) : null,
298
-				'state'          => isset( $posted['wpinv_state'] ) ? wpinv_clean( $posted['wpinv_state'] ) : null,
299
-				'city'           => isset( $posted['wpinv_city'] ) ? wpinv_clean( $posted['wpinv_city'] ) : null,
300
-				'country'        => isset( $posted['wpinv_country'] ) ? wpinv_clean( $posted['wpinv_country'] ) : null,
301
-				'phone'          => isset( $posted['wpinv_phone'] ) ? wpinv_clean( $posted['wpinv_phone'] ) : null,
302
-				'first_name'     => isset( $posted['wpinv_first_name'] ) ? wpinv_clean( $posted['wpinv_first_name'] ) : null,
303
-				'last_name'      => isset( $posted['wpinv_last_name'] ) ? wpinv_clean( $posted['wpinv_last_name'] ) : null,
304
-				'author'         => isset( $posted['post_author_override'] ) ? wpinv_clean( $posted['post_author_override'] ) : null,
305
-				'date_created'   => isset( $posted['date_created'] ) ? wpinv_clean( $posted['date_created'] ) : null,
306
-				'date_completed' => isset( $posted['wpinv_date_completed'] ) ? wpinv_clean( $posted['wpinv_date_completed'] ) : null,
307
-				'due_date'       => isset( $posted['wpinv_due_date'] ) ? wpinv_clean( $posted['wpinv_due_date'] ) : null,
308
-				'number'         => isset( $posted['wpinv_number'] ) ? wpinv_clean( $posted['wpinv_number'] ) : null,
309
-				'status'         => isset( $posted['wpinv_status'] ) ? wpinv_clean( $posted['wpinv_status'] ) : null,
310
-			)
311
-		);
312
-
313
-		// Discount code.
314
-		if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
315
-
316
-			if ( isset( $posted['wpinv_discount_code'] ) ) {
317
-				$invoice->set_discount_code( wpinv_clean( $posted['wpinv_discount_code'] ) );
318
-			}
319
-
320
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
321
-			if ( $discount->exists() ) {
322
-				$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
323
-			} else {
324
-				$invoice->remove_discount( 'discount_code' );
325
-			}
326
-
327
-			// Recalculate totals.
328
-			$invoice->recalculate_total();
329
-
330
-		}
331
-
332
-		// If we're creating a new user...
333
-		if ( ! empty( $posted['wpinv_new_user'] ) && is_email( stripslashes( $posted['wpinv_email'] ) ) ) {
334
-
335
-			// Attempt to create the user.
336
-			$user = wpinv_create_user( sanitize_email( stripslashes( $posted['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() );
337
-
338
-			// If successful, update the invoice author.
339
-			if ( is_numeric( $user ) ) {
340
-				$invoice->set_author( $user );
341
-			} else {
342
-				wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
343
-			}
344
-		}
345
-
346
-		// Do not send new invoice notifications.
347
-		$GLOBALS['wpinv_skip_invoice_notification'] = true;
348
-
349
-		// Save the invoice.
350
-		$invoice->save();
351
-
352
-		// Save the user address.
353
-		getpaid_save_invoice_user_address( $invoice );
354
-
355
-		// Undo do not send new invoice notifications.
356
-		$GLOBALS['wpinv_skip_invoice_notification'] = false;
357
-
358
-		// (Maybe) send new user notification.
359
-		$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
360
-		if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
361
-			wp_send_new_user_notifications( $user, 'user' );
362
-		}
363
-
364
-		if ( ! empty( $posted['send_to_customer'] ) && ! $invoice->is_draft() ) {
365
-			getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
366
-		}
367
-
368
-		// Fires after an invoice is saved.
369
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
370
-	}
272
+    }
273
+
274
+    /**
275
+     * Save meta box data.
276
+     *
277
+     * @param int $post_id
278
+     * @param array $posted the posted data.
279
+     */
280
+    public static function save( $post_id, $posted ) {
281
+
282
+        // Prepare the invoice.
283
+        $invoice = new WPInv_Invoice( $post_id );
284
+
285
+        // Load new data.
286
+        $invoice->set_props(
287
+            array(
288
+                'template'       => isset( $posted['wpinv_template'] ) ? wpinv_clean( $posted['wpinv_template'] ) : null,
289
+                'email_cc'       => isset( $posted['wpinv_cc'] ) ? wpinv_clean( $posted['wpinv_cc'] ) : null,
290
+                'disable_taxes'  => ! empty( $posted['disable_taxes'] ),
291
+                'currency'       => isset( $posted['wpinv_currency'] ) ? wpinv_clean( $posted['wpinv_currency'] ) : null,
292
+                'gateway'        => ( $invoice->needs_payment() && isset( $posted['wpinv_gateway'] ) ) ? wpinv_clean( $posted['wpinv_gateway'] ) : null,
293
+                'address'        => isset( $posted['wpinv_address'] ) ? wpinv_clean( $posted['wpinv_address'] ) : null,
294
+                'vat_number'     => isset( $posted['wpinv_vat_number'] ) ? wpinv_clean( $posted['wpinv_vat_number'] ) : null,
295
+                'company'        => isset( $posted['wpinv_company'] ) ? wpinv_clean( $posted['wpinv_company'] ) : null,
296
+                'company_id'     => isset( $posted['wpinv_company_id'] ) ? wpinv_clean( $posted['wpinv_company_id'] ) : null,
297
+                'zip'            => isset( $posted['wpinv_zip'] ) ? wpinv_clean( $posted['wpinv_zip'] ) : null,
298
+                'state'          => isset( $posted['wpinv_state'] ) ? wpinv_clean( $posted['wpinv_state'] ) : null,
299
+                'city'           => isset( $posted['wpinv_city'] ) ? wpinv_clean( $posted['wpinv_city'] ) : null,
300
+                'country'        => isset( $posted['wpinv_country'] ) ? wpinv_clean( $posted['wpinv_country'] ) : null,
301
+                'phone'          => isset( $posted['wpinv_phone'] ) ? wpinv_clean( $posted['wpinv_phone'] ) : null,
302
+                'first_name'     => isset( $posted['wpinv_first_name'] ) ? wpinv_clean( $posted['wpinv_first_name'] ) : null,
303
+                'last_name'      => isset( $posted['wpinv_last_name'] ) ? wpinv_clean( $posted['wpinv_last_name'] ) : null,
304
+                'author'         => isset( $posted['post_author_override'] ) ? wpinv_clean( $posted['post_author_override'] ) : null,
305
+                'date_created'   => isset( $posted['date_created'] ) ? wpinv_clean( $posted['date_created'] ) : null,
306
+                'date_completed' => isset( $posted['wpinv_date_completed'] ) ? wpinv_clean( $posted['wpinv_date_completed'] ) : null,
307
+                'due_date'       => isset( $posted['wpinv_due_date'] ) ? wpinv_clean( $posted['wpinv_due_date'] ) : null,
308
+                'number'         => isset( $posted['wpinv_number'] ) ? wpinv_clean( $posted['wpinv_number'] ) : null,
309
+                'status'         => isset( $posted['wpinv_status'] ) ? wpinv_clean( $posted['wpinv_status'] ) : null,
310
+            )
311
+        );
312
+
313
+        // Discount code.
314
+        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
315
+
316
+            if ( isset( $posted['wpinv_discount_code'] ) ) {
317
+                $invoice->set_discount_code( wpinv_clean( $posted['wpinv_discount_code'] ) );
318
+            }
319
+
320
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
321
+            if ( $discount->exists() ) {
322
+                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
323
+            } else {
324
+                $invoice->remove_discount( 'discount_code' );
325
+            }
326
+
327
+            // Recalculate totals.
328
+            $invoice->recalculate_total();
329
+
330
+        }
331
+
332
+        // If we're creating a new user...
333
+        if ( ! empty( $posted['wpinv_new_user'] ) && is_email( stripslashes( $posted['wpinv_email'] ) ) ) {
334
+
335
+            // Attempt to create the user.
336
+            $user = wpinv_create_user( sanitize_email( stripslashes( $posted['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() );
337
+
338
+            // If successful, update the invoice author.
339
+            if ( is_numeric( $user ) ) {
340
+                $invoice->set_author( $user );
341
+            } else {
342
+                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
343
+            }
344
+        }
345
+
346
+        // Do not send new invoice notifications.
347
+        $GLOBALS['wpinv_skip_invoice_notification'] = true;
348
+
349
+        // Save the invoice.
350
+        $invoice->save();
351
+
352
+        // Save the user address.
353
+        getpaid_save_invoice_user_address( $invoice );
354
+
355
+        // Undo do not send new invoice notifications.
356
+        $GLOBALS['wpinv_skip_invoice_notification'] = false;
357
+
358
+        // (Maybe) send new user notification.
359
+        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
360
+        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
361
+            wp_send_new_user_notifications( $user, 'user' );
362
+        }
363
+
364
+        if ( ! empty( $posted['send_to_customer'] ) && ! $invoice->is_draft() ) {
365
+            getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
366
+        }
367
+
368
+        // Fires after an invoice is saved.
369
+        do_action( 'wpinv_invoice_metabox_saved', $invoice );
370
+    }
371 371
 }
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,79 +21,79 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-	public static function output( $post ) {
24
+	public static function output($post) {
25 25
 
26 26
 		// Prepare the invoice.
27
-		$invoice  = new WPInv_Invoice( $post );
28
-		$customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-		$customer = new WP_User( $customer );
30
-		$display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-		wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+		$invoice  = new WPInv_Invoice($post);
28
+		$customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+		$customer = new WP_User($customer);
30
+		$display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+		wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
 		// Address fields.
34 34
 		$address_fields = array(
35 35
 			'first_name' => array(
36
-				'label' => __( 'First Name', 'invoicing' ),
36
+				'label' => __('First Name', 'invoicing'),
37 37
 				'type'  => 'text',
38 38
 			),
39 39
 			'last_name'  => array(
40
-				'label' => __( 'Last Name', 'invoicing' ),
40
+				'label' => __('Last Name', 'invoicing'),
41 41
 				'type'  => 'text',
42 42
 			),
43 43
 			'company'    => array(
44
-				'label' => __( 'Company', 'invoicing' ),
44
+				'label' => __('Company', 'invoicing'),
45 45
 				'type'  => 'text',
46 46
 				'class' => 'getpaid-recalculate-prices-on-change',
47 47
 			),
48 48
 			'vat_number' => array(
49
-				'label' => __( 'VAT Number', 'invoicing' ),
49
+				'label' => __('VAT Number', 'invoicing'),
50 50
 				'type'  => 'text',
51 51
 				'class' => 'getpaid-recalculate-prices-on-change',
52 52
 			),
53 53
 			'address'    => array(
54
-				'label' => __( 'Address', 'invoicing' ),
54
+				'label' => __('Address', 'invoicing'),
55 55
 				'type'  => 'text',
56 56
 			),
57 57
 			'city'       => array(
58
-				'label' => __( 'City', 'invoicing' ),
58
+				'label' => __('City', 'invoicing'),
59 59
 				'type'  => 'text',
60 60
 			),
61 61
 			'country'    => array(
62
-				'label'       => __( 'Country', 'invoicing' ),
62
+				'label'       => __('Country', 'invoicing'),
63 63
 				'type'        => 'select',
64 64
 				'class'       => 'getpaid-recalculate-prices-on-change',
65 65
 				'options'     => wpinv_get_country_list(),
66
-				'placeholder' => __( 'Choose a country', 'invoicing' ),
66
+				'placeholder' => __('Choose a country', 'invoicing'),
67 67
 			),
68 68
 			'state'      => array(
69
-				'label' => __( 'State', 'invoicing' ),
69
+				'label' => __('State', 'invoicing'),
70 70
 				'type'  => 'text',
71 71
 				'class' => 'getpaid-recalculate-prices-on-change',
72 72
 			),
73 73
 			'zip'        => array(
74
-				'label' => __( 'Zip', 'invoicing' ),
74
+				'label' => __('Zip', 'invoicing'),
75 75
 				'type'  => 'text',
76 76
 			),
77 77
 			'phone'      => array(
78
-				'label' => __( 'Phone', 'invoicing' ),
78
+				'label' => __('Phone', 'invoicing'),
79 79
 				'type'  => 'text',
80 80
 			),
81 81
 		);
82 82
 
83
-		$states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
83
+		$states = wpinv_get_country_states($invoice->get_country('edit'));
84 84
 
85
-		if ( ! empty( $states ) ) {
85
+		if (!empty($states)) {
86 86
 			$address_fields['state']['type']        = 'select';
87 87
 			$address_fields['state']['options']     = $states;
88
-			$address_fields['state']['placeholder'] = __( 'Choose a state', 'invoicing' );
88
+			$address_fields['state']['placeholder'] = __('Choose a state', 'invoicing');
89 89
 		}
90 90
 
91 91
 		// Maybe remove the VAT field.
92
-		if ( ! wpinv_use_taxes() ) {
93
-			unset( $address_fields['vat_number'] );
92
+		if (!wpinv_use_taxes()) {
93
+			unset($address_fields['vat_number']);
94 94
 		}
95 95
 
96
-		$address_fields = apply_filters( 'getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice );
96
+		$address_fields = apply_filters('getpaid_admin_edit_invoice_address_fields', $address_fields, $invoice);
97 97
 		?>
98 98
 
99 99
 		<style>
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 						<div class="col-12 col-sm-6">
108 108
 							<div id="getpaid-invoice-user-id-wrapper" class="form-group mb-3">
109 109
 								<div>
110
-									<label for="post_author_override"><?php esc_html_e( 'Customer', 'invoicing' ); ?></label>
110
+									<label for="post_author_override"><?php esc_html_e('Customer', 'invoicing'); ?></label>
111 111
 								</div>
112 112
 								<div>
113
-									<select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
114
-										<option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>)
113
+									<select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
114
+										<option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>)
115 115
 									</select>
116 116
 								</div>
117 117
 							</div>
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 											'type'        => 'text',
125 125
 											'id'          => 'getpaid-invoice-new-user-email',
126 126
 											'name'        => 'wpinv_email',
127
-											'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
127
+											'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
128 128
 											'label_type'  => 'vertical',
129 129
 											'placeholder' => '[email protected]',
130 130
 											'class'       => 'form-control-sm',
@@ -135,36 +135,36 @@  discard block
 block discarded – undo
135 135
 							</div>
136 136
 						</div>
137 137
 						<div class="col-12 col-sm-6 form-group mb-3 mt-sm-4">
138
-							<?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
138
+							<?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
139 139
 								<a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
140 140
 									<i aria-hidden="true" class="fa fa-refresh"></i>
141
-									<?php esc_html_e( 'Fill User Details', 'invoicing' ); ?>
141
+									<?php esc_html_e('Fill User Details', 'invoicing'); ?>
142 142
 								</a>
143 143
 								<a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
144 144
 									<i aria-hidden="true" class="fa fa-plus"></i>
145
-									<?php esc_html_e( 'Add New User', 'invoicing' ); ?>
145
+									<?php esc_html_e('Add New User', 'invoicing'); ?>
146 146
 								</a>
147 147
 								<a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
148 148
 									<i aria-hidden="true" class="fa fa-close"></i>
149
-									<?php esc_html_e( 'Cancel', 'invoicing' ); ?>
149
+									<?php esc_html_e('Cancel', 'invoicing'); ?>
150 150
 								</a>
151 151
 							<?php endif; ?>
152 152
 						</div>
153 153
 
154
-						<?php foreach ( $address_fields as $key => $field ) : ?>
155
-							<div class="col-12 col-sm-6 getpaid-invoice-address-field__<?php echo esc_attr( $key ); ?>--wrapper">
154
+						<?php foreach ($address_fields as $key => $field) : ?>
155
+							<div class="col-12 col-sm-6 getpaid-invoice-address-field__<?php echo esc_attr($key); ?>--wrapper">
156 156
 								<?php
157 157
 
158
-									if ( 'select' === $field['type'] ) {
158
+									if ('select' === $field['type']) {
159 159
 										aui()->select(
160 160
 											array(
161 161
 												'id'               => 'wpinv_' . $key,
162 162
 												'name'             => 'wpinv_' . $key,
163 163
 												'label'            => $field['label'],
164 164
 												'label_type'       => 'vertical',
165
-												'placeholder'      => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
166
-												'class'            => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
167
-												'value'            => $invoice->get( $key, 'edit' ),
165
+												'placeholder'      => isset($field['placeholder']) ? $field['placeholder'] : '',
166
+												'class'            => 'form-control-sm ' . (isset($field['class']) ? $field['class'] : ''),
167
+												'value'            => $invoice->get($key, 'edit'),
168 168
 												'options'          => $field['options'],
169 169
 												'data-allow-clear' => 'false',
170 170
 												'select2'          => true,
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 												'name'        => 'wpinv_' . $key,
180 180
 												'label'       => $field['label'],
181 181
 												'label_type'  => 'vertical',
182
-												'placeholder' => isset( $field['placeholder'] ) ? $field['placeholder'] : '',
183
-												'class'       => 'form-control-sm ' . ( isset( $field['class'] ) ? $field['class'] : '' ),
184
-												'value'       => $invoice->get( $key, 'edit' ),
182
+												'placeholder' => isset($field['placeholder']) ? $field['placeholder'] : '',
183
+												'class'       => 'form-control-sm ' . (isset($field['class']) ? $field['class'] : ''),
184
+												'value'       => $invoice->get($key, 'edit'),
185 185
 											),
186 186
 											true
187 187
 										);
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 						<?php endforeach; ?>
193 193
 					</div>
194 194
 
195
-					<?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?>
196
-						<?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
195
+					<?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?>
196
+						<?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
197 197
 
198 198
 						<div class="row">
199 199
 							<div class="col-12 col-sm-6">
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 										array(
203 203
 											'id'          => 'wpinv_template',
204 204
 											'name'        => 'wpinv_template',
205
-											'label'       => __( 'Template', 'invoicing' ),
205
+											'label'       => __('Template', 'invoicing'),
206 206
 											'label_type'  => 'vertical',
207
-											'placeholder' => __( 'Choose a template', 'invoicing' ),
207
+											'placeholder' => __('Choose a template', 'invoicing'),
208 208
 											'class'       => 'form-control-sm',
209
-											'value'       => $invoice->get_template( 'edit' ),
209
+											'value'       => $invoice->get_template('edit'),
210 210
 											'options'     => array(
211
-												'quantity' => __( 'Quantity', 'invoicing' ),
212
-												'hours'    => __( 'Hours', 'invoicing' ),
211
+												'quantity' => __('Quantity', 'invoicing'),
212
+												'hours'    => __('Hours', 'invoicing'),
213 213
 											),
214 214
 											'data-allow-clear' => 'false',
215 215
 											'select2'     => true,
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
 										array(
227 227
 											'id'          => 'wpinv_currency',
228 228
 											'name'        => 'wpinv_currency',
229
-											'label'       => __( 'Currency', 'invoicing' ),
229
+											'label'       => __('Currency', 'invoicing'),
230 230
 											'label_type'  => 'vertical',
231
-											'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
231
+											'placeholder' => __('Select Invoice Currency', 'invoicing'),
232 232
 											'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
233
-											'value'       => $invoice->get_currency( 'edit' ),
233
+											'value'       => $invoice->get_currency('edit'),
234 234
 											'required'    => false,
235 235
 											'data-allow-clear' => 'false',
236 236
 											'select2'     => true,
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 							</div>
244 244
 						</div>
245 245
 
246
-						<?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
246
+						<?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
247 247
 					<?php endif; ?>
248 248
 
249 249
 					<div class="row">
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 										'type'        => 'text',
255 255
 										'id'          => 'wpinv_company_id',
256 256
 										'name'        => 'wpinv_company_id',
257
-										'label'       => __( 'Company ID', 'invoicing' ),
257
+										'label'       => __('Company ID', 'invoicing'),
258 258
 										'label_type'  => 'vertical',
259 259
 										'placeholder' => '',
260 260
 										'class'       => 'form-control-sm',
261
-										'value'       => $invoice->get_company_id( 'edit' ),
261
+										'value'       => $invoice->get_company_id('edit'),
262 262
 									),
263 263
 									true
264 264
 								);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 						</div>
267 267
 					</div>
268 268
 
269
-					<?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
269
+					<?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
270 270
 			</div>
271 271
 		<?php
272 272
 	}
@@ -277,51 +277,51 @@  discard block
 block discarded – undo
277 277
 	 * @param int $post_id
278 278
 	 * @param array $posted the posted data.
279 279
 	 */
280
-	public static function save( $post_id, $posted ) {
280
+	public static function save($post_id, $posted) {
281 281
 
282 282
 		// Prepare the invoice.
283
-		$invoice = new WPInv_Invoice( $post_id );
283
+		$invoice = new WPInv_Invoice($post_id);
284 284
 
285 285
 		// Load new data.
286 286
 		$invoice->set_props(
287 287
 			array(
288
-				'template'       => isset( $posted['wpinv_template'] ) ? wpinv_clean( $posted['wpinv_template'] ) : null,
289
-				'email_cc'       => isset( $posted['wpinv_cc'] ) ? wpinv_clean( $posted['wpinv_cc'] ) : null,
290
-				'disable_taxes'  => ! empty( $posted['disable_taxes'] ),
291
-				'currency'       => isset( $posted['wpinv_currency'] ) ? wpinv_clean( $posted['wpinv_currency'] ) : null,
292
-				'gateway'        => ( $invoice->needs_payment() && isset( $posted['wpinv_gateway'] ) ) ? wpinv_clean( $posted['wpinv_gateway'] ) : null,
293
-				'address'        => isset( $posted['wpinv_address'] ) ? wpinv_clean( $posted['wpinv_address'] ) : null,
294
-				'vat_number'     => isset( $posted['wpinv_vat_number'] ) ? wpinv_clean( $posted['wpinv_vat_number'] ) : null,
295
-				'company'        => isset( $posted['wpinv_company'] ) ? wpinv_clean( $posted['wpinv_company'] ) : null,
296
-				'company_id'     => isset( $posted['wpinv_company_id'] ) ? wpinv_clean( $posted['wpinv_company_id'] ) : null,
297
-				'zip'            => isset( $posted['wpinv_zip'] ) ? wpinv_clean( $posted['wpinv_zip'] ) : null,
298
-				'state'          => isset( $posted['wpinv_state'] ) ? wpinv_clean( $posted['wpinv_state'] ) : null,
299
-				'city'           => isset( $posted['wpinv_city'] ) ? wpinv_clean( $posted['wpinv_city'] ) : null,
300
-				'country'        => isset( $posted['wpinv_country'] ) ? wpinv_clean( $posted['wpinv_country'] ) : null,
301
-				'phone'          => isset( $posted['wpinv_phone'] ) ? wpinv_clean( $posted['wpinv_phone'] ) : null,
302
-				'first_name'     => isset( $posted['wpinv_first_name'] ) ? wpinv_clean( $posted['wpinv_first_name'] ) : null,
303
-				'last_name'      => isset( $posted['wpinv_last_name'] ) ? wpinv_clean( $posted['wpinv_last_name'] ) : null,
304
-				'author'         => isset( $posted['post_author_override'] ) ? wpinv_clean( $posted['post_author_override'] ) : null,
305
-				'date_created'   => isset( $posted['date_created'] ) ? wpinv_clean( $posted['date_created'] ) : null,
306
-				'date_completed' => isset( $posted['wpinv_date_completed'] ) ? wpinv_clean( $posted['wpinv_date_completed'] ) : null,
307
-				'due_date'       => isset( $posted['wpinv_due_date'] ) ? wpinv_clean( $posted['wpinv_due_date'] ) : null,
308
-				'number'         => isset( $posted['wpinv_number'] ) ? wpinv_clean( $posted['wpinv_number'] ) : null,
309
-				'status'         => isset( $posted['wpinv_status'] ) ? wpinv_clean( $posted['wpinv_status'] ) : null,
288
+				'template'       => isset($posted['wpinv_template']) ? wpinv_clean($posted['wpinv_template']) : null,
289
+				'email_cc'       => isset($posted['wpinv_cc']) ? wpinv_clean($posted['wpinv_cc']) : null,
290
+				'disable_taxes'  => !empty($posted['disable_taxes']),
291
+				'currency'       => isset($posted['wpinv_currency']) ? wpinv_clean($posted['wpinv_currency']) : null,
292
+				'gateway'        => ($invoice->needs_payment() && isset($posted['wpinv_gateway'])) ? wpinv_clean($posted['wpinv_gateway']) : null,
293
+				'address'        => isset($posted['wpinv_address']) ? wpinv_clean($posted['wpinv_address']) : null,
294
+				'vat_number'     => isset($posted['wpinv_vat_number']) ? wpinv_clean($posted['wpinv_vat_number']) : null,
295
+				'company'        => isset($posted['wpinv_company']) ? wpinv_clean($posted['wpinv_company']) : null,
296
+				'company_id'     => isset($posted['wpinv_company_id']) ? wpinv_clean($posted['wpinv_company_id']) : null,
297
+				'zip'            => isset($posted['wpinv_zip']) ? wpinv_clean($posted['wpinv_zip']) : null,
298
+				'state'          => isset($posted['wpinv_state']) ? wpinv_clean($posted['wpinv_state']) : null,
299
+				'city'           => isset($posted['wpinv_city']) ? wpinv_clean($posted['wpinv_city']) : null,
300
+				'country'        => isset($posted['wpinv_country']) ? wpinv_clean($posted['wpinv_country']) : null,
301
+				'phone'          => isset($posted['wpinv_phone']) ? wpinv_clean($posted['wpinv_phone']) : null,
302
+				'first_name'     => isset($posted['wpinv_first_name']) ? wpinv_clean($posted['wpinv_first_name']) : null,
303
+				'last_name'      => isset($posted['wpinv_last_name']) ? wpinv_clean($posted['wpinv_last_name']) : null,
304
+				'author'         => isset($posted['post_author_override']) ? wpinv_clean($posted['post_author_override']) : null,
305
+				'date_created'   => isset($posted['date_created']) ? wpinv_clean($posted['date_created']) : null,
306
+				'date_completed' => isset($posted['wpinv_date_completed']) ? wpinv_clean($posted['wpinv_date_completed']) : null,
307
+				'due_date'       => isset($posted['wpinv_due_date']) ? wpinv_clean($posted['wpinv_due_date']) : null,
308
+				'number'         => isset($posted['wpinv_number']) ? wpinv_clean($posted['wpinv_number']) : null,
309
+				'status'         => isset($posted['wpinv_status']) ? wpinv_clean($posted['wpinv_status']) : null,
310 310
 			)
311 311
 		);
312 312
 
313 313
 		// Discount code.
314
-		if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
314
+		if (!$invoice->is_paid() && !$invoice->is_refunded()) {
315 315
 
316
-			if ( isset( $posted['wpinv_discount_code'] ) ) {
317
-				$invoice->set_discount_code( wpinv_clean( $posted['wpinv_discount_code'] ) );
316
+			if (isset($posted['wpinv_discount_code'])) {
317
+				$invoice->set_discount_code(wpinv_clean($posted['wpinv_discount_code']));
318 318
 			}
319 319
 
320
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
321
-			if ( $discount->exists() ) {
322
-				$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
320
+			$discount = new WPInv_Discount($invoice->get_discount_code());
321
+			if ($discount->exists()) {
322
+				$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
323 323
 			} else {
324
-				$invoice->remove_discount( 'discount_code' );
324
+				$invoice->remove_discount('discount_code');
325 325
 			}
326 326
 
327 327
 			// Recalculate totals.
@@ -330,16 +330,16 @@  discard block
 block discarded – undo
330 330
 		}
331 331
 
332 332
 		// If we're creating a new user...
333
-		if ( ! empty( $posted['wpinv_new_user'] ) && is_email( stripslashes( $posted['wpinv_email'] ) ) ) {
333
+		if (!empty($posted['wpinv_new_user']) && is_email(stripslashes($posted['wpinv_email']))) {
334 334
 
335 335
 			// Attempt to create the user.
336
-			$user = wpinv_create_user( sanitize_email( stripslashes( $posted['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() );
336
+			$user = wpinv_create_user(sanitize_email(stripslashes($posted['wpinv_email'])), $invoice->get_first_name() . $invoice->get_last_name());
337 337
 
338 338
 			// If successful, update the invoice author.
339
-			if ( is_numeric( $user ) ) {
340
-				$invoice->set_author( $user );
339
+			if (is_numeric($user)) {
340
+				$invoice->set_author($user);
341 341
 			} else {
342
-				wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
342
+				wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
343 343
 			}
344 344
 		}
345 345
 
@@ -350,22 +350,22 @@  discard block
 block discarded – undo
350 350
 		$invoice->save();
351 351
 
352 352
 		// Save the user address.
353
-		getpaid_save_invoice_user_address( $invoice );
353
+		getpaid_save_invoice_user_address($invoice);
354 354
 
355 355
 		// Undo do not send new invoice notifications.
356 356
 		$GLOBALS['wpinv_skip_invoice_notification'] = false;
357 357
 
358 358
 		// (Maybe) send new user notification.
359
-		$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
360
-		if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
361
-			wp_send_new_user_notifications( $user, 'user' );
359
+		$should_send_notification = wpinv_get_option('disable_new_user_emails');
360
+		if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
361
+			wp_send_new_user_notifications($user, 'user');
362 362
 		}
363 363
 
364
-		if ( ! empty( $posted['send_to_customer'] ) && ! $invoice->is_draft() ) {
365
-			getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
364
+		if (!empty($posted['send_to_customer']) && !$invoice->is_draft()) {
365
+			getpaid()->get('invoice_emails')->user_invoice($invoice, true);
366 366
 		}
367 367
 
368 368
 		// Fires after an invoice is saved.
369
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
369
+		do_action('wpinv_invoice_metabox_saved', $invoice);
370 370
 	}
371 371
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-manual-gateway.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Manual_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'manual';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array(
28 28
         'subscription',
29 29
         'addons',
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
     );
35 35
 
36 36
     /**
37
-	 * Payment method order.
38
-	 *
39
-	 * @var int
40
-	 */
41
-	public $order = 11;
37
+     * Payment method order.
38
+     *
39
+     * @var int
40
+     */
41
+    public $order = 11;
42 42
 
43 43
     /**
44
-	 * Class constructor.
45
-	 */
46
-	public function __construct() {
44
+     * Class constructor.
45
+     */
46
+    public function __construct() {
47 47
         parent::__construct();
48 48
 
49 49
         $this->title        = __( 'Test Gateway', 'invoicing' );
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
     /**
56
-	 * Process Payment.
57
-	 *
58
-	 *
59
-	 * @param WPInv_Invoice $invoice Invoice.
60
-	 * @param array $submission_data Posted checkout fields.
61
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62
-	 * @return array
63
-	 */
64
-	public function process_payment( $invoice, $submission_data, $submission ) {
56
+     * Process Payment.
57
+     *
58
+     *
59
+     * @param WPInv_Invoice $invoice Invoice.
60
+     * @param array $submission_data Posted checkout fields.
61
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62
+     * @return array
63
+     */
64
+    public function process_payment( $invoice, $submission_data, $submission ) {
65 65
 
66 66
         // Mark it as paid.
67 67
         $invoice->mark_paid();
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
     }
92 92
 
93 93
     /**
94
-	 * (Maybe) renews a manual subscription profile.
95
-	 *
96
-	 *
94
+     * (Maybe) renews a manual subscription profile.
95
+     *
96
+     *
97 97
      * @param WPInv_Subscription $subscription
98
-	 */
99
-	public function maybe_renew_subscription( $subscription ) {
98
+     */
99
+    public function maybe_renew_subscription( $subscription ) {
100 100
 
101 101
         // Ensure its our subscription && it's active.
102 102
         if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
     }
117 117
 
118 118
     /**
119
-	 * Processes invoice addons.
120
-	 *
121
-	 * @param WPInv_Invoice $invoice
122
-	 * @param GetPaid_Form_Item[] $items
123
-	 * @return WPInv_Invoice
124
-	 */
125
-	public function process_addons( $invoice, $items ) {
119
+     * Processes invoice addons.
120
+     *
121
+     * @param WPInv_Invoice $invoice
122
+     * @param GetPaid_Form_Item[] $items
123
+     * @return WPInv_Invoice
124
+     */
125
+    public function process_addons( $invoice, $items ) {
126 126
 
127 127
         foreach ( $items as $item ) {
128 128
             $invoice->add_item( $item );
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Manual Payment Gateway class.
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 	public function __construct() {
47 47
         parent::__construct();
48 48
 
49
-        $this->title        = __( 'Test Gateway', 'invoicing' );
50
-        $this->method_title = __( 'Test Gateway', 'invoicing' );
49
+        $this->title        = __('Test Gateway', 'invoicing');
50
+        $this->method_title = __('Test Gateway', 'invoicing');
51 51
 
52
-        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
+        add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
53 53
     }
54 54
 
55 55
     /**
@@ -61,32 +61,32 @@  discard block
 block discarded – undo
61 61
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62 62
 	 * @return array
63 63
 	 */
64
-	public function process_payment( $invoice, $submission_data, $submission ) {
64
+	public function process_payment($invoice, $submission_data, $submission) {
65 65
 
66 66
         // Mark it as paid.
67 67
         $invoice->mark_paid();
68 68
 
69 69
         // (Maybe) activate subscriptions.
70
-        $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
70
+        $subscriptions = getpaid_get_invoice_subscriptions($invoice);
71 71
 
72
-        if ( ! empty( $subscriptions ) ) {
73
-            $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
72
+        if (!empty($subscriptions)) {
73
+            $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
74 74
 
75
-            foreach ( $subscriptions as $subscription ) {
76
-                if ( $subscription->exists() ) {
77
-                    $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
78
-                    $expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
75
+            foreach ($subscriptions as $subscription) {
76
+                if ($subscription->exists()) {
77
+                    $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
78
+                    $expiry   = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration));
79 79
 
80
-                    $subscription->set_next_renewal_date( $expiry );
81
-                    $subscription->set_date_created( current_time( 'mysql' ) );
82
-                    $subscription->set_profile_id( $invoice->generate_key( 'manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) );
80
+                    $subscription->set_next_renewal_date($expiry);
81
+                    $subscription->set_date_created(current_time('mysql'));
82
+                    $subscription->set_profile_id($invoice->generate_key('manual_sub_' . $invoice->get_id() . '_' . $subscription->get_id()));
83 83
                     $subscription->activate();
84 84
                 }
85 85
             }
86 86
         }
87 87
 
88 88
         // Send to the success page.
89
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
89
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
90 90
 
91 91
     }
92 92
 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
      * @param WPInv_Subscription $subscription
98 98
 	 */
99
-	public function maybe_renew_subscription( $subscription ) {
99
+	public function maybe_renew_subscription($subscription) {
100 100
 
101 101
         // Ensure its our subscription && it's active.
102
-        if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
102
+        if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) {
103 103
 
104 104
             // Renew the subscription.
105 105
             $subscription->add_payment(
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
 	 * @param GetPaid_Form_Item[] $items
123 123
 	 * @return WPInv_Invoice
124 124
 	 */
125
-	public function process_addons( $invoice, $items ) {
125
+	public function process_addons($invoice, $items) {
126 126
 
127
-        foreach ( $items as $item ) {
128
-            $invoice->add_item( $item );
127
+        foreach ($items as $item) {
128
+            $invoice->add_item($item);
129 129
         }
130 130
 
131 131
         $invoice->recalculate_total();
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22
-	/**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected $supports = array(
28
-		'subscription',
29
-		'addons',
30
-		'single_subscription_group',
31
-		'multiple_subscription_groups',
32
-		'subscription_date_change',
33
-		'subscription_bill_times_change',
34
-	);
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array(
28
+        'subscription',
29
+        'addons',
30
+        'single_subscription_group',
31
+        'multiple_subscription_groups',
32
+        'subscription_date_change',
33
+        'subscription_bill_times_change',
34
+    );
35
+
36
+    /**
37
+     * Payment method order.
38
+     *
39
+     * @var int
40
+     */
41
+    public $order = 8;
35 42
 
36 43
     /**
37
-	 * Payment method order.
38
-	 *
39
-	 * @var int
40
-	 */
41
-	public $order = 8;
42
-
43
-	/**
44
-	 * Bank transfer instructions.
45
-	 */
46
-	public $instructions;
47
-
48
-	/**
49
-	 * Locale array.
50
-	 */
51
-	public $locale;
44
+     * Bank transfer instructions.
45
+     */
46
+    public $instructions;
52 47
 
53 48
     /**
54
-	 * Class constructor.
55
-	 */
56
-	public function __construct() {
49
+     * Locale array.
50
+     */
51
+    public $locale;
52
+
53
+    /**
54
+     * Class constructor.
55
+     */
56
+    public function __construct() {
57 57
         parent::__construct();
58 58
 
59 59
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
62 62
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
63 63
 
64
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
69
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
64
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
+        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
69
+        add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
70 70
 
71 71
     }
72 72
 
73 73
     /**
74
-	 * Process Payment.
75
-	 *
76
-	 * @param WPInv_Invoice $invoice Invoice.
77
-	 * @param array $submission_data Posted checkout fields.
78
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
79
-	 * @return array
80
-	 */
81
-	public function process_payment( $invoice, $submission_data, $submission ) {
74
+     * Process Payment.
75
+     *
76
+     * @param WPInv_Invoice $invoice Invoice.
77
+     * @param array $submission_data Posted checkout fields.
78
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
79
+     * @return array
80
+     */
81
+    public function process_payment( $invoice, $submission_data, $submission ) {
82 82
 
83 83
         // Add a transaction id.
84 84
         $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
@@ -99,66 +99,66 @@  discard block
 block discarded – undo
99 99
     }
100 100
 
101 101
     /**
102
-	 * Output for the order received page.
103
-	 *
104
-	 * @param WPInv_Invoice $invoice Invoice.
105
-	 */
106
-	public function thankyou_page( $invoice ) {
102
+     * Output for the order received page.
103
+     *
104
+     * @param WPInv_Invoice $invoice Invoice.
105
+     */
106
+    public function thankyou_page( $invoice ) {
107 107
 
108 108
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
109 109
 
110
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
110
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
111 111
 
112 112
             if ( ! empty( $this->instructions ) ) {
113 113
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
114
-			}
114
+            }
115 115
 
116
-			$this->bank_details( $invoice );
116
+            $this->bank_details( $invoice );
117 117
 
118
-			echo '</div>';
118
+            echo '</div>';
119 119
 
120 120
         }
121 121
 
122
-	}
122
+    }
123 123
 
124 124
     /**
125
-	 * Add content to the WPI emails.
126
-	 *
127
-	 * @param WPInv_Invoice $invoice Invoice.
128
-	 * @param string     $email_type Email format: plain text or HTML.
129
-	 * @param bool     $sent_to_admin Sent to admin.
130
-	 */
131
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
125
+     * Add content to the WPI emails.
126
+     *
127
+     * @param WPInv_Invoice $invoice Invoice.
128
+     * @param string     $email_type Email format: plain text or HTML.
129
+     * @param bool     $sent_to_admin Sent to admin.
130
+     */
131
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
132 132
 
133
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
133
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
134 134
 
135
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
135
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
136 136
 
137
-			if ( $this->instructions ) {
138
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
137
+            if ( $this->instructions ) {
138
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
139 139
             }
140 140
 
141
-			$this->bank_details( $invoice );
141
+            $this->bank_details( $invoice );
142 142
 
143
-			echo '</div>';
143
+            echo '</div>';
144 144
 
145
-		}
145
+        }
146 146
 
147 147
     }
148 148
 
149 149
     /**
150
-	 * Get bank details and place into a list format.
151
-	 *
152
-	 * @param WPInv_Invoice $invoice Invoice.
153
-	 */
154
-	protected function bank_details( $invoice ) {
150
+     * Get bank details and place into a list format.
151
+     *
152
+     * @param WPInv_Invoice $invoice Invoice.
153
+     */
154
+    protected function bank_details( $invoice ) {
155 155
 
156
-		// Get the invoice country and country $locale.
157
-		$country = $invoice->get_country();
158
-		$locale  = $this->get_country_locale();
156
+        // Get the invoice country and country $locale.
157
+        $country = $invoice->get_country();
158
+        $locale  = $this->get_country_locale();
159 159
 
160
-		// Get sortcode label in the $locale array and use appropriate one.
161
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
160
+        // Get sortcode label in the $locale array and use appropriate one.
161
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
162 162
 
163 163
         $bank_fields = array(
164 164
             'ac_name'   => __( 'Account Name', 'invoicing' ),
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 
178 178
             if ( ! empty( $value ) ) {
179 179
                 $bank_info[ $field ] = array(
180
-					'label' => $label,
181
-					'value' => $value,
182
-				);
180
+                    'label' => $label,
181
+                    'value' => $value,
182
+                );
183 183
             }
184
-		}
184
+        }
185 185
 
186 186
         $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
187 187
 
@@ -189,139 +189,139 @@  discard block
 block discarded – undo
189 189
             return;
190 190
         }
191 191
 
192
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
192
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
193
+
194
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
195
+
196
+        foreach ( $bank_info as $key => $data ) {
197
+            echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
198
+        }
199
+
200
+        echo '</table>';
201
+
202
+    }
193 203
 
194
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
204
+    /**
205
+     * Get country locale if localized.
206
+     *
207
+     * @return array
208
+     */
209
+    public function get_country_locale() {
210
+
211
+        if ( empty( $this->locale ) ) {
212
+
213
+            // Locale information to be used - only those that are not 'Sort Code'.
214
+            $this->locale = apply_filters(
215
+                'getpaid_get_bank_transfer_locale',
216
+                array(
217
+                    'AU' => array(
218
+                        'sortcode' => array(
219
+                            'label' => __( 'BSB', 'invoicing' ),
220
+                        ),
221
+                    ),
222
+                    'CA' => array(
223
+                        'sortcode' => array(
224
+                            'label' => __( 'Bank transit number', 'invoicing' ),
225
+                        ),
226
+                    ),
227
+                    'IN' => array(
228
+                        'sortcode' => array(
229
+                            'label' => __( 'IFSC', 'invoicing' ),
230
+                        ),
231
+                    ),
232
+                    'IT' => array(
233
+                        'sortcode' => array(
234
+                            'label' => __( 'Branch sort', 'invoicing' ),
235
+                        ),
236
+                    ),
237
+                    'NZ' => array(
238
+                        'sortcode' => array(
239
+                            'label' => __( 'Bank code', 'invoicing' ),
240
+                        ),
241
+                    ),
242
+                    'SE' => array(
243
+                        'sortcode' => array(
244
+                            'label' => __( 'Bank code', 'invoicing' ),
245
+                        ),
246
+                    ),
247
+                    'US' => array(
248
+                        'sortcode' => array(
249
+                            'label' => __( 'Routing number', 'invoicing' ),
250
+                        ),
251
+                    ),
252
+                    'ZA' => array(
253
+                        'sortcode' => array(
254
+                            'label' => __( 'Branch code', 'invoicing' ),
255
+                        ),
256
+                    ),
257
+                )
258
+            );
195 259
 
196
-		foreach ( $bank_info as $key => $data ) {
197
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
198
-		}
260
+        }
199 261
 
200
-		echo '</table>';
262
+        return $this->locale;
201 263
 
202 264
     }
203 265
 
204 266
     /**
205
-	 * Get country locale if localized.
206
-	 *
207
-	 * @return array
208
-	 */
209
-	public function get_country_locale() {
210
-
211
-		if ( empty( $this->locale ) ) {
212
-
213
-			// Locale information to be used - only those that are not 'Sort Code'.
214
-			$this->locale = apply_filters(
215
-				'getpaid_get_bank_transfer_locale',
216
-				array(
217
-					'AU' => array(
218
-						'sortcode' => array(
219
-							'label' => __( 'BSB', 'invoicing' ),
220
-						),
221
-					),
222
-					'CA' => array(
223
-						'sortcode' => array(
224
-							'label' => __( 'Bank transit number', 'invoicing' ),
225
-						),
226
-					),
227
-					'IN' => array(
228
-						'sortcode' => array(
229
-							'label' => __( 'IFSC', 'invoicing' ),
230
-						),
231
-					),
232
-					'IT' => array(
233
-						'sortcode' => array(
234
-							'label' => __( 'Branch sort', 'invoicing' ),
235
-						),
236
-					),
237
-					'NZ' => array(
238
-						'sortcode' => array(
239
-							'label' => __( 'Bank code', 'invoicing' ),
240
-						),
241
-					),
242
-					'SE' => array(
243
-						'sortcode' => array(
244
-							'label' => __( 'Bank code', 'invoicing' ),
245
-						),
246
-					),
247
-					'US' => array(
248
-						'sortcode' => array(
249
-							'label' => __( 'Routing number', 'invoicing' ),
250
-						),
251
-					),
252
-					'ZA' => array(
253
-						'sortcode' => array(
254
-							'label' => __( 'Branch code', 'invoicing' ),
255
-						),
256
-					),
257
-				)
258
-			);
259
-
260
-		}
261
-
262
-		return $this->locale;
263
-
264
-	}
265
-
266
-	/**
267
-	 * Filters the gateway settings.
268
-	 *
269
-	 * @param array $admin_settings
270
-	 */
271
-	public function admin_settings( $admin_settings ) {
267
+     * Filters the gateway settings.
268
+     *
269
+     * @param array $admin_settings
270
+     */
271
+    public function admin_settings( $admin_settings ) {
272 272
 
273 273
         $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
274
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
274
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
275 275
 
276
-		$locale  = $this->get_country_locale();
276
+        $locale  = $this->get_country_locale();
277 277
 
278
-		// Get sortcode label in the $locale array and use appropriate one.
279
-		$country  = wpinv_default_billing_country();
280
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
278
+        // Get sortcode label in the $locale array and use appropriate one.
279
+        $country  = wpinv_default_billing_country();
280
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
281 281
 
282
-		$admin_settings['bank_transfer_ac_name'] = array(
282
+        $admin_settings['bank_transfer_ac_name'] = array(
283 283
             'type' => 'text',
284 284
             'id'   => 'bank_transfer_ac_name',
285 285
             'name' => __( 'Account Name', 'invoicing' ),
286
-		);
286
+        );
287 287
 
288
-		$admin_settings['bank_transfer_ac_no'] = array(
288
+        $admin_settings['bank_transfer_ac_no'] = array(
289 289
             'type' => 'text',
290 290
             'id'   => 'bank_transfer_ac_no',
291 291
             'name' => __( 'Account Number', 'invoicing' ),
292
-		);
292
+        );
293 293
 
294
-		$admin_settings['bank_transfer_bank_name'] = array(
294
+        $admin_settings['bank_transfer_bank_name'] = array(
295 295
             'type' => 'text',
296 296
             'id'   => 'bank_transfer_bank_name',
297 297
             'name' => __( 'Bank Name', 'invoicing' ),
298
-		);
298
+        );
299 299
 
300
-		$admin_settings['bank_transfer_ifsc'] = array(
300
+        $admin_settings['bank_transfer_ifsc'] = array(
301 301
             'type' => 'text',
302 302
             'id'   => 'bank_transfer_ifsc',
303 303
             'name' => __( 'IFSC Code', 'invoicing' ),
304
-		);
304
+        );
305 305
 
306
-		$admin_settings['bank_transfer_iban'] = array(
306
+        $admin_settings['bank_transfer_iban'] = array(
307 307
             'type' => 'text',
308 308
             'id'   => 'bank_transfer_iban',
309 309
             'name' => __( 'IBAN', 'invoicing' ),
310
-		);
310
+        );
311 311
 
312
-		$admin_settings['bank_transfer_bic'] = array(
312
+        $admin_settings['bank_transfer_bic'] = array(
313 313
             'type' => 'text',
314 314
             'id'   => 'bank_transfer_bic',
315 315
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
316
-		);
316
+        );
317 317
 
318
-		$admin_settings['bank_transfer_sort_code'] = array(
319
-			'type' => 'text',
320
-			'id'   => 'bank_transfer_sort_code',
321
-			'name' => $sortcode,
322
-		);
318
+        $admin_settings['bank_transfer_sort_code'] = array(
319
+            'type' => 'text',
320
+            'id'   => 'bank_transfer_sort_code',
321
+            'name' => $sortcode,
322
+        );
323 323
 
324
-		$admin_settings['bank_transfer_info'] = array(
324
+        $admin_settings['bank_transfer_info'] = array(
325 325
             'id'   => 'bank_transfer_info',
326 326
             'name' => __( 'Instructions', 'invoicing' ),
327 327
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
             'rows' => 5,
332 332
         );
333 333
 
334
-		return $admin_settings;
335
-	}
334
+        return $admin_settings;
335
+    }
336 336
 
337
-	/**
338
-	 * Processes invoice addons.
339
-	 *
340
-	 * @param WPInv_Invoice $invoice
341
-	 * @param GetPaid_Form_Item[] $items
342
-	 * @return WPInv_Invoice
343
-	 */
344
-	public function process_addons( $invoice, $items ) {
337
+    /**
338
+     * Processes invoice addons.
339
+     *
340
+     * @param WPInv_Invoice $invoice
341
+     * @param GetPaid_Form_Item[] $items
342
+     * @return WPInv_Invoice
343
+     */
344
+    public function process_addons( $invoice, $items ) {
345 345
 
346 346
         foreach ( $items as $item ) {
347 347
             $invoice->add_item( $item );
@@ -349,67 +349,67 @@  discard block
 block discarded – undo
349 349
 
350 350
         $invoice->recalculate_total();
351 351
         $invoice->save();
352
-	}
352
+    }
353 353
 
354
-	/**
355
-	 * (Maybe) renews a bank transfer subscription profile.
356
-	 *
357
-	 *
354
+    /**
355
+     * (Maybe) renews a bank transfer subscription profile.
356
+     *
357
+     *
358 358
      * @param WPInv_Subscription $subscription
359
-	 */
360
-	public function maybe_renew_subscription( $subscription ) {
359
+     */
360
+    public function maybe_renew_subscription( $subscription ) {
361 361
 
362 362
         // Ensure its our subscription && it's active.
363 363
         if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
364
-			$subscription->create_payment();
364
+            $subscription->create_payment();
365 365
         }
366 366
 
367 367
     }
368 368
 
369
-	/**
370
-	 * Process a bank transfer payment.
371
-	 *
372
-	 *
369
+    /**
370
+     * Process a bank transfer payment.
371
+     *
372
+     *
373 373
      * @param WPInv_Invoice $invoice
374
-	 */
375
-	public function invoice_paid( $invoice ) {
376
-
377
-		// Abort if not paid by bank transfer.
378
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
379
-			return;
380
-		}
381
-
382
-		// Is it a parent payment?
383
-		if ( 0 == $invoice->get_parent_id() ) {
384
-
385
-			// (Maybe) activate subscriptions.
386
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
387
-
388
-			if ( ! empty( $subscriptions ) ) {
389
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
390
-
391
-				foreach ( $subscriptions as $subscription ) {
392
-					if ( $subscription->exists() ) {
393
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
394
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
395
-
396
-						$subscription->set_next_renewal_date( $expiry );
397
-						$subscription->set_date_created( current_time( 'mysql' ) );
398
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
399
-						$subscription->activate();
400
-					}
401
-				}
402
-			}
403
-		} else {
404
-
405
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
406
-
407
-			// Renew the subscription.
408
-			if ( $subscription && $subscription->exists() ) {
409
-				$subscription->add_payment( array(), $invoice );
410
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
411
-			}
412
-		}
374
+     */
375
+    public function invoice_paid( $invoice ) {
376
+
377
+        // Abort if not paid by bank transfer.
378
+        if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
379
+            return;
380
+        }
381
+
382
+        // Is it a parent payment?
383
+        if ( 0 == $invoice->get_parent_id() ) {
384
+
385
+            // (Maybe) activate subscriptions.
386
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
387
+
388
+            if ( ! empty( $subscriptions ) ) {
389
+                $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
390
+
391
+                foreach ( $subscriptions as $subscription ) {
392
+                    if ( $subscription->exists() ) {
393
+                        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
394
+                        $expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
395
+
396
+                        $subscription->set_next_renewal_date( $expiry );
397
+                        $subscription->set_date_created( current_time( 'mysql' ) );
398
+                        $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
399
+                        $subscription->activate();
400
+                    }
401
+                }
402
+            }
403
+        } else {
404
+
405
+            $subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
406
+
407
+            // Renew the subscription.
408
+            if ( $subscription && $subscription->exists() ) {
409
+                $subscription->add_payment( array(), $invoice );
410
+                $subscription->renew( strtotime( $invoice->get_date_created() ) );
411
+            }
412
+        }
413 413
 
414 414
     }
415 415
 
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Bank transfer Payment Gateway class.
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 	public function __construct() {
57 57
         parent::__construct();
58 58
 
59
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
60
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
61
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
62
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
59
+        $this->title                = __('Direct bank transfer', 'invoicing');
60
+        $this->method_title         = __('Bank transfer', 'invoicing');
61
+        $this->checkout_button_text = __('Proceed', 'invoicing');
62
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
63 63
 
64
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
69
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
64
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
65
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
66
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
67
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
68
+		add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
69
+		add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20);
70 70
 
71 71
     }
72 72
 
@@ -78,23 +78,23 @@  discard block
 block discarded – undo
78 78
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
79 79
 	 * @return array
80 80
 	 */
81
-	public function process_payment( $invoice, $submission_data, $submission ) {
81
+	public function process_payment($invoice, $submission_data, $submission) {
82 82
 
83 83
         // Add a transaction id.
84
-        $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
84
+        $invoice->set_transaction_id($invoice->generate_key('bt_'));
85 85
 
86 86
         // Set it as pending payment.
87
-        if ( ! $invoice->needs_payment() ) {
87
+        if (!$invoice->needs_payment()) {
88 88
             $invoice->mark_paid();
89
-        } elseif ( ! $invoice->is_paid() ) {
90
-            $invoice->set_status( 'wpi-onhold' );
89
+        } elseif (!$invoice->is_paid()) {
90
+            $invoice->set_status('wpi-onhold');
91 91
         }
92 92
 
93 93
         // Save it.
94 94
         $invoice->save();
95 95
 
96 96
         // Send to the success page.
97
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
97
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
98 98
 
99 99
     }
100 100
 
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @param WPInv_Invoice $invoice Invoice.
105 105
 	 */
106
-	public function thankyou_page( $invoice ) {
106
+	public function thankyou_page($invoice) {
107 107
 
108
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
108
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
109 109
 
110 110
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
111 111
 
112
-            if ( ! empty( $this->instructions ) ) {
113
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
112
+            if (!empty($this->instructions)) {
113
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
114 114
 			}
115 115
 
116
-			$this->bank_details( $invoice );
116
+			$this->bank_details($invoice);
117 117
 
118 118
 			echo '</div>';
119 119
 
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 	 * @param string     $email_type Email format: plain text or HTML.
129 129
 	 * @param bool     $sent_to_admin Sent to admin.
130 130
 	 */
131
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
131
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
132 132
 
133
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
133
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
134 134
 
135 135
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
136 136
 
137
-			if ( $this->instructions ) {
138
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
137
+			if ($this->instructions) {
138
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
139 139
             }
140 140
 
141
-			$this->bank_details( $invoice );
141
+			$this->bank_details($invoice);
142 142
 
143 143
 			echo '</div>';
144 144
 
@@ -151,50 +151,50 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @param WPInv_Invoice $invoice Invoice.
153 153
 	 */
154
-	protected function bank_details( $invoice ) {
154
+	protected function bank_details($invoice) {
155 155
 
156 156
 		// Get the invoice country and country $locale.
157 157
 		$country = $invoice->get_country();
158 158
 		$locale  = $this->get_country_locale();
159 159
 
160 160
 		// Get sortcode label in the $locale array and use appropriate one.
161
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
161
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
162 162
 
163 163
         $bank_fields = array(
164
-            'ac_name'   => __( 'Account Name', 'invoicing' ),
165
-            'ac_no'     => __( 'Account Number', 'invoicing' ),
166
-            'bank_name' => __( 'Bank Name', 'invoicing' ),
167
-            'ifsc'      => __( 'IFSC code', 'invoicing' ),
168
-            'iban'      => __( 'IBAN', 'invoicing' ),
169
-            'bic'       => __( 'BIC/Swift code', 'invoicing' ),
164
+            'ac_name'   => __('Account Name', 'invoicing'),
165
+            'ac_no'     => __('Account Number', 'invoicing'),
166
+            'bank_name' => __('Bank Name', 'invoicing'),
167
+            'ifsc'      => __('IFSC code', 'invoicing'),
168
+            'iban'      => __('IBAN', 'invoicing'),
169
+            'bic'       => __('BIC/Swift code', 'invoicing'),
170 170
             'sort_code' => $sortcode,
171 171
         );
172 172
 
173 173
         $bank_info = array();
174 174
 
175
-        foreach ( $bank_fields as $field => $label ) {
176
-            $value = $this->get_option( $field );
175
+        foreach ($bank_fields as $field => $label) {
176
+            $value = $this->get_option($field);
177 177
 
178
-            if ( ! empty( $value ) ) {
179
-                $bank_info[ $field ] = array(
178
+            if (!empty($value)) {
179
+                $bank_info[$field] = array(
180 180
 					'label' => $label,
181 181
 					'value' => $value,
182 182
 				);
183 183
             }
184 184
 		}
185 185
 
186
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
186
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info, $invoice);
187 187
 
188
-        if ( empty( $bank_info ) ) {
188
+        if (empty($bank_info)) {
189 189
             return;
190 190
         }
191 191
 
192
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
192
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'), $invoice)) . '</h3>' . PHP_EOL;
193 193
 
194 194
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
195 195
 
196
-		foreach ( $bank_info as $key => $data ) {
197
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
196
+		foreach ($bank_info as $key => $data) {
197
+			echo "<tr class='getpaid-bank-transfer-" . esc_attr($key) . "'><th class='font-weight-bold'>" . wp_kses_post($data['label']) . "</th><td class='w-75'>" . wp_kses_post(wptexturize($data['value'])) . '</td></tr>' . PHP_EOL;
198 198
 		}
199 199
 
200 200
 		echo '</table>';
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function get_country_locale() {
210 210
 
211
-		if ( empty( $this->locale ) ) {
211
+		if (empty($this->locale)) {
212 212
 
213 213
 			// Locale information to be used - only those that are not 'Sort Code'.
214 214
 			$this->locale = apply_filters(
@@ -216,42 +216,42 @@  discard block
 block discarded – undo
216 216
 				array(
217 217
 					'AU' => array(
218 218
 						'sortcode' => array(
219
-							'label' => __( 'BSB', 'invoicing' ),
219
+							'label' => __('BSB', 'invoicing'),
220 220
 						),
221 221
 					),
222 222
 					'CA' => array(
223 223
 						'sortcode' => array(
224
-							'label' => __( 'Bank transit number', 'invoicing' ),
224
+							'label' => __('Bank transit number', 'invoicing'),
225 225
 						),
226 226
 					),
227 227
 					'IN' => array(
228 228
 						'sortcode' => array(
229
-							'label' => __( 'IFSC', 'invoicing' ),
229
+							'label' => __('IFSC', 'invoicing'),
230 230
 						),
231 231
 					),
232 232
 					'IT' => array(
233 233
 						'sortcode' => array(
234
-							'label' => __( 'Branch sort', 'invoicing' ),
234
+							'label' => __('Branch sort', 'invoicing'),
235 235
 						),
236 236
 					),
237 237
 					'NZ' => array(
238 238
 						'sortcode' => array(
239
-							'label' => __( 'Bank code', 'invoicing' ),
239
+							'label' => __('Bank code', 'invoicing'),
240 240
 						),
241 241
 					),
242 242
 					'SE' => array(
243 243
 						'sortcode' => array(
244
-							'label' => __( 'Bank code', 'invoicing' ),
244
+							'label' => __('Bank code', 'invoicing'),
245 245
 						),
246 246
 					),
247 247
 					'US' => array(
248 248
 						'sortcode' => array(
249
-							'label' => __( 'Routing number', 'invoicing' ),
249
+							'label' => __('Routing number', 'invoicing'),
250 250
 						),
251 251
 					),
252 252
 					'ZA' => array(
253 253
 						'sortcode' => array(
254
-							'label' => __( 'Branch code', 'invoicing' ),
254
+							'label' => __('Branch code', 'invoicing'),
255 255
 						),
256 256
 					),
257 257
 				)
@@ -268,51 +268,51 @@  discard block
 block discarded – undo
268 268
 	 *
269 269
 	 * @param array $admin_settings
270 270
 	 */
271
-	public function admin_settings( $admin_settings ) {
271
+	public function admin_settings($admin_settings) {
272 272
 
273
-        $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
274
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
273
+        $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing');
274
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
275 275
 
276
-		$locale  = $this->get_country_locale();
276
+		$locale = $this->get_country_locale();
277 277
 
278 278
 		// Get sortcode label in the $locale array and use appropriate one.
279 279
 		$country  = wpinv_default_billing_country();
280
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
280
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
281 281
 
282 282
 		$admin_settings['bank_transfer_ac_name'] = array(
283 283
             'type' => 'text',
284 284
             'id'   => 'bank_transfer_ac_name',
285
-            'name' => __( 'Account Name', 'invoicing' ),
285
+            'name' => __('Account Name', 'invoicing'),
286 286
 		);
287 287
 
288 288
 		$admin_settings['bank_transfer_ac_no'] = array(
289 289
             'type' => 'text',
290 290
             'id'   => 'bank_transfer_ac_no',
291
-            'name' => __( 'Account Number', 'invoicing' ),
291
+            'name' => __('Account Number', 'invoicing'),
292 292
 		);
293 293
 
294 294
 		$admin_settings['bank_transfer_bank_name'] = array(
295 295
             'type' => 'text',
296 296
             'id'   => 'bank_transfer_bank_name',
297
-            'name' => __( 'Bank Name', 'invoicing' ),
297
+            'name' => __('Bank Name', 'invoicing'),
298 298
 		);
299 299
 
300 300
 		$admin_settings['bank_transfer_ifsc'] = array(
301 301
             'type' => 'text',
302 302
             'id'   => 'bank_transfer_ifsc',
303
-            'name' => __( 'IFSC Code', 'invoicing' ),
303
+            'name' => __('IFSC Code', 'invoicing'),
304 304
 		);
305 305
 
306 306
 		$admin_settings['bank_transfer_iban'] = array(
307 307
             'type' => 'text',
308 308
             'id'   => 'bank_transfer_iban',
309
-            'name' => __( 'IBAN', 'invoicing' ),
309
+            'name' => __('IBAN', 'invoicing'),
310 310
 		);
311 311
 
312 312
 		$admin_settings['bank_transfer_bic'] = array(
313 313
             'type' => 'text',
314 314
             'id'   => 'bank_transfer_bic',
315
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
315
+            'name' => __('BIC/Swift Code', 'invoicing'),
316 316
 		);
317 317
 
318 318
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
 
324 324
 		$admin_settings['bank_transfer_info'] = array(
325 325
             'id'   => 'bank_transfer_info',
326
-            'name' => __( 'Instructions', 'invoicing' ),
327
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
326
+            'name' => __('Instructions', 'invoicing'),
327
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
328 328
             'type' => 'textarea',
329
-            'std'  => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ),
329
+            'std'  => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'),
330 330
             'cols' => 50,
331 331
             'rows' => 5,
332 332
         );
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 	 * @param GetPaid_Form_Item[] $items
342 342
 	 * @return WPInv_Invoice
343 343
 	 */
344
-	public function process_addons( $invoice, $items ) {
344
+	public function process_addons($invoice, $items) {
345 345
 
346
-        foreach ( $items as $item ) {
347
-            $invoice->add_item( $item );
346
+        foreach ($items as $item) {
347
+            $invoice->add_item($item);
348 348
         }
349 349
 
350 350
         $invoice->recalculate_total();
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
      * @param WPInv_Subscription $subscription
359 359
 	 */
360
-	public function maybe_renew_subscription( $subscription ) {
360
+	public function maybe_renew_subscription($subscription) {
361 361
 
362 362
         // Ensure its our subscription && it's active.
363
-        if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
363
+        if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) {
364 364
 			$subscription->create_payment();
365 365
         }
366 366
 
@@ -372,42 +372,42 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
      * @param WPInv_Invoice $invoice
374 374
 	 */
375
-	public function invoice_paid( $invoice ) {
375
+	public function invoice_paid($invoice) {
376 376
 
377 377
 		// Abort if not paid by bank transfer.
378
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
378
+		if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) {
379 379
 			return;
380 380
 		}
381 381
 
382 382
 		// Is it a parent payment?
383
-		if ( 0 == $invoice->get_parent_id() ) {
383
+		if (0 == $invoice->get_parent_id()) {
384 384
 
385 385
 			// (Maybe) activate subscriptions.
386
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
386
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
387 387
 
388
-			if ( ! empty( $subscriptions ) ) {
389
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
388
+			if (!empty($subscriptions)) {
389
+				$subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
390 390
 
391
-				foreach ( $subscriptions as $subscription ) {
392
-					if ( $subscription->exists() ) {
393
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
394
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
391
+				foreach ($subscriptions as $subscription) {
392
+					if ($subscription->exists()) {
393
+						$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
394
+						$expiry   = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration));
395 395
 
396
-						$subscription->set_next_renewal_date( $expiry );
397
-						$subscription->set_date_created( current_time( 'mysql' ) );
398
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
396
+						$subscription->set_next_renewal_date($expiry);
397
+						$subscription->set_date_created(current_time('mysql'));
398
+						$subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id());
399 399
 						$subscription->activate();
400 400
 					}
401 401
 				}
402 402
 			}
403 403
 		} else {
404 404
 
405
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
405
+			$subscription = getpaid_get_subscription($invoice->get_subscription_id());
406 406
 
407 407
 			// Renew the subscription.
408
-			if ( $subscription && $subscription->exists() ) {
409
-				$subscription->add_payment( array(), $invoice );
410
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
408
+			if ($subscription && $subscription->exists()) {
409
+				$subscription->add_payment(array(), $invoice);
410
+				$subscription->renew(strtotime($invoice->get_date_created()));
411 411
 			}
412 412
 		}
413 413
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@
 block discarded – undo
128 128
 
129 129
 				if( !$version || version_compare($version,'5.999','>')){
130 130
 					$url .= 'assets/js/fa-iconpicker-v6.min.js';
131
-				}else{
131
+				} else{
132 132
 					$url .= 'assets/js/fa-iconpicker-v5.min.js';
133 133
 				}
134 134
 
Please login to merge, or discard this 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.
Spacing   +242 added lines, -242 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
 		 * @return WP_Font_Awesome_Settings - Main instance.
83 83
 		 */
84 84
 		public static function instance() {
85
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
85
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
86 86
 				self::$instance = new WP_Font_Awesome_Settings;
87 87
 
88
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
88
+				add_action('init', array(self::$instance, 'init')); // set settings
89 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' ) );
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 95
 				}
96 96
 
97
-				do_action( 'wp_font_awesome_settings_loaded' );
97
+				do_action('wp_font_awesome_settings_loaded');
98 98
 			}
99 99
 
100 100
 			return self::$instance;
@@ -105,26 +105,26 @@  discard block
 block discarded – undo
105 105
          *
106 106
 		 * @return void
107 107
 		 */
108
-		public function constants(){
108
+		public function constants() {
109 109
 
110 110
 			// register iconpicker constant
111
-			if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
111
+			if (!defined('FAS_ICONPICKER_JS_URL')) {
112 112
 				$url = $this->get_path_url();
113 113
 				$version = $this->settings['version'];
114 114
 
115
-				if( !$version || version_compare($version,'5.999','>')){
115
+				if (!$version || version_compare($version, '5.999', '>')) {
116 116
 					$url .= 'assets/js/fa-iconpicker-v6.min.js';
117
-				}else{
117
+				} else {
118 118
 					$url .= 'assets/js/fa-iconpicker-v5.min.js';
119 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 );
126
+			if (!defined('FAS_PRO') && $this->settings['pro']) {
127
+				define('FAS_PRO', true);
128 128
 			}
129 129
 		}
130 130
 
@@ -134,19 +134,19 @@  discard block
 block discarded – undo
134 134
 		 * @return string
135 135
 		 */
136 136
 		public function get_path_url() {
137
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138
-			$content_url = untrailingslashit( WP_CONTENT_URL );
137
+			$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
138
+			$content_url = untrailingslashit(WP_CONTENT_URL);
139 139
 
140 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 );
141
+			if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
142
+				$content_url = str_replace('http://', 'https://', $content_url);
143 143
 			}
144 144
 
145 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 );
146
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
147
+			$url = str_replace($content_dir, $content_url, $file_dir);
148 148
 
149
-			return trailingslashit( $url );
149
+			return trailingslashit($url);
150 150
 		}
151 151
 
152 152
 		/**
@@ -156,45 +156,45 @@  discard block
 block discarded – undo
156 156
 		 */
157 157
 		public function init() {
158 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 );
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 161
 
162 162
 			$this->settings = $this->get_settings();
163 163
 
164 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 );
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 168
 				}
169 169
 
170
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171
-					add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
170
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
171
+					add_action('wp_head', array($this, 'add_generator'), 99);
172 172
 				}
173 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 );
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 177
 						//add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178 178
 					}
179 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 );
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 183
 					}
184 184
 				} else {
185
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
186
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
185
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
186
+						add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
187 187
 					}
188 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 );
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 192
 					}
193 193
 				}
194 194
 
195 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 );
196
+				if ($this->settings['dequeue'] == '1') {
197
+					add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
198 198
 				}
199 199
 			}
200 200
 
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 		 *
209 209
 		 * @return array
210 210
 		 */
211
-		public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
211
+		public function enqueue_editor_styles($editor_settings, $block_editor_context) {
212 212
 
213
-			if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
213
+			if (!empty($editor_settings['__unstableResolvedAssets']['styles'])) {
214 214
 				$url = $this->get_url();
215 215
 				$editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
216 216
 			}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		 *
227 227
 		 * @return array
228 228
 		 */
229
-		public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
229
+		public function enqueue_editor_scripts($editor_settings, $block_editor_context) {
230 230
 
231 231
 			$url = $this->get_url();
232 232
 			$editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
@@ -240,22 +240,22 @@  discard block
 block discarded – undo
240 240
 		public function enqueue_style() {
241 241
 			// build url
242 242
 			$url = $this->get_url();
243
-			$version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
243
+			$version = !empty($this->settings['local']) && empty($this->settings['pro']) ? strip_tags($this->settings['local_version']) : null;
244 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' );
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 248
 
249 249
 			// RTL language support CSS.
250
-			if ( is_rtl() ) {
251
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
250
+			if (is_rtl()) {
251
+				wp_add_inline_style('font-awesome', $this->rtl_inline_css());
252 252
 			}
253 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' );
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 259
 			}
260 260
 		}
261 261
 
@@ -267,15 +267,15 @@  discard block
 block discarded – undo
267 267
 			$url = $this->get_url();
268 268
 
269 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' );
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 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' );
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 279
 			}
280 280
 		}
281 281
 
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 		 *
288 288
 		 * @return string The url to the file.
289 289
 		 */
290
-		public function get_url( $shims = false, $local = true ) {
290
+		public function get_url($shims = false, $local = true) {
291 291
 			$script  = $shims ? 'v4-shims' : 'all';
292 292
 			$sub     = $this->settings['pro'] ? 'pro' : 'use';
293 293
 			$type    = $this->settings['type'];
294 294
 			$version = $this->settings['version'];
295
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
295
+			$kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : '';
296 296
 			$url     = '';
297 297
 
298
-			if ( $type == 'KIT' && $kit_url ) {
299
-				if ( $shims ) {
298
+			if ($type == 'KIT' && $kit_url) {
299
+				if ($shims) {
300 300
 					// if its a kit then we don't add shims here
301 301
 					return '';
302 302
 				}
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 			} else {
306 306
 				$v = '';
307 307
 				// Check and load locally.
308
-				if ( $local && $this->has_local() ) {
308
+				if ($local && $this->has_local()) {
309 309
 					$script .= ".min";
310
-					$v .= '&ver=' . strip_tags( $this->settings['local_version'] );
310
+					$v .= '&ver=' . strip_tags($this->settings['local_version']);
311 311
 					$url .= $this->get_fonts_url(); // Local fonts url.
312 312
 				} else {
313 313
 					$url .= "https://$sub.fontawesome.com/releases/"; // CDN
314
-					$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
314
+					$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
315 315
 				}
316 316
 				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
317 317
 				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 		 *
333 333
 		 * @return string The filtered url.
334 334
 		 */
335
-		public function remove_font_awesome( $url, $original_url, $_context ) {
335
+		public function remove_font_awesome($url, $original_url, $_context) {
336 336
 
337
-			if ( $_context == 'display'
338
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
339
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
337
+			if ($_context == 'display'
338
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
339
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
340 340
 			) {// it's a font-awesome-url (probably)
341 341
 
342
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
343
-					if ( $this->settings['type'] == 'JS' ) {
344
-						if ( $this->settings['js-pseudo'] ) {
342
+				if (strstr($url, "wpfas=true") !== false) {
343
+					if ($this->settings['type'] == 'JS') {
344
+						if ($this->settings['js-pseudo']) {
345 345
 							$url .= "' data-search-pseudo-elements defer='defer";
346 346
 						} else {
347 347
 							$url .= "' defer='defer";
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 		 * Register the database settings with WordPress.
361 361
 		 */
362 362
 		public function register_settings() {
363
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
363
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
364 364
 		}
365 365
 
366 366
 		/**
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
 		 */
370 370
 		public function menu_item() {
371 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(
372
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
373 373
 				$this,
374 374
 				'settings_page'
375
-			) );
375
+			));
376 376
 		}
377 377
 
378 378
 		/**
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		 * @return array The array of settings.
382 382
 		 */
383 383
 		public function get_settings() {
384
-			$db_settings = get_option( 'wp-font-awesome-settings' );
384
+			$db_settings = get_option('wp-font-awesome-settings');
385 385
 
386 386
 			$defaults = array(
387 387
 				'type'      => 'CSS', // type to use, CSS or JS or KIT
@@ -396,30 +396,30 @@  discard block
 block discarded – undo
396 396
 				'kit-url'   => '', // the kit url
397 397
 			);
398 398
 
399
-			$settings = wp_parse_args( $db_settings, $defaults );
399
+			$settings = wp_parse_args($db_settings, $defaults);
400 400
 
401 401
 			/**
402 402
 			 * Filter the Font Awesome settings.
403 403
 			 *
404 404
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
405 405
 			 */
406
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
406
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
407 407
 		}
408 408
 
409 409
 		/**
410 410
 		 * The settings page html output.
411 411
 		 */
412 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' ) );
413
+			if (!current_user_can('manage_options')) {
414
+				wp_die(__('You do not have sufficient permissions to access this page.', 'ayecode-connect'));
415 415
 			}
416 416
 
417 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 );
418
+			if (isset($_REQUEST['force-version-check'])) {
419
+				$this->get_latest_version($force_api = true);
420 420
 			}
421 421
 
422
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
422
+			if (!defined('FONTAWESOME_PLUGIN_FILE')) {
423 423
 				?>
424 424
                 <style>
425 425
                     .wpfas-kit-show {
@@ -446,42 +446,42 @@  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' );
449
+						settings_fields('wp-font-awesome-settings');
450
+						do_settings_sections('wp-font-awesome-settings');
451 451
 						$table_class = '';
452
-						if ( $this->settings['type'] ) {
453
-							$table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
452
+						if ($this->settings['type']) {
453
+							$table_class .= 'wpfas-' . sanitize_html_class(strtolower($this->settings['type'])) . '-set';
454 454
 						}
455
-						if ( ! empty( $this->settings['pro'] ) ) {
455
+						if (!empty($this->settings['pro'])) {
456 456
 							$table_class .= ' wpfas-has-pro';
457 457
 						}
458 458
 						?>
459
-						<?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?>
460
-							<?php if ( $this->has_local() ) { ?>
461
-                                <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'ayecode-connect' ); ?></strong></p></div>
459
+						<?php if ($this->settings['type'] != 'KIT' && !empty($this->settings['local']) && empty($this->settings['pro'])) { ?>
460
+							<?php if ($this->has_local()) { ?>
461
+                                <div class="notice notice-info"><p><strong><?php _e('Font Awesome fonts are loading locally.', 'ayecode-connect'); ?></strong></p></div>
462 462
 							<?php } else { ?>
463
-                                <div class="notice notice-error"><p><strong><?php _e( 'Font Awesome fonts are not loading locally!', 'ayecode-connect' ); ?></strong></p></div>
463
+                                <div class="notice notice-error"><p><strong><?php _e('Font Awesome fonts are not loading locally!', 'ayecode-connect'); ?></strong></p></div>
464 464
 							<?php } ?>
465 465
 						<?php } ?>
466
-                        <table class="form-table wpfas-table-settings <?php echo esc_attr( $table_class ); ?>">
466
+                        <table class="form-table wpfas-table-settings <?php echo esc_attr($table_class); ?>">
467 467
                             <tr valign="top">
468
-                                <th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'ayecode-connect' ); ?></label></th>
468
+                                <th scope="row"><label for="wpfas-type"><?php _e('Type', 'ayecode-connect'); ?></label></th>
469 469
                                 <td>
470 470
                                     <select name="wp-font-awesome-settings[type]" id="wpfas-type" onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}">
471
-                                        <option value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'ayecode-connect' ); ?></option>
472
-                                        <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
473
-                                        <option value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'ayecode-connect' ); ?></option>
471
+                                        <option value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'ayecode-connect'); ?></option>
472
+                                        <option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
473
+                                        <option value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'ayecode-connect'); ?></option>
474 474
                                     </select>
475 475
                                 </td>
476 476
                             </tr>
477 477
 
478 478
                             <tr valign="top" class="wpfas-kit-show">
479
-                                <th scope="row"><label for="wpfas-kit-url"><?php _e( 'Kit URL', 'ayecode-connect' ); ?></label></th>
479
+                                <th scope="row"><label for="wpfas-kit-url"><?php _e('Kit URL', 'ayecode-connect'); ?></label></th>
480 480
                                 <td>
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 :(?>"/>
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 483
 										echo wp_sprintf(
484
-											__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
484
+											__('Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect'),
485 485
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
486 486
 											'</a>'
487 487
 										);
@@ -490,44 +490,44 @@  discard block
 block discarded – undo
490 490
                             </tr>
491 491
 
492 492
                             <tr valign="top" class="wpfas-kit-hide">
493
-                                <th scope="row"><label for="wpfas-version"><?php _e( 'Version', 'ayecode-connect' ); ?></label></th>
493
+                                <th scope="row"><label for="wpfas-version"><?php _e('Version', 'ayecode-connect'); ?></label></th>
494 494
                                 <td>
495 495
                                     <select name="wp-font-awesome-settings[version]" id="wpfas-version">
496
-                                        <option value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo wp_sprintf( __( 'Latest - %s (default)', 'ayecode-connect' ), $this->get_latest_version() ); ?></option>
497
-                                        <option value="6.1.0" <?php selected( $this->settings['version'], '6.1.0' ); ?>>6.1.0</option>
498
-                                        <option value="6.0.0" <?php selected( $this->settings['version'], '6.0.0' ); ?>>6.0.0</option>
499
-                                        <option value="5.15.4" <?php selected( $this->settings['version'], '5.15.4' ); ?>>5.15.4</option>
500
-                                        <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>5.6.0</option>
501
-                                        <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>5.5.0</option>
502
-                                        <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>5.4.0</option>
503
-                                        <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>5.3.0</option>
504
-                                        <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>5.2.0</option>
505
-                                        <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>5.1.0</option>
506
-                                        <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>4.7.1 (CSS only)</option>
496
+                                        <option value="" <?php selected($this->settings['version'], ''); ?>><?php echo wp_sprintf(__('Latest - %s (default)', 'ayecode-connect'), $this->get_latest_version()); ?></option>
497
+                                        <option value="6.1.0" <?php selected($this->settings['version'], '6.1.0'); ?>>6.1.0</option>
498
+                                        <option value="6.0.0" <?php selected($this->settings['version'], '6.0.0'); ?>>6.0.0</option>
499
+                                        <option value="5.15.4" <?php selected($this->settings['version'], '5.15.4'); ?>>5.15.4</option>
500
+                                        <option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>5.6.0</option>
501
+                                        <option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>5.5.0</option>
502
+                                        <option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>5.4.0</option>
503
+                                        <option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>5.3.0</option>
504
+                                        <option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>5.2.0</option>
505
+                                        <option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>5.1.0</option>
506
+                                        <option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>4.7.1 (CSS only)</option>
507 507
                                     </select>
508 508
                                 </td>
509 509
                             </tr>
510 510
 
511 511
                             <tr valign="top">
512
-                                <th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue', 'ayecode-connect' ); ?></label></th>
512
+                                <th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue', 'ayecode-connect'); ?></label></th>
513 513
                                 <td>
514 514
                                     <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
515
-                                        <option value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'ayecode-connect' ); ?></option>
516
-                                        <option value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'ayecode-connect' ); ?></option>
517
-                                        <option value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'ayecode-connect' ); ?></option>
515
+                                        <option value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'ayecode-connect'); ?></option>
516
+                                        <option value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'ayecode-connect'); ?></option>
517
+                                        <option value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'ayecode-connect'); ?></option>
518 518
                                     </select>
519 519
                                 </td>
520 520
                             </tr>
521 521
 
522 522
                             <tr valign="top" class="wpfas-kit-hide">
523 523
                                 <th scope="row"><label
524
-                                            for="wpfas-pro"><?php _e( 'Enable pro', 'ayecode-connect' ); ?></label></th>
524
+                                            for="wpfas-pro"><?php _e('Enable pro', 'ayecode-connect'); ?></label></th>
525 525
                                 <td>
526 526
                                     <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
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')}"/>
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 529
 										echo wp_sprintf(
530
-											__( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
530
+											__('Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect'),
531 531
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
532 532
 											' <i class="fas fa-external-link-alt"></i></a>',
533 533
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
@@ -538,49 +538,49 @@  discard block
 block discarded – undo
538 538
                             </tr>
539 539
 
540 540
                             <tr valign="top" class="wpfas-kit-hide wpfas-hide-pro">
541
-                                <th scope="row"><label for="wpfas-local"><?php _e( 'Load Fonts Locally', 'ayecode-connect' ); ?></label></th>
541
+                                <th scope="row"><label for="wpfas-local"><?php _e('Load Fonts Locally', 'ayecode-connect'); ?></label></th>
542 542
                                 <td>
543 543
                                     <input type="hidden" name="wp-font-awesome-settings[local]" value="0"/>
544
-                                    <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr( $this->settings['local_version'] ); ?>"/>
545
-                                    <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked( $this->settings['local'], '1' ); ?> id="wpfas-local"/>
546
-                                    <span><?php _e( '(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'ayecode-connect' ); ?></span>
544
+                                    <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr($this->settings['local_version']); ?>"/>
545
+                                    <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked($this->settings['local'], '1'); ?> id="wpfas-local"/>
546
+                                    <span><?php _e('(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'ayecode-connect'); ?></span>
547 547
                                 </td>
548 548
                             </tr>
549 549
 
550 550
                             <tr valign="top" class="wpfas-kit-hide">
551 551
                                 <th scope="row"><label
552
-                                            for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'ayecode-connect' ); ?></label>
552
+                                            for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'ayecode-connect'); ?></label>
553 553
                                 </th>
554 554
                                 <td>
555 555
                                     <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
556 556
                                     <input type="checkbox" name="wp-font-awesome-settings[shims]"
557
-                                           value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
558
-                                    <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'ayecode-connect' ); ?></span>
557
+                                           value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
558
+                                    <span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'ayecode-connect'); ?></span>
559 559
                                 </td>
560 560
                             </tr>
561 561
 
562 562
                             <tr valign="top" class="wpfas-kit-hide">
563 563
                                 <th scope="row"><label
564
-                                            for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'ayecode-connect' ); ?></label>
564
+                                            for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'ayecode-connect'); ?></label>
565 565
                                 </th>
566 566
                                 <td>
567 567
                                     <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
568 568
                                     <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
569
-                                           value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
569
+                                           value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
570 570
                                            id="wpfas-js-pseudo"/>
571
-                                    <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'ayecode-connect' ); ?></span>
571
+                                    <span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'ayecode-connect'); ?></span>
572 572
                                 </td>
573 573
                             </tr>
574 574
 
575 575
                             <tr valign="top">
576 576
                                 <th scope="row"><label
577
-                                            for="wpfas-dequeue"><?php _e( 'Dequeue', 'ayecode-connect' ); ?></label></th>
577
+                                            for="wpfas-dequeue"><?php _e('Dequeue', 'ayecode-connect'); ?></label></th>
578 578
                                 <td>
579 579
                                     <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
580 580
                                     <input type="checkbox" name="wp-font-awesome-settings[dequeue]"
581
-                                           value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
581
+                                           value="1" <?php checked($this->settings['dequeue'], '1'); ?>
582 582
                                            id="wpfas-dequeue"/>
583
-                                    <span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'ayecode-connect' ); ?></span>
583
+                                    <span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'ayecode-connect'); ?></span>
584 584
                                 </td>
585 585
                             </tr>
586 586
 
@@ -589,12 +589,12 @@  discard block
 block discarded – undo
589 589
 							<?php
590 590
 							submit_button();
591 591
 							?>
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>
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>
595 595
                     </form>
596 596
 
597
-                    <div id="wpfas-version"><?php echo wp_sprintf(__( 'Version: %s (affiliate links provided)', 'ayecode-connect' ), $this->version ); ?></div>
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 600
 			}
@@ -609,12 +609,12 @@  discard block
 block discarded – undo
609 609
 		 *
610 610
 		 * @return string Either a valid version number or an empty string.
611 611
 		 */
612
-		public function validate_version_number( $version ) {
612
+		public function validate_version_number($version) {
613 613
 
614
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
614
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
615 615
 				// valid
616 616
 			} else {
617
-				$version = '';// not validated
617
+				$version = ''; // not validated
618 618
 			}
619 619
 
620 620
 			return $version;
@@ -629,27 +629,27 @@  discard block
 block discarded – undo
629 629
 		 * @since 1.0.7
630 630
 		 * @return mixed|string The latest version number found.
631 631
 		 */
632
-		public function get_latest_version( $force_api = false ) {
632
+		public function get_latest_version($force_api = false) {
633 633
 			$latest_version = $this->latest;
634 634
 
635
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
635
+			$cache = get_transient('wp-font-awesome-settings-version');
636 636
 
637
-			if ( $cache === false || $force_api ) { // its not set
637
+			if ($cache === false || $force_api) { // its not set
638 638
 				$api_ver = $this->get_latest_version_from_api();
639
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
639
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
640 640
 					$latest_version = $api_ver;
641
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
641
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
642 642
 				}
643
-			} elseif ( $this->validate_version_number( $cache ) ) {
644
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
643
+			} elseif ($this->validate_version_number($cache)) {
644
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
645 645
 					$latest_version = $cache;
646 646
 				}
647 647
 			}
648 648
 
649 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 );
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 653
 				}
654 654
 			}
655 655
 
@@ -664,10 +664,10 @@  discard block
 block discarded – undo
664 664
 		 */
665 665
 		public function get_latest_version_from_api() {
666 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'] ) ) {
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 671
 					$version = $api_response['tag_name'];
672 672
 				}
673 673
 			}
@@ -695,21 +695,21 @@  discard block
 block discarded – undo
695 695
 		public function admin_notices() {
696 696
 			$settings = $this->settings;
697 697
 
698
-			if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
699
-				if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
698
+			if (defined('FONTAWESOME_PLUGIN_FILE')) {
699
+				if (!empty($_REQUEST['page']) && $_REQUEST['page'] == 'wp-font-awesome-settings') {
700 700
 					?>
701 701
                     <div class="notice  notice-error is-dismissible">
702
-                        <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect' ); ?></p>
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 705
 				}
706 706
 			} else {
707
-				if ( ! empty( $settings ) ) {
708
-					if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
707
+				if (!empty($settings)) {
708
+					if ($settings['type'] != 'KIT' && $settings['pro'] && ($settings['version'] == '' || version_compare($settings['version'], '6', '>='))) {
709 709
 						$link = admin_url('options-general.php?page=wp-font-awesome-settings');
710 710
 						?>
711 711
                         <div class="notice  notice-error is-dismissible">
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>
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 715
 					}
@@ -725,20 +725,20 @@  discard block
 block discarded – undo
725 725
 		 * @param string $option The option name.
726 726
 		 * @param mixed  $value  The option value.
727 727
 		 */
728
-		public function add_option_wp_font_awesome_settings( $option, $value ) {
728
+		public function add_option_wp_font_awesome_settings($option, $value) {
729 729
 			// Do nothing if WordPress is being installed.
730
-			if ( wp_installing() ) {
730
+			if (wp_installing()) {
731 731
 				return;
732 732
 			}
733 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();
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 736
 
737
-				if ( ! empty( $version ) ) {
738
-					$response = $this->download_package( $version, $value );
737
+				if (!empty($version)) {
738
+					$response = $this->download_package($version, $value);
739 739
 
740
-					if ( is_wp_error( $response ) ) {
741
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
740
+					if (is_wp_error($response)) {
741
+						add_settings_error('general', 'fontawesome_download', __('ERROR:', 'ayecode-connect') . ' ' . $response->get_error_message(), 'error');
742 742
 					}
743 743
 				}
744 744
 			}
@@ -752,25 +752,25 @@  discard block
 block discarded – undo
752 752
 		 * @param mixed $old_value The old option value.
753 753
 		 * @param mixed $value     The new option value.
754 754
 		 */
755
-		public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
755
+		public function update_option_wp_font_awesome_settings($old_value, $new_value) {
756 756
 			// Do nothing if WordPress is being installed.
757
-			if ( wp_installing() ) {
757
+			if (wp_installing()) {
758 758
 				return;
759 759
 			}
760 760
 
761
-			if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
761
+			if (!empty($new_value['local']) && empty($new_value['pro']) && !(!empty($new_value['type']) && $new_value['type'] == 'KIT')) {
762 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;
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 765
 
766 766
 				// New values
767
-				$new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
767
+				$new_version = isset($new_value['version']) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
768 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 );
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 771
 
772
-					if ( is_wp_error( $response ) ) {
773
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
772
+					if (is_wp_error($response)) {
773
+						add_settings_error('general', 'fontawesome_download', __('ERROR:', 'ayecode-connect') . ' ' . $response->get_error_message(), 'error');
774 774
 					}
775 775
 				}
776 776
 			}
@@ -784,9 +784,9 @@  discard block
 block discarded – undo
784 784
 		 * @param string Fonts directory local path.
785 785
 		 */
786 786
 		public function get_fonts_dir() {
787
-			$upload_dir = wp_upload_dir( null, false );
787
+			$upload_dir = wp_upload_dir(null, false);
788 788
 
789
-			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
789
+			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
790 790
 		}
791 791
 
792 792
 		/**
@@ -797,9 +797,9 @@  discard block
 block discarded – undo
797 797
 		 * @param string Fonts directory local url.
798 798
 		 */
799 799
 		public function get_fonts_url() {
800
-			$upload_dir = wp_upload_dir( null, false );
800
+			$upload_dir = wp_upload_dir(null, false);
801 801
 
802
-			return $upload_dir['baseurl'] .  '/ayefonts/fa/';
802
+			return $upload_dir['baseurl'] . '/ayefonts/fa/';
803 803
 		}
804 804
 
805 805
 		/**
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 		 * @return bool True if active else false.
811 811
 		 */
812 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' ) ) {
813
+			if (!empty($this->settings['local']) && empty($this->settings['pro']) && file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) {
814 814
 				return true;
815 815
 			}
816 816
 
@@ -825,18 +825,18 @@  discard block
 block discarded – undo
825 825
 		 * @return object The WP Filesystem.
826 826
 		 */
827 827
 		public function get_wp_filesystem() {
828
-			if ( ! function_exists( 'get_filesystem_method' ) ) {
829
-				require_once( ABSPATH . "/wp-admin/includes/file.php" );
828
+			if (!function_exists('get_filesystem_method')) {
829
+				require_once(ABSPATH . "/wp-admin/includes/file.php");
830 830
 			}
831 831
 
832 832
 			$access_type = get_filesystem_method();
833 833
 
834
-			if ( $access_type === 'direct' ) {
834
+			if ($access_type === 'direct') {
835 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() );
836
+				$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
837 837
 
838 838
 				/* Initialize the API */
839
-				if ( ! WP_Filesystem( $creds ) ) {
839
+				if (!WP_Filesystem($creds)) {
840 840
 					/* Any problems and we exit */
841 841
 					return false;
842 842
 				}
@@ -845,11 +845,11 @@  discard block
 block discarded – undo
845 845
 
846 846
 				return $wp_filesystem;
847 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() );
848
+			} else if (defined('FTP_USER')) {
849
+				$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
850 850
 
851 851
 				/* Initialize the API */
852
-				if ( ! WP_Filesystem( $creds ) ) {
852
+				if (!WP_Filesystem($creds)) {
853 853
 					/* Any problems and we exit */
854 854
 					return false;
855 855
 				}
@@ -872,38 +872,38 @@  discard block
 block discarded – undo
872 872
 		 * @param array $option Fontawesome settings.
873 873
 		 * @return WP_ERROR|bool Error on fail and true on success.
874 874
 		 */
875
-		public function download_package( $version, $option = array() ) {
875
+		public function download_package($version, $option = array()) {
876 876
 			$filename = 'fontawesome-free-' . $version . '-web';
877 877
 			$url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
878 878
 
879
-			if ( ! function_exists( 'wp_handle_upload' ) ) {
879
+			if (!function_exists('wp_handle_upload')) {
880 880
 				require_once ABSPATH . 'wp-admin/includes/file.php';
881 881
 			}
882 882
 
883
-			$download_file = download_url( esc_url_raw( $url ) );
883
+			$download_file = download_url(esc_url_raw($url));
884 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' ) );
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 889
 			}
890 890
 
891
-			$response = $this->extract_package( $download_file, $filename, true );
891
+			$response = $this->extract_package($download_file, $filename, true);
892 892
 
893 893
 			// Update local version.
894
-			if ( is_wp_error( $response ) ) {
894
+			if (is_wp_error($response)) {
895 895
 				return $response;
896
-			} else if ( $response ) {
897
-				if ( empty( $option ) ) {
898
-					$option = get_option( 'wp-font-awesome-settings' );
896
+			} else if ($response) {
897
+				if (empty($option)) {
898
+					$option = get_option('wp-font-awesome-settings');
899 899
 				}
900 900
 
901 901
 				$option['local_version'] = $version;
902 902
 
903 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 );
904
+				remove_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2);
905 905
 
906
-				update_option( 'wp-font-awesome-settings', $option );
906
+				update_option('wp-font-awesome-settings', $option);
907 907
 
908 908
 				return true;
909 909
 			}
@@ -921,60 +921,60 @@  discard block
 block discarded – undo
921 921
 		 * @param bool   $delete_package Delete temp file or not.
922 922
 		 * @return WP_Error|bool True on success WP_Error on fail.
923 923
 		 */
924
-		public function extract_package( $package, $dirname = '', $delete_package = false ) {
924
+		public function extract_package($package, $dirname = '', $delete_package = false) {
925 925
 			global $wp_filesystem;
926 926
 
927 927
 			$wp_filesystem = $this->get_wp_filesystem();
928 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' ) );
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 933
 			}
934 934
 
935 935
 			$fonts_dir = $this->get_fonts_dir();
936
-			$fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
936
+			$fonts_tmp_dir = dirname($fonts_dir) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
937 937
 
938
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
939
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
938
+			if ($wp_filesystem->is_dir($fonts_tmp_dir)) {
939
+				$wp_filesystem->delete($fonts_tmp_dir, true);
940 940
 			}
941 941
 
942 942
 			// Unzip package to working directory.
943
-			$result = unzip_file( $package, $fonts_tmp_dir );
943
+			$result = unzip_file($package, $fonts_tmp_dir);
944 944
 
945
-			if ( is_wp_error( $result ) ) {
946
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
945
+			if (is_wp_error($result)) {
946
+				$wp_filesystem->delete($fonts_tmp_dir, true);
947 947
 
948
-				if ( 'incompatible_archive' === $result->get_error_code() ) {
949
-					return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
948
+				if ('incompatible_archive' === $result->get_error_code()) {
949
+					return new WP_Error('fontawesome_incompatible_archive', __($result->get_error_message(), 'ayecode-connect'));
950 950
 				}
951 951
 
952 952
 				return $result;
953 953
 			}
954 954
 
955
-			if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
956
-				$wp_filesystem->delete( $fonts_dir, true );
955
+			if ($wp_filesystem->is_dir($fonts_dir)) {
956
+				$wp_filesystem->delete($fonts_dir, true);
957 957
 			}
958 958
 
959 959
 			$extract_dir = $fonts_tmp_dir;
960 960
 
961
-			if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
961
+			if ($dirname && $wp_filesystem->is_dir($extract_dir . $dirname . DIRECTORY_SEPARATOR)) {
962 962
 				$extract_dir .= $dirname . DIRECTORY_SEPARATOR;
963 963
 			}
964 964
 
965 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' ) );
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 969
 			}
970 970
 
971
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
972
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
971
+			if ($wp_filesystem->is_dir($fonts_tmp_dir)) {
972
+				$wp_filesystem->delete($fonts_tmp_dir, true);
973 973
 			}
974 974
 
975 975
 			// Once extracted, delete the package if required.
976
-			if ( $delete_package ) {
977
-				unlink( $package );
976
+			if ($delete_package) {
977
+				unlink($package);
978 978
 			}
979 979
 
980 980
 			return $return;
@@ -984,22 +984,22 @@  discard block
 block discarded – undo
984 984
 		 * Output the version in the header.
985 985
 		 */
986 986
 		public function add_generator() {
987
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
988
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
987
+			$file = str_replace(array("/", "\\"), "/", realpath(__FILE__));
988
+			$plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR));
989 989
 
990 990
 			// Find source plugin/theme.
991 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() ) );
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 996
 
997
-				if ( strpos( $file, $themes_dir ) !== false ) {
998
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
997
+				if (strpos($file, $themes_dir) !== false) {
998
+					$source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/"));
999 999
 				}
1000 1000
 			}
1001 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] ) . '"' : '' ) . ' />';
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 1003
 		}
1004 1004
 	}
1005 1005
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php 3 patches
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 
463 463
 			if( is_admin() && !$this->is_aui_screen()){
464 464
 				// don't add wp-admin scripts if not requested to
465
-			}else{
465
+			} else{
466 466
 				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
467 467
 
468 468
 				$rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : '';
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 					// custom changes
553 553
 					if ( $load_fse ) {
554 554
 						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
555
-					}else{
555
+					} else{
556 556
 						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
557 557
 
558 558
 					}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 			ob_start();
577 577
 			if ( $aui_bs5 ) {
578 578
 				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
579
-			}else{
579
+			} else{
580 580
 				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
581 581
             }
582 582
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 
648 648
 			if( is_admin() && !$this->is_aui_screen()){
649 649
 				// don't add wp-admin scripts if not requested to
650
-			}else {
650
+			} else {
651 651
 
652 652
 				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
653 653
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 				// iconpicker
663 663
 				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
664 664
 					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
665
-				}else{
665
+				} else{
666 666
 					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
667 667
 				}
668 668
 
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 						$colors[$color['slug']] = esc_attr($color['color']);
1095 1095
 					}
1096 1096
 				}
1097
-			}else{
1097
+			} else{
1098 1098
 				$settings = get_option('aui_options');
1099 1099
 				$colors = array(
1100 1100
 					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
@@ -1232,9 +1232,9 @@  discard block
 block discarded – undo
1232 1232
 
1233 1233
 			if($compatibility===true || $compatibility===1){
1234 1234
 				$compatibility = '.bsui';
1235
-			}elseif(!$compatibility){
1235
+			} elseif(!$compatibility){
1236 1236
 				$compatibility = '';
1237
-			}else{
1237
+			} else{
1238 1238
 				$compatibility = esc_attr($compatibility);
1239 1239
 			}
1240 1240
 
@@ -1517,9 +1517,9 @@  discard block
 block discarded – undo
1517 1517
 
1518 1518
 			if($compatibility===true || $compatibility===1){
1519 1519
 				$compatibility = '.bsui';
1520
-			}elseif(!$compatibility){
1520
+			} elseif(!$compatibility){
1521 1521
 				$compatibility = '';
1522
-			}else{
1522
+			} else{
1523 1523
 				$compatibility = esc_attr($compatibility);
1524 1524
 			}
1525 1525
 
@@ -2385,7 +2385,9 @@  discard block
 block discarded – undo
2385 2385
 		 * @return mixed
2386 2386
 		 */
2387 2387
 		public static function minify_js($input) {
2388
-			if(trim($input) === "") return $input;
2388
+			if(trim($input) === "") {
2389
+			    return $input;
2390
+			}
2389 2391
 			return preg_replace(
2390 2392
 				array(
2391 2393
 					// Remove comment(s)
@@ -2417,7 +2419,9 @@  discard block
 block discarded – undo
2417 2419
 		 * @return mixed
2418 2420
 		 */
2419 2421
 		public static function minify_css($input) {
2420
-			if(trim($input) === "") return $input;
2422
+			if(trim($input) === "") {
2423
+			    return $input;
2424
+			}
2421 2425
 			return preg_replace(
2422 2426
 				array(
2423 2427
 					// Remove comment(s)
Please login to merge, or discard this patch.
Indentation   +1963 added lines, -1963 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,480 +21,480 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class AyeCode_UI_Settings
28
-	 * @ver 1.0.0
29
-	 * @todo decide how to implement textdomain
30
-	 */
31
-	class AyeCode_UI_Settings {
32
-
33
-		/**
34
-		 * Class version version.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $version = '0.2.8';
39
-
40
-		/**
41
-		 * Class textdomain.
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $textdomain = 'aui';
46
-
47
-		/**
48
-		 * Latest version of Bootstrap at time of publish published.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public $latest = "5.2.2";
53
-
54
-		/**
55
-		 * Current version of select2 being used.
56
-		 *
57
-		 * @var string
58
-		 */
59
-		public $select2_version = "4.0.11";
60
-
61
-		/**
62
-		 * The title.
63
-		 *
64
-		 * @var string
65
-		 */
66
-		public $name = 'AyeCode UI';
67
-
68
-		/**
69
-		 * The relative url to the assets.
70
-		 *
71
-		 * @var string
72
-		 */
73
-		public $url = '';
74
-
75
-		/**
76
-		 * Holds the settings values.
77
-		 *
78
-		 * @var array
79
-		 */
80
-		private $settings;
81
-
82
-		/**
83
-		 * AyeCode_UI_Settings instance.
84
-		 *
85
-		 * @access private
86
-		 * @since  1.0.0
87
-		 * @var    AyeCode_UI_Settings There can be only one!
88
-		 */
89
-		private static $instance = null;
90
-
91
-
92
-		/**
93
-		 * Main AyeCode_UI_Settings Instance.
94
-		 *
95
-		 * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
96
-		 *
97
-		 * @since 1.0.0
98
-		 * @static
99
-		 * @return AyeCode_UI_Settings - Main instance.
100
-		 */
101
-		public static function instance() {
102
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103
-
104
-				self::$instance = new AyeCode_UI_Settings;
105
-
106
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
107
-
108
-				if ( is_admin() ) {
109
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
111
-
112
-					// Maybe show example page
113
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
114
-
115
-					if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
-						add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
-					}
118
-				}
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class AyeCode_UI_Settings
28
+     * @ver 1.0.0
29
+     * @todo decide how to implement textdomain
30
+     */
31
+    class AyeCode_UI_Settings {
32
+
33
+        /**
34
+         * Class version version.
35
+         *
36
+         * @var string
37
+         */
38
+        public $version = '0.2.8';
39
+
40
+        /**
41
+         * Class textdomain.
42
+         *
43
+         * @var string
44
+         */
45
+        public $textdomain = 'aui';
119 46
 
120
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
47
+        /**
48
+         * Latest version of Bootstrap at time of publish published.
49
+         *
50
+         * @var string
51
+         */
52
+        public $latest = "5.2.2";
53
+
54
+        /**
55
+         * Current version of select2 being used.
56
+         *
57
+         * @var string
58
+         */
59
+        public $select2_version = "4.0.11";
121 60
 
122
-				do_action( 'ayecode_ui_settings_loaded' );
123
-			}
61
+        /**
62
+         * The title.
63
+         *
64
+         * @var string
65
+         */
66
+        public $name = 'AyeCode UI';
124 67
 
125
-			return self::$instance;
126
-		}
68
+        /**
69
+         * The relative url to the assets.
70
+         *
71
+         * @var string
72
+         */
73
+        public $url = '';
127 74
 
128
-		/**
129
-		 * Add custom colors to the color selector.
130
-		 *
131
-		 * @param $theme_colors
132
-		 * @param $include_outlines
133
-		 * @param $include_branding
134
-		 *
135
-		 * @return mixed
136
-		 */
137
-		public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
75
+        /**
76
+         * Holds the settings values.
77
+         *
78
+         * @var array
79
+         */
80
+        private $settings;
138 81
 
82
+        /**
83
+         * AyeCode_UI_Settings instance.
84
+         *
85
+         * @access private
86
+         * @since  1.0.0
87
+         * @var    AyeCode_UI_Settings There can be only one!
88
+         */
89
+        private static $instance = null;
139 90
 
140
-			$setting = wp_get_global_settings();
141 91
 
142
-			if(!empty($setting['color']['palette']['custom'])){
143
-				foreach($setting['color']['palette']['custom'] as $color){
144
-					$theme_colors[$color['slug']] = esc_attr($color['name']);
145
-				}
146
-			}
147
-
148
-			return $theme_colors;
149
-		}
150
-
151
-		/**
152
-		 * Setup some constants.
153
-		 */
154
-		public function constants(){
155
-			define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
-			define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
-			define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
-			define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
-			define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
-			define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
-			define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
-			define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
-			define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
-			define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
-			define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
-			define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
-			define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
-			define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
-			define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
-			define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
171
-
172
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
-				define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
-			}
175
-			if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
-				define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
-			}
178
-			if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
-				define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
-			}
181
-			if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
-				define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
-			}
184
-			if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
-				define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
-			}
187
-			if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
-				define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
-			}
190
-			if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
-				define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
-			}
193
-			if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
-				define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
-			}
196
-			if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
-				define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
-			}
199
-			if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
-				define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
-			}
202
-			if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
-				define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
-			}
205
-			if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
-				define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
-			}
208
-			if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
-				define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
-			}
211
-			if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
-				define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
-			}
214
-			if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
-				define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
-			}
217
-			if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
-				define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
-			}
220
-
221
-		}
222
-
223
-		public static function get_colors( $original = false){
224
-
225
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
-				return array();
227
-			}
228
-			if ( $original ) {
229
-				return array(
230
-					'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
-					'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
-					'info'      => AUI_INFO_COLOR_ORIGINAL,
233
-					'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
-					'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
-					'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
-					'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
-					'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
-					'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
-					'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
-					'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
-					'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
-					'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
-					'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
-					'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
-					'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
-				);
247
-			}
248
-
249
-			return array(
250
-				'primary'   => AUI_PRIMARY_COLOR,
251
-				'secondary' => AUI_SECONDARY_COLOR,
252
-				'info'      => AUI_INFO_COLOR,
253
-				'warning'   => AUI_WARNING_COLOR,
254
-				'danger'    => AUI_DANGER_COLOR,
255
-				'success'   => AUI_SUCCESS_COLOR,
256
-				'light'     => AUI_LIGHT_COLOR,
257
-				'dark'      => AUI_DARK_COLOR,
258
-				'white'     => AUI_WHITE_COLOR,
259
-				'purple'    => AUI_PURPLE_COLOR,
260
-				'salmon'    => AUI_SALMON_COLOR,
261
-				'cyan'      => AUI_CYAN_COLOR,
262
-				'gray'      => AUI_GRAY_COLOR,
263
-				'indigo'    => AUI_INDIGO_COLOR,
264
-				'orange'    => AUI_ORANGE_COLOR,
265
-				'black'     => AUI_BLACK_COLOR,
266
-			);
267
-		}
268
-
269
-		/**
270
-		 * Add admin body class to show when BS5 is active.
271
-		 *
272
-		 * @param $classes
273
-		 *
274
-		 * @return mixed
275
-		 */
276
-		public function add_bs5_admin_body_class( $classes = '' ) {
277
-			$classes .= ' aui_bs5';
278
-
279
-			return $classes;
280
-		}
281
-
282
-		/**
283
-		 * Add a body class to show when BS5 is active.
284
-		 *
285
-		 * @param $classes
286
-		 *
287
-		 * @return mixed
288
-		 */
289
-		public function add_bs5_body_class( $classes ) {
290
-			$classes[] = 'aui_bs5';
291
-
292
-			return $classes;
293
-		}
294
-
295
-		/**
296
-		 * Initiate the settings and add the required action hooks.
297
-		 */
298
-		public function init() {
92
+        /**
93
+         * Main AyeCode_UI_Settings Instance.
94
+         *
95
+         * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
96
+         *
97
+         * @since 1.0.0
98
+         * @static
99
+         * @return AyeCode_UI_Settings - Main instance.
100
+         */
101
+        public static function instance() {
102
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103
+
104
+                self::$instance = new AyeCode_UI_Settings;
105
+
106
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
107
+
108
+                if ( is_admin() ) {
109
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
111
+
112
+                    // Maybe show example page
113
+                    add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
114
+
115
+                    if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
+                        add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
+                    }
118
+                }
119
+
120
+                add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
121
+
122
+                do_action( 'ayecode_ui_settings_loaded' );
123
+            }
124
+
125
+            return self::$instance;
126
+        }
127
+
128
+        /**
129
+         * Add custom colors to the color selector.
130
+         *
131
+         * @param $theme_colors
132
+         * @param $include_outlines
133
+         * @param $include_branding
134
+         *
135
+         * @return mixed
136
+         */
137
+        public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
138
+
139
+
140
+            $setting = wp_get_global_settings();
141
+
142
+            if(!empty($setting['color']['palette']['custom'])){
143
+                foreach($setting['color']['palette']['custom'] as $color){
144
+                    $theme_colors[$color['slug']] = esc_attr($color['name']);
145
+                }
146
+            }
147
+
148
+            return $theme_colors;
149
+        }
150
+
151
+        /**
152
+         * Setup some constants.
153
+         */
154
+        public function constants(){
155
+            define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
+            define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
+            define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
+            define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
+            define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
+            define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
+            define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
+            define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
+            define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
+            define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
+            define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
+            define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
+            define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
+            define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
+            define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
+            define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
171
+
172
+            if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
+                define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
+            }
175
+            if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
+                define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
+            }
178
+            if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
+                define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
+            }
181
+            if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
+                define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
+            }
184
+            if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
+                define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
+            }
187
+            if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
+                define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
+            }
190
+            if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
+                define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
+            }
193
+            if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
+                define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
+            }
196
+            if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
+                define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
+            }
199
+            if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
+                define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
+            }
202
+            if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
+                define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
+            }
205
+            if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
+                define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
+            }
208
+            if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
+                define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
+            }
211
+            if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
+                define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
+            }
214
+            if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
+                define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
+            }
217
+            if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
+                define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
+            }
220
+
221
+        }
222
+
223
+        public static function get_colors( $original = false){
224
+
225
+            if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
+                return array();
227
+            }
228
+            if ( $original ) {
229
+                return array(
230
+                    'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
+                    'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
+                    'info'      => AUI_INFO_COLOR_ORIGINAL,
233
+                    'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
+                    'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
+                    'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
+                    'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
+                    'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
+                    'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
+                    'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
+                    'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
+                    'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
+                    'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
+                    'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
+                    'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
+                    'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
+                );
247
+            }
248
+
249
+            return array(
250
+                'primary'   => AUI_PRIMARY_COLOR,
251
+                'secondary' => AUI_SECONDARY_COLOR,
252
+                'info'      => AUI_INFO_COLOR,
253
+                'warning'   => AUI_WARNING_COLOR,
254
+                'danger'    => AUI_DANGER_COLOR,
255
+                'success'   => AUI_SUCCESS_COLOR,
256
+                'light'     => AUI_LIGHT_COLOR,
257
+                'dark'      => AUI_DARK_COLOR,
258
+                'white'     => AUI_WHITE_COLOR,
259
+                'purple'    => AUI_PURPLE_COLOR,
260
+                'salmon'    => AUI_SALMON_COLOR,
261
+                'cyan'      => AUI_CYAN_COLOR,
262
+                'gray'      => AUI_GRAY_COLOR,
263
+                'indigo'    => AUI_INDIGO_COLOR,
264
+                'orange'    => AUI_ORANGE_COLOR,
265
+                'black'     => AUI_BLACK_COLOR,
266
+            );
267
+        }
268
+
269
+        /**
270
+         * Add admin body class to show when BS5 is active.
271
+         *
272
+         * @param $classes
273
+         *
274
+         * @return mixed
275
+         */
276
+        public function add_bs5_admin_body_class( $classes = '' ) {
277
+            $classes .= ' aui_bs5';
278
+
279
+            return $classes;
280
+        }
281
+
282
+        /**
283
+         * Add a body class to show when BS5 is active.
284
+         *
285
+         * @param $classes
286
+         *
287
+         * @return mixed
288
+         */
289
+        public function add_bs5_body_class( $classes ) {
290
+            $classes[] = 'aui_bs5';
291
+
292
+            return $classes;
293
+        }
294
+
295
+        /**
296
+         * Initiate the settings and add the required action hooks.
297
+         */
298
+        public function init() {
299 299
             global $aui_bs5;
300 300
 
301
-			// Maybe fix settings
302
-			if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
303
-				$db_settings = get_option( 'ayecode-ui-settings' );
304
-				if ( ! empty( $db_settings ) ) {
305
-					$db_settings['css_backend'] = 'compatibility';
306
-					$db_settings['js_backend'] = 'core-popper';
307
-					update_option( 'ayecode-ui-settings', $db_settings );
308
-					wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309
-				}
310
-			}
301
+            // Maybe fix settings
302
+            if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
303
+                $db_settings = get_option( 'ayecode-ui-settings' );
304
+                if ( ! empty( $db_settings ) ) {
305
+                    $db_settings['css_backend'] = 'compatibility';
306
+                    $db_settings['js_backend'] = 'core-popper';
307
+                    update_option( 'ayecode-ui-settings', $db_settings );
308
+                    wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309
+                }
310
+            }
311 311
 
312
-			$this->constants();
313
-			$this->settings = $this->get_settings();
314
-			$this->url = $this->get_url();
312
+            $this->constants();
313
+            $this->settings = $this->get_settings();
314
+            $this->url = $this->get_url();
315 315
 
316 316
             // define the version
317
-			$aui_bs5 = $this->settings['bs_ver'] === '5';
318
-
319
-			if ( $aui_bs5 ) {
320
-				include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' );
321
-				add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 );
322
-				add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) );
323
-			}
324
-
325
-			/**
326
-			 * Maybe load CSS
327
-			 *
328
-			 * We load super early in case there is a theme version that might change the colors
329
-			 */
330
-			if ( $this->settings['css'] ) {
331
-				$priority = $this->is_bs3_compat() ? 100 : 1;
317
+            $aui_bs5 = $this->settings['bs_ver'] === '5';
318
+
319
+            if ( $aui_bs5 ) {
320
+                include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' );
321
+                add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 );
322
+                add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) );
323
+            }
324
+
325
+            /**
326
+             * Maybe load CSS
327
+             *
328
+             * We load super early in case there is a theme version that might change the colors
329
+             */
330
+            if ( $this->settings['css'] ) {
331
+                $priority = $this->is_bs3_compat() ? 100 : 1;
332 332
                 $priority = $aui_bs5 ? 10 : $priority;
333
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
334
-			}
335
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
337
-			}
338
-
339
-			// maybe load JS
340
-			if ( $this->settings['js'] ) {
341
-				$priority = $this->is_bs3_compat() ? 100 : 1;
342
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
343
-			}
344
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
346
-			}
347
-
348
-			// Maybe set the HTML font size
349
-			if ( $this->settings['html_font_size'] ) {
350
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
351
-			}
352
-
353
-			// Maybe show backend style error
354
-			if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
355
-				add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
356
-			}
357
-
358
-		}
359
-
360
-		/**
361
-		 * Show admin notice if backend scripts not loaded.
362
-		 */
363
-		public function show_admin_style_notice(){
364
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
365
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
366
-			$message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
367
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
368
-		}
369
-
370
-		/**
371
-		 * Check if we should load the admin scripts or not.
372
-		 *
373
-		 * @return bool
374
-		 */
375
-		public function load_admin_scripts(){
376
-			$result = true;
377
-
378
-			// check if specifically disabled
379
-			if(!empty($this->settings['disable_admin'])){
380
-				$url_parts = explode("\n",$this->settings['disable_admin']);
381
-				foreach($url_parts as $part){
382
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
383
-						return false; // return early, no point checking further
384
-					}
385
-				}
386
-			}
387
-
388
-			return $result;
389
-		}
390
-
391
-		/**
392
-		 * Add a html font size to the footer.
393
-		 */
394
-		public function html_font_size(){
395
-			$this->settings = $this->get_settings();
396
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
397
-		}
398
-
399
-		/**
400
-		 * Check if the current admin screen should load scripts.
401
-		 *
402
-		 * @return bool
403
-		 */
404
-		public function is_aui_screen(){
333
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
334
+            }
335
+            if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
337
+            }
338
+
339
+            // maybe load JS
340
+            if ( $this->settings['js'] ) {
341
+                $priority = $this->is_bs3_compat() ? 100 : 1;
342
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
343
+            }
344
+            if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
346
+            }
347
+
348
+            // Maybe set the HTML font size
349
+            if ( $this->settings['html_font_size'] ) {
350
+                add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
351
+            }
352
+
353
+            // Maybe show backend style error
354
+            if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
355
+                add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
356
+            }
357
+
358
+        }
359
+
360
+        /**
361
+         * Show admin notice if backend scripts not loaded.
362
+         */
363
+        public function show_admin_style_notice(){
364
+            $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
365
+            $button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
366
+            $message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
367
+            echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
368
+        }
369
+
370
+        /**
371
+         * Check if we should load the admin scripts or not.
372
+         *
373
+         * @return bool
374
+         */
375
+        public function load_admin_scripts(){
376
+            $result = true;
377
+
378
+            // check if specifically disabled
379
+            if(!empty($this->settings['disable_admin'])){
380
+                $url_parts = explode("\n",$this->settings['disable_admin']);
381
+                foreach($url_parts as $part){
382
+                    if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
383
+                        return false; // return early, no point checking further
384
+                    }
385
+                }
386
+            }
387
+
388
+            return $result;
389
+        }
390
+
391
+        /**
392
+         * Add a html font size to the footer.
393
+         */
394
+        public function html_font_size(){
395
+            $this->settings = $this->get_settings();
396
+            echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
397
+        }
398
+
399
+        /**
400
+         * Check if the current admin screen should load scripts.
401
+         *
402
+         * @return bool
403
+         */
404
+        public function is_aui_screen(){
405 405
 //			echo '###';exit;
406
-			$load = false;
407
-			// check if we should load or not
408
-			if ( is_admin() ) {
409
-				// Only enable on set pages
410
-				$aui_screens = array(
411
-					'page',
406
+            $load = false;
407
+            // check if we should load or not
408
+            if ( is_admin() ) {
409
+                // Only enable on set pages
410
+                $aui_screens = array(
411
+                    'page',
412 412
                     //'docs',
413
-					'post',
414
-					'settings_page_ayecode-ui-settings',
415
-					'appearance_page_gutenberg-widgets',
416
-					'widgets',
417
-					'ayecode-ui-settings',
418
-					'site-editor'
419
-				);
420
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
413
+                    'post',
414
+                    'settings_page_ayecode-ui-settings',
415
+                    'appearance_page_gutenberg-widgets',
416
+                    'widgets',
417
+                    'ayecode-ui-settings',
418
+                    'site-editor'
419
+                );
420
+                $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
421 421
 
422
-				$screen = get_current_screen();
422
+                $screen = get_current_screen();
423 423
 
424 424
 //				echo '###'.$screen->id;
425 425
 
426
-				// check if we are on a AUI screen
427
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
428
-					$load = true;
429
-				}
426
+                // check if we are on a AUI screen
427
+                if ( $screen && in_array( $screen->id, $screen_ids ) ) {
428
+                    $load = true;
429
+                }
430 430
 
431
-				//load for widget previews in WP 5.8
432
-				if( !empty($_REQUEST['legacy-widget-preview'])){
433
-					$load = true;
434
-				}
435
-			}
431
+                //load for widget previews in WP 5.8
432
+                if( !empty($_REQUEST['legacy-widget-preview'])){
433
+                    $load = true;
434
+                }
435
+            }
436 436
 
437 437
 
438 438
 
439
-			return apply_filters( 'aui_load_on_admin' , $load );
440
-		}
439
+            return apply_filters( 'aui_load_on_admin' , $load );
440
+        }
441 441
 
442
-		/**
443
-		 * Check if the current theme is a block theme.
444
-		 *
445
-		 * @return bool
446
-		 */
447
-		public static function is_block_theme() {
448
-			if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
449
-				return true;
450
-			}
442
+        /**
443
+         * Check if the current theme is a block theme.
444
+         *
445
+         * @return bool
446
+         */
447
+        public static function is_block_theme() {
448
+            if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
449
+                return true;
450
+            }
451 451
 
452
-			return false;
453
-		}
452
+            return false;
453
+        }
454 454
 
455
-		/**
456
-		 * Adds the styles.
457
-		 */
458
-		public function enqueue_style() {
455
+        /**
456
+         * Adds the styles.
457
+         */
458
+        public function enqueue_style() {
459 459
             global $aui_bs5;
460 460
 
461 461
             $load_fse = false;
462 462
 
463
-			if( is_admin() && !$this->is_aui_screen()){
464
-				// don't add wp-admin scripts if not requested to
465
-			}else{
466
-				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
463
+            if( is_admin() && !$this->is_aui_screen()){
464
+                // don't add wp-admin scripts if not requested to
465
+            }else{
466
+                $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
467 467
 
468
-				$rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : '';
468
+                $rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : '';
469 469
 
470 470
                 $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
471 471
 
472
-				if($this->settings[$css_setting]){
473
-					$compatibility = $this->settings[$css_setting]=='core' ? false : true;
474
-					$url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css';
472
+                if($this->settings[$css_setting]){
473
+                    $compatibility = $this->settings[$css_setting]=='core' ? false : true;
474
+                    $url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css';
475 475
 
476 476
 
477 477
 
478
-					wp_register_style( 'ayecode-ui', $url, array(), $this->version );
479
-					wp_enqueue_style( 'ayecode-ui' );
478
+                    wp_register_style( 'ayecode-ui', $url, array(), $this->version );
479
+                    wp_enqueue_style( 'ayecode-ui' );
480 480
 
481
-					$current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
481
+                    $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
482 482
 
483 483
 //					if ( is_admin() && !empty($_REQUEST['postType']) ) {
484
-					if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
485
-						$url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css';
486
-						wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
487
-						wp_enqueue_style( 'ayecode-ui-fse' );
488
-						$load_fse = true;
489
-					}
484
+                    if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
485
+                        $url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css';
486
+                        wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
487
+                        wp_enqueue_style( 'ayecode-ui-fse' );
488
+                        $load_fse = true;
489
+                    }
490 490
 
491 491
 
492
-					// flatpickr
493
-					wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
492
+                    // flatpickr
493
+                    wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
494 494
 
495
-					// fix some wp-admin issues
496
-					if(is_admin()){
497
-						$custom_css = "
495
+                    // fix some wp-admin issues
496
+                    if(is_admin()){
497
+                        $custom_css = "
498 498
                 body{
499 499
                     background-color: #f1f1f1;
500 500
                     font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif;
@@ -535,67 +535,67 @@  discard block
 block discarded – undo
535 535
 				}
536 536
                 ";
537 537
 
538
-						// @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
539
-						$custom_css .= "
538
+                        // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
539
+                        $custom_css .= "
540 540
 						.edit-post-sidebar input[type=color].components-text-control__input{
541 541
 						    padding: 0;
542 542
 						}
543 543
 					";
544
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
545
-					}
544
+                        wp_add_inline_style( 'ayecode-ui', $custom_css );
545
+                    }
546 546
 
547
-					// custom changes
548
-					if ( $load_fse ) {
549
-						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
-					}else{
551
-						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
547
+                    // custom changes
548
+                    if ( $load_fse ) {
549
+                        wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
+                    }else{
551
+                        wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
552 552
 
553
-					}
553
+                    }
554 554
 
555
-				}
556
-			}
555
+                }
556
+            }
557 557
 
558 558
 
559
-		}
559
+        }
560 560
 
561
-		/**
562
-		 * Get inline script used if bootstrap enqueued
563
-		 *
564
-		 * If this remains small then its best to use this than to add another JS file.
565
-		 */
566
-		public function inline_script() {
561
+        /**
562
+         * Get inline script used if bootstrap enqueued
563
+         *
564
+         * If this remains small then its best to use this than to add another JS file.
565
+         */
566
+        public function inline_script() {
567 567
             global $aui_bs5;
568
-			// Flatpickr calendar locale
569
-			$flatpickr_locale = self::flatpickr_locale();
570
-
571
-			ob_start();
572
-			if ( $aui_bs5 ) {
573
-				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
-			}else{
575
-				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
568
+            // Flatpickr calendar locale
569
+            $flatpickr_locale = self::flatpickr_locale();
570
+
571
+            ob_start();
572
+            if ( $aui_bs5 ) {
573
+                include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
+            }else{
575
+                include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
576 576
             }
577 577
 
578
-			$output = ob_get_clean();
578
+            $output = ob_get_clean();
579 579
 
580
-			/*
580
+            /*
581 581
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
582 582
 			 */
583
-			return str_replace( array(
584
-				'<script>',
585
-				'</script>'
586
-			), '', self::minify_js($output) );
587
-		}
588
-
589
-
590
-		/**
591
-		 * JS to help with conflict issues with other plugins and themes using bootstrap v3.
592
-		 *
593
-		 * @TODO we may need this when other conflicts arrise.
594
-		 * @return mixed
595
-		 */
596
-		public static function bs3_compat_js() {
597
-			ob_start();
598
-			?>
583
+            return str_replace( array(
584
+                '<script>',
585
+                '</script>'
586
+            ), '', self::minify_js($output) );
587
+        }
588
+
589
+
590
+        /**
591
+         * JS to help with conflict issues with other plugins and themes using bootstrap v3.
592
+         *
593
+         * @TODO we may need this when other conflicts arrise.
594
+         * @return mixed
595
+         */
596
+        public static function bs3_compat_js() {
597
+            ob_start();
598
+            ?>
599 599
             <script>
600 600
 				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
601 601
                 /* With Avada builder */
@@ -603,20 +603,20 @@  discard block
 block discarded – undo
603 603
 				<?php } ?>
604 604
             </script>
605 605
 			<?php
606
-			return str_replace( array(
607
-				'<script>',
608
-				'</script>'
609
-			), '', ob_get_clean());
610
-		}
611
-
612
-		/**
613
-		 * Get inline script used if bootstrap file browser enqueued.
614
-		 *
615
-		 * If this remains small then its best to use this than to add another JS file.
616
-		 */
617
-		public function inline_script_file_browser(){
618
-			ob_start();
619
-			?>
606
+            return str_replace( array(
607
+                '<script>',
608
+                '</script>'
609
+            ), '', ob_get_clean());
610
+        }
611
+
612
+        /**
613
+         * Get inline script used if bootstrap file browser enqueued.
614
+         *
615
+         * If this remains small then its best to use this than to add another JS file.
616
+         */
617
+        public function inline_script_file_browser(){
618
+            ob_start();
619
+            ?>
620 620
             <script>
621 621
                 // run on doc ready
622 622
                 jQuery(document).ready(function () {
@@ -624,282 +624,282 @@  discard block
 block discarded – undo
624 624
                 });
625 625
             </script>
626 626
 			<?php
627
-			$output = ob_get_clean();
627
+            $output = ob_get_clean();
628 628
 
629
-			/*
629
+            /*
630 630
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
631 631
 			 */
632
-			return str_replace( array(
633
-				'<script>',
634
-				'</script>'
635
-			), '', $output );
636
-		}
632
+            return str_replace( array(
633
+                '<script>',
634
+                '</script>'
635
+            ), '', $output );
636
+        }
637 637
 
638
-		/**
639
-		 * Adds the Font Awesome JS.
640
-		 */
641
-		public function enqueue_scripts() {
638
+        /**
639
+         * Adds the Font Awesome JS.
640
+         */
641
+        public function enqueue_scripts() {
642 642
 
643
-			if( is_admin() && !$this->is_aui_screen()){
644
-				// don't add wp-admin scripts if not requested to
645
-			}else {
643
+            if( is_admin() && !$this->is_aui_screen()){
644
+                // don't add wp-admin scripts if not requested to
645
+            }else {
646 646
 
647
-				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
647
+                $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
648 648
 
649
-				$bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
649
+                $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
650 650
 
651
-				// select2
652
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
651
+                // select2
652
+                wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
653 653
 
654
-				// flatpickr
655
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
654
+                // flatpickr
655
+                wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
656 656
 
657
-				// iconpicker
658
-				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
-					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
-				}else{
661
-					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
662
-				}
657
+                // iconpicker
658
+                if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
+                    wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
+                }else{
661
+                    wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
662
+                }
663 663
 
664
-				// Bootstrap file browser
665
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
667
-
668
-				$load_inline = false;
669
-
670
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
671
-					// Bootstrap bundle
672
-					$url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
674
-						'select2',
675
-						'jquery'
676
-					), $this->version, $this->is_bs3_compat() );
677
-					// if in admin then add to footer for compatibility.
678
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
679
-					$script = $this->inline_script();
680
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
682
-					$url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
-					wp_enqueue_script( 'bootstrap-js-popper' );
685
-					$load_inline = true;
686
-				} else {
687
-					$load_inline = true;
688
-				}
664
+                // Bootstrap file browser
665
+                wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
+                wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
667
+
668
+                $load_inline = false;
669
+
670
+                if ( $this->settings[ $js_setting ] == 'core-popper' ) {
671
+                    // Bootstrap bundle
672
+                    $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
+                    wp_register_script( 'bootstrap-js-bundle', $url, array(
674
+                        'select2',
675
+                        'jquery'
676
+                    ), $this->version, $this->is_bs3_compat() );
677
+                    // if in admin then add to footer for compatibility.
678
+                    is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
679
+                    $script = $this->inline_script();
680
+                    wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
+                } elseif ( $this->settings[ $js_setting ] == 'popper' ) {
682
+                    $url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
+                    wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
+                    wp_enqueue_script( 'bootstrap-js-popper' );
685
+                    $load_inline = true;
686
+                } else {
687
+                    $load_inline = true;
688
+                }
689 689
 
690
-				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
-				if ( $load_inline ) {
692
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
-					wp_enqueue_script( 'bootstrap-dummy' );
694
-					$script = $this->inline_script();
695
-					wp_add_inline_script( 'bootstrap-dummy', $script );
696
-				}
697
-			}
698
-
699
-		}
700
-
701
-		/**
702
-		 * Enqueue flatpickr if called.
703
-		 */
704
-		public function enqueue_flatpickr(){
705
-			wp_enqueue_style( 'flatpickr' );
706
-			wp_enqueue_script( 'flatpickr' );
707
-		}
708
-
709
-		/**
710
-		 * Enqueue iconpicker if called.
711
-		 */
712
-		public function enqueue_iconpicker(){
713
-			wp_enqueue_style( 'iconpicker' );
714
-			wp_enqueue_script( 'iconpicker' );
715
-		}
716
-
717
-		/**
718
-		 * Get the url path to the current folder.
719
-		 *
720
-		 * @return string
721
-		 */
722
-		public function get_url() {
723
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
-			$content_url = untrailingslashit( WP_CONTENT_URL );
725
-
726
-			// Replace http:// to https://.
727
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
-				$content_url = str_replace( 'http://', 'https://', $content_url );
729
-			}
730
-
731
-			// Check if we are inside a plugin
732
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
-			$url = str_replace( $content_dir, $content_url, $file_dir );
734
-
735
-			return trailingslashit( $url );
736
-		}
737
-
738
-		/**
739
-		 * Get the url path to the current folder.
740
-		 *
741
-		 * @return string
742
-		 */
743
-		public function get_url_old() {
744
-
745
-			$url = '';
746
-			// check if we are inside a plugin
747
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
748
-
749
-			// add check in-case user has changed wp-content dir name.
750
-			$wp_content_folder_name = basename(WP_CONTENT_DIR);
751
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
753
-
754
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
756
-			}
757
-
758
-			return $url;
759
-		}
760
-
761
-		/**
762
-		 * Register the database settings with WordPress.
763
-		 */
764
-		public function register_settings() {
765
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
766
-		}
767
-
768
-		/**
769
-		 * Add the WordPress settings menu item.
770
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
771
-		 */
772
-		public function menu_item() {
773
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775
-				$this,
776
-				'settings_page'
777
-			) );
778
-		}
779
-
780
-		/**
781
-		 * Get a list of themes and their default JS settings.
782
-		 *
783
-		 * @return array
784
-		 */
785
-		public function theme_js_settings(){
786
-			return array(
787
-				'ayetheme' => 'popper',
788
-				'listimia' => 'required',
789
-				'listimia_backend' => 'core-popper',
790
-				//'avada'    => 'required', // removed as we now add compatibility
791
-			);
792
-		}
793
-
794
-		/**
690
+                // Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
+                if ( $load_inline ) {
692
+                    wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
+                    wp_enqueue_script( 'bootstrap-dummy' );
694
+                    $script = $this->inline_script();
695
+                    wp_add_inline_script( 'bootstrap-dummy', $script );
696
+                }
697
+            }
698
+
699
+        }
700
+
701
+        /**
702
+         * Enqueue flatpickr if called.
703
+         */
704
+        public function enqueue_flatpickr(){
705
+            wp_enqueue_style( 'flatpickr' );
706
+            wp_enqueue_script( 'flatpickr' );
707
+        }
708
+
709
+        /**
710
+         * Enqueue iconpicker if called.
711
+         */
712
+        public function enqueue_iconpicker(){
713
+            wp_enqueue_style( 'iconpicker' );
714
+            wp_enqueue_script( 'iconpicker' );
715
+        }
716
+
717
+        /**
718
+         * Get the url path to the current folder.
719
+         *
720
+         * @return string
721
+         */
722
+        public function get_url() {
723
+            $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
+            $content_url = untrailingslashit( WP_CONTENT_URL );
725
+
726
+            // Replace http:// to https://.
727
+            if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
+                $content_url = str_replace( 'http://', 'https://', $content_url );
729
+            }
730
+
731
+            // Check if we are inside a plugin
732
+            $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
+            $url = str_replace( $content_dir, $content_url, $file_dir );
734
+
735
+            return trailingslashit( $url );
736
+        }
737
+
738
+        /**
739
+         * Get the url path to the current folder.
740
+         *
741
+         * @return string
742
+         */
743
+        public function get_url_old() {
744
+
745
+            $url = '';
746
+            // check if we are inside a plugin
747
+            $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
748
+
749
+            // add check in-case user has changed wp-content dir name.
750
+            $wp_content_folder_name = basename(WP_CONTENT_DIR);
751
+            $dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
+            $url_parts = explode("/$wp_content_folder_name/",plugins_url());
753
+
754
+            if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
+                $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
756
+            }
757
+
758
+            return $url;
759
+        }
760
+
761
+        /**
762
+         * Register the database settings with WordPress.
763
+         */
764
+        public function register_settings() {
765
+            register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
766
+        }
767
+
768
+        /**
769
+         * Add the WordPress settings menu item.
770
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
771
+         */
772
+        public function menu_item() {
773
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775
+                $this,
776
+                'settings_page'
777
+            ) );
778
+        }
779
+
780
+        /**
781
+         * Get a list of themes and their default JS settings.
782
+         *
783
+         * @return array
784
+         */
785
+        public function theme_js_settings(){
786
+            return array(
787
+                'ayetheme' => 'popper',
788
+                'listimia' => 'required',
789
+                'listimia_backend' => 'core-popper',
790
+                //'avada'    => 'required', // removed as we now add compatibility
791
+            );
792
+        }
793
+
794
+        /**
795 795
          * Get the date the site was installed.
796 796
          *
797
-		 * @return false|string
798
-		 */
797
+         * @return false|string
798
+         */
799 799
         public function get_site_install_date() {
800
-	        global $wpdb; // This gives you access to the WordPress database object
800
+            global $wpdb; // This gives you access to the WordPress database object
801
+
802
+            // Prepare the SQL query to get the oldest registration date
803
+            $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}";
801 804
 
802
-	        // Prepare the SQL query to get the oldest registration date
803
-	        $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}";
805
+            // Execute the query
806
+            $date = $wpdb->get_var($query);
804 807
 
805
-	        // Execute the query
806
-	        $date = $wpdb->get_var($query);
808
+            return $date ? $date : false;
809
+        }
807 810
 
808
-	        return $date ? $date : false;
811
+        /**
812
+         * Show admin notice if backend scripts not loaded.
813
+         */
814
+        public function show_admin_version_notice(){
815
+            $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" );
816
+            $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>';
817
+            $message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button;
818
+            echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
809 819
         }
810 820
 
811
-		/**
812
-		 * Show admin notice if backend scripts not loaded.
813
-		 */
814
-		public function show_admin_version_notice(){
815
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings" );
816
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>';
817
-			$message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button;
818
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
819
-		}
820
-
821
-		/**
822
-		 * Get the current Font Awesome output settings.
823
-		 *
824
-		 * @return array The array of settings.
825
-		 */
826
-		public function get_settings() {
827
-
828
-			$db_settings = get_option( 'ayecode-ui-settings' );
821
+        /**
822
+         * Get the current Font Awesome output settings.
823
+         *
824
+         * @return array The array of settings.
825
+         */
826
+        public function get_settings() {
827
+
828
+            $db_settings = get_option( 'ayecode-ui-settings' );
829 829
 
830 830
             // Maybe show default version notice
831
-			$site_install_date = new DateTime( self::get_site_install_date() );
832
-			$switch_over_date = new DateTime("2024-02-01");
833
-			if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) {
834
-				add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) );
835
-			}
836
-
837
-			$js_default = 'core-popper';
838
-			$js_default_backend = $js_default;
839
-
840
-			// maybe set defaults (if no settings set)
841
-			if(empty($db_settings)){
842
-				$active_theme = strtolower( get_template() ); // active parent theme.
843
-				$theme_js_settings = self::theme_js_settings();
844
-				if(isset($theme_js_settings[$active_theme])){
845
-					$js_default = $theme_js_settings[$active_theme];
846
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
847
-				}
848
-			}
831
+            $site_install_date = new DateTime( self::get_site_install_date() );
832
+            $switch_over_date = new DateTime("2024-02-01");
833
+            if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) {
834
+                add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) );
835
+            }
849 836
 
850
-			/**
851
-			 * Filter the default settings.
852
-			 */
853
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
854
-				'css'            => 'compatibility', // core, compatibility
855
-				'js'             => $js_default, // js to load, core-popper, popper
856
-				'html_font_size' => '16', // js to load, core-popper, popper
857
-				'css_backend'    => 'compatibility', // core, compatibility
858
-				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
859
-				'disable_admin'  => '', // URL snippets to disable loading on admin
837
+            $js_default = 'core-popper';
838
+            $js_default_backend = $js_default;
839
+
840
+            // maybe set defaults (if no settings set)
841
+            if(empty($db_settings)){
842
+                $active_theme = strtolower( get_template() ); // active parent theme.
843
+                $theme_js_settings = self::theme_js_settings();
844
+                if(isset($theme_js_settings[$active_theme])){
845
+                    $js_default = $theme_js_settings[$active_theme];
846
+                    $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
847
+                }
848
+            }
849
+
850
+            /**
851
+             * Filter the default settings.
852
+             */
853
+            $defaults = apply_filters( 'ayecode-ui-default-settings', array(
854
+                'css'            => 'compatibility', // core, compatibility
855
+                'js'             => $js_default, // js to load, core-popper, popper
856
+                'html_font_size' => '16', // js to load, core-popper, popper
857
+                'css_backend'    => 'compatibility', // core, compatibility
858
+                'js_backend'     => $js_default_backend, // js to load, core-popper, popper
859
+                'disable_admin'  => '', // URL snippets to disable loading on admin
860 860
                 'bs_ver'         => '5', // The default bootstrap version to sue by default
861
-			), $db_settings );
861
+            ), $db_settings );
862 862
 
863
-			$settings = wp_parse_args( $db_settings, $defaults );
863
+            $settings = wp_parse_args( $db_settings, $defaults );
864 864
 
865
-			/**
866
-			 * Filter the Bootstrap settings.
867
-			 *
868
-			 * @todo if we add this filer people might use it and then it defeats the purpose of this class :/
869
-			 */
870
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
871
-		}
865
+            /**
866
+             * Filter the Bootstrap settings.
867
+             *
868
+             * @todo if we add this filer people might use it and then it defeats the purpose of this class :/
869
+             */
870
+            return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
871
+        }
872 872
 
873 873
 
874
-		/**
875
-		 * The settings page html output.
876
-		 */
877
-		public function settings_page() {
878
-			if ( ! current_user_can( 'manage_options' ) ) {
879
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
880
-			}
874
+        /**
875
+         * The settings page html output.
876
+         */
877
+        public function settings_page() {
878
+            if ( ! current_user_can( 'manage_options' ) ) {
879
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
880
+            }
881 881
             $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() );
882 882
 
883
-			?>
883
+            ?>
884 884
             <div class="wrap">
885 885
                 <h1><?php echo $this->name; ?></h1>
886 886
                 <p><?php echo apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) );?></p>
887 887
                 <form method="post" action="options.php">
888 888
 					<?php
889
-					settings_fields( 'ayecode-ui-settings' );
890
-					do_settings_sections( 'ayecode-ui-settings' );
891
-					?>
889
+                    settings_fields( 'ayecode-ui-settings' );
890
+                    do_settings_sections( 'ayecode-ui-settings' );
891
+                    ?>
892 892
 
893 893
                     <h2><?php _e( 'BootStrap Version', 'ayecode-connect' ); ?></h2>
894 894
                     <p><?php echo apply_filters( 'ayecode-ui-version-settings-message', __("V5 is recommended, however if you have another plugin installed using v4, you may need to use v4 also.", 'ayecode-connect' ) );?></p>
895 895
 	                <div class="bsui"><?php
896
-	                if ( ! empty( $overrides ) ) {
897
-		                echo aui()->alert(array(
898
-			                'type'=> 'info',
899
-			                'content'=> __("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
900
-		                ));
901
-	                }
902
-	                ?>
896
+                    if ( ! empty( $overrides ) ) {
897
+                        echo aui()->alert(array(
898
+                            'type'=> 'info',
899
+                            'content'=> __("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
900
+                        ));
901
+                    }
902
+                    ?>
903 903
                     </div>
904 904
                     <table class="form-table wpbs-table-version-settings">
905 905
                         <tr valign="top">
@@ -983,77 +983,77 @@  discard block
 block discarded – undo
983 983
                     </table>
984 984
 
985 985
 					<?php
986
-					submit_button();
987
-					?>
986
+                    submit_button();
987
+                    ?>
988 988
                 </form>
989 989
                 <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo $this->version; ?></div>
990 990
             </div>
991 991
 			<?php
992
-		}
992
+        }
993 993
 
994 994
         public function get_load_source(){
995
-	        $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
996
-	        $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
997
-
998
-	        // Find source plugin/theme of SD
999
-	        $source = array();
1000
-	        if ( strpos( $file, $plugins_dir ) !== false ) {
1001
-		        $source = explode( "/", plugin_basename( $file ) );
1002
-	        } else if ( function_exists( 'get_theme_root' ) ) {
1003
-		        $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1004
-
1005
-		        if ( strpos( $file, $themes_dir ) !== false ) {
1006
-			        $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1007
-		        }
1008
-	        }
995
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
996
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
997
+
998
+            // Find source plugin/theme of SD
999
+            $source = array();
1000
+            if ( strpos( $file, $plugins_dir ) !== false ) {
1001
+                $source = explode( "/", plugin_basename( $file ) );
1002
+            } else if ( function_exists( 'get_theme_root' ) ) {
1003
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1004
+
1005
+                if ( strpos( $file, $themes_dir ) !== false ) {
1006
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1007
+                }
1008
+            }
1009 1009
 
1010 1010
             return isset($source[0]) ? esc_attr($source[0]) : '';
1011 1011
         }
1012 1012
 
1013
-		public function customizer_settings($wp_customize){
1014
-			$wp_customize->add_section('aui_settings', array(
1015
-				'title'    => __('AyeCode UI', 'ayecode-connect' ),
1016
-				'priority' => 120,
1017
-			));
1018
-
1019
-			//  =============================
1020
-			//  = Color Picker              =
1021
-			//  =============================
1022
-			$wp_customize->add_setting('aui_options[color_primary]', array(
1023
-				'default'           => AUI_PRIMARY_COLOR,
1024
-				'sanitize_callback' => 'sanitize_hex_color',
1025
-				'capability'        => 'edit_theme_options',
1026
-				'type'              => 'option',
1027
-				'transport'         => 'refresh',
1028
-			));
1029
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
-				'label'    => __('Primary Color', 'ayecode-connect' ),
1031
-				'section'  => 'aui_settings',
1032
-				'settings' => 'aui_options[color_primary]',
1033
-			)));
1034
-
1035
-			$wp_customize->add_setting('aui_options[color_secondary]', array(
1036
-				'default'           => '#6c757d',
1037
-				'sanitize_callback' => 'sanitize_hex_color',
1038
-				'capability'        => 'edit_theme_options',
1039
-				'type'              => 'option',
1040
-				'transport'         => 'refresh',
1041
-			));
1042
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
-				'label'    => __('Secondary Color', 'ayecode-connect' ),
1044
-				'section'  => 'aui_settings',
1045
-				'settings' => 'aui_options[color_secondary]',
1046
-			)));
1047
-		}
1048
-
1049
-		/**
1050
-		 * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1051
-		 *
1052
-		 * @return mixed
1053
-		 */
1054
-		public static function bs3_compat_css() {
1055
-			ob_start();
1056
-			?>
1013
+        public function customizer_settings($wp_customize){
1014
+            $wp_customize->add_section('aui_settings', array(
1015
+                'title'    => __('AyeCode UI', 'ayecode-connect' ),
1016
+                'priority' => 120,
1017
+            ));
1018
+
1019
+            //  =============================
1020
+            //  = Color Picker              =
1021
+            //  =============================
1022
+            $wp_customize->add_setting('aui_options[color_primary]', array(
1023
+                'default'           => AUI_PRIMARY_COLOR,
1024
+                'sanitize_callback' => 'sanitize_hex_color',
1025
+                'capability'        => 'edit_theme_options',
1026
+                'type'              => 'option',
1027
+                'transport'         => 'refresh',
1028
+            ));
1029
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
+                'label'    => __('Primary Color', 'ayecode-connect' ),
1031
+                'section'  => 'aui_settings',
1032
+                'settings' => 'aui_options[color_primary]',
1033
+            )));
1034
+
1035
+            $wp_customize->add_setting('aui_options[color_secondary]', array(
1036
+                'default'           => '#6c757d',
1037
+                'sanitize_callback' => 'sanitize_hex_color',
1038
+                'capability'        => 'edit_theme_options',
1039
+                'type'              => 'option',
1040
+                'transport'         => 'refresh',
1041
+            ));
1042
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
+                'label'    => __('Secondary Color', 'ayecode-connect' ),
1044
+                'section'  => 'aui_settings',
1045
+                'settings' => 'aui_options[color_secondary]',
1046
+            )));
1047
+        }
1048
+
1049
+        /**
1050
+         * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1051
+         *
1052
+         * @return mixed
1053
+         */
1054
+        public static function bs3_compat_css() {
1055
+            ob_start();
1056
+            ?>
1057 1057
             <style>
1058 1058
                 /* Bootstrap 3 compatibility */
1059 1059
                 body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;}
@@ -1082,55 +1082,55 @@  discard block
 block discarded – undo
1082 1082
                 <?php } ?>
1083 1083
             </style>
1084 1084
 			<?php
1085
-			return str_replace( array(
1086
-				'<style>',
1087
-				'</style>'
1088
-			), '', self::minify_css( ob_get_clean() ) );
1089
-		}
1085
+            return str_replace( array(
1086
+                '<style>',
1087
+                '</style>'
1088
+            ), '', self::minify_css( ob_get_clean() ) );
1089
+        }
1090 1090
 
1091 1091
 
1092
-		public static function custom_css($compatibility = true) {
1092
+        public static function custom_css($compatibility = true) {
1093 1093
             global $aui_bs5;
1094 1094
 
1095
-			$colors = array();
1096
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1095
+            $colors = array();
1096
+            if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1097 1097
 
1098 1098
 
1099
-				$setting = wp_get_global_settings();
1099
+                $setting = wp_get_global_settings();
1100 1100
 
1101 1101
 //                print_r(wp_get_global_styles());//exit;
1102 1102
 //                print_r(get_default_block_editor_settings());exit;
1103 1103
 
1104 1104
 //                print_r($setting);echo  '###';exit;
1105
-				if(!empty($setting['color']['palette']['theme'])){
1106
-					foreach($setting['color']['palette']['theme'] as $color){
1107
-						$colors[$color['slug']] = esc_attr($color['color']);
1108
-					}
1109
-				}
1105
+                if(!empty($setting['color']['palette']['theme'])){
1106
+                    foreach($setting['color']['palette']['theme'] as $color){
1107
+                        $colors[$color['slug']] = esc_attr($color['color']);
1108
+                    }
1109
+                }
1110 1110
 
1111
-				if(!empty($setting['color']['palette']['custom'])){
1112
-					foreach($setting['color']['palette']['custom'] as $color){
1113
-						$colors[$color['slug']] = esc_attr($color['color']);
1114
-					}
1115
-				}
1116
-			}else{
1117
-				$settings = get_option('aui_options');
1118
-				$colors = array(
1119
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1121
-				);
1122
-			}
1111
+                if(!empty($setting['color']['palette']['custom'])){
1112
+                    foreach($setting['color']['palette']['custom'] as $color){
1113
+                        $colors[$color['slug']] = esc_attr($color['color']);
1114
+                    }
1115
+                }
1116
+            }else{
1117
+                $settings = get_option('aui_options');
1118
+                $colors = array(
1119
+                    'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
+                    'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1121
+                );
1122
+            }
1123 1123
 
1124
-			ob_start();
1124
+            ob_start();
1125 1125
 
1126
-			?>
1126
+            ?>
1127 1127
             <style>
1128 1128
                 <?php
1129 1129
 
1130
-					// BS v3 compat
1131
-					if( self::is_bs3_compat() ){
1132
-						echo self::bs3_compat_css();
1133
-					}
1130
+                    // BS v3 compat
1131
+                    if( self::is_bs3_compat() ){
1132
+                        echo self::bs3_compat_css();
1133
+                    }
1134 1134
 
1135 1135
                     $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
1136 1136
                     $is_fse = false;
@@ -1138,26 +1138,26 @@  discard block
 block discarded – undo
1138 1138
                         $is_fse = true;
1139 1139
                     }
1140 1140
 
1141
-					if(!empty($colors)){
1142
-						$d_colors = self::get_colors(true);
1141
+                    if(!empty($colors)){
1142
+                        $d_colors = self::get_colors(true);
1143 1143
 
1144 1144
 //						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1145
-						foreach($colors as $key => $color ){
1146
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1147
-								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1148
-								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1149
-								echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color);
1150
-							}
1151
-						}
1152
-					   // exit;
1153
-					}
1145
+                        foreach($colors as $key => $color ){
1146
+                            if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1147
+                                $var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1148
+                                $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1149
+                                echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color);
1150
+                            }
1151
+                        }
1152
+                        // exit;
1153
+                    }
1154 1154
 
1155
-					// Set admin bar z-index lower when modal is open.
1156
-					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1155
+                    // Set admin bar z-index lower when modal is open.
1156
+                    echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1157 1157
 
1158
-					if(is_admin()){
1159
-						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1160
-					}
1158
+                    if(is_admin()){
1159
+                        echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1160
+                    }
1161 1161
 
1162 1162
                     if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' )  ){
1163 1163
                         $css = '';
@@ -1177,28 +1177,28 @@  discard block
 block discarded – undo
1177 1177
                         }
1178 1178
 
1179 1179
                         // line height
1180
-                         if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1180
+                            if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1181 1181
                             $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';';
1182 1182
                         }
1183 1183
 
1184 1184
 
1185
-                           // font weight
1186
-                         if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1185
+                            // font weight
1186
+                            if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1187 1187
                             $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';';
1188 1188
                         }
1189 1189
 
1190 1190
                         // Background
1191
-                         if( !empty( $theme_settings['color']['background'] ) ){
1191
+                            if( !empty( $theme_settings['color']['background'] ) ){
1192 1192
                             $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';';
1193 1193
                         }
1194 1194
 
1195
-                         // Background Gradient
1196
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1195
+                            // Background Gradient
1196
+                            if( !empty( $theme_settings['color']['gradient'] ) ){
1197 1197
                             $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1198 1198
                         }
1199 1199
 
1200
-                           // Background Gradient
1201
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1200
+                            // Background Gradient
1201
+                            if( !empty( $theme_settings['color']['gradient'] ) ){
1202 1202
                             $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1203 1203
                         }
1204 1204
 
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
                             $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';';
1237 1237
                         }
1238 1238
 
1239
-                         // heading font family
1239
+                            // heading font family
1240 1240
                         if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){
1241 1241
                             $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily']  ) . ';';
1242 1242
                         }
@@ -1249,21 +1249,21 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
                         foreach($hs as $hn){
1251 1251
                             $h_css = '';
1252
-                             if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1252
+                                if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1253 1253
                                 $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';';
1254
-                             }
1254
+                                }
1255 1255
 
1256
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1256
+                                if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1257 1257
                                 $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize']  ) . ';';
1258
-                             }
1258
+                                }
1259 1259
 
1260
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1260
+                                if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1261 1261
                                 $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily']  ) . ';';
1262
-                             }
1262
+                                }
1263 1263
 
1264
-                             if($h_css){
1264
+                                if($h_css){
1265 1265
                                 echo $bep . $hn . '{'.$h_css.'}';
1266
-                             }
1266
+                                }
1267 1267
                         }
1268 1268
 
1269 1269
 //                        wp_mail('[email protected]','ss',print_r($_SERVER,true).'@@@');
@@ -1273,171 +1273,171 @@  discard block
 block discarded – undo
1273 1273
 
1274 1274
 
1275 1275
                     }
1276
-				?>
1276
+                ?>
1277 1277
             </style>
1278 1278
 			<?php
1279 1279
 
1280 1280
 
1281
-			/*
1281
+            /*
1282 1282
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1283 1283
 			 */
1284
-			return str_replace( array(
1285
-				'<style>',
1286
-				'</style>'
1287
-			), '', self::minify_css( ob_get_clean() ) );
1288
-		}
1289
-
1290
-
1291
-
1292
-		/**
1293
-		 * Check if we should add booststrap 3 compatibility changes.
1294
-		 *
1295
-		 * @return bool
1296
-		 */
1297
-		public static function is_bs3_compat(){
1298
-			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1299
-		}
1300
-
1301
-		public static function hex_to_rgb($hex) {
1302
-			// Remove '#' if present
1303
-			$hex = str_replace('#', '', $hex);
1304
-
1305
-			// Convert 3-digit hex to 6-digit hex
1306
-			if(strlen($hex) == 3) {
1307
-				$hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2);
1308
-			}
1309
-
1310
-			// Convert hex to RGB
1311
-			$r = hexdec(substr($hex, 0, 2));
1312
-			$g = hexdec(substr($hex, 2, 2));
1313
-			$b = hexdec(substr($hex, 4, 2));
1314
-
1315
-			// Return RGB values as an array
1316
-			return $r . ',' . $g . ',' . $b;
1317
-		}
1318
-
1319
-		/**
1320
-		 * Build the CSS to overwrite a bootstrap color variable.
1321
-		 *
1322
-		 * @param $type
1323
-		 * @param $color_code
1324
-		 * @param $compatibility
1325
-		 *
1326
-		 * @return string
1327
-		 */
1328
-		public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1329
-			global $aui_bs5;
1330
-
1331
-			$is_var = false;
1332
-			$is_custom = strpos($type, 'custom-') !== false ? true : false;
1333
-			if(!$color_code){return '';}
1334
-			if(strpos($color_code, 'var') !== false){
1335
-				//if(!sanitize_hex_color($color_code)){
1336
-				$color_code = esc_attr($color_code);
1337
-				$is_var = true;
1284
+            return str_replace( array(
1285
+                '<style>',
1286
+                '</style>'
1287
+            ), '', self::minify_css( ob_get_clean() ) );
1288
+        }
1289
+
1290
+
1291
+
1292
+        /**
1293
+         * Check if we should add booststrap 3 compatibility changes.
1294
+         *
1295
+         * @return bool
1296
+         */
1297
+        public static function is_bs3_compat(){
1298
+            return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1299
+        }
1300
+
1301
+        public static function hex_to_rgb($hex) {
1302
+            // Remove '#' if present
1303
+            $hex = str_replace('#', '', $hex);
1304
+
1305
+            // Convert 3-digit hex to 6-digit hex
1306
+            if(strlen($hex) == 3) {
1307
+                $hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2);
1308
+            }
1309
+
1310
+            // Convert hex to RGB
1311
+            $r = hexdec(substr($hex, 0, 2));
1312
+            $g = hexdec(substr($hex, 2, 2));
1313
+            $b = hexdec(substr($hex, 4, 2));
1314
+
1315
+            // Return RGB values as an array
1316
+            return $r . ',' . $g . ',' . $b;
1317
+        }
1318
+
1319
+        /**
1320
+         * Build the CSS to overwrite a bootstrap color variable.
1321
+         *
1322
+         * @param $type
1323
+         * @param $color_code
1324
+         * @param $compatibility
1325
+         *
1326
+         * @return string
1327
+         */
1328
+        public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1329
+            global $aui_bs5;
1330
+
1331
+            $is_var = false;
1332
+            $is_custom = strpos($type, 'custom-') !== false ? true : false;
1333
+            if(!$color_code){return '';}
1334
+            if(strpos($color_code, 'var') !== false){
1335
+                //if(!sanitize_hex_color($color_code)){
1336
+                $color_code = esc_attr($color_code);
1337
+                $is_var = true;
1338 1338
 //				$color_code = "rgba($color_code, 0.5)";
1339 1339
 //                echo '###1'.$color_code.'###';//exit;
1340
-			}
1340
+            }
1341 1341
 
1342 1342
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1343 1343
 
1344
-			if(!$color_code){return '';}
1344
+            if(!$color_code){return '';}
1345 1345
 
1346
-			$rgb = self::hex_to_rgb($hex);
1346
+            $rgb = self::hex_to_rgb($hex);
1347 1347
 
1348
-			if($compatibility===true || $compatibility===1){
1349
-				$compatibility = '.bsui';
1350
-			}elseif(!$compatibility){
1351
-				$compatibility = '';
1352
-			}else{
1353
-				$compatibility = esc_attr($compatibility);
1354
-			}
1348
+            if($compatibility===true || $compatibility===1){
1349
+                $compatibility = '.bsui';
1350
+            }elseif(!$compatibility){
1351
+                $compatibility = '';
1352
+            }else{
1353
+                $compatibility = esc_attr($compatibility);
1354
+            }
1355 1355
 
1356
-			$prefix = $compatibility ? $compatibility . " " : "";
1356
+            $prefix = $compatibility ? $compatibility . " " : "";
1357 1357
 
1358 1358
 
1359 1359
             $output = '';
1360 1360
 
1361 1361
 //            echo '####'.$color_code;exit;
1362 1362
 
1363
-			$type = sanitize_html_class($type);
1363
+            $type = sanitize_html_class($type);
1364
+
1365
+            /**
1366
+             * c = color, b = background color, o = border-color, f = fill
1367
+             */
1368
+            $selectors = array(
1369
+                ".btn-{$type}"                                              => array( 'b', 'o' ),
1370
+                ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1371
+                ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1372
+                ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1373
+                ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1374
+                ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1375
+                ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1376
+                ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1377
+                ".badge-{$type}"                                            => array( 'b' ),
1378
+                ".alert-{$type}"                                            => array( 'b', 'o' ),
1379
+                ".bg-{$type}"                                               => array( 'b', 'f' ),
1380
+                ".btn-link.btn-{$type}"                                     => array( 'c' ),
1381
+                ".text-{$type}"                                     => array( 'c' ),
1382
+            );
1383
+
1384
+            if ( $aui_bs5 ) {
1385
+                unset($selectors[".alert-{$type}" ]);
1386
+            }
1364 1387
 
1365
-			/**
1366
-			 * c = color, b = background color, o = border-color, f = fill
1367
-			 */
1368
-			$selectors = array(
1369
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1370
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1371
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1372
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1373
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1374
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1375
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1376
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1377
-				".badge-{$type}"                                            => array( 'b' ),
1378
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1379
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1380
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1381
-				".text-{$type}"                                     => array( 'c' ),
1382
-			);
1383
-
1384
-			if ( $aui_bs5 ) {
1385
-				unset($selectors[".alert-{$type}" ]);
1386
-			}
1387
-
1388
-			if ( $type == 'primary' ) {
1389
-				$selectors = $selectors + array(
1390
-						'a'                                                                                                    => array( 'c' ),
1391
-						'.btn-link'                                                                                            => array( 'c' ),
1392
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1393
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1394
-							'b',
1395
-							'o'
1396
-						),
1397
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1398
-							'b',
1399
-							'o'
1400
-						),
1401
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1402
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1403
-						'.page-link'                                                                                           => array( 'c' ),
1404
-						'.page-item.active .page-link'                                                                         => array(
1405
-							'b',
1406
-							'o'
1407
-						),
1408
-						'.progress-bar'                                                                                        => array( 'b' ),
1409
-						'.list-group-item.active'                                                                              => array(
1410
-							'b',
1411
-							'o'
1412
-						),
1413
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1414
-					);
1415
-			}
1388
+            if ( $type == 'primary' ) {
1389
+                $selectors = $selectors + array(
1390
+                        'a'                                                                                                    => array( 'c' ),
1391
+                        '.btn-link'                                                                                            => array( 'c' ),
1392
+                        '.dropdown-item.active'                                                                                => array( 'b' ),
1393
+                        '.custom-control-input:checked~.custom-control-label::before'                                          => array(
1394
+                            'b',
1395
+                            'o'
1396
+                        ),
1397
+                        '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1398
+                            'b',
1399
+                            'o'
1400
+                        ),
1401
+                        '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1402
+                        '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1403
+                        '.page-link'                                                                                           => array( 'c' ),
1404
+                        '.page-item.active .page-link'                                                                         => array(
1405
+                            'b',
1406
+                            'o'
1407
+                        ),
1408
+                        '.progress-bar'                                                                                        => array( 'b' ),
1409
+                        '.list-group-item.active'                                                                              => array(
1410
+                            'b',
1411
+                            'o'
1412
+                        ),
1413
+                        '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1414
+                    );
1415
+            }
1416 1416
 
1417 1417
 
1418 1418
 
1419 1419
             // link
1420
-			if ( $type === 'primary' ) {
1421
-				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1422
-				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1423
-				$output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }';
1420
+            if ( $type === 'primary' ) {
1421
+                $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1422
+                $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1423
+                $output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }';
1424 1424
 
1425
-				$output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1426
-				$output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1425
+                $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1426
+                $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1427 1427
 
1428 1428
                 // dropdown
1429
-				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1429
+                $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1430 1430
 
1431 1431
                 // pagination
1432
-				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1432
+                $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1433 1433
 
1434
-			}
1434
+            }
1435 1435
 
1436
-			$output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1436
+            $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1437 1437
 
1438
-			//  buttons
1439
-			$output .= $prefix . ' .btn-'.esc_attr($type).'{';
1440
-			$output .= ' 
1438
+            //  buttons
1439
+            $output .= $prefix . ' .btn-'.esc_attr($type).'{';
1440
+            $output .= ' 
1441 1441
             --bs-btn-bg: '.esc_attr($color_code).';
1442 1442
             --bs-btn-border-color: '.esc_attr($color_code).';
1443 1443
             --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
@@ -1455,11 +1455,11 @@  discard block
 block discarded – undo
1455 1455
 //			--bs-btn-active-color: #fff;
1456 1456
 //			--bs-btn-disabled-color: #fff;
1457 1457
 //            ';
1458
-			$output .= '}';
1458
+            $output .= '}';
1459 1459
 
1460
-			//  buttons outline
1461
-			$output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1462
-			$output .= ' 
1460
+            //  buttons outline
1461
+            $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1462
+            $output .= ' 
1463 1463
             --bs-btn-border-color: '.esc_attr($color_code).';
1464 1464
             --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1465 1465
             --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
@@ -1476,37 +1476,37 @@  discard block
 block discarded – undo
1476 1476
 //			--bs-btn-active-color: #fff;
1477 1477
 //			--bs-btn-disabled-color: #fff;
1478 1478
 //            ';
1479
-			$output .= '}';
1479
+            $output .= '}';
1480 1480
 
1481 1481
 
1482 1482
             // button hover
1483
-			$output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1484
-			$output .= ' 
1483
+            $output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1484
+            $output .= ' 
1485 1485
             box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb) , .4);
1486 1486
             }
1487 1487
             ';
1488 1488
 
1489 1489
 
1490
-			if ( $aui_bs5 ) {
1490
+            if ( $aui_bs5 ) {
1491 1491
 //				$output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1492
-				$output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1493
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1494
-			}
1492
+                $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1493
+                $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1494
+            }
1495 1495
 
1496 1496
 
1497
-			if ( $is_custom ) {
1497
+            if ( $is_custom ) {
1498 1498
 
1499 1499
 //				echo '###'.$type;exit;
1500 1500
 
1501
-				// build rules into each type
1502
-				foreach($selectors as $selector => $types){
1503
-					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1504
-					$types = array_combine($types,$types);
1505
-					if(isset($types['c'])){$color[] = $selector;}
1506
-					if(isset($types['b'])){$background[] = $selector;}
1507
-					if(isset($types['o'])){$border[] = $selector;}
1508
-					if(isset($types['f'])){$fill[] = $selector;}
1509
-				}
1501
+                // build rules into each type
1502
+                foreach($selectors as $selector => $types){
1503
+                    $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1504
+                    $types = array_combine($types,$types);
1505
+                    if(isset($types['c'])){$color[] = $selector;}
1506
+                    if(isset($types['b'])){$background[] = $selector;}
1507
+                    if(isset($types['o'])){$border[] = $selector;}
1508
+                    if(isset($types['f'])){$fill[] = $selector;}
1509
+                }
1510 1510
 
1511 1511
 //				// build rules into each type
1512 1512
 //				foreach($important_selectors as $selector => $types){
@@ -1518,67 +1518,67 @@  discard block
 block discarded – undo
1518 1518
 //					if(isset($types['f'])){$fill_i[] = $selector;}
1519 1519
 //				}
1520 1520
 
1521
-				// add any color rules
1522
-				if(!empty($color)){
1523
-					$output .= implode(",",$color) . "{color: $color_code;} ";
1524
-				}
1525
-				if(!empty($color_i)){
1526
-					$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1527
-				}
1521
+                // add any color rules
1522
+                if(!empty($color)){
1523
+                    $output .= implode(",",$color) . "{color: $color_code;} ";
1524
+                }
1525
+                if(!empty($color_i)){
1526
+                    $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1527
+                }
1528 1528
 
1529
-				// add any background color rules
1530
-				if(!empty($background)){
1531
-					$output .= implode(",",$background) . "{background-color: $color_code;} ";
1532
-				}
1533
-				if(!empty($background_i)){
1534
-					$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1529
+                // add any background color rules
1530
+                if(!empty($background)){
1531
+                    $output .= implode(",",$background) . "{background-color: $color_code;} ";
1532
+                }
1533
+                if(!empty($background_i)){
1534
+                    $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1535 1535
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1536
-				}
1536
+                }
1537 1537
 
1538
-				// add any border color rules
1539
-				if(!empty($border)){
1540
-					$output .= implode(",",$border) . "{border-color: $color_code;} ";
1541
-				}
1542
-				if(!empty($border_i)){
1543
-					$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1544
-				}
1538
+                // add any border color rules
1539
+                if(!empty($border)){
1540
+                    $output .= implode(",",$border) . "{border-color: $color_code;} ";
1541
+                }
1542
+                if(!empty($border_i)){
1543
+                    $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1544
+                }
1545 1545
 
1546
-				// add any fill color rules
1547
-				if(!empty($fill)){
1548
-					$output .= implode(",",$fill) . "{fill: $color_code;} ";
1549
-				}
1550
-				if(!empty($fill_i)){
1551
-					$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1552
-				}
1546
+                // add any fill color rules
1547
+                if(!empty($fill)){
1548
+                    $output .= implode(",",$fill) . "{fill: $color_code;} ";
1549
+                }
1550
+                if(!empty($fill_i)){
1551
+                    $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1552
+                }
1553 1553
 
1554
-			}
1554
+            }
1555 1555
 
1556 1556
 
1557 1557
 
1558 1558
 
1559
-			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1560
-			// darken
1561
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1562
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1563
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1564
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1559
+            $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1560
+            // darken
1561
+            $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1562
+            $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1563
+            $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1564
+            $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1565 1565
 
1566
-			// lighten
1567
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1566
+            // lighten
1567
+            $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1568 1568
 
1569
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1570
-			$op_25 = $color_code."40"; // 25% opacity
1569
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1570
+            $op_25 = $color_code."40"; // 25% opacity
1571 1571
 
1572 1572
 
1573
-			// button states
1574
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1575
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1573
+            // button states
1574
+            $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1575
+            $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1576 1576
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1577
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1578
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1579
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1577
+            $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1578
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1579
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1580 1580
 
1581
-			// text
1581
+            // text
1582 1582
 //			$output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} ";
1583 1583
 
1584 1584
 
@@ -1593,773 +1593,773 @@  discard block
 block discarded – undo
1593 1593
 //				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1594 1594
 //			}
1595 1595
 
1596
-			// alerts
1597
-			if ( $aui_bs5 ) {
1596
+            // alerts
1597
+            if ( $aui_bs5 ) {
1598 1598
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1599
-				$output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1600
-			}
1601
-
1602
-			return $output;
1603
-		}
1604
-
1605
-		/**
1606
-		 * Build the CSS to overwrite a bootstrap color variable.
1607
-		 *
1608
-		 * @param $type
1609
-		 * @param $color_code
1610
-		 * @param $compatibility
1611
-		 *
1612
-		 * @return string
1613
-		 */
1614
-		public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1599
+                $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1600
+            }
1601
+
1602
+            return $output;
1603
+        }
1604
+
1605
+        /**
1606
+         * Build the CSS to overwrite a bootstrap color variable.
1607
+         *
1608
+         * @param $type
1609
+         * @param $color_code
1610
+         * @param $compatibility
1611
+         *
1612
+         * @return string
1613
+         */
1614
+        public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1615 1615
             global $aui_bs5;
1616 1616
 
1617
-			$is_var = false;
1618
-			if(!$color_code){return '';}
1619
-			if(strpos($color_code, 'var') !== false){
1620
-				//if(!sanitize_hex_color($color_code)){
1621
-				$color_code = esc_attr($color_code);
1622
-				$is_var = true;
1617
+            $is_var = false;
1618
+            if(!$color_code){return '';}
1619
+            if(strpos($color_code, 'var') !== false){
1620
+                //if(!sanitize_hex_color($color_code)){
1621
+                $color_code = esc_attr($color_code);
1622
+                $is_var = true;
1623 1623
 //				$color_code = "rgba($color_code, 0.5)";
1624 1624
 //                echo '###1'.$color_code.'###';//exit;
1625
-			}
1625
+            }
1626 1626
 
1627 1627
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1628 1628
 
1629
-			if(!$color_code){return '';}
1629
+            if(!$color_code){return '';}
1630 1630
 
1631 1631
             $rgb = self::hex_to_rgb($hex);
1632 1632
 
1633
-			if($compatibility===true || $compatibility===1){
1634
-				$compatibility = '.bsui';
1635
-			}elseif(!$compatibility){
1636
-				$compatibility = '';
1637
-			}else{
1638
-				$compatibility = esc_attr($compatibility);
1639
-			}
1633
+            if($compatibility===true || $compatibility===1){
1634
+                $compatibility = '.bsui';
1635
+            }elseif(!$compatibility){
1636
+                $compatibility = '';
1637
+            }else{
1638
+                $compatibility = esc_attr($compatibility);
1639
+            }
1640 1640
 
1641 1641
 
1642 1642
 
1643 1643
 //            echo '####'.$color_code;exit;
1644 1644
 
1645
-			$type = sanitize_html_class($type);
1646
-
1647
-			/**
1648
-			 * c = color, b = background color, o = border-color, f = fill
1649
-			 */
1650
-			$selectors = array(
1651
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1652
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1653
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1654
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1655
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1656
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1657
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1658
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1659
-				".badge-{$type}"                                            => array( 'b' ),
1660
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1661
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1662
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1663
-			);
1664
-
1665
-			if ( $aui_bs5 ) {
1645
+            $type = sanitize_html_class($type);
1646
+
1647
+            /**
1648
+             * c = color, b = background color, o = border-color, f = fill
1649
+             */
1650
+            $selectors = array(
1651
+                ".btn-{$type}"                                              => array( 'b', 'o' ),
1652
+                ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1653
+                ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1654
+                ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1655
+                ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1656
+                ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1657
+                ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1658
+                ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1659
+                ".badge-{$type}"                                            => array( 'b' ),
1660
+                ".alert-{$type}"                                            => array( 'b', 'o' ),
1661
+                ".bg-{$type}"                                               => array( 'b', 'f' ),
1662
+                ".btn-link.btn-{$type}"                                     => array( 'c' ),
1663
+            );
1664
+
1665
+            if ( $aui_bs5 ) {
1666 1666
                 unset($selectors[".alert-{$type}" ]);
1667
-			}
1668
-
1669
-			if ( $type == 'primary' ) {
1670
-				$selectors = $selectors + array(
1671
-						'a'                                                                                                    => array( 'c' ),
1672
-						'.btn-link'                                                                                            => array( 'c' ),
1673
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1674
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1675
-							'b',
1676
-							'o'
1677
-						),
1678
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1679
-							'b',
1680
-							'o'
1681
-						),
1682
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1683
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1684
-						'.page-link'                                                                                           => array( 'c' ),
1685
-						'.page-item.active .page-link'                                                                         => array(
1686
-							'b',
1687
-							'o'
1688
-						),
1689
-						'.progress-bar'                                                                                        => array( 'b' ),
1690
-						'.list-group-item.active'                                                                              => array(
1691
-							'b',
1692
-							'o'
1693
-						),
1694
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1667
+            }
1668
+
1669
+            if ( $type == 'primary' ) {
1670
+                $selectors = $selectors + array(
1671
+                        'a'                                                                                                    => array( 'c' ),
1672
+                        '.btn-link'                                                                                            => array( 'c' ),
1673
+                        '.dropdown-item.active'                                                                                => array( 'b' ),
1674
+                        '.custom-control-input:checked~.custom-control-label::before'                                          => array(
1675
+                            'b',
1676
+                            'o'
1677
+                        ),
1678
+                        '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1679
+                            'b',
1680
+                            'o'
1681
+                        ),
1682
+                        '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1683
+                        '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1684
+                        '.page-link'                                                                                           => array( 'c' ),
1685
+                        '.page-item.active .page-link'                                                                         => array(
1686
+                            'b',
1687
+                            'o'
1688
+                        ),
1689
+                        '.progress-bar'                                                                                        => array( 'b' ),
1690
+                        '.list-group-item.active'                                                                              => array(
1691
+                            'b',
1692
+                            'o'
1693
+                        ),
1694
+                        '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1695 1695
 //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1696 1696
 //				    '.custom-range::-moz-range-thumb' => array('b'),
1697 1697
 //				    '.custom-range::-ms-thumb' => array('b'),
1698
-					);
1699
-			}
1700
-
1701
-			$important_selectors = array(
1702
-				".bg-{$type}" => array('b','f'),
1703
-				".border-{$type}" => array('o'),
1704
-				".text-{$type}" => array('c'),
1705
-			);
1706
-
1707
-			$color = array();
1708
-			$color_i = array();
1709
-			$background = array();
1710
-			$background_i = array();
1711
-			$border = array();
1712
-			$border_i = array();
1713
-			$fill = array();
1714
-			$fill_i = array();
1715
-
1716
-			$output = '';
1717
-
1718
-			if ( $aui_bs5 ) {
1698
+                    );
1699
+            }
1700
+
1701
+            $important_selectors = array(
1702
+                ".bg-{$type}" => array('b','f'),
1703
+                ".border-{$type}" => array('o'),
1704
+                ".text-{$type}" => array('c'),
1705
+            );
1706
+
1707
+            $color = array();
1708
+            $color_i = array();
1709
+            $background = array();
1710
+            $background_i = array();
1711
+            $border = array();
1712
+            $border_i = array();
1713
+            $fill = array();
1714
+            $fill_i = array();
1715
+
1716
+            $output = '';
1717
+
1718
+            if ( $aui_bs5 ) {
1719 1719
 //				$output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1720
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1721
-			}
1722
-
1723
-			// build rules into each type
1724
-			foreach($selectors as $selector => $types){
1725
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1726
-				$types = array_combine($types,$types);
1727
-				if(isset($types['c'])){$color[] = $selector;}
1728
-				if(isset($types['b'])){$background[] = $selector;}
1729
-				if(isset($types['o'])){$border[] = $selector;}
1730
-				if(isset($types['f'])){$fill[] = $selector;}
1731
-			}
1732
-
1733
-			// build rules into each type
1734
-			foreach($important_selectors as $selector => $types){
1735
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1736
-				$types = array_combine($types,$types);
1737
-				if(isset($types['c'])){$color_i[] = $selector;}
1738
-				if(isset($types['b'])){$background_i[] = $selector;}
1739
-				if(isset($types['o'])){$border_i[] = $selector;}
1740
-				if(isset($types['f'])){$fill_i[] = $selector;}
1741
-			}
1742
-
1743
-			// add any color rules
1744
-			if(!empty($color)){
1745
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1746
-			}
1747
-			if(!empty($color_i)){
1748
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1749
-			}
1750
-
1751
-			// add any background color rules
1752
-			if(!empty($background)){
1753
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1754
-			}
1755
-			if(!empty($background_i)){
1756
-				$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1720
+                $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1721
+            }
1722
+
1723
+            // build rules into each type
1724
+            foreach($selectors as $selector => $types){
1725
+                $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1726
+                $types = array_combine($types,$types);
1727
+                if(isset($types['c'])){$color[] = $selector;}
1728
+                if(isset($types['b'])){$background[] = $selector;}
1729
+                if(isset($types['o'])){$border[] = $selector;}
1730
+                if(isset($types['f'])){$fill[] = $selector;}
1731
+            }
1732
+
1733
+            // build rules into each type
1734
+            foreach($important_selectors as $selector => $types){
1735
+                $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1736
+                $types = array_combine($types,$types);
1737
+                if(isset($types['c'])){$color_i[] = $selector;}
1738
+                if(isset($types['b'])){$background_i[] = $selector;}
1739
+                if(isset($types['o'])){$border_i[] = $selector;}
1740
+                if(isset($types['f'])){$fill_i[] = $selector;}
1741
+            }
1742
+
1743
+            // add any color rules
1744
+            if(!empty($color)){
1745
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1746
+            }
1747
+            if(!empty($color_i)){
1748
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1749
+            }
1750
+
1751
+            // add any background color rules
1752
+            if(!empty($background)){
1753
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1754
+            }
1755
+            if(!empty($background_i)){
1756
+                $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1757 1757
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1758
-			}
1758
+            }
1759 1759
 
1760
-			// add any border color rules
1761
-			if(!empty($border)){
1762
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1763
-			}
1764
-			if(!empty($border_i)){
1765
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1766
-			}
1760
+            // add any border color rules
1761
+            if(!empty($border)){
1762
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1763
+            }
1764
+            if(!empty($border_i)){
1765
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1766
+            }
1767 1767
 
1768
-			// add any fill color rules
1769
-			if(!empty($fill)){
1770
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1771
-			}
1772
-			if(!empty($fill_i)){
1773
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1774
-			}
1768
+            // add any fill color rules
1769
+            if(!empty($fill)){
1770
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1771
+            }
1772
+            if(!empty($fill_i)){
1773
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1774
+            }
1775 1775
 
1776 1776
 
1777
-			$prefix = $compatibility ? $compatibility . " " : "";
1777
+            $prefix = $compatibility ? $compatibility . " " : "";
1778 1778
 
1779
-			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1780
-			// darken
1781
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1782
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1783
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1784
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1779
+            $transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1780
+            // darken
1781
+            $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1782
+            $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1783
+            $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1784
+            $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1785 1785
 
1786
-			// lighten
1787
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1786
+            // lighten
1787
+            $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1788 1788
 
1789
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1790
-			$op_25 = $color_code."40"; // 25% opacity
1789
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1790
+            $op_25 = $color_code."40"; // 25% opacity
1791 1791
 
1792 1792
 
1793
-			// button states
1794
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1795
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1793
+            // button states
1794
+            $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1795
+            $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1796 1796
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1797
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1798
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1799
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1797
+            $output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1798
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1799
+            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1800 1800
 
1801
-			if ( $type == 'primary' ) {
1802
-				// dropdown's
1803
-				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1801
+            if ( $type == 'primary' ) {
1802
+                // dropdown's
1803
+                $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1804 1804
 
1805
-				// input states
1806
-				$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1805
+                // input states
1806
+                $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1807 1807
 
1808
-				// page link
1809
-				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1810
-			}
1808
+                // page link
1809
+                $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1810
+            }
1811 1811
 
1812 1812
             // alerts
1813
-			if ( $aui_bs5 ) {
1813
+            if ( $aui_bs5 ) {
1814 1814
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1815
-				$output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1816
-			}
1817
-
1818
-			return $output;
1819
-		}
1820
-
1821
-		/**
1822
-		 *
1823
-		 * @deprecated 0.1.76 Use css_overwrite()
1824
-		 *
1825
-		 * @param $color_code
1826
-		 * @param $compatibility
1827
-		 * @param $use_variable
1828
-		 *
1829
-		 * @return string
1830
-		 */
1831
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
1832
-
1833
-			if(!$use_variable){
1834
-				$color_code = sanitize_hex_color($color_code);
1835
-				if(!$color_code){return '';}
1836
-			}
1837
-
1838
-			/**
1839
-			 * c = color, b = background color, o = border-color, f = fill
1840
-			 */
1841
-			$selectors = array(
1842
-				'a' => array('c'),
1843
-				'.btn-primary' => array('b','o'),
1844
-				'.btn-primary.disabled' => array('b','o'),
1845
-				'.btn-primary:disabled' => array('b','o'),
1846
-				'.btn-outline-primary' => array('c','o'),
1847
-				'.btn-outline-primary:hover' => array('b','o'),
1848
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1849
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1850
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1851
-				'.btn-link' => array('c'),
1852
-				'.dropdown-item.active' => array('b'),
1853
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1854
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1815
+                $output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1816
+            }
1817
+
1818
+            return $output;
1819
+        }
1820
+
1821
+        /**
1822
+         *
1823
+         * @deprecated 0.1.76 Use css_overwrite()
1824
+         *
1825
+         * @param $color_code
1826
+         * @param $compatibility
1827
+         * @param $use_variable
1828
+         *
1829
+         * @return string
1830
+         */
1831
+        public static function css_primary($color_code,$compatibility, $use_variable = false){
1832
+
1833
+            if(!$use_variable){
1834
+                $color_code = sanitize_hex_color($color_code);
1835
+                if(!$color_code){return '';}
1836
+            }
1837
+
1838
+            /**
1839
+             * c = color, b = background color, o = border-color, f = fill
1840
+             */
1841
+            $selectors = array(
1842
+                'a' => array('c'),
1843
+                '.btn-primary' => array('b','o'),
1844
+                '.btn-primary.disabled' => array('b','o'),
1845
+                '.btn-primary:disabled' => array('b','o'),
1846
+                '.btn-outline-primary' => array('c','o'),
1847
+                '.btn-outline-primary:hover' => array('b','o'),
1848
+                '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1849
+                '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1850
+                '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1851
+                '.btn-link' => array('c'),
1852
+                '.dropdown-item.active' => array('b'),
1853
+                '.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1854
+                '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1855 1855
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1856 1856
 //				'.custom-range::-moz-range-thumb' => array('b'),
1857 1857
 //				'.custom-range::-ms-thumb' => array('b'),
1858
-				'.nav-pills .nav-link.active' => array('b'),
1859
-				'.nav-pills .show>.nav-link' => array('b'),
1860
-				'.page-link' => array('c'),
1861
-				'.page-item.active .page-link' => array('b','o'),
1862
-				'.badge-primary' => array('b'),
1863
-				'.alert-primary' => array('b','o'),
1864
-				'.progress-bar' => array('b'),
1865
-				'.list-group-item.active' => array('b','o'),
1866
-				'.bg-primary' => array('b','f'),
1867
-				'.btn-link.btn-primary' => array('c'),
1868
-				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1869
-			);
1870
-
1871
-			$important_selectors = array(
1872
-				'.bg-primary' => array('b','f'),
1873
-				'.border-primary' => array('o'),
1874
-				'.text-primary' => array('c'),
1875
-			);
1876
-
1877
-			$color = array();
1878
-			$color_i = array();
1879
-			$background = array();
1880
-			$background_i = array();
1881
-			$border = array();
1882
-			$border_i = array();
1883
-			$fill = array();
1884
-			$fill_i = array();
1885
-
1886
-			$output = '';
1887
-
1888
-			// build rules into each type
1889
-			foreach($selectors as $selector => $types){
1890
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1891
-				$types = array_combine($types,$types);
1892
-				if(isset($types['c'])){$color[] = $selector;}
1893
-				if(isset($types['b'])){$background[] = $selector;}
1894
-				if(isset($types['o'])){$border[] = $selector;}
1895
-				if(isset($types['f'])){$fill[] = $selector;}
1896
-			}
1897
-
1898
-			// build rules into each type
1899
-			foreach($important_selectors as $selector => $types){
1900
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1901
-				$types = array_combine($types,$types);
1902
-				if(isset($types['c'])){$color_i[] = $selector;}
1903
-				if(isset($types['b'])){$background_i[] = $selector;}
1904
-				if(isset($types['o'])){$border_i[] = $selector;}
1905
-				if(isset($types['f'])){$fill_i[] = $selector;}
1906
-			}
1907
-
1908
-			// add any color rules
1909
-			if(!empty($color)){
1910
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1911
-			}
1912
-			if(!empty($color_i)){
1913
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1914
-			}
1915
-
1916
-			// add any background color rules
1917
-			if(!empty($background)){
1918
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1919
-			}
1920
-			if(!empty($background_i)){
1921
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1922
-			}
1923
-
1924
-			// add any border color rules
1925
-			if(!empty($border)){
1926
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1927
-			}
1928
-			if(!empty($border_i)){
1929
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1930
-			}
1931
-
1932
-			// add any fill color rules
1933
-			if(!empty($fill)){
1934
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1935
-			}
1936
-			if(!empty($fill_i)){
1937
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1938
-			}
1939
-
1940
-
1941
-			$prefix = $compatibility ? ".bsui " : "";
1942
-
1943
-			// darken
1944
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1945
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1946
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1947
-
1948
-			// lighten
1949
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1950
-
1951
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1952
-			$op_25 = $color_code."40"; // 25% opacity
1953
-
1954
-
1955
-			// button states
1956
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1957
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1958
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1959
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1960
-
1961
-
1962
-			// dropdown's
1963
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1964
-
1965
-
1966
-			// input states
1967
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1968
-
1969
-			// page link
1970
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1971
-
1972
-			return $output;
1973
-		}
1974
-
1975
-		/**
1976
-		 *
1977
-		 * @deprecated 0.1.76 Use css_overwrite()
1978
-		 *
1979
-		 * @param $color_code
1980
-		 * @param $compatibility
1981
-		 *
1982
-		 * @return string
1983
-		 */
1984
-		public static function css_secondary($color_code,$compatibility){;
1985
-			$color_code = sanitize_hex_color($color_code);
1986
-			if(!$color_code){return '';}
1987
-			/**
1988
-			 * c = color, b = background color, o = border-color, f = fill
1989
-			 */
1990
-			$selectors = array(
1991
-				'.btn-secondary' => array('b','o'),
1992
-				'.btn-secondary.disabled' => array('b','o'),
1993
-				'.btn-secondary:disabled' => array('b','o'),
1994
-				'.btn-outline-secondary' => array('c','o'),
1995
-				'.btn-outline-secondary:hover' => array('b','o'),
1996
-				'.btn-outline-secondary.disabled' => array('c'),
1997
-				'.btn-outline-secondary:disabled' => array('c'),
1998
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
1999
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2000
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2001
-				'.badge-secondary' => array('b'),
2002
-				'.alert-secondary' => array('b','o'),
2003
-				'.btn-link.btn-secondary' => array('c'),
2004
-			);
2005
-
2006
-			$important_selectors = array(
2007
-				'.bg-secondary' => array('b','f'),
2008
-				'.border-secondary' => array('o'),
2009
-				'.text-secondary' => array('c'),
2010
-			);
2011
-
2012
-			$color = array();
2013
-			$color_i = array();
2014
-			$background = array();
2015
-			$background_i = array();
2016
-			$border = array();
2017
-			$border_i = array();
2018
-			$fill = array();
2019
-			$fill_i = array();
2020
-
2021
-			$output = '';
2022
-
2023
-			// build rules into each type
2024
-			foreach($selectors as $selector => $types){
2025
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2026
-				$types = array_combine($types,$types);
2027
-				if(isset($types['c'])){$color[] = $selector;}
2028
-				if(isset($types['b'])){$background[] = $selector;}
2029
-				if(isset($types['o'])){$border[] = $selector;}
2030
-				if(isset($types['f'])){$fill[] = $selector;}
2031
-			}
2032
-
2033
-			// build rules into each type
2034
-			foreach($important_selectors as $selector => $types){
2035
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2036
-				$types = array_combine($types,$types);
2037
-				if(isset($types['c'])){$color_i[] = $selector;}
2038
-				if(isset($types['b'])){$background_i[] = $selector;}
2039
-				if(isset($types['o'])){$border_i[] = $selector;}
2040
-				if(isset($types['f'])){$fill_i[] = $selector;}
2041
-			}
2042
-
2043
-			// add any color rules
2044
-			if(!empty($color)){
2045
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2046
-			}
2047
-			if(!empty($color_i)){
2048
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2049
-			}
2050
-
2051
-			// add any background color rules
2052
-			if(!empty($background)){
2053
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2054
-			}
2055
-			if(!empty($background_i)){
2056
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2057
-			}
2058
-
2059
-			// add any border color rules
2060
-			if(!empty($border)){
2061
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2062
-			}
2063
-			if(!empty($border_i)){
2064
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2065
-			}
2066
-
2067
-			// add any fill color rules
2068
-			if(!empty($fill)){
2069
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2070
-			}
2071
-			if(!empty($fill_i)){
2072
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2073
-			}
2074
-
2075
-
2076
-			$prefix = $compatibility ? ".bsui " : "";
2077
-
2078
-			// darken
2079
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2080
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2081
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2082
-
2083
-			// lighten
2084
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2085
-
2086
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
2087
-			$op_25 = $color_code."40"; // 25% opacity
2088
-
2089
-
2090
-			// button states
2091
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2092
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2093
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2094
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2095
-
2096
-
2097
-			return $output;
2098
-		}
2099
-
2100
-		/**
2101
-		 * Increases or decreases the brightness of a color by a percentage of the current brightness.
2102
-		 *
2103
-		 * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
2104
-		 * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
2105
-		 *
2106
-		 * @return  string
2107
-		 */
2108
-		public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2109
-			$hexCode = ltrim($hexCode, '#');
2110
-
2111
-			if (strlen($hexCode) == 3) {
2112
-				$hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2113
-			}
2114
-
2115
-			$hexCode = array_map('hexdec', str_split($hexCode, 2));
2116
-
2117
-			foreach ($hexCode as & $color) {
2118
-				$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2119
-				$adjustAmount = ceil($adjustableLimit * $adjustPercent);
2120
-
2121
-				$color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2122
-			}
2123
-
2124
-			return '#' . implode($hexCode);
2125
-		}
2126
-
2127
-		/**
2128
-		 * Check if we should display examples.
2129
-		 */
2130
-		public function maybe_show_examples(){
2131
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2132
-				echo "<head>";
2133
-				wp_head();
2134
-				echo "</head>";
2135
-				echo "<body>";
2136
-				echo $this->get_examples();
2137
-				echo "</body>";
2138
-				exit;
2139
-			}
2140
-		}
2141
-
2142
-		/**
2143
-		 * Get developer examples.
2144
-		 *
2145
-		 * @return string
2146
-		 */
2147
-		public function get_examples(){
2148
-			$output = '';
2149
-
2150
-
2151
-			// open form
2152
-			$output .= "<form class='p-5 m-5 border rounded'>";
2153
-
2154
-			// input example
2155
-			$output .= aui()->input(array(
2156
-				'type'  =>  'text',
2157
-				'id'    =>  'text-example',
2158
-				'name'    =>  'text-example',
2159
-				'placeholder'   => 'text placeholder',
2160
-				'title'   => 'Text input example',
2161
-				'value' =>  '',
2162
-				'required'  => false,
2163
-				'help_text' => 'help text',
2164
-				'label' => 'Text input example label'
2165
-			));
2166
-
2167
-			// input example
2168
-			$output .= aui()->input(array(
2169
-				'type'  =>  'url',
2170
-				'id'    =>  'text-example2',
2171
-				'name'    =>  'text-example',
2172
-				'placeholder'   => 'url placeholder',
2173
-				'title'   => 'Text input example',
2174
-				'value' =>  '',
2175
-				'required'  => false,
2176
-				'help_text' => 'help text',
2177
-				'label' => 'Text input example label'
2178
-			));
2179
-
2180
-			// checkbox example
2181
-			$output .= aui()->input(array(
2182
-				'type'  =>  'checkbox',
2183
-				'id'    =>  'checkbox-example',
2184
-				'name'    =>  'checkbox-example',
2185
-				'placeholder'   => 'checkbox-example',
2186
-				'title'   => 'Checkbox example',
2187
-				'value' =>  '1',
2188
-				'checked'   => true,
2189
-				'required'  => false,
2190
-				'help_text' => 'help text',
2191
-				'label' => 'Checkbox checked'
2192
-			));
2193
-
2194
-			// checkbox example
2195
-			$output .= aui()->input(array(
2196
-				'type'  =>  'checkbox',
2197
-				'id'    =>  'checkbox-example2',
2198
-				'name'    =>  'checkbox-example2',
2199
-				'placeholder'   => 'checkbox-example',
2200
-				'title'   => 'Checkbox example',
2201
-				'value' =>  '1',
2202
-				'checked'   => false,
2203
-				'required'  => false,
2204
-				'help_text' => 'help text',
2205
-				'label' => 'Checkbox un-checked'
2206
-			));
2207
-
2208
-			// switch example
2209
-			$output .= aui()->input(array(
2210
-				'type'  =>  'checkbox',
2211
-				'id'    =>  'switch-example',
2212
-				'name'    =>  'switch-example',
2213
-				'placeholder'   => 'checkbox-example',
2214
-				'title'   => 'Switch example',
2215
-				'value' =>  '1',
2216
-				'checked'   => true,
2217
-				'switch'    => true,
2218
-				'required'  => false,
2219
-				'help_text' => 'help text',
2220
-				'label' => 'Switch on'
2221
-			));
2222
-
2223
-			// switch example
2224
-			$output .= aui()->input(array(
2225
-				'type'  =>  'checkbox',
2226
-				'id'    =>  'switch-example2',
2227
-				'name'    =>  'switch-example2',
2228
-				'placeholder'   => 'checkbox-example',
2229
-				'title'   => 'Switch example',
2230
-				'value' =>  '1',
2231
-				'checked'   => false,
2232
-				'switch'    => true,
2233
-				'required'  => false,
2234
-				'help_text' => 'help text',
2235
-				'label' => 'Switch off'
2236
-			));
2237
-
2238
-			// close form
2239
-			$output .= "</form>";
2240
-
2241
-			return $output;
2242
-		}
2243
-
2244
-		/**
2245
-		 * Calendar params.
2246
-		 *
2247
-		 * @since 0.1.44
2248
-		 *
2249
-		 * @return array Calendar params.
2250
-		 */
2251
-		public static function calendar_params() {
2252
-			$params = array(
2253
-				'month_long_1' => __( 'January', 'ayecode-connect' ),
2254
-				'month_long_2' => __( 'February', 'ayecode-connect' ),
2255
-				'month_long_3' => __( 'March', 'ayecode-connect' ),
2256
-				'month_long_4' => __( 'April', 'ayecode-connect' ),
2257
-				'month_long_5' => __( 'May', 'ayecode-connect' ),
2258
-				'month_long_6' => __( 'June', 'ayecode-connect' ),
2259
-				'month_long_7' => __( 'July', 'ayecode-connect' ),
2260
-				'month_long_8' => __( 'August', 'ayecode-connect' ),
2261
-				'month_long_9' => __( 'September', 'ayecode-connect' ),
2262
-				'month_long_10' => __( 'October', 'ayecode-connect' ),
2263
-				'month_long_11' => __( 'November', 'ayecode-connect' ),
2264
-				'month_long_12' => __( 'December', 'ayecode-connect' ),
2265
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2266
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2267
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2268
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2269
-				'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2270
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2271
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2272
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2273
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2274
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2275
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2276
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2277
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2278
-				'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2279
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2280
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2281
-				'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2282
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2283
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2284
-				'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2285
-				'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2286
-				'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2287
-				'day_s2_4' => __( 'We', 'ayecode-connect' ),
2288
-				'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2289
-				'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2290
-				'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2291
-				'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2292
-				'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2293
-				'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2294
-				'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2295
-				'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2296
-				'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2297
-				'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2298
-				'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2299
-				'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2300
-				'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2301
-				'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2302
-				'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2303
-				'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2304
-				'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2305
-				'am_lower' => __( 'am', 'ayecode-connect' ),
2306
-				'pm_lower' => __( 'pm', 'ayecode-connect' ),
2307
-				'am_upper' => __( 'AM', 'ayecode-connect' ),
2308
-				'pm_upper' => __( 'PM', 'ayecode-connect' ),
2309
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2310
-				'time_24hr' => false,
2311
-				'year' => __( 'Year', 'ayecode-connect' ),
2312
-				'hour' => __( 'Hour', 'ayecode-connect' ),
2313
-				'minute' => __( 'Minute', 'ayecode-connect' ),
2314
-				'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2315
-				'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2316
-				'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2317
-				'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2318
-			);
2319
-
2320
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2321
-		}
2322
-
2323
-		/**
2324
-		 * Flatpickr calendar localize.
2325
-		 *
2326
-		 * @since 0.1.44
2327
-		 *
2328
-		 * @return string Calendar locale.
2329
-		 */
2330
-		public static function flatpickr_locale() {
2331
-			$params = self::calendar_params();
2332
-
2333
-			if ( is_string( $params ) ) {
2334
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2335
-			} else {
2336
-				foreach ( (array) $params as $key => $value ) {
2337
-					if ( ! is_scalar( $value ) ) {
2338
-						continue;
2339
-					}
2340
-
2341
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2342
-				}
2343
-			}
1858
+                '.nav-pills .nav-link.active' => array('b'),
1859
+                '.nav-pills .show>.nav-link' => array('b'),
1860
+                '.page-link' => array('c'),
1861
+                '.page-item.active .page-link' => array('b','o'),
1862
+                '.badge-primary' => array('b'),
1863
+                '.alert-primary' => array('b','o'),
1864
+                '.progress-bar' => array('b'),
1865
+                '.list-group-item.active' => array('b','o'),
1866
+                '.bg-primary' => array('b','f'),
1867
+                '.btn-link.btn-primary' => array('c'),
1868
+                '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1869
+            );
1870
+
1871
+            $important_selectors = array(
1872
+                '.bg-primary' => array('b','f'),
1873
+                '.border-primary' => array('o'),
1874
+                '.text-primary' => array('c'),
1875
+            );
1876
+
1877
+            $color = array();
1878
+            $color_i = array();
1879
+            $background = array();
1880
+            $background_i = array();
1881
+            $border = array();
1882
+            $border_i = array();
1883
+            $fill = array();
1884
+            $fill_i = array();
1885
+
1886
+            $output = '';
1887
+
1888
+            // build rules into each type
1889
+            foreach($selectors as $selector => $types){
1890
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1891
+                $types = array_combine($types,$types);
1892
+                if(isset($types['c'])){$color[] = $selector;}
1893
+                if(isset($types['b'])){$background[] = $selector;}
1894
+                if(isset($types['o'])){$border[] = $selector;}
1895
+                if(isset($types['f'])){$fill[] = $selector;}
1896
+            }
1897
+
1898
+            // build rules into each type
1899
+            foreach($important_selectors as $selector => $types){
1900
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1901
+                $types = array_combine($types,$types);
1902
+                if(isset($types['c'])){$color_i[] = $selector;}
1903
+                if(isset($types['b'])){$background_i[] = $selector;}
1904
+                if(isset($types['o'])){$border_i[] = $selector;}
1905
+                if(isset($types['f'])){$fill_i[] = $selector;}
1906
+            }
1907
+
1908
+            // add any color rules
1909
+            if(!empty($color)){
1910
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1911
+            }
1912
+            if(!empty($color_i)){
1913
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1914
+            }
1915
+
1916
+            // add any background color rules
1917
+            if(!empty($background)){
1918
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1919
+            }
1920
+            if(!empty($background_i)){
1921
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1922
+            }
1923
+
1924
+            // add any border color rules
1925
+            if(!empty($border)){
1926
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1927
+            }
1928
+            if(!empty($border_i)){
1929
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1930
+            }
1931
+
1932
+            // add any fill color rules
1933
+            if(!empty($fill)){
1934
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1935
+            }
1936
+            if(!empty($fill_i)){
1937
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1938
+            }
1939
+
1940
+
1941
+            $prefix = $compatibility ? ".bsui " : "";
1942
+
1943
+            // darken
1944
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1945
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1946
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1947
+
1948
+            // lighten
1949
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1950
+
1951
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1952
+            $op_25 = $color_code."40"; // 25% opacity
1953
+
2344 1954
 
2345
-			$day_s3 = array();
2346
-			$day_s5 = array();
1955
+            // button states
1956
+            $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1957
+            $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1958
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1959
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2347 1960
 
2348
-			for ( $i = 1; $i <= 7; $i ++ ) {
2349
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2350
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2351
-			}
2352 1961
 
2353
-			$month_s = array();
2354
-			$month_long = array();
1962
+            // dropdown's
1963
+            $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2355 1964
 
2356
-			for ( $i = 1; $i <= 12; $i ++ ) {
2357
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2358
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2359
-			}
2360 1965
 
2361
-			ob_start();
2362
-		if ( 0 ) { ?><script><?php } ?>
1966
+            // input states
1967
+            $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1968
+
1969
+            // page link
1970
+            $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1971
+
1972
+            return $output;
1973
+        }
1974
+
1975
+        /**
1976
+         *
1977
+         * @deprecated 0.1.76 Use css_overwrite()
1978
+         *
1979
+         * @param $color_code
1980
+         * @param $compatibility
1981
+         *
1982
+         * @return string
1983
+         */
1984
+        public static function css_secondary($color_code,$compatibility){;
1985
+            $color_code = sanitize_hex_color($color_code);
1986
+            if(!$color_code){return '';}
1987
+            /**
1988
+             * c = color, b = background color, o = border-color, f = fill
1989
+             */
1990
+            $selectors = array(
1991
+                '.btn-secondary' => array('b','o'),
1992
+                '.btn-secondary.disabled' => array('b','o'),
1993
+                '.btn-secondary:disabled' => array('b','o'),
1994
+                '.btn-outline-secondary' => array('c','o'),
1995
+                '.btn-outline-secondary:hover' => array('b','o'),
1996
+                '.btn-outline-secondary.disabled' => array('c'),
1997
+                '.btn-outline-secondary:disabled' => array('c'),
1998
+                '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
1999
+                '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2000
+                '.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2001
+                '.badge-secondary' => array('b'),
2002
+                '.alert-secondary' => array('b','o'),
2003
+                '.btn-link.btn-secondary' => array('c'),
2004
+            );
2005
+
2006
+            $important_selectors = array(
2007
+                '.bg-secondary' => array('b','f'),
2008
+                '.border-secondary' => array('o'),
2009
+                '.text-secondary' => array('c'),
2010
+            );
2011
+
2012
+            $color = array();
2013
+            $color_i = array();
2014
+            $background = array();
2015
+            $background_i = array();
2016
+            $border = array();
2017
+            $border_i = array();
2018
+            $fill = array();
2019
+            $fill_i = array();
2020
+
2021
+            $output = '';
2022
+
2023
+            // build rules into each type
2024
+            foreach($selectors as $selector => $types){
2025
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2026
+                $types = array_combine($types,$types);
2027
+                if(isset($types['c'])){$color[] = $selector;}
2028
+                if(isset($types['b'])){$background[] = $selector;}
2029
+                if(isset($types['o'])){$border[] = $selector;}
2030
+                if(isset($types['f'])){$fill[] = $selector;}
2031
+            }
2032
+
2033
+            // build rules into each type
2034
+            foreach($important_selectors as $selector => $types){
2035
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2036
+                $types = array_combine($types,$types);
2037
+                if(isset($types['c'])){$color_i[] = $selector;}
2038
+                if(isset($types['b'])){$background_i[] = $selector;}
2039
+                if(isset($types['o'])){$border_i[] = $selector;}
2040
+                if(isset($types['f'])){$fill_i[] = $selector;}
2041
+            }
2042
+
2043
+            // add any color rules
2044
+            if(!empty($color)){
2045
+                $output .= implode(",",$color) . "{color: $color_code;} ";
2046
+            }
2047
+            if(!empty($color_i)){
2048
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2049
+            }
2050
+
2051
+            // add any background color rules
2052
+            if(!empty($background)){
2053
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
2054
+            }
2055
+            if(!empty($background_i)){
2056
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2057
+            }
2058
+
2059
+            // add any border color rules
2060
+            if(!empty($border)){
2061
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
2062
+            }
2063
+            if(!empty($border_i)){
2064
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2065
+            }
2066
+
2067
+            // add any fill color rules
2068
+            if(!empty($fill)){
2069
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
2070
+            }
2071
+            if(!empty($fill_i)){
2072
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2073
+            }
2074
+
2075
+
2076
+            $prefix = $compatibility ? ".bsui " : "";
2077
+
2078
+            // darken
2079
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2080
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2081
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2082
+
2083
+            // lighten
2084
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2085
+
2086
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
2087
+            $op_25 = $color_code."40"; // 25% opacity
2088
+
2089
+
2090
+            // button states
2091
+            $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2092
+            $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2093
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2094
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2095
+
2096
+
2097
+            return $output;
2098
+        }
2099
+
2100
+        /**
2101
+         * Increases or decreases the brightness of a color by a percentage of the current brightness.
2102
+         *
2103
+         * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
2104
+         * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
2105
+         *
2106
+         * @return  string
2107
+         */
2108
+        public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2109
+            $hexCode = ltrim($hexCode, '#');
2110
+
2111
+            if (strlen($hexCode) == 3) {
2112
+                $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2113
+            }
2114
+
2115
+            $hexCode = array_map('hexdec', str_split($hexCode, 2));
2116
+
2117
+            foreach ($hexCode as & $color) {
2118
+                $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2119
+                $adjustAmount = ceil($adjustableLimit * $adjustPercent);
2120
+
2121
+                $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2122
+            }
2123
+
2124
+            return '#' . implode($hexCode);
2125
+        }
2126
+
2127
+        /**
2128
+         * Check if we should display examples.
2129
+         */
2130
+        public function maybe_show_examples(){
2131
+            if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2132
+                echo "<head>";
2133
+                wp_head();
2134
+                echo "</head>";
2135
+                echo "<body>";
2136
+                echo $this->get_examples();
2137
+                echo "</body>";
2138
+                exit;
2139
+            }
2140
+        }
2141
+
2142
+        /**
2143
+         * Get developer examples.
2144
+         *
2145
+         * @return string
2146
+         */
2147
+        public function get_examples(){
2148
+            $output = '';
2149
+
2150
+
2151
+            // open form
2152
+            $output .= "<form class='p-5 m-5 border rounded'>";
2153
+
2154
+            // input example
2155
+            $output .= aui()->input(array(
2156
+                'type'  =>  'text',
2157
+                'id'    =>  'text-example',
2158
+                'name'    =>  'text-example',
2159
+                'placeholder'   => 'text placeholder',
2160
+                'title'   => 'Text input example',
2161
+                'value' =>  '',
2162
+                'required'  => false,
2163
+                'help_text' => 'help text',
2164
+                'label' => 'Text input example label'
2165
+            ));
2166
+
2167
+            // input example
2168
+            $output .= aui()->input(array(
2169
+                'type'  =>  'url',
2170
+                'id'    =>  'text-example2',
2171
+                'name'    =>  'text-example',
2172
+                'placeholder'   => 'url placeholder',
2173
+                'title'   => 'Text input example',
2174
+                'value' =>  '',
2175
+                'required'  => false,
2176
+                'help_text' => 'help text',
2177
+                'label' => 'Text input example label'
2178
+            ));
2179
+
2180
+            // checkbox example
2181
+            $output .= aui()->input(array(
2182
+                'type'  =>  'checkbox',
2183
+                'id'    =>  'checkbox-example',
2184
+                'name'    =>  'checkbox-example',
2185
+                'placeholder'   => 'checkbox-example',
2186
+                'title'   => 'Checkbox example',
2187
+                'value' =>  '1',
2188
+                'checked'   => true,
2189
+                'required'  => false,
2190
+                'help_text' => 'help text',
2191
+                'label' => 'Checkbox checked'
2192
+            ));
2193
+
2194
+            // checkbox example
2195
+            $output .= aui()->input(array(
2196
+                'type'  =>  'checkbox',
2197
+                'id'    =>  'checkbox-example2',
2198
+                'name'    =>  'checkbox-example2',
2199
+                'placeholder'   => 'checkbox-example',
2200
+                'title'   => 'Checkbox example',
2201
+                'value' =>  '1',
2202
+                'checked'   => false,
2203
+                'required'  => false,
2204
+                'help_text' => 'help text',
2205
+                'label' => 'Checkbox un-checked'
2206
+            ));
2207
+
2208
+            // switch example
2209
+            $output .= aui()->input(array(
2210
+                'type'  =>  'checkbox',
2211
+                'id'    =>  'switch-example',
2212
+                'name'    =>  'switch-example',
2213
+                'placeholder'   => 'checkbox-example',
2214
+                'title'   => 'Switch example',
2215
+                'value' =>  '1',
2216
+                'checked'   => true,
2217
+                'switch'    => true,
2218
+                'required'  => false,
2219
+                'help_text' => 'help text',
2220
+                'label' => 'Switch on'
2221
+            ));
2222
+
2223
+            // switch example
2224
+            $output .= aui()->input(array(
2225
+                'type'  =>  'checkbox',
2226
+                'id'    =>  'switch-example2',
2227
+                'name'    =>  'switch-example2',
2228
+                'placeholder'   => 'checkbox-example',
2229
+                'title'   => 'Switch example',
2230
+                'value' =>  '1',
2231
+                'checked'   => false,
2232
+                'switch'    => true,
2233
+                'required'  => false,
2234
+                'help_text' => 'help text',
2235
+                'label' => 'Switch off'
2236
+            ));
2237
+
2238
+            // close form
2239
+            $output .= "</form>";
2240
+
2241
+            return $output;
2242
+        }
2243
+
2244
+        /**
2245
+         * Calendar params.
2246
+         *
2247
+         * @since 0.1.44
2248
+         *
2249
+         * @return array Calendar params.
2250
+         */
2251
+        public static function calendar_params() {
2252
+            $params = array(
2253
+                'month_long_1' => __( 'January', 'ayecode-connect' ),
2254
+                'month_long_2' => __( 'February', 'ayecode-connect' ),
2255
+                'month_long_3' => __( 'March', 'ayecode-connect' ),
2256
+                'month_long_4' => __( 'April', 'ayecode-connect' ),
2257
+                'month_long_5' => __( 'May', 'ayecode-connect' ),
2258
+                'month_long_6' => __( 'June', 'ayecode-connect' ),
2259
+                'month_long_7' => __( 'July', 'ayecode-connect' ),
2260
+                'month_long_8' => __( 'August', 'ayecode-connect' ),
2261
+                'month_long_9' => __( 'September', 'ayecode-connect' ),
2262
+                'month_long_10' => __( 'October', 'ayecode-connect' ),
2263
+                'month_long_11' => __( 'November', 'ayecode-connect' ),
2264
+                'month_long_12' => __( 'December', 'ayecode-connect' ),
2265
+                'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2266
+                'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2267
+                'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2268
+                'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2269
+                'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2270
+                'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2271
+                'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2272
+                'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2273
+                'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2274
+                'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2275
+                'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2276
+                'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2277
+                'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2278
+                'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2279
+                'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2280
+                'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2281
+                'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2282
+                'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2283
+                'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2284
+                'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2285
+                'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2286
+                'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2287
+                'day_s2_4' => __( 'We', 'ayecode-connect' ),
2288
+                'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2289
+                'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2290
+                'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2291
+                'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2292
+                'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2293
+                'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2294
+                'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2295
+                'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2296
+                'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2297
+                'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2298
+                'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2299
+                'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2300
+                'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2301
+                'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2302
+                'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2303
+                'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2304
+                'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2305
+                'am_lower' => __( 'am', 'ayecode-connect' ),
2306
+                'pm_lower' => __( 'pm', 'ayecode-connect' ),
2307
+                'am_upper' => __( 'AM', 'ayecode-connect' ),
2308
+                'pm_upper' => __( 'PM', 'ayecode-connect' ),
2309
+                'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2310
+                'time_24hr' => false,
2311
+                'year' => __( 'Year', 'ayecode-connect' ),
2312
+                'hour' => __( 'Hour', 'ayecode-connect' ),
2313
+                'minute' => __( 'Minute', 'ayecode-connect' ),
2314
+                'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2315
+                'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2316
+                'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2317
+                'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2318
+            );
2319
+
2320
+            return apply_filters( 'ayecode_ui_calendar_params', $params );
2321
+        }
2322
+
2323
+        /**
2324
+         * Flatpickr calendar localize.
2325
+         *
2326
+         * @since 0.1.44
2327
+         *
2328
+         * @return string Calendar locale.
2329
+         */
2330
+        public static function flatpickr_locale() {
2331
+            $params = self::calendar_params();
2332
+
2333
+            if ( is_string( $params ) ) {
2334
+                $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2335
+            } else {
2336
+                foreach ( (array) $params as $key => $value ) {
2337
+                    if ( ! is_scalar( $value ) ) {
2338
+                        continue;
2339
+                    }
2340
+
2341
+                    $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2342
+                }
2343
+            }
2344
+
2345
+            $day_s3 = array();
2346
+            $day_s5 = array();
2347
+
2348
+            for ( $i = 1; $i <= 7; $i ++ ) {
2349
+                $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2350
+                $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2351
+            }
2352
+
2353
+            $month_s = array();
2354
+            $month_long = array();
2355
+
2356
+            for ( $i = 1; $i <= 12; $i ++ ) {
2357
+                $month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2358
+                $month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2359
+            }
2360
+
2361
+            ob_start();
2362
+        if ( 0 ) { ?><script><?php } ?>
2363 2363
                 {
2364 2364
                     weekdays: {
2365 2365
                         shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'],
@@ -2398,189 +2398,189 @@  discard block
 block discarded – undo
2398 2398
                 }
2399 2399
 				<?php if ( 0 ) { ?></script><?php } ?>
2400 2400
 			<?php
2401
-			$locale = ob_get_clean();
2402
-
2403
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2404
-		}
2405
-
2406
-		/**
2407
-		 * Select2 JS params.
2408
-		 *
2409
-		 * @since 0.1.44
2410
-		 *
2411
-		 * @return array Select2 JS params.
2412
-		 */
2413
-		public static function select2_params() {
2414
-			$params = array(
2415
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2416
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2417
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2418
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2419
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2420
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2421
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2422
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2423
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2424
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2425
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2426
-			);
2427
-
2428
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2429
-		}
2430
-
2431
-		/**
2432
-		 * Select2 JS localize.
2433
-		 *
2434
-		 * @since 0.1.44
2435
-		 *
2436
-		 * @return string Select2 JS locale.
2437
-		 */
2438
-		public static function select2_locale() {
2439
-			$params = self::select2_params();
2440
-
2441
-			foreach ( (array) $params as $key => $value ) {
2442
-				if ( ! is_scalar( $value ) ) {
2443
-					continue;
2444
-				}
2401
+            $locale = ob_get_clean();
2445 2402
 
2446
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2447
-			}
2448
-
2449
-			$locale = json_encode( $params );
2450
-
2451
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2452
-		}
2453
-
2454
-		/**
2455
-		 * Time ago JS localize.
2456
-		 *
2457
-		 * @since 0.1.47
2458
-		 *
2459
-		 * @return string Time ago JS locale.
2460
-		 */
2461
-		public static function timeago_locale() {
2462
-			$params = array(
2463
-				'prefix_ago' => '',
2464
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2465
-				'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2466
-				'suffix_after' => '',
2467
-				'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2468
-				'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2469
-				'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2470
-				'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2471
-				'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2472
-				'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2473
-				'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2474
-				'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2475
-				'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2476
-				'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2477
-				'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2478
-			);
2479
-
2480
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2481
-
2482
-			foreach ( (array) $params as $key => $value ) {
2483
-				if ( ! is_scalar( $value ) ) {
2484
-					continue;
2485
-				}
2403
+            return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2404
+        }
2405
+
2406
+        /**
2407
+         * Select2 JS params.
2408
+         *
2409
+         * @since 0.1.44
2410
+         *
2411
+         * @return array Select2 JS params.
2412
+         */
2413
+        public static function select2_params() {
2414
+            $params = array(
2415
+                'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2416
+                'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2417
+                'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2418
+                'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2419
+                'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2420
+                'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2421
+                'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2422
+                'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2423
+                'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2424
+                'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2425
+                'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2426
+            );
2427
+
2428
+            return apply_filters( 'ayecode_ui_select2_params', $params );
2429
+        }
2430
+
2431
+        /**
2432
+         * Select2 JS localize.
2433
+         *
2434
+         * @since 0.1.44
2435
+         *
2436
+         * @return string Select2 JS locale.
2437
+         */
2438
+        public static function select2_locale() {
2439
+            $params = self::select2_params();
2440
+
2441
+            foreach ( (array) $params as $key => $value ) {
2442
+                if ( ! is_scalar( $value ) ) {
2443
+                    continue;
2444
+                }
2445
+
2446
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2447
+            }
2448
+
2449
+            $locale = json_encode( $params );
2450
+
2451
+            return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2452
+        }
2453
+
2454
+        /**
2455
+         * Time ago JS localize.
2456
+         *
2457
+         * @since 0.1.47
2458
+         *
2459
+         * @return string Time ago JS locale.
2460
+         */
2461
+        public static function timeago_locale() {
2462
+            $params = array(
2463
+                'prefix_ago' => '',
2464
+                'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2465
+                'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2466
+                'suffix_after' => '',
2467
+                'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2468
+                'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2469
+                'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2470
+                'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2471
+                'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2472
+                'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2473
+                'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2474
+                'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2475
+                'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2476
+                'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2477
+                'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2478
+            );
2479
+
2480
+            $params = apply_filters( 'ayecode_ui_timeago_params', $params );
2481
+
2482
+            foreach ( (array) $params as $key => $value ) {
2483
+                if ( ! is_scalar( $value ) ) {
2484
+                    continue;
2485
+                }
2486
+
2487
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2488
+            }
2486 2489
 
2487
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2488
-			}
2489
-
2490
-			$locale = json_encode( $params );
2491
-
2492
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2493
-		}
2494
-
2495
-		/**
2496
-		 * JavaScript Minifier
2497
-		 *
2498
-		 * @param $input
2499
-		 *
2500
-		 * @return mixed
2501
-		 */
2502
-		public static function minify_js($input) {
2503
-			if(trim($input) === "") return $input;
2504
-			return preg_replace(
2505
-				array(
2506
-					// Remove comment(s)
2507
-					'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2508
-					// Remove white-space(s) outside the string and regex
2509
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2510
-					// Remove the last semicolon
2511
-					'#;+\}#',
2512
-					// Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2513
-					'#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2514
-					// --ibid. From `foo['bar']` to `foo.bar`
2515
-					'#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2516
-				),
2517
-				array(
2518
-					'$1',
2519
-					'$1$2',
2520
-					'}',
2521
-					'$1$3',
2522
-					'$1.$3'
2523
-				),
2524
-				$input);
2525
-		}
2526
-
2527
-		/**
2528
-		 * Minify CSS
2529
-		 *
2530
-		 * @param $input
2531
-		 *
2532
-		 * @return mixed
2533
-		 */
2534
-		public static function minify_css($input) {
2535
-			if(trim($input) === "") return $input;
2536
-			return preg_replace(
2537
-				array(
2538
-					// Remove comment(s)
2539
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2540
-					// Remove unused white-space(s)
2541
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2542
-					// Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2543
-					'#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2544
-					// Replace `:0 0 0 0` with `:0`
2545
-					'#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2546
-					// Replace `background-position:0` with `background-position:0 0`
2547
-					'#(background-position):0(?=[;\}])#si',
2548
-					// Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2549
-					'#(?<=[\s:,\-])0+\.(\d+)#s',
2550
-					// Minify string value
2551
-					'#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2552
-					'#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2553
-					// Minify HEX color code
2554
-					'#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2555
-					// Replace `(border|outline):none` with `(border|outline):0`
2556
-					'#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2557
-					// Remove empty selector(s)
2558
-					'#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2559
-				),
2560
-				array(
2561
-					'$1',
2562
-					'$1$2$3$4$5$6$7',
2563
-					'$1',
2564
-					':0',
2565
-					'$1:0 0',
2566
-					'.$1',
2567
-					'$1$3',
2568
-					'$1$2$4$5',
2569
-					'$1$2$3',
2570
-					'$1:0',
2571
-					'$1$2'
2572
-				),
2573
-				$input);
2574
-		}
2575
-
2576
-		/**
2577
-		 * Get the conditional fields JavaScript.
2578
-		 *
2579
-		 * @return mixed
2580
-		 */
2581
-		public function conditional_fields_js() {
2582
-			ob_start();
2583
-			?>
2490
+            $locale = json_encode( $params );
2491
+
2492
+            return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2493
+        }
2494
+
2495
+        /**
2496
+         * JavaScript Minifier
2497
+         *
2498
+         * @param $input
2499
+         *
2500
+         * @return mixed
2501
+         */
2502
+        public static function minify_js($input) {
2503
+            if(trim($input) === "") return $input;
2504
+            return preg_replace(
2505
+                array(
2506
+                    // Remove comment(s)
2507
+                    '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2508
+                    // Remove white-space(s) outside the string and regex
2509
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2510
+                    // Remove the last semicolon
2511
+                    '#;+\}#',
2512
+                    // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2513
+                    '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2514
+                    // --ibid. From `foo['bar']` to `foo.bar`
2515
+                    '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2516
+                ),
2517
+                array(
2518
+                    '$1',
2519
+                    '$1$2',
2520
+                    '}',
2521
+                    '$1$3',
2522
+                    '$1.$3'
2523
+                ),
2524
+                $input);
2525
+        }
2526
+
2527
+        /**
2528
+         * Minify CSS
2529
+         *
2530
+         * @param $input
2531
+         *
2532
+         * @return mixed
2533
+         */
2534
+        public static function minify_css($input) {
2535
+            if(trim($input) === "") return $input;
2536
+            return preg_replace(
2537
+                array(
2538
+                    // Remove comment(s)
2539
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2540
+                    // Remove unused white-space(s)
2541
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2542
+                    // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2543
+                    '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2544
+                    // Replace `:0 0 0 0` with `:0`
2545
+                    '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2546
+                    // Replace `background-position:0` with `background-position:0 0`
2547
+                    '#(background-position):0(?=[;\}])#si',
2548
+                    // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2549
+                    '#(?<=[\s:,\-])0+\.(\d+)#s',
2550
+                    // Minify string value
2551
+                    '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2552
+                    '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2553
+                    // Minify HEX color code
2554
+                    '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2555
+                    // Replace `(border|outline):none` with `(border|outline):0`
2556
+                    '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2557
+                    // Remove empty selector(s)
2558
+                    '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2559
+                ),
2560
+                array(
2561
+                    '$1',
2562
+                    '$1$2$3$4$5$6$7',
2563
+                    '$1',
2564
+                    ':0',
2565
+                    '$1:0 0',
2566
+                    '.$1',
2567
+                    '$1$3',
2568
+                    '$1$2$4$5',
2569
+                    '$1$2$3',
2570
+                    '$1:0',
2571
+                    '$1$2'
2572
+                ),
2573
+                $input);
2574
+        }
2575
+
2576
+        /**
2577
+         * Get the conditional fields JavaScript.
2578
+         *
2579
+         * @return mixed
2580
+         */
2581
+        public function conditional_fields_js() {
2582
+            ob_start();
2583
+            ?>
2584 2584
             <script>
2585 2585
                 /**
2586 2586
                  * Conditional Fields
@@ -3101,14 +3101,14 @@  discard block
 block discarded – undo
3101 3101
 				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
3102 3102
             </script>
3103 3103
 			<?php
3104
-			$output = ob_get_clean();
3104
+            $output = ob_get_clean();
3105 3105
 
3106
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3107
-		}
3108
-	}
3106
+            return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3107
+        }
3108
+    }
3109 3109
 
3110
-	/**
3111
-	 * Run the class if found.
3112
-	 */
3113
-	AyeCode_UI_Settings::instance();
3110
+    /**
3111
+     * Run the class if found.
3112
+     */
3113
+    AyeCode_UI_Settings::instance();
3114 3114
 }
3115 3115
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +743 added lines, -743 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
22
+if (!class_exists('AyeCode_UI_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -99,27 +99,27 @@  discard block
 block discarded – undo
99 99
 		 * @return AyeCode_UI_Settings - Main instance.
100 100
 		 */
101 101
 		public static function instance() {
102
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
102
+			if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) {
103 103
 
104 104
 				self::$instance = new AyeCode_UI_Settings;
105 105
 
106
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
106
+				add_action('init', array(self::$instance, 'init')); // set settings
107 107
 
108
-				if ( is_admin() ) {
109
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
108
+				if (is_admin()) {
109
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
110
+					add_action('admin_init', array(self::$instance, 'register_settings'));
111 111
 
112 112
 					// Maybe show example page
113
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
113
+					add_action('template_redirect', array(self::$instance, 'maybe_show_examples'));
114 114
 
115
-					if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
-						add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
115
+					if (defined('BLOCKSTRAP_VERSION')) {
116
+						add_filter('sd_aui_colors', array(self::$instance, 'sd_aui_colors'), 10, 3);
117 117
 					}
118 118
 				}
119 119
 
120
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
120
+				add_action('customize_register', array(self::$instance, 'customizer_settings'));
121 121
 
122
-				do_action( 'ayecode_ui_settings_loaded' );
122
+				do_action('ayecode_ui_settings_loaded');
123 123
 			}
124 124
 
125 125
 			return self::$instance;
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 		 *
135 135
 		 * @return mixed
136 136
 		 */
137
-		public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
137
+		public function sd_aui_colors($theme_colors, $include_outlines, $include_branding) {
138 138
 
139 139
 
140 140
 			$setting = wp_get_global_settings();
141 141
 
142
-			if(!empty($setting['color']['palette']['custom'])){
143
-				foreach($setting['color']['palette']['custom'] as $color){
142
+			if (!empty($setting['color']['palette']['custom'])) {
143
+				foreach ($setting['color']['palette']['custom'] as $color) {
144 144
 					$theme_colors[$color['slug']] = esc_attr($color['name']);
145 145
 				}
146 146
 			}
@@ -151,81 +151,81 @@  discard block
 block discarded – undo
151 151
 		/**
152 152
 		 * Setup some constants.
153 153
 		 */
154
-		public function constants(){
155
-			define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
-			define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
-			define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
-			define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
-			define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
-			define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
-			define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
-			define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
-			define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
-			define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
-			define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
-			define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
-			define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
-			define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
-			define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
-			define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
154
+		public function constants() {
155
+			define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be");
156
+			define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d');
157
+			define('AUI_INFO_COLOR_ORIGINAL', '#17a2b8');
158
+			define('AUI_WARNING_COLOR_ORIGINAL', '#ffc107');
159
+			define('AUI_DANGER_COLOR_ORIGINAL', '#dc3545');
160
+			define('AUI_SUCCESS_COLOR_ORIGINAL', '#44c553');
161
+			define('AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa');
162
+			define('AUI_DARK_COLOR_ORIGINAL', '#343a40');
163
+			define('AUI_WHITE_COLOR_ORIGINAL', '#fff');
164
+			define('AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd');
165
+			define('AUI_SALMON_COLOR_ORIGINAL', '#ff977a');
166
+			define('AUI_CYAN_COLOR_ORIGINAL', '#35bdff');
167
+			define('AUI_GRAY_COLOR_ORIGINAL', '#ced4da');
168
+			define('AUI_INDIGO_COLOR_ORIGINAL', '#502c6c');
169
+			define('AUI_ORANGE_COLOR_ORIGINAL', '#orange');
170
+			define('AUI_BLACK_COLOR_ORIGINAL', '#000');
171 171
 
172
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
-				define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
172
+			if (!defined('AUI_PRIMARY_COLOR')) {
173
+				define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL);
174 174
 			}
175
-			if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
-				define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
175
+			if (!defined('AUI_SECONDARY_COLOR')) {
176
+				define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL);
177 177
 			}
178
-			if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
-				define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
178
+			if (!defined('AUI_INFO_COLOR')) {
179
+				define('AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL);
180 180
 			}
181
-			if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
-				define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
181
+			if (!defined('AUI_WARNING_COLOR')) {
182
+				define('AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL);
183 183
 			}
184
-			if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
-				define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
184
+			if (!defined('AUI_DANGER_COLOR')) {
185
+				define('AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL);
186 186
 			}
187
-			if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
-				define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
187
+			if (!defined('AUI_SUCCESS_COLOR')) {
188
+				define('AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL);
189 189
 			}
190
-			if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
-				define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
190
+			if (!defined('AUI_LIGHT_COLOR')) {
191
+				define('AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL);
192 192
 			}
193
-			if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
-				define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
193
+			if (!defined('AUI_DARK_COLOR')) {
194
+				define('AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL);
195 195
 			}
196
-			if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
-				define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
196
+			if (!defined('AUI_WHITE_COLOR')) {
197
+				define('AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL);
198 198
 			}
199
-			if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
-				define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
199
+			if (!defined('AUI_PURPLE_COLOR')) {
200
+				define('AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL);
201 201
 			}
202
-			if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
-				define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
202
+			if (!defined('AUI_SALMON_COLOR')) {
203
+				define('AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL);
204 204
 			}
205
-			if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
-				define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
205
+			if (!defined('AUI_CYAN_COLOR')) {
206
+				define('AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL);
207 207
 			}
208
-			if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
-				define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
208
+			if (!defined('AUI_GRAY_COLOR')) {
209
+				define('AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL);
210 210
 			}
211
-			if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
-				define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
211
+			if (!defined('AUI_INDIGO_COLOR')) {
212
+				define('AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL);
213 213
 			}
214
-			if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
-				define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
214
+			if (!defined('AUI_ORANGE_COLOR')) {
215
+				define('AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL);
216 216
 			}
217
-			if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
-				define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
217
+			if (!defined('AUI_BLACK_COLOR')) {
218
+				define('AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL);
219 219
 			}
220 220
 
221 221
 		}
222 222
 
223
-		public static function get_colors( $original = false){
223
+		public static function get_colors($original = false) {
224 224
 
225
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
225
+			if (!defined('AUI_PRIMARY_COLOR')) {
226 226
 				return array();
227 227
 			}
228
-			if ( $original ) {
228
+			if ($original) {
229 229
 				return array(
230 230
 					'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231 231
 					'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		 *
274 274
 		 * @return mixed
275 275
 		 */
276
-		public function add_bs5_admin_body_class( $classes = '' ) {
276
+		public function add_bs5_admin_body_class($classes = '') {
277 277
 			$classes .= ' aui_bs5';
278 278
 
279 279
 			return $classes;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		 *
287 287
 		 * @return mixed
288 288
 		 */
289
-		public function add_bs5_body_class( $classes ) {
289
+		public function add_bs5_body_class($classes) {
290 290
 			$classes[] = 'aui_bs5';
291 291
 
292 292
 			return $classes;
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
             global $aui_bs5;
300 300
 
301 301
 			// Maybe fix settings
302
-			if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
303
-				$db_settings = get_option( 'ayecode-ui-settings' );
304
-				if ( ! empty( $db_settings ) ) {
302
+			if (!empty($_REQUEST['aui-fix-admin']) && !empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], "aui-fix-admin")) {
303
+				$db_settings = get_option('ayecode-ui-settings');
304
+				if (!empty($db_settings)) {
305 305
 					$db_settings['css_backend'] = 'compatibility';
306 306
 					$db_settings['js_backend'] = 'core-popper';
307
-					update_option( 'ayecode-ui-settings', $db_settings );
307
+					update_option('ayecode-ui-settings', $db_settings);
308 308
 					wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309 309
 				}
310 310
 			}
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
             // define the version
317 317
 			$aui_bs5 = $this->settings['bs_ver'] === '5';
318 318
 
319
-			if ( $aui_bs5 ) {
320
-				include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' );
321
-				add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 );
322
-				add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) );
319
+			if ($aui_bs5) {
320
+				include_once(dirname(__FILE__) . '/inc/bs-conversion.php');
321
+				add_filter('admin_body_class', array($this, 'add_bs5_admin_body_class'), 99, 1);
322
+				add_filter('body_class', array($this, 'add_bs5_body_class'));
323 323
 			}
324 324
 
325 325
 			/**
@@ -327,32 +327,32 @@  discard block
 block discarded – undo
327 327
 			 *
328 328
 			 * We load super early in case there is a theme version that might change the colors
329 329
 			 */
330
-			if ( $this->settings['css'] ) {
330
+			if ($this->settings['css']) {
331 331
 				$priority = $this->is_bs3_compat() ? 100 : 1;
332 332
                 $priority = $aui_bs5 ? 10 : $priority;
333
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
333
+				add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), $priority);
334 334
 			}
335
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
335
+			if ($this->settings['css_backend'] && $this->load_admin_scripts()) {
336
+				add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1);
337 337
 			}
338 338
 
339 339
 			// maybe load JS
340
-			if ( $this->settings['js'] ) {
340
+			if ($this->settings['js']) {
341 341
 				$priority = $this->is_bs3_compat() ? 100 : 1;
342
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
342
+				add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority);
343 343
 			}
344
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
344
+			if ($this->settings['js_backend'] && $this->load_admin_scripts()) {
345
+				add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1);
346 346
 			}
347 347
 
348 348
 			// Maybe set the HTML font size
349
-			if ( $this->settings['html_font_size'] ) {
350
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
349
+			if ($this->settings['html_font_size']) {
350
+				add_action('wp_footer', array($this, 'html_font_size'), 10);
351 351
 			}
352 352
 
353 353
 			// Maybe show backend style error
354
-			if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
355
-				add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
354
+			if ($this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper') {
355
+				add_action('admin_notices', array($this, 'show_admin_style_notice'));
356 356
 			}
357 357
 
358 358
 		}
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 		/**
361 361
 		 * Show admin notice if backend scripts not loaded.
362 362
 		 */
363
-		public function show_admin_style_notice(){
364
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
365
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
366
-			$message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
367
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
363
+		public function show_admin_style_notice() {
364
+			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=" . wp_create_nonce('aui-fix-admin'));
365
+			$button = '<a href="' . esc_url($fix_url) . '" class="button-primary">Fix Now</a>';
366
+			$message = __('<b>Style Issue:</b> AyeCode UI is disable or set wrong.') . " " . $button;
367
+			echo '<div class="notice notice-error aui-settings-error-notice"><p>' . $message . '</p></div>';
368 368
 		}
369 369
 
370 370
 		/**
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 		 *
373 373
 		 * @return bool
374 374
 		 */
375
-		public function load_admin_scripts(){
375
+		public function load_admin_scripts() {
376 376
 			$result = true;
377 377
 
378 378
 			// check if specifically disabled
379
-			if(!empty($this->settings['disable_admin'])){
380
-				$url_parts = explode("\n",$this->settings['disable_admin']);
381
-				foreach($url_parts as $part){
382
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
379
+			if (!empty($this->settings['disable_admin'])) {
380
+				$url_parts = explode("\n", $this->settings['disable_admin']);
381
+				foreach ($url_parts as $part) {
382
+					if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) {
383 383
 						return false; // return early, no point checking further
384 384
 					}
385 385
 				}
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 		/**
392 392
 		 * Add a html font size to the footer.
393 393
 		 */
394
-		public function html_font_size(){
394
+		public function html_font_size() {
395 395
 			$this->settings = $this->get_settings();
396
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
396
+			echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>";
397 397
 		}
398 398
 
399 399
 		/**
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 		 *
402 402
 		 * @return bool
403 403
 		 */
404
-		public function is_aui_screen(){
404
+		public function is_aui_screen() {
405 405
 //			echo '###';exit;
406 406
 			$load = false;
407 407
 			// check if we should load or not
408
-			if ( is_admin() ) {
408
+			if (is_admin()) {
409 409
 				// Only enable on set pages
410 410
 				$aui_screens = array(
411 411
 					'page',
@@ -417,26 +417,26 @@  discard block
 block discarded – undo
417 417
 					'ayecode-ui-settings',
418 418
 					'site-editor'
419 419
 				);
420
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
420
+				$screen_ids = apply_filters('aui_screen_ids', $aui_screens);
421 421
 
422 422
 				$screen = get_current_screen();
423 423
 
424 424
 //				echo '###'.$screen->id;
425 425
 
426 426
 				// check if we are on a AUI screen
427
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
427
+				if ($screen && in_array($screen->id, $screen_ids)) {
428 428
 					$load = true;
429 429
 				}
430 430
 
431 431
 				//load for widget previews in WP 5.8
432
-				if( !empty($_REQUEST['legacy-widget-preview'])){
432
+				if (!empty($_REQUEST['legacy-widget-preview'])) {
433 433
 					$load = true;
434 434
 				}
435 435
 			}
436 436
 
437 437
 
438 438
 
439
-			return apply_filters( 'aui_load_on_admin' , $load );
439
+			return apply_filters('aui_load_on_admin', $load);
440 440
 		}
441 441
 
442 442
 		/**
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		 * @return bool
446 446
 		 */
447 447
 		public static function is_block_theme() {
448
-			if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
448
+			if (function_exists('wp_is_block_theme' && wp_is_block_theme())) {
449 449
 				return true;
450 450
 			}
451 451
 
@@ -460,40 +460,40 @@  discard block
 block discarded – undo
460 460
 
461 461
             $load_fse = false;
462 462
 
463
-			if( is_admin() && !$this->is_aui_screen()){
463
+			if (is_admin() && !$this->is_aui_screen()) {
464 464
 				// don't add wp-admin scripts if not requested to
465
-			}else{
465
+			} else {
466 466
 				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
467 467
 
468
-				$rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : '';
468
+				$rtl = is_rtl() && !$aui_bs5 ? '-rtl' : '';
469 469
 
470 470
                 $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
471 471
 
472
-				if($this->settings[$css_setting]){
473
-					$compatibility = $this->settings[$css_setting]=='core' ? false : true;
474
-					$url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css';
472
+				if ($this->settings[$css_setting]) {
473
+					$compatibility = $this->settings[$css_setting] == 'core' ? false : true;
474
+					$url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets' . $bs_ver . '/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets' . $bs_ver . '/css/ayecode-ui-compatibility' . $rtl . '.css';
475 475
 
476 476
 
477 477
 
478
-					wp_register_style( 'ayecode-ui', $url, array(), $this->version );
479
-					wp_enqueue_style( 'ayecode-ui' );
478
+					wp_register_style('ayecode-ui', $url, array(), $this->version);
479
+					wp_enqueue_style('ayecode-ui');
480 480
 
481
-					$current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
481
+					$current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
482 482
 
483 483
 //					if ( is_admin() && !empty($_REQUEST['postType']) ) {
484
-					if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
485
-						$url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css';
486
-						wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
487
-						wp_enqueue_style( 'ayecode-ui-fse' );
484
+					if (is_admin() && (!empty($_REQUEST['postType']) || $current_screen->is_block_editor()) && (defined('BLOCKSTRAP_VERSION') || defined('AUI_FSE'))) {
485
+						$url = $this->url . 'assets' . $bs_ver . '/css/ayecode-ui-fse.css';
486
+						wp_register_style('ayecode-ui-fse', $url, array(), $this->version);
487
+						wp_enqueue_style('ayecode-ui-fse');
488 488
 						$load_fse = true;
489 489
 					}
490 490
 
491 491
 
492 492
 					// flatpickr
493
-					wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
493
+					wp_register_style('flatpickr', $this->url . 'assets' . $bs_ver . '/css/flatpickr.min.css', array(), $this->version);
494 494
 
495 495
 					// fix some wp-admin issues
496
-					if(is_admin()){
496
+					if (is_admin()) {
497 497
 						$custom_css = "
498 498
                 body{
499 499
                     background-color: #f1f1f1;
@@ -541,14 +541,14 @@  discard block
 block discarded – undo
541 541
 						    padding: 0;
542 542
 						}
543 543
 					";
544
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
544
+						wp_add_inline_style('ayecode-ui', $custom_css);
545 545
 					}
546 546
 
547 547
 					// custom changes
548
-					if ( $load_fse ) {
549
-						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
-					}else{
551
-						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
548
+					if ($load_fse) {
549
+						wp_add_inline_style('ayecode-ui-fse', self::custom_css($compatibility));
550
+					} else {
551
+						wp_add_inline_style('ayecode-ui', self::custom_css($compatibility));
552 552
 
553 553
 					}
554 554
 
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
 			$flatpickr_locale = self::flatpickr_locale();
570 570
 
571 571
 			ob_start();
572
-			if ( $aui_bs5 ) {
573
-				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
-			}else{
575
-				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
572
+			if ($aui_bs5) {
573
+				include_once(dirname(__FILE__) . '/inc/bs5-js.php');
574
+			} else {
575
+				include_once(dirname(__FILE__) . '/inc/bs4-js.php');
576 576
             }
577 577
 
578 578
 			$output = ob_get_clean();
@@ -580,10 +580,10 @@  discard block
 block discarded – undo
580 580
 			/*
581 581
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
582 582
 			 */
583
-			return str_replace( array(
583
+			return str_replace(array(
584 584
 				'<script>',
585 585
 				'</script>'
586
-			), '', self::minify_js($output) );
586
+			), '', self::minify_js($output));
587 587
 		}
588 588
 
589 589
 
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
 			ob_start();
598 598
 			?>
599 599
             <script>
600
-				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
600
+				<?php if (defined('FUSION_BUILDER_VERSION')) { ?>
601 601
                 /* With Avada builder */
602 602
 
603 603
 				<?php } ?>
604 604
             </script>
605 605
 			<?php
606
-			return str_replace( array(
606
+			return str_replace(array(
607 607
 				'<script>',
608 608
 				'</script>'
609 609
 			), '', ob_get_clean());
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 		 *
615 615
 		 * If this remains small then its best to use this than to add another JS file.
616 616
 		 */
617
-		public function inline_script_file_browser(){
617
+		public function inline_script_file_browser() {
618 618
 			ob_start();
619 619
 			?>
620 620
             <script>
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
 			/*
630 630
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
631 631
 			 */
632
-			return str_replace( array(
632
+			return str_replace(array(
633 633
 				'<script>',
634 634
 				'</script>'
635
-			), '', $output );
635
+			), '', $output);
636 636
 		}
637 637
 
638 638
 		/**
@@ -640,59 +640,59 @@  discard block
 block discarded – undo
640 640
 		 */
641 641
 		public function enqueue_scripts() {
642 642
 
643
-			if( is_admin() && !$this->is_aui_screen()){
643
+			if (is_admin() && !$this->is_aui_screen()) {
644 644
 				// don't add wp-admin scripts if not requested to
645
-			}else {
645
+			} else {
646 646
 
647 647
 				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
648 648
 
649 649
 				$bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
650 650
 
651 651
 				// select2
652
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
652
+				wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version);
653 653
 
654 654
 				// flatpickr
655
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
655
+				wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version);
656 656
 
657 657
 				// iconpicker
658
-				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
-					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
-				}else{
661
-					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
658
+				if (defined('FAS_ICONPICKER_JS_URL')) {
659
+					wp_register_script('iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version);
660
+				} else {
661
+					wp_register_script('iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version);
662 662
 				}
663 663
 
664 664
 				// Bootstrap file browser
665
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
665
+				wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version);
666
+				wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser());
667 667
 
668 668
 				$load_inline = false;
669 669
 
670
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
670
+				if ($this->settings[$js_setting] == 'core-popper') {
671 671
 					// Bootstrap bundle
672 672
 					$url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
673
+					wp_register_script('bootstrap-js-bundle', $url, array(
674 674
 						'select2',
675 675
 						'jquery'
676
-					), $this->version, $this->is_bs3_compat() );
676
+					), $this->version, $this->is_bs3_compat());
677 677
 					// if in admin then add to footer for compatibility.
678
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
678
+					is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle');
679 679
 					$script = $this->inline_script();
680
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
680
+					wp_add_inline_script('bootstrap-js-bundle', $script);
681
+				} elseif ($this->settings[$js_setting] == 'popper') {
682 682
 					$url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
-					wp_enqueue_script( 'bootstrap-js-popper' );
683
+					wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->version);
684
+					wp_enqueue_script('bootstrap-js-popper');
685 685
 					$load_inline = true;
686 686
 				} else {
687 687
 					$load_inline = true;
688 688
 				}
689 689
 
690 690
 				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
-				if ( $load_inline ) {
692
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
-					wp_enqueue_script( 'bootstrap-dummy' );
691
+				if ($load_inline) {
692
+					wp_register_script('bootstrap-dummy', '', array('select2', 'jquery'));
693
+					wp_enqueue_script('bootstrap-dummy');
694 694
 					$script = $this->inline_script();
695
-					wp_add_inline_script( 'bootstrap-dummy', $script );
695
+					wp_add_inline_script('bootstrap-dummy', $script);
696 696
 				}
697 697
 			}
698 698
 
@@ -701,17 +701,17 @@  discard block
 block discarded – undo
701 701
 		/**
702 702
 		 * Enqueue flatpickr if called.
703 703
 		 */
704
-		public function enqueue_flatpickr(){
705
-			wp_enqueue_style( 'flatpickr' );
706
-			wp_enqueue_script( 'flatpickr' );
704
+		public function enqueue_flatpickr() {
705
+			wp_enqueue_style('flatpickr');
706
+			wp_enqueue_script('flatpickr');
707 707
 		}
708 708
 
709 709
 		/**
710 710
 		 * Enqueue iconpicker if called.
711 711
 		 */
712
-		public function enqueue_iconpicker(){
713
-			wp_enqueue_style( 'iconpicker' );
714
-			wp_enqueue_script( 'iconpicker' );
712
+		public function enqueue_iconpicker() {
713
+			wp_enqueue_style('iconpicker');
714
+			wp_enqueue_script('iconpicker');
715 715
 		}
716 716
 
717 717
 		/**
@@ -720,19 +720,19 @@  discard block
 block discarded – undo
720 720
 		 * @return string
721 721
 		 */
722 722
 		public function get_url() {
723
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
-			$content_url = untrailingslashit( WP_CONTENT_URL );
723
+			$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
724
+			$content_url = untrailingslashit(WP_CONTENT_URL);
725 725
 
726 726
 			// Replace http:// to https://.
727
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
-				$content_url = str_replace( 'http://', 'https://', $content_url );
727
+			if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
728
+				$content_url = str_replace('http://', 'https://', $content_url);
729 729
 			}
730 730
 
731 731
 			// Check if we are inside a plugin
732
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
-			$url = str_replace( $content_dir, $content_url, $file_dir );
732
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
733
+			$url = str_replace($content_dir, $content_url, $file_dir);
734 734
 
735
-			return trailingslashit( $url );
735
+			return trailingslashit($url);
736 736
 		}
737 737
 
738 738
 		/**
@@ -744,15 +744,15 @@  discard block
 block discarded – undo
744 744
 
745 745
 			$url = '';
746 746
 			// check if we are inside a plugin
747
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
747
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
748 748
 
749 749
 			// add check in-case user has changed wp-content dir name.
750 750
 			$wp_content_folder_name = basename(WP_CONTENT_DIR);
751
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
751
+			$dir_parts = explode("/$wp_content_folder_name/", $file_dir);
752
+			$url_parts = explode("/$wp_content_folder_name/", plugins_url());
753 753
 
754
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
754
+			if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
755
+				$url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]);
756 756
 			}
757 757
 
758 758
 			return $url;
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 		 * Register the database settings with WordPress.
763 763
 		 */
764 764
 		public function register_settings() {
765
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
765
+			register_setting('ayecode-ui-settings', 'ayecode-ui-settings');
766 766
 		}
767 767
 
768 768
 		/**
@@ -771,10 +771,10 @@  discard block
 block discarded – undo
771 771
 		 */
772 772
 		public function menu_item() {
773 773
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
774
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775 775
 				$this,
776 776
 				'settings_page'
777
-			) );
777
+			));
778 778
 		}
779 779
 
780 780
 		/**
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 		 *
783 783
 		 * @return array
784 784
 		 */
785
-		public function theme_js_settings(){
785
+		public function theme_js_settings() {
786 786
 			return array(
787 787
 				'ayetheme' => 'popper',
788 788
 				'listimia' => 'required',
@@ -811,11 +811,11 @@  discard block
 block discarded – undo
811 811
 		/**
812 812
 		 * Show admin notice if backend scripts not loaded.
813 813
 		 */
814
-		public function show_admin_version_notice(){
815
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings" );
816
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>';
817
-			$message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button;
818
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
814
+		public function show_admin_version_notice() {
815
+			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings");
816
+			$button = '<a href="' . esc_url($fix_url) . '" class="button-primary">View Settings</a>';
817
+			$message = __('<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)') . " " . $button;
818
+			echo '<div class="notice notice-error aui-settings-error-notice"><p>' . $message . '</p></div>';
819 819
 		}
820 820
 
821 821
 		/**
@@ -825,32 +825,32 @@  discard block
 block discarded – undo
825 825
 		 */
826 826
 		public function get_settings() {
827 827
 
828
-			$db_settings = get_option( 'ayecode-ui-settings' );
828
+			$db_settings = get_option('ayecode-ui-settings');
829 829
 
830 830
             // Maybe show default version notice
831
-			$site_install_date = new DateTime( self::get_site_install_date() );
831
+			$site_install_date = new DateTime(self::get_site_install_date());
832 832
 			$switch_over_date = new DateTime("2024-02-01");
833
-			if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) {
834
-				add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) );
833
+			if (empty($db_settings) && $site_install_date < $switch_over_date) {
834
+				add_action('admin_notices', array($this, 'show_admin_version_notice'));
835 835
 			}
836 836
 
837 837
 			$js_default = 'core-popper';
838 838
 			$js_default_backend = $js_default;
839 839
 
840 840
 			// maybe set defaults (if no settings set)
841
-			if(empty($db_settings)){
842
-				$active_theme = strtolower( get_template() ); // active parent theme.
841
+			if (empty($db_settings)) {
842
+				$active_theme = strtolower(get_template()); // active parent theme.
843 843
 				$theme_js_settings = self::theme_js_settings();
844
-				if(isset($theme_js_settings[$active_theme])){
844
+				if (isset($theme_js_settings[$active_theme])) {
845 845
 					$js_default = $theme_js_settings[$active_theme];
846
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
846
+					$js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default;
847 847
 				}
848 848
 			}
849 849
 
850 850
 			/**
851 851
 			 * Filter the default settings.
852 852
 			 */
853
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
853
+			$defaults = apply_filters('ayecode-ui-default-settings', array(
854 854
 				'css'            => 'compatibility', // core, compatibility
855 855
 				'js'             => $js_default, // js to load, core-popper, popper
856 856
 				'html_font_size' => '16', // js to load, core-popper, popper
@@ -858,16 +858,16 @@  discard block
 block discarded – undo
858 858
 				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
859 859
 				'disable_admin'  => '', // URL snippets to disable loading on admin
860 860
                 'bs_ver'         => '5', // The default bootstrap version to sue by default
861
-			), $db_settings );
861
+			), $db_settings);
862 862
 
863
-			$settings = wp_parse_args( $db_settings, $defaults );
863
+			$settings = wp_parse_args($db_settings, $defaults);
864 864
 
865 865
 			/**
866 866
 			 * Filter the Bootstrap settings.
867 867
 			 *
868 868
 			 * @todo if we add this filer people might use it and then it defeats the purpose of this class :/
869 869
 			 */
870
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
870
+			return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults);
871 871
 		}
872 872
 
873 873
 
@@ -875,109 +875,109 @@  discard block
 block discarded – undo
875 875
 		 * The settings page html output.
876 876
 		 */
877 877
 		public function settings_page() {
878
-			if ( ! current_user_can( 'manage_options' ) ) {
879
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
878
+			if (!current_user_can('manage_options')) {
879
+				wp_die(__('You do not have sufficient permissions to access this page.', 'ayecode-connect'));
880 880
 			}
881
-            $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() );
881
+            $overrides = apply_filters('ayecode-ui-settings', array(), array(), array());
882 882
 
883 883
 			?>
884 884
             <div class="wrap">
885 885
                 <h1><?php echo $this->name; ?></h1>
886
-                <p><?php echo apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) );?></p>
886
+                <p><?php echo apply_filters('ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect')); ?></p>
887 887
                 <form method="post" action="options.php">
888 888
 					<?php
889
-					settings_fields( 'ayecode-ui-settings' );
890
-					do_settings_sections( 'ayecode-ui-settings' );
889
+					settings_fields('ayecode-ui-settings');
890
+					do_settings_sections('ayecode-ui-settings');
891 891
 					?>
892 892
 
893
-                    <h2><?php _e( 'BootStrap Version', 'ayecode-connect' ); ?></h2>
894
-                    <p><?php echo apply_filters( 'ayecode-ui-version-settings-message', __("V5 is recommended, however if you have another plugin installed using v4, you may need to use v4 also.", 'ayecode-connect' ) );?></p>
893
+                    <h2><?php _e('BootStrap Version', 'ayecode-connect'); ?></h2>
894
+                    <p><?php echo apply_filters('ayecode-ui-version-settings-message', __("V5 is recommended, however if you have another plugin installed using v4, you may need to use v4 also.", 'ayecode-connect')); ?></p>
895 895
 	                <div class="bsui"><?php
896
-	                if ( ! empty( $overrides ) ) {
896
+	                if (!empty($overrides)) {
897 897
 		                echo aui()->alert(array(
898 898
 			                'type'=> 'info',
899
-			                'content'=> __("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
899
+			                'content'=> __("Some options are disabled as your current theme is overriding them.", 'ayecode-connect')
900 900
 		                ));
901 901
 	                }
902 902
 	                ?>
903 903
                     </div>
904 904
                     <table class="form-table wpbs-table-version-settings">
905 905
                         <tr valign="top">
906
-                            <th scope="row"><label for="wpbs-css"><?php _e( 'Version', 'ayecode-connect' ); ?></label></th>
906
+                            <th scope="row"><label for="wpbs-css"><?php _e('Version', 'ayecode-connect'); ?></label></th>
907 907
                             <td>
908 908
                                 <select name="ayecode-ui-settings[bs_ver]" id="wpbs-css" <?php echo !empty($overrides['bs_ver']) ? 'disabled' : ''; ?>>
909
-                                    <option	value="5" <?php selected( $this->settings['bs_ver'], '5' ); ?>><?php _e( 'v5 (recommended)', 'ayecode-connect' ); ?></option>
910
-                                    <option value="4" <?php selected( $this->settings['bs_ver'], '4' ); ?>><?php _e( 'v4 (legacy)', 'ayecode-connect' ); ?></option>
909
+                                    <option	value="5" <?php selected($this->settings['bs_ver'], '5'); ?>><?php _e('v5 (recommended)', 'ayecode-connect'); ?></option>
910
+                                    <option value="4" <?php selected($this->settings['bs_ver'], '4'); ?>><?php _e('v4 (legacy)', 'ayecode-connect'); ?></option>
911 911
                                 </select>
912 912
                             </td>
913 913
                         </tr>
914 914
                     </table>
915 915
 
916
-                    <h2><?php _e( 'Frontend', 'ayecode-connect' ); ?></h2>
916
+                    <h2><?php _e('Frontend', 'ayecode-connect'); ?></h2>
917 917
                     <table class="form-table wpbs-table-settings">
918 918
                         <tr valign="top">
919
-                            <th scope="row"><label for="wpbs-css"><?php _e( 'Load CSS', 'ayecode-connect' ); ?></label></th>
919
+                            <th scope="row"><label for="wpbs-css"><?php _e('Load CSS', 'ayecode-connect'); ?></label></th>
920 920
                             <td>
921 921
                                 <select name="ayecode-ui-settings[css]" id="wpbs-css" <?php echo !empty($overrides['css']) ? 'disabled' : ''; ?>>
922
-                                    <option	value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'ayecode-connect' ); ?></option>
923
-                                    <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'ayecode-connect' ); ?></option>
924
-                                    <option	value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'ayecode-connect' ); ?></option>
922
+                                    <option	value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'ayecode-connect'); ?></option>
923
+                                    <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'ayecode-connect'); ?></option>
924
+                                    <option	value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'ayecode-connect'); ?></option>
925 925
                                 </select>
926 926
                             </td>
927 927
                         </tr>
928 928
 
929 929
                         <tr valign="top">
930
-                            <th scope="row"><label for="wpbs-js"><?php _e( 'Load JS', 'ayecode-connect' ); ?></label></th>
930
+                            <th scope="row"><label for="wpbs-js"><?php _e('Load JS', 'ayecode-connect'); ?></label></th>
931 931
                             <td>
932 932
                                 <select name="ayecode-ui-settings[js]" id="wpbs-js" <?php echo !empty($overrides['js']) ? 'disabled' : ''; ?>>
933
-                                    <option	value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'ayecode-connect' ); ?></option>
934
-                                    <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'ayecode-connect' ); ?></option>
935
-                                    <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'ayecode-connect' ); ?></option>
936
-                                    <option	value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'ayecode-connect' ); ?></option>
933
+                                    <option	value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'ayecode-connect'); ?></option>
934
+                                    <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'ayecode-connect'); ?></option>
935
+                                    <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'ayecode-connect'); ?></option>
936
+                                    <option	value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'ayecode-connect'); ?></option>
937 937
                                 </select>
938 938
                             </td>
939 939
                         </tr>
940 940
 
941 941
                         <tr valign="top">
942
-                            <th scope="row"><label for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'ayecode-connect' ); ?></label></th>
942
+                            <th scope="row"><label for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'ayecode-connect'); ?></label></th>
943 943
                             <td>
944
-                                <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" <?php echo !empty($overrides['html_font_size']) ? 'disabled' : ''; ?> />
945
-                                <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'ayecode-connect' );?></p>
944
+                                <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" <?php echo !empty($overrides['html_font_size']) ? 'disabled' : ''; ?> />
945
+                                <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'ayecode-connect'); ?></p>
946 946
                             </td>
947 947
                         </tr>
948 948
 
949 949
                     </table>
950 950
 
951
-                    <h2><?php _e( 'Backend', 'ayecode-connect' ); ?> (wp-admin)</h2>
951
+                    <h2><?php _e('Backend', 'ayecode-connect'); ?> (wp-admin)</h2>
952 952
                     <table class="form-table wpbs-table-settings">
953 953
                         <tr valign="top">
954
-                            <th scope="row"><label for="wpbs-css-admin"><?php _e( 'Load CSS', 'ayecode-connect' ); ?></label></th>
954
+                            <th scope="row"><label for="wpbs-css-admin"><?php _e('Load CSS', 'ayecode-connect'); ?></label></th>
955 955
                             <td>
956 956
                                 <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin" <?php echo !empty($overrides['css_backend']) ? 'disabled' : ''; ?>>
957
-                                    <option	value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'ayecode-connect' ); ?></option>
958
-                                    <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'ayecode-connect' ); ?></option>
959
-                                    <option	value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'ayecode-connect' ); ?></option>
957
+                                    <option	value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'ayecode-connect'); ?></option>
958
+                                    <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'ayecode-connect'); ?></option>
959
+                                    <option	value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'ayecode-connect'); ?></option>
960 960
                                 </select>
961 961
                             </td>
962 962
                         </tr>
963 963
 
964 964
                         <tr valign="top">
965
-                            <th scope="row"><label for="wpbs-js-admin"><?php _e( 'Load JS', 'ayecode-connect' ); ?></label></th>
965
+                            <th scope="row"><label for="wpbs-js-admin"><?php _e('Load JS', 'ayecode-connect'); ?></label></th>
966 966
                             <td>
967 967
                                 <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin" <?php echo !empty($overrides['js_backend']) ? 'disabled' : ''; ?>>
968
-                                    <option	value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'ayecode-connect' ); ?></option>
969
-                                    <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'ayecode-connect' ); ?></option>
970
-                                    <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'ayecode-connect' ); ?></option>
971
-                                    <option	value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'ayecode-connect' ); ?></option>
968
+                                    <option	value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'ayecode-connect'); ?></option>
969
+                                    <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'ayecode-connect'); ?></option>
970
+                                    <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'ayecode-connect'); ?></option>
971
+                                    <option	value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'ayecode-connect'); ?></option>
972 972
                                 </select>
973 973
                             </td>
974 974
                         </tr>
975 975
 
976 976
                         <tr valign="top">
977
-                            <th scope="row"><label for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'ayecode-connect' ); ?></label></th>
977
+                            <th scope="row"><label for="wpbs-disable-admin"><?php _e('Disable load on URL', 'ayecode-connect'); ?></label></th>
978 978
                             <td>
979
-                                <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'ayecode-connect' ); ?></p>
980
-                                <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php &#10;action=go"><?php echo $this->settings['disable_admin'];?></textarea>
979
+                                <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'ayecode-connect'); ?></p>
980
+                                <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php &#10;action=go"><?php echo $this->settings['disable_admin']; ?></textarea>
981 981
                             </td>
982 982
                         </tr>
983 983
                     </table>
@@ -986,33 +986,33 @@  discard block
 block discarded – undo
986 986
 					submit_button();
987 987
 					?>
988 988
                 </form>
989
-                <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo $this->version; ?></div>
989
+                <div id="wpbs-version" data-aui-source="<?php echo esc_attr($this->get_load_source()); ?>"><?php echo $this->version; ?></div>
990 990
             </div>
991 991
 			<?php
992 992
 		}
993 993
 
994
-        public function get_load_source(){
995
-	        $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
996
-	        $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
994
+        public function get_load_source() {
995
+	        $file = str_replace(array("/", "\\"), "/", realpath(__FILE__));
996
+	        $plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR));
997 997
 
998 998
 	        // Find source plugin/theme of SD
999 999
 	        $source = array();
1000
-	        if ( strpos( $file, $plugins_dir ) !== false ) {
1001
-		        $source = explode( "/", plugin_basename( $file ) );
1002
-	        } else if ( function_exists( 'get_theme_root' ) ) {
1003
-		        $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1000
+	        if (strpos($file, $plugins_dir) !== false) {
1001
+		        $source = explode("/", plugin_basename($file));
1002
+	        } else if (function_exists('get_theme_root')) {
1003
+		        $themes_dir = str_replace(array("/", "\\"), "/", realpath(get_theme_root()));
1004 1004
 
1005
-		        if ( strpos( $file, $themes_dir ) !== false ) {
1006
-			        $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1005
+		        if (strpos($file, $themes_dir) !== false) {
1006
+			        $source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/"));
1007 1007
 		        }
1008 1008
 	        }
1009 1009
 
1010 1010
             return isset($source[0]) ? esc_attr($source[0]) : '';
1011 1011
         }
1012 1012
 
1013
-		public function customizer_settings($wp_customize){
1013
+		public function customizer_settings($wp_customize) {
1014 1014
 			$wp_customize->add_section('aui_settings', array(
1015
-				'title'    => __('AyeCode UI', 'ayecode-connect' ),
1015
+				'title'    => __('AyeCode UI', 'ayecode-connect'),
1016 1016
 				'priority' => 120,
1017 1017
 			));
1018 1018
 
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 				'type'              => 'option',
1027 1027
 				'transport'         => 'refresh',
1028 1028
 			));
1029
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
-				'label'    => __('Primary Color', 'ayecode-connect' ),
1029
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
+				'label'    => __('Primary Color', 'ayecode-connect'),
1031 1031
 				'section'  => 'aui_settings',
1032 1032
 				'settings' => 'aui_options[color_primary]',
1033 1033
 			)));
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 				'type'              => 'option',
1040 1040
 				'transport'         => 'refresh',
1041 1041
 			));
1042
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
-				'label'    => __('Secondary Color', 'ayecode-connect' ),
1042
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
+				'label'    => __('Secondary Color', 'ayecode-connect'),
1044 1044
 				'section'  => 'aui_settings',
1045 1045
 				'settings' => 'aui_options[color_secondary]',
1046 1046
 			)));
@@ -1066,12 +1066,12 @@  discard block
 block discarded – undo
1066 1066
                 .collapse.show:not(.in){display: inherit;}
1067 1067
                 .fade.show{opacity: 1;}
1068 1068
 
1069
-                <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?>
1069
+                <?php if (defined('SVQ_THEME_VERSION')) { ?>
1070 1070
                 /* KLEO theme specific */
1071 1071
                 .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;}
1072 1072
                 <?php } ?>
1073 1073
 
1074
-                <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
1074
+                <?php if (defined('FUSION_BUILDER_VERSION')) { ?>
1075 1075
                 /* With Avada builder */
1076 1076
                 body.modal-open .modal.in  {opacity:1;z-index: 99999}
1077 1077
                 body.modal-open .modal.bsui.in .modal-content  {box-shadow: none;}
@@ -1082,10 +1082,10 @@  discard block
 block discarded – undo
1082 1082
                 <?php } ?>
1083 1083
             </style>
1084 1084
 			<?php
1085
-			return str_replace( array(
1085
+			return str_replace(array(
1086 1086
 				'<style>',
1087 1087
 				'</style>'
1088
-			), '', self::minify_css( ob_get_clean() ) );
1088
+			), '', self::minify_css(ob_get_clean()));
1089 1089
 		}
1090 1090
 
1091 1091
 
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
             global $aui_bs5;
1094 1094
 
1095 1095
 			$colors = array();
1096
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1096
+			if (defined('BLOCKSTRAP_VERSION')) {
1097 1097
 
1098 1098
 
1099 1099
 				$setting = wp_get_global_settings();
@@ -1102,22 +1102,22 @@  discard block
 block discarded – undo
1102 1102
 //                print_r(get_default_block_editor_settings());exit;
1103 1103
 
1104 1104
 //                print_r($setting);echo  '###';exit;
1105
-				if(!empty($setting['color']['palette']['theme'])){
1106
-					foreach($setting['color']['palette']['theme'] as $color){
1105
+				if (!empty($setting['color']['palette']['theme'])) {
1106
+					foreach ($setting['color']['palette']['theme'] as $color) {
1107 1107
 						$colors[$color['slug']] = esc_attr($color['color']);
1108 1108
 					}
1109 1109
 				}
1110 1110
 
1111
-				if(!empty($setting['color']['palette']['custom'])){
1112
-					foreach($setting['color']['palette']['custom'] as $color){
1111
+				if (!empty($setting['color']['palette']['custom'])) {
1112
+					foreach ($setting['color']['palette']['custom'] as $color) {
1113 1113
 						$colors[$color['slug']] = esc_attr($color['color']);
1114 1114
 					}
1115 1115
 				}
1116
-			}else{
1116
+			} else {
1117 1117
 				$settings = get_option('aui_options');
1118 1118
 				$colors = array(
1119
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1119
+					'primary'   => !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
+					'secondary' => !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1121 1121
 				);
1122 1122
 			}
1123 1123
 
@@ -1128,25 +1128,25 @@  discard block
 block discarded – undo
1128 1128
                 <?php
1129 1129
 
1130 1130
 					// BS v3 compat
1131
-					if( self::is_bs3_compat() ){
1131
+					if (self::is_bs3_compat()) {
1132 1132
 						echo self::bs3_compat_css();
1133 1133
 					}
1134 1134
 
1135
-                    $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
1135
+                    $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
1136 1136
                     $is_fse = false;
1137
-                    if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
1137
+                    if (is_admin() && (!empty($_REQUEST['postType']) || $current_screen->is_block_editor()) && (defined('BLOCKSTRAP_VERSION') || defined('AUI_FSE'))) {
1138 1138
                         $is_fse = true;
1139 1139
                     }
1140 1140
 
1141
-					if(!empty($colors)){
1141
+					if (!empty($colors)) {
1142 1142
 						$d_colors = self::get_colors(true);
1143 1143
 
1144 1144
 //						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1145
-						foreach($colors as $key => $color ){
1146
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1145
+						foreach ($colors as $key => $color) {
1146
+							if ((empty($d_colors[$key]) || $d_colors[$key] != $color) || $is_fse) {
1147 1147
 								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1148 1148
 								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1149
-								echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color);
1149
+								echo $aui_bs5 ? self::css_overwrite_bs5($key, $var, $compat, $color) : self::css_overwrite($key, $var, $compat, $color);
1150 1150
 							}
1151 1151
 						}
1152 1152
 					   // exit;
@@ -1155,70 +1155,70 @@  discard block
 block discarded – undo
1155 1155
 					// Set admin bar z-index lower when modal is open.
1156 1156
 					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1157 1157
 
1158
-					if(is_admin()){
1158
+					if (is_admin()) {
1159 1159
 						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1160 1160
 					}
1161 1161
 
1162
-                    if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' )  ){
1162
+                    if ($aui_bs5 && defined('BLOCKSTRAP_VERSION')) {
1163 1163
                         $css = '';
1164 1164
                         $theme_settings = wp_get_global_styles();
1165 1165
 
1166 1166
 //                        print_r( $theme_settings);exit;
1167 1167
 
1168 1168
                         // font face
1169
-                        if( !empty( $theme_settings['typography']['fontFamily'] ) ){
1170
-                            $t_fontface = str_replace( array('var:preset|','font-family|'), array('--wp--preset--','font-family--'), $theme_settings['typography']['fontFamily']  ); //var(--wp--preset--font-family--poppins)
1169
+                        if (!empty($theme_settings['typography']['fontFamily'])) {
1170
+                            $t_fontface = str_replace(array('var:preset|', 'font-family|'), array('--wp--preset--', 'font-family--'), $theme_settings['typography']['fontFamily']); //var(--wp--preset--font-family--poppins)
1171 1171
                             $css .= '--bs-body-font-family: ' . esc_attr($t_fontface) . ';';
1172 1172
                         }
1173 1173
 
1174 1174
                         // font size
1175
-                        if( !empty( $theme_settings['typography']['fontSize'] ) ){
1176
-                            $css .= '--bs-body-font-size: ' . esc_attr( $theme_settings['typography']['fontSize'] ) . ' ;';
1175
+                        if (!empty($theme_settings['typography']['fontSize'])) {
1176
+                            $css .= '--bs-body-font-size: ' . esc_attr($theme_settings['typography']['fontSize']) . ' ;';
1177 1177
                         }
1178 1178
 
1179 1179
                         // line height
1180
-                         if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1181
-                            $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';';
1180
+                         if (!empty($theme_settings['typography']['lineHeight'])) {
1181
+                            $css .= '--bs-body-line-height: ' . esc_attr($theme_settings['typography']['lineHeight']) . ';';
1182 1182
                         }
1183 1183
 
1184 1184
 
1185 1185
                            // font weight
1186
-                         if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1187
-                            $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';';
1186
+                         if (!empty($theme_settings['typography']['fontWeight'])) {
1187
+                            $css .= '--bs-body-font-weight: ' . esc_attr($theme_settings['typography']['fontWeight']) . ';';
1188 1188
                         }
1189 1189
 
1190 1190
                         // Background
1191
-                         if( !empty( $theme_settings['color']['background'] ) ){
1192
-                            $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';';
1191
+                         if (!empty($theme_settings['color']['background'])) {
1192
+                            $css .= '--bs-body-bg: ' . esc_attr($theme_settings['color']['background']) . ';';
1193 1193
                         }
1194 1194
 
1195 1195
                          // Background Gradient
1196
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1197
-                            $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1196
+                         if (!empty($theme_settings['color']['gradient'])) {
1197
+                            $css .= 'background: ' . esc_attr($theme_settings['color']['gradient']) . ';';
1198 1198
                         }
1199 1199
 
1200 1200
                            // Background Gradient
1201
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1202
-                            $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1201
+                         if (!empty($theme_settings['color']['gradient'])) {
1202
+                            $css .= 'background: ' . esc_attr($theme_settings['color']['gradient']) . ';';
1203 1203
                         }
1204 1204
 
1205 1205
                         // text color
1206
-                        if( !empty( $theme_settings['color']['text'] ) ){
1207
-                            $css .= '--bs-body-color: ' . esc_attr( $theme_settings['color']['text'] ) . ';';
1206
+                        if (!empty($theme_settings['color']['text'])) {
1207
+                            $css .= '--bs-body-color: ' . esc_attr($theme_settings['color']['text']) . ';';
1208 1208
                         }
1209 1209
 
1210 1210
 
1211 1211
                         // link colors
1212
-                        if( !empty( $theme_settings['elements']['link']['color']['text'] ) ){
1213
-                            $css .= '--bs-link-color: ' . esc_attr( $theme_settings['elements']['link']['color']['text'] ) . ';';
1212
+                        if (!empty($theme_settings['elements']['link']['color']['text'])) {
1213
+                            $css .= '--bs-link-color: ' . esc_attr($theme_settings['elements']['link']['color']['text']) . ';';
1214 1214
                         }
1215
-                        if( !empty( $theme_settings['elements']['link'][':hover']['color']['text'] ) ){
1216
-                            $css .= '--bs-link-hover-color: ' . esc_attr( $theme_settings['elements']['link'][':hover']['color']['text'] ) . ';';
1215
+                        if (!empty($theme_settings['elements']['link'][':hover']['color']['text'])) {
1216
+                            $css .= '--bs-link-hover-color: ' . esc_attr($theme_settings['elements']['link'][':hover']['color']['text']) . ';';
1217 1217
                         }
1218 1218
 
1219 1219
 
1220 1220
 
1221
-                        if($css){
1221
+                        if ($css) {
1222 1222
                             echo  $is_fse ? 'body.editor-styles-wrapper{' . $css . '}' : 'body{' . $css . '}';
1223 1223
                         }
1224 1224
 
@@ -1227,42 +1227,42 @@  discard block
 block discarded – undo
1227 1227
 
1228 1228
                         // Headings
1229 1229
                         $headings_css = '';
1230
-                        if( !empty( $theme_settings['elements']['heading']['color']['text'] ) ){
1231
-                            $headings_css .= "color: " . esc_attr( $theme_settings['elements']['heading']['color']['text'] ) . ";";
1230
+                        if (!empty($theme_settings['elements']['heading']['color']['text'])) {
1231
+                            $headings_css .= "color: " . esc_attr($theme_settings['elements']['heading']['color']['text']) . ";";
1232 1232
                         }
1233 1233
 
1234 1234
                         // heading background
1235
-                        if( !empty( $theme_settings['elements']['heading']['color']['background'] ) ){
1236
-                            $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';';
1235
+                        if (!empty($theme_settings['elements']['heading']['color']['background'])) {
1236
+                            $headings_css .= 'background: ' . esc_attr($theme_settings['elements']['heading']['color']['background']) . ';';
1237 1237
                         }
1238 1238
 
1239 1239
                          // heading font family
1240
-                        if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){
1241
-                            $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily']  ) . ';';
1240
+                        if (!empty($theme_settings['elements']['heading']['typography']['fontFamily'])) {
1241
+                            $headings_css .= 'font-family: ' . esc_attr($theme_settings['elements']['heading']['typography']['fontFamily']) . ';';
1242 1242
                         }
1243 1243
 
1244
-                        if( $headings_css ){
1244
+                        if ($headings_css) {
1245 1245
                             echo "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . $headings_css . "}";
1246 1246
                         }
1247 1247
 
1248
-                        $hs = array('h1','h2','h3','h4','h5','h6');
1248
+                        $hs = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6');
1249 1249
 
1250
-                        foreach($hs as $hn){
1250
+                        foreach ($hs as $hn) {
1251 1251
                             $h_css = '';
1252
-                             if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1253
-                                $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';';
1252
+                             if (!empty($theme_settings['elements'][$hn]['color']['text'])) {
1253
+                                $h_css .= 'color: ' . esc_attr($theme_settings['elements'][$hn]['color']['text']) . ';';
1254 1254
                              }
1255 1255
 
1256
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1257
-                                $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize']  ) . ';';
1256
+                              if (!empty($theme_settings['elements'][$hn]['typography']['fontSize'])) {
1257
+                                $h_css .= 'font-size: ' . esc_attr($theme_settings['elements'][$hn]['typography']['fontSize']) . ';';
1258 1258
                              }
1259 1259
 
1260
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1261
-                                $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily']  ) . ';';
1260
+                              if (!empty($theme_settings['elements'][$hn]['typography']['fontFamily'])) {
1261
+                                $h_css .= 'font-family: ' . esc_attr($theme_settings['elements'][$hn]['typography']['fontFamily']) . ';';
1262 1262
                              }
1263 1263
 
1264
-                             if($h_css){
1265
-                                echo $bep . $hn . '{'.$h_css.'}';
1264
+                             if ($h_css) {
1265
+                                echo $bep . $hn . '{' . $h_css . '}';
1266 1266
                              }
1267 1267
                         }
1268 1268
 
@@ -1281,10 +1281,10 @@  discard block
 block discarded – undo
1281 1281
 			/*
1282 1282
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1283 1283
 			 */
1284
-			return str_replace( array(
1284
+			return str_replace(array(
1285 1285
 				'<style>',
1286 1286
 				'</style>'
1287
-			), '', self::minify_css( ob_get_clean() ) );
1287
+			), '', self::minify_css(ob_get_clean()));
1288 1288
 		}
1289 1289
 
1290 1290
 
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 		 *
1295 1295
 		 * @return bool
1296 1296
 		 */
1297
-		public static function is_bs3_compat(){
1297
+		public static function is_bs3_compat() {
1298 1298
 			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1299 1299
 		}
1300 1300
 
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 			$hex = str_replace('#', '', $hex);
1304 1304
 
1305 1305
 			// Convert 3-digit hex to 6-digit hex
1306
-			if(strlen($hex) == 3) {
1306
+			if (strlen($hex) == 3) {
1307 1307
 				$hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2);
1308 1308
 			}
1309 1309
 
@@ -1325,13 +1325,13 @@  discard block
 block discarded – undo
1325 1325
 		 *
1326 1326
 		 * @return string
1327 1327
 		 */
1328
-		public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1328
+		public static function css_overwrite_bs5($type, $color_code, $compatibility, $hex = '') {
1329 1329
 			global $aui_bs5;
1330 1330
 
1331 1331
 			$is_var = false;
1332 1332
 			$is_custom = strpos($type, 'custom-') !== false ? true : false;
1333
-			if(!$color_code){return '';}
1334
-			if(strpos($color_code, 'var') !== false){
1333
+			if (!$color_code) {return ''; }
1334
+			if (strpos($color_code, 'var') !== false) {
1335 1335
 				//if(!sanitize_hex_color($color_code)){
1336 1336
 				$color_code = esc_attr($color_code);
1337 1337
 				$is_var = true;
@@ -1341,15 +1341,15 @@  discard block
 block discarded – undo
1341 1341
 
1342 1342
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1343 1343
 
1344
-			if(!$color_code){return '';}
1344
+			if (!$color_code) {return ''; }
1345 1345
 
1346 1346
 			$rgb = self::hex_to_rgb($hex);
1347 1347
 
1348
-			if($compatibility===true || $compatibility===1){
1348
+			if ($compatibility === true || $compatibility === 1) {
1349 1349
 				$compatibility = '.bsui';
1350
-			}elseif(!$compatibility){
1350
+			}elseif (!$compatibility) {
1351 1351
 				$compatibility = '';
1352
-			}else{
1352
+			} else {
1353 1353
 				$compatibility = esc_attr($compatibility);
1354 1354
 			}
1355 1355
 
@@ -1366,30 +1366,30 @@  discard block
 block discarded – undo
1366 1366
 			 * c = color, b = background color, o = border-color, f = fill
1367 1367
 			 */
1368 1368
 			$selectors = array(
1369
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1370
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1371
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1372
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1373
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1374
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1375
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1376
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1377
-				".badge-{$type}"                                            => array( 'b' ),
1378
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1379
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1380
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1381
-				".text-{$type}"                                     => array( 'c' ),
1369
+				".btn-{$type}"                                              => array('b', 'o'),
1370
+				".btn-{$type}.disabled"                                     => array('b', 'o'),
1371
+				".btn-{$type}:disabled"                                     => array('b', 'o'),
1372
+				".btn-outline-{$type}"                                      => array('c', 'o'),
1373
+				".btn-outline-{$type}:hover"                                => array('b', 'o'),
1374
+				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'),
1375
+				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'),
1376
+				".show>.btn-outline-{$type}.dropdown-toggle"                => array('b', 'o'),
1377
+				".badge-{$type}"                                            => array('b'),
1378
+				".alert-{$type}"                                            => array('b', 'o'),
1379
+				".bg-{$type}"                                               => array('b', 'f'),
1380
+				".btn-link.btn-{$type}"                                     => array('c'),
1381
+				".text-{$type}"                                     => array('c'),
1382 1382
 			);
1383 1383
 
1384
-			if ( $aui_bs5 ) {
1385
-				unset($selectors[".alert-{$type}" ]);
1384
+			if ($aui_bs5) {
1385
+				unset($selectors[".alert-{$type}"]);
1386 1386
 			}
1387 1387
 
1388
-			if ( $type == 'primary' ) {
1388
+			if ($type == 'primary') {
1389 1389
 				$selectors = $selectors + array(
1390
-						'a'                                                                                                    => array( 'c' ),
1391
-						'.btn-link'                                                                                            => array( 'c' ),
1392
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1390
+						'a'                                                                                                    => array('c'),
1391
+						'.btn-link'                                                                                            => array('c'),
1392
+						'.dropdown-item.active'                                                                                => array('b'),
1393 1393
 						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1394 1394
 							'b',
1395 1395
 							'o'
@@ -1398,56 +1398,56 @@  discard block
 block discarded – undo
1398 1398
 							'b',
1399 1399
 							'o'
1400 1400
 						),
1401
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1402
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1403
-						'.page-link'                                                                                           => array( 'c' ),
1401
+						'.nav-pills .nav-link.active'                                                                          => array('b'),
1402
+						'.nav-pills .show>.nav-link'                                                                           => array('b'),
1403
+						'.page-link'                                                                                           => array('c'),
1404 1404
 						'.page-item.active .page-link'                                                                         => array(
1405 1405
 							'b',
1406 1406
 							'o'
1407 1407
 						),
1408
-						'.progress-bar'                                                                                        => array( 'b' ),
1408
+						'.progress-bar'                                                                                        => array('b'),
1409 1409
 						'.list-group-item.active'                                                                              => array(
1410 1410
 							'b',
1411 1411
 							'o'
1412 1412
 						),
1413
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1413
+						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1414 1414
 					);
1415 1415
 			}
1416 1416
 
1417 1417
 
1418 1418
 
1419 1419
             // link
1420
-			if ( $type === 'primary' ) {
1421
-				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1422
-				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1423
-				$output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }';
1420
+			if ($type === 'primary') {
1421
+				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-' . esc_attr($type) . '-rgb), .75); --bs-link-color: var(--bs-' . esc_attr($type) . '); }';
1422
+				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: ' . esc_attr($color_code) . ';  }';
1423
+				$output .= $prefix . ' .navbar { --bs-nav-link-hover-color: ' . esc_attr($color_code) . '; --bs-navbar-hover-color: ' . esc_attr($color_code) . '; --bs-navbar-active-color: ' . esc_attr($color_code) . '; }';
1424 1424
 
1425
-				$output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1426
-				$output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1425
+				$output .= $prefix . ' a{color: var(--bs-' . esc_attr($type) . ');}';
1426
+				$output .= $prefix . ' .text-primary{color: var(--bs-' . esc_attr($type) . ') !important;}';
1427 1427
 
1428 1428
                 // dropdown
1429
-				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1429
+				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-' . esc_attr($type) . '); --bs-dropdown-link-active-color: var(--bs-' . esc_attr($type) . ');}';
1430 1430
 
1431 1431
                 // pagination
1432
-				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1432
+				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-' . esc_attr($type) . '); --bs-pagination-active-bg: var(--bs-' . esc_attr($type) . ');}';
1433 1433
 
1434 1434
 			}
1435 1435
 
1436
-			$output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1436
+			$output .= $prefix . ' .link-' . esc_attr($type) . ':hover {color: rgba(var(--bs-' . esc_attr($type) . '-rgb), .8) !important;}';
1437 1437
 
1438 1438
 			//  buttons
1439
-			$output .= $prefix . ' .btn-'.esc_attr($type).'{';
1439
+			$output .= $prefix . ' .btn-' . esc_attr($type) . '{';
1440 1440
 			$output .= ' 
1441
-            --bs-btn-bg: '.esc_attr($color_code).';
1442
-            --bs-btn-border-color: '.esc_attr($color_code).';
1443
-            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1444
-            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1445
-            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb;
1446
-            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1447
-            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1441
+            --bs-btn-bg: '.esc_attr($color_code) . ';
1442
+            --bs-btn-border-color: '.esc_attr($color_code) . ';
1443
+            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1444
+            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1445
+            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type) . '-rgb;
1446
+            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1447
+            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1448 1448
             --bs-btn-active-shadow: unset;
1449
-            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
1450
-            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1);
1449
+            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .5);
1450
+            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .1);
1451 1451
             ';
1452 1452
 //			$output .= '
1453 1453
 //		    --bs-btn-color: #fff;
@@ -1458,17 +1458,17 @@  discard block
 block discarded – undo
1458 1458
 			$output .= '}';
1459 1459
 
1460 1460
 			//  buttons outline
1461
-			$output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1461
+			$output .= $prefix . ' .btn-outline-' . esc_attr($type) . '{';
1462 1462
 			$output .= ' 
1463
-            --bs-btn-border-color: '.esc_attr($color_code).';
1464
-            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1465
-            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1466
-            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb;
1467
-            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1468
-            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1463
+            --bs-btn-border-color: '.esc_attr($color_code) . ';
1464
+            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1465
+            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1466
+            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type) . '-rgb;
1467
+            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1468
+            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1469 1469
             --bs-btn-active-shadow: unset;
1470
-            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
1471
-            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1);
1470
+            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .5);
1471
+            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .1);
1472 1472
             ';
1473 1473
 //			$output .= '
1474 1474
 //		    --bs-btn-color: #fff;
@@ -1480,32 +1480,32 @@  discard block
 block discarded – undo
1480 1480
 
1481 1481
 
1482 1482
             // button hover
1483
-			$output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1483
+			$output .= $prefix . ' .btn-' . esc_attr($type) . ':hover{';
1484 1484
 			$output .= ' 
1485
-            box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb) , .4);
1485
+            box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type) . '-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-' . esc_attr($type) . '-rgb) , .4);
1486 1486
             }
1487 1487
             ';
1488 1488
 
1489 1489
 
1490
-			if ( $aui_bs5 ) {
1490
+			if ($aui_bs5) {
1491 1491
 //				$output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1492
-				$output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1493
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1492
+				$output .= 'html body {--bs-' . esc_attr($type) . ': ' . esc_attr($color_code) . '; }';
1493
+				$output .= 'html body {--bs-' . esc_attr($type) . '-rgb: ' . $rgb . '; }';
1494 1494
 			}
1495 1495
 
1496 1496
 
1497
-			if ( $is_custom ) {
1497
+			if ($is_custom) {
1498 1498
 
1499 1499
 //				echo '###'.$type;exit;
1500 1500
 
1501 1501
 				// build rules into each type
1502
-				foreach($selectors as $selector => $types){
1503
-					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1504
-					$types = array_combine($types,$types);
1505
-					if(isset($types['c'])){$color[] = $selector;}
1506
-					if(isset($types['b'])){$background[] = $selector;}
1507
-					if(isset($types['o'])){$border[] = $selector;}
1508
-					if(isset($types['f'])){$fill[] = $selector;}
1502
+				foreach ($selectors as $selector => $types) {
1503
+					$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1504
+					$types = array_combine($types, $types);
1505
+					if (isset($types['c'])) {$color[] = $selector; }
1506
+					if (isset($types['b'])) {$background[] = $selector; }
1507
+					if (isset($types['o'])) {$border[] = $selector; }
1508
+					if (isset($types['f'])) {$fill[] = $selector; }
1509 1509
 				}
1510 1510
 
1511 1511
 //				// build rules into each type
@@ -1519,36 +1519,36 @@  discard block
 block discarded – undo
1519 1519
 //				}
1520 1520
 
1521 1521
 				// add any color rules
1522
-				if(!empty($color)){
1523
-					$output .= implode(",",$color) . "{color: $color_code;} ";
1522
+				if (!empty($color)) {
1523
+					$output .= implode(",", $color) . "{color: $color_code;} ";
1524 1524
 				}
1525
-				if(!empty($color_i)){
1526
-					$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1525
+				if (!empty($color_i)) {
1526
+					$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1527 1527
 				}
1528 1528
 
1529 1529
 				// add any background color rules
1530
-				if(!empty($background)){
1531
-					$output .= implode(",",$background) . "{background-color: $color_code;} ";
1530
+				if (!empty($background)) {
1531
+					$output .= implode(",", $background) . "{background-color: $color_code;} ";
1532 1532
 				}
1533
-				if(!empty($background_i)){
1534
-					$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1533
+				if (!empty($background_i)) {
1534
+					$output .= $aui_bs5 ? '' : implode(",", $background_i) . "{background-color: $color_code !important;} ";
1535 1535
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1536 1536
 				}
1537 1537
 
1538 1538
 				// add any border color rules
1539
-				if(!empty($border)){
1540
-					$output .= implode(",",$border) . "{border-color: $color_code;} ";
1539
+				if (!empty($border)) {
1540
+					$output .= implode(",", $border) . "{border-color: $color_code;} ";
1541 1541
 				}
1542
-				if(!empty($border_i)){
1543
-					$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1542
+				if (!empty($border_i)) {
1543
+					$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1544 1544
 				}
1545 1545
 
1546 1546
 				// add any fill color rules
1547
-				if(!empty($fill)){
1548
-					$output .= implode(",",$fill) . "{fill: $color_code;} ";
1547
+				if (!empty($fill)) {
1548
+					$output .= implode(",", $fill) . "{fill: $color_code;} ";
1549 1549
 				}
1550
-				if(!empty($fill_i)){
1551
-					$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1550
+				if (!empty($fill_i)) {
1551
+					$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1552 1552
 				}
1553 1553
 
1554 1554
 			}
@@ -1558,25 +1558,25 @@  discard block
 block discarded – undo
1558 1558
 
1559 1559
 			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1560 1560
 			// darken
1561
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1562
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1563
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1564
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1561
+			$darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075");
1562
+			$darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10");
1563
+			$darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125");
1564
+			$darker_40 = $is_var ? $color_code . ';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code, "-0.4");
1565 1565
 
1566 1566
 			// lighten
1567
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1567
+			$lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25");
1568 1568
 
1569 1569
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1570
-			$op_25 = $color_code."40"; // 25% opacity
1570
+			$op_25 = $color_code . "40"; // 25% opacity
1571 1571
 
1572 1572
 
1573 1573
 			// button states
1574
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1575
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1574
+			$output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : '';
1575
+			$output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1576 1576
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1577
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1578
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1579
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1577
+			$output .= $prefix . " .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1578
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
1579
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1580 1580
 
1581 1581
 			// text
1582 1582
 //			$output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} ";
@@ -1594,9 +1594,9 @@  discard block
 block discarded – undo
1594 1594
 //			}
1595 1595
 
1596 1596
 			// alerts
1597
-			if ( $aui_bs5 ) {
1597
+			if ($aui_bs5) {
1598 1598
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1599
-				$output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1599
+				$output .= $prefix . " .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1600 1600
 			}
1601 1601
 
1602 1602
 			return $output;
@@ -1611,12 +1611,12 @@  discard block
 block discarded – undo
1611 1611
 		 *
1612 1612
 		 * @return string
1613 1613
 		 */
1614
-		public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1614
+		public static function css_overwrite($type, $color_code, $compatibility, $hex = '') {
1615 1615
             global $aui_bs5;
1616 1616
 
1617 1617
 			$is_var = false;
1618
-			if(!$color_code){return '';}
1619
-			if(strpos($color_code, 'var') !== false){
1618
+			if (!$color_code) {return ''; }
1619
+			if (strpos($color_code, 'var') !== false) {
1620 1620
 				//if(!sanitize_hex_color($color_code)){
1621 1621
 				$color_code = esc_attr($color_code);
1622 1622
 				$is_var = true;
@@ -1626,15 +1626,15 @@  discard block
 block discarded – undo
1626 1626
 
1627 1627
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1628 1628
 
1629
-			if(!$color_code){return '';}
1629
+			if (!$color_code) {return ''; }
1630 1630
 
1631 1631
             $rgb = self::hex_to_rgb($hex);
1632 1632
 
1633
-			if($compatibility===true || $compatibility===1){
1633
+			if ($compatibility === true || $compatibility === 1) {
1634 1634
 				$compatibility = '.bsui';
1635
-			}elseif(!$compatibility){
1635
+			}elseif (!$compatibility) {
1636 1636
 				$compatibility = '';
1637
-			}else{
1637
+			} else {
1638 1638
 				$compatibility = esc_attr($compatibility);
1639 1639
 			}
1640 1640
 
@@ -1648,29 +1648,29 @@  discard block
 block discarded – undo
1648 1648
 			 * c = color, b = background color, o = border-color, f = fill
1649 1649
 			 */
1650 1650
 			$selectors = array(
1651
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1652
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1653
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1654
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1655
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1656
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1657
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1658
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1659
-				".badge-{$type}"                                            => array( 'b' ),
1660
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1661
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1662
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1651
+				".btn-{$type}"                                              => array('b', 'o'),
1652
+				".btn-{$type}.disabled"                                     => array('b', 'o'),
1653
+				".btn-{$type}:disabled"                                     => array('b', 'o'),
1654
+				".btn-outline-{$type}"                                      => array('c', 'o'),
1655
+				".btn-outline-{$type}:hover"                                => array('b', 'o'),
1656
+				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'),
1657
+				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'),
1658
+				".show>.btn-outline-{$type}.dropdown-toggle"                => array('b', 'o'),
1659
+				".badge-{$type}"                                            => array('b'),
1660
+				".alert-{$type}"                                            => array('b', 'o'),
1661
+				".bg-{$type}"                                               => array('b', 'f'),
1662
+				".btn-link.btn-{$type}"                                     => array('c'),
1663 1663
 			);
1664 1664
 
1665
-			if ( $aui_bs5 ) {
1666
-                unset($selectors[".alert-{$type}" ]);
1665
+			if ($aui_bs5) {
1666
+                unset($selectors[".alert-{$type}"]);
1667 1667
 			}
1668 1668
 
1669
-			if ( $type == 'primary' ) {
1669
+			if ($type == 'primary') {
1670 1670
 				$selectors = $selectors + array(
1671
-						'a'                                                                                                    => array( 'c' ),
1672
-						'.btn-link'                                                                                            => array( 'c' ),
1673
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1671
+						'a'                                                                                                    => array('c'),
1672
+						'.btn-link'                                                                                            => array('c'),
1673
+						'.dropdown-item.active'                                                                                => array('b'),
1674 1674
 						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1675 1675
 							'b',
1676 1676
 							'o'
@@ -1679,19 +1679,19 @@  discard block
 block discarded – undo
1679 1679
 							'b',
1680 1680
 							'o'
1681 1681
 						),
1682
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1683
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1684
-						'.page-link'                                                                                           => array( 'c' ),
1682
+						'.nav-pills .nav-link.active'                                                                          => array('b'),
1683
+						'.nav-pills .show>.nav-link'                                                                           => array('b'),
1684
+						'.page-link'                                                                                           => array('c'),
1685 1685
 						'.page-item.active .page-link'                                                                         => array(
1686 1686
 							'b',
1687 1687
 							'o'
1688 1688
 						),
1689
-						'.progress-bar'                                                                                        => array( 'b' ),
1689
+						'.progress-bar'                                                                                        => array('b'),
1690 1690
 						'.list-group-item.active'                                                                              => array(
1691 1691
 							'b',
1692 1692
 							'o'
1693 1693
 						),
1694
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1694
+						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1695 1695
 //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1696 1696
 //				    '.custom-range::-moz-range-thumb' => array('b'),
1697 1697
 //				    '.custom-range::-ms-thumb' => array('b'),
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
 			}
1700 1700
 
1701 1701
 			$important_selectors = array(
1702
-				".bg-{$type}" => array('b','f'),
1702
+				".bg-{$type}" => array('b', 'f'),
1703 1703
 				".border-{$type}" => array('o'),
1704 1704
 				".text-{$type}" => array('c'),
1705 1705
 			);
@@ -1715,62 +1715,62 @@  discard block
 block discarded – undo
1715 1715
 
1716 1716
 			$output = '';
1717 1717
 
1718
-			if ( $aui_bs5 ) {
1718
+			if ($aui_bs5) {
1719 1719
 //				$output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1720
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1720
+				$output .= 'html body {--bs-' . esc_attr($type) . '-rgb: ' . $rgb . '; }';
1721 1721
 			}
1722 1722
 
1723 1723
 			// build rules into each type
1724
-			foreach($selectors as $selector => $types){
1725
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1726
-				$types = array_combine($types,$types);
1727
-				if(isset($types['c'])){$color[] = $selector;}
1728
-				if(isset($types['b'])){$background[] = $selector;}
1729
-				if(isset($types['o'])){$border[] = $selector;}
1730
-				if(isset($types['f'])){$fill[] = $selector;}
1724
+			foreach ($selectors as $selector => $types) {
1725
+				$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1726
+				$types = array_combine($types, $types);
1727
+				if (isset($types['c'])) {$color[] = $selector; }
1728
+				if (isset($types['b'])) {$background[] = $selector; }
1729
+				if (isset($types['o'])) {$border[] = $selector; }
1730
+				if (isset($types['f'])) {$fill[] = $selector; }
1731 1731
 			}
1732 1732
 
1733 1733
 			// build rules into each type
1734
-			foreach($important_selectors as $selector => $types){
1735
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1736
-				$types = array_combine($types,$types);
1737
-				if(isset($types['c'])){$color_i[] = $selector;}
1738
-				if(isset($types['b'])){$background_i[] = $selector;}
1739
-				if(isset($types['o'])){$border_i[] = $selector;}
1740
-				if(isset($types['f'])){$fill_i[] = $selector;}
1734
+			foreach ($important_selectors as $selector => $types) {
1735
+				$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1736
+				$types = array_combine($types, $types);
1737
+				if (isset($types['c'])) {$color_i[] = $selector; }
1738
+				if (isset($types['b'])) {$background_i[] = $selector; }
1739
+				if (isset($types['o'])) {$border_i[] = $selector; }
1740
+				if (isset($types['f'])) {$fill_i[] = $selector; }
1741 1741
 			}
1742 1742
 
1743 1743
 			// add any color rules
1744
-			if(!empty($color)){
1745
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1744
+			if (!empty($color)) {
1745
+				$output .= implode(",", $color) . "{color: $color_code;} ";
1746 1746
 			}
1747
-			if(!empty($color_i)){
1748
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1747
+			if (!empty($color_i)) {
1748
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1749 1749
 			}
1750 1750
 
1751 1751
 			// add any background color rules
1752
-			if(!empty($background)){
1753
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1752
+			if (!empty($background)) {
1753
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
1754 1754
 			}
1755
-			if(!empty($background_i)){
1756
-				$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1755
+			if (!empty($background_i)) {
1756
+				$output .= $aui_bs5 ? '' : implode(",", $background_i) . "{background-color: $color_code !important;} ";
1757 1757
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1758 1758
 			}
1759 1759
 
1760 1760
 			// add any border color rules
1761
-			if(!empty($border)){
1762
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1761
+			if (!empty($border)) {
1762
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
1763 1763
 			}
1764
-			if(!empty($border_i)){
1765
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1764
+			if (!empty($border_i)) {
1765
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1766 1766
 			}
1767 1767
 
1768 1768
 			// add any fill color rules
1769
-			if(!empty($fill)){
1770
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1769
+			if (!empty($fill)) {
1770
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
1771 1771
 			}
1772
-			if(!empty($fill_i)){
1773
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1772
+			if (!empty($fill_i)) {
1773
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1774 1774
 			}
1775 1775
 
1776 1776
 
@@ -1778,27 +1778,27 @@  discard block
 block discarded – undo
1778 1778
 
1779 1779
 			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1780 1780
 			// darken
1781
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1782
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1783
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1784
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1781
+			$darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075");
1782
+			$darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10");
1783
+			$darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125");
1784
+			$darker_40 = $is_var ? $color_code . ';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code, "-0.4");
1785 1785
 
1786 1786
 			// lighten
1787
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1787
+			$lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25");
1788 1788
 
1789 1789
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1790
-			$op_25 = $color_code."40"; // 25% opacity
1790
+			$op_25 = $color_code . "40"; // 25% opacity
1791 1791
 
1792 1792
 
1793 1793
 			// button states
1794
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1795
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1794
+			$output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : '';
1795
+			$output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1796 1796
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1797
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1798
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1799
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1797
+			$output .= $prefix . " .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1798
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
1799
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1800 1800
 
1801
-			if ( $type == 'primary' ) {
1801
+			if ($type == 'primary') {
1802 1802
 				// dropdown's
1803 1803
 				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1804 1804
 
@@ -1810,9 +1810,9 @@  discard block
 block discarded – undo
1810 1810
 			}
1811 1811
 
1812 1812
             // alerts
1813
-			if ( $aui_bs5 ) {
1813
+			if ($aui_bs5) {
1814 1814
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1815
-				$output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1815
+				$output .= $prefix . " .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1816 1816
 			}
1817 1817
 
1818 1818
 			return $output;
@@ -1828,11 +1828,11 @@  discard block
 block discarded – undo
1828 1828
 		 *
1829 1829
 		 * @return string
1830 1830
 		 */
1831
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
1831
+		public static function css_primary($color_code, $compatibility, $use_variable = false) {
1832 1832
 
1833
-			if(!$use_variable){
1833
+			if (!$use_variable) {
1834 1834
 				$color_code = sanitize_hex_color($color_code);
1835
-				if(!$color_code){return '';}
1835
+				if (!$color_code) {return ''; }
1836 1836
 			}
1837 1837
 
1838 1838
 			/**
@@ -1840,36 +1840,36 @@  discard block
 block discarded – undo
1840 1840
 			 */
1841 1841
 			$selectors = array(
1842 1842
 				'a' => array('c'),
1843
-				'.btn-primary' => array('b','o'),
1844
-				'.btn-primary.disabled' => array('b','o'),
1845
-				'.btn-primary:disabled' => array('b','o'),
1846
-				'.btn-outline-primary' => array('c','o'),
1847
-				'.btn-outline-primary:hover' => array('b','o'),
1848
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1849
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1850
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1843
+				'.btn-primary' => array('b', 'o'),
1844
+				'.btn-primary.disabled' => array('b', 'o'),
1845
+				'.btn-primary:disabled' => array('b', 'o'),
1846
+				'.btn-outline-primary' => array('c', 'o'),
1847
+				'.btn-outline-primary:hover' => array('b', 'o'),
1848
+				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'),
1849
+				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'),
1850
+				'.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'),
1851 1851
 				'.btn-link' => array('c'),
1852 1852
 				'.dropdown-item.active' => array('b'),
1853
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1854
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1853
+				'.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'),
1854
+				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'),
1855 1855
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1856 1856
 //				'.custom-range::-moz-range-thumb' => array('b'),
1857 1857
 //				'.custom-range::-ms-thumb' => array('b'),
1858 1858
 				'.nav-pills .nav-link.active' => array('b'),
1859 1859
 				'.nav-pills .show>.nav-link' => array('b'),
1860 1860
 				'.page-link' => array('c'),
1861
-				'.page-item.active .page-link' => array('b','o'),
1861
+				'.page-item.active .page-link' => array('b', 'o'),
1862 1862
 				'.badge-primary' => array('b'),
1863
-				'.alert-primary' => array('b','o'),
1863
+				'.alert-primary' => array('b', 'o'),
1864 1864
 				'.progress-bar' => array('b'),
1865
-				'.list-group-item.active' => array('b','o'),
1866
-				'.bg-primary' => array('b','f'),
1865
+				'.list-group-item.active' => array('b', 'o'),
1866
+				'.bg-primary' => array('b', 'f'),
1867 1867
 				'.btn-link.btn-primary' => array('c'),
1868 1868
 				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1869 1869
 			);
1870 1870
 
1871 1871
 			$important_selectors = array(
1872
-				'.bg-primary' => array('b','f'),
1872
+				'.bg-primary' => array('b', 'f'),
1873 1873
 				'.border-primary' => array('o'),
1874 1874
 				'.text-primary' => array('c'),
1875 1875
 			);
@@ -1886,88 +1886,88 @@  discard block
 block discarded – undo
1886 1886
 			$output = '';
1887 1887
 
1888 1888
 			// build rules into each type
1889
-			foreach($selectors as $selector => $types){
1890
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1891
-				$types = array_combine($types,$types);
1892
-				if(isset($types['c'])){$color[] = $selector;}
1893
-				if(isset($types['b'])){$background[] = $selector;}
1894
-				if(isset($types['o'])){$border[] = $selector;}
1895
-				if(isset($types['f'])){$fill[] = $selector;}
1889
+			foreach ($selectors as $selector => $types) {
1890
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1891
+				$types = array_combine($types, $types);
1892
+				if (isset($types['c'])) {$color[] = $selector; }
1893
+				if (isset($types['b'])) {$background[] = $selector; }
1894
+				if (isset($types['o'])) {$border[] = $selector; }
1895
+				if (isset($types['f'])) {$fill[] = $selector; }
1896 1896
 			}
1897 1897
 
1898 1898
 			// build rules into each type
1899
-			foreach($important_selectors as $selector => $types){
1900
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1901
-				$types = array_combine($types,$types);
1902
-				if(isset($types['c'])){$color_i[] = $selector;}
1903
-				if(isset($types['b'])){$background_i[] = $selector;}
1904
-				if(isset($types['o'])){$border_i[] = $selector;}
1905
-				if(isset($types['f'])){$fill_i[] = $selector;}
1899
+			foreach ($important_selectors as $selector => $types) {
1900
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1901
+				$types = array_combine($types, $types);
1902
+				if (isset($types['c'])) {$color_i[] = $selector; }
1903
+				if (isset($types['b'])) {$background_i[] = $selector; }
1904
+				if (isset($types['o'])) {$border_i[] = $selector; }
1905
+				if (isset($types['f'])) {$fill_i[] = $selector; }
1906 1906
 			}
1907 1907
 
1908 1908
 			// add any color rules
1909
-			if(!empty($color)){
1910
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1909
+			if (!empty($color)) {
1910
+				$output .= implode(",", $color) . "{color: $color_code;} ";
1911 1911
 			}
1912
-			if(!empty($color_i)){
1913
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1912
+			if (!empty($color_i)) {
1913
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1914 1914
 			}
1915 1915
 
1916 1916
 			// add any background color rules
1917
-			if(!empty($background)){
1918
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1917
+			if (!empty($background)) {
1918
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
1919 1919
 			}
1920
-			if(!empty($background_i)){
1921
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1920
+			if (!empty($background_i)) {
1921
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
1922 1922
 			}
1923 1923
 
1924 1924
 			// add any border color rules
1925
-			if(!empty($border)){
1926
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1925
+			if (!empty($border)) {
1926
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
1927 1927
 			}
1928
-			if(!empty($border_i)){
1929
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1928
+			if (!empty($border_i)) {
1929
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1930 1930
 			}
1931 1931
 
1932 1932
 			// add any fill color rules
1933
-			if(!empty($fill)){
1934
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1933
+			if (!empty($fill)) {
1934
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
1935 1935
 			}
1936
-			if(!empty($fill_i)){
1937
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1936
+			if (!empty($fill_i)) {
1937
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1938 1938
 			}
1939 1939
 
1940 1940
 
1941 1941
 			$prefix = $compatibility ? ".bsui " : "";
1942 1942
 
1943 1943
 			// darken
1944
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1945
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1946
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1944
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
1945
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
1946
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
1947 1947
 
1948 1948
 			// lighten
1949
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1949
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
1950 1950
 
1951 1951
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1952
-			$op_25 = $color_code."40"; // 25% opacity
1952
+			$op_25 = $color_code . "40"; // 25% opacity
1953 1953
 
1954 1954
 
1955 1955
 			// button states
1956
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1957
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1958
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1959
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1956
+			$output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1957
+			$output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1958
+			$output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
1959
+			$output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1960 1960
 
1961 1961
 
1962 1962
 			// dropdown's
1963
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1963
+			$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1964 1964
 
1965 1965
 
1966 1966
 			// input states
1967
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1967
+			$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1968 1968
 
1969 1969
 			// page link
1970
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1970
+			$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1971 1971
 
1972 1972
 			return $output;
1973 1973
 		}
@@ -1981,30 +1981,30 @@  discard block
 block discarded – undo
1981 1981
 		 *
1982 1982
 		 * @return string
1983 1983
 		 */
1984
-		public static function css_secondary($color_code,$compatibility){;
1984
+		public static function css_secondary($color_code, $compatibility) {;
1985 1985
 			$color_code = sanitize_hex_color($color_code);
1986
-			if(!$color_code){return '';}
1986
+			if (!$color_code) {return ''; }
1987 1987
 			/**
1988 1988
 			 * c = color, b = background color, o = border-color, f = fill
1989 1989
 			 */
1990 1990
 			$selectors = array(
1991
-				'.btn-secondary' => array('b','o'),
1992
-				'.btn-secondary.disabled' => array('b','o'),
1993
-				'.btn-secondary:disabled' => array('b','o'),
1994
-				'.btn-outline-secondary' => array('c','o'),
1995
-				'.btn-outline-secondary:hover' => array('b','o'),
1991
+				'.btn-secondary' => array('b', 'o'),
1992
+				'.btn-secondary.disabled' => array('b', 'o'),
1993
+				'.btn-secondary:disabled' => array('b', 'o'),
1994
+				'.btn-outline-secondary' => array('c', 'o'),
1995
+				'.btn-outline-secondary:hover' => array('b', 'o'),
1996 1996
 				'.btn-outline-secondary.disabled' => array('c'),
1997 1997
 				'.btn-outline-secondary:disabled' => array('c'),
1998
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
1999
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2000
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
1998
+				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'),
1999
+				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'),
2000
+				'.btn-outline-secondary.dropdown-toggle' => array('b', 'o'),
2001 2001
 				'.badge-secondary' => array('b'),
2002
-				'.alert-secondary' => array('b','o'),
2002
+				'.alert-secondary' => array('b', 'o'),
2003 2003
 				'.btn-link.btn-secondary' => array('c'),
2004 2004
 			);
2005 2005
 
2006 2006
 			$important_selectors = array(
2007
-				'.bg-secondary' => array('b','f'),
2007
+				'.bg-secondary' => array('b', 'f'),
2008 2008
 				'.border-secondary' => array('o'),
2009 2009
 				'.text-secondary' => array('c'),
2010 2010
 			);
@@ -2021,77 +2021,77 @@  discard block
 block discarded – undo
2021 2021
 			$output = '';
2022 2022
 
2023 2023
 			// build rules into each type
2024
-			foreach($selectors as $selector => $types){
2025
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2026
-				$types = array_combine($types,$types);
2027
-				if(isset($types['c'])){$color[] = $selector;}
2028
-				if(isset($types['b'])){$background[] = $selector;}
2029
-				if(isset($types['o'])){$border[] = $selector;}
2030
-				if(isset($types['f'])){$fill[] = $selector;}
2024
+			foreach ($selectors as $selector => $types) {
2025
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
2026
+				$types = array_combine($types, $types);
2027
+				if (isset($types['c'])) {$color[] = $selector; }
2028
+				if (isset($types['b'])) {$background[] = $selector; }
2029
+				if (isset($types['o'])) {$border[] = $selector; }
2030
+				if (isset($types['f'])) {$fill[] = $selector; }
2031 2031
 			}
2032 2032
 
2033 2033
 			// build rules into each type
2034
-			foreach($important_selectors as $selector => $types){
2035
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2036
-				$types = array_combine($types,$types);
2037
-				if(isset($types['c'])){$color_i[] = $selector;}
2038
-				if(isset($types['b'])){$background_i[] = $selector;}
2039
-				if(isset($types['o'])){$border_i[] = $selector;}
2040
-				if(isset($types['f'])){$fill_i[] = $selector;}
2034
+			foreach ($important_selectors as $selector => $types) {
2035
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
2036
+				$types = array_combine($types, $types);
2037
+				if (isset($types['c'])) {$color_i[] = $selector; }
2038
+				if (isset($types['b'])) {$background_i[] = $selector; }
2039
+				if (isset($types['o'])) {$border_i[] = $selector; }
2040
+				if (isset($types['f'])) {$fill_i[] = $selector; }
2041 2041
 			}
2042 2042
 
2043 2043
 			// add any color rules
2044
-			if(!empty($color)){
2045
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2044
+			if (!empty($color)) {
2045
+				$output .= implode(",", $color) . "{color: $color_code;} ";
2046 2046
 			}
2047
-			if(!empty($color_i)){
2048
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2047
+			if (!empty($color_i)) {
2048
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
2049 2049
 			}
2050 2050
 
2051 2051
 			// add any background color rules
2052
-			if(!empty($background)){
2053
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2052
+			if (!empty($background)) {
2053
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
2054 2054
 			}
2055
-			if(!empty($background_i)){
2056
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2055
+			if (!empty($background_i)) {
2056
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
2057 2057
 			}
2058 2058
 
2059 2059
 			// add any border color rules
2060
-			if(!empty($border)){
2061
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2060
+			if (!empty($border)) {
2061
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
2062 2062
 			}
2063
-			if(!empty($border_i)){
2064
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2063
+			if (!empty($border_i)) {
2064
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
2065 2065
 			}
2066 2066
 
2067 2067
 			// add any fill color rules
2068
-			if(!empty($fill)){
2069
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2068
+			if (!empty($fill)) {
2069
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
2070 2070
 			}
2071
-			if(!empty($fill_i)){
2072
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2071
+			if (!empty($fill_i)) {
2072
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
2073 2073
 			}
2074 2074
 
2075 2075
 
2076 2076
 			$prefix = $compatibility ? ".bsui " : "";
2077 2077
 
2078 2078
 			// darken
2079
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2080
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2081
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2079
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
2080
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
2081
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
2082 2082
 
2083 2083
 			// lighten
2084
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2084
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
2085 2085
 
2086 2086
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
2087
-			$op_25 = $color_code."40"; // 25% opacity
2087
+			$op_25 = $color_code . "40"; // 25% opacity
2088 2088
 
2089 2089
 
2090 2090
 			// button states
2091
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2092
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2093
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
2094
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2091
+			$output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
2092
+			$output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
2093
+			$output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
2094
+			$output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
2095 2095
 
2096 2096
 
2097 2097
 			return $output;
@@ -2127,8 +2127,8 @@  discard block
 block discarded – undo
2127 2127
 		/**
2128 2128
 		 * Check if we should display examples.
2129 2129
 		 */
2130
-		public function maybe_show_examples(){
2131
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2130
+		public function maybe_show_examples() {
2131
+			if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) {
2132 2132
 				echo "<head>";
2133 2133
 				wp_head();
2134 2134
 				echo "</head>";
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 		 *
2145 2145
 		 * @return string
2146 2146
 		 */
2147
-		public function get_examples(){
2147
+		public function get_examples() {
2148 2148
 			$output = '';
2149 2149
 
2150 2150
 
@@ -2250,74 +2250,74 @@  discard block
 block discarded – undo
2250 2250
 		 */
2251 2251
 		public static function calendar_params() {
2252 2252
 			$params = array(
2253
-				'month_long_1' => __( 'January', 'ayecode-connect' ),
2254
-				'month_long_2' => __( 'February', 'ayecode-connect' ),
2255
-				'month_long_3' => __( 'March', 'ayecode-connect' ),
2256
-				'month_long_4' => __( 'April', 'ayecode-connect' ),
2257
-				'month_long_5' => __( 'May', 'ayecode-connect' ),
2258
-				'month_long_6' => __( 'June', 'ayecode-connect' ),
2259
-				'month_long_7' => __( 'July', 'ayecode-connect' ),
2260
-				'month_long_8' => __( 'August', 'ayecode-connect' ),
2261
-				'month_long_9' => __( 'September', 'ayecode-connect' ),
2262
-				'month_long_10' => __( 'October', 'ayecode-connect' ),
2263
-				'month_long_11' => __( 'November', 'ayecode-connect' ),
2264
-				'month_long_12' => __( 'December', 'ayecode-connect' ),
2265
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2266
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2267
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2268
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2269
-				'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2270
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2271
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2272
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2273
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2274
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2275
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2276
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2277
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2278
-				'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2279
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2280
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2281
-				'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2282
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2283
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2284
-				'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2285
-				'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2286
-				'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2287
-				'day_s2_4' => __( 'We', 'ayecode-connect' ),
2288
-				'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2289
-				'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2290
-				'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2291
-				'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2292
-				'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2293
-				'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2294
-				'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2295
-				'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2296
-				'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2297
-				'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2298
-				'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2299
-				'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2300
-				'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2301
-				'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2302
-				'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2303
-				'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2304
-				'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2305
-				'am_lower' => __( 'am', 'ayecode-connect' ),
2306
-				'pm_lower' => __( 'pm', 'ayecode-connect' ),
2307
-				'am_upper' => __( 'AM', 'ayecode-connect' ),
2308
-				'pm_upper' => __( 'PM', 'ayecode-connect' ),
2309
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2253
+				'month_long_1' => __('January', 'ayecode-connect'),
2254
+				'month_long_2' => __('February', 'ayecode-connect'),
2255
+				'month_long_3' => __('March', 'ayecode-connect'),
2256
+				'month_long_4' => __('April', 'ayecode-connect'),
2257
+				'month_long_5' => __('May', 'ayecode-connect'),
2258
+				'month_long_6' => __('June', 'ayecode-connect'),
2259
+				'month_long_7' => __('July', 'ayecode-connect'),
2260
+				'month_long_8' => __('August', 'ayecode-connect'),
2261
+				'month_long_9' => __('September', 'ayecode-connect'),
2262
+				'month_long_10' => __('October', 'ayecode-connect'),
2263
+				'month_long_11' => __('November', 'ayecode-connect'),
2264
+				'month_long_12' => __('December', 'ayecode-connect'),
2265
+				'month_s_1' => _x('Jan', 'January abbreviation', 'ayecode-connect'),
2266
+				'month_s_2' => _x('Feb', 'February abbreviation', 'ayecode-connect'),
2267
+				'month_s_3' => _x('Mar', 'March abbreviation', 'ayecode-connect'),
2268
+				'month_s_4' => _x('Apr', 'April abbreviation', 'ayecode-connect'),
2269
+				'month_s_5' => _x('May', 'May abbreviation', 'ayecode-connect'),
2270
+				'month_s_6' => _x('Jun', 'June abbreviation', 'ayecode-connect'),
2271
+				'month_s_7' => _x('Jul', 'July abbreviation', 'ayecode-connect'),
2272
+				'month_s_8' => _x('Aug', 'August abbreviation', 'ayecode-connect'),
2273
+				'month_s_9' => _x('Sep', 'September abbreviation', 'ayecode-connect'),
2274
+				'month_s_10' => _x('Oct', 'October abbreviation', 'ayecode-connect'),
2275
+				'month_s_11' => _x('Nov', 'November abbreviation', 'ayecode-connect'),
2276
+				'month_s_12' => _x('Dec', 'December abbreviation', 'ayecode-connect'),
2277
+				'day_s1_1' => _x('S', 'Sunday initial', 'ayecode-connect'),
2278
+				'day_s1_2' => _x('M', 'Monday initial', 'ayecode-connect'),
2279
+				'day_s1_3' => _x('T', 'Tuesday initial', 'ayecode-connect'),
2280
+				'day_s1_4' => _x('W', 'Wednesday initial', 'ayecode-connect'),
2281
+				'day_s1_5' => _x('T', 'Friday initial', 'ayecode-connect'),
2282
+				'day_s1_6' => _x('F', 'Thursday initial', 'ayecode-connect'),
2283
+				'day_s1_7' => _x('S', 'Saturday initial', 'ayecode-connect'),
2284
+				'day_s2_1' => __('Su', 'ayecode-connect'),
2285
+				'day_s2_2' => __('Mo', 'ayecode-connect'),
2286
+				'day_s2_3' => __('Tu', 'ayecode-connect'),
2287
+				'day_s2_4' => __('We', 'ayecode-connect'),
2288
+				'day_s2_5' => __('Th', 'ayecode-connect'),
2289
+				'day_s2_6' => __('Fr', 'ayecode-connect'),
2290
+				'day_s2_7' => __('Sa', 'ayecode-connect'),
2291
+				'day_s3_1' => __('Sun', 'ayecode-connect'),
2292
+				'day_s3_2' => __('Mon', 'ayecode-connect'),
2293
+				'day_s3_3' => __('Tue', 'ayecode-connect'),
2294
+				'day_s3_4' => __('Wed', 'ayecode-connect'),
2295
+				'day_s3_5' => __('Thu', 'ayecode-connect'),
2296
+				'day_s3_6' => __('Fri', 'ayecode-connect'),
2297
+				'day_s3_7' => __('Sat', 'ayecode-connect'),
2298
+				'day_s5_1' => __('Sunday', 'ayecode-connect'),
2299
+				'day_s5_2' => __('Monday', 'ayecode-connect'),
2300
+				'day_s5_3' => __('Tuesday', 'ayecode-connect'),
2301
+				'day_s5_4' => __('Wednesday', 'ayecode-connect'),
2302
+				'day_s5_5' => __('Thursday', 'ayecode-connect'),
2303
+				'day_s5_6' => __('Friday', 'ayecode-connect'),
2304
+				'day_s5_7' => __('Saturday', 'ayecode-connect'),
2305
+				'am_lower' => __('am', 'ayecode-connect'),
2306
+				'pm_lower' => __('pm', 'ayecode-connect'),
2307
+				'am_upper' => __('AM', 'ayecode-connect'),
2308
+				'pm_upper' => __('PM', 'ayecode-connect'),
2309
+				'firstDayOfWeek' => (int) get_option('start_of_week'),
2310 2310
 				'time_24hr' => false,
2311
-				'year' => __( 'Year', 'ayecode-connect' ),
2312
-				'hour' => __( 'Hour', 'ayecode-connect' ),
2313
-				'minute' => __( 'Minute', 'ayecode-connect' ),
2314
-				'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2315
-				'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2316
-				'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2317
-				'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2311
+				'year' => __('Year', 'ayecode-connect'),
2312
+				'hour' => __('Hour', 'ayecode-connect'),
2313
+				'minute' => __('Minute', 'ayecode-connect'),
2314
+				'weekAbbreviation' => __('Wk', 'ayecode-connect'),
2315
+				'rangeSeparator' => __(' to ', 'ayecode-connect'),
2316
+				'scrollTitle' => __('Scroll to increment', 'ayecode-connect'),
2317
+				'toggleTitle' => __('Click to toggle', 'ayecode-connect')
2318 2318
 			);
2319 2319
 
2320
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2320
+			return apply_filters('ayecode_ui_calendar_params', $params);
2321 2321
 		}
2322 2322
 
2323 2323
 		/**
@@ -2330,47 +2330,47 @@  discard block
 block discarded – undo
2330 2330
 		public static function flatpickr_locale() {
2331 2331
 			$params = self::calendar_params();
2332 2332
 
2333
-			if ( is_string( $params ) ) {
2334
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2333
+			if (is_string($params)) {
2334
+				$params = html_entity_decode($params, ENT_QUOTES, 'UTF-8');
2335 2335
 			} else {
2336
-				foreach ( (array) $params as $key => $value ) {
2337
-					if ( ! is_scalar( $value ) ) {
2336
+				foreach ((array) $params as $key => $value) {
2337
+					if (!is_scalar($value)) {
2338 2338
 						continue;
2339 2339
 					}
2340 2340
 
2341
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2341
+					$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2342 2342
 				}
2343 2343
 			}
2344 2344
 
2345 2345
 			$day_s3 = array();
2346 2346
 			$day_s5 = array();
2347 2347
 
2348
-			for ( $i = 1; $i <= 7; $i ++ ) {
2349
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2350
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2348
+			for ($i = 1; $i <= 7; $i++) {
2349
+				$day_s3[] = addslashes($params['day_s3_' . $i]);
2350
+				$day_s5[] = addslashes($params['day_s3_' . $i]);
2351 2351
 			}
2352 2352
 
2353 2353
 			$month_s = array();
2354 2354
 			$month_long = array();
2355 2355
 
2356
-			for ( $i = 1; $i <= 12; $i ++ ) {
2357
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2358
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2356
+			for ($i = 1; $i <= 12; $i++) {
2357
+				$month_s[] = addslashes($params['month_s_' . $i]);
2358
+				$month_long[] = addslashes($params['month_long_' . $i]);
2359 2359
 			}
2360 2360
 
2361 2361
 			ob_start();
2362
-		if ( 0 ) { ?><script><?php } ?>
2362
+		if (0) { ?><script><?php } ?>
2363 2363
                 {
2364 2364
                     weekdays: {
2365
-                        shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'],
2366
-                            longhand: ['<?php echo implode( "','", $day_s5 ); ?>'],
2365
+                        shorthand: ['<?php echo implode("','", $day_s3); ?>'],
2366
+                            longhand: ['<?php echo implode("','", $day_s5); ?>'],
2367 2367
                     },
2368 2368
                     months: {
2369
-                        shorthand: ['<?php echo implode( "','", $month_s ); ?>'],
2370
-                            longhand: ['<?php echo implode( "','", $month_long ); ?>'],
2369
+                        shorthand: ['<?php echo implode("','", $month_s); ?>'],
2370
+                            longhand: ['<?php echo implode("','", $month_long); ?>'],
2371 2371
                     },
2372 2372
                     daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31],
2373
-                        firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>,
2373
+                        firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>,
2374 2374
                     ordinal: function (nth) {
2375 2375
                         var s = nth % 100;
2376 2376
                         if (s > 3 && s < 21)
@@ -2386,21 +2386,21 @@  discard block
 block discarded – undo
2386 2386
                                 return "th";
2387 2387
                         }
2388 2388
                     },
2389
-                    rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>',
2390
-                        weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>',
2391
-                    scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>',
2392
-                    toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>',
2393
-                    amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'],
2394
-                    yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>',
2395
-                    hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>',
2396
-                    minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>',
2397
-                    time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?>
2389
+                    rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>',
2390
+                        weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>',
2391
+                    scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>',
2392
+                    toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>',
2393
+                    amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'],
2394
+                    yearAriaLabel: '<?php echo addslashes($params['year']); ?>',
2395
+                    hourAriaLabel: '<?php echo addslashes($params['hour']); ?>',
2396
+                    minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>',
2397
+                    time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?>
2398 2398
                 }
2399
-				<?php if ( 0 ) { ?></script><?php } ?>
2399
+				<?php if (0) { ?></script><?php } ?>
2400 2400
 			<?php
2401 2401
 			$locale = ob_get_clean();
2402 2402
 
2403
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2403
+			return apply_filters('ayecode_ui_flatpickr_locale', trim($locale));
2404 2404
 		}
2405 2405
 
2406 2406
 		/**
@@ -2412,20 +2412,20 @@  discard block
 block discarded – undo
2412 2412
 		 */
2413 2413
 		public static function select2_params() {
2414 2414
 			$params = array(
2415
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2416
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2417
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2418
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2419
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2420
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2421
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2422
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2423
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2424
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2425
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2415
+				'i18n_select_state_text'    => esc_attr__('Select an option&hellip;', 'ayecode-connect'),
2416
+				'i18n_no_matches'           => _x('No matches found', 'enhanced select', 'ayecode-connect'),
2417
+				'i18n_ajax_error'           => _x('Loading failed', 'enhanced select', 'ayecode-connect'),
2418
+				'i18n_input_too_short_1'    => _x('Please enter 1 or more characters', 'enhanced select', 'ayecode-connect'),
2419
+				'i18n_input_too_short_n'    => _x('Please enter %item% or more characters', 'enhanced select', 'ayecode-connect'),
2420
+				'i18n_input_too_long_1'     => _x('Please delete 1 character', 'enhanced select', 'ayecode-connect'),
2421
+				'i18n_input_too_long_n'     => _x('Please delete %item% characters', 'enhanced select', 'ayecode-connect'),
2422
+				'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'ayecode-connect'),
2423
+				'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'ayecode-connect'),
2424
+				'i18n_load_more'            => _x('Loading more results&hellip;', 'enhanced select', 'ayecode-connect'),
2425
+				'i18n_searching'            => _x('Searching&hellip;', 'enhanced select', 'ayecode-connect')
2426 2426
 			);
2427 2427
 
2428
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2428
+			return apply_filters('ayecode_ui_select2_params', $params);
2429 2429
 		}
2430 2430
 
2431 2431
 		/**
@@ -2438,17 +2438,17 @@  discard block
 block discarded – undo
2438 2438
 		public static function select2_locale() {
2439 2439
 			$params = self::select2_params();
2440 2440
 
2441
-			foreach ( (array) $params as $key => $value ) {
2442
-				if ( ! is_scalar( $value ) ) {
2441
+			foreach ((array) $params as $key => $value) {
2442
+				if (!is_scalar($value)) {
2443 2443
 					continue;
2444 2444
 				}
2445 2445
 
2446
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2446
+				$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2447 2447
 			}
2448 2448
 
2449
-			$locale = json_encode( $params );
2449
+			$locale = json_encode($params);
2450 2450
 
2451
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2451
+			return apply_filters('ayecode_ui_select2_locale', trim($locale));
2452 2452
 		}
2453 2453
 
2454 2454
 		/**
@@ -2461,35 +2461,35 @@  discard block
 block discarded – undo
2461 2461
 		public static function timeago_locale() {
2462 2462
 			$params = array(
2463 2463
 				'prefix_ago' => '',
2464
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2465
-				'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2464
+				'suffix_ago' => ' ' . _x('ago', 'time ago', 'ayecode-connect'),
2465
+				'prefix_after' => _x('after', 'time ago', 'ayecode-connect') . ' ',
2466 2466
 				'suffix_after' => '',
2467
-				'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2468
-				'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2469
-				'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2470
-				'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2471
-				'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2472
-				'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2473
-				'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2474
-				'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2475
-				'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2476
-				'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2477
-				'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2467
+				'seconds' => _x('less than a minute', 'time ago', 'ayecode-connect'),
2468
+				'minute' => _x('about a minute', 'time ago', 'ayecode-connect'),
2469
+				'minutes' => _x('%d minutes', 'time ago', 'ayecode-connect'),
2470
+				'hour' => _x('about an hour', 'time ago', 'ayecode-connect'),
2471
+				'hours' => _x('about %d hours', 'time ago', 'ayecode-connect'),
2472
+				'day' => _x('a day', 'time ago', 'ayecode-connect'),
2473
+				'days' => _x('%d days', 'time ago', 'ayecode-connect'),
2474
+				'month' => _x('about a month', 'time ago', 'ayecode-connect'),
2475
+				'months' => _x('%d months', 'time ago', 'ayecode-connect'),
2476
+				'year' => _x('about a year', 'time ago', 'ayecode-connect'),
2477
+				'years' => _x('%d years', 'time ago', 'ayecode-connect'),
2478 2478
 			);
2479 2479
 
2480
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2480
+			$params = apply_filters('ayecode_ui_timeago_params', $params);
2481 2481
 
2482
-			foreach ( (array) $params as $key => $value ) {
2483
-				if ( ! is_scalar( $value ) ) {
2482
+			foreach ((array) $params as $key => $value) {
2483
+				if (!is_scalar($value)) {
2484 2484
 					continue;
2485 2485
 				}
2486 2486
 
2487
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2487
+				$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2488 2488
 			}
2489 2489
 
2490
-			$locale = json_encode( $params );
2490
+			$locale = json_encode($params);
2491 2491
 
2492
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2492
+			return apply_filters('ayecode_ui_timeago_locale', trim($locale));
2493 2493
 		}
2494 2494
 
2495 2495
 		/**
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
 		 * @return mixed
2501 2501
 		 */
2502 2502
 		public static function minify_js($input) {
2503
-			if(trim($input) === "") return $input;
2503
+			if (trim($input) === "") return $input;
2504 2504
 			return preg_replace(
2505 2505
 				array(
2506 2506
 					// Remove comment(s)
@@ -2532,7 +2532,7 @@  discard block
 block discarded – undo
2532 2532
 		 * @return mixed
2533 2533
 		 */
2534 2534
 		public static function minify_css($input) {
2535
-			if(trim($input) === "") return $input;
2535
+			if (trim($input) === "") return $input;
2536 2536
 			return preg_replace(
2537 2537
 				array(
2538 2538
 					// Remove comment(s)
@@ -3098,12 +3098,12 @@  discard block
 block discarded – undo
3098 3098
                         });
3099 3099
                     }
3100 3100
                 }
3101
-				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
3101
+				<?php do_action('aui_conditional_fields_js', $this); ?>
3102 3102
             </script>
3103 3103
 			<?php
3104 3104
 			$output = ob_get_clean();
3105 3105
 
3106
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3106
+			return str_replace(array('<script>', '</script>'), '', self::minify_js($output));
3107 3107
 		}
3108 3108
 	}
3109 3109
 
Please login to merge, or discard this patch.