@@ -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.26' ); |
|
26 | + define( 'WPINV_VERSION', '2.8.26' ); |
|
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.26' ); |
|
25 | +if (!defined('WPINV_VERSION')) { |
|
26 | + define('WPINV_VERSION', '2.8.26'); |
|
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', 0 ); |
|
67 | +add_action('plugins_loaded', 'getpaid', 0); |
@@ -1075,8 +1075,8 @@ |
||
1075 | 1075 | aui_flip_color_scheme_on_scroll(); |
1076 | 1076 | |
1077 | 1077 | <?php |
1078 | - // FSE tweaks. |
|
1079 | - if(!empty($_REQUEST['postType']) || !empty($_REQUEST['canvas']) ){ ?> |
|
1078 | + // FSE tweaks. |
|
1079 | + if(!empty($_REQUEST['postType']) || !empty($_REQUEST['canvas']) ){ ?> |
|
1080 | 1080 | function aui_fse_set_data_scroll() { |
1081 | 1081 | console.log('init scroll'); |
1082 | 1082 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | function aui_init_flatpickr(){ |
261 | 261 | if ( typeof jQuery.fn.flatpickr === "function" && !$aui_doing_init_flatpickr) { |
262 | 262 | $aui_doing_init_flatpickr = true; |
263 | - <?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 } ?> |
|
263 | + <?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 } ?> |
|
264 | 264 | jQuery('input[data-aui-init="flatpickr"]:not(.flatpickr-input)').flatpickr(); |
265 | 265 | } |
266 | 266 | $aui_doing_init_flatpickr = false; |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | |
1077 | 1077 | <?php |
1078 | 1078 | // FSE tweaks. |
1079 | - if(!empty($_REQUEST['postType']) || !empty($_REQUEST['canvas']) ){ ?> |
|
1079 | + if (!empty($_REQUEST['postType']) || !empty($_REQUEST['canvas'])) { ?> |
|
1080 | 1080 | function aui_fse_set_data_scroll() { |
1081 | 1081 | console.log('init scroll'); |
1082 | 1082 | let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas"); |
@@ -962,8 +962,8 @@ |
||
962 | 962 | aui_flip_color_scheme_on_scroll(); |
963 | 963 | |
964 | 964 | <?php |
965 | - // FSE tweaks. |
|
966 | - if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template' || !empty($_REQUEST['canvas']) ){ ?> |
|
965 | + // FSE tweaks. |
|
966 | + if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template' || !empty($_REQUEST['canvas']) ){ ?> |
|
967 | 967 | function aui_fse_set_data_scroll() { |
968 | 968 | console.log('init scroll'); |
969 | 969 | 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; |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | |
964 | 964 | <?php |
965 | 965 | // FSE tweaks. |
966 | - if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template' || !empty($_REQUEST['canvas']) ){ ?> |
|
966 | + if (!empty($_REQUEST['postType']) && $_REQUEST['postType'] == 'wp_template' || !empty($_REQUEST['canvas'])) { ?> |
|
967 | 967 | function aui_fse_set_data_scroll() { |
968 | 968 | console.log('init scroll'); |
969 | 969 | 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,472 +21,472 @@ 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.36'; |
|
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 { |
|
119 | 32 | |
120 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
33 | + /** |
|
34 | + * Class version version. |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + public $version = '0.2.36'; |
|
121 | 39 | |
122 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
123 | - } |
|
40 | + /** |
|
41 | + * Class textdomain. |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + public $textdomain = 'aui'; |
|
124 | 46 | |
125 | - return self::$instance; |
|
126 | - } |
|
47 | + /** |
|
48 | + * Latest version of Bootstrap at time of publish published. |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + public $latest = "5.2.2"; |
|
127 | 53 | |
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 ){ |
|
54 | + /** |
|
55 | + * Current version of select2 being used. |
|
56 | + * |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + public $select2_version = "4.0.11"; |
|
138 | 60 | |
61 | + /** |
|
62 | + * The title. |
|
63 | + * |
|
64 | + * @var string |
|
65 | + */ |
|
66 | + public $name = 'AyeCode UI'; |
|
139 | 67 | |
140 | - $setting = wp_get_global_settings(); |
|
68 | + /** |
|
69 | + * The relative url to the assets. |
|
70 | + * |
|
71 | + * @var string |
|
72 | + */ |
|
73 | + public $url = ''; |
|
141 | 74 | |
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() { |
|
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 | + } |
|
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'; |
|
467 | - $rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : ''; |
|
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 | + $rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : ''; |
|
468 | 468 | $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
469 | 469 | |
470 | - if ( $this->settings[ $css_setting ] ) { |
|
471 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
472 | - $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'; |
|
470 | + if ( $this->settings[ $css_setting ] ) { |
|
471 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
472 | + $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'; |
|
473 | 473 | |
474 | - wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
475 | - wp_enqueue_style( 'ayecode-ui' ); |
|
474 | + wp_register_style( 'ayecode-ui', $url, array(), $this->version ); |
|
475 | + wp_enqueue_style( 'ayecode-ui' ); |
|
476 | 476 | |
477 | - if ( is_admin() && ( !empty($_REQUEST['postType']) || self::is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
478 | - $url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css'; |
|
479 | - wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version ); |
|
480 | - wp_enqueue_style( 'ayecode-ui-fse' ); |
|
481 | - $load_fse = true; |
|
482 | - } |
|
477 | + if ( is_admin() && ( !empty($_REQUEST['postType']) || self::is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
478 | + $url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css'; |
|
479 | + wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version ); |
|
480 | + wp_enqueue_style( 'ayecode-ui-fse' ); |
|
481 | + $load_fse = true; |
|
482 | + } |
|
483 | 483 | |
484 | - // flatpickr |
|
485 | - wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version ); |
|
484 | + // flatpickr |
|
485 | + wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version ); |
|
486 | 486 | |
487 | - // fix some wp-admin issues |
|
488 | - if(is_admin()){ |
|
489 | - $custom_css = " |
|
487 | + // fix some wp-admin issues |
|
488 | + if(is_admin()){ |
|
489 | + $custom_css = " |
|
490 | 490 | body{ |
491 | 491 | background-color: #f1f1f1; |
492 | 492 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -526,63 +526,63 @@ discard block |
||
526 | 526 | } |
527 | 527 | "; |
528 | 528 | |
529 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
530 | - $custom_css .= " |
|
529 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
530 | + $custom_css .= " |
|
531 | 531 | .edit-post-sidebar input[type=color].components-text-control__input{ |
532 | 532 | padding: 0; |
533 | 533 | } |
534 | 534 | "; |
535 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
536 | - } |
|
537 | - |
|
538 | - // custom changes |
|
539 | - if ( $load_fse ) { |
|
540 | - wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility, true) ); |
|
541 | - }else{ |
|
542 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
543 | - } |
|
544 | - } |
|
545 | - } |
|
546 | - } |
|
547 | - |
|
548 | - /** |
|
549 | - * Get inline script used if bootstrap enqueued |
|
550 | - * |
|
551 | - * If this remains small then its best to use this than to add another JS file. |
|
552 | - */ |
|
553 | - public function inline_script() { |
|
554 | - global $aui_bs5; |
|
555 | - // Flatpickr calendar locale |
|
556 | - $flatpickr_locale = self::flatpickr_locale(); |
|
535 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
536 | + } |
|
537 | + |
|
538 | + // custom changes |
|
539 | + if ( $load_fse ) { |
|
540 | + wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility, true) ); |
|
541 | + }else{ |
|
542 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
543 | + } |
|
544 | + } |
|
545 | + } |
|
546 | + } |
|
557 | 547 | |
558 | - ob_start(); |
|
559 | - if ( $aui_bs5 ) { |
|
560 | - include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' ); |
|
561 | - }else{ |
|
562 | - include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' ); |
|
548 | + /** |
|
549 | + * Get inline script used if bootstrap enqueued |
|
550 | + * |
|
551 | + * If this remains small then its best to use this than to add another JS file. |
|
552 | + */ |
|
553 | + public function inline_script() { |
|
554 | + global $aui_bs5; |
|
555 | + // Flatpickr calendar locale |
|
556 | + $flatpickr_locale = self::flatpickr_locale(); |
|
557 | + |
|
558 | + ob_start(); |
|
559 | + if ( $aui_bs5 ) { |
|
560 | + include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' ); |
|
561 | + }else{ |
|
562 | + include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' ); |
|
563 | 563 | } |
564 | 564 | |
565 | - $output = ob_get_clean(); |
|
565 | + $output = ob_get_clean(); |
|
566 | 566 | |
567 | - /* |
|
567 | + /* |
|
568 | 568 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
569 | 569 | */ |
570 | - return str_replace( array( |
|
571 | - '<script>', |
|
572 | - '</script>' |
|
573 | - ), '', self::minify_js($output) ); |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
579 | - * |
|
580 | - * @TODO we may need this when other conflicts arrise. |
|
581 | - * @return mixed |
|
582 | - */ |
|
583 | - public static function bs3_compat_js() { |
|
584 | - ob_start(); |
|
585 | - ?> |
|
570 | + return str_replace( array( |
|
571 | + '<script>', |
|
572 | + '</script>' |
|
573 | + ), '', self::minify_js($output) ); |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
579 | + * |
|
580 | + * @TODO we may need this when other conflicts arrise. |
|
581 | + * @return mixed |
|
582 | + */ |
|
583 | + public static function bs3_compat_js() { |
|
584 | + ob_start(); |
|
585 | + ?> |
|
586 | 586 | <script> |
587 | 587 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
588 | 588 | /* With Avada builder */ |
@@ -590,20 +590,20 @@ discard block |
||
590 | 590 | <?php } ?> |
591 | 591 | </script> |
592 | 592 | <?php |
593 | - return str_replace( array( |
|
594 | - '<script>', |
|
595 | - '</script>' |
|
596 | - ), '', ob_get_clean()); |
|
597 | - } |
|
598 | - |
|
599 | - /** |
|
600 | - * Get inline script used if bootstrap file browser enqueued. |
|
601 | - * |
|
602 | - * If this remains small then its best to use this than to add another JS file. |
|
603 | - */ |
|
604 | - public function inline_script_file_browser(){ |
|
605 | - ob_start(); |
|
606 | - ?> |
|
593 | + return str_replace( array( |
|
594 | + '<script>', |
|
595 | + '</script>' |
|
596 | + ), '', ob_get_clean()); |
|
597 | + } |
|
598 | + |
|
599 | + /** |
|
600 | + * Get inline script used if bootstrap file browser enqueued. |
|
601 | + * |
|
602 | + * If this remains small then its best to use this than to add another JS file. |
|
603 | + */ |
|
604 | + public function inline_script_file_browser(){ |
|
605 | + ob_start(); |
|
606 | + ?> |
|
607 | 607 | <script> |
608 | 608 | // run on doc ready |
609 | 609 | jQuery(document).ready(function () { |
@@ -611,127 +611,127 @@ discard block |
||
611 | 611 | }); |
612 | 612 | </script> |
613 | 613 | <?php |
614 | - $output = ob_get_clean(); |
|
614 | + $output = ob_get_clean(); |
|
615 | 615 | |
616 | - /* |
|
616 | + /* |
|
617 | 617 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
618 | 618 | */ |
619 | - return str_replace( array( |
|
620 | - '<script>', |
|
621 | - '</script>' |
|
622 | - ), '', $output ); |
|
623 | - } |
|
624 | - |
|
625 | - /** |
|
626 | - * Adds the Font Awesome JS. |
|
627 | - */ |
|
628 | - public function enqueue_scripts() { |
|
629 | - if( is_admin() && !$this->is_aui_screen()){ |
|
630 | - // Don't add wp-admin scripts if not requested to. |
|
631 | - } else { |
|
632 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
633 | - |
|
634 | - $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
|
635 | - |
|
636 | - // select2 |
|
637 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
638 | - |
|
639 | - // flatpickr |
|
640 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
641 | - |
|
642 | - // iconpicker |
|
643 | - if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
644 | - wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version ); |
|
645 | - }else{ |
|
646 | - wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
647 | - } |
|
619 | + return str_replace( array( |
|
620 | + '<script>', |
|
621 | + '</script>' |
|
622 | + ), '', $output ); |
|
623 | + } |
|
648 | 624 | |
649 | - // Bootstrap file browser |
|
650 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
651 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
625 | + /** |
|
626 | + * Adds the Font Awesome JS. |
|
627 | + */ |
|
628 | + public function enqueue_scripts() { |
|
629 | + if( is_admin() && !$this->is_aui_screen()){ |
|
630 | + // Don't add wp-admin scripts if not requested to. |
|
631 | + } else { |
|
632 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
652 | 633 | |
653 | - $load_inline = false; |
|
634 | + $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : ''; |
|
654 | 635 | |
655 | - // Load select2 only when required. |
|
656 | - if ( $this->force_load_select2() ) { |
|
657 | - $dependency = array( 'select2', 'jquery' ); |
|
658 | - } else { |
|
659 | - $dependency = array( 'jquery' ); |
|
660 | - } |
|
636 | + // select2 |
|
637 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
661 | 638 | |
662 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
663 | - // Bootstrap bundle |
|
664 | - $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js'; |
|
665 | - wp_register_script( 'bootstrap-js-bundle', $url, $dependency, $this->version, $this->is_bs3_compat() ); |
|
666 | - |
|
667 | - // If in admin then add to footer for compatibility. |
|
668 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
669 | - |
|
670 | - $script = $this->inline_script(); |
|
671 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
672 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
673 | - $url = $this->url . 'assets/js/popper.min.js'; // @todo we need to update this to bs5 |
|
674 | - wp_register_script( 'bootstrap-js-popper', $url, $dependency, $this->version ); |
|
675 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
676 | - $load_inline = true; |
|
677 | - } else { |
|
678 | - $load_inline = true; |
|
679 | - } |
|
639 | + // flatpickr |
|
640 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); |
|
641 | + |
|
642 | + // iconpicker |
|
643 | + if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) { |
|
644 | + wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version ); |
|
645 | + }else{ |
|
646 | + wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); |
|
647 | + } |
|
680 | 648 | |
681 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
682 | - if ( $load_inline ) { |
|
683 | - wp_register_script( 'bootstrap-dummy', '', $dependency ); |
|
684 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
649 | + // Bootstrap file browser |
|
650 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
651 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
685 | 652 | |
686 | - $script = $this->inline_script(); |
|
687 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
688 | - } |
|
689 | - } |
|
690 | - } |
|
691 | - |
|
692 | - /** |
|
693 | - * Enqueue select2 if called. |
|
694 | - * |
|
695 | - * @since 0.2.29 |
|
696 | - */ |
|
697 | - public function force_load_select2() { |
|
698 | - global $aui_select2_enqueued; |
|
699 | - |
|
700 | - $conditional_select2 = apply_filters( 'aui_is_conditional_select2', true ); |
|
701 | - |
|
702 | - if ( $conditional_select2 !== true ) { |
|
703 | - return true; |
|
704 | - } |
|
705 | - |
|
706 | - $load = is_admin() && ! $aui_select2_enqueued; |
|
707 | - |
|
708 | - return apply_filters( 'aui_force_load_select2', $load ); |
|
709 | - } |
|
710 | - |
|
711 | - /** |
|
712 | - * Enqueue select2 if called. |
|
713 | - * |
|
714 | - * @since 0.2.29 |
|
715 | - */ |
|
716 | - public function enqueue_select2() { |
|
717 | - wp_enqueue_script( 'select2' ); |
|
718 | - } |
|
719 | - |
|
720 | - /** |
|
721 | - * Enqueue flatpickr if called. |
|
722 | - */ |
|
723 | - public function enqueue_flatpickr(){ |
|
724 | - wp_enqueue_style( 'flatpickr' ); |
|
725 | - wp_enqueue_script( 'flatpickr' ); |
|
726 | - } |
|
727 | - |
|
728 | - /** |
|
729 | - * Enqueue iconpicker if called. |
|
730 | - */ |
|
731 | - public function enqueue_iconpicker(){ |
|
732 | - wp_enqueue_style( 'iconpicker' ); |
|
733 | - wp_enqueue_script( 'iconpicker' ); |
|
734 | - } |
|
653 | + $load_inline = false; |
|
654 | + |
|
655 | + // Load select2 only when required. |
|
656 | + if ( $this->force_load_select2() ) { |
|
657 | + $dependency = array( 'select2', 'jquery' ); |
|
658 | + } else { |
|
659 | + $dependency = array( 'jquery' ); |
|
660 | + } |
|
661 | + |
|
662 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
663 | + // Bootstrap bundle |
|
664 | + $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js'; |
|
665 | + wp_register_script( 'bootstrap-js-bundle', $url, $dependency, $this->version, $this->is_bs3_compat() ); |
|
666 | + |
|
667 | + // If in admin then add to footer for compatibility. |
|
668 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
669 | + |
|
670 | + $script = $this->inline_script(); |
|
671 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
672 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
673 | + $url = $this->url . 'assets/js/popper.min.js'; // @todo we need to update this to bs5 |
|
674 | + wp_register_script( 'bootstrap-js-popper', $url, $dependency, $this->version ); |
|
675 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
676 | + $load_inline = true; |
|
677 | + } else { |
|
678 | + $load_inline = true; |
|
679 | + } |
|
680 | + |
|
681 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
682 | + if ( $load_inline ) { |
|
683 | + wp_register_script( 'bootstrap-dummy', '', $dependency ); |
|
684 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
685 | + |
|
686 | + $script = $this->inline_script(); |
|
687 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
688 | + } |
|
689 | + } |
|
690 | + } |
|
691 | + |
|
692 | + /** |
|
693 | + * Enqueue select2 if called. |
|
694 | + * |
|
695 | + * @since 0.2.29 |
|
696 | + */ |
|
697 | + public function force_load_select2() { |
|
698 | + global $aui_select2_enqueued; |
|
699 | + |
|
700 | + $conditional_select2 = apply_filters( 'aui_is_conditional_select2', true ); |
|
701 | + |
|
702 | + if ( $conditional_select2 !== true ) { |
|
703 | + return true; |
|
704 | + } |
|
705 | + |
|
706 | + $load = is_admin() && ! $aui_select2_enqueued; |
|
707 | + |
|
708 | + return apply_filters( 'aui_force_load_select2', $load ); |
|
709 | + } |
|
710 | + |
|
711 | + /** |
|
712 | + * Enqueue select2 if called. |
|
713 | + * |
|
714 | + * @since 0.2.29 |
|
715 | + */ |
|
716 | + public function enqueue_select2() { |
|
717 | + wp_enqueue_script( 'select2' ); |
|
718 | + } |
|
719 | + |
|
720 | + /** |
|
721 | + * Enqueue flatpickr if called. |
|
722 | + */ |
|
723 | + public function enqueue_flatpickr(){ |
|
724 | + wp_enqueue_style( 'flatpickr' ); |
|
725 | + wp_enqueue_script( 'flatpickr' ); |
|
726 | + } |
|
727 | + |
|
728 | + /** |
|
729 | + * Enqueue iconpicker if called. |
|
730 | + */ |
|
731 | + public function enqueue_iconpicker(){ |
|
732 | + wp_enqueue_style( 'iconpicker' ); |
|
733 | + wp_enqueue_script( 'iconpicker' ); |
|
734 | + } |
|
735 | 735 | |
736 | 736 | /** |
737 | 737 | * Get the url path to the current folder. |
@@ -766,171 +766,171 @@ discard block |
||
766 | 766 | return trailingslashit($url); |
767 | 767 | } |
768 | 768 | |
769 | - /** |
|
770 | - * Get the url path to the current folder. |
|
771 | - * @todo remove |
|
772 | - * @return string |
|
773 | - */ |
|
774 | - public function get_url_old() { |
|
775 | - |
|
776 | - $url = ''; |
|
777 | - // check if we are inside a plugin |
|
778 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
779 | - |
|
780 | - // add check in-case user has changed wp-content dir name. |
|
781 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
782 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
783 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
784 | - |
|
785 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
786 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
787 | - } |
|
788 | - |
|
789 | - return $url; |
|
790 | - } |
|
791 | - |
|
792 | - /** |
|
793 | - * Register the database settings with WordPress. |
|
794 | - */ |
|
795 | - public function register_settings() { |
|
796 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
797 | - } |
|
798 | - |
|
799 | - /** |
|
800 | - * Add the WordPress settings menu item. |
|
801 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
802 | - */ |
|
803 | - public function menu_item() { |
|
804 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
805 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
806 | - $this, |
|
807 | - 'settings_page' |
|
808 | - ) ); |
|
809 | - } |
|
810 | - |
|
811 | - /** |
|
812 | - * Get a list of themes and their default JS settings. |
|
813 | - * |
|
814 | - * @return array |
|
815 | - */ |
|
816 | - public function theme_js_settings(){ |
|
817 | - return array( |
|
818 | - 'ayetheme' => 'popper', |
|
819 | - 'listimia' => 'required', |
|
820 | - 'listimia_backend' => 'core-popper', |
|
821 | - //'avada' => 'required', // removed as we now add compatibility |
|
822 | - ); |
|
823 | - } |
|
824 | - |
|
825 | - /** |
|
769 | + /** |
|
770 | + * Get the url path to the current folder. |
|
771 | + * @todo remove |
|
772 | + * @return string |
|
773 | + */ |
|
774 | + public function get_url_old() { |
|
775 | + |
|
776 | + $url = ''; |
|
777 | + // check if we are inside a plugin |
|
778 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
779 | + |
|
780 | + // add check in-case user has changed wp-content dir name. |
|
781 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
782 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
783 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
784 | + |
|
785 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
786 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
787 | + } |
|
788 | + |
|
789 | + return $url; |
|
790 | + } |
|
791 | + |
|
792 | + /** |
|
793 | + * Register the database settings with WordPress. |
|
794 | + */ |
|
795 | + public function register_settings() { |
|
796 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
797 | + } |
|
798 | + |
|
799 | + /** |
|
800 | + * Add the WordPress settings menu item. |
|
801 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
802 | + */ |
|
803 | + public function menu_item() { |
|
804 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
805 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
806 | + $this, |
|
807 | + 'settings_page' |
|
808 | + ) ); |
|
809 | + } |
|
810 | + |
|
811 | + /** |
|
812 | + * Get a list of themes and their default JS settings. |
|
813 | + * |
|
814 | + * @return array |
|
815 | + */ |
|
816 | + public function theme_js_settings(){ |
|
817 | + return array( |
|
818 | + 'ayetheme' => 'popper', |
|
819 | + 'listimia' => 'required', |
|
820 | + 'listimia_backend' => 'core-popper', |
|
821 | + //'avada' => 'required', // removed as we now add compatibility |
|
822 | + ); |
|
823 | + } |
|
824 | + |
|
825 | + /** |
|
826 | 826 | * Get the date the site was installed. |
827 | 827 | * |
828 | - * @return false|string |
|
829 | - */ |
|
828 | + * @return false|string |
|
829 | + */ |
|
830 | 830 | public function get_site_install_date() { |
831 | - global $wpdb; // This gives you access to the WordPress database object |
|
831 | + global $wpdb; // This gives you access to the WordPress database object |
|
832 | 832 | |
833 | - // Prepare the SQL query to get the oldest registration date |
|
834 | - $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}"; |
|
833 | + // Prepare the SQL query to get the oldest registration date |
|
834 | + $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}"; |
|
835 | 835 | |
836 | - // Execute the query |
|
837 | - $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
836 | + // Execute the query |
|
837 | + $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
|
838 | 838 | |
839 | - return $date ? $date : false; |
|
839 | + return $date ? $date : false; |
|
840 | 840 | } |
841 | 841 | |
842 | - /** |
|
843 | - * Show admin notice if backend scripts not loaded. |
|
844 | - */ |
|
845 | - public function show_admin_version_notice(){ |
|
846 | - $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" ); |
|
847 | - $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>'; |
|
848 | - $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; |
|
849 | - echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
850 | - } |
|
851 | - |
|
852 | - /** |
|
853 | - * Get the current Font Awesome output settings. |
|
854 | - * |
|
855 | - * @return array The array of settings. |
|
856 | - */ |
|
857 | - public function get_settings() { |
|
858 | - |
|
859 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
842 | + /** |
|
843 | + * Show admin notice if backend scripts not loaded. |
|
844 | + */ |
|
845 | + public function show_admin_version_notice(){ |
|
846 | + $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" ); |
|
847 | + $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>'; |
|
848 | + $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; |
|
849 | + echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>'; |
|
850 | + } |
|
851 | + |
|
852 | + /** |
|
853 | + * Get the current Font Awesome output settings. |
|
854 | + * |
|
855 | + * @return array The array of settings. |
|
856 | + */ |
|
857 | + public function get_settings() { |
|
858 | + |
|
859 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
860 | 860 | |
861 | 861 | // Maybe show default version notice |
862 | - $site_install_date = new DateTime( self::get_site_install_date() ); |
|
863 | - $switch_over_date = new DateTime("2024-02-01"); |
|
864 | - if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) { |
|
865 | - add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) ); |
|
866 | - } |
|
867 | - |
|
868 | - $js_default = 'core-popper'; |
|
869 | - $js_default_backend = $js_default; |
|
870 | - |
|
871 | - // maybe set defaults (if no settings set) |
|
872 | - if(empty($db_settings)){ |
|
873 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
874 | - $theme_js_settings = self::theme_js_settings(); |
|
875 | - if(isset($theme_js_settings[$active_theme])){ |
|
876 | - $js_default = $theme_js_settings[$active_theme]; |
|
877 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
878 | - } |
|
879 | - } |
|
862 | + $site_install_date = new DateTime( self::get_site_install_date() ); |
|
863 | + $switch_over_date = new DateTime("2024-02-01"); |
|
864 | + if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) { |
|
865 | + add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) ); |
|
866 | + } |
|
880 | 867 | |
881 | - /** |
|
882 | - * Filter the default settings. |
|
883 | - */ |
|
884 | - $defaults = apply_filters( 'ayecode-ui-default-settings', array( |
|
885 | - 'css' => 'compatibility', // core, compatibility |
|
886 | - 'js' => $js_default, // js to load, core-popper, popper |
|
887 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
888 | - 'css_backend' => 'compatibility', // core, compatibility |
|
889 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
890 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
868 | + $js_default = 'core-popper'; |
|
869 | + $js_default_backend = $js_default; |
|
870 | + |
|
871 | + // maybe set defaults (if no settings set) |
|
872 | + if(empty($db_settings)){ |
|
873 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
874 | + $theme_js_settings = self::theme_js_settings(); |
|
875 | + if(isset($theme_js_settings[$active_theme])){ |
|
876 | + $js_default = $theme_js_settings[$active_theme]; |
|
877 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
878 | + } |
|
879 | + } |
|
880 | + |
|
881 | + /** |
|
882 | + * Filter the default settings. |
|
883 | + */ |
|
884 | + $defaults = apply_filters( 'ayecode-ui-default-settings', array( |
|
885 | + 'css' => 'compatibility', // core, compatibility |
|
886 | + 'js' => $js_default, // js to load, core-popper, popper |
|
887 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
888 | + 'css_backend' => 'compatibility', // core, compatibility |
|
889 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
890 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
891 | 891 | 'bs_ver' => '5', // The default bootstrap version to sue by default |
892 | - ), $db_settings ); |
|
892 | + ), $db_settings ); |
|
893 | 893 | |
894 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
894 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
895 | 895 | |
896 | - /** |
|
897 | - * Filter the Bootstrap settings. |
|
898 | - * |
|
899 | - * @todo if we add this filer people might use it and then it defeats the purpose of this class :/ |
|
900 | - */ |
|
901 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
902 | - } |
|
896 | + /** |
|
897 | + * Filter the Bootstrap settings. |
|
898 | + * |
|
899 | + * @todo if we add this filer people might use it and then it defeats the purpose of this class :/ |
|
900 | + */ |
|
901 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
902 | + } |
|
903 | 903 | |
904 | 904 | |
905 | - /** |
|
906 | - * The settings page html output. |
|
907 | - */ |
|
908 | - public function settings_page() { |
|
909 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
910 | - wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) ); |
|
911 | - } |
|
905 | + /** |
|
906 | + * The settings page html output. |
|
907 | + */ |
|
908 | + public function settings_page() { |
|
909 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
910 | + wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) ); |
|
911 | + } |
|
912 | 912 | $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() ); |
913 | 913 | |
914 | - ?> |
|
914 | + ?> |
|
915 | 915 | <div class="wrap"> |
916 | 916 | <h1><?php echo esc_attr( $this->name ); ?></h1> |
917 | 917 | <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> |
918 | 918 | <form method="post" action="options.php"> |
919 | 919 | <?php |
920 | - settings_fields( 'ayecode-ui-settings' ); |
|
921 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
922 | - ?> |
|
920 | + settings_fields( 'ayecode-ui-settings' ); |
|
921 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
922 | + ?> |
|
923 | 923 | |
924 | 924 | <h2><?php esc_html_e( 'BootStrap Version', 'ayecode-connect' ); ?></h2> |
925 | 925 | <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> |
926 | 926 | <div class="bsui"><?php |
927 | - if ( ! empty( $overrides ) ) { |
|
928 | - echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
929 | - 'type'=> 'info', |
|
930 | - 'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' ) |
|
931 | - )); |
|
932 | - } |
|
933 | - ?> |
|
927 | + if ( ! empty( $overrides ) ) { |
|
928 | + echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
929 | + 'type'=> 'info', |
|
930 | + 'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' ) |
|
931 | + )); |
|
932 | + } |
|
933 | + ?> |
|
934 | 934 | </div> |
935 | 935 | <table class="form-table wpbs-table-version-settings"> |
936 | 936 | <tr valign="top"> |
@@ -1014,77 +1014,77 @@ discard block |
||
1014 | 1014 | </table> |
1015 | 1015 | |
1016 | 1016 | <?php |
1017 | - submit_button(); |
|
1018 | - ?> |
|
1017 | + submit_button(); |
|
1018 | + ?> |
|
1019 | 1019 | </form> |
1020 | 1020 | <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo esc_html( $this->version ); ?></div> |
1021 | 1021 | </div> |
1022 | 1022 | <?php |
1023 | - } |
|
1023 | + } |
|
1024 | 1024 | |
1025 | 1025 | public function get_load_source(){ |
1026 | - $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
1027 | - $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
1028 | - |
|
1029 | - // Find source plugin/theme of SD |
|
1030 | - $source = array(); |
|
1031 | - if ( strpos( $file, $plugins_dir ) !== false ) { |
|
1032 | - $source = explode( "/", plugin_basename( $file ) ); |
|
1033 | - } else if ( function_exists( 'get_theme_root' ) ) { |
|
1034 | - $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
1035 | - |
|
1036 | - if ( strpos( $file, $themes_dir ) !== false ) { |
|
1037 | - $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
1038 | - } |
|
1039 | - } |
|
1026 | + $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) ); |
|
1027 | + $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) ); |
|
1028 | + |
|
1029 | + // Find source plugin/theme of SD |
|
1030 | + $source = array(); |
|
1031 | + if ( strpos( $file, $plugins_dir ) !== false ) { |
|
1032 | + $source = explode( "/", plugin_basename( $file ) ); |
|
1033 | + } else if ( function_exists( 'get_theme_root' ) ) { |
|
1034 | + $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) ); |
|
1035 | + |
|
1036 | + if ( strpos( $file, $themes_dir ) !== false ) { |
|
1037 | + $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) ); |
|
1038 | + } |
|
1039 | + } |
|
1040 | 1040 | |
1041 | 1041 | return isset($source[0]) ? esc_attr($source[0]) : ''; |
1042 | 1042 | } |
1043 | 1043 | |
1044 | - public function customizer_settings($wp_customize){ |
|
1045 | - $wp_customize->add_section('aui_settings', array( |
|
1046 | - 'title' => __('AyeCode UI', 'ayecode-connect' ), |
|
1047 | - 'priority' => 120, |
|
1048 | - )); |
|
1049 | - |
|
1050 | - // ============================= |
|
1051 | - // = Color Picker = |
|
1052 | - // ============================= |
|
1053 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1054 | - 'default' => AUI_PRIMARY_COLOR, |
|
1055 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1056 | - 'capability' => 'edit_theme_options', |
|
1057 | - 'type' => 'option', |
|
1058 | - 'transport' => 'refresh', |
|
1059 | - )); |
|
1060 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1061 | - 'label' => __('Primary Color', 'ayecode-connect' ), |
|
1062 | - 'section' => 'aui_settings', |
|
1063 | - 'settings' => 'aui_options[color_primary]', |
|
1064 | - ))); |
|
1065 | - |
|
1066 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1067 | - 'default' => '#6c757d', |
|
1068 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1069 | - 'capability' => 'edit_theme_options', |
|
1070 | - 'type' => 'option', |
|
1071 | - 'transport' => 'refresh', |
|
1072 | - )); |
|
1073 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1074 | - 'label' => __('Secondary Color', 'ayecode-connect' ), |
|
1075 | - 'section' => 'aui_settings', |
|
1076 | - 'settings' => 'aui_options[color_secondary]', |
|
1077 | - ))); |
|
1078 | - } |
|
1079 | - |
|
1080 | - /** |
|
1081 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1082 | - * |
|
1083 | - * @return mixed |
|
1084 | - */ |
|
1085 | - public static function bs3_compat_css() { |
|
1086 | - ob_start(); |
|
1087 | - ?> |
|
1044 | + public function customizer_settings($wp_customize){ |
|
1045 | + $wp_customize->add_section('aui_settings', array( |
|
1046 | + 'title' => __('AyeCode UI', 'ayecode-connect' ), |
|
1047 | + 'priority' => 120, |
|
1048 | + )); |
|
1049 | + |
|
1050 | + // ============================= |
|
1051 | + // = Color Picker = |
|
1052 | + // ============================= |
|
1053 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1054 | + 'default' => AUI_PRIMARY_COLOR, |
|
1055 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1056 | + 'capability' => 'edit_theme_options', |
|
1057 | + 'type' => 'option', |
|
1058 | + 'transport' => 'refresh', |
|
1059 | + )); |
|
1060 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1061 | + 'label' => __('Primary Color', 'ayecode-connect' ), |
|
1062 | + 'section' => 'aui_settings', |
|
1063 | + 'settings' => 'aui_options[color_primary]', |
|
1064 | + ))); |
|
1065 | + |
|
1066 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1067 | + 'default' => '#6c757d', |
|
1068 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1069 | + 'capability' => 'edit_theme_options', |
|
1070 | + 'type' => 'option', |
|
1071 | + 'transport' => 'refresh', |
|
1072 | + )); |
|
1073 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1074 | + 'label' => __('Secondary Color', 'ayecode-connect' ), |
|
1075 | + 'section' => 'aui_settings', |
|
1076 | + 'settings' => 'aui_options[color_secondary]', |
|
1077 | + ))); |
|
1078 | + } |
|
1079 | + |
|
1080 | + /** |
|
1081 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1082 | + * |
|
1083 | + * @return mixed |
|
1084 | + */ |
|
1085 | + public static function bs3_compat_css() { |
|
1086 | + ob_start(); |
|
1087 | + ?> |
|
1088 | 1088 | <style> |
1089 | 1089 | /* Bootstrap 3 compatibility */ |
1090 | 1090 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1113,374 +1113,374 @@ discard block |
||
1113 | 1113 | <?php } ?> |
1114 | 1114 | </style> |
1115 | 1115 | <?php |
1116 | - return str_replace( array( |
|
1117 | - '<style>', |
|
1118 | - '</style>' |
|
1119 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1120 | - } |
|
1116 | + return str_replace( array( |
|
1117 | + '<style>', |
|
1118 | + '</style>' |
|
1119 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1120 | + } |
|
1121 | 1121 | |
1122 | - public static function custom_css( $compatibility = true, $is_fse = false ) { |
|
1123 | - global $aui_bs5; |
|
1122 | + public static function custom_css( $compatibility = true, $is_fse = false ) { |
|
1123 | + global $aui_bs5; |
|
1124 | 1124 | |
1125 | - $colors = array(); |
|
1125 | + $colors = array(); |
|
1126 | 1126 | |
1127 | - if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
1128 | - $setting = wp_get_global_settings(); |
|
1127 | + if ( defined( 'BLOCKSTRAP_VERSION' ) ) { |
|
1128 | + $setting = wp_get_global_settings(); |
|
1129 | 1129 | |
1130 | - if ( ! empty( $setting['color']['palette']['theme'] ) ) { |
|
1131 | - foreach ( $setting['color']['palette']['theme'] as $color ) { |
|
1132 | - $colors[$color['slug']] = esc_attr( $color['color'] ); |
|
1133 | - } |
|
1134 | - } |
|
1130 | + if ( ! empty( $setting['color']['palette']['theme'] ) ) { |
|
1131 | + foreach ( $setting['color']['palette']['theme'] as $color ) { |
|
1132 | + $colors[$color['slug']] = esc_attr( $color['color'] ); |
|
1133 | + } |
|
1134 | + } |
|
1135 | 1135 | |
1136 | - if ( ! empty( $setting['color']['palette']['custom'] ) ) { |
|
1137 | - foreach ( $setting['color']['palette']['custom'] as $color ) { |
|
1138 | - $colors[$color['slug']] = esc_attr( $color['color'] ); |
|
1139 | - } |
|
1140 | - } |
|
1141 | - } else { |
|
1142 | - $settings = get_option( 'aui_options' ); |
|
1143 | - |
|
1144 | - $colors = array( |
|
1145 | - 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
1146 | - 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
1147 | - ); |
|
1148 | - } |
|
1149 | - |
|
1150 | - ob_start(); |
|
1151 | - ?><style><?php |
|
1152 | - // BS v3 compat |
|
1153 | - if( self::is_bs3_compat() ){ |
|
1154 | - echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1155 | - } |
|
1156 | - |
|
1157 | - //$is_fse = false; |
|
1158 | - //if ( is_admin() && ( !empty($_REQUEST['postType']) || self::is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
1159 | - //$is_fse = true; |
|
1160 | - //} |
|
1161 | - |
|
1162 | - $custom_front = ! is_admin() ? true : apply_filters('ayecode_ui_custom_front', false ); |
|
1163 | - $custom_admin = $is_fse || self::is_preview() ? true : apply_filters('ayecode_ui_custom_admin', false ); |
|
1136 | + if ( ! empty( $setting['color']['palette']['custom'] ) ) { |
|
1137 | + foreach ( $setting['color']['palette']['custom'] as $color ) { |
|
1138 | + $colors[$color['slug']] = esc_attr( $color['color'] ); |
|
1139 | + } |
|
1140 | + } |
|
1141 | + } else { |
|
1142 | + $settings = get_option( 'aui_options' ); |
|
1143 | + |
|
1144 | + $colors = array( |
|
1145 | + 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, |
|
1146 | + 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR |
|
1147 | + ); |
|
1148 | + } |
|
1149 | + |
|
1150 | + ob_start(); |
|
1151 | + ?><style><?php |
|
1152 | + // BS v3 compat |
|
1153 | + if( self::is_bs3_compat() ){ |
|
1154 | + echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1155 | + } |
|
1156 | + |
|
1157 | + //$is_fse = false; |
|
1158 | + //if ( is_admin() && ( !empty($_REQUEST['postType']) || self::is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) ) ) { |
|
1159 | + //$is_fse = true; |
|
1160 | + //} |
|
1161 | + |
|
1162 | + $custom_front = ! is_admin() ? true : apply_filters('ayecode_ui_custom_front', false ); |
|
1163 | + $custom_admin = $is_fse || self::is_preview() ? true : apply_filters('ayecode_ui_custom_admin', false ); |
|
1164 | 1164 | $bs_custom_css = apply_filters( 'ayecode_ui_bs_custom_css', $custom_admin || $custom_front ); |
1165 | - //$bs_custom_css = true; // Force true to fix any color issue. |
|
1165 | + //$bs_custom_css = true; // Force true to fix any color issue. |
|
1166 | 1166 | |
1167 | - $colors_css = ''; |
|
1168 | - if ( ! empty( $colors ) && $bs_custom_css ) { |
|
1169 | - $d_colors = self::get_colors(true); |
|
1167 | + $colors_css = ''; |
|
1168 | + if ( ! empty( $colors ) && $bs_custom_css ) { |
|
1169 | + $d_colors = self::get_colors(true); |
|
1170 | 1170 | |
1171 | - foreach ( $colors as $key => $color ) { |
|
1172 | - if ( ( empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
1173 | - $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
|
1174 | - $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
|
1171 | + foreach ( $colors as $key => $color ) { |
|
1172 | + if ( ( empty( $d_colors[$key]) || $d_colors[$key] != $color) || $is_fse ) { |
|
1173 | + $var = $is_fse ? "var(--wp--preset--color--$key)" : $color; |
|
1174 | + $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility; |
|
1175 | 1175 | |
1176 | - $colors_css .= $aui_bs5 ? self::css_overwrite_bs5( $key,$var, $compat, $color ) : self::css_overwrite( $key, $var, $compat, $color ); |
|
1177 | - } |
|
1178 | - } |
|
1179 | - } |
|
1176 | + $colors_css .= $aui_bs5 ? self::css_overwrite_bs5( $key,$var, $compat, $color ) : self::css_overwrite( $key, $var, $compat, $color ); |
|
1177 | + } |
|
1178 | + } |
|
1179 | + } |
|
1180 | 1180 | |
1181 | - if ( $colors_css ) { |
|
1182 | - echo $colors_css; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1183 | - } |
|
1181 | + if ( $colors_css ) { |
|
1182 | + echo $colors_css; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1183 | + } |
|
1184 | 1184 | |
1185 | - // Set admin bar z-index lower when modal is open. |
|
1186 | - echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
1185 | + // Set admin bar z-index lower when modal is open. |
|
1186 | + echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}'; |
|
1187 | 1187 | |
1188 | - if ( is_admin() ) { |
|
1189 | - echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
1190 | - } |
|
1188 | + if ( is_admin() ) { |
|
1189 | + echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}'; |
|
1190 | + } |
|
1191 | 1191 | |
1192 | - $custom_css = ''; |
|
1192 | + $custom_css = ''; |
|
1193 | 1193 | |
1194 | - if ( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' ) && $bs_custom_css ) { |
|
1195 | - $css = ''; |
|
1196 | - $theme_settings = wp_get_global_styles(); |
|
1194 | + if ( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' ) && $bs_custom_css ) { |
|
1195 | + $css = ''; |
|
1196 | + $theme_settings = wp_get_global_styles(); |
|
1197 | 1197 | |
1198 | - // Font face |
|
1199 | - if( !empty( $theme_settings['typography']['fontFamily'] ) ){ |
|
1200 | - $t_fontface = str_replace( array('var:preset|','font-family|'), array('--wp--preset--','font-family--'), $theme_settings['typography']['fontFamily'] ); //var(--wp--preset--font-family--poppins) |
|
1201 | - $css .= '--bs-body-font-family: ' . esc_attr($t_fontface) . ';'; |
|
1202 | - } |
|
1198 | + // Font face |
|
1199 | + if( !empty( $theme_settings['typography']['fontFamily'] ) ){ |
|
1200 | + $t_fontface = str_replace( array('var:preset|','font-family|'), array('--wp--preset--','font-family--'), $theme_settings['typography']['fontFamily'] ); //var(--wp--preset--font-family--poppins) |
|
1201 | + $css .= '--bs-body-font-family: ' . esc_attr($t_fontface) . ';'; |
|
1202 | + } |
|
1203 | 1203 | |
1204 | - // font size |
|
1205 | - if( !empty( $theme_settings['typography']['fontSize'] ) ){ |
|
1206 | - $css .= '--bs-body-font-size: ' . esc_attr( $theme_settings['typography']['fontSize'] ) . ' ;'; |
|
1207 | - } |
|
1204 | + // font size |
|
1205 | + if( !empty( $theme_settings['typography']['fontSize'] ) ){ |
|
1206 | + $css .= '--bs-body-font-size: ' . esc_attr( $theme_settings['typography']['fontSize'] ) . ' ;'; |
|
1207 | + } |
|
1208 | 1208 | |
1209 | - // line height |
|
1210 | - if( !empty( $theme_settings['typography']['lineHeight'] ) ){ |
|
1211 | - $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';'; |
|
1212 | - } |
|
1209 | + // line height |
|
1210 | + if( !empty( $theme_settings['typography']['lineHeight'] ) ){ |
|
1211 | + $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';'; |
|
1212 | + } |
|
1213 | 1213 | |
1214 | 1214 | |
1215 | - // font weight |
|
1216 | - if( !empty( $theme_settings['typography']['fontWeight'] ) ){ |
|
1217 | - $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';'; |
|
1218 | - } |
|
1215 | + // font weight |
|
1216 | + if( !empty( $theme_settings['typography']['fontWeight'] ) ){ |
|
1217 | + $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';'; |
|
1218 | + } |
|
1219 | 1219 | |
1220 | - // Background |
|
1221 | - if( !empty( $theme_settings['color']['background'] ) ){ |
|
1222 | - $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';'; |
|
1223 | - } |
|
1220 | + // Background |
|
1221 | + if( !empty( $theme_settings['color']['background'] ) ){ |
|
1222 | + $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';'; |
|
1223 | + } |
|
1224 | 1224 | |
1225 | - // Background Gradient |
|
1226 | - if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
1227 | - $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';'; |
|
1228 | - } |
|
1225 | + // Background Gradient |
|
1226 | + if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
1227 | + $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';'; |
|
1228 | + } |
|
1229 | 1229 | |
1230 | - // Background Gradient |
|
1231 | - if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
1232 | - $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';'; |
|
1233 | - } |
|
1230 | + // Background Gradient |
|
1231 | + if( !empty( $theme_settings['color']['gradient'] ) ){ |
|
1232 | + $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';'; |
|
1233 | + } |
|
1234 | 1234 | |
1235 | - // text color |
|
1236 | - if( !empty( $theme_settings['color']['text'] ) ){ |
|
1237 | - $css .= '--bs-body-color: ' . esc_attr( $theme_settings['color']['text'] ) . ';'; |
|
1238 | - } |
|
1235 | + // text color |
|
1236 | + if( !empty( $theme_settings['color']['text'] ) ){ |
|
1237 | + $css .= '--bs-body-color: ' . esc_attr( $theme_settings['color']['text'] ) . ';'; |
|
1238 | + } |
|
1239 | 1239 | |
1240 | 1240 | |
1241 | - // link colors |
|
1242 | - if( !empty( $theme_settings['elements']['link']['color']['text'] ) ){ |
|
1243 | - $css .= '--bs-link-color: ' . esc_attr( $theme_settings['elements']['link']['color']['text'] ) . ';'; |
|
1244 | - } |
|
1245 | - if( !empty( $theme_settings['elements']['link'][':hover']['color']['text'] ) ){ |
|
1246 | - $css .= '--bs-link-hover-color: ' . esc_attr( $theme_settings['elements']['link'][':hover']['color']['text'] ) . ';'; |
|
1247 | - } |
|
1241 | + // link colors |
|
1242 | + if( !empty( $theme_settings['elements']['link']['color']['text'] ) ){ |
|
1243 | + $css .= '--bs-link-color: ' . esc_attr( $theme_settings['elements']['link']['color']['text'] ) . ';'; |
|
1244 | + } |
|
1245 | + if( !empty( $theme_settings['elements']['link'][':hover']['color']['text'] ) ){ |
|
1246 | + $css .= '--bs-link-hover-color: ' . esc_attr( $theme_settings['elements']['link'][':hover']['color']['text'] ) . ';'; |
|
1247 | + } |
|
1248 | 1248 | |
1249 | - if($css){ |
|
1250 | - $custom_css .= $is_fse ? 'body.editor-styles-wrapper{' . esc_attr( $css ) . '}' : 'body{' . esc_attr( $css ) . '}'; |
|
1251 | - } |
|
1249 | + if($css){ |
|
1250 | + $custom_css .= $is_fse ? 'body.editor-styles-wrapper{' . esc_attr( $css ) . '}' : 'body{' . esc_attr( $css ) . '}'; |
|
1251 | + } |
|
1252 | 1252 | |
1253 | - $bep = $is_fse ? 'body.editor-styles-wrapper ' : ''; |
|
1253 | + $bep = $is_fse ? 'body.editor-styles-wrapper ' : ''; |
|
1254 | 1254 | |
1255 | - // Headings |
|
1256 | - $headings_css = ''; |
|
1257 | - if( !empty( $theme_settings['elements']['heading']['color']['text'] ) ){ |
|
1258 | - $headings_css .= "color: " . esc_attr( $theme_settings['elements']['heading']['color']['text'] ) . ";"; |
|
1259 | - } |
|
1255 | + // Headings |
|
1256 | + $headings_css = ''; |
|
1257 | + if( !empty( $theme_settings['elements']['heading']['color']['text'] ) ){ |
|
1258 | + $headings_css .= "color: " . esc_attr( $theme_settings['elements']['heading']['color']['text'] ) . ";"; |
|
1259 | + } |
|
1260 | 1260 | |
1261 | - // heading background |
|
1262 | - if( !empty( $theme_settings['elements']['heading']['color']['background'] ) ){ |
|
1263 | - $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';'; |
|
1264 | - } |
|
1261 | + // heading background |
|
1262 | + if( !empty( $theme_settings['elements']['heading']['color']['background'] ) ){ |
|
1263 | + $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';'; |
|
1264 | + } |
|
1265 | 1265 | |
1266 | - // heading font family |
|
1267 | - if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){ |
|
1268 | - $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily'] ) . ';'; |
|
1269 | - } |
|
1266 | + // heading font family |
|
1267 | + if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){ |
|
1268 | + $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily'] ) . ';'; |
|
1269 | + } |
|
1270 | 1270 | |
1271 | - if( $headings_css ){ |
|
1272 | - $custom_css .= "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . esc_attr( $headings_css ) . "}"; |
|
1273 | - } |
|
1271 | + if( $headings_css ){ |
|
1272 | + $custom_css .= "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . esc_attr( $headings_css ) . "}"; |
|
1273 | + } |
|
1274 | 1274 | |
1275 | - $hs = array('h1','h2','h3','h4','h5','h6'); |
|
1275 | + $hs = array('h1','h2','h3','h4','h5','h6'); |
|
1276 | 1276 | |
1277 | - foreach($hs as $hn){ |
|
1278 | - $h_css = ''; |
|
1279 | - if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){ |
|
1280 | - $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';'; |
|
1281 | - } |
|
1277 | + foreach($hs as $hn){ |
|
1278 | + $h_css = ''; |
|
1279 | + if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){ |
|
1280 | + $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';'; |
|
1281 | + } |
|
1282 | 1282 | |
1283 | - if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){ |
|
1284 | - $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize'] ) . ';'; |
|
1285 | - } |
|
1283 | + if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){ |
|
1284 | + $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize'] ) . ';'; |
|
1285 | + } |
|
1286 | 1286 | |
1287 | - if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){ |
|
1288 | - $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) . ';'; |
|
1289 | - } |
|
1287 | + if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){ |
|
1288 | + $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) . ';'; |
|
1289 | + } |
|
1290 | 1290 | |
1291 | - if($h_css){ |
|
1292 | - $custom_css .= esc_attr( $bep . $hn ) . '{'.esc_attr( $h_css ).'}'; |
|
1293 | - } |
|
1294 | - } |
|
1295 | - } |
|
1291 | + if($h_css){ |
|
1292 | + $custom_css .= esc_attr( $bep . $hn ) . '{'.esc_attr( $h_css ).'}'; |
|
1293 | + } |
|
1294 | + } |
|
1295 | + } |
|
1296 | 1296 | |
1297 | - if ( $custom_css ) { |
|
1298 | - echo $custom_css; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1299 | - } |
|
1297 | + if ( $custom_css ) { |
|
1298 | + echo $custom_css; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
1299 | + } |
|
1300 | 1300 | |
1301 | - // Pagination on Hello Elementor theme. |
|
1302 | - if ( function_exists( 'hello_elementor_setup' ) ) { |
|
1303 | - echo '.aui-nav-links .pagination{justify-content:inherit}'; |
|
1304 | - } |
|
1301 | + // Pagination on Hello Elementor theme. |
|
1302 | + if ( function_exists( 'hello_elementor_setup' ) ) { |
|
1303 | + echo '.aui-nav-links .pagination{justify-content:inherit}'; |
|
1304 | + } |
|
1305 | 1305 | |
1306 | 1306 | // Astra theme - when woocommerce active they add compatibility CSS which breaks select2 in modals |
1307 | 1307 | if( defined('ASTRA_THEME_VERSION')){ |
1308 | 1308 | echo '.woocommerce-js.modal-open .select2-container .select2-dropdown, .woocommerce-js.modal-open .select2-container .select2-search__field, .woocommerce-page.modal-open .select2-container .select2-dropdown, .woocommerce-page.modal-open .select2-container .select2-search__field{z-index: 1056;}'; |
1309 | 1309 | } |
1310 | 1310 | |
1311 | - ?></style><?php |
|
1312 | - $custom_css = ob_get_clean(); |
|
1311 | + ?></style><?php |
|
1312 | + $custom_css = ob_get_clean(); |
|
1313 | 1313 | |
1314 | - /* |
|
1314 | + /* |
|
1315 | 1315 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1316 | 1316 | */ |
1317 | - return str_replace( array( |
|
1318 | - '<style>', |
|
1319 | - '</style>' |
|
1320 | - ), '', self::minify_css( $custom_css ) ); |
|
1321 | - } |
|
1322 | - |
|
1323 | - /** |
|
1324 | - * Check if we should add booststrap 3 compatibility changes. |
|
1325 | - * |
|
1326 | - * @return bool |
|
1327 | - */ |
|
1328 | - public static function is_bs3_compat(){ |
|
1329 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1330 | - } |
|
1331 | - |
|
1332 | - public static function hex_to_rgb( $hex ) { |
|
1333 | - // Remove '#' if present |
|
1334 | - $hex = str_replace( '#', '', $hex ); |
|
1335 | - |
|
1336 | - // Check if input is RGB |
|
1337 | - if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) { |
|
1338 | - $_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) ); |
|
1339 | - |
|
1340 | - $rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ','; |
|
1341 | - $rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ','; |
|
1342 | - $rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' ); |
|
1343 | - |
|
1344 | - return $rgb; |
|
1345 | - } |
|
1346 | - |
|
1347 | - // Convert 3-digit hex to 6-digit hex |
|
1348 | - if ( strlen( $hex ) == 3 ) { |
|
1349 | - $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 ); |
|
1350 | - } |
|
1351 | - |
|
1352 | - // Convert hex to RGB |
|
1353 | - $r = hexdec( substr( $hex, 0, 2 ) ); |
|
1354 | - $g = hexdec( substr( $hex, 2, 2 ) ); |
|
1355 | - $b = hexdec( substr( $hex, 4, 2 ) ); |
|
1356 | - |
|
1357 | - // Return RGB values as an array |
|
1358 | - return $r . ',' . $g . ',' . $b; |
|
1359 | - } |
|
1360 | - |
|
1361 | - /** |
|
1362 | - * Build the CSS to overwrite a bootstrap color variable. |
|
1363 | - * |
|
1364 | - * @param $type |
|
1365 | - * @param $color_code |
|
1366 | - * @param $compatibility |
|
1367 | - * |
|
1368 | - * @return string |
|
1369 | - */ |
|
1370 | - public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
1371 | - global $aui_bs5; |
|
1372 | - |
|
1373 | - $is_var = false; |
|
1374 | - $is_custom = strpos($type, 'custom-') !== false ? true : false; |
|
1375 | - if(!$color_code){return '';} |
|
1376 | - if(strpos($color_code, 'var') !== false){ |
|
1377 | - //if(!sanitize_hex_color($color_code)){ |
|
1378 | - $color_code = esc_attr($color_code); |
|
1379 | - $is_var = true; |
|
1317 | + return str_replace( array( |
|
1318 | + '<style>', |
|
1319 | + '</style>' |
|
1320 | + ), '', self::minify_css( $custom_css ) ); |
|
1321 | + } |
|
1322 | + |
|
1323 | + /** |
|
1324 | + * Check if we should add booststrap 3 compatibility changes. |
|
1325 | + * |
|
1326 | + * @return bool |
|
1327 | + */ |
|
1328 | + public static function is_bs3_compat(){ |
|
1329 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1330 | + } |
|
1331 | + |
|
1332 | + public static function hex_to_rgb( $hex ) { |
|
1333 | + // Remove '#' if present |
|
1334 | + $hex = str_replace( '#', '', $hex ); |
|
1335 | + |
|
1336 | + // Check if input is RGB |
|
1337 | + if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) { |
|
1338 | + $_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) ); |
|
1339 | + |
|
1340 | + $rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ','; |
|
1341 | + $rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ','; |
|
1342 | + $rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' ); |
|
1343 | + |
|
1344 | + return $rgb; |
|
1345 | + } |
|
1346 | + |
|
1347 | + // Convert 3-digit hex to 6-digit hex |
|
1348 | + if ( strlen( $hex ) == 3 ) { |
|
1349 | + $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 ); |
|
1350 | + } |
|
1351 | + |
|
1352 | + // Convert hex to RGB |
|
1353 | + $r = hexdec( substr( $hex, 0, 2 ) ); |
|
1354 | + $g = hexdec( substr( $hex, 2, 2 ) ); |
|
1355 | + $b = hexdec( substr( $hex, 4, 2 ) ); |
|
1356 | + |
|
1357 | + // Return RGB values as an array |
|
1358 | + return $r . ',' . $g . ',' . $b; |
|
1359 | + } |
|
1360 | + |
|
1361 | + /** |
|
1362 | + * Build the CSS to overwrite a bootstrap color variable. |
|
1363 | + * |
|
1364 | + * @param $type |
|
1365 | + * @param $color_code |
|
1366 | + * @param $compatibility |
|
1367 | + * |
|
1368 | + * @return string |
|
1369 | + */ |
|
1370 | + public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){ |
|
1371 | + global $aui_bs5; |
|
1372 | + |
|
1373 | + $is_var = false; |
|
1374 | + $is_custom = strpos($type, 'custom-') !== false ? true : false; |
|
1375 | + if(!$color_code){return '';} |
|
1376 | + if(strpos($color_code, 'var') !== false){ |
|
1377 | + //if(!sanitize_hex_color($color_code)){ |
|
1378 | + $color_code = esc_attr($color_code); |
|
1379 | + $is_var = true; |
|
1380 | 1380 | // $color_code = "rgba($color_code, 0.5)"; |
1381 | 1381 | // echo '###1'.$color_code.'###';//exit; |
1382 | - } |
|
1382 | + } |
|
1383 | 1383 | |
1384 | 1384 | // echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
1385 | 1385 | |
1386 | - if(!$color_code){return '';} |
|
1386 | + if(!$color_code){return '';} |
|
1387 | 1387 | |
1388 | - $rgb = self::hex_to_rgb($hex); |
|
1388 | + $rgb = self::hex_to_rgb($hex); |
|
1389 | 1389 | |
1390 | - if($compatibility===true || $compatibility===1){ |
|
1391 | - $compatibility = '.bsui'; |
|
1392 | - }elseif(!$compatibility){ |
|
1393 | - $compatibility = ''; |
|
1394 | - }else{ |
|
1395 | - $compatibility = esc_attr($compatibility); |
|
1396 | - } |
|
1390 | + if($compatibility===true || $compatibility===1){ |
|
1391 | + $compatibility = '.bsui'; |
|
1392 | + }elseif(!$compatibility){ |
|
1393 | + $compatibility = ''; |
|
1394 | + }else{ |
|
1395 | + $compatibility = esc_attr($compatibility); |
|
1396 | + } |
|
1397 | 1397 | |
1398 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
1398 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
1399 | 1399 | |
1400 | 1400 | |
1401 | 1401 | $output = ''; |
1402 | 1402 | |
1403 | 1403 | // echo '####'.$color_code;exit; |
1404 | 1404 | |
1405 | - $type = sanitize_html_class($type); |
|
1405 | + $type = sanitize_html_class($type); |
|
1406 | + |
|
1407 | + /** |
|
1408 | + * c = color, b = background color, o = border-color, f = fill |
|
1409 | + */ |
|
1410 | + $selectors = array( |
|
1411 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
1412 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1413 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1414 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1415 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1416 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1417 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1418 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1419 | + ".badge-{$type}" => array( 'b' ), |
|
1420 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
1421 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
1422 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
1423 | + ".text-{$type}" => array( 'c' ), |
|
1424 | + ); |
|
1425 | + |
|
1426 | + if ( $aui_bs5 ) { |
|
1427 | + unset($selectors[".alert-{$type}" ]); |
|
1428 | + } |
|
1406 | 1429 | |
1407 | - /** |
|
1408 | - * c = color, b = background color, o = border-color, f = fill |
|
1409 | - */ |
|
1410 | - $selectors = array( |
|
1411 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
1412 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1413 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1414 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1415 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1416 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1417 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1418 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1419 | - ".badge-{$type}" => array( 'b' ), |
|
1420 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
1421 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
1422 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
1423 | - ".text-{$type}" => array( 'c' ), |
|
1424 | - ); |
|
1425 | - |
|
1426 | - if ( $aui_bs5 ) { |
|
1427 | - unset($selectors[".alert-{$type}" ]); |
|
1428 | - } |
|
1429 | - |
|
1430 | - if ( $type == 'primary' ) { |
|
1431 | - $selectors = $selectors + array( |
|
1432 | - 'a' => array( 'c' ), |
|
1433 | - '.btn-link' => array( 'c' ), |
|
1434 | - '.dropdown-item.active' => array( 'b' ), |
|
1435 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
1436 | - 'b', |
|
1437 | - 'o' |
|
1438 | - ), |
|
1439 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
1440 | - 'b', |
|
1441 | - 'o' |
|
1442 | - ), |
|
1443 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
1444 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1445 | - '.page-link' => array( 'c' ), |
|
1446 | - '.page-item.active .page-link' => array( |
|
1447 | - 'b', |
|
1448 | - 'o' |
|
1449 | - ), |
|
1450 | - '.progress-bar' => array( 'b' ), |
|
1451 | - '.list-group-item.active' => array( |
|
1452 | - 'b', |
|
1453 | - 'o' |
|
1454 | - ), |
|
1455 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1456 | - ); |
|
1457 | - } |
|
1430 | + if ( $type == 'primary' ) { |
|
1431 | + $selectors = $selectors + array( |
|
1432 | + 'a' => array( 'c' ), |
|
1433 | + '.btn-link' => array( 'c' ), |
|
1434 | + '.dropdown-item.active' => array( 'b' ), |
|
1435 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
1436 | + 'b', |
|
1437 | + 'o' |
|
1438 | + ), |
|
1439 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
1440 | + 'b', |
|
1441 | + 'o' |
|
1442 | + ), |
|
1443 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
1444 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1445 | + '.page-link' => array( 'c' ), |
|
1446 | + '.page-item.active .page-link' => array( |
|
1447 | + 'b', |
|
1448 | + 'o' |
|
1449 | + ), |
|
1450 | + '.progress-bar' => array( 'b' ), |
|
1451 | + '.list-group-item.active' => array( |
|
1452 | + 'b', |
|
1453 | + 'o' |
|
1454 | + ), |
|
1455 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1456 | + ); |
|
1457 | + } |
|
1458 | 1458 | |
1459 | 1459 | |
1460 | 1460 | |
1461 | 1461 | // link |
1462 | - if ( $type === 'primary' ) { |
|
1463 | - $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
1464 | - $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
1465 | - $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).'; }'; |
|
1462 | + if ( $type === 'primary' ) { |
|
1463 | + $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }'; |
|
1464 | + $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).'; }'; |
|
1465 | + $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).'; }'; |
|
1466 | 1466 | |
1467 | - $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
1468 | - $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
1467 | + $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}'; |
|
1468 | + $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}'; |
|
1469 | 1469 | |
1470 | 1470 | // dropdown |
1471 | - $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
1471 | + $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}'; |
|
1472 | 1472 | |
1473 | 1473 | // pagination |
1474 | - $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
1474 | + $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}'; |
|
1475 | 1475 | |
1476 | - } |
|
1476 | + } |
|
1477 | 1477 | |
1478 | - $output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}'; |
|
1479 | - $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
1478 | + $output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}'; |
|
1479 | + $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}'; |
|
1480 | 1480 | |
1481 | - // buttons |
|
1482 | - $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
1483 | - $output .= ' |
|
1481 | + // buttons |
|
1482 | + $output .= $prefix . ' .btn-'.esc_attr($type).'{'; |
|
1483 | + $output .= ' |
|
1484 | 1484 | --bs-btn-bg: '.esc_attr($color_code).'; |
1485 | 1485 | --bs-btn-border-color: '.esc_attr($color_code).'; |
1486 | 1486 | --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
@@ -1498,11 +1498,11 @@ discard block |
||
1498 | 1498 | // --bs-btn-active-color: #fff; |
1499 | 1499 | // --bs-btn-disabled-color: #fff; |
1500 | 1500 | // '; |
1501 | - $output .= '}'; |
|
1501 | + $output .= '}'; |
|
1502 | 1502 | |
1503 | - // buttons outline |
|
1504 | - $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
1505 | - $output .= ' |
|
1503 | + // buttons outline |
|
1504 | + $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; |
|
1505 | + $output .= ' |
|
1506 | 1506 | --bs-btn-color: '.esc_attr($color_code).'; |
1507 | 1507 | --bs-btn-border-color: '.esc_attr($color_code).'; |
1508 | 1508 | --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); |
@@ -1520,37 +1520,37 @@ discard block |
||
1520 | 1520 | // --bs-btn-active-color: #fff; |
1521 | 1521 | // --bs-btn-disabled-color: #fff; |
1522 | 1522 | // '; |
1523 | - $output .= '}'; |
|
1523 | + $output .= '}'; |
|
1524 | 1524 | |
1525 | 1525 | |
1526 | 1526 | // button hover |
1527 | - $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
1528 | - $output .= ' |
|
1527 | + $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; |
|
1528 | + $output .= ' |
|
1529 | 1529 | 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); |
1530 | 1530 | } |
1531 | 1531 | '; |
1532 | 1532 | |
1533 | 1533 | |
1534 | - if ( $aui_bs5 ) { |
|
1534 | + if ( $aui_bs5 ) { |
|
1535 | 1535 | // $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).'; }'; |
1536 | - $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
1537 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1538 | - } |
|
1536 | + $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }'; |
|
1537 | + $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1538 | + } |
|
1539 | 1539 | |
1540 | 1540 | |
1541 | - if ( $is_custom ) { |
|
1541 | + if ( $is_custom ) { |
|
1542 | 1542 | |
1543 | 1543 | // echo '###'.$type;exit; |
1544 | 1544 | |
1545 | - // build rules into each type |
|
1546 | - foreach($selectors as $selector => $types){ |
|
1547 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1548 | - $types = array_combine($types,$types); |
|
1549 | - if(isset($types['c'])){$color[] = $selector;} |
|
1550 | - if(isset($types['b'])){$background[] = $selector;} |
|
1551 | - if(isset($types['o'])){$border[] = $selector;} |
|
1552 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1553 | - } |
|
1545 | + // build rules into each type |
|
1546 | + foreach($selectors as $selector => $types){ |
|
1547 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1548 | + $types = array_combine($types,$types); |
|
1549 | + if(isset($types['c'])){$color[] = $selector;} |
|
1550 | + if(isset($types['b'])){$background[] = $selector;} |
|
1551 | + if(isset($types['o'])){$border[] = $selector;} |
|
1552 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1553 | + } |
|
1554 | 1554 | |
1555 | 1555 | // // build rules into each type |
1556 | 1556 | // foreach($important_selectors as $selector => $types){ |
@@ -1562,853 +1562,853 @@ discard block |
||
1562 | 1562 | // if(isset($types['f'])){$fill_i[] = $selector;} |
1563 | 1563 | // } |
1564 | 1564 | |
1565 | - // add any color rules |
|
1566 | - if(!empty($color)){ |
|
1567 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1568 | - } |
|
1569 | - if(!empty($color_i)){ |
|
1570 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1571 | - } |
|
1565 | + // add any color rules |
|
1566 | + if(!empty($color)){ |
|
1567 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1568 | + } |
|
1569 | + if(!empty($color_i)){ |
|
1570 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1571 | + } |
|
1572 | + |
|
1573 | + // add any background color rules |
|
1574 | + if(!empty($background)){ |
|
1575 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1576 | + } |
|
1577 | + if(!empty($background_i)){ |
|
1578 | + $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1579 | +// $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
|
1580 | + } |
|
1581 | + |
|
1582 | + // add any border color rules |
|
1583 | + if(!empty($border)){ |
|
1584 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1585 | + } |
|
1586 | + if(!empty($border_i)){ |
|
1587 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1588 | + } |
|
1589 | + |
|
1590 | + // add any fill color rules |
|
1591 | + if(!empty($fill)){ |
|
1592 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1593 | + } |
|
1594 | + if(!empty($fill_i)){ |
|
1595 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1596 | + } |
|
1597 | + |
|
1598 | + } |
|
1599 | + |
|
1600 | + |
|
1601 | + |
|
1602 | + |
|
1603 | + $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;' : ''; |
|
1604 | + // darken |
|
1605 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1606 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1607 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1608 | + $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
1609 | + |
|
1610 | + // lighten |
|
1611 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1612 | + |
|
1613 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1614 | + $op_25 = $color_code."40"; // 25% opacity |
|
1615 | + |
|
1616 | + |
|
1617 | + // button states |
|
1618 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1619 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1620 | +// $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
|
1621 | + $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;} "; |
|
1622 | + $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.";} "; |
|
1623 | + $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;} "; |
|
1624 | + $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled):focus {box-shadow: 0 0.25rem 0.25rem 0.125rem rgba(var(--bs-{$type}-rgb), 0.1), 0 0.375rem 0.75rem -0.125rem rgba(var(--bs-{$type}-rgb), 0.4);} "; |
|
1625 | + |
|
1626 | + // text |
|
1627 | +// $output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} "; |
|
1628 | + |
|
1629 | + |
|
1630 | +// if ( $type == 'primary' ) { |
|
1631 | +// // dropdown's |
|
1632 | +// $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1633 | +// |
|
1634 | +// // input states |
|
1635 | +// $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1636 | +// |
|
1637 | +// // page link |
|
1638 | +// $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1639 | +// } |
|
1640 | + |
|
1641 | + // alerts |
|
1642 | + if ( $aui_bs5 ) { |
|
1643 | +// $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
|
1644 | + $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;} "; |
|
1645 | + } |
|
1646 | + |
|
1647 | + return $output; |
|
1648 | + } |
|
1649 | + |
|
1650 | + /** |
|
1651 | + * Build the CSS to overwrite a bootstrap color variable. |
|
1652 | + * |
|
1653 | + * @param $type |
|
1654 | + * @param $color_code |
|
1655 | + * @param $compatibility |
|
1656 | + * |
|
1657 | + * @return string |
|
1658 | + */ |
|
1659 | + public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
1660 | + global $aui_bs5; |
|
1661 | + |
|
1662 | + $is_var = false; |
|
1663 | + if(!$color_code){return '';} |
|
1664 | + if(strpos($color_code, 'var') !== false){ |
|
1665 | + //if(!sanitize_hex_color($color_code)){ |
|
1666 | + $color_code = esc_attr($color_code); |
|
1667 | + $is_var = true; |
|
1668 | +// $color_code = "rgba($color_code, 0.5)"; |
|
1669 | +// echo '###1'.$color_code.'###';//exit; |
|
1670 | + } |
|
1671 | + |
|
1672 | +// echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
|
1673 | + |
|
1674 | + if(!$color_code){return '';} |
|
1675 | + |
|
1676 | + $rgb = self::hex_to_rgb($hex); |
|
1677 | + |
|
1678 | + if($compatibility===true || $compatibility===1){ |
|
1679 | + $compatibility = '.bsui'; |
|
1680 | + }elseif(!$compatibility){ |
|
1681 | + $compatibility = ''; |
|
1682 | + }else{ |
|
1683 | + $compatibility = esc_attr($compatibility); |
|
1684 | + } |
|
1685 | + |
|
1686 | + |
|
1687 | + |
|
1688 | +// echo '####'.$color_code;exit; |
|
1689 | + |
|
1690 | + $type = sanitize_html_class($type); |
|
1691 | + |
|
1692 | + /** |
|
1693 | + * c = color, b = background color, o = border-color, f = fill |
|
1694 | + */ |
|
1695 | + $selectors = array( |
|
1696 | + ".btn-{$type}" => array( 'b', 'o' ), |
|
1697 | + ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1698 | + ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1699 | + ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1700 | + ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1701 | + ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1702 | + ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1703 | + ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1704 | + ".badge-{$type}" => array( 'b' ), |
|
1705 | + ".alert-{$type}" => array( 'b', 'o' ), |
|
1706 | + ".bg-{$type}" => array( 'b', 'f' ), |
|
1707 | + ".btn-link.btn-{$type}" => array( 'c' ), |
|
1708 | + ); |
|
1709 | + |
|
1710 | + if ( $aui_bs5 ) { |
|
1711 | + unset($selectors[".alert-{$type}" ]); |
|
1712 | + } |
|
1713 | + |
|
1714 | + if ( $type == 'primary' ) { |
|
1715 | + $selectors = $selectors + array( |
|
1716 | + 'a' => array( 'c' ), |
|
1717 | + '.btn-link' => array( 'c' ), |
|
1718 | + '.dropdown-item.active' => array( 'b' ), |
|
1719 | + '.custom-control-input:checked~.custom-control-label::before' => array( |
|
1720 | + 'b', |
|
1721 | + 'o' |
|
1722 | + ), |
|
1723 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
1724 | + 'b', |
|
1725 | + 'o' |
|
1726 | + ), |
|
1727 | + '.nav-pills .nav-link.active' => array( 'b' ), |
|
1728 | + '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1729 | + '.page-link' => array( 'c' ), |
|
1730 | + '.page-item.active .page-link' => array( |
|
1731 | + 'b', |
|
1732 | + 'o' |
|
1733 | + ), |
|
1734 | + '.progress-bar' => array( 'b' ), |
|
1735 | + '.list-group-item.active' => array( |
|
1736 | + 'b', |
|
1737 | + 'o' |
|
1738 | + ), |
|
1739 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1740 | +// '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
|
1741 | +// '.custom-range::-moz-range-thumb' => array('b'), |
|
1742 | +// '.custom-range::-ms-thumb' => array('b'), |
|
1743 | + ); |
|
1744 | + } |
|
1745 | + |
|
1746 | + $important_selectors = array( |
|
1747 | + ".bg-{$type}" => array('b','f'), |
|
1748 | + ".border-{$type}" => array('o'), |
|
1749 | + ".text-{$type}" => array('c'), |
|
1750 | + ); |
|
1751 | + |
|
1752 | + $color = array(); |
|
1753 | + $color_i = array(); |
|
1754 | + $background = array(); |
|
1755 | + $background_i = array(); |
|
1756 | + $border = array(); |
|
1757 | + $border_i = array(); |
|
1758 | + $fill = array(); |
|
1759 | + $fill_i = array(); |
|
1760 | + |
|
1761 | + $output = ''; |
|
1762 | + |
|
1763 | + if ( $aui_bs5 ) { |
|
1764 | +// $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).'; }'; |
|
1765 | + $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1766 | + } |
|
1767 | + |
|
1768 | + // build rules into each type |
|
1769 | + foreach($selectors as $selector => $types){ |
|
1770 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1771 | + $types = array_combine($types,$types); |
|
1772 | + if(isset($types['c'])){$color[] = $selector;} |
|
1773 | + if(isset($types['b'])){$background[] = $selector;} |
|
1774 | + if(isset($types['o'])){$border[] = $selector;} |
|
1775 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1776 | + } |
|
1777 | + |
|
1778 | + // build rules into each type |
|
1779 | + foreach($important_selectors as $selector => $types){ |
|
1780 | + $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1781 | + $types = array_combine($types,$types); |
|
1782 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1783 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1784 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1785 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1786 | + } |
|
1787 | + |
|
1788 | + // add any color rules |
|
1789 | + if(!empty($color)){ |
|
1790 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1791 | + } |
|
1792 | + if(!empty($color_i)){ |
|
1793 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1794 | + } |
|
1795 | + |
|
1796 | + // add any background color rules |
|
1797 | + if(!empty($background)){ |
|
1798 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1799 | + } |
|
1800 | + if(!empty($background_i)){ |
|
1801 | + $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1802 | +// $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
|
1803 | + } |
|
1804 | + |
|
1805 | + // add any border color rules |
|
1806 | + if(!empty($border)){ |
|
1807 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1808 | + } |
|
1809 | + if(!empty($border_i)){ |
|
1810 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1811 | + } |
|
1812 | + |
|
1813 | + // add any fill color rules |
|
1814 | + if(!empty($fill)){ |
|
1815 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1816 | + } |
|
1817 | + if(!empty($fill_i)){ |
|
1818 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1819 | + } |
|
1820 | + |
|
1821 | + |
|
1822 | + $prefix = $compatibility ? $compatibility . " " : ""; |
|
1823 | + |
|
1824 | + $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;' : ''; |
|
1825 | + // darken |
|
1826 | + $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1827 | + $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1828 | + $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1829 | + $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
1830 | + |
|
1831 | + // lighten |
|
1832 | + $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1833 | + |
|
1834 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1835 | + $op_25 = $color_code."40"; // 25% opacity |
|
1836 | + |
|
1837 | + |
|
1838 | + // button states |
|
1839 | + $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1840 | + $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1841 | +// $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
|
1842 | + $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;} "; |
|
1843 | + $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.";} "; |
|
1844 | + $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;} "; |
|
1845 | + |
|
1846 | + if ( $type == 'primary' ) { |
|
1847 | + // dropdown's |
|
1848 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1849 | + |
|
1850 | + // input states |
|
1851 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1852 | + |
|
1853 | + // page link |
|
1854 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1855 | + } |
|
1856 | + |
|
1857 | + // alerts |
|
1858 | + if ( $aui_bs5 ) { |
|
1859 | +// $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
|
1860 | + $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;} "; |
|
1861 | + } |
|
1862 | + |
|
1863 | + return $output; |
|
1864 | + } |
|
1865 | + |
|
1866 | + /** |
|
1867 | + * |
|
1868 | + * @deprecated 0.1.76 Use css_overwrite() |
|
1869 | + * |
|
1870 | + * @param $color_code |
|
1871 | + * @param $compatibility |
|
1872 | + * @param $use_variable |
|
1873 | + * |
|
1874 | + * @return string |
|
1875 | + */ |
|
1876 | + public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
1877 | + |
|
1878 | + if(!$use_variable){ |
|
1879 | + $color_code = sanitize_hex_color($color_code); |
|
1880 | + if(!$color_code){return '';} |
|
1881 | + } |
|
1882 | + |
|
1883 | + /** |
|
1884 | + * c = color, b = background color, o = border-color, f = fill |
|
1885 | + */ |
|
1886 | + $selectors = array( |
|
1887 | + 'a' => array('c'), |
|
1888 | + '.btn-primary' => array('b','o'), |
|
1889 | + '.btn-primary.disabled' => array('b','o'), |
|
1890 | + '.btn-primary:disabled' => array('b','o'), |
|
1891 | + '.btn-outline-primary' => array('c','o'), |
|
1892 | + '.btn-outline-primary:hover' => array('b','o'), |
|
1893 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1894 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1895 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1896 | + '.btn-link' => array('c'), |
|
1897 | + '.dropdown-item.active' => array('b'), |
|
1898 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1899 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1900 | +// '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
|
1901 | +// '.custom-range::-moz-range-thumb' => array('b'), |
|
1902 | +// '.custom-range::-ms-thumb' => array('b'), |
|
1903 | + '.nav-pills .nav-link.active' => array('b'), |
|
1904 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1905 | + '.page-link' => array('c'), |
|
1906 | + '.page-item.active .page-link' => array('b','o'), |
|
1907 | + '.badge-primary' => array('b'), |
|
1908 | + '.alert-primary' => array('b','o'), |
|
1909 | + '.progress-bar' => array('b'), |
|
1910 | + '.list-group-item.active' => array('b','o'), |
|
1911 | + '.bg-primary' => array('b','f'), |
|
1912 | + '.btn-link.btn-primary' => array('c'), |
|
1913 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1914 | + ); |
|
1915 | + |
|
1916 | + $important_selectors = array( |
|
1917 | + '.bg-primary' => array('b','f'), |
|
1918 | + '.border-primary' => array('o'), |
|
1919 | + '.text-primary' => array('c'), |
|
1920 | + ); |
|
1921 | + |
|
1922 | + $color = array(); |
|
1923 | + $color_i = array(); |
|
1924 | + $background = array(); |
|
1925 | + $background_i = array(); |
|
1926 | + $border = array(); |
|
1927 | + $border_i = array(); |
|
1928 | + $fill = array(); |
|
1929 | + $fill_i = array(); |
|
1930 | + |
|
1931 | + $output = ''; |
|
1932 | + |
|
1933 | + // build rules into each type |
|
1934 | + foreach($selectors as $selector => $types){ |
|
1935 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1936 | + $types = array_combine($types,$types); |
|
1937 | + if(isset($types['c'])){$color[] = $selector;} |
|
1938 | + if(isset($types['b'])){$background[] = $selector;} |
|
1939 | + if(isset($types['o'])){$border[] = $selector;} |
|
1940 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1941 | + } |
|
1942 | + |
|
1943 | + // build rules into each type |
|
1944 | + foreach($important_selectors as $selector => $types){ |
|
1945 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1946 | + $types = array_combine($types,$types); |
|
1947 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1948 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1949 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1950 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1951 | + } |
|
1952 | + |
|
1953 | + // add any color rules |
|
1954 | + if(!empty($color)){ |
|
1955 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1956 | + } |
|
1957 | + if(!empty($color_i)){ |
|
1958 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1959 | + } |
|
1960 | + |
|
1961 | + // add any background color rules |
|
1962 | + if(!empty($background)){ |
|
1963 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1964 | + } |
|
1965 | + if(!empty($background_i)){ |
|
1966 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1967 | + } |
|
1968 | + |
|
1969 | + // add any border color rules |
|
1970 | + if(!empty($border)){ |
|
1971 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1972 | + } |
|
1973 | + if(!empty($border_i)){ |
|
1974 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1975 | + } |
|
1976 | + |
|
1977 | + // add any fill color rules |
|
1978 | + if(!empty($fill)){ |
|
1979 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1980 | + } |
|
1981 | + if(!empty($fill_i)){ |
|
1982 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1983 | + } |
|
1984 | + |
|
1572 | 1985 | |
1573 | - // add any background color rules |
|
1574 | - if(!empty($background)){ |
|
1575 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1576 | - } |
|
1577 | - if(!empty($background_i)){ |
|
1578 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1579 | -// $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
|
1580 | - } |
|
1986 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1581 | 1987 | |
1582 | - // add any border color rules |
|
1583 | - if(!empty($border)){ |
|
1584 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1585 | - } |
|
1586 | - if(!empty($border_i)){ |
|
1587 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1588 | - } |
|
1988 | + // darken |
|
1989 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1990 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1991 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1589 | 1992 | |
1590 | - // add any fill color rules |
|
1591 | - if(!empty($fill)){ |
|
1592 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1593 | - } |
|
1594 | - if(!empty($fill_i)){ |
|
1595 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1596 | - } |
|
1993 | + // lighten |
|
1994 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1597 | 1995 | |
1598 | - } |
|
1996 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1997 | + $op_25 = $color_code."40"; // 25% opacity |
|
1599 | 1998 | |
1600 | 1999 | |
2000 | + // button states |
|
2001 | + $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
2002 | + $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;} "; |
|
2003 | + $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.";} "; |
|
2004 | + $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;} "; |
|
1601 | 2005 | |
1602 | 2006 | |
1603 | - $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;' : ''; |
|
1604 | - // darken |
|
1605 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1606 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1607 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1608 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
2007 | + // dropdown's |
|
2008 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1609 | 2009 | |
1610 | - // lighten |
|
1611 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
1612 | 2010 | |
1613 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1614 | - $op_25 = $color_code."40"; // 25% opacity |
|
2011 | + // input states |
|
2012 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1615 | 2013 | |
2014 | + // page link |
|
2015 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1616 | 2016 | |
1617 | - // button states |
|
1618 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1619 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1620 | -// $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
|
1621 | - $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;} "; |
|
1622 | - $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.";} "; |
|
1623 | - $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;} "; |
|
1624 | - $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled):focus {box-shadow: 0 0.25rem 0.25rem 0.125rem rgba(var(--bs-{$type}-rgb), 0.1), 0 0.375rem 0.75rem -0.125rem rgba(var(--bs-{$type}-rgb), 0.4);} "; |
|
2017 | + return $output; |
|
2018 | + } |
|
1625 | 2019 | |
1626 | - // text |
|
1627 | -// $output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} "; |
|
2020 | + /** |
|
2021 | + * |
|
2022 | + * @deprecated 0.1.76 Use css_overwrite() |
|
2023 | + * |
|
2024 | + * @param $color_code |
|
2025 | + * @param $compatibility |
|
2026 | + * |
|
2027 | + * @return string |
|
2028 | + */ |
|
2029 | + public static function css_secondary($color_code,$compatibility){; |
|
2030 | + $color_code = sanitize_hex_color($color_code); |
|
2031 | + if(!$color_code){return '';} |
|
2032 | + /** |
|
2033 | + * c = color, b = background color, o = border-color, f = fill |
|
2034 | + */ |
|
2035 | + $selectors = array( |
|
2036 | + '.btn-secondary' => array('b','o'), |
|
2037 | + '.btn-secondary.disabled' => array('b','o'), |
|
2038 | + '.btn-secondary:disabled' => array('b','o'), |
|
2039 | + '.btn-outline-secondary' => array('c','o'), |
|
2040 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
2041 | + '.btn-outline-secondary.disabled' => array('c'), |
|
2042 | + '.btn-outline-secondary:disabled' => array('c'), |
|
2043 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
2044 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
2045 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
2046 | + '.badge-secondary' => array('b'), |
|
2047 | + '.alert-secondary' => array('b','o'), |
|
2048 | + '.btn-link.btn-secondary' => array('c'), |
|
2049 | + ); |
|
2050 | + |
|
2051 | + $important_selectors = array( |
|
2052 | + '.bg-secondary' => array('b','f'), |
|
2053 | + '.border-secondary' => array('o'), |
|
2054 | + '.text-secondary' => array('c'), |
|
2055 | + ); |
|
2056 | + |
|
2057 | + $color = array(); |
|
2058 | + $color_i = array(); |
|
2059 | + $background = array(); |
|
2060 | + $background_i = array(); |
|
2061 | + $border = array(); |
|
2062 | + $border_i = array(); |
|
2063 | + $fill = array(); |
|
2064 | + $fill_i = array(); |
|
1628 | 2065 | |
2066 | + $output = ''; |
|
1629 | 2067 | |
1630 | -// if ( $type == 'primary' ) { |
|
1631 | -// // dropdown's |
|
1632 | -// $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1633 | -// |
|
1634 | -// // input states |
|
1635 | -// $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1636 | -// |
|
1637 | -// // page link |
|
1638 | -// $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1639 | -// } |
|
2068 | + // build rules into each type |
|
2069 | + foreach($selectors as $selector => $types){ |
|
2070 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2071 | + $types = array_combine($types,$types); |
|
2072 | + if(isset($types['c'])){$color[] = $selector;} |
|
2073 | + if(isset($types['b'])){$background[] = $selector;} |
|
2074 | + if(isset($types['o'])){$border[] = $selector;} |
|
2075 | + if(isset($types['f'])){$fill[] = $selector;} |
|
2076 | + } |
|
1640 | 2077 | |
1641 | - // alerts |
|
1642 | - if ( $aui_bs5 ) { |
|
1643 | -// $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
|
1644 | - $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;} "; |
|
1645 | - } |
|
1646 | - |
|
1647 | - return $output; |
|
1648 | - } |
|
1649 | - |
|
1650 | - /** |
|
1651 | - * Build the CSS to overwrite a bootstrap color variable. |
|
1652 | - * |
|
1653 | - * @param $type |
|
1654 | - * @param $color_code |
|
1655 | - * @param $compatibility |
|
1656 | - * |
|
1657 | - * @return string |
|
1658 | - */ |
|
1659 | - public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){ |
|
1660 | - global $aui_bs5; |
|
2078 | + // build rules into each type |
|
2079 | + foreach($important_selectors as $selector => $types){ |
|
2080 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2081 | + $types = array_combine($types,$types); |
|
2082 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
2083 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
2084 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
2085 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
2086 | + } |
|
1661 | 2087 | |
1662 | - $is_var = false; |
|
1663 | - if(!$color_code){return '';} |
|
1664 | - if(strpos($color_code, 'var') !== false){ |
|
1665 | - //if(!sanitize_hex_color($color_code)){ |
|
1666 | - $color_code = esc_attr($color_code); |
|
1667 | - $is_var = true; |
|
1668 | -// $color_code = "rgba($color_code, 0.5)"; |
|
1669 | -// echo '###1'.$color_code.'###';//exit; |
|
1670 | - } |
|
2088 | + // add any color rules |
|
2089 | + if(!empty($color)){ |
|
2090 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
2091 | + } |
|
2092 | + if(!empty($color_i)){ |
|
2093 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
2094 | + } |
|
1671 | 2095 | |
1672 | -// echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit; |
|
2096 | + // add any background color rules |
|
2097 | + if(!empty($background)){ |
|
2098 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
2099 | + } |
|
2100 | + if(!empty($background_i)){ |
|
2101 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
2102 | + } |
|
1673 | 2103 | |
1674 | - if(!$color_code){return '';} |
|
2104 | + // add any border color rules |
|
2105 | + if(!empty($border)){ |
|
2106 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
2107 | + } |
|
2108 | + if(!empty($border_i)){ |
|
2109 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
2110 | + } |
|
1675 | 2111 | |
1676 | - $rgb = self::hex_to_rgb($hex); |
|
2112 | + // add any fill color rules |
|
2113 | + if(!empty($fill)){ |
|
2114 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
2115 | + } |
|
2116 | + if(!empty($fill_i)){ |
|
2117 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
2118 | + } |
|
1677 | 2119 | |
1678 | - if($compatibility===true || $compatibility===1){ |
|
1679 | - $compatibility = '.bsui'; |
|
1680 | - }elseif(!$compatibility){ |
|
1681 | - $compatibility = ''; |
|
1682 | - }else{ |
|
1683 | - $compatibility = esc_attr($compatibility); |
|
1684 | - } |
|
1685 | 2120 | |
2121 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1686 | 2122 | |
2123 | + // darken |
|
2124 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
2125 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
2126 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1687 | 2127 | |
1688 | -// echo '####'.$color_code;exit; |
|
2128 | + // lighten |
|
2129 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1689 | 2130 | |
1690 | - $type = sanitize_html_class($type); |
|
2131 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
2132 | + $op_25 = $color_code."40"; // 25% opacity |
|
1691 | 2133 | |
1692 | - /** |
|
1693 | - * c = color, b = background color, o = border-color, f = fill |
|
1694 | - */ |
|
1695 | - $selectors = array( |
|
1696 | - ".btn-{$type}" => array( 'b', 'o' ), |
|
1697 | - ".btn-{$type}.disabled" => array( 'b', 'o' ), |
|
1698 | - ".btn-{$type}:disabled" => array( 'b', 'o' ), |
|
1699 | - ".btn-outline-{$type}" => array( 'c', 'o' ), |
|
1700 | - ".btn-outline-{$type}:hover" => array( 'b', 'o' ), |
|
1701 | - ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), |
|
1702 | - ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), |
|
1703 | - ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), |
|
1704 | - ".badge-{$type}" => array( 'b' ), |
|
1705 | - ".alert-{$type}" => array( 'b', 'o' ), |
|
1706 | - ".bg-{$type}" => array( 'b', 'f' ), |
|
1707 | - ".btn-link.btn-{$type}" => array( 'c' ), |
|
1708 | - ); |
|
1709 | - |
|
1710 | - if ( $aui_bs5 ) { |
|
1711 | - unset($selectors[".alert-{$type}" ]); |
|
1712 | - } |
|
1713 | - |
|
1714 | - if ( $type == 'primary' ) { |
|
1715 | - $selectors = $selectors + array( |
|
1716 | - 'a' => array( 'c' ), |
|
1717 | - '.btn-link' => array( 'c' ), |
|
1718 | - '.dropdown-item.active' => array( 'b' ), |
|
1719 | - '.custom-control-input:checked~.custom-control-label::before' => array( |
|
1720 | - 'b', |
|
1721 | - 'o' |
|
1722 | - ), |
|
1723 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( |
|
1724 | - 'b', |
|
1725 | - 'o' |
|
1726 | - ), |
|
1727 | - '.nav-pills .nav-link.active' => array( 'b' ), |
|
1728 | - '.nav-pills .show>.nav-link' => array( 'b' ), |
|
1729 | - '.page-link' => array( 'c' ), |
|
1730 | - '.page-item.active .page-link' => array( |
|
1731 | - 'b', |
|
1732 | - 'o' |
|
1733 | - ), |
|
1734 | - '.progress-bar' => array( 'b' ), |
|
1735 | - '.list-group-item.active' => array( |
|
1736 | - 'b', |
|
1737 | - 'o' |
|
1738 | - ), |
|
1739 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), |
|
1740 | -// '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
|
1741 | -// '.custom-range::-moz-range-thumb' => array('b'), |
|
1742 | -// '.custom-range::-ms-thumb' => array('b'), |
|
1743 | - ); |
|
1744 | - } |
|
1745 | - |
|
1746 | - $important_selectors = array( |
|
1747 | - ".bg-{$type}" => array('b','f'), |
|
1748 | - ".border-{$type}" => array('o'), |
|
1749 | - ".text-{$type}" => array('c'), |
|
1750 | - ); |
|
1751 | - |
|
1752 | - $color = array(); |
|
1753 | - $color_i = array(); |
|
1754 | - $background = array(); |
|
1755 | - $background_i = array(); |
|
1756 | - $border = array(); |
|
1757 | - $border_i = array(); |
|
1758 | - $fill = array(); |
|
1759 | - $fill_i = array(); |
|
1760 | - |
|
1761 | - $output = ''; |
|
1762 | - |
|
1763 | - if ( $aui_bs5 ) { |
|
1764 | -// $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).'; }'; |
|
1765 | - $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }'; |
|
1766 | - } |
|
1767 | - |
|
1768 | - // build rules into each type |
|
1769 | - foreach($selectors as $selector => $types){ |
|
1770 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1771 | - $types = array_combine($types,$types); |
|
1772 | - if(isset($types['c'])){$color[] = $selector;} |
|
1773 | - if(isset($types['b'])){$background[] = $selector;} |
|
1774 | - if(isset($types['o'])){$border[] = $selector;} |
|
1775 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1776 | - } |
|
1777 | - |
|
1778 | - // build rules into each type |
|
1779 | - foreach($important_selectors as $selector => $types){ |
|
1780 | - $selector = $compatibility ? $compatibility . " ".$selector : $selector; |
|
1781 | - $types = array_combine($types,$types); |
|
1782 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1783 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1784 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1785 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1786 | - } |
|
1787 | - |
|
1788 | - // add any color rules |
|
1789 | - if(!empty($color)){ |
|
1790 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1791 | - } |
|
1792 | - if(!empty($color_i)){ |
|
1793 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1794 | - } |
|
1795 | - |
|
1796 | - // add any background color rules |
|
1797 | - if(!empty($background)){ |
|
1798 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1799 | - } |
|
1800 | - if(!empty($background_i)){ |
|
1801 | - $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1802 | -// $output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} "; |
|
1803 | - } |
|
1804 | 2134 | |
1805 | - // add any border color rules |
|
1806 | - if(!empty($border)){ |
|
1807 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1808 | - } |
|
1809 | - if(!empty($border_i)){ |
|
1810 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1811 | - } |
|
2135 | + // button states |
|
2136 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
2137 | + $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;} "; |
|
2138 | + $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.";} "; |
|
2139 | + $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;} "; |
|
1812 | 2140 | |
1813 | - // add any fill color rules |
|
1814 | - if(!empty($fill)){ |
|
1815 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1816 | - } |
|
1817 | - if(!empty($fill_i)){ |
|
1818 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1819 | - } |
|
1820 | 2141 | |
2142 | + return $output; |
|
2143 | + } |
|
1821 | 2144 | |
1822 | - $prefix = $compatibility ? $compatibility . " " : ""; |
|
2145 | + /** |
|
2146 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
2147 | + * |
|
2148 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
2149 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
2150 | + * |
|
2151 | + * @return string |
|
2152 | + */ |
|
2153 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
2154 | + $hexCode = ltrim($hexCode, '#'); |
|
1823 | 2155 | |
1824 | - $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;' : ''; |
|
1825 | - // darken |
|
1826 | - $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1827 | - $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1828 | - $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1829 | - $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4"); |
|
2156 | + if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) { |
|
2157 | + return $hexCode; |
|
2158 | + } |
|
1830 | 2159 | |
1831 | - // lighten |
|
1832 | - $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); |
|
2160 | + if (strlen($hexCode) == 3) { |
|
2161 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
2162 | + } |
|
1833 | 2163 | |
1834 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1835 | - $op_25 = $color_code."40"; // 25% opacity |
|
2164 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1836 | 2165 | |
2166 | + foreach ($hexCode as & $color) { |
|
2167 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
2168 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1837 | 2169 | |
1838 | - // button states |
|
1839 | - $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; |
|
1840 | - $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1841 | -// $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; |
|
1842 | - $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;} "; |
|
1843 | - $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.";} "; |
|
1844 | - $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;} "; |
|
2170 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
2171 | + } |
|
1845 | 2172 | |
1846 | - if ( $type == 'primary' ) { |
|
1847 | - // dropdown's |
|
1848 | - $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
2173 | + return '#' . implode($hexCode); |
|
2174 | + } |
|
1849 | 2175 | |
1850 | - // input states |
|
1851 | - $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
2176 | + /** |
|
2177 | + * Check if we should display examples. |
|
2178 | + */ |
|
2179 | + public function maybe_show_examples(){ |
|
2180 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
2181 | + echo "<head>"; |
|
2182 | + wp_head(); |
|
2183 | + echo "</head>"; |
|
2184 | + echo "<body>"; |
|
2185 | + echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2186 | + echo "</body>"; |
|
2187 | + exit; |
|
2188 | + } |
|
2189 | + } |
|
1852 | 2190 | |
1853 | - // page link |
|
1854 | - $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1855 | - } |
|
2191 | + /** |
|
2192 | + * Get developer examples. |
|
2193 | + * |
|
2194 | + * @return string |
|
2195 | + */ |
|
2196 | + public function get_examples(){ |
|
2197 | + $output = ''; |
|
1856 | 2198 | |
1857 | - // alerts |
|
1858 | - if ( $aui_bs5 ) { |
|
1859 | -// $output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20; border-color: ".$color_code."30;color:$darker_40} "; |
|
1860 | - $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;} "; |
|
1861 | - } |
|
1862 | - |
|
1863 | - return $output; |
|
1864 | - } |
|
1865 | - |
|
1866 | - /** |
|
1867 | - * |
|
1868 | - * @deprecated 0.1.76 Use css_overwrite() |
|
1869 | - * |
|
1870 | - * @param $color_code |
|
1871 | - * @param $compatibility |
|
1872 | - * @param $use_variable |
|
1873 | - * |
|
1874 | - * @return string |
|
1875 | - */ |
|
1876 | - public static function css_primary($color_code,$compatibility, $use_variable = false){ |
|
1877 | - |
|
1878 | - if(!$use_variable){ |
|
1879 | - $color_code = sanitize_hex_color($color_code); |
|
1880 | - if(!$color_code){return '';} |
|
1881 | - } |
|
1882 | - |
|
1883 | - /** |
|
1884 | - * c = color, b = background color, o = border-color, f = fill |
|
1885 | - */ |
|
1886 | - $selectors = array( |
|
1887 | - 'a' => array('c'), |
|
1888 | - '.btn-primary' => array('b','o'), |
|
1889 | - '.btn-primary.disabled' => array('b','o'), |
|
1890 | - '.btn-primary:disabled' => array('b','o'), |
|
1891 | - '.btn-outline-primary' => array('c','o'), |
|
1892 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1893 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1894 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1895 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1896 | - '.btn-link' => array('c'), |
|
1897 | - '.dropdown-item.active' => array('b'), |
|
1898 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1899 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1900 | -// '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
|
1901 | -// '.custom-range::-moz-range-thumb' => array('b'), |
|
1902 | -// '.custom-range::-ms-thumb' => array('b'), |
|
1903 | - '.nav-pills .nav-link.active' => array('b'), |
|
1904 | - '.nav-pills .show>.nav-link' => array('b'), |
|
1905 | - '.page-link' => array('c'), |
|
1906 | - '.page-item.active .page-link' => array('b','o'), |
|
1907 | - '.badge-primary' => array('b'), |
|
1908 | - '.alert-primary' => array('b','o'), |
|
1909 | - '.progress-bar' => array('b'), |
|
1910 | - '.list-group-item.active' => array('b','o'), |
|
1911 | - '.bg-primary' => array('b','f'), |
|
1912 | - '.btn-link.btn-primary' => array('c'), |
|
1913 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1914 | - ); |
|
1915 | - |
|
1916 | - $important_selectors = array( |
|
1917 | - '.bg-primary' => array('b','f'), |
|
1918 | - '.border-primary' => array('o'), |
|
1919 | - '.text-primary' => array('c'), |
|
1920 | - ); |
|
1921 | - |
|
1922 | - $color = array(); |
|
1923 | - $color_i = array(); |
|
1924 | - $background = array(); |
|
1925 | - $background_i = array(); |
|
1926 | - $border = array(); |
|
1927 | - $border_i = array(); |
|
1928 | - $fill = array(); |
|
1929 | - $fill_i = array(); |
|
1930 | - |
|
1931 | - $output = ''; |
|
1932 | - |
|
1933 | - // build rules into each type |
|
1934 | - foreach($selectors as $selector => $types){ |
|
1935 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1936 | - $types = array_combine($types,$types); |
|
1937 | - if(isset($types['c'])){$color[] = $selector;} |
|
1938 | - if(isset($types['b'])){$background[] = $selector;} |
|
1939 | - if(isset($types['o'])){$border[] = $selector;} |
|
1940 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1941 | - } |
|
1942 | - |
|
1943 | - // build rules into each type |
|
1944 | - foreach($important_selectors as $selector => $types){ |
|
1945 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1946 | - $types = array_combine($types,$types); |
|
1947 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1948 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1949 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1950 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1951 | - } |
|
1952 | - |
|
1953 | - // add any color rules |
|
1954 | - if(!empty($color)){ |
|
1955 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1956 | - } |
|
1957 | - if(!empty($color_i)){ |
|
1958 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1959 | - } |
|
1960 | - |
|
1961 | - // add any background color rules |
|
1962 | - if(!empty($background)){ |
|
1963 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1964 | - } |
|
1965 | - if(!empty($background_i)){ |
|
1966 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1967 | - } |
|
1968 | - |
|
1969 | - // add any border color rules |
|
1970 | - if(!empty($border)){ |
|
1971 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1972 | - } |
|
1973 | - if(!empty($border_i)){ |
|
1974 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1975 | - } |
|
1976 | - |
|
1977 | - // add any fill color rules |
|
1978 | - if(!empty($fill)){ |
|
1979 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1980 | - } |
|
1981 | - if(!empty($fill_i)){ |
|
1982 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1983 | - } |
|
1984 | - |
|
1985 | - |
|
1986 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1987 | - |
|
1988 | - // darken |
|
1989 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1990 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1991 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1992 | - |
|
1993 | - // lighten |
|
1994 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1995 | - |
|
1996 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1997 | - $op_25 = $color_code."40"; // 25% opacity |
|
1998 | - |
|
1999 | - |
|
2000 | - // button states |
|
2001 | - $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
2002 | - $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;} "; |
|
2003 | - $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.";} "; |
|
2004 | - $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;} "; |
|
2005 | - |
|
2006 | - |
|
2007 | - // dropdown's |
|
2008 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
2009 | - |
|
2010 | - |
|
2011 | - // input states |
|
2012 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
2013 | - |
|
2014 | - // page link |
|
2015 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
2016 | - |
|
2017 | - return $output; |
|
2018 | - } |
|
2019 | - |
|
2020 | - /** |
|
2021 | - * |
|
2022 | - * @deprecated 0.1.76 Use css_overwrite() |
|
2023 | - * |
|
2024 | - * @param $color_code |
|
2025 | - * @param $compatibility |
|
2026 | - * |
|
2027 | - * @return string |
|
2028 | - */ |
|
2029 | - public static function css_secondary($color_code,$compatibility){; |
|
2030 | - $color_code = sanitize_hex_color($color_code); |
|
2031 | - if(!$color_code){return '';} |
|
2032 | - /** |
|
2033 | - * c = color, b = background color, o = border-color, f = fill |
|
2034 | - */ |
|
2035 | - $selectors = array( |
|
2036 | - '.btn-secondary' => array('b','o'), |
|
2037 | - '.btn-secondary.disabled' => array('b','o'), |
|
2038 | - '.btn-secondary:disabled' => array('b','o'), |
|
2039 | - '.btn-outline-secondary' => array('c','o'), |
|
2040 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
2041 | - '.btn-outline-secondary.disabled' => array('c'), |
|
2042 | - '.btn-outline-secondary:disabled' => array('c'), |
|
2043 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
2044 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
2045 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
2046 | - '.badge-secondary' => array('b'), |
|
2047 | - '.alert-secondary' => array('b','o'), |
|
2048 | - '.btn-link.btn-secondary' => array('c'), |
|
2049 | - ); |
|
2050 | - |
|
2051 | - $important_selectors = array( |
|
2052 | - '.bg-secondary' => array('b','f'), |
|
2053 | - '.border-secondary' => array('o'), |
|
2054 | - '.text-secondary' => array('c'), |
|
2055 | - ); |
|
2056 | - |
|
2057 | - $color = array(); |
|
2058 | - $color_i = array(); |
|
2059 | - $background = array(); |
|
2060 | - $background_i = array(); |
|
2061 | - $border = array(); |
|
2062 | - $border_i = array(); |
|
2063 | - $fill = array(); |
|
2064 | - $fill_i = array(); |
|
2065 | - |
|
2066 | - $output = ''; |
|
2067 | - |
|
2068 | - // build rules into each type |
|
2069 | - foreach($selectors as $selector => $types){ |
|
2070 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2071 | - $types = array_combine($types,$types); |
|
2072 | - if(isset($types['c'])){$color[] = $selector;} |
|
2073 | - if(isset($types['b'])){$background[] = $selector;} |
|
2074 | - if(isset($types['o'])){$border[] = $selector;} |
|
2075 | - if(isset($types['f'])){$fill[] = $selector;} |
|
2076 | - } |
|
2077 | - |
|
2078 | - // build rules into each type |
|
2079 | - foreach($important_selectors as $selector => $types){ |
|
2080 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
2081 | - $types = array_combine($types,$types); |
|
2082 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
2083 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
2084 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
2085 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
2086 | - } |
|
2087 | - |
|
2088 | - // add any color rules |
|
2089 | - if(!empty($color)){ |
|
2090 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
2091 | - } |
|
2092 | - if(!empty($color_i)){ |
|
2093 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
2094 | - } |
|
2095 | - |
|
2096 | - // add any background color rules |
|
2097 | - if(!empty($background)){ |
|
2098 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
2099 | - } |
|
2100 | - if(!empty($background_i)){ |
|
2101 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
2102 | - } |
|
2103 | - |
|
2104 | - // add any border color rules |
|
2105 | - if(!empty($border)){ |
|
2106 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
2107 | - } |
|
2108 | - if(!empty($border_i)){ |
|
2109 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
2110 | - } |
|
2111 | - |
|
2112 | - // add any fill color rules |
|
2113 | - if(!empty($fill)){ |
|
2114 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
2115 | - } |
|
2116 | - if(!empty($fill_i)){ |
|
2117 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
2118 | - } |
|
2119 | - |
|
2120 | - |
|
2121 | - $prefix = $compatibility ? ".bsui " : ""; |
|
2122 | - |
|
2123 | - // darken |
|
2124 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
2125 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
2126 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
2127 | - |
|
2128 | - // lighten |
|
2129 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
2130 | - |
|
2131 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
2132 | - $op_25 = $color_code."40"; // 25% opacity |
|
2133 | - |
|
2134 | - |
|
2135 | - // button states |
|
2136 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
2137 | - $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;} "; |
|
2138 | - $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.";} "; |
|
2139 | - $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;} "; |
|
2140 | - |
|
2141 | - |
|
2142 | - return $output; |
|
2143 | - } |
|
2144 | - |
|
2145 | - /** |
|
2146 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
2147 | - * |
|
2148 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
2149 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
2150 | - * |
|
2151 | - * @return string |
|
2152 | - */ |
|
2153 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
2154 | - $hexCode = ltrim($hexCode, '#'); |
|
2155 | - |
|
2156 | - if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) { |
|
2157 | - return $hexCode; |
|
2158 | - } |
|
2159 | - |
|
2160 | - if (strlen($hexCode) == 3) { |
|
2161 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
2162 | - } |
|
2163 | - |
|
2164 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
2165 | - |
|
2166 | - foreach ($hexCode as & $color) { |
|
2167 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
2168 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
2169 | - |
|
2170 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
2171 | - } |
|
2172 | - |
|
2173 | - return '#' . implode($hexCode); |
|
2174 | - } |
|
2175 | - |
|
2176 | - /** |
|
2177 | - * Check if we should display examples. |
|
2178 | - */ |
|
2179 | - public function maybe_show_examples(){ |
|
2180 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
2181 | - echo "<head>"; |
|
2182 | - wp_head(); |
|
2183 | - echo "</head>"; |
|
2184 | - echo "<body>"; |
|
2185 | - echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2186 | - echo "</body>"; |
|
2187 | - exit; |
|
2188 | - } |
|
2189 | - } |
|
2190 | - |
|
2191 | - /** |
|
2192 | - * Get developer examples. |
|
2193 | - * |
|
2194 | - * @return string |
|
2195 | - */ |
|
2196 | - public function get_examples(){ |
|
2197 | - $output = ''; |
|
2198 | - |
|
2199 | - |
|
2200 | - // open form |
|
2201 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
2202 | - |
|
2203 | - // input example |
|
2204 | - $output .= aui()->input(array( |
|
2205 | - 'type' => 'text', |
|
2206 | - 'id' => 'text-example', |
|
2207 | - 'name' => 'text-example', |
|
2208 | - 'placeholder' => 'text placeholder', |
|
2209 | - 'title' => 'Text input example', |
|
2210 | - 'value' => '', |
|
2211 | - 'required' => false, |
|
2212 | - 'help_text' => 'help text', |
|
2213 | - 'label' => 'Text input example label' |
|
2214 | - )); |
|
2215 | - |
|
2216 | - // input example |
|
2217 | - $output .= aui()->input(array( |
|
2218 | - 'type' => 'url', |
|
2219 | - 'id' => 'text-example2', |
|
2220 | - 'name' => 'text-example', |
|
2221 | - 'placeholder' => 'url placeholder', |
|
2222 | - 'title' => 'Text input example', |
|
2223 | - 'value' => '', |
|
2224 | - 'required' => false, |
|
2225 | - 'help_text' => 'help text', |
|
2226 | - 'label' => 'Text input example label' |
|
2227 | - )); |
|
2228 | - |
|
2229 | - // checkbox example |
|
2230 | - $output .= aui()->input(array( |
|
2231 | - 'type' => 'checkbox', |
|
2232 | - 'id' => 'checkbox-example', |
|
2233 | - 'name' => 'checkbox-example', |
|
2234 | - 'placeholder' => 'checkbox-example', |
|
2235 | - 'title' => 'Checkbox example', |
|
2236 | - 'value' => '1', |
|
2237 | - 'checked' => true, |
|
2238 | - 'required' => false, |
|
2239 | - 'help_text' => 'help text', |
|
2240 | - 'label' => 'Checkbox checked' |
|
2241 | - )); |
|
2242 | - |
|
2243 | - // checkbox example |
|
2244 | - $output .= aui()->input(array( |
|
2245 | - 'type' => 'checkbox', |
|
2246 | - 'id' => 'checkbox-example2', |
|
2247 | - 'name' => 'checkbox-example2', |
|
2248 | - 'placeholder' => 'checkbox-example', |
|
2249 | - 'title' => 'Checkbox example', |
|
2250 | - 'value' => '1', |
|
2251 | - 'checked' => false, |
|
2252 | - 'required' => false, |
|
2253 | - 'help_text' => 'help text', |
|
2254 | - 'label' => 'Checkbox un-checked' |
|
2255 | - )); |
|
2256 | - |
|
2257 | - // switch example |
|
2258 | - $output .= aui()->input(array( |
|
2259 | - 'type' => 'checkbox', |
|
2260 | - 'id' => 'switch-example', |
|
2261 | - 'name' => 'switch-example', |
|
2262 | - 'placeholder' => 'checkbox-example', |
|
2263 | - 'title' => 'Switch example', |
|
2264 | - 'value' => '1', |
|
2265 | - 'checked' => true, |
|
2266 | - 'switch' => true, |
|
2267 | - 'required' => false, |
|
2268 | - 'help_text' => 'help text', |
|
2269 | - 'label' => 'Switch on' |
|
2270 | - )); |
|
2271 | - |
|
2272 | - // switch example |
|
2273 | - $output .= aui()->input(array( |
|
2274 | - 'type' => 'checkbox', |
|
2275 | - 'id' => 'switch-example2', |
|
2276 | - 'name' => 'switch-example2', |
|
2277 | - 'placeholder' => 'checkbox-example', |
|
2278 | - 'title' => 'Switch example', |
|
2279 | - 'value' => '1', |
|
2280 | - 'checked' => false, |
|
2281 | - 'switch' => true, |
|
2282 | - 'required' => false, |
|
2283 | - 'help_text' => 'help text', |
|
2284 | - 'label' => 'Switch off' |
|
2285 | - )); |
|
2286 | - |
|
2287 | - // close form |
|
2288 | - $output .= "</form>"; |
|
2289 | - |
|
2290 | - return $output; |
|
2291 | - } |
|
2292 | - |
|
2293 | - /** |
|
2294 | - * Calendar params. |
|
2295 | - * |
|
2296 | - * @since 0.1.44 |
|
2297 | - * |
|
2298 | - * @return array Calendar params. |
|
2299 | - */ |
|
2300 | - public static function calendar_params() { |
|
2301 | - $params = array( |
|
2302 | - 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
2303 | - 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
2304 | - 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
2305 | - 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
2306 | - 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
2307 | - 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
2308 | - 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
2309 | - 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
2310 | - 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
2311 | - 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
2312 | - 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
2313 | - 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
2314 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
2315 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
2316 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
2317 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
2318 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
2319 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
2320 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
2321 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
2322 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
2323 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
2324 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
2325 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
2326 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
2327 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
2328 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
2329 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
2330 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
2331 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
2332 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
2333 | - 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
2334 | - 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
2335 | - 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
2336 | - 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
2337 | - 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
2338 | - 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
2339 | - 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
2340 | - 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
2341 | - 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
2342 | - 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
2343 | - 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
2344 | - 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
2345 | - 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
2346 | - 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
2347 | - 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
2348 | - 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
2349 | - 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
2350 | - 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
2351 | - 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
2352 | - 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
2353 | - 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
2354 | - 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
2355 | - 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
2356 | - 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
2357 | - 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
2358 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
2359 | - 'time_24hr' => false, |
|
2360 | - 'year' => __( 'Year', 'ayecode-connect' ), |
|
2361 | - 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
2362 | - 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
2363 | - 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
2364 | - 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
2365 | - 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
2366 | - 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
2367 | - ); |
|
2368 | - |
|
2369 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
2370 | - } |
|
2371 | - |
|
2372 | - /** |
|
2373 | - * Flatpickr calendar localize. |
|
2374 | - * |
|
2375 | - * @since 0.1.44 |
|
2376 | - * |
|
2377 | - * @return string Calendar locale. |
|
2378 | - */ |
|
2379 | - public static function flatpickr_locale() { |
|
2380 | - $params = self::calendar_params(); |
|
2381 | - |
|
2382 | - if ( is_string( $params ) ) { |
|
2383 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
2384 | - } else { |
|
2385 | - foreach ( (array) $params as $key => $value ) { |
|
2386 | - if ( ! is_scalar( $value ) ) { |
|
2387 | - continue; |
|
2388 | - } |
|
2389 | - |
|
2390 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2391 | - } |
|
2392 | - } |
|
2393 | 2199 | |
2394 | - $day_s3 = array(); |
|
2395 | - $day_s5 = array(); |
|
2200 | + // open form |
|
2201 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
2202 | + |
|
2203 | + // input example |
|
2204 | + $output .= aui()->input(array( |
|
2205 | + 'type' => 'text', |
|
2206 | + 'id' => 'text-example', |
|
2207 | + 'name' => 'text-example', |
|
2208 | + 'placeholder' => 'text placeholder', |
|
2209 | + 'title' => 'Text input example', |
|
2210 | + 'value' => '', |
|
2211 | + 'required' => false, |
|
2212 | + 'help_text' => 'help text', |
|
2213 | + 'label' => 'Text input example label' |
|
2214 | + )); |
|
2215 | + |
|
2216 | + // input example |
|
2217 | + $output .= aui()->input(array( |
|
2218 | + 'type' => 'url', |
|
2219 | + 'id' => 'text-example2', |
|
2220 | + 'name' => 'text-example', |
|
2221 | + 'placeholder' => 'url placeholder', |
|
2222 | + 'title' => 'Text input example', |
|
2223 | + 'value' => '', |
|
2224 | + 'required' => false, |
|
2225 | + 'help_text' => 'help text', |
|
2226 | + 'label' => 'Text input example label' |
|
2227 | + )); |
|
2228 | + |
|
2229 | + // checkbox example |
|
2230 | + $output .= aui()->input(array( |
|
2231 | + 'type' => 'checkbox', |
|
2232 | + 'id' => 'checkbox-example', |
|
2233 | + 'name' => 'checkbox-example', |
|
2234 | + 'placeholder' => 'checkbox-example', |
|
2235 | + 'title' => 'Checkbox example', |
|
2236 | + 'value' => '1', |
|
2237 | + 'checked' => true, |
|
2238 | + 'required' => false, |
|
2239 | + 'help_text' => 'help text', |
|
2240 | + 'label' => 'Checkbox checked' |
|
2241 | + )); |
|
2242 | + |
|
2243 | + // checkbox example |
|
2244 | + $output .= aui()->input(array( |
|
2245 | + 'type' => 'checkbox', |
|
2246 | + 'id' => 'checkbox-example2', |
|
2247 | + 'name' => 'checkbox-example2', |
|
2248 | + 'placeholder' => 'checkbox-example', |
|
2249 | + 'title' => 'Checkbox example', |
|
2250 | + 'value' => '1', |
|
2251 | + 'checked' => false, |
|
2252 | + 'required' => false, |
|
2253 | + 'help_text' => 'help text', |
|
2254 | + 'label' => 'Checkbox un-checked' |
|
2255 | + )); |
|
2256 | + |
|
2257 | + // switch example |
|
2258 | + $output .= aui()->input(array( |
|
2259 | + 'type' => 'checkbox', |
|
2260 | + 'id' => 'switch-example', |
|
2261 | + 'name' => 'switch-example', |
|
2262 | + 'placeholder' => 'checkbox-example', |
|
2263 | + 'title' => 'Switch example', |
|
2264 | + 'value' => '1', |
|
2265 | + 'checked' => true, |
|
2266 | + 'switch' => true, |
|
2267 | + 'required' => false, |
|
2268 | + 'help_text' => 'help text', |
|
2269 | + 'label' => 'Switch on' |
|
2270 | + )); |
|
2271 | + |
|
2272 | + // switch example |
|
2273 | + $output .= aui()->input(array( |
|
2274 | + 'type' => 'checkbox', |
|
2275 | + 'id' => 'switch-example2', |
|
2276 | + 'name' => 'switch-example2', |
|
2277 | + 'placeholder' => 'checkbox-example', |
|
2278 | + 'title' => 'Switch example', |
|
2279 | + 'value' => '1', |
|
2280 | + 'checked' => false, |
|
2281 | + 'switch' => true, |
|
2282 | + 'required' => false, |
|
2283 | + 'help_text' => 'help text', |
|
2284 | + 'label' => 'Switch off' |
|
2285 | + )); |
|
2286 | + |
|
2287 | + // close form |
|
2288 | + $output .= "</form>"; |
|
2289 | + |
|
2290 | + return $output; |
|
2291 | + } |
|
2292 | + |
|
2293 | + /** |
|
2294 | + * Calendar params. |
|
2295 | + * |
|
2296 | + * @since 0.1.44 |
|
2297 | + * |
|
2298 | + * @return array Calendar params. |
|
2299 | + */ |
|
2300 | + public static function calendar_params() { |
|
2301 | + $params = array( |
|
2302 | + 'month_long_1' => __( 'January', 'ayecode-connect' ), |
|
2303 | + 'month_long_2' => __( 'February', 'ayecode-connect' ), |
|
2304 | + 'month_long_3' => __( 'March', 'ayecode-connect' ), |
|
2305 | + 'month_long_4' => __( 'April', 'ayecode-connect' ), |
|
2306 | + 'month_long_5' => __( 'May', 'ayecode-connect' ), |
|
2307 | + 'month_long_6' => __( 'June', 'ayecode-connect' ), |
|
2308 | + 'month_long_7' => __( 'July', 'ayecode-connect' ), |
|
2309 | + 'month_long_8' => __( 'August', 'ayecode-connect' ), |
|
2310 | + 'month_long_9' => __( 'September', 'ayecode-connect' ), |
|
2311 | + 'month_long_10' => __( 'October', 'ayecode-connect' ), |
|
2312 | + 'month_long_11' => __( 'November', 'ayecode-connect' ), |
|
2313 | + 'month_long_12' => __( 'December', 'ayecode-connect' ), |
|
2314 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ), |
|
2315 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ), |
|
2316 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ), |
|
2317 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ), |
|
2318 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ), |
|
2319 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ), |
|
2320 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ), |
|
2321 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ), |
|
2322 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ), |
|
2323 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ), |
|
2324 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ), |
|
2325 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ), |
|
2326 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ), |
|
2327 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ), |
|
2328 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ), |
|
2329 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ), |
|
2330 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ), |
|
2331 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ), |
|
2332 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ), |
|
2333 | + 'day_s2_1' => __( 'Su', 'ayecode-connect' ), |
|
2334 | + 'day_s2_2' => __( 'Mo', 'ayecode-connect' ), |
|
2335 | + 'day_s2_3' => __( 'Tu', 'ayecode-connect' ), |
|
2336 | + 'day_s2_4' => __( 'We', 'ayecode-connect' ), |
|
2337 | + 'day_s2_5' => __( 'Th', 'ayecode-connect' ), |
|
2338 | + 'day_s2_6' => __( 'Fr', 'ayecode-connect' ), |
|
2339 | + 'day_s2_7' => __( 'Sa', 'ayecode-connect' ), |
|
2340 | + 'day_s3_1' => __( 'Sun', 'ayecode-connect' ), |
|
2341 | + 'day_s3_2' => __( 'Mon', 'ayecode-connect' ), |
|
2342 | + 'day_s3_3' => __( 'Tue', 'ayecode-connect' ), |
|
2343 | + 'day_s3_4' => __( 'Wed', 'ayecode-connect' ), |
|
2344 | + 'day_s3_5' => __( 'Thu', 'ayecode-connect' ), |
|
2345 | + 'day_s3_6' => __( 'Fri', 'ayecode-connect' ), |
|
2346 | + 'day_s3_7' => __( 'Sat', 'ayecode-connect' ), |
|
2347 | + 'day_s5_1' => __( 'Sunday', 'ayecode-connect' ), |
|
2348 | + 'day_s5_2' => __( 'Monday', 'ayecode-connect' ), |
|
2349 | + 'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ), |
|
2350 | + 'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ), |
|
2351 | + 'day_s5_5' => __( 'Thursday', 'ayecode-connect' ), |
|
2352 | + 'day_s5_6' => __( 'Friday', 'ayecode-connect' ), |
|
2353 | + 'day_s5_7' => __( 'Saturday', 'ayecode-connect' ), |
|
2354 | + 'am_lower' => __( 'am', 'ayecode-connect' ), |
|
2355 | + 'pm_lower' => __( 'pm', 'ayecode-connect' ), |
|
2356 | + 'am_upper' => __( 'AM', 'ayecode-connect' ), |
|
2357 | + 'pm_upper' => __( 'PM', 'ayecode-connect' ), |
|
2358 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
2359 | + 'time_24hr' => false, |
|
2360 | + 'year' => __( 'Year', 'ayecode-connect' ), |
|
2361 | + 'hour' => __( 'Hour', 'ayecode-connect' ), |
|
2362 | + 'minute' => __( 'Minute', 'ayecode-connect' ), |
|
2363 | + 'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ), |
|
2364 | + 'rangeSeparator' => __( ' to ', 'ayecode-connect' ), |
|
2365 | + 'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ), |
|
2366 | + 'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' ) |
|
2367 | + ); |
|
2368 | + |
|
2369 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
2370 | + } |
|
2371 | + |
|
2372 | + /** |
|
2373 | + * Flatpickr calendar localize. |
|
2374 | + * |
|
2375 | + * @since 0.1.44 |
|
2376 | + * |
|
2377 | + * @return string Calendar locale. |
|
2378 | + */ |
|
2379 | + public static function flatpickr_locale() { |
|
2380 | + $params = self::calendar_params(); |
|
2381 | + |
|
2382 | + if ( is_string( $params ) ) { |
|
2383 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
2384 | + } else { |
|
2385 | + foreach ( (array) $params as $key => $value ) { |
|
2386 | + if ( ! is_scalar( $value ) ) { |
|
2387 | + continue; |
|
2388 | + } |
|
2389 | + |
|
2390 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2391 | + } |
|
2392 | + } |
|
2396 | 2393 | |
2397 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
2398 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2399 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2400 | - } |
|
2394 | + $day_s3 = array(); |
|
2395 | + $day_s5 = array(); |
|
2396 | + |
|
2397 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
2398 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2399 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2400 | + } |
|
2401 | 2401 | |
2402 | - $month_s = array(); |
|
2403 | - $month_long = array(); |
|
2402 | + $month_s = array(); |
|
2403 | + $month_long = array(); |
|
2404 | 2404 | |
2405 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
2406 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2407 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2408 | - } |
|
2405 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
2406 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2407 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
2408 | + } |
|
2409 | 2409 | |
2410 | - ob_start(); |
|
2411 | - if ( 0 ) { ?><script><?php } ?> |
|
2410 | + ob_start(); |
|
2411 | + if ( 0 ) { ?><script><?php } ?> |
|
2412 | 2412 | { |
2413 | 2413 | weekdays: { |
2414 | 2414 | shorthand: ['<?php echo implode( "','", $day_s3 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'], |
@@ -2447,189 +2447,189 @@ discard block |
||
2447 | 2447 | } |
2448 | 2448 | <?php if ( 0 ) { ?></script><?php } ?> |
2449 | 2449 | <?php |
2450 | - $locale = ob_get_clean(); |
|
2451 | - |
|
2452 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2453 | - } |
|
2454 | - |
|
2455 | - /** |
|
2456 | - * Select2 JS params. |
|
2457 | - * |
|
2458 | - * @since 0.1.44 |
|
2459 | - * |
|
2460 | - * @return array Select2 JS params. |
|
2461 | - */ |
|
2462 | - public static function select2_params() { |
|
2463 | - $params = array( |
|
2464 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
2465 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
2466 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
2467 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2468 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2469 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
2470 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
2471 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
2472 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
2473 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
2474 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
2475 | - ); |
|
2476 | - |
|
2477 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2478 | - } |
|
2479 | - |
|
2480 | - /** |
|
2481 | - * Select2 JS localize. |
|
2482 | - * |
|
2483 | - * @since 0.1.44 |
|
2484 | - * |
|
2485 | - * @return string Select2 JS locale. |
|
2486 | - */ |
|
2487 | - public static function select2_locale() { |
|
2488 | - $params = self::select2_params(); |
|
2489 | - |
|
2490 | - foreach ( (array) $params as $key => $value ) { |
|
2491 | - if ( ! is_scalar( $value ) ) { |
|
2492 | - continue; |
|
2493 | - } |
|
2450 | + $locale = ob_get_clean(); |
|
2494 | 2451 | |
2495 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2496 | - } |
|
2497 | - |
|
2498 | - $locale = json_encode( $params ); |
|
2499 | - |
|
2500 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2501 | - } |
|
2502 | - |
|
2503 | - /** |
|
2504 | - * Time ago JS localize. |
|
2505 | - * |
|
2506 | - * @since 0.1.47 |
|
2507 | - * |
|
2508 | - * @return string Time ago JS locale. |
|
2509 | - */ |
|
2510 | - public static function timeago_locale() { |
|
2511 | - $params = array( |
|
2512 | - 'prefix_ago' => '', |
|
2513 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
2514 | - 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
2515 | - 'suffix_after' => '', |
|
2516 | - 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
2517 | - 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
2518 | - 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
2519 | - 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
2520 | - 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
2521 | - 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
2522 | - 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
2523 | - 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
2524 | - 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
2525 | - 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
2526 | - 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
2527 | - ); |
|
2528 | - |
|
2529 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2530 | - |
|
2531 | - foreach ( (array) $params as $key => $value ) { |
|
2532 | - if ( ! is_scalar( $value ) ) { |
|
2533 | - continue; |
|
2534 | - } |
|
2452 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2453 | + } |
|
2454 | + |
|
2455 | + /** |
|
2456 | + * Select2 JS params. |
|
2457 | + * |
|
2458 | + * @since 0.1.44 |
|
2459 | + * |
|
2460 | + * @return array Select2 JS params. |
|
2461 | + */ |
|
2462 | + public static function select2_params() { |
|
2463 | + $params = array( |
|
2464 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'ayecode-connect' ), |
|
2465 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ), |
|
2466 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ), |
|
2467 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2468 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ), |
|
2469 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ), |
|
2470 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ), |
|
2471 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ), |
|
2472 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ), |
|
2473 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'ayecode-connect' ), |
|
2474 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'ayecode-connect' ) |
|
2475 | + ); |
|
2476 | + |
|
2477 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2478 | + } |
|
2479 | + |
|
2480 | + /** |
|
2481 | + * Select2 JS localize. |
|
2482 | + * |
|
2483 | + * @since 0.1.44 |
|
2484 | + * |
|
2485 | + * @return string Select2 JS locale. |
|
2486 | + */ |
|
2487 | + public static function select2_locale() { |
|
2488 | + $params = self::select2_params(); |
|
2489 | + |
|
2490 | + foreach ( (array) $params as $key => $value ) { |
|
2491 | + if ( ! is_scalar( $value ) ) { |
|
2492 | + continue; |
|
2493 | + } |
|
2494 | + |
|
2495 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2496 | + } |
|
2497 | + |
|
2498 | + $locale = json_encode( $params ); |
|
2499 | + |
|
2500 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2501 | + } |
|
2502 | + |
|
2503 | + /** |
|
2504 | + * Time ago JS localize. |
|
2505 | + * |
|
2506 | + * @since 0.1.47 |
|
2507 | + * |
|
2508 | + * @return string Time ago JS locale. |
|
2509 | + */ |
|
2510 | + public static function timeago_locale() { |
|
2511 | + $params = array( |
|
2512 | + 'prefix_ago' => '', |
|
2513 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ), |
|
2514 | + 'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ', |
|
2515 | + 'suffix_after' => '', |
|
2516 | + 'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ), |
|
2517 | + 'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ), |
|
2518 | + 'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ), |
|
2519 | + 'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ), |
|
2520 | + 'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ), |
|
2521 | + 'day' => _x( 'a day', 'time ago', 'ayecode-connect' ), |
|
2522 | + 'days' => _x( '%d days', 'time ago', 'ayecode-connect' ), |
|
2523 | + 'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ), |
|
2524 | + 'months' => _x( '%d months', 'time ago', 'ayecode-connect' ), |
|
2525 | + 'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ), |
|
2526 | + 'years' => _x( '%d years', 'time ago', 'ayecode-connect' ), |
|
2527 | + ); |
|
2528 | + |
|
2529 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2530 | + |
|
2531 | + foreach ( (array) $params as $key => $value ) { |
|
2532 | + if ( ! is_scalar( $value ) ) { |
|
2533 | + continue; |
|
2534 | + } |
|
2535 | 2535 | |
2536 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2537 | - } |
|
2538 | - |
|
2539 | - $locale = json_encode( $params ); |
|
2540 | - |
|
2541 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2542 | - } |
|
2543 | - |
|
2544 | - /** |
|
2545 | - * JavaScript Minifier |
|
2546 | - * |
|
2547 | - * @param $input |
|
2548 | - * |
|
2549 | - * @return mixed |
|
2550 | - */ |
|
2551 | - public static function minify_js($input) { |
|
2552 | - if(trim($input) === "") return $input; |
|
2553 | - return preg_replace( |
|
2554 | - array( |
|
2555 | - // Remove comment(s) |
|
2556 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2557 | - // Remove white-space(s) outside the string and regex |
|
2558 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2559 | - // Remove the last semicolon |
|
2560 | - '#;+\}#', |
|
2561 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2562 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2563 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
2564 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2565 | - ), |
|
2566 | - array( |
|
2567 | - '$1', |
|
2568 | - '$1$2', |
|
2569 | - '}', |
|
2570 | - '$1$3', |
|
2571 | - '$1.$3' |
|
2572 | - ), |
|
2573 | - $input); |
|
2574 | - } |
|
2575 | - |
|
2576 | - /** |
|
2577 | - * Minify CSS |
|
2578 | - * |
|
2579 | - * @param $input |
|
2580 | - * |
|
2581 | - * @return mixed |
|
2582 | - */ |
|
2583 | - public static function minify_css($input) { |
|
2584 | - if(trim($input) === "") return $input; |
|
2585 | - return preg_replace( |
|
2586 | - array( |
|
2587 | - // Remove comment(s) |
|
2588 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2589 | - // Remove unused white-space(s) |
|
2590 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2591 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2592 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2593 | - // Replace `:0 0 0 0` with `:0` |
|
2594 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2595 | - // Replace `background-position:0` with `background-position:0 0` |
|
2596 | - '#(background-position):0(?=[;\}])#si', |
|
2597 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2598 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2599 | - // Minify string value |
|
2600 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2601 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2602 | - // Minify HEX color code |
|
2603 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2604 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
2605 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2606 | - // Remove empty selector(s) |
|
2607 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2608 | - ), |
|
2609 | - array( |
|
2610 | - '$1', |
|
2611 | - '$1$2$3$4$5$6$7', |
|
2612 | - '$1', |
|
2613 | - ':0', |
|
2614 | - '$1:0 0', |
|
2615 | - '.$1', |
|
2616 | - '$1$3', |
|
2617 | - '$1$2$4$5', |
|
2618 | - '$1$2$3', |
|
2619 | - '$1:0', |
|
2620 | - '$1$2' |
|
2621 | - ), |
|
2622 | - $input); |
|
2623 | - } |
|
2624 | - |
|
2625 | - /** |
|
2626 | - * Get the conditional fields JavaScript. |
|
2627 | - * |
|
2628 | - * @return mixed |
|
2629 | - */ |
|
2630 | - public function conditional_fields_js() { |
|
2631 | - ob_start(); |
|
2632 | - ?> |
|
2536 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2537 | + } |
|
2538 | + |
|
2539 | + $locale = json_encode( $params ); |
|
2540 | + |
|
2541 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2542 | + } |
|
2543 | + |
|
2544 | + /** |
|
2545 | + * JavaScript Minifier |
|
2546 | + * |
|
2547 | + * @param $input |
|
2548 | + * |
|
2549 | + * @return mixed |
|
2550 | + */ |
|
2551 | + public static function minify_js($input) { |
|
2552 | + if(trim($input) === "") return $input; |
|
2553 | + return preg_replace( |
|
2554 | + array( |
|
2555 | + // Remove comment(s) |
|
2556 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2557 | + // Remove white-space(s) outside the string and regex |
|
2558 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2559 | + // Remove the last semicolon |
|
2560 | + '#;+\}#', |
|
2561 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2562 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2563 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
2564 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2565 | + ), |
|
2566 | + array( |
|
2567 | + '$1', |
|
2568 | + '$1$2', |
|
2569 | + '}', |
|
2570 | + '$1$3', |
|
2571 | + '$1.$3' |
|
2572 | + ), |
|
2573 | + $input); |
|
2574 | + } |
|
2575 | + |
|
2576 | + /** |
|
2577 | + * Minify CSS |
|
2578 | + * |
|
2579 | + * @param $input |
|
2580 | + * |
|
2581 | + * @return mixed |
|
2582 | + */ |
|
2583 | + public static function minify_css($input) { |
|
2584 | + if(trim($input) === "") return $input; |
|
2585 | + return preg_replace( |
|
2586 | + array( |
|
2587 | + // Remove comment(s) |
|
2588 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2589 | + // Remove unused white-space(s) |
|
2590 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2591 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2592 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2593 | + // Replace `:0 0 0 0` with `:0` |
|
2594 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2595 | + // Replace `background-position:0` with `background-position:0 0` |
|
2596 | + '#(background-position):0(?=[;\}])#si', |
|
2597 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2598 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2599 | + // Minify string value |
|
2600 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2601 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2602 | + // Minify HEX color code |
|
2603 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2604 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
2605 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2606 | + // Remove empty selector(s) |
|
2607 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2608 | + ), |
|
2609 | + array( |
|
2610 | + '$1', |
|
2611 | + '$1$2$3$4$5$6$7', |
|
2612 | + '$1', |
|
2613 | + ':0', |
|
2614 | + '$1:0 0', |
|
2615 | + '.$1', |
|
2616 | + '$1$3', |
|
2617 | + '$1$2$4$5', |
|
2618 | + '$1$2$3', |
|
2619 | + '$1:0', |
|
2620 | + '$1$2' |
|
2621 | + ), |
|
2622 | + $input); |
|
2623 | + } |
|
2624 | + |
|
2625 | + /** |
|
2626 | + * Get the conditional fields JavaScript. |
|
2627 | + * |
|
2628 | + * @return mixed |
|
2629 | + */ |
|
2630 | + public function conditional_fields_js() { |
|
2631 | + ob_start(); |
|
2632 | + ?> |
|
2633 | 2633 | <script> |
2634 | 2634 | /** |
2635 | 2635 | * Conditional Fields |
@@ -3164,237 +3164,237 @@ discard block |
||
3164 | 3164 | <?php do_action( 'aui_conditional_fields_js', $this ); ?> |
3165 | 3165 | </script> |
3166 | 3166 | <?php |
3167 | - $output = ob_get_clean(); |
|
3168 | - |
|
3169 | - return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
3170 | - } |
|
3171 | - |
|
3172 | - /** |
|
3173 | - * Check if block editor page. |
|
3174 | - * |
|
3175 | - * @since 0.2.27 |
|
3176 | - * |
|
3177 | - * @return bool |
|
3178 | - */ |
|
3179 | - public static function is_block_editor() { |
|
3180 | - if ( is_admin() ) { |
|
3181 | - $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : array(); |
|
3182 | - |
|
3183 | - if ( ! empty( $current_screen ) && $current_screen->is_block_editor() ) { |
|
3184 | - return true; |
|
3185 | - } |
|
3186 | - } |
|
3187 | - |
|
3188 | - return false; |
|
3189 | - } |
|
3190 | - |
|
3191 | - /** |
|
3192 | - * Checks if the current call is a ajax call to get the block content. |
|
3193 | - * |
|
3194 | - * This can be used in your widget to return different content as the block content. |
|
3195 | - * |
|
3196 | - * @since 0.2.27 |
|
3197 | - * |
|
3198 | - * @return bool |
|
3199 | - */ |
|
3200 | - public static function is_block_content_call() { |
|
3201 | - $result = false; |
|
3202 | - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
3203 | - $result = true; |
|
3204 | - } |
|
3205 | - |
|
3206 | - return $result; |
|
3207 | - } |
|
3208 | - |
|
3209 | - /** |
|
3210 | - * Tests if the current output is inside a Divi preview. |
|
3211 | - * |
|
3212 | - * @since 0.2.27 |
|
3213 | - * |
|
3214 | - * @return bool |
|
3215 | - */ |
|
3216 | - public static function is_divi_preview() { |
|
3217 | - $result = false; |
|
3218 | - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
3219 | - $result = true; |
|
3220 | - } |
|
3221 | - |
|
3222 | - return $result; |
|
3223 | - } |
|
3224 | - |
|
3225 | - /** |
|
3226 | - * Tests if the current output is inside a elementor preview. |
|
3227 | - * |
|
3228 | - * |
|
3229 | - * @since 0.2.27 |
|
3230 | - * |
|
3231 | - * @return bool |
|
3232 | - */ |
|
3233 | - public static function is_elementor_preview() { |
|
3234 | - $result = false; |
|
3235 | - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
3236 | - $result = true; |
|
3237 | - } |
|
3238 | - |
|
3239 | - return $result; |
|
3240 | - } |
|
3241 | - |
|
3242 | - /** |
|
3243 | - * Tests if the current output is inside a Beaver builder preview. |
|
3244 | - * |
|
3245 | - * @since 0.2.27 |
|
3246 | - * |
|
3247 | - * @return bool |
|
3248 | - */ |
|
3249 | - public static function is_beaver_preview() { |
|
3250 | - $result = false; |
|
3251 | - if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
3252 | - $result = true; |
|
3253 | - } |
|
3254 | - |
|
3255 | - return $result; |
|
3256 | - } |
|
3257 | - |
|
3258 | - /** |
|
3259 | - * Tests if the current output is inside a siteorigin builder preview. |
|
3260 | - * |
|
3261 | - * @since 0.2.27 |
|
3262 | - * |
|
3263 | - * @return bool |
|
3264 | - */ |
|
3265 | - public static function is_siteorigin_preview() { |
|
3266 | - $result = false; |
|
3267 | - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
3268 | - $result = true; |
|
3269 | - } |
|
3270 | - |
|
3271 | - return $result; |
|
3272 | - } |
|
3273 | - |
|
3274 | - /** |
|
3275 | - * Tests if the current output is inside a cornerstone builder preview. |
|
3276 | - * |
|
3277 | - * @since 0.2.27 |
|
3278 | - * |
|
3279 | - * @return bool |
|
3280 | - */ |
|
3281 | - public static function is_cornerstone_preview() { |
|
3282 | - $result = false; |
|
3283 | - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
3284 | - $result = true; |
|
3285 | - } |
|
3286 | - |
|
3287 | - return $result; |
|
3288 | - } |
|
3289 | - |
|
3290 | - /** |
|
3291 | - * Tests if the current output is inside a fusion builder preview. |
|
3292 | - * |
|
3293 | - * @return bool |
|
3294 | - *@since 1.1.0 |
|
3295 | - */ |
|
3296 | - public static function is_fusion_preview() { |
|
3297 | - $result = false; |
|
3298 | - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
3299 | - $result = true; |
|
3300 | - } |
|
3301 | - |
|
3302 | - return $result; |
|
3303 | - } |
|
3304 | - |
|
3305 | - /** |
|
3306 | - * Tests if the current output is inside a Oxygen builder preview. |
|
3307 | - * |
|
3308 | - * @return bool |
|
3309 | - *@since 1.0.18 |
|
3310 | - */ |
|
3311 | - public static function is_oxygen_preview() { |
|
3312 | - $result = false; |
|
3313 | - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
3314 | - $result = true; |
|
3315 | - } |
|
3316 | - |
|
3317 | - return $result; |
|
3318 | - } |
|
3319 | - |
|
3320 | - /** |
|
3321 | - * Check for Kallyas theme Zion builder preview. |
|
3322 | - * |
|
3323 | - * @since 0.2.27 |
|
3324 | - * |
|
3325 | - * @return bool |
|
3326 | - */ |
|
3327 | - public static function is_kallyas_zion_preview() { |
|
3328 | - $result = false; |
|
3329 | - |
|
3330 | - if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) { |
|
3331 | - $result = true; |
|
3332 | - } |
|
3333 | - |
|
3334 | - return $result; |
|
3335 | - } |
|
3336 | - |
|
3337 | - /** |
|
3338 | - * Check for Bricks theme builder preview. |
|
3339 | - * |
|
3340 | - * @since 0.2.27 |
|
3341 | - * |
|
3342 | - * @return bool |
|
3343 | - */ |
|
3344 | - public static function is_bricks_preview() { |
|
3345 | - $result = false; |
|
3346 | - |
|
3347 | - if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) { |
|
3348 | - $result = true; |
|
3349 | - } |
|
3350 | - |
|
3351 | - return $result; |
|
3352 | - } |
|
3353 | - |
|
3354 | - /** |
|
3355 | - * General function to check if we are in a preview situation. |
|
3356 | - * |
|
3357 | - * @since 0.2.27 |
|
3358 | - * |
|
3359 | - * @return bool |
|
3360 | - */ |
|
3361 | - public static function is_preview() { |
|
3362 | - $preview = false; |
|
3363 | - |
|
3364 | - if ( self::is_block_editor() ) { |
|
3365 | - return true; |
|
3366 | - } |
|
3367 | - |
|
3368 | - if( self::is_block_content_call() ) { |
|
3369 | - $preview = true; |
|
3370 | - } elseif ( self::is_divi_preview() ) { |
|
3371 | - $preview = true; |
|
3372 | - } elseif ( self::is_elementor_preview() ) { |
|
3373 | - $preview = true; |
|
3374 | - } elseif ( self::is_beaver_preview() ) { |
|
3375 | - $preview = true; |
|
3376 | - } elseif ( self::is_siteorigin_preview() ) { |
|
3377 | - $preview = true; |
|
3378 | - } elseif ( self::is_cornerstone_preview() ) { |
|
3379 | - $preview = true; |
|
3380 | - } elseif ( self::is_fusion_preview() ) { |
|
3381 | - $preview = true; |
|
3382 | - } elseif ( self::is_oxygen_preview() ) { |
|
3383 | - $preview = true; |
|
3384 | - } elseif( self::is_kallyas_zion_preview() ) { |
|
3385 | - $preview = true; |
|
3386 | - } elseif( self::is_bricks_preview() ) { |
|
3387 | - $preview = true; |
|
3388 | - } |
|
3389 | - |
|
3390 | - return $preview; |
|
3391 | - } |
|
3392 | - } |
|
3393 | - |
|
3394 | - global $ayecode_ui_settings; |
|
3395 | - |
|
3396 | - /** |
|
3397 | - * Run the class if found. |
|
3398 | - */ |
|
3399 | - $ayecode_ui_settings = AyeCode_UI_Settings::instance(); |
|
3167 | + $output = ob_get_clean(); |
|
3168 | + |
|
3169 | + return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) ); |
|
3170 | + } |
|
3171 | + |
|
3172 | + /** |
|
3173 | + * Check if block editor page. |
|
3174 | + * |
|
3175 | + * @since 0.2.27 |
|
3176 | + * |
|
3177 | + * @return bool |
|
3178 | + */ |
|
3179 | + public static function is_block_editor() { |
|
3180 | + if ( is_admin() ) { |
|
3181 | + $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : array(); |
|
3182 | + |
|
3183 | + if ( ! empty( $current_screen ) && $current_screen->is_block_editor() ) { |
|
3184 | + return true; |
|
3185 | + } |
|
3186 | + } |
|
3187 | + |
|
3188 | + return false; |
|
3189 | + } |
|
3190 | + |
|
3191 | + /** |
|
3192 | + * Checks if the current call is a ajax call to get the block content. |
|
3193 | + * |
|
3194 | + * This can be used in your widget to return different content as the block content. |
|
3195 | + * |
|
3196 | + * @since 0.2.27 |
|
3197 | + * |
|
3198 | + * @return bool |
|
3199 | + */ |
|
3200 | + public static function is_block_content_call() { |
|
3201 | + $result = false; |
|
3202 | + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { |
|
3203 | + $result = true; |
|
3204 | + } |
|
3205 | + |
|
3206 | + return $result; |
|
3207 | + } |
|
3208 | + |
|
3209 | + /** |
|
3210 | + * Tests if the current output is inside a Divi preview. |
|
3211 | + * |
|
3212 | + * @since 0.2.27 |
|
3213 | + * |
|
3214 | + * @return bool |
|
3215 | + */ |
|
3216 | + public static function is_divi_preview() { |
|
3217 | + $result = false; |
|
3218 | + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { |
|
3219 | + $result = true; |
|
3220 | + } |
|
3221 | + |
|
3222 | + return $result; |
|
3223 | + } |
|
3224 | + |
|
3225 | + /** |
|
3226 | + * Tests if the current output is inside a elementor preview. |
|
3227 | + * |
|
3228 | + * |
|
3229 | + * @since 0.2.27 |
|
3230 | + * |
|
3231 | + * @return bool |
|
3232 | + */ |
|
3233 | + public static function is_elementor_preview() { |
|
3234 | + $result = false; |
|
3235 | + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { |
|
3236 | + $result = true; |
|
3237 | + } |
|
3238 | + |
|
3239 | + return $result; |
|
3240 | + } |
|
3241 | + |
|
3242 | + /** |
|
3243 | + * Tests if the current output is inside a Beaver builder preview. |
|
3244 | + * |
|
3245 | + * @since 0.2.27 |
|
3246 | + * |
|
3247 | + * @return bool |
|
3248 | + */ |
|
3249 | + public static function is_beaver_preview() { |
|
3250 | + $result = false; |
|
3251 | + if ( isset( $_REQUEST['fl_builder'] ) ) { |
|
3252 | + $result = true; |
|
3253 | + } |
|
3254 | + |
|
3255 | + return $result; |
|
3256 | + } |
|
3257 | + |
|
3258 | + /** |
|
3259 | + * Tests if the current output is inside a siteorigin builder preview. |
|
3260 | + * |
|
3261 | + * @since 0.2.27 |
|
3262 | + * |
|
3263 | + * @return bool |
|
3264 | + */ |
|
3265 | + public static function is_siteorigin_preview() { |
|
3266 | + $result = false; |
|
3267 | + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { |
|
3268 | + $result = true; |
|
3269 | + } |
|
3270 | + |
|
3271 | + return $result; |
|
3272 | + } |
|
3273 | + |
|
3274 | + /** |
|
3275 | + * Tests if the current output is inside a cornerstone builder preview. |
|
3276 | + * |
|
3277 | + * @since 0.2.27 |
|
3278 | + * |
|
3279 | + * @return bool |
|
3280 | + */ |
|
3281 | + public static function is_cornerstone_preview() { |
|
3282 | + $result = false; |
|
3283 | + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { |
|
3284 | + $result = true; |
|
3285 | + } |
|
3286 | + |
|
3287 | + return $result; |
|
3288 | + } |
|
3289 | + |
|
3290 | + /** |
|
3291 | + * Tests if the current output is inside a fusion builder preview. |
|
3292 | + * |
|
3293 | + * @return bool |
|
3294 | + *@since 1.1.0 |
|
3295 | + */ |
|
3296 | + public static function is_fusion_preview() { |
|
3297 | + $result = false; |
|
3298 | + if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { |
|
3299 | + $result = true; |
|
3300 | + } |
|
3301 | + |
|
3302 | + return $result; |
|
3303 | + } |
|
3304 | + |
|
3305 | + /** |
|
3306 | + * Tests if the current output is inside a Oxygen builder preview. |
|
3307 | + * |
|
3308 | + * @return bool |
|
3309 | + *@since 1.0.18 |
|
3310 | + */ |
|
3311 | + public static function is_oxygen_preview() { |
|
3312 | + $result = false; |
|
3313 | + if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { |
|
3314 | + $result = true; |
|
3315 | + } |
|
3316 | + |
|
3317 | + return $result; |
|
3318 | + } |
|
3319 | + |
|
3320 | + /** |
|
3321 | + * Check for Kallyas theme Zion builder preview. |
|
3322 | + * |
|
3323 | + * @since 0.2.27 |
|
3324 | + * |
|
3325 | + * @return bool |
|
3326 | + */ |
|
3327 | + public static function is_kallyas_zion_preview() { |
|
3328 | + $result = false; |
|
3329 | + |
|
3330 | + if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) { |
|
3331 | + $result = true; |
|
3332 | + } |
|
3333 | + |
|
3334 | + return $result; |
|
3335 | + } |
|
3336 | + |
|
3337 | + /** |
|
3338 | + * Check for Bricks theme builder preview. |
|
3339 | + * |
|
3340 | + * @since 0.2.27 |
|
3341 | + * |
|
3342 | + * @return bool |
|
3343 | + */ |
|
3344 | + public static function is_bricks_preview() { |
|
3345 | + $result = false; |
|
3346 | + |
|
3347 | + if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) { |
|
3348 | + $result = true; |
|
3349 | + } |
|
3350 | + |
|
3351 | + return $result; |
|
3352 | + } |
|
3353 | + |
|
3354 | + /** |
|
3355 | + * General function to check if we are in a preview situation. |
|
3356 | + * |
|
3357 | + * @since 0.2.27 |
|
3358 | + * |
|
3359 | + * @return bool |
|
3360 | + */ |
|
3361 | + public static function is_preview() { |
|
3362 | + $preview = false; |
|
3363 | + |
|
3364 | + if ( self::is_block_editor() ) { |
|
3365 | + return true; |
|
3366 | + } |
|
3367 | + |
|
3368 | + if( self::is_block_content_call() ) { |
|
3369 | + $preview = true; |
|
3370 | + } elseif ( self::is_divi_preview() ) { |
|
3371 | + $preview = true; |
|
3372 | + } elseif ( self::is_elementor_preview() ) { |
|
3373 | + $preview = true; |
|
3374 | + } elseif ( self::is_beaver_preview() ) { |
|
3375 | + $preview = true; |
|
3376 | + } elseif ( self::is_siteorigin_preview() ) { |
|
3377 | + $preview = true; |
|
3378 | + } elseif ( self::is_cornerstone_preview() ) { |
|
3379 | + $preview = true; |
|
3380 | + } elseif ( self::is_fusion_preview() ) { |
|
3381 | + $preview = true; |
|
3382 | + } elseif ( self::is_oxygen_preview() ) { |
|
3383 | + $preview = true; |
|
3384 | + } elseif( self::is_kallyas_zion_preview() ) { |
|
3385 | + $preview = true; |
|
3386 | + } elseif( self::is_bricks_preview() ) { |
|
3387 | + $preview = true; |
|
3388 | + } |
|
3389 | + |
|
3390 | + return $preview; |
|
3391 | + } |
|
3392 | + } |
|
3393 | + |
|
3394 | + global $ayecode_ui_settings; |
|
3395 | + |
|
3396 | + /** |
|
3397 | + * Run the class if found. |
|
3398 | + */ |
|
3399 | + $ayecode_ui_settings = AyeCode_UI_Settings::instance(); |
|
3400 | 3400 | } |
3401 | 3401 | \ 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.36"; |
|
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.36"; |
|
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.36"; |
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(); |