@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | |
20 | 20 | // Define constants. |
21 | 21 | if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
22 | + define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if ( ! defined( 'WPINV_VERSION' ) ) { |
26 | - define( 'WPINV_VERSION', '2.8.7' ); |
|
26 | + define( 'WPINV_VERSION', '2.8.7' ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | 30 | if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
31 | + require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
46 | - return $GLOBALS['invoicing']; |
|
46 | + return $GLOBALS['invoicing']; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -15,20 +15,20 @@ discard block |
||
15 | 15 | * @package GetPaid |
16 | 16 | */ |
17 | 17 | |
18 | -defined( 'ABSPATH' ) || exit; |
|
18 | +defined('ABSPATH') || exit; |
|
19 | 19 | |
20 | 20 | // Define constants. |
21 | -if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
22 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
21 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
22 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
23 | 23 | } |
24 | 24 | |
25 | -if ( ! defined( 'WPINV_VERSION' ) ) { |
|
26 | - define( 'WPINV_VERSION', '2.8.7' ); |
|
25 | +if (!defined('WPINV_VERSION')) { |
|
26 | + define('WPINV_VERSION', '2.8.7'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Include the main Invoicing class. |
30 | -if ( ! class_exists( 'WPInv_Plugin', false ) ) { |
|
31 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php'; |
|
30 | +if (!class_exists('WPInv_Plugin', false)) { |
|
31 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php'; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function getpaid() { |
41 | 41 | |
42 | - if ( empty( $GLOBALS['invoicing'] ) ) { |
|
42 | + if (empty($GLOBALS['invoicing'])) { |
|
43 | 43 | $GLOBALS['invoicing'] = new WPInv_Plugin(); |
44 | 44 | } |
45 | 45 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @since 2.0.8 |
53 | 53 | */ |
54 | 54 | function getpaid_deactivation_hook() { |
55 | - update_option( 'wpinv_flush_permalinks', 1 ); |
|
55 | + update_option('wpinv_flush_permalinks', 1); |
|
56 | 56 | } |
57 | -register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' ); |
|
57 | +register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook'); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @deprecated |
@@ -64,4 +64,4 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | // Kickstart the plugin. |
67 | -add_action( 'plugins_loaded', 'getpaid', -100 ); |
|
67 | +add_action('plugins_loaded', 'getpaid', -100); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
7 | - exit; |
|
7 | + exit; |
|
8 | 8 | } |
9 | 9 | add_ThickBox(); |
10 | 10 | ?> |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | <?php if ( $tabs ) { ?> |
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
19 | - } |
|
20 | - do_action( 'wpi_addons_tabs' ); |
|
21 | - ?> |
|
17 | + foreach ( $tabs as $name => $label ) { |
|
18 | + echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
19 | + } |
|
20 | + do_action( 'wpi_addons_tabs' ); |
|
21 | + ?> |
|
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ( $current_tab == 'membership' ) { |
|
27 | 27 | |
28 | - ?> |
|
28 | + ?> |
|
29 | 29 | |
30 | 30 | <div class="wpi-membership-tab-conatiner"> |
31 | 31 | <div class="membership-content"> |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | <h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2> |
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
41 | - ?> |
|
39 | + $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | + echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
41 | + ?> |
|
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | - $addon_obj = new WPInv_Admin_Addons(); |
|
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
55 | - } |
|
56 | - } |
|
57 | - ?> |
|
51 | + $addon_obj = new WPInv_Admin_Addons(); |
|
52 | + if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | + foreach ( $addons as $addon ) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
55 | + } |
|
56 | + } |
|
57 | + ?> |
|
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | <h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3> |
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
71 | - } |
|
72 | - } |
|
73 | - ?> |
|
68 | + if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | + foreach ( $addons as $addon ) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
71 | + } |
|
72 | + } |
|
73 | + ?> |
|
74 | 74 | </ul> |
75 | 75 | </div> |
76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > '; |
|
85 | - ?> |
|
84 | + echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > '; |
|
85 | + ?> |
|
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
88 | 88 | <p> |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > '; |
|
105 | - ?> |
|
104 | + echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > '; |
|
105 | + ?> |
|
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
108 | 108 | <p> |
@@ -126,26 +126,26 @@ discard block |
||
126 | 126 | </div> |
127 | 127 | </div> |
128 | 128 | <?php |
129 | - } else { |
|
130 | - $installed_plugins = get_plugins(); |
|
129 | + } else { |
|
130 | + $installed_plugins = get_plugins(); |
|
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
133 | - //print_r($addons); |
|
134 | - ?> |
|
132 | + if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
133 | + //print_r($addons); |
|
134 | + ?> |
|
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | 137 | foreach ( $addons as $addon ) : |
138 | 138 | if ( 965 == $addon->info->id ) { |
139 | 139 | continue;}// don't show quote add on |
140 | - ?> |
|
140 | + ?> |
|
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - wpi_help_tip( $addon->info->excerpt, false, false, true ); |
|
147 | - } |
|
148 | - echo esc_html( $addon->info->title ); |
|
145 | + if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | + wpi_help_tip( $addon->info->excerpt, false, false, true ); |
|
147 | + } |
|
148 | + echo esc_html( $addon->info->title ); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
@@ -156,40 +156,40 @@ discard block |
||
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
160 | - $addon->info->slug = 'getpaid-stripe-payments'; |
|
161 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
162 | - } |
|
159 | + if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
160 | + $addon->info->slug = 'getpaid-stripe-payments'; |
|
161 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
162 | + } |
|
163 | 163 | elseif( 'wallet' == $addon->info->slug ){ |
164 | - $addon->info->slug = 'getpaid-wallet'; |
|
165 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-wallet/'; |
|
166 | - } |
|
164 | + $addon->info->slug = 'getpaid-wallet'; |
|
165 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-wallet/'; |
|
166 | + } |
|
167 | 167 | elseif( 'item-inventory' == $addon->info->slug ){ |
168 | - $addon->info->slug = 'getpaid-item-inventory'; |
|
169 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-item-inventory/'; |
|
170 | - } |
|
171 | - |
|
172 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
173 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
174 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
175 | - echo '</a>'; |
|
176 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
177 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
178 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
179 | - } else { |
|
180 | - // if installed show activation link |
|
181 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
182 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
183 | - } else { |
|
184 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
185 | - } |
|
186 | - } |
|
187 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
188 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
189 | - echo '</a>'; |
|
190 | - } |
|
191 | - |
|
192 | - ?> |
|
168 | + $addon->info->slug = 'getpaid-item-inventory'; |
|
169 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-item-inventory/'; |
|
170 | + } |
|
171 | + |
|
172 | + if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
173 | + echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
174 | + echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
175 | + echo '</a>'; |
|
176 | + } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
177 | + if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
178 | + $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
179 | + } else { |
|
180 | + // if installed show activation link |
|
181 | + if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
182 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
183 | + } else { |
|
184 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
185 | + } |
|
186 | + } |
|
187 | + echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
188 | + echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
189 | + echo '</a>'; |
|
190 | + } |
|
191 | + |
|
192 | + ?> |
|
193 | 193 | |
194 | 194 | </span> |
195 | 195 | |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | <span class="wpi-product-button"> |
198 | 198 | <?php |
199 | 199 | $addon_obj->output_button( $addon ); |
200 | - ?> |
|
200 | + ?> |
|
201 | 201 | </span> |
202 | 202 | |
203 | 203 | <span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul> |
204 | 204 | <?php |
205 | 205 | endif; |
206 | - } |
|
206 | + } |
|
207 | 207 | } |
208 | - ?> |
|
208 | + ?> |
|
209 | 209 | |
210 | 210 | |
211 | 211 | <div class="clearfix" ></div> |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button> |
225 | 225 | <br> |
226 | 226 | <?php |
227 | - printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
228 | - ?> |
|
227 | + printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
228 | + ?> |
|
229 | 229 | </span> |
230 | 230 | </div> |
231 | 231 |
@@ -3,27 +3,27 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
10 | 10 | ?> |
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
12 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
13 | 13 | |
14 | - <?php if ( $tabs ) { ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . esc_url( admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . esc_html( $label ) . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . esc_url(admin_url('admin.php?page=wpi-addons&tab=' . $name)) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . esc_html($label) . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if ( $current_tab == 'membership' ) { |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { ?> |
|
36 | - <h2><?php esc_html_e( 'Have a membership key?', 'invoicing' ); ?></h2> |
|
35 | + <?php if (defined('WP_EASY_UPDATES_ACTIVE')) { ?> |
|
36 | + <h2><?php esc_html_e('Have a membership key?', 'invoicing'); ?></h2> |
|
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin( 'wpinvoicing.com', '1' ); |
|
40 | - echo $wpeu_admin->render_licence_actions( 'wpinvoicing.com', 'membership', array( 95, 106, 108, 12351 ) ); |
|
39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1'); |
|
40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351)); |
|
41 | 41 | ?> |
42 | 42 | </p> |
43 | 43 | <?php } ?> |
44 | 44 | |
45 | 45 | <div class="membership-cta-contet"> |
46 | 46 | <div class="main-cta"> |
47 | - <h2><?php esc_html_e( 'Membership benefits Include:', 'invoicing' ); ?></h2> |
|
47 | + <h2><?php esc_html_e('Membership benefits Include:', 'invoicing'); ?></h2> |
|
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | 51 | $addon_obj = new WPInv_Admin_Addons(); |
52 | - if ( $addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
52 | + if ($addons = $addon_obj->get_section_data('addons')) { |
|
53 | + foreach ($addons as $addon) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
61 | - <h3><?php esc_html_e( 'Membership Starts from', 'invoicing' ); ?></h3> |
|
61 | + <h3><?php esc_html_e('Membership Starts from', 'invoicing'); ?></h3> |
|
62 | 62 | <h4>$99</h4> |
63 | - <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
63 | + <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_attr_e('Buy Membership', 'invoicing'); ?></a> |
|
64 | 64 | </div> |
65 | - <h3><?php esc_html_e( 'Included Gateways:', 'invoicing' ); ?></h3> |
|
65 | + <h3><?php esc_html_e('Included Gateways:', 'invoicing'); ?></h3> |
|
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ( $addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html( $addon->info->title ) . '</li>'; |
|
68 | + if ($addons = $addon_obj->get_section_data('gateways')) { |
|
69 | + foreach ($addons as $addon) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image2.png', dirname( __FILE__ ) ) ) . '" > '; |
|
84 | + echo '<img src="' . esc_url(plugins_url('images/t-image2.png', dirname(__FILE__))) . '" > '; |
|
85 | 85 | ?> |
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . esc_url( plugins_url( 'images/t-image1.png', dirname( __FILE__ ) ) ) . '" > '; |
|
104 | + echo '<img src="' . esc_url(plugins_url('images/t-image1.png', dirname(__FILE__))) . '" > '; |
|
105 | 105 | ?> |
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | </div> |
118 | 118 | </div> |
119 | 119 | <div class="member-footer"> |
120 | - <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e( 'Buy Membership', 'invoicing' ); ?></a> |
|
121 | - <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e( 'Create Invoice', 'invoicing' ); ?></a> |
|
120 | + <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php esc_html_e('Buy Membership', 'invoicing'); ?></a> |
|
121 | + <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php esc_html_e('Create Invoice', 'invoicing'); ?></a> |
|
122 | 122 | </div> |
123 | 123 | </div> |
124 | 124 | |
@@ -129,63 +129,63 @@ discard block |
||
129 | 129 | } else { |
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ( $addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
132 | + if ($addons = $addon_obj->get_section_data($current_tab)) : |
|
133 | 133 | //print_r($addons); |
134 | 134 | ?> |
135 | 135 | <ul class="wpi-products"> |
136 | 136 | <?php |
137 | - foreach ( $addons as $addon ) : |
|
138 | - if ( 965 == $addon->info->id ) { |
|
139 | -continue;}// don't show quote add on |
|
137 | + foreach ($addons as $addon) : |
|
138 | + if (965 == $addon->info->id) { |
|
139 | +continue; }// don't show quote add on |
|
140 | 140 | ?> |
141 | 141 | <li class="wpi-product"> |
142 | 142 | <div class="wpi-product-title"> |
143 | 143 | <h3> |
144 | 144 | <?php |
145 | - if ( ! empty( $addon->info->excerpt ) ) { |
|
146 | - wpi_help_tip( $addon->info->excerpt, false, false, true ); |
|
145 | + if (!empty($addon->info->excerpt)) { |
|
146 | + wpi_help_tip($addon->info->excerpt, false, false, true); |
|
147 | 147 | } |
148 | - echo esc_html( $addon->info->title ); |
|
148 | + echo esc_html($addon->info->title); |
|
149 | 149 | ?> |
150 | 150 | </h3> |
151 | 151 | </div> |
152 | 152 | |
153 | 153 | <span class="wpi-product-image"> |
154 | - <?php if ( ! empty( $addon->info->thumbnail ) ) : ?> |
|
155 | - <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
|
154 | + <?php if (!empty($addon->info->thumbnail)) : ?> |
|
155 | + <img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/> |
|
156 | 156 | <?php |
157 | 157 | endif; |
158 | 158 | |
159 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
159 | + if ('stripe-payment-gateway' == $addon->info->slug) { |
|
160 | 160 | $addon->info->slug = 'getpaid-stripe-payments'; |
161 | 161 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
162 | 162 | } |
163 | - elseif( 'wallet' == $addon->info->slug ){ |
|
163 | + elseif ('wallet' == $addon->info->slug) { |
|
164 | 164 | $addon->info->slug = 'getpaid-wallet'; |
165 | 165 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-wallet/'; |
166 | 166 | } |
167 | - elseif( 'item-inventory' == $addon->info->slug ){ |
|
167 | + elseif ('item-inventory' == $addon->info->slug) { |
|
168 | 168 | $addon->info->slug = 'getpaid-item-inventory'; |
169 | 169 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-item-inventory/'; |
170 | 170 | } |
171 | 171 | |
172 | - if ( isset( $addon->info->link ) && substr( $addon->info->link, 0, 21 ) === 'https://wordpress.org' ) { |
|
173 | - echo '<a href="' . esc_url( admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug ) ) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
174 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
172 | + if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === 'https://wordpress.org') { |
|
173 | + echo '<a href="' . esc_url(admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug)) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
174 | + echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>'; |
|
175 | 175 | echo '</a>'; |
176 | - } elseif ( isset( $addon->info->link ) && ( substr( $addon->info->link, 0, 23 ) === 'https://wpinvoicing.com' || substr( $addon->info->link, 0, 21 ) === 'https://wpgetpaid.com' ) ) { |
|
177 | - if ( defined( 'WP_EASY_UPDATES_ACTIVE' ) ) { |
|
178 | - $url = admin_url( '/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true' ); |
|
176 | + } elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === 'https://wpinvoicing.com' || substr($addon->info->link, 0, 21) === 'https://wpgetpaid.com')) { |
|
177 | + if (defined('WP_EASY_UPDATES_ACTIVE')) { |
|
178 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
179 | 179 | } else { |
180 | 180 | // if installed show activation link |
181 | - if ( isset( $installed_plugins['wp-easy-updates/external-updates.php'] ) ) { |
|
181 | + if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) { |
|
182 | 182 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
183 | 183 | } else { |
184 | 184 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
185 | 185 | } |
186 | 186 | } |
187 | - echo '<a href="' . esc_url( $url ) . '" class="thickbox">'; |
|
188 | - echo '<span class="wpi-product-info">' . esc_html__( 'More info', 'invoicing' ) . '</span>'; |
|
187 | + echo '<a href="' . esc_url($url) . '" class="thickbox">'; |
|
188 | + echo '<span class="wpi-product-info">' . esc_html__('More info', 'invoicing') . '</span>'; |
|
189 | 189 | echo '</a>'; |
190 | 190 | } |
191 | 191 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | <span class="wpi-product-button"> |
198 | 198 | <?php |
199 | - $addon_obj->output_button( $addon ); |
|
199 | + $addon_obj->output_button($addon); |
|
200 | 200 | ?> |
201 | 201 | </span> |
202 | 202 | |
@@ -210,21 +210,21 @@ discard block |
||
210 | 210 | |
211 | 211 | <div class="clearfix" ></div> |
212 | 212 | |
213 | - <?php if ( $current_tab == 'addons' ) { ?> |
|
214 | - <p><?php printf( esc_attr__( 'All of our Addons can be found on wpGetPaid.com here: %sInvoicing Addons%s', 'invoicing' ), '<a href="https://wpinvoicing.com/downloads/category/addons/">','</a>' ); ?></p> |
|
215 | - <?php } if ( $current_tab == 'gateways' ) { ?> |
|
216 | - <p><?php printf( esc_attr__( 'All of our Payment Gateways can be found on wpGetPaid.com here: %sGetPaid Payment Gateways %s', 'invoicing' ), '<a href="https://wpinvoicing.com/downloads/category/gateways/">','</a>' ); ?></p> |
|
213 | + <?php if ($current_tab == 'addons') { ?> |
|
214 | + <p><?php printf(esc_attr__('All of our Addons can be found on wpGetPaid.com here: %sInvoicing Addons%s', 'invoicing'), '<a href="https://wpinvoicing.com/downloads/category/addons/">', '</a>'); ?></p> |
|
215 | + <?php } if ($current_tab == 'gateways') { ?> |
|
216 | + <p><?php printf(esc_attr__('All of our Payment Gateways can be found on wpGetPaid.com here: %sGetPaid Payment Gateways %s', 'invoicing'), '<a href="https://wpinvoicing.com/downloads/category/gateways/">', '</a>'); ?></p> |
|
217 | 217 | <?php } ?> |
218 | 218 | |
219 | - <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post( sprintf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing' ), wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php' ), 'activate-plugin_wp-easy-updates/external-updates.php' ) ) ); ?></span></div> |
|
220 | - <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post( sprintf( __( "The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing' ), admin_url( 'plugin-install.php?tab=upload&wpeu-install=true' ) ) ); ?></span></div> |
|
219 | + <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(sprintf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'))); ?></span></div> |
|
220 | + <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php echo wp_kses_post(sprintf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url('plugin-install.php?tab=upload&wpeu-install=true'))); ?></span></div> |
|
221 | 221 | <div id="wpeu-licence-popup" style="display:none;"> |
222 | 222 | <span class="wpi-notification noti-white"> |
223 | - <h3 class="wpeu-licence-title"><?php esc_html_e( 'Licence key', 'invoicing' ); ?></h3> |
|
224 | - <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e( 'Enter your licence key', 'invoicing' ); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e( 'Install', 'invoicing' ); ?></button> |
|
223 | + <h3 class="wpeu-licence-title"><?php esc_html_e('Licence key', 'invoicing'); ?></h3> |
|
224 | + <input class="wpeu-licence-key" type="text" placeholder="<?php esc_attr_e('Enter your licence key', 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php esc_html_e('Install', 'invoicing'); ?></button> |
|
225 | 225 | <br> |
226 | 226 | <?php |
227 | - printf( esc_html__( '%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing' ), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>' ); |
|
227 | + printf(esc_html__('%1$sFind your licence key here%2$s OR %3$sBuy one here%4$s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>'); |
|
228 | 228 | ?> |
229 | 229 | </span> |
230 | 230 | </div> |
@@ -159,12 +159,10 @@ |
||
159 | 159 | if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
160 | 160 | $addon->info->slug = 'getpaid-stripe-payments'; |
161 | 161 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
162 | - } |
|
163 | - elseif( 'wallet' == $addon->info->slug ){ |
|
162 | + } elseif( 'wallet' == $addon->info->slug ){ |
|
164 | 163 | $addon->info->slug = 'getpaid-wallet'; |
165 | 164 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-wallet/'; |
166 | - } |
|
167 | - elseif( 'item-inventory' == $addon->info->slug ){ |
|
165 | + } elseif( 'item-inventory' == $addon->info->slug ){ |
|
168 | 166 | $addon->info->slug = 'getpaid-item-inventory'; |
169 | 167 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-item-inventory/'; |
170 | 168 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; |
|
9 | + exit; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -15,94 +15,94 @@ discard block |
||
15 | 15 | class WPInv_Admin_Addons extends Ayecode_Addons { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Get the extensions page tabs. |
|
20 | - * |
|
21 | - * @return array of tabs. |
|
22 | - */ |
|
23 | - public function get_tabs() { |
|
24 | - $tabs = array( |
|
25 | - 'addons' => __( 'Addons', 'invoicing' ), |
|
18 | + /** |
|
19 | + * Get the extensions page tabs. |
|
20 | + * |
|
21 | + * @return array of tabs. |
|
22 | + */ |
|
23 | + public function get_tabs() { |
|
24 | + $tabs = array( |
|
25 | + 'addons' => __( 'Addons', 'invoicing' ), |
|
26 | 26 | 'gateways' => __( 'Payment Gateways', 'invoicing' ), |
27 | 27 | 'recommended_plugins' => __( 'Recommended plugins', 'invoicing' ), |
28 | 28 | 'membership' => __( 'Membership', 'invoicing' ), |
29 | - ); |
|
30 | - |
|
31 | - return $tabs; |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Get section content for the addons screen. |
|
36 | - * |
|
37 | - * @param string $section_id |
|
38 | - * |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - public function get_section_data( $section_id ) { |
|
42 | - $section = self::get_tab( $section_id ); |
|
43 | - $api_url = 'https://wpinvoicing.com/edd-api/v2/products/'; |
|
44 | - $section_data = new stdClass(); |
|
45 | - |
|
46 | - if ( $section_id == 'recommended_plugins' ) { |
|
47 | - $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
48 | - } elseif ( ! empty( $section ) ) { |
|
49 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
50 | - //if ( 1==1) { |
|
51 | - |
|
52 | - $query_args = array( |
|
53 | - 'category' => $section_id, |
|
54 | - 'number' => 100, |
|
55 | - ); |
|
56 | - $query_args = apply_filters( 'wpeu_edd_api_query_args', $query_args, $api_url, $section_id ); |
|
57 | - |
|
58 | - $raw_section = wp_safe_remote_get( |
|
29 | + ); |
|
30 | + |
|
31 | + return $tabs; |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Get section content for the addons screen. |
|
36 | + * |
|
37 | + * @param string $section_id |
|
38 | + * |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + public function get_section_data( $section_id ) { |
|
42 | + $section = self::get_tab( $section_id ); |
|
43 | + $api_url = 'https://wpinvoicing.com/edd-api/v2/products/'; |
|
44 | + $section_data = new stdClass(); |
|
45 | + |
|
46 | + if ( $section_id == 'recommended_plugins' ) { |
|
47 | + $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
48 | + } elseif ( ! empty( $section ) ) { |
|
49 | + if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
50 | + //if ( 1==1) { |
|
51 | + |
|
52 | + $query_args = array( |
|
53 | + 'category' => $section_id, |
|
54 | + 'number' => 100, |
|
55 | + ); |
|
56 | + $query_args = apply_filters( 'wpeu_edd_api_query_args', $query_args, $api_url, $section_id ); |
|
57 | + |
|
58 | + $raw_section = wp_safe_remote_get( |
|
59 | 59 | esc_url_raw( add_query_arg( $query_args, $api_url ) ), |
60 | 60 | array( |
61 | - 'user-agent' => 'Invoicing Addons Page', |
|
62 | - 'timeout' => 15, |
|
61 | + 'user-agent' => 'Invoicing Addons Page', |
|
62 | + 'timeout' => 15, |
|
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | |
66 | - if ( ! is_wp_error( $raw_section ) ) { |
|
67 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
66 | + if ( ! is_wp_error( $raw_section ) ) { |
|
67 | + $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
68 | 68 | |
69 | - if ( ! empty( $section_data->products ) ) { |
|
70 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
71 | - } |
|
72 | - } |
|
73 | - } |
|
69 | + if ( ! empty( $section_data->products ) ) { |
|
70 | + set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
71 | + } |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | |
76 | - $products = isset( $section_data->products ) ? $section_data->products : array(); |
|
77 | - if ( 'addons' == $section_id ) { |
|
78 | - |
|
79 | - $quotes = new stdClass(); |
|
80 | - $quotes->info = new stdClass(); |
|
81 | - $quotes->info->id = ''; |
|
82 | - $quotes->info->slug = 'invoicing-quotes'; |
|
83 | - $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
84 | - $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
85 | - $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
|
86 | - $quotes->info->thumbnail = WPINV_PLUGIN_URL . 'assets/images/Quotes-1-768x384.png'; |
|
87 | - |
|
88 | - $products[] = $quotes; |
|
89 | - } |
|
90 | - |
|
91 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Outputs a button. |
|
96 | - *ccc |
|
97 | - * @param string $url |
|
98 | - * @param string $text |
|
99 | - * @param string $theme |
|
100 | - * @param string $plugin |
|
101 | - */ |
|
102 | - public function output_button( $addon ) { |
|
76 | + $products = isset( $section_data->products ) ? $section_data->products : array(); |
|
77 | + if ( 'addons' == $section_id ) { |
|
78 | + |
|
79 | + $quotes = new stdClass(); |
|
80 | + $quotes->info = new stdClass(); |
|
81 | + $quotes->info->id = ''; |
|
82 | + $quotes->info->slug = 'invoicing-quotes'; |
|
83 | + $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
84 | + $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
85 | + $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
|
86 | + $quotes->info->thumbnail = WPINV_PLUGIN_URL . 'assets/images/Quotes-1-768x384.png'; |
|
87 | + |
|
88 | + $products[] = $quotes; |
|
89 | + } |
|
90 | + |
|
91 | + return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Outputs a button. |
|
96 | + *ccc |
|
97 | + * @param string $url |
|
98 | + * @param string $text |
|
99 | + * @param string $theme |
|
100 | + * @param string $plugin |
|
101 | + */ |
|
102 | + public function output_button( $addon ) { |
|
103 | 103 | |
104 | 104 | // print_r($addon); |
105 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
105 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
106 | 106 | // $button_text = __('Free','invoicing'); |
107 | 107 | // $licensing = false; |
108 | 108 | // $installed = false; |
@@ -114,128 +114,128 @@ discard block |
||
114 | 114 | // $install_status = 'get'; |
115 | 115 | // $onclick = ''; |
116 | 116 | |
117 | - $wp_org_themes = array( 'supreme-directory', 'directory-starter' ); |
|
118 | - |
|
119 | - $button_args = array( |
|
120 | - 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
|
121 | - 'id' => isset( $addon->info->id ) ? absint( $addon->info->id ) : '', |
|
122 | - 'title' => isset( $addon->info->title ) ? $addon->info->title : '', |
|
123 | - 'button_text' => __( 'Free', 'invoicing' ), |
|
124 | - 'price_text' => __( 'Free', 'invoicing' ), |
|
125 | - 'link' => isset( $addon->info->link ) ? $addon->info->link : '', // link to product |
|
126 | - 'url' => isset( $addon->info->link ) ? $addon->info->link : '', // button url |
|
127 | - 'class' => 'button-primary', |
|
128 | - 'install_status' => 'get', |
|
129 | - 'installed' => false, |
|
130 | - 'price' => '', |
|
131 | - 'licensing' => isset( $addon->licensing->enabled ) && $addon->licensing->enabled ? true : false, |
|
132 | - 'license' => isset( $addon->licensing->license ) && $addon->licensing->license ? $addon->licensing->license : '', |
|
133 | - 'onclick' => '', |
|
134 | - 'slug' => isset( $addon->info->slug ) ? $addon->info->slug : '', |
|
135 | - 'active' => false, |
|
136 | - 'file' => '', |
|
137 | - 'update_url' => '', |
|
138 | - ); |
|
139 | - |
|
140 | - if ( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset( $addon->info->slug ) && $addon->info->slug ) ) { |
|
141 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
142 | - $status = install_plugin_install_status( |
|
117 | + $wp_org_themes = array( 'supreme-directory', 'directory-starter' ); |
|
118 | + |
|
119 | + $button_args = array( |
|
120 | + 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
|
121 | + 'id' => isset( $addon->info->id ) ? absint( $addon->info->id ) : '', |
|
122 | + 'title' => isset( $addon->info->title ) ? $addon->info->title : '', |
|
123 | + 'button_text' => __( 'Free', 'invoicing' ), |
|
124 | + 'price_text' => __( 'Free', 'invoicing' ), |
|
125 | + 'link' => isset( $addon->info->link ) ? $addon->info->link : '', // link to product |
|
126 | + 'url' => isset( $addon->info->link ) ? $addon->info->link : '', // button url |
|
127 | + 'class' => 'button-primary', |
|
128 | + 'install_status' => 'get', |
|
129 | + 'installed' => false, |
|
130 | + 'price' => '', |
|
131 | + 'licensing' => isset( $addon->licensing->enabled ) && $addon->licensing->enabled ? true : false, |
|
132 | + 'license' => isset( $addon->licensing->license ) && $addon->licensing->license ? $addon->licensing->license : '', |
|
133 | + 'onclick' => '', |
|
134 | + 'slug' => isset( $addon->info->slug ) ? $addon->info->slug : '', |
|
135 | + 'active' => false, |
|
136 | + 'file' => '', |
|
137 | + 'update_url' => '', |
|
138 | + ); |
|
139 | + |
|
140 | + if ( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset( $addon->info->slug ) && $addon->info->slug ) ) { |
|
141 | + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
142 | + $status = install_plugin_install_status( |
|
143 | 143 | array( |
144 | - 'slug' => $button_args['slug'], |
|
145 | - 'version' => '', |
|
144 | + 'slug' => $button_args['slug'], |
|
145 | + 'version' => '', |
|
146 | 146 | ) |
147 | 147 | ); |
148 | - $button_args['install_status'] = isset( $status['status'] ) ? $status['status'] : 'install'; |
|
149 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
150 | - } elseif ( ($current_tab == 'addons' || $current_tab == 'gateways') && isset( $addon->info->id ) && $addon->info->id ) { |
|
151 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
152 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
148 | + $button_args['install_status'] = isset( $status['status'] ) ? $status['status'] : 'install'; |
|
149 | + $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
150 | + } elseif ( ($current_tab == 'addons' || $current_tab == 'gateways') && isset( $addon->info->id ) && $addon->info->id ) { |
|
151 | + include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
|
152 | + if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
153 | 153 | $button_args['slug'] = $addon->licensing->edd_slug;} |
154 | - $status = self::install_plugin_install_status( $addon ); |
|
155 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
156 | - if ( isset( $status['status'] ) ) { |
|
154 | + $status = self::install_plugin_install_status( $addon ); |
|
155 | + $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
156 | + if ( isset( $status['status'] ) ) { |
|
157 | 157 | $button_args['install_status'] = $status['status'];} |
158 | - $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
159 | - } elseif ( $current_tab == 'themes' && isset( $addon->info->id ) && $addon->info->id ) { |
|
160 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
158 | + $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
159 | + } elseif ( $current_tab == 'themes' && isset( $addon->info->id ) && $addon->info->id ) { |
|
160 | + if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
161 | 161 | $button_args['slug'] = $addon->licensing->edd_slug;} |
162 | - $button_args['installed'] = self::is_theme_installed( $addon ); |
|
163 | - if ( ! in_array( $button_args['slug'], $wp_org_themes ) ) { |
|
164 | - $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - // set price |
|
169 | - if ( isset( $addon->pricing ) && ! empty( $addon->pricing ) ) { |
|
170 | - if ( is_object( $addon->pricing ) ) { |
|
171 | - $prices = (array)$addon->pricing; |
|
172 | - $button_args['price'] = reset( $prices ); |
|
173 | - } elseif ( isset( $addon->pricing ) ) { |
|
174 | - $button_args['price'] = $addon->pricing; |
|
175 | - } |
|
176 | - } |
|
177 | - |
|
178 | - // set price text |
|
179 | - if ( $button_args['price'] && $button_args['price'] != '0.00' ) { |
|
180 | - $button_args['price_text'] = sprintf( __( 'From: $%d', 'invoicing' ), $button_args['price'] ); |
|
181 | - } |
|
182 | - |
|
183 | - // set if installed |
|
184 | - if ( in_array( $button_args['install_status'], array( 'installed', 'latest_installed', 'update_available', 'newer_installed' ) ) ) { |
|
185 | - $button_args['installed'] = true; |
|
186 | - } |
|
162 | + $button_args['installed'] = self::is_theme_installed( $addon ); |
|
163 | + if ( ! in_array( $button_args['slug'], $wp_org_themes ) ) { |
|
164 | + $button_args['update_url'] = 'https://wpinvoicing.com'; |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + // set price |
|
169 | + if ( isset( $addon->pricing ) && ! empty( $addon->pricing ) ) { |
|
170 | + if ( is_object( $addon->pricing ) ) { |
|
171 | + $prices = (array)$addon->pricing; |
|
172 | + $button_args['price'] = reset( $prices ); |
|
173 | + } elseif ( isset( $addon->pricing ) ) { |
|
174 | + $button_args['price'] = $addon->pricing; |
|
175 | + } |
|
176 | + } |
|
177 | + |
|
178 | + // set price text |
|
179 | + if ( $button_args['price'] && $button_args['price'] != '0.00' ) { |
|
180 | + $button_args['price_text'] = sprintf( __( 'From: $%d', 'invoicing' ), $button_args['price'] ); |
|
181 | + } |
|
182 | + |
|
183 | + // set if installed |
|
184 | + if ( in_array( $button_args['install_status'], array( 'installed', 'latest_installed', 'update_available', 'newer_installed' ) ) ) { |
|
185 | + $button_args['installed'] = true; |
|
186 | + } |
|
187 | 187 | |
188 | 188 | // print_r($button_args); |
189 | - // set if active |
|
190 | - if ( $button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes') ) { |
|
191 | - if ( $button_args['type'] != 'themes' ) { |
|
192 | - $button_args['active'] = is_plugin_active( $button_args['file'] ); |
|
193 | - } else { |
|
194 | - $button_args['active'] = self::is_theme_active( $addon ); |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - // set button text and class |
|
199 | - if ( $button_args['active'] ) { |
|
200 | - $button_args['button_text'] = __( 'Active', 'invoicing' ); |
|
201 | - $button_args['class'] = ' button-secondary disabled '; |
|
202 | - } elseif ( $button_args['installed'] ) { |
|
203 | - $button_args['button_text'] = __( 'Activate', 'invoicing' ); |
|
204 | - |
|
205 | - if ( $button_args['type'] != 'themes' ) { |
|
206 | - if ( current_user_can( 'manage_options' ) ) { |
|
207 | - $button_args['url'] = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $button_args['file'] ), 'activate-plugin_' . $button_args['file'] ); |
|
208 | - } else { |
|
209 | - $button_args['url'] = '#'; |
|
210 | - } |
|
211 | - } else { |
|
212 | - if ( current_user_can( 'switch_themes' ) ) { |
|
213 | - $button_args['url'] = self::get_theme_activation_url( $addon ); |
|
214 | - } else { |
|
215 | - $button_args['url'] = '#'; |
|
216 | - } |
|
217 | - } |
|
189 | + // set if active |
|
190 | + if ( $button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes') ) { |
|
191 | + if ( $button_args['type'] != 'themes' ) { |
|
192 | + $button_args['active'] = is_plugin_active( $button_args['file'] ); |
|
193 | + } else { |
|
194 | + $button_args['active'] = self::is_theme_active( $addon ); |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + // set button text and class |
|
199 | + if ( $button_args['active'] ) { |
|
200 | + $button_args['button_text'] = __( 'Active', 'invoicing' ); |
|
201 | + $button_args['class'] = ' button-secondary disabled '; |
|
202 | + } elseif ( $button_args['installed'] ) { |
|
203 | + $button_args['button_text'] = __( 'Activate', 'invoicing' ); |
|
204 | + |
|
205 | + if ( $button_args['type'] != 'themes' ) { |
|
206 | + if ( current_user_can( 'manage_options' ) ) { |
|
207 | + $button_args['url'] = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $button_args['file'] ), 'activate-plugin_' . $button_args['file'] ); |
|
208 | + } else { |
|
209 | + $button_args['url'] = '#'; |
|
210 | + } |
|
211 | + } else { |
|
212 | + if ( current_user_can( 'switch_themes' ) ) { |
|
213 | + $button_args['url'] = self::get_theme_activation_url( $addon ); |
|
214 | + } else { |
|
215 | + $button_args['url'] = '#'; |
|
216 | + } |
|
217 | + } |
|
218 | 218 | } else { |
219 | - if ( $button_args['type'] == 'recommended_plugins' ) { |
|
220 | - $button_args['button_text'] = __( 'Install', 'invoicing' ); |
|
221 | - } else { |
|
222 | - $button_args['button_text'] = __( 'Get it', 'invoicing' ); |
|
219 | + if ( $button_args['type'] == 'recommended_plugins' ) { |
|
220 | + $button_args['button_text'] = __( 'Install', 'invoicing' ); |
|
221 | + } else { |
|
222 | + $button_args['button_text'] = __( 'Get it', 'invoicing' ); |
|
223 | 223 | |
224 | - /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
224 | + /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
225 | 225 | $button_args['button_text'] = __('Install','invoicing'); |
226 | 226 | $button_args['url'] = self::get_theme_install_url($button_args['slug']); |
227 | 227 | $button_args['onclick'] = 'gd_set_button_installing(this);'; |
228 | 228 | }*/ |
229 | 229 | |
230 | - } |
|
231 | - } |
|
230 | + } |
|
231 | + } |
|
232 | 232 | |
233 | - // filter the button arguments |
|
234 | - $button_args = apply_filters( 'edd_api_button_args', $button_args ); |
|
233 | + // filter the button arguments |
|
234 | + $button_args = apply_filters( 'edd_api_button_args', $button_args ); |
|
235 | 235 | // print_r($button_args); |
236 | - // set price text |
|
237 | - if ( isset( $button_args['price_text'] ) ) { |
|
238 | - ?> |
|
236 | + // set price text |
|
237 | + if ( isset( $button_args['price_text'] ) ) { |
|
238 | + ?> |
|
239 | 239 | <a |
240 | 240 | target="_blank" |
241 | 241 | class="addons-price-text" |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | <?php echo esc_html( $button_args['price_text'] ); ?> |
244 | 244 | </a> |
245 | 245 | <?php |
246 | - } |
|
246 | + } |
|
247 | 247 | |
248 | - ?> |
|
248 | + ?> |
|
249 | 249 | <a |
250 | 250 | data-licence="<?php echo esc_attr( $button_args['license'] ); ?>" |
251 | 251 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>" |
@@ -269,33 +269,33 @@ discard block |
||
269 | 269 | </a> |
270 | 270 | <?php |
271 | 271 | |
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * Handles output of the addons page in admin. |
|
277 | - */ |
|
278 | - public function output() { |
|
279 | - $tabs = self::get_tabs(); |
|
280 | - $sections = self::get_sections(); |
|
281 | - $theme = wp_get_theme(); |
|
282 | - $section_keys = array_keys( $sections ); |
|
283 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
284 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
285 | - include_once WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'; |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * A list of recommended wp.org plugins. |
|
290 | - * @return array |
|
291 | - */ |
|
292 | - public function get_recommend_wp_plugins() { |
|
293 | - $plugins = array( |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * Handles output of the addons page in admin. |
|
277 | + */ |
|
278 | + public function output() { |
|
279 | + $tabs = self::get_tabs(); |
|
280 | + $sections = self::get_sections(); |
|
281 | + $theme = wp_get_theme(); |
|
282 | + $section_keys = array_keys( $sections ); |
|
283 | + $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
284 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
285 | + include_once WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'; |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * A list of recommended wp.org plugins. |
|
290 | + * @return array |
|
291 | + */ |
|
292 | + public function get_recommend_wp_plugins() { |
|
293 | + $plugins = array( |
|
294 | 294 | 'invoicing-quotes' => array( |
295 | 295 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
296 | 296 | 'slug' => 'invoicing-quotes', |
297 | - 'name' => 'Quotes', |
|
298 | - 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
|
297 | + 'name' => 'Quotes', |
|
298 | + 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
|
299 | 299 | 'desc' => __( 'Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing' ), |
300 | 300 | ), |
301 | 301 | 'geodirectory' => array( |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | 'name' => 'UsersWP', |
311 | 311 | 'desc' => __( 'Allow frontend user login and registration as well as have slick profile pages.', 'invoicing' ), |
312 | 312 | ), |
313 | - ); |
|
313 | + ); |
|
314 | 314 | |
315 | - return $plugins; |
|
316 | - } |
|
315 | + return $plugins; |
|
316 | + } |
|
317 | 317 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * All Invoicing extensions screen related functions can be found here. |
6 | 6 | * |
7 | 7 | */ |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function get_tabs() { |
24 | 24 | $tabs = array( |
25 | - 'addons' => __( 'Addons', 'invoicing' ), |
|
26 | - 'gateways' => __( 'Payment Gateways', 'invoicing' ), |
|
27 | - 'recommended_plugins' => __( 'Recommended plugins', 'invoicing' ), |
|
28 | - 'membership' => __( 'Membership', 'invoicing' ), |
|
25 | + 'addons' => __('Addons', 'invoicing'), |
|
26 | + 'gateways' => __('Payment Gateways', 'invoicing'), |
|
27 | + 'recommended_plugins' => __('Recommended plugins', 'invoicing'), |
|
28 | + 'membership' => __('Membership', 'invoicing'), |
|
29 | 29 | ); |
30 | 30 | |
31 | 31 | return $tabs; |
@@ -38,57 +38,57 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - public function get_section_data( $section_id ) { |
|
42 | - $section = self::get_tab( $section_id ); |
|
41 | + public function get_section_data($section_id) { |
|
42 | + $section = self::get_tab($section_id); |
|
43 | 43 | $api_url = 'https://wpinvoicing.com/edd-api/v2/products/'; |
44 | 44 | $section_data = new stdClass(); |
45 | 45 | |
46 | - if ( $section_id == 'recommended_plugins' ) { |
|
46 | + if ($section_id == 'recommended_plugins') { |
|
47 | 47 | $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
48 | - } elseif ( ! empty( $section ) ) { |
|
49 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
48 | + } elseif (!empty($section)) { |
|
49 | + if (false === ($section_data = get_transient('wpi_addons_section_' . $section_id))) { //@todo restore after testing |
|
50 | 50 | //if ( 1==1) { |
51 | 51 | |
52 | 52 | $query_args = array( |
53 | 53 | 'category' => $section_id, |
54 | 54 | 'number' => 100, |
55 | 55 | ); |
56 | - $query_args = apply_filters( 'wpeu_edd_api_query_args', $query_args, $api_url, $section_id ); |
|
56 | + $query_args = apply_filters('wpeu_edd_api_query_args', $query_args, $api_url, $section_id); |
|
57 | 57 | |
58 | 58 | $raw_section = wp_safe_remote_get( |
59 | - esc_url_raw( add_query_arg( $query_args, $api_url ) ), |
|
59 | + esc_url_raw(add_query_arg($query_args, $api_url)), |
|
60 | 60 | array( |
61 | 61 | 'user-agent' => 'Invoicing Addons Page', |
62 | 62 | 'timeout' => 15, |
63 | 63 | ) |
64 | 64 | ); |
65 | 65 | |
66 | - if ( ! is_wp_error( $raw_section ) ) { |
|
67 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
66 | + if (!is_wp_error($raw_section)) { |
|
67 | + $section_data = json_decode(wp_remote_retrieve_body($raw_section)); |
|
68 | 68 | |
69 | - if ( ! empty( $section_data->products ) ) { |
|
70 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
69 | + if (!empty($section_data->products)) { |
|
70 | + set_transient('wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - $products = isset( $section_data->products ) ? $section_data->products : array(); |
|
77 | - if ( 'addons' == $section_id ) { |
|
76 | + $products = isset($section_data->products) ? $section_data->products : array(); |
|
77 | + if ('addons' == $section_id) { |
|
78 | 78 | |
79 | 79 | $quotes = new stdClass(); |
80 | 80 | $quotes->info = new stdClass(); |
81 | 81 | $quotes->info->id = ''; |
82 | 82 | $quotes->info->slug = 'invoicing-quotes'; |
83 | - $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
84 | - $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
83 | + $quotes->info->title = __('Quotes', 'invoicing'); |
|
84 | + $quotes->info->excerpt = __('Create quotes and estimates', 'invoicing'); |
|
85 | 85 | $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
86 | 86 | $quotes->info->thumbnail = WPINV_PLUGIN_URL . 'assets/images/Quotes-1-768x384.png'; |
87 | 87 | |
88 | 88 | $products[] = $quotes; |
89 | 89 | } |
90 | 90 | |
91 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
91 | + return apply_filters('wpi_addons_section_data', $products, $section_id); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @param string $theme |
100 | 100 | * @param string $plugin |
101 | 101 | */ |
102 | - public function output_button( $addon ) { |
|
102 | + public function output_button($addon) { |
|
103 | 103 | |
104 | 104 | // print_r($addon); |
105 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
105 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
106 | 106 | // $button_text = __('Free','invoicing'); |
107 | 107 | // $licensing = false; |
108 | 108 | // $installed = false; |
@@ -114,30 +114,30 @@ discard block |
||
114 | 114 | // $install_status = 'get'; |
115 | 115 | // $onclick = ''; |
116 | 116 | |
117 | - $wp_org_themes = array( 'supreme-directory', 'directory-starter' ); |
|
117 | + $wp_org_themes = array('supreme-directory', 'directory-starter'); |
|
118 | 118 | |
119 | 119 | $button_args = array( |
120 | 120 | 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
121 | - 'id' => isset( $addon->info->id ) ? absint( $addon->info->id ) : '', |
|
122 | - 'title' => isset( $addon->info->title ) ? $addon->info->title : '', |
|
123 | - 'button_text' => __( 'Free', 'invoicing' ), |
|
124 | - 'price_text' => __( 'Free', 'invoicing' ), |
|
125 | - 'link' => isset( $addon->info->link ) ? $addon->info->link : '', // link to product |
|
126 | - 'url' => isset( $addon->info->link ) ? $addon->info->link : '', // button url |
|
121 | + 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
122 | + 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
123 | + 'button_text' => __('Free', 'invoicing'), |
|
124 | + 'price_text' => __('Free', 'invoicing'), |
|
125 | + 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
126 | + 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
127 | 127 | 'class' => 'button-primary', |
128 | 128 | 'install_status' => 'get', |
129 | 129 | 'installed' => false, |
130 | 130 | 'price' => '', |
131 | - 'licensing' => isset( $addon->licensing->enabled ) && $addon->licensing->enabled ? true : false, |
|
132 | - 'license' => isset( $addon->licensing->license ) && $addon->licensing->license ? $addon->licensing->license : '', |
|
131 | + 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
132 | + 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
133 | 133 | 'onclick' => '', |
134 | - 'slug' => isset( $addon->info->slug ) ? $addon->info->slug : '', |
|
134 | + 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
135 | 135 | 'active' => false, |
136 | 136 | 'file' => '', |
137 | 137 | 'update_url' => '', |
138 | 138 | ); |
139 | 139 | |
140 | - if ( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset( $addon->info->slug ) && $addon->info->slug ) ) { |
|
140 | + if ('invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug)) { |
|
141 | 141 | include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
142 | 142 | $status = install_plugin_install_status( |
143 | 143 | array( |
@@ -145,81 +145,81 @@ discard block |
||
145 | 145 | 'version' => '', |
146 | 146 | ) |
147 | 147 | ); |
148 | - $button_args['install_status'] = isset( $status['status'] ) ? $status['status'] : 'install'; |
|
149 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
150 | - } elseif ( ($current_tab == 'addons' || $current_tab == 'gateways') && isset( $addon->info->id ) && $addon->info->id ) { |
|
148 | + $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
149 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
150 | + } elseif (($current_tab == 'addons' || $current_tab == 'gateways') && isset($addon->info->id) && $addon->info->id) { |
|
151 | 151 | include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api.. |
152 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
153 | -$button_args['slug'] = $addon->licensing->edd_slug;} |
|
154 | - $status = self::install_plugin_install_status( $addon ); |
|
155 | - $button_args['file'] = isset( $status['file'] ) ? $status['file'] : ''; |
|
156 | - if ( isset( $status['status'] ) ) { |
|
157 | -$button_args['install_status'] = $status['status'];} |
|
152 | + if (!empty($addon->licensing->edd_slug)) { |
|
153 | +$button_args['slug'] = $addon->licensing->edd_slug; } |
|
154 | + $status = self::install_plugin_install_status($addon); |
|
155 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
156 | + if (isset($status['status'])) { |
|
157 | +$button_args['install_status'] = $status['status']; } |
|
158 | 158 | $button_args['update_url'] = 'https://wpinvoicing.com'; |
159 | - } elseif ( $current_tab == 'themes' && isset( $addon->info->id ) && $addon->info->id ) { |
|
160 | - if ( ! empty( $addon->licensing->edd_slug ) ) { |
|
161 | -$button_args['slug'] = $addon->licensing->edd_slug;} |
|
162 | - $button_args['installed'] = self::is_theme_installed( $addon ); |
|
163 | - if ( ! in_array( $button_args['slug'], $wp_org_themes ) ) { |
|
159 | + } elseif ($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
160 | + if (!empty($addon->licensing->edd_slug)) { |
|
161 | +$button_args['slug'] = $addon->licensing->edd_slug; } |
|
162 | + $button_args['installed'] = self::is_theme_installed($addon); |
|
163 | + if (!in_array($button_args['slug'], $wp_org_themes)) { |
|
164 | 164 | $button_args['update_url'] = 'https://wpinvoicing.com'; |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | // set price |
169 | - if ( isset( $addon->pricing ) && ! empty( $addon->pricing ) ) { |
|
170 | - if ( is_object( $addon->pricing ) ) { |
|
171 | - $prices = (array)$addon->pricing; |
|
172 | - $button_args['price'] = reset( $prices ); |
|
173 | - } elseif ( isset( $addon->pricing ) ) { |
|
169 | + if (isset($addon->pricing) && !empty($addon->pricing)) { |
|
170 | + if (is_object($addon->pricing)) { |
|
171 | + $prices = (array) $addon->pricing; |
|
172 | + $button_args['price'] = reset($prices); |
|
173 | + } elseif (isset($addon->pricing)) { |
|
174 | 174 | $button_args['price'] = $addon->pricing; |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | 178 | // set price text |
179 | - if ( $button_args['price'] && $button_args['price'] != '0.00' ) { |
|
180 | - $button_args['price_text'] = sprintf( __( 'From: $%d', 'invoicing' ), $button_args['price'] ); |
|
179 | + if ($button_args['price'] && $button_args['price'] != '0.00') { |
|
180 | + $button_args['price_text'] = sprintf(__('From: $%d', 'invoicing'), $button_args['price']); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | // set if installed |
184 | - if ( in_array( $button_args['install_status'], array( 'installed', 'latest_installed', 'update_available', 'newer_installed' ) ) ) { |
|
184 | + if (in_array($button_args['install_status'], array('installed', 'latest_installed', 'update_available', 'newer_installed'))) { |
|
185 | 185 | $button_args['installed'] = true; |
186 | 186 | } |
187 | 187 | |
188 | 188 | // print_r($button_args); |
189 | 189 | // set if active |
190 | - if ( $button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes') ) { |
|
191 | - if ( $button_args['type'] != 'themes' ) { |
|
192 | - $button_args['active'] = is_plugin_active( $button_args['file'] ); |
|
190 | + if ($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')) { |
|
191 | + if ($button_args['type'] != 'themes') { |
|
192 | + $button_args['active'] = is_plugin_active($button_args['file']); |
|
193 | 193 | } else { |
194 | - $button_args['active'] = self::is_theme_active( $addon ); |
|
194 | + $button_args['active'] = self::is_theme_active($addon); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | 198 | // set button text and class |
199 | - if ( $button_args['active'] ) { |
|
200 | - $button_args['button_text'] = __( 'Active', 'invoicing' ); |
|
199 | + if ($button_args['active']) { |
|
200 | + $button_args['button_text'] = __('Active', 'invoicing'); |
|
201 | 201 | $button_args['class'] = ' button-secondary disabled '; |
202 | - } elseif ( $button_args['installed'] ) { |
|
203 | - $button_args['button_text'] = __( 'Activate', 'invoicing' ); |
|
202 | + } elseif ($button_args['installed']) { |
|
203 | + $button_args['button_text'] = __('Activate', 'invoicing'); |
|
204 | 204 | |
205 | - if ( $button_args['type'] != 'themes' ) { |
|
206 | - if ( current_user_can( 'manage_options' ) ) { |
|
207 | - $button_args['url'] = wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $button_args['file'] ), 'activate-plugin_' . $button_args['file'] ); |
|
205 | + if ($button_args['type'] != 'themes') { |
|
206 | + if (current_user_can('manage_options')) { |
|
207 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
208 | 208 | } else { |
209 | 209 | $button_args['url'] = '#'; |
210 | 210 | } |
211 | 211 | } else { |
212 | - if ( current_user_can( 'switch_themes' ) ) { |
|
213 | - $button_args['url'] = self::get_theme_activation_url( $addon ); |
|
212 | + if (current_user_can('switch_themes')) { |
|
213 | + $button_args['url'] = self::get_theme_activation_url($addon); |
|
214 | 214 | } else { |
215 | 215 | $button_args['url'] = '#'; |
216 | 216 | } |
217 | 217 | } |
218 | 218 | } else { |
219 | - if ( $button_args['type'] == 'recommended_plugins' ) { |
|
220 | - $button_args['button_text'] = __( 'Install', 'invoicing' ); |
|
219 | + if ($button_args['type'] == 'recommended_plugins') { |
|
220 | + $button_args['button_text'] = __('Install', 'invoicing'); |
|
221 | 221 | } else { |
222 | - $button_args['button_text'] = __( 'Get it', 'invoicing' ); |
|
222 | + $button_args['button_text'] = __('Get it', 'invoicing'); |
|
223 | 223 | |
224 | 224 | /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
225 | 225 | $button_args['button_text'] = __('Install','invoicing'); |
@@ -231,41 +231,41 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | // filter the button arguments |
234 | - $button_args = apply_filters( 'edd_api_button_args', $button_args ); |
|
234 | + $button_args = apply_filters('edd_api_button_args', $button_args); |
|
235 | 235 | // print_r($button_args); |
236 | 236 | // set price text |
237 | - if ( isset( $button_args['price_text'] ) ) { |
|
237 | + if (isset($button_args['price_text'])) { |
|
238 | 238 | ?> |
239 | 239 | <a |
240 | 240 | target="_blank" |
241 | 241 | class="addons-price-text" |
242 | - href="<?php echo esc_url( $button_args['link'] ); ?>"> |
|
243 | - <?php echo esc_html( $button_args['price_text'] ); ?> |
|
242 | + href="<?php echo esc_url($button_args['link']); ?>"> |
|
243 | + <?php echo esc_html($button_args['price_text']); ?> |
|
244 | 244 | </a> |
245 | 245 | <?php |
246 | 246 | } |
247 | 247 | |
248 | 248 | ?> |
249 | 249 | <a |
250 | - data-licence="<?php echo esc_attr( $button_args['license'] ); ?>" |
|
250 | + data-licence="<?php echo esc_attr($button_args['license']); ?>" |
|
251 | 251 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>" |
252 | - data-title="<?php echo esc_attr( $button_args['title'] ); ?>" |
|
253 | - data-type="<?php echo esc_attr( $button_args['type'] ); ?>" |
|
254 | - data-text-error-message="<?php esc_attr_e( 'Something went wrong!', 'invoicing' ); ?>" |
|
255 | - data-text-activate="<?php esc_attr_e( 'Activate', 'invoicing' ); ?>" |
|
256 | - data-text-activating="<?php esc_attr_e( 'Activating', 'invoicing' ); ?>" |
|
257 | - data-text-deactivate="<?php esc_attr_e( 'Deactivate', 'invoicing' ); ?>" |
|
258 | - data-text-installed="<?php esc_attr_e( 'Installed', 'invoicing' ); ?>" |
|
259 | - data-text-install="<?php esc_attr_e( 'Install', 'invoicing' ); ?>" |
|
260 | - data-text-installing="<?php esc_attr_e( 'Installing', 'invoicing' ); ?>" |
|
261 | - data-text-error="<?php esc_attr_e( 'Error', 'invoicing' ); ?>" |
|
252 | + data-title="<?php echo esc_attr($button_args['title']); ?>" |
|
253 | + data-type="<?php echo esc_attr($button_args['type']); ?>" |
|
254 | + data-text-error-message="<?php esc_attr_e('Something went wrong!', 'invoicing'); ?>" |
|
255 | + data-text-activate="<?php esc_attr_e('Activate', 'invoicing'); ?>" |
|
256 | + data-text-activating="<?php esc_attr_e('Activating', 'invoicing'); ?>" |
|
257 | + data-text-deactivate="<?php esc_attr_e('Deactivate', 'invoicing'); ?>" |
|
258 | + data-text-installed="<?php esc_attr_e('Installed', 'invoicing'); ?>" |
|
259 | + data-text-install="<?php esc_attr_e('Install', 'invoicing'); ?>" |
|
260 | + data-text-installing="<?php esc_attr_e('Installing', 'invoicing'); ?>" |
|
261 | + data-text-error="<?php esc_attr_e('Error', 'invoicing'); ?>" |
|
262 | 262 | <?php |
263 | - if ( ! empty( $button_args['onclick'] ) ) { |
|
264 | -echo " onclick='" . esc_attr( $button_args['onclick'] ) . "' ";} |
|
263 | + if (!empty($button_args['onclick'])) { |
|
264 | +echo " onclick='" . esc_attr($button_args['onclick']) . "' "; } |
|
265 | 265 | ?> |
266 | - class="addons-button <?php echo esc_attr( $button_args['class'] ); ?>" |
|
267 | - href="<?php echo esc_url( $button_args['url'] ); ?>"> |
|
268 | - <?php echo esc_html( $button_args['button_text'] ); ?> |
|
266 | + class="addons-button <?php echo esc_attr($button_args['class']); ?>" |
|
267 | + href="<?php echo esc_url($button_args['url']); ?>"> |
|
268 | + <?php echo esc_html($button_args['button_text']); ?> |
|
269 | 269 | </a> |
270 | 270 | <?php |
271 | 271 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | $tabs = self::get_tabs(); |
280 | 280 | $sections = self::get_sections(); |
281 | 281 | $theme = wp_get_theme(); |
282 | - $section_keys = array_keys( $sections ); |
|
283 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
284 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
282 | + $section_keys = array_keys($sections); |
|
283 | + $current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys); |
|
284 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
285 | 285 | include_once WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'; |
286 | 286 | } |
287 | 287 | |
@@ -296,19 +296,19 @@ discard block |
||
296 | 296 | 'slug' => 'invoicing-quotes', |
297 | 297 | 'name' => 'Quotes', |
298 | 298 | 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
299 | - 'desc' => __( 'Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing' ), |
|
299 | + 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'), |
|
300 | 300 | ), |
301 | 301 | 'geodirectory' => array( |
302 | 302 | 'url' => 'https://wordpress.org/plugins/geodirectory/', |
303 | 303 | 'slug' => 'geodirectory', |
304 | 304 | 'name' => 'GeoDirectory', |
305 | - 'desc' => __( 'Turn any WordPress theme into a global business directory portal.', 'invoicing' ), |
|
305 | + 'desc' => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'), |
|
306 | 306 | ), |
307 | 307 | 'userswp' => array( |
308 | 308 | 'url' => 'https://wordpress.org/plugins/userswp/', |
309 | 309 | 'slug' => 'userswp', |
310 | 310 | 'name' => 'UsersWP', |
311 | - 'desc' => __( 'Allow frontend user login and registration as well as have slick profile pages.', 'invoicing' ), |
|
311 | + 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'), |
|
312 | 312 | ), |
313 | 313 | ); |
314 | 314 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; // Exit if accessed directly |
|
4 | + exit; // Exit if accessed directly |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -11,299 +11,299 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class AUI { |
13 | 13 | |
14 | - /** |
|
15 | - * Holds the class instance. |
|
16 | - * |
|
17 | - * @since 1.0.0 |
|
18 | - * @var null |
|
19 | - */ |
|
20 | - private static $instance = null; |
|
21 | - |
|
22 | - /** |
|
23 | - * Holds the current AUI version number. |
|
24 | - * |
|
25 | - * @var string $ver The current version number. |
|
26 | - */ |
|
27 | - public static $ver = '0.1.72'; |
|
28 | - |
|
29 | - public static $options = null; |
|
30 | - |
|
31 | - /** |
|
32 | - * There can be only one. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * @return AUI|null |
|
36 | - */ |
|
37 | - public static function instance() { |
|
38 | - if ( self::$instance == null ) { |
|
39 | - self::$instance = new AUI(); |
|
40 | - } |
|
41 | - |
|
42 | - return self::$instance; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * AUI constructor. |
|
47 | - * |
|
48 | - * @since 1.0.0 |
|
49 | - */ |
|
50 | - private function __construct() { |
|
51 | - if ( function_exists( "__autoload" ) ) { |
|
52 | - spl_autoload_register( "__autoload" ); |
|
53 | - } |
|
54 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
55 | - |
|
56 | - // load options |
|
57 | - self::$options = get_option('aui_options'); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Autoload any components on the fly. |
|
62 | - * |
|
63 | - * @since 1.0.0 |
|
64 | - * |
|
65 | - * @param $classname |
|
66 | - */ |
|
67 | - private function autoload( $classname ) { |
|
68 | - $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | - $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | - if ( $file_path && is_readable( $file_path ) ) { |
|
71 | - include_once( $file_path ); |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Get the AUI options. |
|
77 | - * |
|
78 | - * @param $option |
|
79 | - * |
|
80 | - * @return string|void |
|
81 | - */ |
|
82 | - public function get_option( $option ){ |
|
83 | - $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
84 | - |
|
85 | - if ( ! $result && $option) { |
|
86 | - if( $option == 'color_primary' ){ |
|
87 | - $result = AUI_PRIMARY_COLOR; |
|
88 | - }elseif( $option == 'color_secondary' ){ |
|
89 | - $result = AUI_SECONDARY_COLOR; |
|
90 | - } |
|
91 | - } |
|
92 | - return $result; |
|
93 | - } |
|
94 | - |
|
95 | - public function render( $items = array(), $echo = false ) { |
|
96 | - $output = ''; |
|
97 | - |
|
98 | - if ( ! empty( $items ) ) { |
|
99 | - foreach ( $items as $args ) { |
|
100 | - $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | - if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | - $output .= $this->$render( $args ); |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - if ( $echo ) { |
|
108 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
109 | - }else{ |
|
110 | - return $output; |
|
111 | - } |
|
112 | - |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Render and return a bootstrap alert component. |
|
117 | - * |
|
118 | - * @since 1.0.0 |
|
119 | - * |
|
120 | - * @param array $args The function arguments. |
|
121 | - * @param bool $echo If we should return or echo. |
|
122 | - * |
|
123 | - * @return string The rendered component. |
|
124 | - */ |
|
125 | - public function alert( $args = array(), $echo = false ) { |
|
126 | - $output = AUI_Component_Alert::get( $args ); |
|
127 | - |
|
128 | - if ( $echo ) { |
|
129 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
130 | - }else{ |
|
131 | - return $output; |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Render and return a bootstrap input component. |
|
137 | - * |
|
138 | - * @since 1.0.0 |
|
139 | - * |
|
140 | - * @param array $args The function arguments. |
|
141 | - * @param bool $echo If we should return or echo. |
|
142 | - * |
|
143 | - * @return string The rendered component. |
|
144 | - */ |
|
145 | - public function input( $args = array(), $echo = false ) { |
|
146 | - $output = AUI_Component_Input::input( $args ); |
|
147 | - |
|
148 | - if ( $echo ) { |
|
149 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
150 | - }else{ |
|
151 | - return $output; |
|
152 | - } |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Render and return a bootstrap textarea component. |
|
157 | - * |
|
158 | - * @since 1.0.0 |
|
159 | - * |
|
160 | - * @param array $args The function arguments. |
|
161 | - * @param bool $echo If we should return or echo. |
|
162 | - * |
|
163 | - * @return string The rendered component. |
|
164 | - */ |
|
165 | - public function textarea( $args = array(), $echo = false ) { |
|
166 | - $output = AUI_Component_Input::textarea( $args ); |
|
167 | - |
|
168 | - if ( $echo ) { |
|
169 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
170 | - }else{ |
|
171 | - return $output; |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Render and return a bootstrap button component. |
|
177 | - * |
|
178 | - * @since 1.0.0 |
|
179 | - * |
|
180 | - * @param array $args The function arguments. |
|
181 | - * @param bool $echo If we should return or echo. |
|
182 | - * |
|
183 | - * @return string The rendered component. |
|
184 | - */ |
|
185 | - public function button( $args = array(), $echo = false ) { |
|
186 | - $output = AUI_Component_Button::get( $args ); |
|
187 | - |
|
188 | - if ( $echo ) { |
|
189 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
190 | - }else{ |
|
191 | - return $output; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Render and return a bootstrap button component. |
|
197 | - * |
|
198 | - * @since 1.0.0 |
|
199 | - * |
|
200 | - * @param array $args The function arguments. |
|
201 | - * @param bool $echo If we should return or echo. |
|
202 | - * |
|
203 | - * @return string The rendered component. |
|
204 | - */ |
|
205 | - public function badge( $args = array(), $echo = false ) { |
|
206 | - $defaults = array( |
|
207 | - 'class' => 'badge badge-primary align-middle', |
|
208 | - ); |
|
209 | - |
|
210 | - // maybe set type. |
|
211 | - if ( empty( $args['href'] ) ) { |
|
212 | - $defaults['type'] = 'badge'; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Parse incoming $args into an array and merge it with $defaults |
|
217 | - */ |
|
218 | - $args = wp_parse_args( $args, $defaults ); |
|
219 | - |
|
220 | - $output = AUI_Component_Button::get( $args ); |
|
221 | - |
|
222 | - if ( $echo ) { |
|
223 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
224 | - }else{ |
|
225 | - return $output; |
|
226 | - } |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Render and return a bootstrap dropdown component. |
|
231 | - * |
|
232 | - * @since 1.0.0 |
|
233 | - * |
|
234 | - * @param array $args The function arguments. |
|
235 | - * @param bool $echo If we should return or echo. |
|
236 | - * |
|
237 | - * @return string The rendered component. |
|
238 | - */ |
|
239 | - public function dropdown( $args = array(), $echo = false ) { |
|
240 | - $output = AUI_Component_Dropdown::get( $args ); |
|
241 | - |
|
242 | - if ( $echo ) { |
|
243 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
244 | - }else{ |
|
245 | - return $output; |
|
246 | - } |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Render and return a bootstrap select component. |
|
251 | - * |
|
252 | - * @since 1.0.0 |
|
253 | - * |
|
254 | - * @param array $args The function arguments. |
|
255 | - * @param bool $echo If we should return or echo. |
|
256 | - * |
|
257 | - * @return string The rendered component. |
|
258 | - */ |
|
259 | - public function select( $args = array(), $echo = false ) { |
|
260 | - $output = AUI_Component_Input::select( $args ); |
|
261 | - |
|
262 | - if ( $echo ) { |
|
263 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
264 | - }else{ |
|
265 | - return $output; |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Render and return a bootstrap radio component. |
|
271 | - * |
|
272 | - * @since 1.0.0 |
|
273 | - * |
|
274 | - * @param array $args The function arguments. |
|
275 | - * @param bool $echo If we should return or echo. |
|
276 | - * |
|
277 | - * @return string The rendered component. |
|
278 | - */ |
|
279 | - public function radio( $args = array(), $echo = false ) { |
|
280 | - $output = AUI_Component_Input::radio( $args ); |
|
281 | - |
|
282 | - if ( $echo ) { |
|
283 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
284 | - }else{ |
|
285 | - return $output; |
|
286 | - } |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Render and return a bootstrap pagination component. |
|
291 | - * |
|
292 | - * @since 1.0.0 |
|
293 | - * |
|
294 | - * @param array $args The function arguments. |
|
295 | - * @param bool $echo If we should return or echo. |
|
296 | - * |
|
297 | - * @return string The rendered component. |
|
298 | - */ |
|
299 | - public function pagination( $args = array(), $echo = false ) { |
|
300 | - $output = AUI_Component_Pagination::get( $args ); |
|
301 | - |
|
302 | - if ( $echo ) { |
|
303 | - echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
304 | - }else{ |
|
305 | - return $output; |
|
306 | - } |
|
307 | - } |
|
14 | + /** |
|
15 | + * Holds the class instance. |
|
16 | + * |
|
17 | + * @since 1.0.0 |
|
18 | + * @var null |
|
19 | + */ |
|
20 | + private static $instance = null; |
|
21 | + |
|
22 | + /** |
|
23 | + * Holds the current AUI version number. |
|
24 | + * |
|
25 | + * @var string $ver The current version number. |
|
26 | + */ |
|
27 | + public static $ver = '0.1.72'; |
|
28 | + |
|
29 | + public static $options = null; |
|
30 | + |
|
31 | + /** |
|
32 | + * There can be only one. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * @return AUI|null |
|
36 | + */ |
|
37 | + public static function instance() { |
|
38 | + if ( self::$instance == null ) { |
|
39 | + self::$instance = new AUI(); |
|
40 | + } |
|
41 | + |
|
42 | + return self::$instance; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * AUI constructor. |
|
47 | + * |
|
48 | + * @since 1.0.0 |
|
49 | + */ |
|
50 | + private function __construct() { |
|
51 | + if ( function_exists( "__autoload" ) ) { |
|
52 | + spl_autoload_register( "__autoload" ); |
|
53 | + } |
|
54 | + spl_autoload_register( array( $this, 'autoload' ) ); |
|
55 | + |
|
56 | + // load options |
|
57 | + self::$options = get_option('aui_options'); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Autoload any components on the fly. |
|
62 | + * |
|
63 | + * @since 1.0.0 |
|
64 | + * |
|
65 | + * @param $classname |
|
66 | + */ |
|
67 | + private function autoload( $classname ) { |
|
68 | + $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | + $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | + if ( $file_path && is_readable( $file_path ) ) { |
|
71 | + include_once( $file_path ); |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Get the AUI options. |
|
77 | + * |
|
78 | + * @param $option |
|
79 | + * |
|
80 | + * @return string|void |
|
81 | + */ |
|
82 | + public function get_option( $option ){ |
|
83 | + $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
|
84 | + |
|
85 | + if ( ! $result && $option) { |
|
86 | + if( $option == 'color_primary' ){ |
|
87 | + $result = AUI_PRIMARY_COLOR; |
|
88 | + }elseif( $option == 'color_secondary' ){ |
|
89 | + $result = AUI_SECONDARY_COLOR; |
|
90 | + } |
|
91 | + } |
|
92 | + return $result; |
|
93 | + } |
|
94 | + |
|
95 | + public function render( $items = array(), $echo = false ) { |
|
96 | + $output = ''; |
|
97 | + |
|
98 | + if ( ! empty( $items ) ) { |
|
99 | + foreach ( $items as $args ) { |
|
100 | + $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | + if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | + $output .= $this->$render( $args ); |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + if ( $echo ) { |
|
108 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
109 | + }else{ |
|
110 | + return $output; |
|
111 | + } |
|
112 | + |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Render and return a bootstrap alert component. |
|
117 | + * |
|
118 | + * @since 1.0.0 |
|
119 | + * |
|
120 | + * @param array $args The function arguments. |
|
121 | + * @param bool $echo If we should return or echo. |
|
122 | + * |
|
123 | + * @return string The rendered component. |
|
124 | + */ |
|
125 | + public function alert( $args = array(), $echo = false ) { |
|
126 | + $output = AUI_Component_Alert::get( $args ); |
|
127 | + |
|
128 | + if ( $echo ) { |
|
129 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
130 | + }else{ |
|
131 | + return $output; |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Render and return a bootstrap input component. |
|
137 | + * |
|
138 | + * @since 1.0.0 |
|
139 | + * |
|
140 | + * @param array $args The function arguments. |
|
141 | + * @param bool $echo If we should return or echo. |
|
142 | + * |
|
143 | + * @return string The rendered component. |
|
144 | + */ |
|
145 | + public function input( $args = array(), $echo = false ) { |
|
146 | + $output = AUI_Component_Input::input( $args ); |
|
147 | + |
|
148 | + if ( $echo ) { |
|
149 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
150 | + }else{ |
|
151 | + return $output; |
|
152 | + } |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Render and return a bootstrap textarea component. |
|
157 | + * |
|
158 | + * @since 1.0.0 |
|
159 | + * |
|
160 | + * @param array $args The function arguments. |
|
161 | + * @param bool $echo If we should return or echo. |
|
162 | + * |
|
163 | + * @return string The rendered component. |
|
164 | + */ |
|
165 | + public function textarea( $args = array(), $echo = false ) { |
|
166 | + $output = AUI_Component_Input::textarea( $args ); |
|
167 | + |
|
168 | + if ( $echo ) { |
|
169 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
170 | + }else{ |
|
171 | + return $output; |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Render and return a bootstrap button component. |
|
177 | + * |
|
178 | + * @since 1.0.0 |
|
179 | + * |
|
180 | + * @param array $args The function arguments. |
|
181 | + * @param bool $echo If we should return or echo. |
|
182 | + * |
|
183 | + * @return string The rendered component. |
|
184 | + */ |
|
185 | + public function button( $args = array(), $echo = false ) { |
|
186 | + $output = AUI_Component_Button::get( $args ); |
|
187 | + |
|
188 | + if ( $echo ) { |
|
189 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
190 | + }else{ |
|
191 | + return $output; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Render and return a bootstrap button component. |
|
197 | + * |
|
198 | + * @since 1.0.0 |
|
199 | + * |
|
200 | + * @param array $args The function arguments. |
|
201 | + * @param bool $echo If we should return or echo. |
|
202 | + * |
|
203 | + * @return string The rendered component. |
|
204 | + */ |
|
205 | + public function badge( $args = array(), $echo = false ) { |
|
206 | + $defaults = array( |
|
207 | + 'class' => 'badge badge-primary align-middle', |
|
208 | + ); |
|
209 | + |
|
210 | + // maybe set type. |
|
211 | + if ( empty( $args['href'] ) ) { |
|
212 | + $defaults['type'] = 'badge'; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Parse incoming $args into an array and merge it with $defaults |
|
217 | + */ |
|
218 | + $args = wp_parse_args( $args, $defaults ); |
|
219 | + |
|
220 | + $output = AUI_Component_Button::get( $args ); |
|
221 | + |
|
222 | + if ( $echo ) { |
|
223 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
224 | + }else{ |
|
225 | + return $output; |
|
226 | + } |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * Render and return a bootstrap dropdown component. |
|
231 | + * |
|
232 | + * @since 1.0.0 |
|
233 | + * |
|
234 | + * @param array $args The function arguments. |
|
235 | + * @param bool $echo If we should return or echo. |
|
236 | + * |
|
237 | + * @return string The rendered component. |
|
238 | + */ |
|
239 | + public function dropdown( $args = array(), $echo = false ) { |
|
240 | + $output = AUI_Component_Dropdown::get( $args ); |
|
241 | + |
|
242 | + if ( $echo ) { |
|
243 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
244 | + }else{ |
|
245 | + return $output; |
|
246 | + } |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Render and return a bootstrap select component. |
|
251 | + * |
|
252 | + * @since 1.0.0 |
|
253 | + * |
|
254 | + * @param array $args The function arguments. |
|
255 | + * @param bool $echo If we should return or echo. |
|
256 | + * |
|
257 | + * @return string The rendered component. |
|
258 | + */ |
|
259 | + public function select( $args = array(), $echo = false ) { |
|
260 | + $output = AUI_Component_Input::select( $args ); |
|
261 | + |
|
262 | + if ( $echo ) { |
|
263 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
264 | + }else{ |
|
265 | + return $output; |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Render and return a bootstrap radio component. |
|
271 | + * |
|
272 | + * @since 1.0.0 |
|
273 | + * |
|
274 | + * @param array $args The function arguments. |
|
275 | + * @param bool $echo If we should return or echo. |
|
276 | + * |
|
277 | + * @return string The rendered component. |
|
278 | + */ |
|
279 | + public function radio( $args = array(), $echo = false ) { |
|
280 | + $output = AUI_Component_Input::radio( $args ); |
|
281 | + |
|
282 | + if ( $echo ) { |
|
283 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
284 | + }else{ |
|
285 | + return $output; |
|
286 | + } |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Render and return a bootstrap pagination component. |
|
291 | + * |
|
292 | + * @since 1.0.0 |
|
293 | + * |
|
294 | + * @param array $args The function arguments. |
|
295 | + * @param bool $echo If we should return or echo. |
|
296 | + * |
|
297 | + * @return string The rendered component. |
|
298 | + */ |
|
299 | + public function pagination( $args = array(), $echo = false ) { |
|
300 | + $output = AUI_Component_Pagination::get( $args ); |
|
301 | + |
|
302 | + if ( $echo ) { |
|
303 | + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
304 | + }else{ |
|
305 | + return $output; |
|
306 | + } |
|
307 | + } |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @return AUI|null |
36 | 36 | */ |
37 | 37 | public static function instance() { |
38 | - if ( self::$instance == null ) { |
|
38 | + if (self::$instance == null) { |
|
39 | 39 | self::$instance = new AUI(); |
40 | 40 | } |
41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | * @since 1.0.0 |
49 | 49 | */ |
50 | 50 | private function __construct() { |
51 | - if ( function_exists( "__autoload" ) ) { |
|
52 | - spl_autoload_register( "__autoload" ); |
|
51 | + if (function_exists("__autoload")) { |
|
52 | + spl_autoload_register("__autoload"); |
|
53 | 53 | } |
54 | - spl_autoload_register( array( $this, 'autoload' ) ); |
|
54 | + spl_autoload_register(array($this, 'autoload')); |
|
55 | 55 | |
56 | 56 | // load options |
57 | 57 | self::$options = get_option('aui_options'); |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param $classname |
66 | 66 | */ |
67 | - private function autoload( $classname ) { |
|
68 | - $class = str_replace( '_', '-', strtolower( $classname ) ); |
|
69 | - $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php'; |
|
70 | - if ( $file_path && is_readable( $file_path ) ) { |
|
71 | - include_once( $file_path ); |
|
67 | + private function autoload($classname) { |
|
68 | + $class = str_replace('_', '-', strtolower($classname)); |
|
69 | + $file_path = trailingslashit(dirname(__FILE__)) . "components/class-" . $class . '.php'; |
|
70 | + if ($file_path && is_readable($file_path)) { |
|
71 | + include_once($file_path); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -79,34 +79,34 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return string|void |
81 | 81 | */ |
82 | - public function get_option( $option ){ |
|
82 | + public function get_option($option) { |
|
83 | 83 | $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : ''; |
84 | 84 | |
85 | - if ( ! $result && $option) { |
|
86 | - if( $option == 'color_primary' ){ |
|
85 | + if (!$result && $option) { |
|
86 | + if ($option == 'color_primary') { |
|
87 | 87 | $result = AUI_PRIMARY_COLOR; |
88 | - }elseif( $option == 'color_secondary' ){ |
|
88 | + }elseif ($option == 'color_secondary') { |
|
89 | 89 | $result = AUI_SECONDARY_COLOR; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | return $result; |
93 | 93 | } |
94 | 94 | |
95 | - public function render( $items = array(), $echo = false ) { |
|
95 | + public function render($items = array(), $echo = false) { |
|
96 | 96 | $output = ''; |
97 | 97 | |
98 | - if ( ! empty( $items ) ) { |
|
99 | - foreach ( $items as $args ) { |
|
100 | - $render = isset( $args['render'] ) ? $args['render'] : ''; |
|
101 | - if ( $render && method_exists( __CLASS__, $render ) ) { |
|
102 | - $output .= $this->$render( $args ); |
|
98 | + if (!empty($items)) { |
|
99 | + foreach ($items as $args) { |
|
100 | + $render = isset($args['render']) ? $args['render'] : ''; |
|
101 | + if ($render && method_exists(__CLASS__, $render)) { |
|
102 | + $output .= $this->$render($args); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | - if ( $echo ) { |
|
107 | + if ($echo) { |
|
108 | 108 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
109 | - }else{ |
|
109 | + } else { |
|
110 | 110 | return $output; |
111 | 111 | } |
112 | 112 | |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return string The rendered component. |
124 | 124 | */ |
125 | - public function alert( $args = array(), $echo = false ) { |
|
126 | - $output = AUI_Component_Alert::get( $args ); |
|
125 | + public function alert($args = array(), $echo = false) { |
|
126 | + $output = AUI_Component_Alert::get($args); |
|
127 | 127 | |
128 | - if ( $echo ) { |
|
128 | + if ($echo) { |
|
129 | 129 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
130 | - }else{ |
|
130 | + } else { |
|
131 | 131 | return $output; |
132 | 132 | } |
133 | 133 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string The rendered component. |
144 | 144 | */ |
145 | - public function input( $args = array(), $echo = false ) { |
|
146 | - $output = AUI_Component_Input::input( $args ); |
|
145 | + public function input($args = array(), $echo = false) { |
|
146 | + $output = AUI_Component_Input::input($args); |
|
147 | 147 | |
148 | - if ( $echo ) { |
|
148 | + if ($echo) { |
|
149 | 149 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
150 | - }else{ |
|
150 | + } else { |
|
151 | 151 | return $output; |
152 | 152 | } |
153 | 153 | } |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string The rendered component. |
164 | 164 | */ |
165 | - public function textarea( $args = array(), $echo = false ) { |
|
166 | - $output = AUI_Component_Input::textarea( $args ); |
|
165 | + public function textarea($args = array(), $echo = false) { |
|
166 | + $output = AUI_Component_Input::textarea($args); |
|
167 | 167 | |
168 | - if ( $echo ) { |
|
168 | + if ($echo) { |
|
169 | 169 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
170 | - }else{ |
|
170 | + } else { |
|
171 | 171 | return $output; |
172 | 172 | } |
173 | 173 | } |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return string The rendered component. |
184 | 184 | */ |
185 | - public function button( $args = array(), $echo = false ) { |
|
186 | - $output = AUI_Component_Button::get( $args ); |
|
185 | + public function button($args = array(), $echo = false) { |
|
186 | + $output = AUI_Component_Button::get($args); |
|
187 | 187 | |
188 | - if ( $echo ) { |
|
188 | + if ($echo) { |
|
189 | 189 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | return $output; |
192 | 192 | } |
193 | 193 | } |
@@ -202,26 +202,26 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return string The rendered component. |
204 | 204 | */ |
205 | - public function badge( $args = array(), $echo = false ) { |
|
205 | + public function badge($args = array(), $echo = false) { |
|
206 | 206 | $defaults = array( |
207 | 207 | 'class' => 'badge badge-primary align-middle', |
208 | 208 | ); |
209 | 209 | |
210 | 210 | // maybe set type. |
211 | - if ( empty( $args['href'] ) ) { |
|
211 | + if (empty($args['href'])) { |
|
212 | 212 | $defaults['type'] = 'badge'; |
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
216 | 216 | * Parse incoming $args into an array and merge it with $defaults |
217 | 217 | */ |
218 | - $args = wp_parse_args( $args, $defaults ); |
|
218 | + $args = wp_parse_args($args, $defaults); |
|
219 | 219 | |
220 | - $output = AUI_Component_Button::get( $args ); |
|
220 | + $output = AUI_Component_Button::get($args); |
|
221 | 221 | |
222 | - if ( $echo ) { |
|
222 | + if ($echo) { |
|
223 | 223 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
224 | - }else{ |
|
224 | + } else { |
|
225 | 225 | return $output; |
226 | 226 | } |
227 | 227 | } |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return string The rendered component. |
238 | 238 | */ |
239 | - public function dropdown( $args = array(), $echo = false ) { |
|
240 | - $output = AUI_Component_Dropdown::get( $args ); |
|
239 | + public function dropdown($args = array(), $echo = false) { |
|
240 | + $output = AUI_Component_Dropdown::get($args); |
|
241 | 241 | |
242 | - if ( $echo ) { |
|
242 | + if ($echo) { |
|
243 | 243 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
244 | - }else{ |
|
244 | + } else { |
|
245 | 245 | return $output; |
246 | 246 | } |
247 | 247 | } |
@@ -256,12 +256,12 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return string The rendered component. |
258 | 258 | */ |
259 | - public function select( $args = array(), $echo = false ) { |
|
260 | - $output = AUI_Component_Input::select( $args ); |
|
259 | + public function select($args = array(), $echo = false) { |
|
260 | + $output = AUI_Component_Input::select($args); |
|
261 | 261 | |
262 | - if ( $echo ) { |
|
262 | + if ($echo) { |
|
263 | 263 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
264 | - }else{ |
|
264 | + } else { |
|
265 | 265 | return $output; |
266 | 266 | } |
267 | 267 | } |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return string The rendered component. |
278 | 278 | */ |
279 | - public function radio( $args = array(), $echo = false ) { |
|
280 | - $output = AUI_Component_Input::radio( $args ); |
|
279 | + public function radio($args = array(), $echo = false) { |
|
280 | + $output = AUI_Component_Input::radio($args); |
|
281 | 281 | |
282 | - if ( $echo ) { |
|
282 | + if ($echo) { |
|
283 | 283 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
284 | - }else{ |
|
284 | + } else { |
|
285 | 285 | return $output; |
286 | 286 | } |
287 | 287 | } |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return string The rendered component. |
298 | 298 | */ |
299 | - public function pagination( $args = array(), $echo = false ) { |
|
300 | - $output = AUI_Component_Pagination::get( $args ); |
|
299 | + public function pagination($args = array(), $echo = false) { |
|
300 | + $output = AUI_Component_Pagination::get($args); |
|
301 | 301 | |
302 | - if ( $echo ) { |
|
302 | + if ($echo) { |
|
303 | 303 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
304 | - }else{ |
|
304 | + } else { |
|
305 | 305 | return $output; |
306 | 306 | } |
307 | 307 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | if ( ! $result && $option) { |
86 | 86 | if( $option == 'color_primary' ){ |
87 | 87 | $result = AUI_PRIMARY_COLOR; |
88 | - }elseif( $option == 'color_secondary' ){ |
|
88 | + } elseif( $option == 'color_secondary' ){ |
|
89 | 89 | $result = AUI_SECONDARY_COLOR; |
90 | 90 | } |
91 | 91 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | if ( $echo ) { |
108 | 108 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
109 | - }else{ |
|
109 | + } else{ |
|
110 | 110 | return $output; |
111 | 111 | } |
112 | 112 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | if ( $echo ) { |
129 | 129 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
130 | - }else{ |
|
130 | + } else{ |
|
131 | 131 | return $output; |
132 | 132 | } |
133 | 133 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | if ( $echo ) { |
149 | 149 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
150 | - }else{ |
|
150 | + } else{ |
|
151 | 151 | return $output; |
152 | 152 | } |
153 | 153 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | if ( $echo ) { |
169 | 169 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
170 | - }else{ |
|
170 | + } else{ |
|
171 | 171 | return $output; |
172 | 172 | } |
173 | 173 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | |
188 | 188 | if ( $echo ) { |
189 | 189 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
190 | - }else{ |
|
190 | + } else{ |
|
191 | 191 | return $output; |
192 | 192 | } |
193 | 193 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | if ( $echo ) { |
223 | 223 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
224 | - }else{ |
|
224 | + } else{ |
|
225 | 225 | return $output; |
226 | 226 | } |
227 | 227 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | if ( $echo ) { |
243 | 243 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
244 | - }else{ |
|
244 | + } else{ |
|
245 | 245 | return $output; |
246 | 246 | } |
247 | 247 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | if ( $echo ) { |
263 | 263 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
264 | - }else{ |
|
264 | + } else{ |
|
265 | 265 | return $output; |
266 | 266 | } |
267 | 267 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | if ( $echo ) { |
283 | 283 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
284 | - }else{ |
|
284 | + } else{ |
|
285 | 285 | return $output; |
286 | 286 | } |
287 | 287 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | if ( $echo ) { |
303 | 303 | echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
304 | - }else{ |
|
304 | + } else{ |
|
305 | 305 | return $output; |
306 | 306 | } |
307 | 307 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | function aui_init_flatpickr(){ |
253 | 253 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
254 | 254 | $aui_doing_init_flatpickr = true; |
255 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
255 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
256 | 256 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
257 | 257 | } |
258 | 258 | $aui_doing_init_flatpickr = false; |
@@ -1013,7 +1013,7 @@ discard block |
||
1013 | 1013 | |
1014 | 1014 | <?php |
1015 | 1015 | // FSE tweaks. |
1016 | - if(!empty($_REQUEST['postType'])){ ?> |
|
1016 | + if (!empty($_REQUEST['postType'])) { ?> |
|
1017 | 1017 | function aui_fse_set_data_scroll() { |
1018 | 1018 | console.log('init scroll'); |
1019 | 1019 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | function aui_init_flatpickr(){ |
243 | 243 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
244 | 244 | $aui_doing_init_flatpickr = true; |
245 | - <?php if ( ! empty( $flatpickr_locale ) ) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
245 | + <?php if (!empty($flatpickr_locale)) { ?>try{flatpickr.localize(<?php echo $flatpickr_locale; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>);}catch(err){console.log(err.message);}<?php } ?> |
|
246 | 246 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
247 | 247 | } |
248 | 248 | $aui_doing_init_flatpickr = false; |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | |
972 | 972 | <?php |
973 | 973 | // FSE tweaks. |
974 | - if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?> |
|
974 | + if (!empty($_REQUEST['postType']) && $_REQUEST['postType'] == 'wp_template') { ?> |
|
975 | 975 | function aui_fse_set_data_scroll() { |
976 | 976 | console.log('init scroll'); |
977 | 977 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
@@ -13,7 +13,7 @@ discard block |
||
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 |
||
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.9'; |
|
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.9'; |
|
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>'. wp_kses_post( $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>'. wp_kses_post( $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 |
||
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 |
||
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 |
||
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 ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
804 | 807 | |
805 | - // Execute the query |
|
806 | - $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
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>'. wp_kses_post( $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>'. wp_kses_post( $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( esc_attr__( '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( esc_attr__( '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 esc_attr( $this->name ); ?></h1> |
886 | 886 | <p><?php echo esc_html( 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 esc_html_e( 'BootStrap Version', 'ayecode-connect' ); ?></h2> |
894 | 894 | <p><?php echo esc_html( 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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
898 | - 'type'=> 'info', |
|
899 | - 'content'=> esc_attr__("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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
898 | + 'type'=> 'info', |
|
899 | + 'content'=> esc_attr__("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 |
||
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 esc_html( $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 |
||
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(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1133 | - } |
|
1130 | + // BS v3 compat |
|
1131 | + if( self::is_bs3_compat() ){ |
|
1132 | + echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
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 |
||
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); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
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); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
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 |
||
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 |
||
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,189 +1249,189 @@ discard block |
||
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 esc_attr( $bep . $hn ) . '{'.esc_attr( $h_css ).'}'; |
1266 | - } |
|
1266 | + } |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | } |
1270 | - ?> |
|
1270 | + ?> |
|
1271 | 1271 | </style> |
1272 | 1272 | <?php |
1273 | 1273 | |
1274 | 1274 | |
1275 | - /* |
|
1275 | + /* |
|
1276 | 1276 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1277 | 1277 | */ |
1278 | - return str_replace( array( |
|
1279 | - '<style>', |
|
1280 | - '</style>' |
|
1281 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1282 | - } |
|
1283 | - |
|
1284 | - |
|
1285 | - |
|
1286 | - /** |
|
1287 | - * Check if we should add booststrap 3 compatibility changes. |
|
1288 | - * |
|
1289 | - * @return bool |
|
1290 | - */ |
|
1291 | - public static function is_bs3_compat(){ |
|
1292 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1293 | - } |
|
1294 | - |
|
1295 | - public static function hex_to_rgb($hex) { |
|
1296 | - // Remove '#' if present |
|
1297 | - $hex = str_replace('#', '', $hex); |
|
1298 | - |
|
1299 | - // Convert 3-digit hex to 6-digit hex |
|
1300 | - if(strlen($hex) == 3) { |
|
1301 | - $hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2); |
|
1302 | - } |
|
1303 | - |
|
1304 | - // Convert hex to RGB |
|
1305 | - $r = hexdec(substr($hex, 0, 2)); |
|
1306 | - $g = hexdec(substr($hex, 2, 2)); |
|
1307 | - $b = hexdec(substr($hex, 4, 2)); |
|
1308 | - |
|
1309 | - // Return RGB values as an array |
|
1310 | - return $r . ',' . $g . ',' . $b; |
|
1311 | - } |
|
1312 | - |
|
1313 | - /** |
|
1314 | - * Build the CSS to overwrite a bootstrap color variable. |
|
1315 | - * |
|
1316 | - * @param $type |
|
1317 | - * @param $color_code |
|
1318 | - * @param $compatibility |
|
1319 | - * |
|
1320 | - * @return string |
|
1321 | - */ |
|
1322 | - public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
1323 | - global $aui_bs5; |
|
1324 | - |
|
1325 | - $is_var = false; |
|
1326 | - $is_custom = strpos($type, 'custom-') !== false ? true : false; |
|
1327 | - if(!$color_code){return '';} |
|
1328 | - if(strpos($color_code, 'var') !== false){ |
|
1329 | - //if(!sanitize_hex_color($color_code)){ |
|
1330 | - $color_code = esc_attr($color_code); |
|
1331 | - $is_var = true; |
|
1278 | + return str_replace( array( |
|
1279 | + '<style>', |
|
1280 | + '</style>' |
|
1281 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1282 | + } |
|
1283 | + |
|
1284 | + |
|
1285 | + |
|
1286 | + /** |
|
1287 | + * Check if we should add booststrap 3 compatibility changes. |
|
1288 | + * |
|
1289 | + * @return bool |
|
1290 | + */ |
|
1291 | + public static function is_bs3_compat(){ |
|
1292 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1293 | + } |
|
1294 | + |
|
1295 | + public static function hex_to_rgb($hex) { |
|
1296 | + // Remove '#' if present |
|
1297 | + $hex = str_replace('#', '', $hex); |
|
1298 | + |
|
1299 | + // Convert 3-digit hex to 6-digit hex |
|
1300 | + if(strlen($hex) == 3) { |
|
1301 | + $hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2); |
|
1302 | + } |
|
1303 | + |
|
1304 | + // Convert hex to RGB |
|
1305 | + $r = hexdec(substr($hex, 0, 2)); |
|
1306 | + $g = hexdec(substr($hex, 2, 2)); |
|
1307 | + $b = hexdec(substr($hex, 4, 2)); |
|
1308 | + |
|
1309 | + // Return RGB values as an array |
|
1310 | + return $r . ',' . $g . ',' . $b; |
|
1311 | + } |
|
1312 | + |
|
1313 | + /** |
|
1314 | + * Build the CSS to overwrite a bootstrap color variable. |
|
1315 | + * |
|
1316 | + * @param $type |
|
1317 | + * @param $color_code |
|
1318 | + * @param $compatibility |
|
1319 | + * |
|
1320 | + * @return string |
|
1321 | + */ |
|
1322 | + public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
1323 | + global $aui_bs5; |
|
1324 | + |
|
1325 | + $is_var = false; |
|
1326 | + $is_custom = strpos($type, 'custom-') !== false ? true : false; |
|
1327 | + if(!$color_code){return '';} |
|
1328 | + if(strpos($color_code, 'var') !== false){ |
|
1329 | + //if(!sanitize_hex_color($color_code)){ |
|
1330 | + $color_code = esc_attr($color_code); |
|
1331 | + $is_var = true; |
|
1332 | 1332 | // $color_code = "rgba($color_code, 0.5)"; |
1333 | 1333 | // echo '###1'.$color_code.'###';//exit; |
1334 | - } |
|
1334 | + } |
|
1335 | 1335 | |
1336 | 1336 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
1337 | 1337 | |
1338 | - if(!$color_code){return '';} |
|
1338 | + if(!$color_code){return '';} |
|
1339 | 1339 | |
1340 | - $rgb = self::hex_to_rgb($hex); |
|
1340 | + $rgb = self::hex_to_rgb($hex); |
|
1341 | 1341 | |
1342 | - if($compatibility===true || $compatibility===1){ |
|
1343 | - $compatibility = '.bsui'; |
|
1344 | - }elseif(!$compatibility){ |
|
1345 | - $compatibility = ''; |
|
1346 | - }else{ |
|
1347 | - $compatibility = esc_attr($compatibility); |
|
1348 | - } |
|
1342 | + if($compatibility===true || $compatibility===1){ |
|
1343 | + $compatibility = '.bsui'; |
|
1344 | + }elseif(!$compatibility){ |
|
1345 | + $compatibility = ''; |
|
1346 | + }else{ |
|
1347 | + $compatibility = esc_attr($compatibility); |
|
1348 | + } |
|
1349 | 1349 | |
1350 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
1350 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
1351 | 1351 | |
1352 | 1352 | |
1353 | 1353 | $output = ''; |
1354 | 1354 | |
1355 | 1355 | // echo '####'.$color_code;exit; |
1356 | 1356 | |
1357 | - $type = sanitize_html_class($type); |
|
1357 | + $type = sanitize_html_class($type); |
|
1358 | + |
|
1359 | + /** |
|
1360 | + * c = color, b = background color, o = border-color, f = fill |
|
1361 | + */ |
|
1362 | + $selectors = array( |
|
1363 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
1364 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1365 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1366 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1367 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1368 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1369 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1370 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1371 | + ".badge-{$type}" => array( 'b' ), |
|
1372 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
1373 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
1374 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
1375 | + ".text-{$type}" => array( 'c' ), |
|
1376 | + ); |
|
1377 | + |
|
1378 | + if ( $aui_bs5 ) { |
|
1379 | + unset($selectors[".alert-{$type}" ]); |
|
1380 | + } |
|
1358 | 1381 | |
1359 | - /** |
|
1360 | - * c = color, b = background color, o = border-color, f = fill |
|
1361 | - */ |
|
1362 | - $selectors = array( |
|
1363 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
1364 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1365 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1366 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1367 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1368 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1369 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1370 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1371 | - ".badge-{$type}" => array( 'b' ), |
|
1372 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
1373 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
1374 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
1375 | - ".text-{$type}" => array( 'c' ), |
|
1376 | - ); |
|
1377 | - |
|
1378 | - if ( $aui_bs5 ) { |
|
1379 | - unset($selectors[".alert-{$type}" ]); |
|
1380 | - } |
|
1381 | - |
|
1382 | - if ( $type == 'primary' ) { |
|
1383 | - $selectors = $selectors + array( |
|
1384 | - 'a' => array( 'c' ), |
|
1385 | - '.btn-link' => array( 'c' ), |
|
1386 | - '.dropdown-item.active' => array( 'b' ), |
|
1387 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
1388 | - 'b', |
|
1389 | - 'o' |
|
1390 | - ), |
|
1391 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
1392 | - 'b', |
|
1393 | - 'o' |
|
1394 | - ), |
|
1395 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
1396 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1397 | - '.page-link' => array( 'c' ), |
|
1398 | - '.page-item.active .page-link' => array( |
|
1399 | - 'b', |
|
1400 | - 'o' |
|
1401 | - ), |
|
1402 | - '.progress-bar' => array( 'b' ), |
|
1403 | - '.list-group-item.active' => array( |
|
1404 | - 'b', |
|
1405 | - 'o' |
|
1406 | - ), |
|
1407 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1408 | - ); |
|
1409 | - } |
|
1382 | + if ( $type == 'primary' ) { |
|
1383 | + $selectors = $selectors + array( |
|
1384 | + 'a' => array( 'c' ), |
|
1385 | + '.btn-link' => array( 'c' ), |
|
1386 | + '.dropdown-item.active' => array( 'b' ), |
|
1387 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
1388 | + 'b', |
|
1389 | + 'o' |
|
1390 | + ), |
|
1391 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
1392 | + 'b', |
|
1393 | + 'o' |
|
1394 | + ), |
|
1395 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
1396 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1397 | + '.page-link' => array( 'c' ), |
|
1398 | + '.page-item.active .page-link' => array( |
|
1399 | + 'b', |
|
1400 | + 'o' |
|
1401 | + ), |
|
1402 | + '.progress-bar' => array( 'b' ), |
|
1403 | + '.list-group-item.active' => array( |
|
1404 | + 'b', |
|
1405 | + 'o' |
|
1406 | + ), |
|
1407 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1408 | + ); |
|
1409 | + } |
|
1410 | 1410 | |
1411 | 1411 | |
1412 | 1412 | |
1413 | 1413 | // link |
1414 | - if ( $type === 'primary' ) { |
|
1415 | - $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
1416 | - $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
1417 | - $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).'; }'; |
|
1414 | + if ( $type === 'primary' ) { |
|
1415 | + $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
1416 | + $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
1417 | + $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).'; }'; |
|
1418 | 1418 | |
1419 | - $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
1420 | - $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
1419 | + $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
1420 | + $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
1421 | 1421 | |
1422 | 1422 | // dropdown |
1423 | - $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
1423 | + $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
1424 | 1424 | |
1425 | 1425 | // pagination |
1426 | - $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
1426 | + $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
1427 | 1427 | |
1428 | - } |
|
1428 | + } |
|
1429 | 1429 | |
1430 | - $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
1430 | + $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
1431 | 1431 | |
1432 | - // buttons |
|
1433 | - $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
1434 | - $output .= ' |
|
1432 | + // buttons |
|
1433 | + $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
1434 | + $output .= ' |
|
1435 | 1435 | --bs-btn-bg: '.esc_attr($color_code).'; |
1436 | 1436 | --bs-btn-border-color: '.esc_attr($color_code).'; |
1437 | 1437 | --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
@@ -1449,11 +1449,11 @@ discard block |
||
1449 | 1449 | // --bs-btn-active-color: #fff; |
1450 | 1450 | // --bs-btn-disabled-color: #fff; |
1451 | 1451 | // '; |
1452 | - $output .= '}'; |
|
1452 | + $output .= '}'; |
|
1453 | 1453 | |
1454 | - // buttons outline |
|
1455 | - $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
1456 | - $output .= ' |
|
1454 | + // buttons outline |
|
1455 | + $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
1456 | + $output .= ' |
|
1457 | 1457 | --bs-btn-border-color: '.esc_attr($color_code).'; |
1458 | 1458 | --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
1459 | 1459 | --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
@@ -1470,37 +1470,37 @@ discard block |
||
1470 | 1470 | // --bs-btn-active-color: #fff; |
1471 | 1471 | // --bs-btn-disabled-color: #fff; |
1472 | 1472 | // '; |
1473 | - $output .= '}'; |
|
1473 | + $output .= '}'; |
|
1474 | 1474 | |
1475 | 1475 | |
1476 | 1476 | // button hover |
1477 | - $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
1478 | - $output .= ' |
|
1477 | + $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
1478 | + $output .= ' |
|
1479 | 1479 | 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); |
1480 | 1480 | } |
1481 | 1481 | '; |
1482 | 1482 | |
1483 | 1483 | |
1484 | - if ( $aui_bs5 ) { |
|
1484 | + if ( $aui_bs5 ) { |
|
1485 | 1485 | // $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).'; }'; |
1486 | - $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
1487 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1488 | - } |
|
1486 | + $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
1487 | + $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1488 | + } |
|
1489 | 1489 | |
1490 | 1490 | |
1491 | - if ( $is_custom ) { |
|
1491 | + if ( $is_custom ) { |
|
1492 | 1492 | |
1493 | 1493 | // echo '###'.$type;exit; |
1494 | 1494 | |
1495 | - // build rules into each type |
|
1496 | - foreach($selectors as $selector => $types){ |
|
1497 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1498 | - $types = array_combine($types,$types); |
|
1499 | - if(isset($types['c'])){$color[] = $selector;} |
|
1500 | - if(isset($types['b'])){$background[] = $selector;} |
|
1501 | - if(isset($types['o'])){$border[] = $selector;} |
|
1502 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1503 | - } |
|
1495 | + // build rules into each type |
|
1496 | + foreach($selectors as $selector => $types){ |
|
1497 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1498 | + $types = array_combine($types,$types); |
|
1499 | + if(isset($types['c'])){$color[] = $selector;} |
|
1500 | + if(isset($types['b'])){$background[] = $selector;} |
|
1501 | + if(isset($types['o'])){$border[] = $selector;} |
|
1502 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1503 | + } |
|
1504 | 1504 | |
1505 | 1505 | // // build rules into each type |
1506 | 1506 | // foreach($important_selectors as $selector => $types){ |
@@ -1512,67 +1512,67 @@ discard block |
||
1512 | 1512 | // if(isset($types['f'])){$fill_i[] = $selector;} |
1513 | 1513 | // } |
1514 | 1514 | |
1515 | - // add any color rules |
|
1516 | - if(!empty($color)){ |
|
1517 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1518 | - } |
|
1519 | - if(!empty($color_i)){ |
|
1520 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1521 | - } |
|
1515 | + // add any color rules |
|
1516 | + if(!empty($color)){ |
|
1517 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1518 | + } |
|
1519 | + if(!empty($color_i)){ |
|
1520 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1521 | + } |
|
1522 | 1522 | |
1523 | - // add any background color rules |
|
1524 | - if(!empty($background)){ |
|
1525 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1526 | - } |
|
1527 | - if(!empty($background_i)){ |
|
1528 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1523 | + // add any background color rules |
|
1524 | + if(!empty($background)){ |
|
1525 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1526 | + } |
|
1527 | + if(!empty($background_i)){ |
|
1528 | + $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1529 | 1529 | // $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
1530 | - } |
|
1530 | + } |
|
1531 | 1531 | |
1532 | - // add any border color rules |
|
1533 | - if(!empty($border)){ |
|
1534 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1535 | - } |
|
1536 | - if(!empty($border_i)){ |
|
1537 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1538 | - } |
|
1532 | + // add any border color rules |
|
1533 | + if(!empty($border)){ |
|
1534 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1535 | + } |
|
1536 | + if(!empty($border_i)){ |
|
1537 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1538 | + } |
|
1539 | 1539 | |
1540 | - // add any fill color rules |
|
1541 | - if(!empty($fill)){ |
|
1542 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1543 | - } |
|
1544 | - if(!empty($fill_i)){ |
|
1545 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1546 | - } |
|
1540 | + // add any fill color rules |
|
1541 | + if(!empty($fill)){ |
|
1542 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1543 | + } |
|
1544 | + if(!empty($fill_i)){ |
|
1545 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1546 | + } |
|
1547 | 1547 | |
1548 | - } |
|
1548 | + } |
|
1549 | 1549 | |
1550 | 1550 | |
1551 | 1551 | |
1552 | 1552 | |
1553 | - $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;' : ''; |
|
1554 | - // darken |
|
1555 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1556 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1557 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1558 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
1553 | + $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;' : ''; |
|
1554 | + // darken |
|
1555 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1556 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1557 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1558 | + $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
1559 | 1559 | |
1560 | - // lighten |
|
1561 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1560 | + // lighten |
|
1561 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1562 | 1562 | |
1563 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1564 | - $op_25 = $color_code."40"; // 25% opacity |
|
1563 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1564 | + $op_25 = $color_code."40"; // 25% opacity |
|
1565 | 1565 | |
1566 | 1566 | |
1567 | - // button states |
|
1568 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1569 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1567 | + // button states |
|
1568 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1569 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1570 | 1570 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
1571 | - $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;} "; |
|
1572 | - $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.";} "; |
|
1573 | - $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;} "; |
|
1571 | + $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;} "; |
|
1572 | + $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.";} "; |
|
1573 | + $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;} "; |
|
1574 | 1574 | |
1575 | - // text |
|
1575 | + // text |
|
1576 | 1576 | // $output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} "; |
1577 | 1577 | |
1578 | 1578 | |
@@ -1587,773 +1587,773 @@ discard block |
||
1587 | 1587 | // $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
1588 | 1588 | // } |
1589 | 1589 | |
1590 | - // alerts |
|
1591 | - if ( $aui_bs5 ) { |
|
1590 | + // alerts |
|
1591 | + if ( $aui_bs5 ) { |
|
1592 | 1592 | // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
1593 | - $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;} "; |
|
1594 | - } |
|
1595 | - |
|
1596 | - return $output; |
|
1597 | - } |
|
1598 | - |
|
1599 | - /** |
|
1600 | - * Build the CSS to overwrite a bootstrap color variable. |
|
1601 | - * |
|
1602 | - * @param $type |
|
1603 | - * @param $color_code |
|
1604 | - * @param $compatibility |
|
1605 | - * |
|
1606 | - * @return string |
|
1607 | - */ |
|
1608 | - public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
1593 | + $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;} "; |
|
1594 | + } |
|
1595 | + |
|
1596 | + return $output; |
|
1597 | + } |
|
1598 | + |
|
1599 | + /** |
|
1600 | + * Build the CSS to overwrite a bootstrap color variable. |
|
1601 | + * |
|
1602 | + * @param $type |
|
1603 | + * @param $color_code |
|
1604 | + * @param $compatibility |
|
1605 | + * |
|
1606 | + * @return string |
|
1607 | + */ |
|
1608 | + public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
1609 | 1609 | global $aui_bs5; |
1610 | 1610 | |
1611 | - $is_var = false; |
|
1612 | - if(!$color_code){return '';} |
|
1613 | - if(strpos($color_code, 'var') !== false){ |
|
1614 | - //if(!sanitize_hex_color($color_code)){ |
|
1615 | - $color_code = esc_attr($color_code); |
|
1616 | - $is_var = true; |
|
1611 | + $is_var = false; |
|
1612 | + if(!$color_code){return '';} |
|
1613 | + if(strpos($color_code, 'var') !== false){ |
|
1614 | + //if(!sanitize_hex_color($color_code)){ |
|
1615 | + $color_code = esc_attr($color_code); |
|
1616 | + $is_var = true; |
|
1617 | 1617 | // $color_code = "rgba($color_code, 0.5)"; |
1618 | 1618 | // echo '###1'.$color_code.'###';//exit; |
1619 | - } |
|
1619 | + } |
|
1620 | 1620 | |
1621 | 1621 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
1622 | 1622 | |
1623 | - if(!$color_code){return '';} |
|
1623 | + if(!$color_code){return '';} |
|
1624 | 1624 | |
1625 | 1625 | $rgb = self::hex_to_rgb($hex); |
1626 | 1626 | |
1627 | - if($compatibility===true || $compatibility===1){ |
|
1628 | - $compatibility = '.bsui'; |
|
1629 | - }elseif(!$compatibility){ |
|
1630 | - $compatibility = ''; |
|
1631 | - }else{ |
|
1632 | - $compatibility = esc_attr($compatibility); |
|
1633 | - } |
|
1627 | + if($compatibility===true || $compatibility===1){ |
|
1628 | + $compatibility = '.bsui'; |
|
1629 | + }elseif(!$compatibility){ |
|
1630 | + $compatibility = ''; |
|
1631 | + }else{ |
|
1632 | + $compatibility = esc_attr($compatibility); |
|
1633 | + } |
|
1634 | 1634 | |
1635 | 1635 | |
1636 | 1636 | |
1637 | 1637 | // echo '####'.$color_code;exit; |
1638 | 1638 | |
1639 | - $type = sanitize_html_class($type); |
|
1640 | - |
|
1641 | - /** |
|
1642 | - * c = color, b = background color, o = border-color, f = fill |
|
1643 | - */ |
|
1644 | - $selectors = array( |
|
1645 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
1646 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1647 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1648 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1649 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1650 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1651 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1652 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1653 | - ".badge-{$type}" => array( 'b' ), |
|
1654 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
1655 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
1656 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
1657 | - ); |
|
1658 | - |
|
1659 | - if ( $aui_bs5 ) { |
|
1639 | + $type = sanitize_html_class($type); |
|
1640 | + |
|
1641 | + /** |
|
1642 | + * c = color, b = background color, o = border-color, f = fill |
|
1643 | + */ |
|
1644 | + $selectors = array( |
|
1645 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
1646 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1647 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1648 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1649 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1650 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1651 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1652 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1653 | + ".badge-{$type}" => array( 'b' ), |
|
1654 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
1655 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
1656 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
1657 | + ); |
|
1658 | + |
|
1659 | + if ( $aui_bs5 ) { |
|
1660 | 1660 | unset($selectors[".alert-{$type}" ]); |
1661 | - } |
|
1662 | - |
|
1663 | - if ( $type == 'primary' ) { |
|
1664 | - $selectors = $selectors + array( |
|
1665 | - 'a' => array( 'c' ), |
|
1666 | - '.btn-link' => array( 'c' ), |
|
1667 | - '.dropdown-item.active' => array( 'b' ), |
|
1668 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
1669 | - 'b', |
|
1670 | - 'o' |
|
1671 | - ), |
|
1672 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
1673 | - 'b', |
|
1674 | - 'o' |
|
1675 | - ), |
|
1676 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
1677 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1678 | - '.page-link' => array( 'c' ), |
|
1679 | - '.page-item.active .page-link' => array( |
|
1680 | - 'b', |
|
1681 | - 'o' |
|
1682 | - ), |
|
1683 | - '.progress-bar' => array( 'b' ), |
|
1684 | - '.list-group-item.active' => array( |
|
1685 | - 'b', |
|
1686 | - 'o' |
|
1687 | - ), |
|
1688 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1661 | + } |
|
1662 | + |
|
1663 | + if ( $type == 'primary' ) { |
|
1664 | + $selectors = $selectors + array( |
|
1665 | + 'a' => array( 'c' ), |
|
1666 | + '.btn-link' => array( 'c' ), |
|
1667 | + '.dropdown-item.active' => array( 'b' ), |
|
1668 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
1669 | + 'b', |
|
1670 | + 'o' |
|
1671 | + ), |
|
1672 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
1673 | + 'b', |
|
1674 | + 'o' |
|
1675 | + ), |
|
1676 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
1677 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1678 | + '.page-link' => array( 'c' ), |
|
1679 | + '.page-item.active .page-link' => array( |
|
1680 | + 'b', |
|
1681 | + 'o' |
|
1682 | + ), |
|
1683 | + '.progress-bar' => array( 'b' ), |
|
1684 | + '.list-group-item.active' => array( |
|
1685 | + 'b', |
|
1686 | + 'o' |
|
1687 | + ), |
|
1688 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1689 | 1689 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1690 | 1690 | // '.custom-range::-moz-range-thumb' => array('b'), |
1691 | 1691 | // '.custom-range::-ms-thumb' => array('b'), |
1692 | - ); |
|
1693 | - } |
|
1694 | - |
|
1695 | - $important_selectors = array( |
|
1696 | - ".bg-{$type}" => array('b','f'), |
|
1697 | - ".border-{$type}" => array('o'), |
|
1698 | - ".text-{$type}" => array('c'), |
|
1699 | - ); |
|
1700 | - |
|
1701 | - $color = array(); |
|
1702 | - $color_i = array(); |
|
1703 | - $background = array(); |
|
1704 | - $background_i = array(); |
|
1705 | - $border = array(); |
|
1706 | - $border_i = array(); |
|
1707 | - $fill = array(); |
|
1708 | - $fill_i = array(); |
|
1709 | - |
|
1710 | - $output = ''; |
|
1711 | - |
|
1712 | - if ( $aui_bs5 ) { |
|
1692 | + ); |
|
1693 | + } |
|
1694 | + |
|
1695 | + $important_selectors = array( |
|
1696 | + ".bg-{$type}" => array('b','f'), |
|
1697 | + ".border-{$type}" => array('o'), |
|
1698 | + ".text-{$type}" => array('c'), |
|
1699 | + ); |
|
1700 | + |
|
1701 | + $color = array(); |
|
1702 | + $color_i = array(); |
|
1703 | + $background = array(); |
|
1704 | + $background_i = array(); |
|
1705 | + $border = array(); |
|
1706 | + $border_i = array(); |
|
1707 | + $fill = array(); |
|
1708 | + $fill_i = array(); |
|
1709 | + |
|
1710 | + $output = ''; |
|
1711 | + |
|
1712 | + if ( $aui_bs5 ) { |
|
1713 | 1713 | // $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).'; }'; |
1714 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1715 | - } |
|
1716 | - |
|
1717 | - // build rules into each type |
|
1718 | - foreach($selectors as $selector => $types){ |
|
1719 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1720 | - $types = array_combine($types,$types); |
|
1721 | - if(isset($types['c'])){$color[] = $selector;} |
|
1722 | - if(isset($types['b'])){$background[] = $selector;} |
|
1723 | - if(isset($types['o'])){$border[] = $selector;} |
|
1724 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1725 | - } |
|
1726 | - |
|
1727 | - // build rules into each type |
|
1728 | - foreach($important_selectors as $selector => $types){ |
|
1729 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1730 | - $types = array_combine($types,$types); |
|
1731 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1732 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1733 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1734 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1735 | - } |
|
1736 | - |
|
1737 | - // add any color rules |
|
1738 | - if(!empty($color)){ |
|
1739 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1740 | - } |
|
1741 | - if(!empty($color_i)){ |
|
1742 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1743 | - } |
|
1744 | - |
|
1745 | - // add any background color rules |
|
1746 | - if(!empty($background)){ |
|
1747 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1748 | - } |
|
1749 | - if(!empty($background_i)){ |
|
1750 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1714 | + $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1715 | + } |
|
1716 | + |
|
1717 | + // build rules into each type |
|
1718 | + foreach($selectors as $selector => $types){ |
|
1719 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1720 | + $types = array_combine($types,$types); |
|
1721 | + if(isset($types['c'])){$color[] = $selector;} |
|
1722 | + if(isset($types['b'])){$background[] = $selector;} |
|
1723 | + if(isset($types['o'])){$border[] = $selector;} |
|
1724 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1725 | + } |
|
1726 | + |
|
1727 | + // build rules into each type |
|
1728 | + foreach($important_selectors as $selector => $types){ |
|
1729 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1730 | + $types = array_combine($types,$types); |
|
1731 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1732 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1733 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1734 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1735 | + } |
|
1736 | + |
|
1737 | + // add any color rules |
|
1738 | + if(!empty($color)){ |
|
1739 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1740 | + } |
|
1741 | + if(!empty($color_i)){ |
|
1742 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1743 | + } |
|
1744 | + |
|
1745 | + // add any background color rules |
|
1746 | + if(!empty($background)){ |
|
1747 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1748 | + } |
|
1749 | + if(!empty($background_i)){ |
|
1750 | + $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1751 | 1751 | // $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
1752 | - } |
|
1752 | + } |
|
1753 | 1753 | |
1754 | - // add any border color rules |
|
1755 | - if(!empty($border)){ |
|
1756 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1757 | - } |
|
1758 | - if(!empty($border_i)){ |
|
1759 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1760 | - } |
|
1754 | + // add any border color rules |
|
1755 | + if(!empty($border)){ |
|
1756 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1757 | + } |
|
1758 | + if(!empty($border_i)){ |
|
1759 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1760 | + } |
|
1761 | 1761 | |
1762 | - // add any fill color rules |
|
1763 | - if(!empty($fill)){ |
|
1764 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1765 | - } |
|
1766 | - if(!empty($fill_i)){ |
|
1767 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1768 | - } |
|
1762 | + // add any fill color rules |
|
1763 | + if(!empty($fill)){ |
|
1764 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1765 | + } |
|
1766 | + if(!empty($fill_i)){ |
|
1767 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1768 | + } |
|
1769 | 1769 | |
1770 | 1770 | |
1771 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
1771 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
1772 | 1772 | |
1773 | - $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;' : ''; |
|
1774 | - // darken |
|
1775 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1776 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1777 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1778 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
1773 | + $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;' : ''; |
|
1774 | + // darken |
|
1775 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1776 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1777 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1778 | + $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
1779 | 1779 | |
1780 | - // lighten |
|
1781 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1780 | + // lighten |
|
1781 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1782 | 1782 | |
1783 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1784 | - $op_25 = $color_code."40"; // 25% opacity |
|
1783 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1784 | + $op_25 = $color_code."40"; // 25% opacity |
|
1785 | 1785 | |
1786 | 1786 | |
1787 | - // button states |
|
1788 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1789 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1787 | + // button states |
|
1788 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1789 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1790 | 1790 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
1791 | - $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;} "; |
|
1792 | - $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.";} "; |
|
1793 | - $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;} "; |
|
1791 | + $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;} "; |
|
1792 | + $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.";} "; |
|
1793 | + $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;} "; |
|
1794 | 1794 | |
1795 | - if ( $type == 'primary' ) { |
|
1796 | - // dropdown's |
|
1797 | - $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1795 | + if ( $type == 'primary' ) { |
|
1796 | + // dropdown's |
|
1797 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1798 | 1798 | |
1799 | - // input states |
|
1800 | - $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1799 | + // input states |
|
1800 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1801 | 1801 | |
1802 | - // page link |
|
1803 | - $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1804 | - } |
|
1802 | + // page link |
|
1803 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1804 | + } |
|
1805 | 1805 | |
1806 | 1806 | // alerts |
1807 | - if ( $aui_bs5 ) { |
|
1807 | + if ( $aui_bs5 ) { |
|
1808 | 1808 | // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
1809 | - $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;} "; |
|
1810 | - } |
|
1811 | - |
|
1812 | - return $output; |
|
1813 | - } |
|
1814 | - |
|
1815 | - /** |
|
1816 | - * |
|
1817 | - * @deprecated 0.1.76 Use css_overwrite() |
|
1818 | - * |
|
1819 | - * @param $color_code |
|
1820 | - * @param $compatibility |
|
1821 | - * @param $use_variable |
|
1822 | - * |
|
1823 | - * @return string |
|
1824 | - */ |
|
1825 | - public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
1826 | - |
|
1827 | - if(!$use_variable){ |
|
1828 | - $color_code = sanitize_hex_color($color_code); |
|
1829 | - if(!$color_code){return '';} |
|
1830 | - } |
|
1831 | - |
|
1832 | - /** |
|
1833 | - * c = color, b = background color, o = border-color, f = fill |
|
1834 | - */ |
|
1835 | - $selectors = array( |
|
1836 | - 'a' => array('c'), |
|
1837 | - '.btn-primary' => array('b','o'), |
|
1838 | - '.btn-primary.disabled' => array('b','o'), |
|
1839 | - '.btn-primary:disabled' => array('b','o'), |
|
1840 | - '.btn-outline-primary' => array('c','o'), |
|
1841 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1842 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1843 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1844 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1845 | - '.btn-link' => array('c'), |
|
1846 | - '.dropdown-item.active' => array('b'), |
|
1847 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1848 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1809 | + $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;} "; |
|
1810 | + } |
|
1811 | + |
|
1812 | + return $output; |
|
1813 | + } |
|
1814 | + |
|
1815 | + /** |
|
1816 | + * |
|
1817 | + * @deprecated 0.1.76 Use css_overwrite() |
|
1818 | + * |
|
1819 | + * @param $color_code |
|
1820 | + * @param $compatibility |
|
1821 | + * @param $use_variable |
|
1822 | + * |
|
1823 | + * @return string |
|
1824 | + */ |
|
1825 | + public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
1826 | + |
|
1827 | + if(!$use_variable){ |
|
1828 | + $color_code = sanitize_hex_color($color_code); |
|
1829 | + if(!$color_code){return '';} |
|
1830 | + } |
|
1831 | + |
|
1832 | + /** |
|
1833 | + * c = color, b = background color, o = border-color, f = fill |
|
1834 | + */ |
|
1835 | + $selectors = array( |
|
1836 | + 'a' => array('c'), |
|
1837 | + '.btn-primary' => array('b','o'), |
|
1838 | + '.btn-primary.disabled' => array('b','o'), |
|
1839 | + '.btn-primary:disabled' => array('b','o'), |
|
1840 | + '.btn-outline-primary' => array('c','o'), |
|
1841 | + '.btn-outline-primary:hover' => array('b','o'), |
|
1842 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1843 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1844 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1845 | + '.btn-link' => array('c'), |
|
1846 | + '.dropdown-item.active' => array('b'), |
|
1847 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1848 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1849 | 1849 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1850 | 1850 | // '.custom-range::-moz-range-thumb' => array('b'), |
1851 | 1851 | // '.custom-range::-ms-thumb' => array('b'), |
1852 | - '.nav-pills .nav-link.active' => array('b'), |
|
1853 | - '.nav-pills .show>.nav-link' => array('b'), |
|
1854 | - '.page-link' => array('c'), |
|
1855 | - '.page-item.active .page-link' => array('b','o'), |
|
1856 | - '.badge-primary' => array('b'), |
|
1857 | - '.alert-primary' => array('b','o'), |
|
1858 | - '.progress-bar' => array('b'), |
|
1859 | - '.list-group-item.active' => array('b','o'), |
|
1860 | - '.bg-primary' => array('b','f'), |
|
1861 | - '.btn-link.btn-primary' => array('c'), |
|
1862 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1863 | - ); |
|
1864 | - |
|
1865 | - $important_selectors = array( |
|
1866 | - '.bg-primary' => array('b','f'), |
|
1867 | - '.border-primary' => array('o'), |
|
1868 | - '.text-primary' => array('c'), |
|
1869 | - ); |
|
1870 | - |
|
1871 | - $color = array(); |
|
1872 | - $color_i = array(); |
|
1873 | - $background = array(); |
|
1874 | - $background_i = array(); |
|
1875 | - $border = array(); |
|
1876 | - $border_i = array(); |
|
1877 | - $fill = array(); |
|
1878 | - $fill_i = array(); |
|
1879 | - |
|
1880 | - $output = ''; |
|
1881 | - |
|
1882 | - // build rules into each type |
|
1883 | - foreach($selectors as $selector => $types){ |
|
1884 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1885 | - $types = array_combine($types,$types); |
|
1886 | - if(isset($types['c'])){$color[] = $selector;} |
|
1887 | - if(isset($types['b'])){$background[] = $selector;} |
|
1888 | - if(isset($types['o'])){$border[] = $selector;} |
|
1889 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1890 | - } |
|
1891 | - |
|
1892 | - // build rules into each type |
|
1893 | - foreach($important_selectors as $selector => $types){ |
|
1894 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1895 | - $types = array_combine($types,$types); |
|
1896 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1897 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1898 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1899 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1900 | - } |
|
1901 | - |
|
1902 | - // add any color rules |
|
1903 | - if(!empty($color)){ |
|
1904 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1905 | - } |
|
1906 | - if(!empty($color_i)){ |
|
1907 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1908 | - } |
|
1909 | - |
|
1910 | - // add any background color rules |
|
1911 | - if(!empty($background)){ |
|
1912 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1913 | - } |
|
1914 | - if(!empty($background_i)){ |
|
1915 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1916 | - } |
|
1917 | - |
|
1918 | - // add any border color rules |
|
1919 | - if(!empty($border)){ |
|
1920 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1921 | - } |
|
1922 | - if(!empty($border_i)){ |
|
1923 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1924 | - } |
|
1925 | - |
|
1926 | - // add any fill color rules |
|
1927 | - if(!empty($fill)){ |
|
1928 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1929 | - } |
|
1930 | - if(!empty($fill_i)){ |
|
1931 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1932 | - } |
|
1933 | - |
|
1934 | - |
|
1935 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1936 | - |
|
1937 | - // darken |
|
1938 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1939 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1940 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1941 | - |
|
1942 | - // lighten |
|
1943 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1944 | - |
|
1945 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1946 | - $op_25 = $color_code."40"; // 25% opacity |
|
1947 | - |
|
1948 | - |
|
1949 | - // button states |
|
1950 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1951 | - $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;} "; |
|
1952 | - $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.";} "; |
|
1953 | - $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;} "; |
|
1954 | - |
|
1955 | - |
|
1956 | - // dropdown's |
|
1957 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1958 | - |
|
1959 | - |
|
1960 | - // input states |
|
1961 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1962 | - |
|
1963 | - // page link |
|
1964 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1965 | - |
|
1966 | - return $output; |
|
1967 | - } |
|
1968 | - |
|
1969 | - /** |
|
1970 | - * |
|
1971 | - * @deprecated 0.1.76 Use css_overwrite() |
|
1972 | - * |
|
1973 | - * @param $color_code |
|
1974 | - * @param $compatibility |
|
1975 | - * |
|
1976 | - * @return string |
|
1977 | - */ |
|
1978 | - public static function css_secondary($color_code,$compatibility){; |
|
1979 | - $color_code = sanitize_hex_color($color_code); |
|
1980 | - if(!$color_code){return '';} |
|
1981 | - /** |
|
1982 | - * c = color, b = background color, o = border-color, f = fill |
|
1983 | - */ |
|
1984 | - $selectors = array( |
|
1985 | - '.btn-secondary' => array('b','o'), |
|
1986 | - '.btn-secondary.disabled' => array('b','o'), |
|
1987 | - '.btn-secondary:disabled' => array('b','o'), |
|
1988 | - '.btn-outline-secondary' => array('c','o'), |
|
1989 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1990 | - '.btn-outline-secondary.disabled' => array('c'), |
|
1991 | - '.btn-outline-secondary:disabled' => array('c'), |
|
1992 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1993 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1994 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1995 | - '.badge-secondary' => array('b'), |
|
1996 | - '.alert-secondary' => array('b','o'), |
|
1997 | - '.btn-link.btn-secondary' => array('c'), |
|
1998 | - ); |
|
1999 | - |
|
2000 | - $important_selectors = array( |
|
2001 | - '.bg-secondary' => array('b','f'), |
|
2002 | - '.border-secondary' => array('o'), |
|
2003 | - '.text-secondary' => array('c'), |
|
2004 | - ); |
|
2005 | - |
|
2006 | - $color = array(); |
|
2007 | - $color_i = array(); |
|
2008 | - $background = array(); |
|
2009 | - $background_i = array(); |
|
2010 | - $border = array(); |
|
2011 | - $border_i = array(); |
|
2012 | - $fill = array(); |
|
2013 | - $fill_i = array(); |
|
2014 | - |
|
2015 | - $output = ''; |
|
2016 | - |
|
2017 | - // build rules into each type |
|
2018 | - foreach($selectors as $selector => $types){ |
|
2019 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2020 | - $types = array_combine($types,$types); |
|
2021 | - if(isset($types['c'])){$color[] = $selector;} |
|
2022 | - if(isset($types['b'])){$background[] = $selector;} |
|
2023 | - if(isset($types['o'])){$border[] = $selector;} |
|
2024 | - if(isset($types['f'])){$fill[] = $selector;} |
|
2025 | - } |
|
2026 | - |
|
2027 | - // build rules into each type |
|
2028 | - foreach($important_selectors as $selector => $types){ |
|
2029 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2030 | - $types = array_combine($types,$types); |
|
2031 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
2032 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
2033 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
2034 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
2035 | - } |
|
2036 | - |
|
2037 | - // add any color rules |
|
2038 | - if(!empty($color)){ |
|
2039 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
2040 | - } |
|
2041 | - if(!empty($color_i)){ |
|
2042 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
2043 | - } |
|
2044 | - |
|
2045 | - // add any background color rules |
|
2046 | - if(!empty($background)){ |
|
2047 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
2048 | - } |
|
2049 | - if(!empty($background_i)){ |
|
2050 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
2051 | - } |
|
2052 | - |
|
2053 | - // add any border color rules |
|
2054 | - if(!empty($border)){ |
|
2055 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
2056 | - } |
|
2057 | - if(!empty($border_i)){ |
|
2058 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
2059 | - } |
|
2060 | - |
|
2061 | - // add any fill color rules |
|
2062 | - if(!empty($fill)){ |
|
2063 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
2064 | - } |
|
2065 | - if(!empty($fill_i)){ |
|
2066 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
2067 | - } |
|
2068 | - |
|
2069 | - |
|
2070 | - $prefix = $compatibility ? ".bsui " : ""; |
|
2071 | - |
|
2072 | - // darken |
|
2073 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
2074 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
2075 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
2076 | - |
|
2077 | - // lighten |
|
2078 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
2079 | - |
|
2080 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
2081 | - $op_25 = $color_code."40"; // 25% opacity |
|
2082 | - |
|
2083 | - |
|
2084 | - // button states |
|
2085 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
2086 | - $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;} "; |
|
2087 | - $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.";} "; |
|
2088 | - $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;} "; |
|
2089 | - |
|
2090 | - |
|
2091 | - return $output; |
|
2092 | - } |
|
2093 | - |
|
2094 | - /** |
|
2095 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
2096 | - * |
|
2097 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
2098 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
2099 | - * |
|
2100 | - * @return string |
|
2101 | - */ |
|
2102 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
2103 | - $hexCode = ltrim($hexCode, '#'); |
|
2104 | - |
|
2105 | - if (strlen($hexCode) == 3) { |
|
2106 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
2107 | - } |
|
2108 | - |
|
2109 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
2110 | - |
|
2111 | - foreach ($hexCode as & $color) { |
|
2112 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
2113 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
2114 | - |
|
2115 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
2116 | - } |
|
2117 | - |
|
2118 | - return '#' . implode($hexCode); |
|
2119 | - } |
|
2120 | - |
|
2121 | - /** |
|
2122 | - * Check if we should display examples. |
|
2123 | - */ |
|
2124 | - public function maybe_show_examples(){ |
|
2125 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
2126 | - echo "<head>"; |
|
2127 | - wp_head(); |
|
2128 | - echo "</head>"; |
|
2129 | - echo "<body>"; |
|
2130 | - echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2131 | - echo "</body>"; |
|
2132 | - exit; |
|
2133 | - } |
|
2134 | - } |
|
2135 | - |
|
2136 | - /** |
|
2137 | - * Get developer examples. |
|
2138 | - * |
|
2139 | - * @return string |
|
2140 | - */ |
|
2141 | - public function get_examples(){ |
|
2142 | - $output = ''; |
|
2143 | - |
|
2144 | - |
|
2145 | - // open form |
|
2146 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
2147 | - |
|
2148 | - // input example |
|
2149 | - $output .= aui()->input(array( |
|
2150 | - 'type' => 'text', |
|
2151 | - 'id' => 'text-example', |
|
2152 | - 'name' => 'text-example', |
|
2153 | - 'placeholder' => 'text placeholder', |
|
2154 | - 'title' => 'Text input example', |
|
2155 | - 'value' => '', |
|
2156 | - 'required' => false, |
|
2157 | - 'help_text' => 'help text', |
|
2158 | - 'label' => 'Text input example label' |
|
2159 | - )); |
|
2160 | - |
|
2161 | - // input example |
|
2162 | - $output .= aui()->input(array( |
|
2163 | - 'type' => 'url', |
|
2164 | - 'id' => 'text-example2', |
|
2165 | - 'name' => 'text-example', |
|
2166 | - 'placeholder' => 'url placeholder', |
|
2167 | - 'title' => 'Text input example', |
|
2168 | - 'value' => '', |
|
2169 | - 'required' => false, |
|
2170 | - 'help_text' => 'help text', |
|
2171 | - 'label' => 'Text input example label' |
|
2172 | - )); |
|
2173 | - |
|
2174 | - // checkbox example |
|
2175 | - $output .= aui()->input(array( |
|
2176 | - 'type' => 'checkbox', |
|
2177 | - 'id' => 'checkbox-example', |
|
2178 | - 'name' => 'checkbox-example', |
|
2179 | - 'placeholder' => 'checkbox-example', |
|
2180 | - 'title' => 'Checkbox example', |
|
2181 | - 'value' => '1', |
|
2182 | - 'checked' => true, |
|
2183 | - 'required' => false, |
|
2184 | - 'help_text' => 'help text', |
|
2185 | - 'label' => 'Checkbox checked' |
|
2186 | - )); |
|
2187 | - |
|
2188 | - // checkbox example |
|
2189 | - $output .= aui()->input(array( |
|
2190 | - 'type' => 'checkbox', |
|
2191 | - 'id' => 'checkbox-example2', |
|
2192 | - 'name' => 'checkbox-example2', |
|
2193 | - 'placeholder' => 'checkbox-example', |
|
2194 | - 'title' => 'Checkbox example', |
|
2195 | - 'value' => '1', |
|
2196 | - 'checked' => false, |
|
2197 | - 'required' => false, |
|
2198 | - 'help_text' => 'help text', |
|
2199 | - 'label' => 'Checkbox un-checked' |
|
2200 | - )); |
|
2201 | - |
|
2202 | - // switch example |
|
2203 | - $output .= aui()->input(array( |
|
2204 | - 'type' => 'checkbox', |
|
2205 | - 'id' => 'switch-example', |
|
2206 | - 'name' => 'switch-example', |
|
2207 | - 'placeholder' => 'checkbox-example', |
|
2208 | - 'title' => 'Switch example', |
|
2209 | - 'value' => '1', |
|
2210 | - 'checked' => true, |
|
2211 | - 'switch' => true, |
|
2212 | - 'required' => false, |
|
2213 | - 'help_text' => 'help text', |
|
2214 | - 'label' => 'Switch on' |
|
2215 | - )); |
|
2216 | - |
|
2217 | - // switch example |
|
2218 | - $output .= aui()->input(array( |
|
2219 | - 'type' => 'checkbox', |
|
2220 | - 'id' => 'switch-example2', |
|
2221 | - 'name' => 'switch-example2', |
|
2222 | - 'placeholder' => 'checkbox-example', |
|
2223 | - 'title' => 'Switch example', |
|
2224 | - 'value' => '1', |
|
2225 | - 'checked' => false, |
|
2226 | - 'switch' => true, |
|
2227 | - 'required' => false, |
|
2228 | - 'help_text' => 'help text', |
|
2229 | - 'label' => 'Switch off' |
|
2230 | - )); |
|
2231 | - |
|
2232 | - // close form |
|
2233 | - $output .= "</form>"; |
|
2234 | - |
|
2235 | - return $output; |
|
2236 | - } |
|
2237 | - |
|
2238 | - /** |
|
2239 | - * Calendar params. |
|
2240 | - * |
|
2241 | - * @since 0.1.44 |
|
2242 | - * |
|
2243 | - * @return array Calendar params. |
|
2244 | - */ |
|
2245 | - public static function calendar_params() { |
|
2246 | - $params = array( |
|
2247 | - 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
2248 | - 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
2249 | - 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
2250 | - 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
2251 | - 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
2252 | - 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
2253 | - 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
2254 | - 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
2255 | - 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
2256 | - 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
2257 | - 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
2258 | - 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
2259 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
2260 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
2261 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
2262 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
2263 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
2264 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
2265 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
2266 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
2267 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
2268 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
2269 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
2270 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
2271 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
2272 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
2273 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
2274 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
2275 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
2276 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
2277 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
2278 | - 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
2279 | - 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
2280 | - 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
2281 | - 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
2282 | - 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
2283 | - 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
2284 | - 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
2285 | - 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
2286 | - 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
2287 | - 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
2288 | - 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
2289 | - 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
2290 | - 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
2291 | - 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
2292 | - 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
2293 | - 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
2294 | - 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
2295 | - 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
2296 | - 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
2297 | - 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
2298 | - 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
2299 | - 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
2300 | - 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
2301 | - 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
2302 | - 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
2303 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
2304 | - 'time_24hr' => false, |
|
2305 | - 'year' => __( 'Year', 'ayecode-connect' ), |
|
2306 | - 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
2307 | - 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
2308 | - 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
2309 | - 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
2310 | - 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
2311 | - 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
2312 | - ); |
|
2313 | - |
|
2314 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
2315 | - } |
|
2316 | - |
|
2317 | - /** |
|
2318 | - * Flatpickr calendar localize. |
|
2319 | - * |
|
2320 | - * @since 0.1.44 |
|
2321 | - * |
|
2322 | - * @return string Calendar locale. |
|
2323 | - */ |
|
2324 | - public static function flatpickr_locale() { |
|
2325 | - $params = self::calendar_params(); |
|
2326 | - |
|
2327 | - if ( is_string( $params ) ) { |
|
2328 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
2329 | - } else { |
|
2330 | - foreach ( (array) $params as $key => $value ) { |
|
2331 | - if ( ! is_scalar( $value ) ) { |
|
2332 | - continue; |
|
2333 | - } |
|
2334 | - |
|
2335 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2336 | - } |
|
2337 | - } |
|
1852 | + '.nav-pills .nav-link.active' => array('b'), |
|
1853 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1854 | + '.page-link' => array('c'), |
|
1855 | + '.page-item.active .page-link' => array('b','o'), |
|
1856 | + '.badge-primary' => array('b'), |
|
1857 | + '.alert-primary' => array('b','o'), |
|
1858 | + '.progress-bar' => array('b'), |
|
1859 | + '.list-group-item.active' => array('b','o'), |
|
1860 | + '.bg-primary' => array('b','f'), |
|
1861 | + '.btn-link.btn-primary' => array('c'), |
|
1862 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1863 | + ); |
|
1864 | + |
|
1865 | + $important_selectors = array( |
|
1866 | + '.bg-primary' => array('b','f'), |
|
1867 | + '.border-primary' => array('o'), |
|
1868 | + '.text-primary' => array('c'), |
|
1869 | + ); |
|
1870 | + |
|
1871 | + $color = array(); |
|
1872 | + $color_i = array(); |
|
1873 | + $background = array(); |
|
1874 | + $background_i = array(); |
|
1875 | + $border = array(); |
|
1876 | + $border_i = array(); |
|
1877 | + $fill = array(); |
|
1878 | + $fill_i = array(); |
|
1879 | + |
|
1880 | + $output = ''; |
|
1881 | + |
|
1882 | + // build rules into each type |
|
1883 | + foreach($selectors as $selector => $types){ |
|
1884 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1885 | + $types = array_combine($types,$types); |
|
1886 | + if(isset($types['c'])){$color[] = $selector;} |
|
1887 | + if(isset($types['b'])){$background[] = $selector;} |
|
1888 | + if(isset($types['o'])){$border[] = $selector;} |
|
1889 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1890 | + } |
|
1891 | + |
|
1892 | + // build rules into each type |
|
1893 | + foreach($important_selectors as $selector => $types){ |
|
1894 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1895 | + $types = array_combine($types,$types); |
|
1896 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1897 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1898 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1899 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1900 | + } |
|
1901 | + |
|
1902 | + // add any color rules |
|
1903 | + if(!empty($color)){ |
|
1904 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1905 | + } |
|
1906 | + if(!empty($color_i)){ |
|
1907 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1908 | + } |
|
1909 | + |
|
1910 | + // add any background color rules |
|
1911 | + if(!empty($background)){ |
|
1912 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1913 | + } |
|
1914 | + if(!empty($background_i)){ |
|
1915 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1916 | + } |
|
1917 | + |
|
1918 | + // add any border color rules |
|
1919 | + if(!empty($border)){ |
|
1920 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1921 | + } |
|
1922 | + if(!empty($border_i)){ |
|
1923 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1924 | + } |
|
1925 | + |
|
1926 | + // add any fill color rules |
|
1927 | + if(!empty($fill)){ |
|
1928 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1929 | + } |
|
1930 | + if(!empty($fill_i)){ |
|
1931 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1932 | + } |
|
1933 | + |
|
1934 | + |
|
1935 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1936 | + |
|
1937 | + // darken |
|
1938 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1939 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1940 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1941 | + |
|
1942 | + // lighten |
|
1943 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1944 | + |
|
1945 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1946 | + $op_25 = $color_code."40"; // 25% opacity |
|
1947 | + |
|
2338 | 1948 | |
2339 | - $day_s3 = array(); |
|
2340 | - $day_s5 = array(); |
|
1949 | + // button states |
|
1950 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1951 | + $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;} "; |
|
1952 | + $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.";} "; |
|
1953 | + $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;} "; |
|
2341 | 1954 | |
2342 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
2343 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2344 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2345 | - } |
|
2346 | 1955 | |
2347 | - $month_s = array(); |
|
2348 | - $month_long = array(); |
|
1956 | + // dropdown's |
|
1957 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
2349 | 1958 | |
2350 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
2351 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2352 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2353 | - } |
|
2354 | 1959 | |
2355 | - ob_start(); |
|
2356 | - if ( 0 ) { ?><script><?php } ?> |
|
1960 | + // input states |
|
1961 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1962 | + |
|
1963 | + // page link |
|
1964 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1965 | + |
|
1966 | + return $output; |
|
1967 | + } |
|
1968 | + |
|
1969 | + /** |
|
1970 | + * |
|
1971 | + * @deprecated 0.1.76 Use css_overwrite() |
|
1972 | + * |
|
1973 | + * @param $color_code |
|
1974 | + * @param $compatibility |
|
1975 | + * |
|
1976 | + * @return string |
|
1977 | + */ |
|
1978 | + public static function css_secondary($color_code,$compatibility){; |
|
1979 | + $color_code = sanitize_hex_color($color_code); |
|
1980 | + if(!$color_code){return '';} |
|
1981 | + /** |
|
1982 | + * c = color, b = background color, o = border-color, f = fill |
|
1983 | + */ |
|
1984 | + $selectors = array( |
|
1985 | + '.btn-secondary' => array('b','o'), |
|
1986 | + '.btn-secondary.disabled' => array('b','o'), |
|
1987 | + '.btn-secondary:disabled' => array('b','o'), |
|
1988 | + '.btn-outline-secondary' => array('c','o'), |
|
1989 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
1990 | + '.btn-outline-secondary.disabled' => array('c'), |
|
1991 | + '.btn-outline-secondary:disabled' => array('c'), |
|
1992 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1993 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1994 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1995 | + '.badge-secondary' => array('b'), |
|
1996 | + '.alert-secondary' => array('b','o'), |
|
1997 | + '.btn-link.btn-secondary' => array('c'), |
|
1998 | + ); |
|
1999 | + |
|
2000 | + $important_selectors = array( |
|
2001 | + '.bg-secondary' => array('b','f'), |
|
2002 | + '.border-secondary' => array('o'), |
|
2003 | + '.text-secondary' => array('c'), |
|
2004 | + ); |
|
2005 | + |
|
2006 | + $color = array(); |
|
2007 | + $color_i = array(); |
|
2008 | + $background = array(); |
|
2009 | + $background_i = array(); |
|
2010 | + $border = array(); |
|
2011 | + $border_i = array(); |
|
2012 | + $fill = array(); |
|
2013 | + $fill_i = array(); |
|
2014 | + |
|
2015 | + $output = ''; |
|
2016 | + |
|
2017 | + // build rules into each type |
|
2018 | + foreach($selectors as $selector => $types){ |
|
2019 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2020 | + $types = array_combine($types,$types); |
|
2021 | + if(isset($types['c'])){$color[] = $selector;} |
|
2022 | + if(isset($types['b'])){$background[] = $selector;} |
|
2023 | + if(isset($types['o'])){$border[] = $selector;} |
|
2024 | + if(isset($types['f'])){$fill[] = $selector;} |
|
2025 | + } |
|
2026 | + |
|
2027 | + // build rules into each type |
|
2028 | + foreach($important_selectors as $selector => $types){ |
|
2029 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2030 | + $types = array_combine($types,$types); |
|
2031 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
2032 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
2033 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
2034 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
2035 | + } |
|
2036 | + |
|
2037 | + // add any color rules |
|
2038 | + if(!empty($color)){ |
|
2039 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
2040 | + } |
|
2041 | + if(!empty($color_i)){ |
|
2042 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
2043 | + } |
|
2044 | + |
|
2045 | + // add any background color rules |
|
2046 | + if(!empty($background)){ |
|
2047 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
2048 | + } |
|
2049 | + if(!empty($background_i)){ |
|
2050 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
2051 | + } |
|
2052 | + |
|
2053 | + // add any border color rules |
|
2054 | + if(!empty($border)){ |
|
2055 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
2056 | + } |
|
2057 | + if(!empty($border_i)){ |
|
2058 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
2059 | + } |
|
2060 | + |
|
2061 | + // add any fill color rules |
|
2062 | + if(!empty($fill)){ |
|
2063 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
2064 | + } |
|
2065 | + if(!empty($fill_i)){ |
|
2066 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
2067 | + } |
|
2068 | + |
|
2069 | + |
|
2070 | + $prefix = $compatibility ? ".bsui " : ""; |
|
2071 | + |
|
2072 | + // darken |
|
2073 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
2074 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
2075 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
2076 | + |
|
2077 | + // lighten |
|
2078 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
2079 | + |
|
2080 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
2081 | + $op_25 = $color_code."40"; // 25% opacity |
|
2082 | + |
|
2083 | + |
|
2084 | + // button states |
|
2085 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
2086 | + $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;} "; |
|
2087 | + $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.";} "; |
|
2088 | + $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;} "; |
|
2089 | + |
|
2090 | + |
|
2091 | + return $output; |
|
2092 | + } |
|
2093 | + |
|
2094 | + /** |
|
2095 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
2096 | + * |
|
2097 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
2098 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
2099 | + * |
|
2100 | + * @return string |
|
2101 | + */ |
|
2102 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
2103 | + $hexCode = ltrim($hexCode, '#'); |
|
2104 | + |
|
2105 | + if (strlen($hexCode) == 3) { |
|
2106 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
2107 | + } |
|
2108 | + |
|
2109 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
2110 | + |
|
2111 | + foreach ($hexCode as & $color) { |
|
2112 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
2113 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
2114 | + |
|
2115 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
2116 | + } |
|
2117 | + |
|
2118 | + return '#' . implode($hexCode); |
|
2119 | + } |
|
2120 | + |
|
2121 | + /** |
|
2122 | + * Check if we should display examples. |
|
2123 | + */ |
|
2124 | + public function maybe_show_examples(){ |
|
2125 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
2126 | + echo "<head>"; |
|
2127 | + wp_head(); |
|
2128 | + echo "</head>"; |
|
2129 | + echo "<body>"; |
|
2130 | + echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2131 | + echo "</body>"; |
|
2132 | + exit; |
|
2133 | + } |
|
2134 | + } |
|
2135 | + |
|
2136 | + /** |
|
2137 | + * Get developer examples. |
|
2138 | + * |
|
2139 | + * @return string |
|
2140 | + */ |
|
2141 | + public function get_examples(){ |
|
2142 | + $output = ''; |
|
2143 | + |
|
2144 | + |
|
2145 | + // open form |
|
2146 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
2147 | + |
|
2148 | + // input example |
|
2149 | + $output .= aui()->input(array( |
|
2150 | + 'type' => 'text', |
|
2151 | + 'id' => 'text-example', |
|
2152 | + 'name' => 'text-example', |
|
2153 | + 'placeholder' => 'text placeholder', |
|
2154 | + 'title' => 'Text input example', |
|
2155 | + 'value' => '', |
|
2156 | + 'required' => false, |
|
2157 | + 'help_text' => 'help text', |
|
2158 | + 'label' => 'Text input example label' |
|
2159 | + )); |
|
2160 | + |
|
2161 | + // input example |
|
2162 | + $output .= aui()->input(array( |
|
2163 | + 'type' => 'url', |
|
2164 | + 'id' => 'text-example2', |
|
2165 | + 'name' => 'text-example', |
|
2166 | + 'placeholder' => 'url placeholder', |
|
2167 | + 'title' => 'Text input example', |
|
2168 | + 'value' => '', |
|
2169 | + 'required' => false, |
|
2170 | + 'help_text' => 'help text', |
|
2171 | + 'label' => 'Text input example label' |
|
2172 | + )); |
|
2173 | + |
|
2174 | + // checkbox example |
|
2175 | + $output .= aui()->input(array( |
|
2176 | + 'type' => 'checkbox', |
|
2177 | + 'id' => 'checkbox-example', |
|
2178 | + 'name' => 'checkbox-example', |
|
2179 | + 'placeholder' => 'checkbox-example', |
|
2180 | + 'title' => 'Checkbox example', |
|
2181 | + 'value' => '1', |
|
2182 | + 'checked' => true, |
|
2183 | + 'required' => false, |
|
2184 | + 'help_text' => 'help text', |
|
2185 | + 'label' => 'Checkbox checked' |
|
2186 | + )); |
|
2187 | + |
|
2188 | + // checkbox example |
|
2189 | + $output .= aui()->input(array( |
|
2190 | + 'type' => 'checkbox', |
|
2191 | + 'id' => 'checkbox-example2', |
|
2192 | + 'name' => 'checkbox-example2', |
|
2193 | + 'placeholder' => 'checkbox-example', |
|
2194 | + 'title' => 'Checkbox example', |
|
2195 | + 'value' => '1', |
|
2196 | + 'checked' => false, |
|
2197 | + 'required' => false, |
|
2198 | + 'help_text' => 'help text', |
|
2199 | + 'label' => 'Checkbox un-checked' |
|
2200 | + )); |
|
2201 | + |
|
2202 | + // switch example |
|
2203 | + $output .= aui()->input(array( |
|
2204 | + 'type' => 'checkbox', |
|
2205 | + 'id' => 'switch-example', |
|
2206 | + 'name' => 'switch-example', |
|
2207 | + 'placeholder' => 'checkbox-example', |
|
2208 | + 'title' => 'Switch example', |
|
2209 | + 'value' => '1', |
|
2210 | + 'checked' => true, |
|
2211 | + 'switch' => true, |
|
2212 | + 'required' => false, |
|
2213 | + 'help_text' => 'help text', |
|
2214 | + 'label' => 'Switch on' |
|
2215 | + )); |
|
2216 | + |
|
2217 | + // switch example |
|
2218 | + $output .= aui()->input(array( |
|
2219 | + 'type' => 'checkbox', |
|
2220 | + 'id' => 'switch-example2', |
|
2221 | + 'name' => 'switch-example2', |
|
2222 | + 'placeholder' => 'checkbox-example', |
|
2223 | + 'title' => 'Switch example', |
|
2224 | + 'value' => '1', |
|
2225 | + 'checked' => false, |
|
2226 | + 'switch' => true, |
|
2227 | + 'required' => false, |
|
2228 | + 'help_text' => 'help text', |
|
2229 | + 'label' => 'Switch off' |
|
2230 | + )); |
|
2231 | + |
|
2232 | + // close form |
|
2233 | + $output .= "</form>"; |
|
2234 | + |
|
2235 | + return $output; |
|
2236 | + } |
|
2237 | + |
|
2238 | + /** |
|
2239 | + * Calendar params. |
|
2240 | + * |
|
2241 | + * @since 0.1.44 |
|
2242 | + * |
|
2243 | + * @return array Calendar params. |
|
2244 | + */ |
|
2245 | + public static function calendar_params() { |
|
2246 | + $params = array( |
|
2247 | + 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
2248 | + 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
2249 | + 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
2250 | + 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
2251 | + 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
2252 | + 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
2253 | + 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
2254 | + 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
2255 | + 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
2256 | + 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
2257 | + 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
2258 | + 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
2259 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
2260 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
2261 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
2262 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
2263 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
2264 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
2265 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
2266 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
2267 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
2268 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
2269 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
2270 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
2271 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
2272 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
2273 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
2274 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
2275 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
2276 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
2277 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
2278 | + 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
2279 | + 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
2280 | + 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
2281 | + 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
2282 | + 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
2283 | + 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
2284 | + 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
2285 | + 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
2286 | + 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
2287 | + 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
2288 | + 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
2289 | + 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
2290 | + 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
2291 | + 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
2292 | + 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
2293 | + 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
2294 | + 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
2295 | + 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
2296 | + 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
2297 | + 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
2298 | + 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
2299 | + 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
2300 | + 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
2301 | + 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
2302 | + 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
2303 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
2304 | + 'time_24hr' => false, |
|
2305 | + 'year' => __( 'Year', 'ayecode-connect' ), |
|
2306 | + 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
2307 | + 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
2308 | + 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
2309 | + 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
2310 | + 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
2311 | + 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
2312 | + ); |
|
2313 | + |
|
2314 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
2315 | + } |
|
2316 | + |
|
2317 | + /** |
|
2318 | + * Flatpickr calendar localize. |
|
2319 | + * |
|
2320 | + * @since 0.1.44 |
|
2321 | + * |
|
2322 | + * @return string Calendar locale. |
|
2323 | + */ |
|
2324 | + public static function flatpickr_locale() { |
|
2325 | + $params = self::calendar_params(); |
|
2326 | + |
|
2327 | + if ( is_string( $params ) ) { |
|
2328 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
2329 | + } else { |
|
2330 | + foreach ( (array) $params as $key => $value ) { |
|
2331 | + if ( ! is_scalar( $value ) ) { |
|
2332 | + continue; |
|
2333 | + } |
|
2334 | + |
|
2335 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2336 | + } |
|
2337 | + } |
|
2338 | + |
|
2339 | + $day_s3 = array(); |
|
2340 | + $day_s5 = array(); |
|
2341 | + |
|
2342 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
2343 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2344 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2345 | + } |
|
2346 | + |
|
2347 | + $month_s = array(); |
|
2348 | + $month_long = array(); |
|
2349 | + |
|
2350 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
2351 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2352 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2353 | + } |
|
2354 | + |
|
2355 | + ob_start(); |
|
2356 | + if ( 0 ) { ?><script><?php } ?> |
|
2357 | 2357 | { |
2358 | 2358 | weekdays: { |
2359 | 2359 | shorthand: ['<?php echo implode( "','", $day_s3 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
@@ -2392,189 +2392,189 @@ discard block |
||
2392 | 2392 | } |
2393 | 2393 | <?php if ( 0 ) { ?></script><?php } ?> |
2394 | 2394 | <?php |
2395 | - $locale = ob_get_clean(); |
|
2396 | - |
|
2397 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2398 | - } |
|
2399 | - |
|
2400 | - /** |
|
2401 | - * Select2 JS params. |
|
2402 | - * |
|
2403 | - * @since 0.1.44 |
|
2404 | - * |
|
2405 | - * @return array Select2 JS params. |
|
2406 | - */ |
|
2407 | - public static function select2_params() { |
|
2408 | - $params = array( |
|
2409 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
2410 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
2411 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
2412 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2413 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2414 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
2415 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
2416 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
2417 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
2418 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
2419 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
2420 | - ); |
|
2421 | - |
|
2422 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2423 | - } |
|
2424 | - |
|
2425 | - /** |
|
2426 | - * Select2 JS localize. |
|
2427 | - * |
|
2428 | - * @since 0.1.44 |
|
2429 | - * |
|
2430 | - * @return string Select2 JS locale. |
|
2431 | - */ |
|
2432 | - public static function select2_locale() { |
|
2433 | - $params = self::select2_params(); |
|
2434 | - |
|
2435 | - foreach ( (array) $params as $key => $value ) { |
|
2436 | - if ( ! is_scalar( $value ) ) { |
|
2437 | - continue; |
|
2438 | - } |
|
2395 | + $locale = ob_get_clean(); |
|
2439 | 2396 | |
2440 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2441 | - } |
|
2442 | - |
|
2443 | - $locale = json_encode( $params ); |
|
2444 | - |
|
2445 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2446 | - } |
|
2447 | - |
|
2448 | - /** |
|
2449 | - * Time ago JS localize. |
|
2450 | - * |
|
2451 | - * @since 0.1.47 |
|
2452 | - * |
|
2453 | - * @return string Time ago JS locale. |
|
2454 | - */ |
|
2455 | - public static function timeago_locale() { |
|
2456 | - $params = array( |
|
2457 | - 'prefix_ago' => '', |
|
2458 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
2459 | - 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
2460 | - 'suffix_after' => '', |
|
2461 | - 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
2462 | - 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
2463 | - 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
2464 | - 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
2465 | - 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
2466 | - 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
2467 | - 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
2468 | - 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
2469 | - 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
2470 | - 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
2471 | - 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
2472 | - ); |
|
2473 | - |
|
2474 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2475 | - |
|
2476 | - foreach ( (array) $params as $key => $value ) { |
|
2477 | - if ( ! is_scalar( $value ) ) { |
|
2478 | - continue; |
|
2479 | - } |
|
2397 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2398 | + } |
|
2399 | + |
|
2400 | + /** |
|
2401 | + * Select2 JS params. |
|
2402 | + * |
|
2403 | + * @since 0.1.44 |
|
2404 | + * |
|
2405 | + * @return array Select2 JS params. |
|
2406 | + */ |
|
2407 | + public static function select2_params() { |
|
2408 | + $params = array( |
|
2409 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
2410 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
2411 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
2412 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2413 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2414 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
2415 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
2416 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
2417 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
2418 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
2419 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
2420 | + ); |
|
2421 | + |
|
2422 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2423 | + } |
|
2424 | + |
|
2425 | + /** |
|
2426 | + * Select2 JS localize. |
|
2427 | + * |
|
2428 | + * @since 0.1.44 |
|
2429 | + * |
|
2430 | + * @return string Select2 JS locale. |
|
2431 | + */ |
|
2432 | + public static function select2_locale() { |
|
2433 | + $params = self::select2_params(); |
|
2434 | + |
|
2435 | + foreach ( (array) $params as $key => $value ) { |
|
2436 | + if ( ! is_scalar( $value ) ) { |
|
2437 | + continue; |
|
2438 | + } |
|
2439 | + |
|
2440 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2441 | + } |
|
2442 | + |
|
2443 | + $locale = json_encode( $params ); |
|
2444 | + |
|
2445 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2446 | + } |
|
2447 | + |
|
2448 | + /** |
|
2449 | + * Time ago JS localize. |
|
2450 | + * |
|
2451 | + * @since 0.1.47 |
|
2452 | + * |
|
2453 | + * @return string Time ago JS locale. |
|
2454 | + */ |
|
2455 | + public static function timeago_locale() { |
|
2456 | + $params = array( |
|
2457 | + 'prefix_ago' => '', |
|
2458 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
2459 | + 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
2460 | + 'suffix_after' => '', |
|
2461 | + 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
2462 | + 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
2463 | + 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
2464 | + 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
2465 | + 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
2466 | + 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
2467 | + 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
2468 | + 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
2469 | + 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
2470 | + 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
2471 | + 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
2472 | + ); |
|
2473 | + |
|
2474 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2475 | + |
|
2476 | + foreach ( (array) $params as $key => $value ) { |
|
2477 | + if ( ! is_scalar( $value ) ) { |
|
2478 | + continue; |
|
2479 | + } |
|
2480 | + |
|
2481 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2482 | + } |
|
2480 | 2483 | |
2481 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2482 | - } |
|
2483 | - |
|
2484 | - $locale = json_encode( $params ); |
|
2485 | - |
|
2486 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2487 | - } |
|
2488 | - |
|
2489 | - /** |
|
2490 | - * JavaScript Minifier |
|
2491 | - * |
|
2492 | - * @param $input |
|
2493 | - * |
|
2494 | - * @return mixed |
|
2495 | - */ |
|
2496 | - public static function minify_js($input) { |
|
2497 | - if(trim($input) === "") return $input; |
|
2498 | - return preg_replace( |
|
2499 | - array( |
|
2500 | - // Remove comment(s) |
|
2501 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2502 | - // Remove white-space(s) outside the string and regex |
|
2503 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2504 | - // Remove the last semicolon |
|
2505 | - '#;+\}#', |
|
2506 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2507 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2508 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
2509 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2510 | - ), |
|
2511 | - array( |
|
2512 | - '$1', |
|
2513 | - '$1$2', |
|
2514 | - '}', |
|
2515 | - '$1$3', |
|
2516 | - '$1.$3' |
|
2517 | - ), |
|
2518 | - $input); |
|
2519 | - } |
|
2520 | - |
|
2521 | - /** |
|
2522 | - * Minify CSS |
|
2523 | - * |
|
2524 | - * @param $input |
|
2525 | - * |
|
2526 | - * @return mixed |
|
2527 | - */ |
|
2528 | - public static function minify_css($input) { |
|
2529 | - if(trim($input) === "") return $input; |
|
2530 | - return preg_replace( |
|
2531 | - array( |
|
2532 | - // Remove comment(s) |
|
2533 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2534 | - // Remove unused white-space(s) |
|
2535 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2536 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2537 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2538 | - // Replace `:0 0 0 0` with `:0` |
|
2539 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2540 | - // Replace `background-position:0` with `background-position:0 0` |
|
2541 | - '#(background-position):0(?=[;\}])#si', |
|
2542 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2543 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2544 | - // Minify string value |
|
2545 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2546 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2547 | - // Minify HEX color code |
|
2548 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2549 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
2550 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2551 | - // Remove empty selector(s) |
|
2552 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2553 | - ), |
|
2554 | - array( |
|
2555 | - '$1', |
|
2556 | - '$1$2$3$4$5$6$7', |
|
2557 | - '$1', |
|
2558 | - ':0', |
|
2559 | - '$1:0 0', |
|
2560 | - '.$1', |
|
2561 | - '$1$3', |
|
2562 | - '$1$2$4$5', |
|
2563 | - '$1$2$3', |
|
2564 | - '$1:0', |
|
2565 | - '$1$2' |
|
2566 | - ), |
|
2567 | - $input); |
|
2568 | - } |
|
2569 | - |
|
2570 | - /** |
|
2571 | - * Get the conditional fields JavaScript. |
|
2572 | - * |
|
2573 | - * @return mixed |
|
2574 | - */ |
|
2575 | - public function conditional_fields_js() { |
|
2576 | - ob_start(); |
|
2577 | - ?> |
|
2484 | + $locale = json_encode( $params ); |
|
2485 | + |
|
2486 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2487 | + } |
|
2488 | + |
|
2489 | + /** |
|
2490 | + * JavaScript Minifier |
|
2491 | + * |
|
2492 | + * @param $input |
|
2493 | + * |
|
2494 | + * @return mixed |
|
2495 | + */ |
|
2496 | + public static function minify_js($input) { |
|
2497 | + if(trim($input) === "") return $input; |
|
2498 | + return preg_replace( |
|
2499 | + array( |
|
2500 | + // Remove comment(s) |
|
2501 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2502 | + // Remove white-space(s) outside the string and regex |
|
2503 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2504 | + // Remove the last semicolon |
|
2505 | + '#;+\}#', |
|
2506 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2507 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2508 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
2509 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2510 | + ), |
|
2511 | + array( |
|
2512 | + '$1', |
|
2513 | + '$1$2', |
|
2514 | + '}', |
|
2515 | + '$1$3', |
|
2516 | + '$1.$3' |
|
2517 | + ), |
|
2518 | + $input); |
|
2519 | + } |
|
2520 | + |
|
2521 | + /** |
|
2522 | + * Minify CSS |
|
2523 | + * |
|
2524 | + * @param $input |
|
2525 | + * |
|
2526 | + * @return mixed |
|
2527 | + */ |
|
2528 | + public static function minify_css($input) { |
|
2529 | + if(trim($input) === "") return $input; |
|
2530 | + return preg_replace( |
|
2531 | + array( |
|
2532 | + // Remove comment(s) |
|
2533 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2534 | + // Remove unused white-space(s) |
|
2535 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2536 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2537 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2538 | + // Replace `:0 0 0 0` with `:0` |
|
2539 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2540 | + // Replace `background-position:0` with `background-position:0 0` |
|
2541 | + '#(background-position):0(?=[;\}])#si', |
|
2542 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2543 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2544 | + // Minify string value |
|
2545 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2546 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2547 | + // Minify HEX color code |
|
2548 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2549 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
2550 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2551 | + // Remove empty selector(s) |
|
2552 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2553 | + ), |
|
2554 | + array( |
|
2555 | + '$1', |
|
2556 | + '$1$2$3$4$5$6$7', |
|
2557 | + '$1', |
|
2558 | + ':0', |
|
2559 | + '$1:0 0', |
|
2560 | + '.$1', |
|
2561 | + '$1$3', |
|
2562 | + '$1$2$4$5', |
|
2563 | + '$1$2$3', |
|
2564 | + '$1:0', |
|
2565 | + '$1$2' |
|
2566 | + ), |
|
2567 | + $input); |
|
2568 | + } |
|
2569 | + |
|
2570 | + /** |
|
2571 | + * Get the conditional fields JavaScript. |
|
2572 | + * |
|
2573 | + * @return mixed |
|
2574 | + */ |
|
2575 | + public function conditional_fields_js() { |
|
2576 | + ob_start(); |
|
2577 | + ?> |
|
2578 | 2578 | <script> |
2579 | 2579 | /** |
2580 | 2580 | * Conditional Fields |
@@ -3095,14 +3095,14 @@ discard block |
||
3095 | 3095 | <?php do_action( 'aui_conditional_fields_js', $this ); ?> |
3096 | 3096 | </script> |
3097 | 3097 | <?php |
3098 | - $output = ob_get_clean(); |
|
3098 | + $output = ob_get_clean(); |
|
3099 | 3099 | |
3100 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
3101 | - } |
|
3102 | - } |
|
3100 | + return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
3101 | + } |
|
3102 | + } |
|
3103 | 3103 | |
3104 | - /** |
|
3105 | - * Run the class if found. |
|
3106 | - */ |
|
3107 | - AyeCode_UI_Settings::instance(); |
|
3104 | + /** |
|
3105 | + * Run the class if found. |
|
3106 | + */ |
|
3107 | + AyeCode_UI_Settings::instance(); |
|
3108 | 3108 | } |
3109 | 3109 | \ No newline at end of file |
@@ -12,14 +12,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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>'. wp_kses_post( $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>' . wp_kses_post($message) . '</p></div>'; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
@@ -372,14 +372,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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', |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}"; |
804 | 804 | |
805 | 805 | // Execute the query |
806 | - $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
806 | + $date = $wpdb->get_var($query); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
807 | 807 | |
808 | 808 | return $date ? $date : false; |
809 | 809 | } |
@@ -811,11 +811,11 @@ discard block |
||
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>'. wp_kses_post( $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>' . wp_kses_post($message) . '</p></div>'; |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | /** |
@@ -825,32 +825,32 @@ discard block |
||
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 |
||
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 |
||
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( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) ); |
|
878 | + if (!current_user_can('manage_options')) { |
|
879 | + wp_die(esc_attr__('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 | - <h1><?php echo esc_attr( $this->name ); ?></h1> |
|
886 | - <p><?php echo esc_html( apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) ) );?></p> |
|
885 | + <h1><?php echo esc_attr($this->name); ?></h1> |
|
886 | + <p><?php echo esc_html(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 esc_html_e( 'BootStrap Version', 'ayecode-connect' ); ?></h2> |
|
894 | - <p><?php echo esc_html( 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 esc_html_e('BootStrap Version', 'ayecode-connect'); ?></h2> |
|
894 | + <p><?php echo esc_html(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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
898 | 898 | 'type'=> 'info', |
899 | - 'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' ) |
|
899 | + 'content'=> esc_attr__("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 esc_html_e( 'Version', 'ayecode-connect' ); ?></label></th> |
|
906 | + <th scope="row"><label for="wpbs-css"><?php esc_html_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 esc_html_e( 'v5 (recommended)', 'ayecode-connect' ); ?></option> |
|
910 | - <option value="4" <?php selected( $this->settings['bs_ver'], '4' ); ?>><?php esc_html_e( 'v4 (legacy)', 'ayecode-connect' ); ?></option> |
|
909 | + <option value="5" <?php selected($this->settings['bs_ver'], '5'); ?>><?php esc_html_e('v5 (recommended)', 'ayecode-connect'); ?></option> |
|
910 | + <option value="4" <?php selected($this->settings['bs_ver'], '4'); ?>><?php esc_html_e('v4 (legacy)', 'ayecode-connect'); ?></option> |
|
911 | 911 | </select> |
912 | 912 | </td> |
913 | 913 | </tr> |
914 | 914 | </table> |
915 | 915 | |
916 | - <h2><?php esc_html_e( 'Frontend', 'ayecode-connect' ); ?></h2> |
|
916 | + <h2><?php esc_html_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 esc_html_e( 'Load CSS', 'ayecode-connect' ); ?></label></th> |
|
919 | + <th scope="row"><label for="wpbs-css"><?php esc_html_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 esc_html_e( 'Compatibility Mode (default)', 'ayecode-connect' ); ?></option> |
|
923 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php esc_html_e( 'Full Mode', 'ayecode-connect' ); ?></option> |
|
924 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php esc_html_e( 'Disabled', 'ayecode-connect' ); ?></option> |
|
922 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php esc_html_e('Compatibility Mode (default)', 'ayecode-connect'); ?></option> |
|
923 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php esc_html_e('Full Mode', 'ayecode-connect'); ?></option> |
|
924 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php esc_html_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 esc_html_e( 'Load JS', 'ayecode-connect' ); ?></label></th> |
|
930 | + <th scope="row"><label for="wpbs-js"><?php esc_html_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 esc_html_e( 'Core + Popper (default)', 'ayecode-connect' ); ?></option> |
|
934 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php esc_html_e( 'Popper', 'ayecode-connect' ); ?></option> |
|
935 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php esc_html_e( 'Required functions only', 'ayecode-connect' ); ?></option> |
|
936 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php esc_html_e( 'Disabled (not recommended)', 'ayecode-connect' ); ?></option> |
|
933 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php esc_html_e('Core + Popper (default)', 'ayecode-connect'); ?></option> |
|
934 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php esc_html_e('Popper', 'ayecode-connect'); ?></option> |
|
935 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php esc_html_e('Required functions only', 'ayecode-connect'); ?></option> |
|
936 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php esc_html_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 esc_html_e( 'HTML Font Size (px)', 'ayecode-connect' ); ?></label></th> |
|
942 | + <th scope="row"><label for="wpbs-font_size"><?php esc_html_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 esc_html_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 esc_html_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 esc_html_e( 'Backend', 'ayecode-connect' ); ?> (wp-admin)</h2> |
|
951 | + <h2><?php esc_html_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 esc_html_e( 'Load CSS', 'ayecode-connect' ); ?></label></th> |
|
954 | + <th scope="row"><label for="wpbs-css-admin"><?php esc_html_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 esc_html_e( 'Compatibility Mode (default)', 'ayecode-connect' ); ?></option> |
|
958 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php esc_html_e( 'Full Mode (will cause style issues)', 'ayecode-connect' ); ?></option> |
|
959 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php esc_html_e( 'Disabled', 'ayecode-connect' ); ?></option> |
|
957 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php esc_html_e('Compatibility Mode (default)', 'ayecode-connect'); ?></option> |
|
958 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php esc_html_e('Full Mode (will cause style issues)', 'ayecode-connect'); ?></option> |
|
959 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php esc_html_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 esc_html_e( 'Load JS', 'ayecode-connect' ); ?></label></th> |
|
965 | + <th scope="row"><label for="wpbs-js-admin"><?php esc_html_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 esc_html_e( 'Core + Popper (default)', 'ayecode-connect' ); ?></option> |
|
969 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php esc_html_e( 'Popper', 'ayecode-connect' ); ?></option> |
|
970 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php esc_html_e( 'Required functions only', 'ayecode-connect' ); ?></option> |
|
971 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php esc_html_e( 'Disabled (not recommended)', 'ayecode-connect' ); ?></option> |
|
968 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php esc_html_e('Core + Popper (default)', 'ayecode-connect'); ?></option> |
|
969 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php esc_html_e('Popper', 'ayecode-connect'); ?></option> |
|
970 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php esc_html_e('Required functions only', 'ayecode-connect'); ?></option> |
|
971 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php esc_html_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 esc_html_e( 'Disable load on URL', 'ayecode-connect' ); ?></label></th> |
|
977 | + <th scope="row"><label for="wpbs-disable-admin"><?php esc_html_e('Disable load on URL', 'ayecode-connect'); ?></label></th> |
|
978 | 978 | <td> |
979 | - <p><?php esc_html_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 action=go"><?php echo esc_textarea( $this->settings['disable_admin'] );?></textarea> |
|
979 | + <p><?php esc_html_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 action=go"><?php echo esc_textarea($this->settings['disable_admin']); ?></textarea> |
|
981 | 981 | </td> |
982 | 982 | </tr> |
983 | 983 | </table> |
@@ -986,33 +986,33 @@ discard block |
||
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 esc_html( $this->version ); ?></div> |
|
989 | + <div id="wpbs-version" data-aui-source="<?php echo esc_attr($this->get_load_source()); ?>"><?php echo esc_html($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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
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); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1149 | + echo $aui_bs5 ? self::css_overwrite_bs5($key, $var, $compat, $color) : self::css_overwrite($key, $var, $compat, $color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1150 | 1150 | } |
1151 | 1151 | } |
1152 | 1152 | // exit; |
@@ -1155,71 +1155,71 @@ discard block |
||
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){ |
|
1222 | - echo $is_fse ? 'body.editor-styles-wrapper{' . esc_attr( $css ) . '}' : 'body{' . esc_attr( $css ) . '}'; |
|
1221 | + if ($css) { |
|
1222 | + echo $is_fse ? 'body.editor-styles-wrapper{' . esc_attr($css) . '}' : 'body{' . esc_attr($css) . '}'; |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | $bep = $is_fse ? 'body.editor-styles-wrapper ' : ''; |
@@ -1227,42 +1227,42 @@ discard block |
||
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 ){ |
|
1245 | - echo "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . esc_attr( $headings_css ) . "}"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1244 | + if ($headings_css) { |
|
1245 | + echo "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . esc_attr($headings_css) . "}"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
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 esc_attr( $bep . $hn ) . '{'.esc_attr( $h_css ).'}'; |
|
1264 | + if ($h_css) { |
|
1265 | + echo esc_attr($bep . $hn) . '{' . esc_attr($h_css) . '}'; |
|
1266 | 1266 | } |
1267 | 1267 | } |
1268 | 1268 | |
@@ -1275,10 +1275,10 @@ discard block |
||
1275 | 1275 | /* |
1276 | 1276 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1277 | 1277 | */ |
1278 | - return str_replace( array( |
|
1278 | + return str_replace(array( |
|
1279 | 1279 | '<style>', |
1280 | 1280 | '</style>' |
1281 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1281 | + ), '', self::minify_css(ob_get_clean())); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | * |
1289 | 1289 | * @return bool |
1290 | 1290 | */ |
1291 | - public static function is_bs3_compat(){ |
|
1291 | + public static function is_bs3_compat() { |
|
1292 | 1292 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
1293 | 1293 | } |
1294 | 1294 | |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | $hex = str_replace('#', '', $hex); |
1298 | 1298 | |
1299 | 1299 | // Convert 3-digit hex to 6-digit hex |
1300 | - if(strlen($hex) == 3) { |
|
1300 | + if (strlen($hex) == 3) { |
|
1301 | 1301 | $hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2); |
1302 | 1302 | } |
1303 | 1303 | |
@@ -1319,13 +1319,13 @@ discard block |
||
1319 | 1319 | * |
1320 | 1320 | * @return string |
1321 | 1321 | */ |
1322 | - public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
1322 | + public static function css_overwrite_bs5($type, $color_code, $compatibility, $hex = '') { |
|
1323 | 1323 | global $aui_bs5; |
1324 | 1324 | |
1325 | 1325 | $is_var = false; |
1326 | 1326 | $is_custom = strpos($type, 'custom-') !== false ? true : false; |
1327 | - if(!$color_code){return '';} |
|
1328 | - if(strpos($color_code, 'var') !== false){ |
|
1327 | + if (!$color_code) {return ''; } |
|
1328 | + if (strpos($color_code, 'var') !== false) { |
|
1329 | 1329 | //if(!sanitize_hex_color($color_code)){ |
1330 | 1330 | $color_code = esc_attr($color_code); |
1331 | 1331 | $is_var = true; |
@@ -1335,15 +1335,15 @@ discard block |
||
1335 | 1335 | |
1336 | 1336 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
1337 | 1337 | |
1338 | - if(!$color_code){return '';} |
|
1338 | + if (!$color_code) {return ''; } |
|
1339 | 1339 | |
1340 | 1340 | $rgb = self::hex_to_rgb($hex); |
1341 | 1341 | |
1342 | - if($compatibility===true || $compatibility===1){ |
|
1342 | + if ($compatibility === true || $compatibility === 1) { |
|
1343 | 1343 | $compatibility = '.bsui'; |
1344 | - }elseif(!$compatibility){ |
|
1344 | + }elseif (!$compatibility) { |
|
1345 | 1345 | $compatibility = ''; |
1346 | - }else{ |
|
1346 | + } else { |
|
1347 | 1347 | $compatibility = esc_attr($compatibility); |
1348 | 1348 | } |
1349 | 1349 | |
@@ -1360,30 +1360,30 @@ discard block |
||
1360 | 1360 | * c = color, b = background color, o = border-color, f = fill |
1361 | 1361 | */ |
1362 | 1362 | $selectors = array( |
1363 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
1364 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1365 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1366 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1367 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1368 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1369 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1370 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1371 | - ".badge-{$type}" => array( 'b' ), |
|
1372 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
1373 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
1374 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
1375 | - ".text-{$type}" => array( 'c' ), |
|
1363 | + ".btn-{$type}" => array('b', 'o'), |
|
1364 | + ".btn-{$type}.disabled" => array('b', 'o'), |
|
1365 | + ".btn-{$type}:disabled" => array('b', 'o'), |
|
1366 | + ".btn-outline-{$type}" => array('c', 'o'), |
|
1367 | + ".btn-outline-{$type}:hover" => array('b', 'o'), |
|
1368 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'), |
|
1369 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'), |
|
1370 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array('b', 'o'), |
|
1371 | + ".badge-{$type}" => array('b'), |
|
1372 | + ".alert-{$type}" => array('b', 'o'), |
|
1373 | + ".bg-{$type}" => array('b', 'f'), |
|
1374 | + ".btn-link.btn-{$type}" => array('c'), |
|
1375 | + ".text-{$type}" => array('c'), |
|
1376 | 1376 | ); |
1377 | 1377 | |
1378 | - if ( $aui_bs5 ) { |
|
1379 | - unset($selectors[".alert-{$type}" ]); |
|
1378 | + if ($aui_bs5) { |
|
1379 | + unset($selectors[".alert-{$type}"]); |
|
1380 | 1380 | } |
1381 | 1381 | |
1382 | - if ( $type == 'primary' ) { |
|
1382 | + if ($type == 'primary') { |
|
1383 | 1383 | $selectors = $selectors + array( |
1384 | - 'a' => array( 'c' ), |
|
1385 | - '.btn-link' => array( 'c' ), |
|
1386 | - '.dropdown-item.active' => array( 'b' ), |
|
1384 | + 'a' => array('c'), |
|
1385 | + '.btn-link' => array('c'), |
|
1386 | + '.dropdown-item.active' => array('b'), |
|
1387 | 1387 | '.custom-control-input:checked~.custom-control-label::before' => array( |
1388 | 1388 | 'b', |
1389 | 1389 | 'o' |
@@ -1392,56 +1392,56 @@ discard block |
||
1392 | 1392 | 'b', |
1393 | 1393 | 'o' |
1394 | 1394 | ), |
1395 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
1396 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1397 | - '.page-link' => array( 'c' ), |
|
1395 | + '.nav-pills .nav-link.active' => array('b'), |
|
1396 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1397 | + '.page-link' => array('c'), |
|
1398 | 1398 | '.page-item.active .page-link' => array( |
1399 | 1399 | 'b', |
1400 | 1400 | 'o' |
1401 | 1401 | ), |
1402 | - '.progress-bar' => array( 'b' ), |
|
1402 | + '.progress-bar' => array('b'), |
|
1403 | 1403 | '.list-group-item.active' => array( |
1404 | 1404 | 'b', |
1405 | 1405 | 'o' |
1406 | 1406 | ), |
1407 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1407 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1408 | 1408 | ); |
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | |
1412 | 1412 | |
1413 | 1413 | // link |
1414 | - if ( $type === 'primary' ) { |
|
1415 | - $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
1416 | - $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
1417 | - $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).'; }'; |
|
1414 | + if ($type === 'primary') { |
|
1415 | + $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-' . esc_attr($type) . '-rgb), .75); --bs-link-color: var(--bs-' . esc_attr($type) . '); }'; |
|
1416 | + $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: ' . esc_attr($color_code) . '; }'; |
|
1417 | + $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) . '; }'; |
|
1418 | 1418 | |
1419 | - $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
1420 | - $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
1419 | + $output .= $prefix . ' a{color: var(--bs-' . esc_attr($type) . ');}'; |
|
1420 | + $output .= $prefix . ' .text-primary{color: var(--bs-' . esc_attr($type) . ') !important;}'; |
|
1421 | 1421 | |
1422 | 1422 | // dropdown |
1423 | - $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
1423 | + $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-' . esc_attr($type) . '); --bs-dropdown-link-active-color: var(--bs-' . esc_attr($type) . ');}'; |
|
1424 | 1424 | |
1425 | 1425 | // pagination |
1426 | - $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
1426 | + $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-' . esc_attr($type) . '); --bs-pagination-active-bg: var(--bs-' . esc_attr($type) . ');}'; |
|
1427 | 1427 | |
1428 | 1428 | } |
1429 | 1429 | |
1430 | - $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
1430 | + $output .= $prefix . ' .link-' . esc_attr($type) . ':hover {color: rgba(var(--bs-' . esc_attr($type) . '-rgb), .8) !important;}'; |
|
1431 | 1431 | |
1432 | 1432 | // buttons |
1433 | - $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
1433 | + $output .= $prefix . ' .btn-' . esc_attr($type) . '{'; |
|
1434 | 1434 | $output .= ' |
1435 | - --bs-btn-bg: '.esc_attr($color_code).'; |
|
1436 | - --bs-btn-border-color: '.esc_attr($color_code).'; |
|
1437 | - --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
|
1438 | - --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
|
1439 | - --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb; |
|
1440 | - --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
|
1441 | - --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
|
1435 | + --bs-btn-bg: '.esc_attr($color_code) . '; |
|
1436 | + --bs-btn-border-color: '.esc_attr($color_code) . '; |
|
1437 | + --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9); |
|
1438 | + --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9); |
|
1439 | + --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type) . '-rgb; |
|
1440 | + --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9); |
|
1441 | + --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9); |
|
1442 | 1442 | --bs-btn-active-shadow: unset; |
1443 | - --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5); |
|
1444 | - --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1); |
|
1443 | + --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .5); |
|
1444 | + --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .1); |
|
1445 | 1445 | '; |
1446 | 1446 | // $output .= ' |
1447 | 1447 | // --bs-btn-color: #fff; |
@@ -1452,17 +1452,17 @@ discard block |
||
1452 | 1452 | $output .= '}'; |
1453 | 1453 | |
1454 | 1454 | // buttons outline |
1455 | - $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
1455 | + $output .= $prefix . ' .btn-outline-' . esc_attr($type) . '{'; |
|
1456 | 1456 | $output .= ' |
1457 | - --bs-btn-border-color: '.esc_attr($color_code).'; |
|
1458 | - --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
|
1459 | - --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
|
1460 | - --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb; |
|
1461 | - --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
|
1462 | - --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
|
1457 | + --bs-btn-border-color: '.esc_attr($color_code) . '; |
|
1458 | + --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9); |
|
1459 | + --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9); |
|
1460 | + --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type) . '-rgb; |
|
1461 | + --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9); |
|
1462 | + --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9); |
|
1463 | 1463 | --bs-btn-active-shadow: unset; |
1464 | - --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5); |
|
1465 | - --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1); |
|
1464 | + --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .5); |
|
1465 | + --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .1); |
|
1466 | 1466 | '; |
1467 | 1467 | // $output .= ' |
1468 | 1468 | // --bs-btn-color: #fff; |
@@ -1474,32 +1474,32 @@ discard block |
||
1474 | 1474 | |
1475 | 1475 | |
1476 | 1476 | // button hover |
1477 | - $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
1477 | + $output .= $prefix . ' .btn-' . esc_attr($type) . ':hover{'; |
|
1478 | 1478 | $output .= ' |
1479 | - 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); |
|
1479 | + 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); |
|
1480 | 1480 | } |
1481 | 1481 | '; |
1482 | 1482 | |
1483 | 1483 | |
1484 | - if ( $aui_bs5 ) { |
|
1484 | + if ($aui_bs5) { |
|
1485 | 1485 | // $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).'; }'; |
1486 | - $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
1487 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1486 | + $output .= 'html body {--bs-' . esc_attr($type) . ': ' . esc_attr($color_code) . '; }'; |
|
1487 | + $output .= 'html body {--bs-' . esc_attr($type) . '-rgb: ' . $rgb . '; }'; |
|
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | |
1491 | - if ( $is_custom ) { |
|
1491 | + if ($is_custom) { |
|
1492 | 1492 | |
1493 | 1493 | // echo '###'.$type;exit; |
1494 | 1494 | |
1495 | 1495 | // build rules into each type |
1496 | - foreach($selectors as $selector => $types){ |
|
1497 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1498 | - $types = array_combine($types,$types); |
|
1499 | - if(isset($types['c'])){$color[] = $selector;} |
|
1500 | - if(isset($types['b'])){$background[] = $selector;} |
|
1501 | - if(isset($types['o'])){$border[] = $selector;} |
|
1502 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1496 | + foreach ($selectors as $selector => $types) { |
|
1497 | + $selector = $compatibility ? $compatibility . " " . $selector : $selector; |
|
1498 | + $types = array_combine($types, $types); |
|
1499 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1500 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1501 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1502 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | // // build rules into each type |
@@ -1513,36 +1513,36 @@ discard block |
||
1513 | 1513 | // } |
1514 | 1514 | |
1515 | 1515 | // add any color rules |
1516 | - if(!empty($color)){ |
|
1517 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1516 | + if (!empty($color)) { |
|
1517 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1518 | 1518 | } |
1519 | - if(!empty($color_i)){ |
|
1520 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1519 | + if (!empty($color_i)) { |
|
1520 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1521 | 1521 | } |
1522 | 1522 | |
1523 | 1523 | // add any background color rules |
1524 | - if(!empty($background)){ |
|
1525 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1524 | + if (!empty($background)) { |
|
1525 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1526 | 1526 | } |
1527 | - if(!empty($background_i)){ |
|
1528 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1527 | + if (!empty($background_i)) { |
|
1528 | + $output .= $aui_bs5 ? '' : implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1529 | 1529 | // $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
1530 | 1530 | } |
1531 | 1531 | |
1532 | 1532 | // add any border color rules |
1533 | - if(!empty($border)){ |
|
1534 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1533 | + if (!empty($border)) { |
|
1534 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1535 | 1535 | } |
1536 | - if(!empty($border_i)){ |
|
1537 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1536 | + if (!empty($border_i)) { |
|
1537 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1538 | 1538 | } |
1539 | 1539 | |
1540 | 1540 | // add any fill color rules |
1541 | - if(!empty($fill)){ |
|
1542 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1541 | + if (!empty($fill)) { |
|
1542 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1543 | 1543 | } |
1544 | - if(!empty($fill_i)){ |
|
1545 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1544 | + if (!empty($fill_i)) { |
|
1545 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | } |
@@ -1552,25 +1552,25 @@ discard block |
||
1552 | 1552 | |
1553 | 1553 | $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;' : ''; |
1554 | 1554 | // darken |
1555 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1556 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1557 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1558 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
1555 | + $darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1556 | + $darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1557 | + $darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1558 | + $darker_40 = $is_var ? $color_code . ';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code, "-0.4"); |
|
1559 | 1559 | |
1560 | 1560 | // lighten |
1561 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1561 | + $lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25"); |
|
1562 | 1562 | |
1563 | 1563 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1564 | - $op_25 = $color_code."40"; // 25% opacity |
|
1564 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1565 | 1565 | |
1566 | 1566 | |
1567 | 1567 | // button states |
1568 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1569 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1568 | + $output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : ''; |
|
1569 | + $output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1570 | 1570 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
1571 | - $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;} "; |
|
1572 | - $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.";} "; |
|
1573 | - $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;} "; |
|
1571 | + $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;} "; |
|
1572 | + $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 . ";} "; |
|
1573 | + $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;} "; |
|
1574 | 1574 | |
1575 | 1575 | // text |
1576 | 1576 | // $output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} "; |
@@ -1588,9 +1588,9 @@ discard block |
||
1588 | 1588 | // } |
1589 | 1589 | |
1590 | 1590 | // alerts |
1591 | - if ( $aui_bs5 ) { |
|
1591 | + if ($aui_bs5) { |
|
1592 | 1592 | // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
1593 | - $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;} "; |
|
1593 | + $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;} "; |
|
1594 | 1594 | } |
1595 | 1595 | |
1596 | 1596 | return $output; |
@@ -1605,12 +1605,12 @@ discard block |
||
1605 | 1605 | * |
1606 | 1606 | * @return string |
1607 | 1607 | */ |
1608 | - public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
1608 | + public static function css_overwrite($type, $color_code, $compatibility, $hex = '') { |
|
1609 | 1609 | global $aui_bs5; |
1610 | 1610 | |
1611 | 1611 | $is_var = false; |
1612 | - if(!$color_code){return '';} |
|
1613 | - if(strpos($color_code, 'var') !== false){ |
|
1612 | + if (!$color_code) {return ''; } |
|
1613 | + if (strpos($color_code, 'var') !== false) { |
|
1614 | 1614 | //if(!sanitize_hex_color($color_code)){ |
1615 | 1615 | $color_code = esc_attr($color_code); |
1616 | 1616 | $is_var = true; |
@@ -1620,15 +1620,15 @@ discard block |
||
1620 | 1620 | |
1621 | 1621 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
1622 | 1622 | |
1623 | - if(!$color_code){return '';} |
|
1623 | + if (!$color_code) {return ''; } |
|
1624 | 1624 | |
1625 | 1625 | $rgb = self::hex_to_rgb($hex); |
1626 | 1626 | |
1627 | - if($compatibility===true || $compatibility===1){ |
|
1627 | + if ($compatibility === true || $compatibility === 1) { |
|
1628 | 1628 | $compatibility = '.bsui'; |
1629 | - }elseif(!$compatibility){ |
|
1629 | + }elseif (!$compatibility) { |
|
1630 | 1630 | $compatibility = ''; |
1631 | - }else{ |
|
1631 | + } else { |
|
1632 | 1632 | $compatibility = esc_attr($compatibility); |
1633 | 1633 | } |
1634 | 1634 | |
@@ -1642,29 +1642,29 @@ discard block |
||
1642 | 1642 | * c = color, b = background color, o = border-color, f = fill |
1643 | 1643 | */ |
1644 | 1644 | $selectors = array( |
1645 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
1646 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1647 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1648 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1649 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1650 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1651 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1652 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1653 | - ".badge-{$type}" => array( 'b' ), |
|
1654 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
1655 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
1656 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
1645 | + ".btn-{$type}" => array('b', 'o'), |
|
1646 | + ".btn-{$type}.disabled" => array('b', 'o'), |
|
1647 | + ".btn-{$type}:disabled" => array('b', 'o'), |
|
1648 | + ".btn-outline-{$type}" => array('c', 'o'), |
|
1649 | + ".btn-outline-{$type}:hover" => array('b', 'o'), |
|
1650 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'), |
|
1651 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'), |
|
1652 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array('b', 'o'), |
|
1653 | + ".badge-{$type}" => array('b'), |
|
1654 | + ".alert-{$type}" => array('b', 'o'), |
|
1655 | + ".bg-{$type}" => array('b', 'f'), |
|
1656 | + ".btn-link.btn-{$type}" => array('c'), |
|
1657 | 1657 | ); |
1658 | 1658 | |
1659 | - if ( $aui_bs5 ) { |
|
1660 | - unset($selectors[".alert-{$type}" ]); |
|
1659 | + if ($aui_bs5) { |
|
1660 | + unset($selectors[".alert-{$type}"]); |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | - if ( $type == 'primary' ) { |
|
1663 | + if ($type == 'primary') { |
|
1664 | 1664 | $selectors = $selectors + array( |
1665 | - 'a' => array( 'c' ), |
|
1666 | - '.btn-link' => array( 'c' ), |
|
1667 | - '.dropdown-item.active' => array( 'b' ), |
|
1665 | + 'a' => array('c'), |
|
1666 | + '.btn-link' => array('c'), |
|
1667 | + '.dropdown-item.active' => array('b'), |
|
1668 | 1668 | '.custom-control-input:checked~.custom-control-label::before' => array( |
1669 | 1669 | 'b', |
1670 | 1670 | 'o' |
@@ -1673,19 +1673,19 @@ discard block |
||
1673 | 1673 | 'b', |
1674 | 1674 | 'o' |
1675 | 1675 | ), |
1676 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
1677 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1678 | - '.page-link' => array( 'c' ), |
|
1676 | + '.nav-pills .nav-link.active' => array('b'), |
|
1677 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1678 | + '.page-link' => array('c'), |
|
1679 | 1679 | '.page-item.active .page-link' => array( |
1680 | 1680 | 'b', |
1681 | 1681 | 'o' |
1682 | 1682 | ), |
1683 | - '.progress-bar' => array( 'b' ), |
|
1683 | + '.progress-bar' => array('b'), |
|
1684 | 1684 | '.list-group-item.active' => array( |
1685 | 1685 | 'b', |
1686 | 1686 | 'o' |
1687 | 1687 | ), |
1688 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1688 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1689 | 1689 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1690 | 1690 | // '.custom-range::-moz-range-thumb' => array('b'), |
1691 | 1691 | // '.custom-range::-ms-thumb' => array('b'), |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | } |
1694 | 1694 | |
1695 | 1695 | $important_selectors = array( |
1696 | - ".bg-{$type}" => array('b','f'), |
|
1696 | + ".bg-{$type}" => array('b', 'f'), |
|
1697 | 1697 | ".border-{$type}" => array('o'), |
1698 | 1698 | ".text-{$type}" => array('c'), |
1699 | 1699 | ); |
@@ -1709,62 +1709,62 @@ discard block |
||
1709 | 1709 | |
1710 | 1710 | $output = ''; |
1711 | 1711 | |
1712 | - if ( $aui_bs5 ) { |
|
1712 | + if ($aui_bs5) { |
|
1713 | 1713 | // $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).'; }'; |
1714 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1714 | + $output .= 'html body {--bs-' . esc_attr($type) . '-rgb: ' . $rgb . '; }'; |
|
1715 | 1715 | } |
1716 | 1716 | |
1717 | 1717 | // build rules into each type |
1718 | - foreach($selectors as $selector => $types){ |
|
1719 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1720 | - $types = array_combine($types,$types); |
|
1721 | - if(isset($types['c'])){$color[] = $selector;} |
|
1722 | - if(isset($types['b'])){$background[] = $selector;} |
|
1723 | - if(isset($types['o'])){$border[] = $selector;} |
|
1724 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1718 | + foreach ($selectors as $selector => $types) { |
|
1719 | + $selector = $compatibility ? $compatibility . " " . $selector : $selector; |
|
1720 | + $types = array_combine($types, $types); |
|
1721 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1722 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1723 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1724 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1725 | 1725 | } |
1726 | 1726 | |
1727 | 1727 | // build rules into each type |
1728 | - foreach($important_selectors as $selector => $types){ |
|
1729 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1730 | - $types = array_combine($types,$types); |
|
1731 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1732 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1733 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1734 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1728 | + foreach ($important_selectors as $selector => $types) { |
|
1729 | + $selector = $compatibility ? $compatibility . " " . $selector : $selector; |
|
1730 | + $types = array_combine($types, $types); |
|
1731 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1732 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1733 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1734 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1735 | 1735 | } |
1736 | 1736 | |
1737 | 1737 | // add any color rules |
1738 | - if(!empty($color)){ |
|
1739 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1738 | + if (!empty($color)) { |
|
1739 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1740 | 1740 | } |
1741 | - if(!empty($color_i)){ |
|
1742 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1741 | + if (!empty($color_i)) { |
|
1742 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1743 | 1743 | } |
1744 | 1744 | |
1745 | 1745 | // add any background color rules |
1746 | - if(!empty($background)){ |
|
1747 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1746 | + if (!empty($background)) { |
|
1747 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1748 | 1748 | } |
1749 | - if(!empty($background_i)){ |
|
1750 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1749 | + if (!empty($background_i)) { |
|
1750 | + $output .= $aui_bs5 ? '' : implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1751 | 1751 | // $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
1752 | 1752 | } |
1753 | 1753 | |
1754 | 1754 | // add any border color rules |
1755 | - if(!empty($border)){ |
|
1756 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1755 | + if (!empty($border)) { |
|
1756 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1757 | 1757 | } |
1758 | - if(!empty($border_i)){ |
|
1759 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1758 | + if (!empty($border_i)) { |
|
1759 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1760 | 1760 | } |
1761 | 1761 | |
1762 | 1762 | // add any fill color rules |
1763 | - if(!empty($fill)){ |
|
1764 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1763 | + if (!empty($fill)) { |
|
1764 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1765 | 1765 | } |
1766 | - if(!empty($fill_i)){ |
|
1767 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1766 | + if (!empty($fill_i)) { |
|
1767 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1768 | 1768 | } |
1769 | 1769 | |
1770 | 1770 | |
@@ -1772,27 +1772,27 @@ discard block |
||
1772 | 1772 | |
1773 | 1773 | $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;' : ''; |
1774 | 1774 | // darken |
1775 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1776 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1777 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1778 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
1775 | + $darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1776 | + $darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1777 | + $darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1778 | + $darker_40 = $is_var ? $color_code . ';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code, "-0.4"); |
|
1779 | 1779 | |
1780 | 1780 | // lighten |
1781 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1781 | + $lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25"); |
|
1782 | 1782 | |
1783 | 1783 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1784 | - $op_25 = $color_code."40"; // 25% opacity |
|
1784 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1785 | 1785 | |
1786 | 1786 | |
1787 | 1787 | // button states |
1788 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1789 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1788 | + $output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : ''; |
|
1789 | + $output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1790 | 1790 | // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
1791 | - $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;} "; |
|
1792 | - $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.";} "; |
|
1793 | - $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;} "; |
|
1791 | + $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;} "; |
|
1792 | + $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 . ";} "; |
|
1793 | + $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;} "; |
|
1794 | 1794 | |
1795 | - if ( $type == 'primary' ) { |
|
1795 | + if ($type == 'primary') { |
|
1796 | 1796 | // dropdown's |
1797 | 1797 | $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
1798 | 1798 | |
@@ -1804,9 +1804,9 @@ discard block |
||
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | // alerts |
1807 | - if ( $aui_bs5 ) { |
|
1807 | + if ($aui_bs5) { |
|
1808 | 1808 | // $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
1809 | - $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;} "; |
|
1809 | + $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;} "; |
|
1810 | 1810 | } |
1811 | 1811 | |
1812 | 1812 | return $output; |
@@ -1822,11 +1822,11 @@ discard block |
||
1822 | 1822 | * |
1823 | 1823 | * @return string |
1824 | 1824 | */ |
1825 | - public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
1825 | + public static function css_primary($color_code, $compatibility, $use_variable = false) { |
|
1826 | 1826 | |
1827 | - if(!$use_variable){ |
|
1827 | + if (!$use_variable) { |
|
1828 | 1828 | $color_code = sanitize_hex_color($color_code); |
1829 | - if(!$color_code){return '';} |
|
1829 | + if (!$color_code) {return ''; } |
|
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | /** |
@@ -1834,36 +1834,36 @@ discard block |
||
1834 | 1834 | */ |
1835 | 1835 | $selectors = array( |
1836 | 1836 | 'a' => array('c'), |
1837 | - '.btn-primary' => array('b','o'), |
|
1838 | - '.btn-primary.disabled' => array('b','o'), |
|
1839 | - '.btn-primary:disabled' => array('b','o'), |
|
1840 | - '.btn-outline-primary' => array('c','o'), |
|
1841 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1842 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1843 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1844 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1837 | + '.btn-primary' => array('b', 'o'), |
|
1838 | + '.btn-primary.disabled' => array('b', 'o'), |
|
1839 | + '.btn-primary:disabled' => array('b', 'o'), |
|
1840 | + '.btn-outline-primary' => array('c', 'o'), |
|
1841 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
1842 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1843 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1844 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
1845 | 1845 | '.btn-link' => array('c'), |
1846 | 1846 | '.dropdown-item.active' => array('b'), |
1847 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1848 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1847 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
1848 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
1849 | 1849 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1850 | 1850 | // '.custom-range::-moz-range-thumb' => array('b'), |
1851 | 1851 | // '.custom-range::-ms-thumb' => array('b'), |
1852 | 1852 | '.nav-pills .nav-link.active' => array('b'), |
1853 | 1853 | '.nav-pills .show>.nav-link' => array('b'), |
1854 | 1854 | '.page-link' => array('c'), |
1855 | - '.page-item.active .page-link' => array('b','o'), |
|
1855 | + '.page-item.active .page-link' => array('b', 'o'), |
|
1856 | 1856 | '.badge-primary' => array('b'), |
1857 | - '.alert-primary' => array('b','o'), |
|
1857 | + '.alert-primary' => array('b', 'o'), |
|
1858 | 1858 | '.progress-bar' => array('b'), |
1859 | - '.list-group-item.active' => array('b','o'), |
|
1860 | - '.bg-primary' => array('b','f'), |
|
1859 | + '.list-group-item.active' => array('b', 'o'), |
|
1860 | + '.bg-primary' => array('b', 'f'), |
|
1861 | 1861 | '.btn-link.btn-primary' => array('c'), |
1862 | 1862 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
1863 | 1863 | ); |
1864 | 1864 | |
1865 | 1865 | $important_selectors = array( |
1866 | - '.bg-primary' => array('b','f'), |
|
1866 | + '.bg-primary' => array('b', 'f'), |
|
1867 | 1867 | '.border-primary' => array('o'), |
1868 | 1868 | '.text-primary' => array('c'), |
1869 | 1869 | ); |
@@ -1880,88 +1880,88 @@ discard block |
||
1880 | 1880 | $output = ''; |
1881 | 1881 | |
1882 | 1882 | // build rules into each type |
1883 | - foreach($selectors as $selector => $types){ |
|
1884 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1885 | - $types = array_combine($types,$types); |
|
1886 | - if(isset($types['c'])){$color[] = $selector;} |
|
1887 | - if(isset($types['b'])){$background[] = $selector;} |
|
1888 | - if(isset($types['o'])){$border[] = $selector;} |
|
1889 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1883 | + foreach ($selectors as $selector => $types) { |
|
1884 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1885 | + $types = array_combine($types, $types); |
|
1886 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1887 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1888 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1889 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1890 | 1890 | } |
1891 | 1891 | |
1892 | 1892 | // build rules into each type |
1893 | - foreach($important_selectors as $selector => $types){ |
|
1894 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1895 | - $types = array_combine($types,$types); |
|
1896 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1897 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1898 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1899 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1893 | + foreach ($important_selectors as $selector => $types) { |
|
1894 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1895 | + $types = array_combine($types, $types); |
|
1896 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1897 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1898 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1899 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1900 | 1900 | } |
1901 | 1901 | |
1902 | 1902 | // add any color rules |
1903 | - if(!empty($color)){ |
|
1904 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1903 | + if (!empty($color)) { |
|
1904 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1905 | 1905 | } |
1906 | - if(!empty($color_i)){ |
|
1907 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1906 | + if (!empty($color_i)) { |
|
1907 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1908 | 1908 | } |
1909 | 1909 | |
1910 | 1910 | // add any background color rules |
1911 | - if(!empty($background)){ |
|
1912 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1911 | + if (!empty($background)) { |
|
1912 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1913 | 1913 | } |
1914 | - if(!empty($background_i)){ |
|
1915 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1914 | + if (!empty($background_i)) { |
|
1915 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1916 | 1916 | } |
1917 | 1917 | |
1918 | 1918 | // add any border color rules |
1919 | - if(!empty($border)){ |
|
1920 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1919 | + if (!empty($border)) { |
|
1920 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1921 | 1921 | } |
1922 | - if(!empty($border_i)){ |
|
1923 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1922 | + if (!empty($border_i)) { |
|
1923 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1924 | 1924 | } |
1925 | 1925 | |
1926 | 1926 | // add any fill color rules |
1927 | - if(!empty($fill)){ |
|
1928 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1927 | + if (!empty($fill)) { |
|
1928 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1929 | 1929 | } |
1930 | - if(!empty($fill_i)){ |
|
1931 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1930 | + if (!empty($fill_i)) { |
|
1931 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1932 | 1932 | } |
1933 | 1933 | |
1934 | 1934 | |
1935 | 1935 | $prefix = $compatibility ? ".bsui " : ""; |
1936 | 1936 | |
1937 | 1937 | // darken |
1938 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1939 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1940 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1938 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1939 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1940 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1941 | 1941 | |
1942 | 1942 | // lighten |
1943 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1943 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1944 | 1944 | |
1945 | 1945 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1946 | - $op_25 = $color_code."40"; // 25% opacity |
|
1946 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1947 | 1947 | |
1948 | 1948 | |
1949 | 1949 | // button states |
1950 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1951 | - $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;} "; |
|
1952 | - $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.";} "; |
|
1953 | - $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;} "; |
|
1950 | + $output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1951 | + $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;} "; |
|
1952 | + $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 . ";} "; |
|
1953 | + $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;} "; |
|
1954 | 1954 | |
1955 | 1955 | |
1956 | 1956 | // dropdown's |
1957 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1957 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1958 | 1958 | |
1959 | 1959 | |
1960 | 1960 | // input states |
1961 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1961 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1962 | 1962 | |
1963 | 1963 | // page link |
1964 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1964 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1965 | 1965 | |
1966 | 1966 | return $output; |
1967 | 1967 | } |
@@ -1975,30 +1975,30 @@ discard block |
||
1975 | 1975 | * |
1976 | 1976 | * @return string |
1977 | 1977 | */ |
1978 | - public static function css_secondary($color_code,$compatibility){; |
|
1978 | + public static function css_secondary($color_code, $compatibility) {; |
|
1979 | 1979 | $color_code = sanitize_hex_color($color_code); |
1980 | - if(!$color_code){return '';} |
|
1980 | + if (!$color_code) {return ''; } |
|
1981 | 1981 | /** |
1982 | 1982 | * c = color, b = background color, o = border-color, f = fill |
1983 | 1983 | */ |
1984 | 1984 | $selectors = array( |
1985 | - '.btn-secondary' => array('b','o'), |
|
1986 | - '.btn-secondary.disabled' => array('b','o'), |
|
1987 | - '.btn-secondary:disabled' => array('b','o'), |
|
1988 | - '.btn-outline-secondary' => array('c','o'), |
|
1989 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1985 | + '.btn-secondary' => array('b', 'o'), |
|
1986 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
1987 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
1988 | + '.btn-outline-secondary' => array('c', 'o'), |
|
1989 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
1990 | 1990 | '.btn-outline-secondary.disabled' => array('c'), |
1991 | 1991 | '.btn-outline-secondary:disabled' => array('c'), |
1992 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1993 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1994 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1992 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1993 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1994 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
1995 | 1995 | '.badge-secondary' => array('b'), |
1996 | - '.alert-secondary' => array('b','o'), |
|
1996 | + '.alert-secondary' => array('b', 'o'), |
|
1997 | 1997 | '.btn-link.btn-secondary' => array('c'), |
1998 | 1998 | ); |
1999 | 1999 | |
2000 | 2000 | $important_selectors = array( |
2001 | - '.bg-secondary' => array('b','f'), |
|
2001 | + '.bg-secondary' => array('b', 'f'), |
|
2002 | 2002 | '.border-secondary' => array('o'), |
2003 | 2003 | '.text-secondary' => array('c'), |
2004 | 2004 | ); |
@@ -2015,77 +2015,77 @@ discard block |
||
2015 | 2015 | $output = ''; |
2016 | 2016 | |
2017 | 2017 | // build rules into each type |
2018 | - foreach($selectors as $selector => $types){ |
|
2019 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2020 | - $types = array_combine($types,$types); |
|
2021 | - if(isset($types['c'])){$color[] = $selector;} |
|
2022 | - if(isset($types['b'])){$background[] = $selector;} |
|
2023 | - if(isset($types['o'])){$border[] = $selector;} |
|
2024 | - if(isset($types['f'])){$fill[] = $selector;} |
|
2018 | + foreach ($selectors as $selector => $types) { |
|
2019 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
2020 | + $types = array_combine($types, $types); |
|
2021 | + if (isset($types['c'])) {$color[] = $selector; } |
|
2022 | + if (isset($types['b'])) {$background[] = $selector; } |
|
2023 | + if (isset($types['o'])) {$border[] = $selector; } |
|
2024 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
2025 | 2025 | } |
2026 | 2026 | |
2027 | 2027 | // build rules into each type |
2028 | - foreach($important_selectors as $selector => $types){ |
|
2029 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2030 | - $types = array_combine($types,$types); |
|
2031 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
2032 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
2033 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
2034 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
2028 | + foreach ($important_selectors as $selector => $types) { |
|
2029 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
2030 | + $types = array_combine($types, $types); |
|
2031 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
2032 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
2033 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
2034 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | 2037 | // add any color rules |
2038 | - if(!empty($color)){ |
|
2039 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
2038 | + if (!empty($color)) { |
|
2039 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
2040 | 2040 | } |
2041 | - if(!empty($color_i)){ |
|
2042 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
2041 | + if (!empty($color_i)) { |
|
2042 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
2043 | 2043 | } |
2044 | 2044 | |
2045 | 2045 | // add any background color rules |
2046 | - if(!empty($background)){ |
|
2047 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
2046 | + if (!empty($background)) { |
|
2047 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
2048 | 2048 | } |
2049 | - if(!empty($background_i)){ |
|
2050 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
2049 | + if (!empty($background_i)) { |
|
2050 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
2051 | 2051 | } |
2052 | 2052 | |
2053 | 2053 | // add any border color rules |
2054 | - if(!empty($border)){ |
|
2055 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
2054 | + if (!empty($border)) { |
|
2055 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
2056 | 2056 | } |
2057 | - if(!empty($border_i)){ |
|
2058 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
2057 | + if (!empty($border_i)) { |
|
2058 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
2059 | 2059 | } |
2060 | 2060 | |
2061 | 2061 | // add any fill color rules |
2062 | - if(!empty($fill)){ |
|
2063 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
2062 | + if (!empty($fill)) { |
|
2063 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
2064 | 2064 | } |
2065 | - if(!empty($fill_i)){ |
|
2066 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
2065 | + if (!empty($fill_i)) { |
|
2066 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
2067 | 2067 | } |
2068 | 2068 | |
2069 | 2069 | |
2070 | 2070 | $prefix = $compatibility ? ".bsui " : ""; |
2071 | 2071 | |
2072 | 2072 | // darken |
2073 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
2074 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
2075 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
2073 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
2074 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
2075 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
2076 | 2076 | |
2077 | 2077 | // lighten |
2078 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
2078 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
2079 | 2079 | |
2080 | 2080 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
2081 | - $op_25 = $color_code."40"; // 25% opacity |
|
2081 | + $op_25 = $color_code . "40"; // 25% opacity |
|
2082 | 2082 | |
2083 | 2083 | |
2084 | 2084 | // button states |
2085 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
2086 | - $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;} "; |
|
2087 | - $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.";} "; |
|
2088 | - $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;} "; |
|
2085 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
2086 | + $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;} "; |
|
2087 | + $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 . ";} "; |
|
2088 | + $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;} "; |
|
2089 | 2089 | |
2090 | 2090 | |
2091 | 2091 | return $output; |
@@ -2121,8 +2121,8 @@ discard block |
||
2121 | 2121 | /** |
2122 | 2122 | * Check if we should display examples. |
2123 | 2123 | */ |
2124 | - public function maybe_show_examples(){ |
|
2125 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
2124 | + public function maybe_show_examples() { |
|
2125 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
2126 | 2126 | echo "<head>"; |
2127 | 2127 | wp_head(); |
2128 | 2128 | echo "</head>"; |
@@ -2138,7 +2138,7 @@ discard block |
||
2138 | 2138 | * |
2139 | 2139 | * @return string |
2140 | 2140 | */ |
2141 | - public function get_examples(){ |
|
2141 | + public function get_examples() { |
|
2142 | 2142 | $output = ''; |
2143 | 2143 | |
2144 | 2144 | |
@@ -2244,74 +2244,74 @@ discard block |
||
2244 | 2244 | */ |
2245 | 2245 | public static function calendar_params() { |
2246 | 2246 | $params = array( |
2247 | - 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
2248 | - 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
2249 | - 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
2250 | - 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
2251 | - 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
2252 | - 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
2253 | - 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
2254 | - 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
2255 | - 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
2256 | - 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
2257 | - 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
2258 | - 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
2259 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
2260 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
2261 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
2262 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
2263 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
2264 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
2265 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
2266 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
2267 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
2268 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
2269 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
2270 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
2271 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
2272 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
2273 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
2274 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
2275 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
2276 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
2277 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
2278 | - 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
2279 | - 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
2280 | - 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
2281 | - 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
2282 | - 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
2283 | - 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
2284 | - 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
2285 | - 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
2286 | - 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
2287 | - 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
2288 | - 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
2289 | - 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
2290 | - 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
2291 | - 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
2292 | - 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
2293 | - 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
2294 | - 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
2295 | - 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
2296 | - 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
2297 | - 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
2298 | - 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
2299 | - 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
2300 | - 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
2301 | - 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
2302 | - 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
2303 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
2247 | + 'month_long_1' => __('January', 'ayecode-connect'), |
|
2248 | + 'month_long_2' => __('February', 'ayecode-connect'), |
|
2249 | + 'month_long_3' => __('March', 'ayecode-connect'), |
|
2250 | + 'month_long_4' => __('April', 'ayecode-connect'), |
|
2251 | + 'month_long_5' => __('May', 'ayecode-connect'), |
|
2252 | + 'month_long_6' => __('June', 'ayecode-connect'), |
|
2253 | + 'month_long_7' => __('July', 'ayecode-connect'), |
|
2254 | + 'month_long_8' => __('August', 'ayecode-connect'), |
|
2255 | + 'month_long_9' => __('September', 'ayecode-connect'), |
|
2256 | + 'month_long_10' => __('October', 'ayecode-connect'), |
|
2257 | + 'month_long_11' => __('November', 'ayecode-connect'), |
|
2258 | + 'month_long_12' => __('December', 'ayecode-connect'), |
|
2259 | + 'month_s_1' => _x('Jan', 'January abbreviation', 'ayecode-connect'), |
|
2260 | + 'month_s_2' => _x('Feb', 'February abbreviation', 'ayecode-connect'), |
|
2261 | + 'month_s_3' => _x('Mar', 'March abbreviation', 'ayecode-connect'), |
|
2262 | + 'month_s_4' => _x('Apr', 'April abbreviation', 'ayecode-connect'), |
|
2263 | + 'month_s_5' => _x('May', 'May abbreviation', 'ayecode-connect'), |
|
2264 | + 'month_s_6' => _x('Jun', 'June abbreviation', 'ayecode-connect'), |
|
2265 | + 'month_s_7' => _x('Jul', 'July abbreviation', 'ayecode-connect'), |
|
2266 | + 'month_s_8' => _x('Aug', 'August abbreviation', 'ayecode-connect'), |
|
2267 | + 'month_s_9' => _x('Sep', 'September abbreviation', 'ayecode-connect'), |
|
2268 | + 'month_s_10' => _x('Oct', 'October abbreviation', 'ayecode-connect'), |
|
2269 | + 'month_s_11' => _x('Nov', 'November abbreviation', 'ayecode-connect'), |
|
2270 | + 'month_s_12' => _x('Dec', 'December abbreviation', 'ayecode-connect'), |
|
2271 | + 'day_s1_1' => _x('S', 'Sunday initial', 'ayecode-connect'), |
|
2272 | + 'day_s1_2' => _x('M', 'Monday initial', 'ayecode-connect'), |
|
2273 | + 'day_s1_3' => _x('T', 'Tuesday initial', 'ayecode-connect'), |
|
2274 | + 'day_s1_4' => _x('W', 'Wednesday initial', 'ayecode-connect'), |
|
2275 | + 'day_s1_5' => _x('T', 'Friday initial', 'ayecode-connect'), |
|
2276 | + 'day_s1_6' => _x('F', 'Thursday initial', 'ayecode-connect'), |
|
2277 | + 'day_s1_7' => _x('S', 'Saturday initial', 'ayecode-connect'), |
|
2278 | + 'day_s2_1' => __('Su', 'ayecode-connect'), |
|
2279 | + 'day_s2_2' => __('Mo', 'ayecode-connect'), |
|
2280 | + 'day_s2_3' => __('Tu', 'ayecode-connect'), |
|
2281 | + 'day_s2_4' => __('We', 'ayecode-connect'), |
|
2282 | + 'day_s2_5' => __('Th', 'ayecode-connect'), |
|
2283 | + 'day_s2_6' => __('Fr', 'ayecode-connect'), |
|
2284 | + 'day_s2_7' => __('Sa', 'ayecode-connect'), |
|
2285 | + 'day_s3_1' => __('Sun', 'ayecode-connect'), |
|
2286 | + 'day_s3_2' => __('Mon', 'ayecode-connect'), |
|
2287 | + 'day_s3_3' => __('Tue', 'ayecode-connect'), |
|
2288 | + 'day_s3_4' => __('Wed', 'ayecode-connect'), |
|
2289 | + 'day_s3_5' => __('Thu', 'ayecode-connect'), |
|
2290 | + 'day_s3_6' => __('Fri', 'ayecode-connect'), |
|
2291 | + 'day_s3_7' => __('Sat', 'ayecode-connect'), |
|
2292 | + 'day_s5_1' => __('Sunday', 'ayecode-connect'), |
|
2293 | + 'day_s5_2' => __('Monday', 'ayecode-connect'), |
|
2294 | + 'day_s5_3' => __('Tuesday', 'ayecode-connect'), |
|
2295 | + 'day_s5_4' => __('Wednesday', 'ayecode-connect'), |
|
2296 | + 'day_s5_5' => __('Thursday', 'ayecode-connect'), |
|
2297 | + 'day_s5_6' => __('Friday', 'ayecode-connect'), |
|
2298 | + 'day_s5_7' => __('Saturday', 'ayecode-connect'), |
|
2299 | + 'am_lower' => __('am', 'ayecode-connect'), |
|
2300 | + 'pm_lower' => __('pm', 'ayecode-connect'), |
|
2301 | + 'am_upper' => __('AM', 'ayecode-connect'), |
|
2302 | + 'pm_upper' => __('PM', 'ayecode-connect'), |
|
2303 | + 'firstDayOfWeek' => (int) get_option('start_of_week'), |
|
2304 | 2304 | 'time_24hr' => false, |
2305 | - 'year' => __( 'Year', 'ayecode-connect' ), |
|
2306 | - 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
2307 | - 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
2308 | - 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
2309 | - 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
2310 | - 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
2311 | - 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
2305 | + 'year' => __('Year', 'ayecode-connect'), |
|
2306 | + 'hour' => __('Hour', 'ayecode-connect'), |
|
2307 | + 'minute' => __('Minute', 'ayecode-connect'), |
|
2308 | + 'weekAbbreviation' => __('Wk', 'ayecode-connect'), |
|
2309 | + 'rangeSeparator' => __(' to ', 'ayecode-connect'), |
|
2310 | + 'scrollTitle' => __('Scroll to increment', 'ayecode-connect'), |
|
2311 | + 'toggleTitle' => __('Click to toggle', 'ayecode-connect') |
|
2312 | 2312 | ); |
2313 | 2313 | |
2314 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
2314 | + return apply_filters('ayecode_ui_calendar_params', $params); |
|
2315 | 2315 | } |
2316 | 2316 | |
2317 | 2317 | /** |
@@ -2324,47 +2324,47 @@ discard block |
||
2324 | 2324 | public static function flatpickr_locale() { |
2325 | 2325 | $params = self::calendar_params(); |
2326 | 2326 | |
2327 | - if ( is_string( $params ) ) { |
|
2328 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
2327 | + if (is_string($params)) { |
|
2328 | + $params = html_entity_decode($params, ENT_QUOTES, 'UTF-8'); |
|
2329 | 2329 | } else { |
2330 | - foreach ( (array) $params as $key => $value ) { |
|
2331 | - if ( ! is_scalar( $value ) ) { |
|
2330 | + foreach ((array) $params as $key => $value) { |
|
2331 | + if (!is_scalar($value)) { |
|
2332 | 2332 | continue; |
2333 | 2333 | } |
2334 | 2334 | |
2335 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2335 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
2336 | 2336 | } |
2337 | 2337 | } |
2338 | 2338 | |
2339 | 2339 | $day_s3 = array(); |
2340 | 2340 | $day_s5 = array(); |
2341 | 2341 | |
2342 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
2343 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2344 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2342 | + for ($i = 1; $i <= 7; $i++) { |
|
2343 | + $day_s3[] = addslashes($params['day_s3_' . $i]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2344 | + $day_s5[] = addslashes($params['day_s3_' . $i]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2345 | 2345 | } |
2346 | 2346 | |
2347 | 2347 | $month_s = array(); |
2348 | 2348 | $month_long = array(); |
2349 | 2349 | |
2350 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
2351 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2352 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2350 | + for ($i = 1; $i <= 12; $i++) { |
|
2351 | + $month_s[] = addslashes($params['month_s_' . $i]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2352 | + $month_long[] = addslashes($params['month_long_' . $i]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2353 | 2353 | } |
2354 | 2354 | |
2355 | 2355 | ob_start(); |
2356 | - if ( 0 ) { ?><script><?php } ?> |
|
2356 | + if (0) { ?><script><?php } ?> |
|
2357 | 2357 | { |
2358 | 2358 | weekdays: { |
2359 | - shorthand: ['<?php echo implode( "','", $day_s3 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
|
2360 | - longhand: ['<?php echo implode( "','", $day_s5 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
|
2359 | + shorthand: ['<?php echo implode("','", $day_s3); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
|
2360 | + longhand: ['<?php echo implode("','", $day_s5); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
|
2361 | 2361 | }, |
2362 | 2362 | months: { |
2363 | - shorthand: ['<?php echo implode( "','", $month_s ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
|
2364 | - longhand: ['<?php echo implode( "','", $month_long ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
|
2363 | + shorthand: ['<?php echo implode("','", $month_s); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
|
2364 | + longhand: ['<?php echo implode("','", $month_long); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
|
2365 | 2365 | }, |
2366 | 2366 | daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31], |
2367 | - firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>, |
|
2367 | + firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>, |
|
2368 | 2368 | ordinal: function (nth) { |
2369 | 2369 | var s = nth % 100; |
2370 | 2370 | if (s > 3 && s < 21) |
@@ -2380,21 +2380,21 @@ discard block |
||
2380 | 2380 | return "th"; |
2381 | 2381 | } |
2382 | 2382 | }, |
2383 | - rangeSeparator: '<?php echo esc_attr( $params[ 'rangeSeparator' ] ); ?>', |
|
2384 | - weekAbbreviation: '<?php echo esc_attr( $params[ 'weekAbbreviation' ] ); ?>', |
|
2385 | - scrollTitle: '<?php echo esc_attr( $params[ 'scrollTitle' ] ); ?>', |
|
2386 | - toggleTitle: '<?php echo esc_attr( $params[ 'toggleTitle' ] ); ?>', |
|
2387 | - amPM: ['<?php echo esc_attr( $params[ 'am_upper' ] ); ?>','<?php echo esc_attr( $params[ 'pm_upper' ] ); ?>'], |
|
2388 | - yearAriaLabel: '<?php echo esc_attr( $params[ 'year' ] ); ?>', |
|
2389 | - hourAriaLabel: '<?php echo esc_attr( $params[ 'hour' ] ); ?>', |
|
2390 | - minuteAriaLabel: '<?php echo esc_attr( $params[ 'minute' ] ); ?>', |
|
2391 | - time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?> |
|
2383 | + rangeSeparator: '<?php echo esc_attr($params['rangeSeparator']); ?>', |
|
2384 | + weekAbbreviation: '<?php echo esc_attr($params['weekAbbreviation']); ?>', |
|
2385 | + scrollTitle: '<?php echo esc_attr($params['scrollTitle']); ?>', |
|
2386 | + toggleTitle: '<?php echo esc_attr($params['toggleTitle']); ?>', |
|
2387 | + amPM: ['<?php echo esc_attr($params['am_upper']); ?>','<?php echo esc_attr($params['pm_upper']); ?>'], |
|
2388 | + yearAriaLabel: '<?php echo esc_attr($params['year']); ?>', |
|
2389 | + hourAriaLabel: '<?php echo esc_attr($params['hour']); ?>', |
|
2390 | + minuteAriaLabel: '<?php echo esc_attr($params['minute']); ?>', |
|
2391 | + time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?> |
|
2392 | 2392 | } |
2393 | - <?php if ( 0 ) { ?></script><?php } ?> |
|
2393 | + <?php if (0) { ?></script><?php } ?> |
|
2394 | 2394 | <?php |
2395 | 2395 | $locale = ob_get_clean(); |
2396 | 2396 | |
2397 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2397 | + return apply_filters('ayecode_ui_flatpickr_locale', trim($locale)); |
|
2398 | 2398 | } |
2399 | 2399 | |
2400 | 2400 | /** |
@@ -2406,20 +2406,20 @@ discard block |
||
2406 | 2406 | */ |
2407 | 2407 | public static function select2_params() { |
2408 | 2408 | $params = array( |
2409 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
2410 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
2411 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
2412 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2413 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2414 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
2415 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
2416 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
2417 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
2418 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
2419 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
2409 | + 'i18n_select_state_text' => esc_attr__('Select an option…', 'ayecode-connect'), |
|
2410 | + 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'ayecode-connect'), |
|
2411 | + 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'ayecode-connect'), |
|
2412 | + 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'ayecode-connect'), |
|
2413 | + 'i18n_input_too_short_n' => _x('Please enter %item% or more characters', 'enhanced select', 'ayecode-connect'), |
|
2414 | + 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'ayecode-connect'), |
|
2415 | + 'i18n_input_too_long_n' => _x('Please delete %item% characters', 'enhanced select', 'ayecode-connect'), |
|
2416 | + 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'ayecode-connect'), |
|
2417 | + 'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'ayecode-connect'), |
|
2418 | + 'i18n_load_more' => _x('Loading more results…', 'enhanced select', 'ayecode-connect'), |
|
2419 | + 'i18n_searching' => _x('Searching…', 'enhanced select', 'ayecode-connect') |
|
2420 | 2420 | ); |
2421 | 2421 | |
2422 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2422 | + return apply_filters('ayecode_ui_select2_params', $params); |
|
2423 | 2423 | } |
2424 | 2424 | |
2425 | 2425 | /** |
@@ -2432,17 +2432,17 @@ discard block |
||
2432 | 2432 | public static function select2_locale() { |
2433 | 2433 | $params = self::select2_params(); |
2434 | 2434 | |
2435 | - foreach ( (array) $params as $key => $value ) { |
|
2436 | - if ( ! is_scalar( $value ) ) { |
|
2435 | + foreach ((array) $params as $key => $value) { |
|
2436 | + if (!is_scalar($value)) { |
|
2437 | 2437 | continue; |
2438 | 2438 | } |
2439 | 2439 | |
2440 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2440 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
2441 | 2441 | } |
2442 | 2442 | |
2443 | - $locale = json_encode( $params ); |
|
2443 | + $locale = json_encode($params); |
|
2444 | 2444 | |
2445 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2445 | + return apply_filters('ayecode_ui_select2_locale', trim($locale)); |
|
2446 | 2446 | } |
2447 | 2447 | |
2448 | 2448 | /** |
@@ -2455,35 +2455,35 @@ discard block |
||
2455 | 2455 | public static function timeago_locale() { |
2456 | 2456 | $params = array( |
2457 | 2457 | 'prefix_ago' => '', |
2458 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
2459 | - 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
2458 | + 'suffix_ago' => ' ' . _x('ago', 'time ago', 'ayecode-connect'), |
|
2459 | + 'prefix_after' => _x('after', 'time ago', 'ayecode-connect') . ' ', |
|
2460 | 2460 | 'suffix_after' => '', |
2461 | - 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
2462 | - 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
2463 | - 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
2464 | - 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
2465 | - 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
2466 | - 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
2467 | - 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
2468 | - 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
2469 | - 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
2470 | - 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
2471 | - 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
2461 | + 'seconds' => _x('less than a minute', 'time ago', 'ayecode-connect'), |
|
2462 | + 'minute' => _x('about a minute', 'time ago', 'ayecode-connect'), |
|
2463 | + 'minutes' => _x('%d minutes', 'time ago', 'ayecode-connect'), |
|
2464 | + 'hour' => _x('about an hour', 'time ago', 'ayecode-connect'), |
|
2465 | + 'hours' => _x('about %d hours', 'time ago', 'ayecode-connect'), |
|
2466 | + 'day' => _x('a day', 'time ago', 'ayecode-connect'), |
|
2467 | + 'days' => _x('%d days', 'time ago', 'ayecode-connect'), |
|
2468 | + 'month' => _x('about a month', 'time ago', 'ayecode-connect'), |
|
2469 | + 'months' => _x('%d months', 'time ago', 'ayecode-connect'), |
|
2470 | + 'year' => _x('about a year', 'time ago', 'ayecode-connect'), |
|
2471 | + 'years' => _x('%d years', 'time ago', 'ayecode-connect'), |
|
2472 | 2472 | ); |
2473 | 2473 | |
2474 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2474 | + $params = apply_filters('ayecode_ui_timeago_params', $params); |
|
2475 | 2475 | |
2476 | - foreach ( (array) $params as $key => $value ) { |
|
2477 | - if ( ! is_scalar( $value ) ) { |
|
2476 | + foreach ((array) $params as $key => $value) { |
|
2477 | + if (!is_scalar($value)) { |
|
2478 | 2478 | continue; |
2479 | 2479 | } |
2480 | 2480 | |
2481 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2481 | + $params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
2482 | 2482 | } |
2483 | 2483 | |
2484 | - $locale = json_encode( $params ); |
|
2484 | + $locale = json_encode($params); |
|
2485 | 2485 | |
2486 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2486 | + return apply_filters('ayecode_ui_timeago_locale', trim($locale)); |
|
2487 | 2487 | } |
2488 | 2488 | |
2489 | 2489 | /** |
@@ -2494,7 +2494,7 @@ discard block |
||
2494 | 2494 | * @return mixed |
2495 | 2495 | */ |
2496 | 2496 | public static function minify_js($input) { |
2497 | - if(trim($input) === "") return $input; |
|
2497 | + if (trim($input) === "") return $input; |
|
2498 | 2498 | return preg_replace( |
2499 | 2499 | array( |
2500 | 2500 | // Remove comment(s) |
@@ -2526,7 +2526,7 @@ discard block |
||
2526 | 2526 | * @return mixed |
2527 | 2527 | */ |
2528 | 2528 | public static function minify_css($input) { |
2529 | - if(trim($input) === "") return $input; |
|
2529 | + if (trim($input) === "") return $input; |
|
2530 | 2530 | return preg_replace( |
2531 | 2531 | array( |
2532 | 2532 | // Remove comment(s) |
@@ -3092,12 +3092,12 @@ discard block |
||
3092 | 3092 | }); |
3093 | 3093 | } |
3094 | 3094 | } |
3095 | - <?php do_action( 'aui_conditional_fields_js', $this ); ?> |
|
3095 | + <?php do_action('aui_conditional_fields_js', $this); ?> |
|
3096 | 3096 | </script> |
3097 | 3097 | <?php |
3098 | 3098 | $output = ob_get_clean(); |
3099 | 3099 | |
3100 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
3100 | + return str_replace(array('<script>', '</script>'), '', self::minify_js($output)); |
|
3101 | 3101 | } |
3102 | 3102 | } |
3103 | 3103 |
@@ -16,222 +16,222 @@ |
||
16 | 16 | |
17 | 17 | // If this file is called directly, abort. |
18 | 18 | if ( ! defined( 'WPINC' ) ) { |
19 | - die; |
|
19 | + die; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class AyeCode_UI_Plugin { |
23 | 23 | |
24 | - /** |
|
25 | - * AUI Plugin constructor. |
|
26 | - * |
|
27 | - * @since 1.0.0 |
|
28 | - */ |
|
29 | - public function __construct() { |
|
30 | - |
|
31 | - // load AUI |
|
32 | - require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
|
33 | - |
|
34 | - // Maybe show example page |
|
35 | - add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
|
36 | - } |
|
37 | - |
|
38 | - public function maybe_show_examples(){ |
|
39 | - if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) { |
|
40 | - echo "<head>"; |
|
41 | - wp_head(); |
|
42 | - echo "</head>"; |
|
43 | - echo "<body class='bsui'>"; |
|
44 | - echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
45 | - wp_footer(); |
|
46 | - echo "</body>"; |
|
47 | - exit; |
|
48 | - } |
|
49 | - } |
|
50 | - |
|
51 | - public function get_examples(){ |
|
52 | - $output = ''; |
|
53 | - |
|
54 | - // open form |
|
55 | - $output .= "<form class='p-5 m-5 border rounded bg-white'>"; |
|
56 | - |
|
57 | - $output .= aui()->input( |
|
58 | - array( |
|
59 | - 'type' => 'datepicker', |
|
60 | - 'id' => 'date_example_sm', |
|
61 | - 'size' => 'sm', |
|
62 | - 'name' => 'date_example_sm', |
|
63 | - 'label' => 'Date Input Label (small)', |
|
64 | - 'help_text' => 'help text', |
|
65 | - 'label_type' => 'top', |
|
66 | - 'placeholder' => 'YYYY-MM-DD 00:00', |
|
67 | - 'value' => '', |
|
68 | - 'extra_attributes' => array( |
|
69 | - 'data-enable-time' => 'true', |
|
70 | - 'data-time_24hr' => 'true', |
|
71 | - 'data-allow-input' => 'true', |
|
72 | - ), |
|
73 | - ) |
|
74 | - ); |
|
75 | - |
|
76 | - $output .= aui()->input( |
|
77 | - array( |
|
78 | - 'type' => 'datepicker', |
|
79 | - 'id' => 'date_example', |
|
80 | - //'size' => 'smx', |
|
81 | - 'name' => 'date_example', |
|
82 | - 'label' => 'Date Input Label', |
|
83 | - 'help_text' => 'help text', |
|
84 | - 'label_type' => 'top', |
|
85 | - 'placeholder' => 'YYYY-MM-DD 00:00', |
|
86 | - 'value' => '', |
|
87 | - 'extra_attributes' => array( |
|
88 | - 'data-enable-time' => 'true', |
|
89 | - 'data-time_24hr' => 'true', |
|
90 | - 'data-allow-input' => 'true', |
|
91 | - ), |
|
92 | - ) |
|
93 | - ); |
|
94 | - |
|
95 | - $output .= aui()->input( |
|
96 | - array( |
|
97 | - 'type' => 'datepicker', |
|
98 | - 'id' => 'date_example_lg', |
|
99 | - 'size' => 'lg', |
|
100 | - 'name' => 'date_example_lg', |
|
101 | - 'label' => 'Date Input Label (large)', |
|
102 | - 'help_text' => 'help text', |
|
103 | - 'label_type' => 'top', |
|
104 | - 'placeholder' => 'YYYY-MM-DD 00:00', |
|
105 | - 'value' => '', |
|
106 | - 'extra_attributes' => array( |
|
107 | - 'data-enable-time' => 'true', |
|
108 | - 'data-time_24hr' => 'true', |
|
109 | - //'data-allow-input' => 'true', |
|
110 | - ), |
|
111 | - ) |
|
112 | - ); |
|
113 | - |
|
114 | - // input example |
|
115 | - $output .= aui()->input( |
|
116 | - array( |
|
117 | - 'type' => 'text', |
|
118 | - 'id' => 'text-example', |
|
119 | - 'size' => 'sm', |
|
120 | - //'clear_icon' => true, |
|
121 | - 'name' => 'text-example', |
|
122 | - 'placeholder' => 'text placeholder', |
|
123 | - 'title' => 'Text input example', |
|
124 | - 'value' => '', |
|
125 | - 'required' => false, |
|
126 | - 'help_text' => 'help text', |
|
127 | - 'label' => 'Text input example label', |
|
128 | - 'label_type' => 'top' |
|
129 | - ) |
|
130 | - ); |
|
131 | - |
|
132 | - $output .= aui()->input( |
|
133 | - array( |
|
134 | - 'type' => 'search', |
|
135 | - 'id' => 'text-example', |
|
136 | - 'size' => 'sm', |
|
137 | - //'clear_icon' => true, |
|
138 | - 'name' => 'text-example', |
|
139 | - 'placeholder' => 'text placeholder', |
|
140 | - 'title' => 'Text input example', |
|
141 | - 'value' => '', |
|
142 | - 'required' => false, |
|
143 | - 'help_text' => 'help text', |
|
144 | - 'label' => 'Text input example label', |
|
145 | - 'label_type' => 'top' |
|
146 | - ) |
|
147 | - ); |
|
148 | - |
|
149 | - // input example |
|
150 | - $output .= aui()->input( |
|
151 | - array( |
|
152 | - 'type' => 'url', |
|
153 | - 'id' => 'text-example2', |
|
154 | - 'name' => 'text-example', |
|
155 | - 'placeholder' => 'url placeholder', |
|
156 | - 'title' => 'Text input example', |
|
157 | - 'value' => '', |
|
158 | - 'required' => false, |
|
159 | - 'help_text' => 'help text', |
|
160 | - 'label' => 'Text input example label' |
|
161 | - ) |
|
162 | - ); |
|
163 | - |
|
164 | - // checkbox example |
|
165 | - $output .= aui()->input( |
|
166 | - array( |
|
167 | - 'type' => 'checkbox', |
|
168 | - 'id' => 'checkbox-example', |
|
169 | - 'name' => 'checkbox-example', |
|
170 | - 'placeholder' => 'checkbox-example', |
|
171 | - 'title' => 'Checkbox example', |
|
172 | - 'value' => '1', |
|
173 | - 'checked' => true, |
|
174 | - 'required' => false, |
|
175 | - 'help_text' => 'help text', |
|
176 | - 'label' => 'Checkbox checked' |
|
177 | - ) |
|
178 | - ); |
|
179 | - |
|
180 | - // checkbox example |
|
181 | - $output .= aui()->input( |
|
182 | - array( |
|
183 | - 'type' => 'checkbox', |
|
184 | - 'id' => 'checkbox-example2', |
|
185 | - 'name' => 'checkbox-example2', |
|
186 | - 'placeholder' => 'checkbox-example', |
|
187 | - 'title' => 'Checkbox example', |
|
188 | - 'value' => '1', |
|
189 | - 'checked' => false, |
|
190 | - 'required' => false, |
|
191 | - 'help_text' => 'help text', |
|
192 | - 'label' => 'Checkbox un-checked' |
|
193 | - ) |
|
194 | - ); |
|
195 | - |
|
196 | - // switch example |
|
197 | - $output .= aui()->input( |
|
198 | - array( |
|
199 | - 'type' => 'checkbox', |
|
200 | - 'id' => 'switch-example', |
|
201 | - 'name' => 'switch-example', |
|
202 | - 'placeholder' => 'checkbox-example', |
|
203 | - 'title' => 'Switch example', |
|
204 | - 'value' => '1', |
|
205 | - 'checked' => true, |
|
206 | - 'switch' => true, |
|
207 | - 'required' => false, |
|
208 | - 'help_text' => 'help text', |
|
209 | - 'label' => 'Switch on' |
|
210 | - ) |
|
211 | - ); |
|
212 | - |
|
213 | - // switch example |
|
214 | - $output .= aui()->input( |
|
215 | - array( |
|
216 | - 'type' => 'checkbox', |
|
217 | - 'id' => 'switch-example2', |
|
218 | - 'name' => 'switch-example2', |
|
219 | - 'placeholder' => 'checkbox-example', |
|
220 | - 'title' => 'Switch example', |
|
221 | - 'value' => '1', |
|
222 | - 'checked' => false, |
|
223 | - 'switch' => true, |
|
224 | - 'required' => false, |
|
225 | - 'help_text' => 'help text', |
|
226 | - 'label' => 'Switch off' |
|
227 | - ) |
|
228 | - ); |
|
229 | - |
|
230 | - // close form |
|
231 | - $output .= "</form>"; |
|
232 | - |
|
233 | - return $output; |
|
234 | - } |
|
24 | + /** |
|
25 | + * AUI Plugin constructor. |
|
26 | + * |
|
27 | + * @since 1.0.0 |
|
28 | + */ |
|
29 | + public function __construct() { |
|
30 | + |
|
31 | + // load AUI |
|
32 | + require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' ); |
|
33 | + |
|
34 | + // Maybe show example page |
|
35 | + add_action( 'template_redirect', array( $this,'maybe_show_examples' ) ); |
|
36 | + } |
|
37 | + |
|
38 | + public function maybe_show_examples(){ |
|
39 | + if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) { |
|
40 | + echo "<head>"; |
|
41 | + wp_head(); |
|
42 | + echo "</head>"; |
|
43 | + echo "<body class='bsui'>"; |
|
44 | + echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
45 | + wp_footer(); |
|
46 | + echo "</body>"; |
|
47 | + exit; |
|
48 | + } |
|
49 | + } |
|
50 | + |
|
51 | + public function get_examples(){ |
|
52 | + $output = ''; |
|
53 | + |
|
54 | + // open form |
|
55 | + $output .= "<form class='p-5 m-5 border rounded bg-white'>"; |
|
56 | + |
|
57 | + $output .= aui()->input( |
|
58 | + array( |
|
59 | + 'type' => 'datepicker', |
|
60 | + 'id' => 'date_example_sm', |
|
61 | + 'size' => 'sm', |
|
62 | + 'name' => 'date_example_sm', |
|
63 | + 'label' => 'Date Input Label (small)', |
|
64 | + 'help_text' => 'help text', |
|
65 | + 'label_type' => 'top', |
|
66 | + 'placeholder' => 'YYYY-MM-DD 00:00', |
|
67 | + 'value' => '', |
|
68 | + 'extra_attributes' => array( |
|
69 | + 'data-enable-time' => 'true', |
|
70 | + 'data-time_24hr' => 'true', |
|
71 | + 'data-allow-input' => 'true', |
|
72 | + ), |
|
73 | + ) |
|
74 | + ); |
|
75 | + |
|
76 | + $output .= aui()->input( |
|
77 | + array( |
|
78 | + 'type' => 'datepicker', |
|
79 | + 'id' => 'date_example', |
|
80 | + //'size' => 'smx', |
|
81 | + 'name' => 'date_example', |
|
82 | + 'label' => 'Date Input Label', |
|
83 | + 'help_text' => 'help text', |
|
84 | + 'label_type' => 'top', |
|
85 | + 'placeholder' => 'YYYY-MM-DD 00:00', |
|
86 | + 'value' => '', |
|
87 | + 'extra_attributes' => array( |
|
88 | + 'data-enable-time' => 'true', |
|
89 | + 'data-time_24hr' => 'true', |
|
90 | + 'data-allow-input' => 'true', |
|
91 | + ), |
|
92 | + ) |
|
93 | + ); |
|
94 | + |
|
95 | + $output .= aui()->input( |
|
96 | + array( |
|
97 | + 'type' => 'datepicker', |
|
98 | + 'id' => 'date_example_lg', |
|
99 | + 'size' => 'lg', |
|
100 | + 'name' => 'date_example_lg', |
|
101 | + 'label' => 'Date Input Label (large)', |
|
102 | + 'help_text' => 'help text', |
|
103 | + 'label_type' => 'top', |
|
104 | + 'placeholder' => 'YYYY-MM-DD 00:00', |
|
105 | + 'value' => '', |
|
106 | + 'extra_attributes' => array( |
|
107 | + 'data-enable-time' => 'true', |
|
108 | + 'data-time_24hr' => 'true', |
|
109 | + //'data-allow-input' => 'true', |
|
110 | + ), |
|
111 | + ) |
|
112 | + ); |
|
113 | + |
|
114 | + // input example |
|
115 | + $output .= aui()->input( |
|
116 | + array( |
|
117 | + 'type' => 'text', |
|
118 | + 'id' => 'text-example', |
|
119 | + 'size' => 'sm', |
|
120 | + //'clear_icon' => true, |
|
121 | + 'name' => 'text-example', |
|
122 | + 'placeholder' => 'text placeholder', |
|
123 | + 'title' => 'Text input example', |
|
124 | + 'value' => '', |
|
125 | + 'required' => false, |
|
126 | + 'help_text' => 'help text', |
|
127 | + 'label' => 'Text input example label', |
|
128 | + 'label_type' => 'top' |
|
129 | + ) |
|
130 | + ); |
|
131 | + |
|
132 | + $output .= aui()->input( |
|
133 | + array( |
|
134 | + 'type' => 'search', |
|
135 | + 'id' => 'text-example', |
|
136 | + 'size' => 'sm', |
|
137 | + //'clear_icon' => true, |
|
138 | + 'name' => 'text-example', |
|
139 | + 'placeholder' => 'text placeholder', |
|
140 | + 'title' => 'Text input example', |
|
141 | + 'value' => '', |
|
142 | + 'required' => false, |
|
143 | + 'help_text' => 'help text', |
|
144 | + 'label' => 'Text input example label', |
|
145 | + 'label_type' => 'top' |
|
146 | + ) |
|
147 | + ); |
|
148 | + |
|
149 | + // input example |
|
150 | + $output .= aui()->input( |
|
151 | + array( |
|
152 | + 'type' => 'url', |
|
153 | + 'id' => 'text-example2', |
|
154 | + 'name' => 'text-example', |
|
155 | + 'placeholder' => 'url placeholder', |
|
156 | + 'title' => 'Text input example', |
|
157 | + 'value' => '', |
|
158 | + 'required' => false, |
|
159 | + 'help_text' => 'help text', |
|
160 | + 'label' => 'Text input example label' |
|
161 | + ) |
|
162 | + ); |
|
163 | + |
|
164 | + // checkbox example |
|
165 | + $output .= aui()->input( |
|
166 | + array( |
|
167 | + 'type' => 'checkbox', |
|
168 | + 'id' => 'checkbox-example', |
|
169 | + 'name' => 'checkbox-example', |
|
170 | + 'placeholder' => 'checkbox-example', |
|
171 | + 'title' => 'Checkbox example', |
|
172 | + 'value' => '1', |
|
173 | + 'checked' => true, |
|
174 | + 'required' => false, |
|
175 | + 'help_text' => 'help text', |
|
176 | + 'label' => 'Checkbox checked' |
|
177 | + ) |
|
178 | + ); |
|
179 | + |
|
180 | + // checkbox example |
|
181 | + $output .= aui()->input( |
|
182 | + array( |
|
183 | + 'type' => 'checkbox', |
|
184 | + 'id' => 'checkbox-example2', |
|
185 | + 'name' => 'checkbox-example2', |
|
186 | + 'placeholder' => 'checkbox-example', |
|
187 | + 'title' => 'Checkbox example', |
|
188 | + 'value' => '1', |
|
189 | + 'checked' => false, |
|
190 | + 'required' => false, |
|
191 | + 'help_text' => 'help text', |
|
192 | + 'label' => 'Checkbox un-checked' |
|
193 | + ) |
|
194 | + ); |
|
195 | + |
|
196 | + // switch example |
|
197 | + $output .= aui()->input( |
|
198 | + array( |
|
199 | + 'type' => 'checkbox', |
|
200 | + 'id' => 'switch-example', |
|
201 | + 'name' => 'switch-example', |
|
202 | + 'placeholder' => 'checkbox-example', |
|
203 | + 'title' => 'Switch example', |
|
204 | + 'value' => '1', |
|
205 | + 'checked' => true, |
|
206 | + 'switch' => true, |
|
207 | + 'required' => false, |
|
208 | + 'help_text' => 'help text', |
|
209 | + 'label' => 'Switch on' |
|
210 | + ) |
|
211 | + ); |
|
212 | + |
|
213 | + // switch example |
|
214 | + $output .= aui()->input( |
|
215 | + array( |
|
216 | + 'type' => 'checkbox', |
|
217 | + 'id' => 'switch-example2', |
|
218 | + 'name' => 'switch-example2', |
|
219 | + 'placeholder' => 'checkbox-example', |
|
220 | + 'title' => 'Switch example', |
|
221 | + 'value' => '1', |
|
222 | + 'checked' => false, |
|
223 | + 'switch' => true, |
|
224 | + 'required' => false, |
|
225 | + 'help_text' => 'help text', |
|
226 | + 'label' => 'Switch off' |
|
227 | + ) |
|
228 | + ); |
|
229 | + |
|
230 | + // close form |
|
231 | + $output .= "</form>"; |
|
232 | + |
|
233 | + return $output; |
|
234 | + } |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | new AyeCode_UI_Plugin(); |
238 | 238 | \ No newline at end of file |
@@ -7,40 +7,40 @@ |
||
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; |
|
10 | + exit; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | 16 | add_action('after_setup_theme', function () { |
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
18 | - $this_version = "0.2.9"; |
|
19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
22 | - } |
|
17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
18 | + $this_version = "0.2.9"; |
|
19 | + if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | + $ayecode_ui_version = $this_version ; |
|
21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
22 | + } |
|
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | 28 | add_action('after_setup_theme', function () { |
29 | - global $ayecode_ui_file_key; |
|
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
33 | - } |
|
29 | + global $ayecode_ui_file_key; |
|
30 | + if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | + include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | + include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
33 | + } |
|
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | 39 | if(!function_exists('aui')){ |
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
42 | - return false; |
|
43 | - } |
|
44 | - return AUI::instance(); |
|
45 | - } |
|
40 | + function aui(){ |
|
41 | + if(!class_exists("AUI",false)){ |
|
42 | + return false; |
|
43 | + } |
|
44 | + return AUI::instance(); |
|
45 | + } |
|
46 | 46 | } |
@@ -6,39 +6,39 @@ |
||
6 | 6 | /** |
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | -add_action('after_setup_theme', function () { |
|
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
16 | +add_action('after_setup_theme', function() { |
|
17 | + global $ayecode_ui_version, $ayecode_ui_file_key; |
|
18 | 18 | $this_version = "0.2.9"; |
19 | - if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
19 | + if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) { |
|
20 | + $ayecode_ui_version = $this_version; |
|
21 | + $ayecode_ui_file_key = wp_hash(__FILE__); |
|
22 | 22 | } |
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | -add_action('after_setup_theme', function () { |
|
28 | +add_action('after_setup_theme', function() { |
|
29 | 29 | global $ayecode_ui_file_key; |
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
30 | + if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) { |
|
31 | + include_once(dirname(__FILE__) . '/includes/class-aui.php'); |
|
32 | + include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php'); |
|
33 | 33 | } |
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | -if(!function_exists('aui')){ |
|
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
39 | +if (!function_exists('aui')) { |
|
40 | + function aui() { |
|
41 | + if (!class_exists("AUI", false)) { |
|
42 | 42 | return false; |
43 | 43 | } |
44 | 44 | return AUI::instance(); |