AUI_PRIMARY_COLOR_ORIGINAL, 'secondary' => AUI_SECONDARY_COLOR_ORIGINAL, 'info' => AUI_INFO_COLOR_ORIGINAL, 'warning' => AUI_WARNING_COLOR_ORIGINAL, 'danger' => AUI_DANGER_COLOR_ORIGINAL, 'success' => AUI_SUCCESS_COLOR_ORIGINAL, 'light' => AUI_LIGHT_COLOR_ORIGINAL, 'dark' => AUI_DARK_COLOR_ORIGINAL, 'white' => AUI_WHITE_COLOR_ORIGINAL, 'purple' => AUI_PURPLE_COLOR_ORIGINAL, 'salmon' => AUI_SALMON_COLOR_ORIGINAL, 'cyan' => AUI_CYAN_COLOR_ORIGINAL, 'gray' => AUI_GRAY_COLOR_ORIGINAL, 'indigo' => AUI_INDIGO_COLOR_ORIGINAL, 'orange' => AUI_ORANGE_COLOR_ORIGINAL, 'black' => AUI_BLACK_COLOR_ORIGINAL, ); } return array( 'primary' => AUI_PRIMARY_COLOR, 'secondary' => AUI_SECONDARY_COLOR, 'info' => AUI_INFO_COLOR, 'warning' => AUI_WARNING_COLOR, 'danger' => AUI_DANGER_COLOR, 'success' => AUI_SUCCESS_COLOR, 'light' => AUI_LIGHT_COLOR, 'dark' => AUI_DARK_COLOR, 'white' => AUI_WHITE_COLOR, 'purple' => AUI_PURPLE_COLOR, 'salmon' => AUI_SALMON_COLOR, 'cyan' => AUI_CYAN_COLOR, 'gray' => AUI_GRAY_COLOR, 'indigo' => AUI_INDIGO_COLOR, 'orange' => AUI_ORANGE_COLOR, 'black' => AUI_BLACK_COLOR, ); } /** * Initiate the settings and add the required action hooks. */ public function init() { // Maybe fix settings if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) { $db_settings = get_option( 'ayecode-ui-settings' ); if ( ! empty( $db_settings ) ) { $db_settings['css_backend'] = 'compatibility'; $db_settings['js_backend'] = 'core-popper'; update_option( 'ayecode-ui-settings', $db_settings ); wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true")); } } $this->constants(); $this->settings = $this->get_settings(); $this->url = $this->get_url(); /** * Maybe load CSS * * We load super early in case there is a theme version that might change the colors */ if ( $this->settings['css'] ) { $priority = $this->is_bs3_compat() ? 100 : 1; add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority ); } if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); } // maybe load JS if ( $this->settings['js'] ) { $priority = $this->is_bs3_compat() ? 100 : 1; add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); } if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); } // Maybe set the HTML font size if ( $this->settings['html_font_size'] ) { add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); } // Maybe show backend style error if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){ add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) ); } } /** * Show admin notice if backend scripts not loaded. */ public function show_admin_style_notice(){ $fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin')); $button = 'Fix Now'; $message = __( 'Style Issue: AyeCode UI is disable or set wrong.')." " .$button; echo '

'.$message.'

'; } /** * Check if we should load the admin scripts or not. * * @return bool */ public function load_admin_scripts(){ $result = true; // check if specifically disabled if(!empty($this->settings['disable_admin'])){ $url_parts = explode("\n",$this->settings['disable_admin']); foreach($url_parts as $part){ if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ return false; // return early, no point checking further } } } return $result; } /** * Add a html font size to the footer. */ public function html_font_size(){ $this->settings = $this->get_settings(); echo ""; } /** * Check if the current admin screen should load scripts. * * @return bool */ public function is_aui_screen(){ // echo '###';exit; $load = false; // check if we should load or not if ( is_admin() ) { // Only enable on set pages $aui_screens = array( 'page', 'post', 'settings_page_ayecode-ui-settings', 'appearance_page_gutenberg-widgets', 'widgets', 'ayecode-ui-settings', 'site-editor' ); $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); $screen = get_current_screen(); // echo '###'.$screen->id; // check if we are on a AUI screen if ( $screen && in_array( $screen->id, $screen_ids ) ) { $load = true; } //load for widget previews in WP 5.8 if( !empty($_REQUEST['legacy-widget-preview'])){ $load = true; } } return apply_filters( 'aui_load_on_admin' , $load ); } /** * Check if the current theme is a block theme. * * @return bool */ public static function is_block_theme() { if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) { return true; } return false; } /** * Adds the styles. */ public function enqueue_style() { if( is_admin() && !$this->is_aui_screen()){ // don't add wp-admin scripts if not requested to }else{ $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; $rtl = is_rtl() ? '-rtl' : ''; if($this->settings[$css_setting]){ $compatibility = $this->settings[$css_setting]=='core' ? false : true; $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; wp_register_style( 'ayecode-ui', $url, array(), $this->version ); wp_enqueue_style( 'ayecode-ui' ); // flatpickr wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->version ); // fix some wp-admin issues if(is_admin()){ $custom_css = " body{ background-color: #f1f1f1; font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; font-size:13px; } a { color: #0073aa; text-decoration: underline; } label { display: initial; margin-bottom: 0; } input, select { margin: 1px; line-height: initial; } th, td, div, h2 { box-sizing: content-box; } p { font-size: 13px; line-height: 1.5; margin: 1em 0; } h1, h2, h3, h4, h5, h6 { display: block; font-weight: 600; } h2,h3 { font-size: 1.3em; margin: 1em 0 } .blocks-widgets-container .bsui *{ box-sizing: border-box; } .bs-tooltip-top .arrow{ margin-left:0px; } .custom-switch input[type=checkbox]{ display:none; } "; // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 $custom_css .= " .edit-post-sidebar input[type=color].components-text-control__input{ padding: 0; } "; wp_add_inline_style( 'ayecode-ui', $custom_css ); } // custom changes wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); } } } /** * Get inline script used if bootstrap enqueued * * If this remains small then its best to use this than to add another JS file. */ public function inline_script() { // Flatpickr calendar locale $flatpickr_locale = self::flatpickr_locale(); ob_start(); ?> tags for code highlighting, so we strip them from the output. */ return str_replace( array( '' ), '', self::minify_js($output) ); } /** * JS to help with conflict issues with other plugins and themes using bootstrap v3. * * @TODO we may need this when other conflicts arrise. * @return mixed */ public static function bs3_compat_js() { ob_start(); ?> ', '' ), '', ob_get_clean()); } /** * Get inline script used if bootstrap file browser enqueued. * * If this remains small then its best to use this than to add another JS file. */ public function inline_script_file_browser(){ ob_start(); ?> tags for code highlighting, so we strip them from the output. */ return str_replace( array( '' ), '', $output ); } /** * Adds the Font Awesome JS. */ public function enqueue_scripts() { if( is_admin() && !$this->is_aui_screen()){ // don't add wp-admin scripts if not requested to }else { $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; // select2 wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); // flatpickr wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version ); // flatpickr wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version ); // Bootstrap file browser wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); $load_inline = false; if ( $this->settings[ $js_setting ] == 'core-popper' ) { // Bootstrap bundle $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; wp_register_script( 'bootstrap-js-bundle', $url, array( 'select2', 'jquery' ), $this->version, $this->is_bs3_compat() ); // if in admin then add to footer for compatibility. is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); $script = $this->inline_script(); wp_add_inline_script( 'bootstrap-js-bundle', $script ); } elseif ( $this->settings[ $js_setting ] == 'popper' ) { $url = $this->url . 'assets/js/popper.min.js'; wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version ); wp_enqueue_script( 'bootstrap-js-popper' ); $load_inline = true; } else { $load_inline = true; } // Load needed inline scripts by faking the loading of a script if the main script is not being loaded if ( $load_inline ) { wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); wp_enqueue_script( 'bootstrap-dummy' ); $script = $this->inline_script(); wp_add_inline_script( 'bootstrap-dummy', $script ); } } } /** * Enqueue flatpickr if called. */ public function enqueue_flatpickr(){ wp_enqueue_style( 'flatpickr' ); wp_enqueue_script( 'flatpickr' ); } /** * Enqueue iconpicker if called. */ public function enqueue_iconpicker(){ wp_enqueue_style( 'iconpicker' ); wp_enqueue_script( 'iconpicker' ); } /** * Get the url path to the current folder. * * @return string */ public function get_url() { $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); $content_url = untrailingslashit( WP_CONTENT_URL ); // Replace http:// to https://. if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { $content_url = str_replace( 'http://', 'https://', $content_url ); } // Check if we are inside a plugin $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); $url = str_replace( $content_dir, $content_url, $file_dir ); return trailingslashit( $url ); } /** * Get the url path to the current folder. * * @return string */ public function get_url_old() { $url = ''; // check if we are inside a plugin $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); // add check in-case user has changed wp-content dir name. $wp_content_folder_name = basename(WP_CONTENT_DIR); $dir_parts = explode("/$wp_content_folder_name/",$file_dir); $url_parts = explode("/$wp_content_folder_name/",plugins_url()); if(!empty($url_parts[0]) && !empty($dir_parts[1])){ $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); } return $url; } /** * Register the database settings with WordPress. */ public function register_settings() { register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); } /** * Add the WordPress settings menu item. * @since 1.0.10 Calling function name direct will fail theme check so we don't. */ public function menu_item() { $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( $this, 'settings_page' ) ); } /** * Get a list of themes and their default JS settings. * * @return array */ public function theme_js_settings(){ return array( 'ayetheme' => 'popper', 'listimia' => 'required', 'listimia_backend' => 'core-popper', //'avada' => 'required', // removed as we now add compatibility ); } /** * Get the current Font Awesome output settings. * * @return array The array of settings. */ public function get_settings() { $db_settings = get_option( 'ayecode-ui-settings' ); $js_default = 'core-popper'; $js_default_backend = $js_default; // maybe set defaults (if no settings set) if(empty($db_settings)){ $active_theme = strtolower( get_template() ); // active parent theme. $theme_js_settings = self::theme_js_settings(); if(isset($theme_js_settings[$active_theme])){ $js_default = $theme_js_settings[$active_theme]; $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; } } $defaults = array( 'css' => 'compatibility', // core, compatibility 'js' => $js_default, // js to load, core-popper, popper 'html_font_size' => '16', // js to load, core-popper, popper 'css_backend' => 'compatibility', // core, compatibility 'js_backend' => $js_default_backend, // js to load, core-popper, popper 'disable_admin' => '', // URL snippets to disable loading on admin ); $settings = wp_parse_args( $db_settings, $defaults ); /** * Filter the Bootstrap settings. * * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ */ return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); } /** * The settings page html output. */ public function settings_page() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.', 'blockstrap' ) ); } ?>

name; ?>

(wp-admin)

version; ?>
add_section('aui_settings', array( 'title' => __('AyeCode UI','aui'), 'priority' => 120, )); // ============================= // = Color Picker = // ============================= $wp_customize->add_setting('aui_options[color_primary]', array( 'default' => AUI_PRIMARY_COLOR, 'sanitize_callback' => 'sanitize_hex_color', 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'refresh', )); $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( 'label' => __('Primary Color','aui'), 'section' => 'aui_settings', 'settings' => 'aui_options[color_primary]', ))); $wp_customize->add_setting('aui_options[color_secondary]', array( 'default' => '#6c757d', 'sanitize_callback' => 'sanitize_hex_color', 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'refresh', )); $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( 'label' => __('Secondary Color','aui'), 'section' => 'aui_settings', 'settings' => 'aui_options[color_secondary]', ))); } /** * CSS to help with conflict issues with other plugins and themes using bootstrap v3. * * @return mixed */ public static function bs3_compat_css() { ob_start(); ?> ', '' ), '', self::minify_css( ob_get_clean() ) ); } public static function custom_css($compatibility = true) { $colors = array(); if ( defined( 'BLOCKSTRAP_VERSION' ) ) { $setting = wp_get_global_settings(); if(!empty($setting['color']['palette']['theme'])){ foreach($setting['color']['palette']['theme'] as $color){ $colors[$color['slug']] = esc_attr($color['color']); } } if(!empty($setting['color']['palette']['custom'])){ foreach($setting['color']['palette']['custom'] as $color){ $colors[$color['slug']] = esc_attr($color['color']); } } }else{ $settings = get_option('aui_options'); $colors = array( 'primary' => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR, 'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR ); } ob_start(); ?> tags for code highlighting, so we strip them from the output. */ return str_replace( array( '' ), '', self::minify_css( ob_get_clean() ) ); } /** * Check if we should add booststrap 3 compatibility changes. * * @return bool */ public static function is_bs3_compat(){ return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); } /** * Build the CSS to overwrite a bootstrap color variable. * * @param $type * @param $color_code * @param $compatibility * * @return string */ public static function css_overwrite($type,$color_code,$compatibility){ $is_var = false; if(!$color_code){return '';} if(!sanitize_hex_color($color_code)){ $color_code = esc_attr($color_code); $is_var = true; // echo '###1'.$color_code;//exit; } if(!$color_code){return '';} if($compatibility===true || $compatibility===1){ $compatibility = '.bsui'; }elseif(!$compatibility){ $compatibility = ''; }else{ $compatibility = esc_attr($compatibility); } // echo '####'.$color_code;exit; $type = sanitize_html_class($type); /** * c = color, b = background color, o = border-color, f = fill */ $selectors = array( ".btn-{$type}" => array( 'b', 'o' ), ".btn-{$type}.disabled" => array( 'b', 'o' ), ".btn-{$type}:disabled" => array( 'b', 'o' ), ".btn-outline-{$type}" => array( 'c', 'o' ), ".btn-outline-{$type}:hover" => array( 'b', 'o' ), ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ), ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ), ".show>.btn-outline-{$type}.dropdown-toggle" => array( 'b', 'o' ), ".badge-{$type}" => array( 'b' ), ".alert-{$type}" => array( 'b', 'o' ), ".bg-{$type}" => array( 'b', 'f' ), ".btn-link.btn-{$type}" => array( 'c' ), ); if ( $type == 'primary' ) { $selectors = $selectors + array( 'a' => array( 'c' ), '.btn-link' => array( 'c' ), '.dropdown-item.active' => array( 'b' ), '.custom-control-input:checked~.custom-control-label::before' => array( 'b', 'o' ), '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array( 'b', 'o' ), '.nav-pills .nav-link.active' => array( 'b' ), '.nav-pills .show>.nav-link' => array( 'b' ), '.page-link' => array( 'c' ), '.page-item.active .page-link' => array( 'b', 'o' ), '.progress-bar' => array( 'b' ), '.list-group-item.active' => array( 'b', 'o' ), '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ), // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... // '.custom-range::-moz-range-thumb' => array('b'), // '.custom-range::-ms-thumb' => array('b'), ); } $important_selectors = array( ".bg-{$type}" => array('b','f'), ".border-{$type}" => array('o'), ".text-{$type}" => array('c'), ); $color = array(); $color_i = array(); $background = array(); $background_i = array(); $border = array(); $border_i = array(); $fill = array(); $fill_i = array(); $output = ''; // build rules into each type foreach($selectors as $selector => $types){ $selector = $compatibility ? $compatibility . " ".$selector : $selector; $types = array_combine($types,$types); if(isset($types['c'])){$color[] = $selector;} if(isset($types['b'])){$background[] = $selector;} if(isset($types['o'])){$border[] = $selector;} if(isset($types['f'])){$fill[] = $selector;} } // build rules into each type foreach($important_selectors as $selector => $types){ $selector = $compatibility ? $compatibility . " ".$selector : $selector; $types = array_combine($types,$types); if(isset($types['c'])){$color_i[] = $selector;} if(isset($types['b'])){$background_i[] = $selector;} if(isset($types['o'])){$border_i[] = $selector;} if(isset($types['f'])){$fill_i[] = $selector;} } // add any color rules if(!empty($color)){ $output .= implode(",",$color) . "{color: $color_code;} "; } if(!empty($color_i)){ $output .= implode(",",$color_i) . "{color: $color_code !important;} "; } // add any background color rules if(!empty($background)){ $output .= implode(",",$background) . "{background-color: $color_code;} "; } if(!empty($background_i)){ $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; } // add any border color rules if(!empty($border)){ $output .= implode(",",$border) . "{border-color: $color_code;} "; } if(!empty($border_i)){ $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; } // add any fill color rules if(!empty($fill)){ $output .= implode(",",$fill) . "{fill: $color_code;} "; } if(!empty($fill_i)){ $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; } $prefix = $compatibility ? $compatibility . " " : ""; $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;' : ''; // darken $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075"); $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10"); $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125"); // lighten $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25"); // opacity see https://css-tricks.com/8-digit-hex-codes/ $op_25 = $color_code."40"; // 25% opacity // button states $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : ''; $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; // $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000; border-color: #000;} "; $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;} "; $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.";} "; $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;} "; if ( $type == 'primary' ) { // dropdown's $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; // input states $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; // page link $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; } return $output; } /** * * @deprecated 0.1.76 Use css_overwrite() * * @param $color_code * @param $compatibility * @param $use_variable * * @return string */ public static function css_primary($color_code,$compatibility, $use_variable = false){ if(!$use_variable){ $color_code = sanitize_hex_color($color_code); if(!$color_code){return '';} } /** * c = color, b = background color, o = border-color, f = fill */ $selectors = array( 'a' => array('c'), '.btn-primary' => array('b','o'), '.btn-primary.disabled' => array('b','o'), '.btn-primary:disabled' => array('b','o'), '.btn-outline-primary' => array('c','o'), '.btn-outline-primary:hover' => array('b','o'), '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), '.btn-link' => array('c'), '.dropdown-item.active' => array('b'), '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... // '.custom-range::-moz-range-thumb' => array('b'), // '.custom-range::-ms-thumb' => array('b'), '.nav-pills .nav-link.active' => array('b'), '.nav-pills .show>.nav-link' => array('b'), '.page-link' => array('c'), '.page-item.active .page-link' => array('b','o'), '.badge-primary' => array('b'), '.alert-primary' => array('b','o'), '.progress-bar' => array('b'), '.list-group-item.active' => array('b','o'), '.bg-primary' => array('b','f'), '.btn-link.btn-primary' => array('c'), '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), ); $important_selectors = array( '.bg-primary' => array('b','f'), '.border-primary' => array('o'), '.text-primary' => array('c'), ); $color = array(); $color_i = array(); $background = array(); $background_i = array(); $border = array(); $border_i = array(); $fill = array(); $fill_i = array(); $output = ''; // build rules into each type foreach($selectors as $selector => $types){ $selector = $compatibility ? ".bsui ".$selector : $selector; $types = array_combine($types,$types); if(isset($types['c'])){$color[] = $selector;} if(isset($types['b'])){$background[] = $selector;} if(isset($types['o'])){$border[] = $selector;} if(isset($types['f'])){$fill[] = $selector;} } // build rules into each type foreach($important_selectors as $selector => $types){ $selector = $compatibility ? ".bsui ".$selector : $selector; $types = array_combine($types,$types); if(isset($types['c'])){$color_i[] = $selector;} if(isset($types['b'])){$background_i[] = $selector;} if(isset($types['o'])){$border_i[] = $selector;} if(isset($types['f'])){$fill_i[] = $selector;} } // add any color rules if(!empty($color)){ $output .= implode(",",$color) . "{color: $color_code;} "; } if(!empty($color_i)){ $output .= implode(",",$color_i) . "{color: $color_code !important;} "; } // add any background color rules if(!empty($background)){ $output .= implode(",",$background) . "{background-color: $color_code;} "; } if(!empty($background_i)){ $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; } // add any border color rules if(!empty($border)){ $output .= implode(",",$border) . "{border-color: $color_code;} "; } if(!empty($border_i)){ $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; } // add any fill color rules if(!empty($fill)){ $output .= implode(",",$fill) . "{fill: $color_code;} "; } if(!empty($fill_i)){ $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; } $prefix = $compatibility ? ".bsui " : ""; // darken $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); // lighten $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); // opacity see https://css-tricks.com/8-digit-hex-codes/ $op_25 = $color_code."40"; // 25% opacity // button states $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; $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;} "; $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.";} "; $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;} "; // dropdown's $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; // input states $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; // page link $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; return $output; } /** * * @deprecated 0.1.76 Use css_overwrite() * * @param $color_code * @param $compatibility * * @return string */ public static function css_secondary($color_code,$compatibility){; $color_code = sanitize_hex_color($color_code); if(!$color_code){return '';} /** * c = color, b = background color, o = border-color, f = fill */ $selectors = array( '.btn-secondary' => array('b','o'), '.btn-secondary.disabled' => array('b','o'), '.btn-secondary:disabled' => array('b','o'), '.btn-outline-secondary' => array('c','o'), '.btn-outline-secondary:hover' => array('b','o'), '.btn-outline-secondary.disabled' => array('c'), '.btn-outline-secondary:disabled' => array('c'), '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), '.btn-outline-secondary.dropdown-toggle' => array('b','o'), '.badge-secondary' => array('b'), '.alert-secondary' => array('b','o'), '.btn-link.btn-secondary' => array('c'), ); $important_selectors = array( '.bg-secondary' => array('b','f'), '.border-secondary' => array('o'), '.text-secondary' => array('c'), ); $color = array(); $color_i = array(); $background = array(); $background_i = array(); $border = array(); $border_i = array(); $fill = array(); $fill_i = array(); $output = ''; // build rules into each type foreach($selectors as $selector => $types){ $selector = $compatibility ? ".bsui ".$selector : $selector; $types = array_combine($types,$types); if(isset($types['c'])){$color[] = $selector;} if(isset($types['b'])){$background[] = $selector;} if(isset($types['o'])){$border[] = $selector;} if(isset($types['f'])){$fill[] = $selector;} } // build rules into each type foreach($important_selectors as $selector => $types){ $selector = $compatibility ? ".bsui ".$selector : $selector; $types = array_combine($types,$types); if(isset($types['c'])){$color_i[] = $selector;} if(isset($types['b'])){$background_i[] = $selector;} if(isset($types['o'])){$border_i[] = $selector;} if(isset($types['f'])){$fill_i[] = $selector;} } // add any color rules if(!empty($color)){ $output .= implode(",",$color) . "{color: $color_code;} "; } if(!empty($color_i)){ $output .= implode(",",$color_i) . "{color: $color_code !important;} "; } // add any background color rules if(!empty($background)){ $output .= implode(",",$background) . "{background-color: $color_code;} "; } if(!empty($background_i)){ $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; } // add any border color rules if(!empty($border)){ $output .= implode(",",$border) . "{border-color: $color_code;} "; } if(!empty($border_i)){ $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; } // add any fill color rules if(!empty($fill)){ $output .= implode(",",$fill) . "{fill: $color_code;} "; } if(!empty($fill_i)){ $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; } $prefix = $compatibility ? ".bsui " : ""; // darken $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); // lighten $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); // opacity see https://css-tricks.com/8-digit-hex-codes/ $op_25 = $color_code."40"; // 25% opacity // button states $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; $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;} "; $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.";} "; $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;} "; return $output; } /** * Increases or decreases the brightness of a color by a percentage of the current brightness. * * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. * * @return string */ public static function css_hex_lighten_darken($hexCode, $adjustPercent) { $hexCode = ltrim($hexCode, '#'); if (strlen($hexCode) == 3) { $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; } $hexCode = array_map('hexdec', str_split($hexCode, 2)); foreach ($hexCode as & $color) { $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; $adjustAmount = ceil($adjustableLimit * $adjustPercent); $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); } return '#' . implode($hexCode); } /** * Check if we should display examples. */ public function maybe_show_examples(){ if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ echo ""; wp_head(); echo ""; echo ""; echo $this->get_examples(); echo ""; exit; } } /** * Get developer examples. * * @return string */ public function get_examples(){ $output = ''; // open form $output .= "
"; // input example $output .= aui()->input(array( 'type' => 'text', 'id' => 'text-example', 'name' => 'text-example', 'placeholder' => 'text placeholder', 'title' => 'Text input example', 'value' => '', 'required' => false, 'help_text' => 'help text', 'label' => 'Text input example label' )); // input example $output .= aui()->input(array( 'type' => 'url', 'id' => 'text-example2', 'name' => 'text-example', 'placeholder' => 'url placeholder', 'title' => 'Text input example', 'value' => '', 'required' => false, 'help_text' => 'help text', 'label' => 'Text input example label' )); // checkbox example $output .= aui()->input(array( 'type' => 'checkbox', 'id' => 'checkbox-example', 'name' => 'checkbox-example', 'placeholder' => 'checkbox-example', 'title' => 'Checkbox example', 'value' => '1', 'checked' => true, 'required' => false, 'help_text' => 'help text', 'label' => 'Checkbox checked' )); // checkbox example $output .= aui()->input(array( 'type' => 'checkbox', 'id' => 'checkbox-example2', 'name' => 'checkbox-example2', 'placeholder' => 'checkbox-example', 'title' => 'Checkbox example', 'value' => '1', 'checked' => false, 'required' => false, 'help_text' => 'help text', 'label' => 'Checkbox un-checked' )); // switch example $output .= aui()->input(array( 'type' => 'checkbox', 'id' => 'switch-example', 'name' => 'switch-example', 'placeholder' => 'checkbox-example', 'title' => 'Switch example', 'value' => '1', 'checked' => true, 'switch' => true, 'required' => false, 'help_text' => 'help text', 'label' => 'Switch on' )); // switch example $output .= aui()->input(array( 'type' => 'checkbox', 'id' => 'switch-example2', 'name' => 'switch-example2', 'placeholder' => 'checkbox-example', 'title' => 'Switch example', 'value' => '1', 'checked' => false, 'switch' => true, 'required' => false, 'help_text' => 'help text', 'label' => 'Switch off' )); // close form $output .= "
"; return $output; } /** * Calendar params. * * @since 0.1.44 * * @return array Calendar params. */ public static function calendar_params() { $params = array( 'month_long_1' => __( 'January', 'blockstrap' ), 'month_long_2' => __( 'February', 'blockstrap' ), 'month_long_3' => __( 'March', 'blockstrap' ), 'month_long_4' => __( 'April', 'blockstrap' ), 'month_long_5' => __( 'May', 'blockstrap' ), 'month_long_6' => __( 'June', 'blockstrap' ), 'month_long_7' => __( 'July', 'blockstrap' ), 'month_long_8' => __( 'August', 'blockstrap' ), 'month_long_9' => __( 'September', 'blockstrap' ), 'month_long_10' => __( 'October', 'blockstrap' ), 'month_long_11' => __( 'November', 'blockstrap' ), 'month_long_12' => __( 'December', 'blockstrap' ), 'month_s_1' => _x( 'Jan', 'January abbreviation', 'blockstrap' ), 'month_s_2' => _x( 'Feb', 'February abbreviation', 'blockstrap' ), 'month_s_3' => _x( 'Mar', 'March abbreviation', 'blockstrap' ), 'month_s_4' => _x( 'Apr', 'April abbreviation', 'blockstrap' ), 'month_s_5' => _x( 'May', 'May abbreviation', 'blockstrap' ), 'month_s_6' => _x( 'Jun', 'June abbreviation', 'blockstrap' ), 'month_s_7' => _x( 'Jul', 'July abbreviation', 'blockstrap' ), 'month_s_8' => _x( 'Aug', 'August abbreviation', 'blockstrap' ), 'month_s_9' => _x( 'Sep', 'September abbreviation', 'blockstrap' ), 'month_s_10' => _x( 'Oct', 'October abbreviation', 'blockstrap' ), 'month_s_11' => _x( 'Nov', 'November abbreviation', 'blockstrap' ), 'month_s_12' => _x( 'Dec', 'December abbreviation', 'blockstrap' ), 'day_s1_1' => _x( 'S', 'Sunday initial', 'blockstrap' ), 'day_s1_2' => _x( 'M', 'Monday initial', 'blockstrap' ), 'day_s1_3' => _x( 'T', 'Tuesday initial', 'blockstrap' ), 'day_s1_4' => _x( 'W', 'Wednesday initial', 'blockstrap' ), 'day_s1_5' => _x( 'T', 'Friday initial', 'blockstrap' ), 'day_s1_6' => _x( 'F', 'Thursday initial', 'blockstrap' ), 'day_s1_7' => _x( 'S', 'Saturday initial', 'blockstrap' ), 'day_s2_1' => __( 'Su', 'blockstrap' ), 'day_s2_2' => __( 'Mo', 'blockstrap' ), 'day_s2_3' => __( 'Tu', 'blockstrap' ), 'day_s2_4' => __( 'We', 'blockstrap' ), 'day_s2_5' => __( 'Th', 'blockstrap' ), 'day_s2_6' => __( 'Fr', 'blockstrap' ), 'day_s2_7' => __( 'Sa', 'blockstrap' ), 'day_s3_1' => __( 'Sun', 'blockstrap' ), 'day_s3_2' => __( 'Mon', 'blockstrap' ), 'day_s3_3' => __( 'Tue', 'blockstrap' ), 'day_s3_4' => __( 'Wed', 'blockstrap' ), 'day_s3_5' => __( 'Thu', 'blockstrap' ), 'day_s3_6' => __( 'Fri', 'blockstrap' ), 'day_s3_7' => __( 'Sat', 'blockstrap' ), 'day_s5_1' => __( 'Sunday', 'blockstrap' ), 'day_s5_2' => __( 'Monday', 'blockstrap' ), 'day_s5_3' => __( 'Tuesday', 'blockstrap' ), 'day_s5_4' => __( 'Wednesday', 'blockstrap' ), 'day_s5_5' => __( 'Thursday', 'blockstrap' ), 'day_s5_6' => __( 'Friday', 'blockstrap' ), 'day_s5_7' => __( 'Saturday', 'blockstrap' ), 'am_lower' => __( 'am', 'blockstrap' ), 'pm_lower' => __( 'pm', 'blockstrap' ), 'am_upper' => __( 'AM', 'blockstrap' ), 'pm_upper' => __( 'PM', 'blockstrap' ), 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), 'time_24hr' => false, 'year' => __( 'Year', 'blockstrap' ), 'hour' => __( 'Hour', 'blockstrap' ), 'minute' => __( 'Minute', 'blockstrap' ), 'weekAbbreviation' => __( 'Wk', 'blockstrap' ), 'rangeSeparator' => __( ' to ', 'blockstrap' ), 'scrollTitle' => __( 'Scroll to increment', 'blockstrap' ), 'toggleTitle' => __( 'Click to toggle', 'blockstrap' ) ); return apply_filters( 'ayecode_ui_calendar_params', $params ); } /** * Flatpickr calendar localize. * * @since 0.1.44 * * @return string Calendar locale. */ public static function flatpickr_locale() { $params = self::calendar_params(); if ( is_string( $params ) ) { $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); } else { foreach ( (array) $params as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); } } $day_s3 = array(); $day_s5 = array(); for ( $i = 1; $i <= 7; $i ++ ) { $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); } $month_s = array(); $month_long = array(); for ( $i = 1; $i <= 12; $i ++ ) { $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); } ob_start(); if ( 0 ) { ?> esc_attr__( 'Select an option…', 'blockstrap' ), 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'blockstrap' ), 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'blockstrap' ), 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'blockstrap' ), 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'blockstrap' ), 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'blockstrap' ), 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'blockstrap' ), 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'blockstrap' ), 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'blockstrap' ), 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'blockstrap' ), 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'blockstrap' ) ); return apply_filters( 'ayecode_ui_select2_params', $params ); } /** * Select2 JS localize. * * @since 0.1.44 * * @return string Select2 JS locale. */ public static function select2_locale() { $params = self::select2_params(); foreach ( (array) $params as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); } $locale = json_encode( $params ); return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); } /** * Time ago JS localize. * * @since 0.1.47 * * @return string Time ago JS locale. */ public static function timeago_locale() { $params = array( 'prefix_ago' => '', 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'blockstrap' ), 'prefix_after' => _x( 'after', 'time ago', 'blockstrap' ) . ' ', 'suffix_after' => '', 'seconds' => _x( 'less than a minute', 'time ago', 'blockstrap' ), 'minute' => _x( 'about a minute', 'time ago', 'blockstrap' ), 'minutes' => _x( '%d minutes', 'time ago', 'blockstrap' ), 'hour' => _x( 'about an hour', 'time ago', 'blockstrap' ), 'hours' => _x( 'about %d hours', 'time ago', 'blockstrap' ), 'day' => _x( 'a day', 'time ago', 'blockstrap' ), 'days' => _x( '%d days', 'time ago', 'blockstrap' ), 'month' => _x( 'about a month', 'time ago', 'blockstrap' ), 'months' => _x( '%d months', 'time ago', 'blockstrap' ), 'year' => _x( 'about a year', 'time ago', 'blockstrap' ), 'years' => _x( '%d years', 'time ago', 'blockstrap' ), ); $params = apply_filters( 'ayecode_ui_timeago_params', $params ); foreach ( (array) $params as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); } $locale = json_encode( $params ); return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); } /** * JavaScript Minifier * * @param $input * * @return mixed */ public static function minify_js($input) { if(trim($input) === "") return $input; return preg_replace( array( // Remove comment(s) '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', // Remove the last semicolon '#;+\}#', // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', // --ibid. From `foo['bar']` to `foo.bar` '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' ), array( '$1', '$1$2', '}', '$1$3', '$1.$3' ), $input); } /** * Minify CSS * * @param $input * * @return mixed */ public static function minify_css($input) { if(trim($input) === "") return $input; return preg_replace( array( // Remove comment(s) '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', // Remove unused white-space(s) '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', // Replace `:0 0 0 0` with `:0` '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', // Replace `background-position:0` with `background-position:0 0` '#(background-position):0(?=[;\}])#si', // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space '#(?<=[\s:,\-])0+\.(\d+)#s', // Minify string value '#(\/\*(?>.*?\*\/))|(?.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', // Minify HEX color code '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', // Replace `(border|outline):none` with `(border|outline):0` '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', // Remove empty selector(s) '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' ), array( '$1', '$1$2$3$4$5$6$7', '$1', ':0', '$1:0 0', '.$1', '$1$3', '$1$2$4$5', '$1$2$3', '$1:0', '$1$2' ), $input); } /** * Get the conditional fields JavaScript. * * @return mixed */ public function conditional_fields_js() { ob_start(); ?> ', '' ), '', self::minify_js( $output ) ); } } /** * Run the class if found. */ AyeCode_UI_Settings::instance(); }