<?php
/*
    VC basic extensions
    integrated in core theme
*/
namespace vc;

if( ! defined( 'ABSPATH' ) ) exit;

new shortcode;
class shortcode {

    /*
        General constructor
    */
    public function __construct() {
        // return if in backend
        if (is_admin()) return;

        // multimedia
        add_shortcode( 'vc_multimedia', array($this, 'multimedia_sc') );
        // empty space
        add_shortcode( 'vc_blank_space', array($this, 'blank_space_sc') );
        // headlines
        add_shortcode( 'vc_headlines', array($this, 'headlines_sc') );
        // buttons
        add_shortcode( 'vc_cbutton', array($this, 'cbutton_sc') );
        add_shortcode( 'vc_cbutton_anchor', array($this, 'cbutton_anchor_sc') );
        // icons
        add_shortcode( 'vc_icons', array($this, 'icons_sc') );
        // social media
        add_shortcode( 'vc_smshare', array($this, 'smshare_sc') );
        add_shortcode( 'vc_smchannels', array($this, 'smchannels_sc') );
        // new search
        add_shortcode( 'vc_search', array($this, 'search_sc') );
        // extra navigation
        add_shortcode( 'vc_footernav', array($this, 'extranav_sc') );
        add_shortcode( 'vc_dropdownnav', array($this, 'dropdownnav_sc') );
        // copyright
        add_shortcode( 'vc_copyright', array($this, 'copyright_sc') );
        // content_box
        add_shortcode( 'vc_content_box', array($this, 'content_box_sc') );
        // styled lists
        add_shortcode( 'vc_list', array($this, 'list_sc') );
        add_shortcode( 'vc_list_item', array($this, 'list_item_sc') );
        // conditional content
        add_shortcode( 'vc_cond_content', array($this, 'cond_content_sc') );
        add_shortcode( 'vc_cond_content_item', array($this, 'cond_content_item_sc') );
        // counter
        add_shortcode( 'vc_counter', array($this, 'counter_sc') );
        
        // render form message if greyd.forms not active
        if (!helper::is_active_plugin('greyd_tp_forms/init.php')) {
            add_shortcode("vc_form", array($this, "form_message_sc"));
        }
    }
    
    /*
        Render shortcodes
    */
    /* multimedia embed */
    public function multimedia_sc($atts, $content=null) {
        //debug($atts);
        $src   = isset($atts['src']) ? esc_attr($atts['src']) : '';
        $url   = isset($atts['url']) ? $atts['url'] : '';
        $pull  = isset($atts['pull']) ? esc_attr($atts['pull']) : '';
        $pull = str_replace("_", "", $pull);

        if ($src != "" && $url != "") {
            ob_start();
                echo "<div class='$pull clear'>";
                    if ($src == "iframe") {
                        $width      = isset($atts['iframe_width']) ? esc_attr($atts['iframe_width']) : '';
                        $height     = isset($atts['iframe_height']) ? esc_attr($atts['iframe_height']) : '';
                        $frameborder= isset($atts['iframe_frameborder']) ? 1 : 0;
                        echo "<iframe src='$url' width='$width' height='$height' scrolling='no' frameborder='$frameborder'></iframe>";
                    }
                    else {
                        $c = apply_filters( 'the_content','[embed]' . $url . '[/embed]');
                        echo $c;
                    }
                echo "</div>";
            $return = ob_get_contents();
            ob_end_clean();
            return $return;
        }
    }
    /* dynamic empty space */
    public function blank_space_sc($atts, $content) {
        // debug($atts);

        $height_default = "100%";
        $base_height    = isset($atts['height']) ? helper::force_units(esc_attr($atts['height']), ['px','em']) : '50px';
        $base_unit      = strval( preg_replace( "/[0-9]/", "", $base_height ) );
        $base_integer   = intval( preg_replace( "/[^0-9]/", "", $base_height ) );

        $sizes = array(
            'sm' => '25%',
            'md' => '50%',
            'lg' => '75%',
            'xl' => '100%'
        );
        foreach ( $sizes as $size => $default ) {

            $height = isset( $atts['height_'.$size] ) ?  esc_attr( $atts['height_'.$size] ) : $default;
            if ( empty($height) ) {
                $height = $height_default;
            }
            else {
                $height = helper::force_units($height, ['%','em'], "%");
                $height_default = $height;
            }
            // if this is a percent value, we want to scale the base height
            if ( strpos($height, '%') > -1 ) {
                $height_int = intval( preg_replace( "/[^0-9]/", "", $height ) );
                $height = ( ($height_int / 100) * $base_integer ).$base_unit;
            }
            
            $sizes[$size] = $height;
        }
        
        $css = isset($atts['css']) ? vc_shortcode_custom_css_class($atts['css']) : '';

        ob_start();

        echo "<div class='vc_blank_space ".$css."'>";
        foreach ( $sizes as $size => $height ) {
            echo "<div class='vc_blank_space_inner_$size' style='height:".$height."'></div>";
        }
        echo "</div>";
            
		$return = ob_get_contents();
		ob_end_clean();
		return $return;
    }
    /* headlines */
    public function headlines_sc($atts, $content) {
        // debug($atts);
        
        $id      = "headline_".uniqid();
        $title   = isset($atts['title']) ? nl2br(str_replace(array('<br />','<br>'), '', $atts['title'])) : '';
        $title   = str_replace(array("``", "''"), '"', $title);
        $h       = isset($atts['h']) ? esc_attr($atts['h']) : '';
        $h_tag   = (isset($atts['h_tag']) && $atts['h_tag'] != "") ? esc_attr($atts['h_tag']) : (($h == '') ? 'p' : $h);
        $color   = helper::get_color($atts, '', '', false);
        $color   = helper::process_color($color);
        $versal  = isset($atts['versal']) ? esc_attr($atts['versal']) : null;
        $width   = isset($atts['max_width']) ? esc_attr($atts['max_width']) : null;
        $font    = isset($atts['font_size']) ? esc_attr($atts['font_size']) : null;
        $weight  = isset($atts['font_weight']) ? esc_attr($atts['font_weight']) : null;
        $align   = isset($atts['align']) ? str_replace("_", "", esc_attr($atts['align'])) : '';
        $padding = isset($atts['padding']) ? esc_attr($atts['padding']) : null;

        $style = '';
        if ($color)   $style .= "color: $color; ";
        if ($versal)  $style .= 'text-transform: uppercase; ';
        if ($width)   $style .= "max-width: $width; ";
        if ($font)    $style .= "font-size: $font; ";
        if ($weight)  $style .= "font-weight: $weight; ";
        if ($padding) $style .= "padding-bottom: $padding; ";
        if ($width && $align == 'center') $style .= "margin-left: auto; margin-right: auto; ";
        
        $css = isset($atts['css']) ? vc_shortcode_custom_css_class($atts['css']) : '';
        
        if ($title != "") {
            ob_start();
                echo "<".$h_tag." id='".$id."' class='vc_headline ".($h == '' ? 'no_h_size' : 'has-fontsize-'.$h)." ".$align." ".$css."' style='".$style."'>".$title."</".$h_tag.">";
                $return = ob_get_contents();
            ob_end_clean();
            return $return;
        }

    }
    /* buttons */
    public function cbutton_sc($atts, $content) {
        //debug($atts);
        //debug($content);
        $mode    = !empty($atts['style']) ? esc_attr($atts['style']) : 'normal';
        
        // leer --> Hinweis
        if (empty($mode)) {
            return helper::make_message(__("Bitte stelle die Art des Buttons ein", 'core'));
        }
        // Content Wrapper
        else if ($mode == "cwb") {
            $atts['icon'] = isset($atts['icon']) ? $atts['icon'] : 'arrow_carrot-down';
            $atts['mode'] = isset($atts['mode']) ? $atts['mode'] : '_button _sec';
            $atts['pull'] = isset($atts['pull']) ? $atts['pull'] : '_right';
        }
        // deprecated scroll up
        else if ($mode == "up") {
            $atts['mode'] = isset($atts['mode']) ? $atts['mode'] : '_button _sec';
            $atts['anchor'] = '_top';
            $atts['icon'] = 'arrow_carrot-up';
            $atts['uri'] = "";
            $atts['click'] = "nav.scrollTop()";
        }
        // scroll button
        else if ($mode == "down") {
            $atts['icon'] = isset($atts['icon']) ? $atts['icon'] : '';
            $anchor = isset($atts['anchor']) ? esc_attr($atts['anchor']) : 'this';
            $atts['uri'] = "";
            if ($anchor == '_top')
                $atts['click'] = "nav.scrollTop()";
            else if ($anchor == '_bottom')
                $atts['click'] = "nav.scrollDown(\".footer\")";
            else
                $atts['uri'] = "#".$anchor;
        }
        // go back
        else if ($mode == "back") {
            $atts['uri'] = "";
            $atts['click'] = 'nav.historyBack()';
        }
        // email
        else if ($mode == "email") {
            $mail    = isset($atts['email']) ? esc_attr($atts['email']) : '';
            $subject = isset($atts['subject']) ? esc_attr($atts['subject']) : '';
            $atts['uri'] = "mailto:". $mail ."?subject=". $subject;
        }
        // download
        else if ($mode == "download") {
            $file    = isset($atts['file']) ? esc_attr($atts['file']) : -1;
            $file_path = wp_get_attachment_url($file);
            $atts['uri'] = $file_path;
            $atts['target'] = true;
        }
        // close popup
        else if ($mode == "popup_close") {
            $atts['uri'] = "";
            $atts['click'] = 'popups.btnClose(this)';
        }
        // open popup
        else if ($mode == "popup_open") {
            $popup_id = isset($atts['popup']) ? esc_attr($atts['popup']) : '';
            $atts['uri'] = "";
            if ( !empty($popup_id) ) {
                $atts['click'] = 'popups.btnToggle("#popup_'.$popup_id.'")';
                \popup::add_popup_id($popup_id);
            }
        }
        // custom trigger
        else if ($mode == "greyd_trigger") {
            $trigger_events = helper::get_trigger_events($atts);
            // set either atts['click'] or atts['hover']
            if ($trigger_events) {
                foreach ( $trigger_events as $event => $action ) {
                    $atts[$event]  = $action;
                }
            }
        }

        $uri     = isset($atts['uri']) ? esc_attr($atts['uri']) : '';
        $content = !$content ? (isset($atts['content']) ? esc_attr($atts['content']) : "") : strip_tags($content);
        $content = nl2br(str_replace(array('<br />','<br>','<br/>'), '', $content));
        $target  = isset($atts['target']) ? '_blank' : '';
        $rel     = '';
        $class   = isset($atts['mode']) ? esc_attr($atts['mode']) : 'link';
        $pull    = isset($atts['pull']) ? esc_attr($atts['pull']) : '';
        $size    = isset($atts['size']) ? esc_attr($atts['size']) : '';
        $width   = isset($atts['min_width']) ? esc_attr($atts['min_width']) : '';
        $versal  = isset($atts['versal']) ? true : false;
        // sanitize classes and styles
        // $aclass = ($class == "_sec" || strpos($class, "_link _sec") !== false) ? "sec" : "";
        // $class = ($class == "_sec") ? "link sec" : $class;
        $class = str_replace("_", "", $class);
        $pull = str_replace("_", "", $pull);
        $size = str_replace("_", "", $size);
        $css = "";
        if ($width != "") {
            if (!strpos($width, "px") && !strpos($width, "%")) $width .= "px";
            $css .= "width: ".$width."; ";
        }
        if ($versal) {
            $css .= "text-transform: uppercase; ";
        }
        // make link
        $link    = isset($atts['linkk']) ? vc_build_link($atts['linkk']) : '';
        if ($link != '') {
            $uri = str_replace("http://http", "http", $link['url']); // Doppelung entfernen...
            $content = $link['title'];
            $target = $link['target'];
            $rel = $link['rel'];
        }
        $icon = isset($atts['icon']) ? esc_attr($atts['icon']) : '';
        
        // don't render if neither content nor icon are set
        if ($content == "" && $icon == "") return;
        
        // add icon to content
        if (!empty($icon)) $content = helper::make_custom_icon($atts, '', $content);

        /**
         * Custom click events
         * for types: back, down, popups, custom_trigger
         */
        $click = "";
        if (isset($atts['click'])) {
            if (strpos($mode, 'popup') === false) {
                $click .= "tabindex='0' role='link' onkeyup='".$atts['click']."' ";
            }
            $click .= "onclick='".$atts['click']."'";
        }
        else if (isset($atts['hover'])) {
            $click .= "onmouseenter='".$atts['hover']."' onmouseleave='".$atts['hover']."'";
        }
        
        // custom button
        if ($class == 'custom2') {
            $class   = "button";
            $css = helper::make_custom_element($atts, 'btn', $css);

            // fix multiple mouseover & mouseout events for custom styled trigger buttons
            if (isset($atts['hover'])) {
                preg_match( "/onmouseenter='([^']+?)('|$)/", $css, $matches );
                if ( isset($matches[1]) ) {
                    $css    = preg_replace( "/onmouseenter='([^']+?)('|$)/", "onmouseenter='$1 ".$atts['hover']."$2", $css);
                    $click  = preg_replace( "/onmouseenter='([^']+?)('|$)/", "", $click);
                }
                preg_match( "/onmouseleave='([^']+?)('|$)/", $css, $matches );
                if ( isset($matches[1]) ) {
                    $css    = preg_replace( "/onmouseleave='([^']+?)('|$)/", "onmouseleave='$1 ".$atts['hover']."$2", $css);
                    $click  = preg_replace( "/onmouseleave='([^']+?)('|$)/", "", $click);
                }
            }
        }

        // vc-css class
        $vccss = isset($atts['css']) ? vc_shortcode_custom_css_class($atts['css']) : '';

        // render
        if ($mode == "cwb") {
            return "<div class='cwp_button $pull $vccss'>
                        <div class='animate_fast $class $size' style='$css' $click>$content</div>
                    </div>";
        }
        else {
            return "<div class='vc_cbutton_wrapper $pull $vccss'>".
                        "<a ".(($uri != "") ? "href='$uri' target='$target' rel='$rel' " : "")."class='animate_fast $class $size' style='$css' $click>$content".
                        "</a>".
                    "</div>";
        }
    }
    public function cbutton_anchor_sc($atts, $content) {
        $id = isset($atts['anchor']) ? esc_attr($atts['anchor']) : '';
        return "<div class='vc_anchor' id='$id'></div>";
    }
    /* icons */
    public static function icons_sc($atts, $content) {
        //debug($atts);
        $icon    = isset($atts['icon']) ? esc_attr($atts['icon']) : null;
        if (empty($icon)) return false;
        $width   = isset($atts['width']) ? esc_attr($atts['width']) : "auto";
        $anim    = isset($atts['anim']) ? esc_attr($atts['anim']) : '';
        $css     = isset($atts['css']) ? vc_shortcode_custom_css_class($atts['css']) : '';
        $pull    = isset($atts['pull']) ? esc_attr($atts['pull']) : '';
        // sanitize
        if (!strpos($width, '%') && !strpos($width, 'px') && $width != 'auto') $width .= "%";
        $pull = str_replace("_", "", $pull);

        // make link
        $link    = isset($atts['link']) ? vc_build_link($atts['link']) : '';
        $lpre = "";
        $lpost = "";
        if ($link != "" && $link['url'] != "") {
            $lpre = "<a href='".$link['url']."' target='".$link['target']."' rel='".$link['rel']."' title='".$link['title']."'>";
            $lpost = "</a>";
        }
        // make onclick
        $hide    = isset($atts['hide']) ? true : false;
        $fade    = isset($atts['fade']) ? esc_attr($atts['fade']) : 'hide';
        $click = "";
        if ($hide) {
            ($fade == "hide") ? $click = "style='cursor:pointer' onclick='$(this).hide()'" : "";
            ($fade == "fade") ? $click = "style='cursor:pointer' onclick='$(this).fadeOut()'" : "";
            ($fade == "slide") ? $click = "style='cursor:pointer' onclick='$(this).slideUp()'" : "";
        }

        if (is_numeric($icon)) {
            $icon_path = wp_get_attachment_url($icon);
        }
        else {
            $icon_path = $icon;
        }
        
        if ( $icon_path ) {
            $icon_id = uniqid();
            $style = "display:inline-block; width:".$width;

            if (strpos($icon_path, '.json') !== false) {
                // make placeholder
                $placeholder = isset($atts['placeholder']) ? esc_attr($atts['placeholder']) : "";
                if ($placeholder != "") {
                    // $placeholder_path = wp_get_attachment_url($placeholder);
                    $placeholder_path = get_image($placeholder, 'medium');
                    $placeholder = "<img class='bm_icon_placeholder' src='".$placeholder_path."' style='$style'>";
                    $style = "display:none; width:".$width;
                }
                // bodymovin json icon with animation
                return "<div class='vc_icons $css $pull' $click>
                            $placeholder
                            $lpre<div class='bm_icon $anim' style='$style' id='$icon_id' data-src='$icon_path' data-anim='$anim'></div>$lpost
                        </div>";
            }
            // everything else svg/png/...
            else {
                // internal Images
                if ( is_numeric($icon) ) {
                    $thumb  = \basics::get_setting(array('site', 'lazyload')) == 'true' ? get_image($icon, 'medium') : $icon_path;
                    $srcset = " data-srcset='".json_encode(get_imageset($icon))."'";
                    $alt    = helper::get_attachment_text($icon);
                    $title  = helper::get_attachment_text($icon, 'title');
                }
                // external Images
                else {
                    $thumb = $icon_path;
                    $srcset = "";
                    $alt = $title = basename($icon_path);
                }
                return "<div class='vc_icons $css $pull' $click>
                            $lpre<img class='vc_icon' id='$icon_id' src='$thumb' alt='$alt' title='$title' style='$style' $srcset>$lpost
                        </div>";
            }
        }
    }
    /* social media */
    public function smshare_sc($atts=[], $content='') {
        $atts['mode'] = "share";
        return self::sm_sc($atts, $content);
    }
    public function smchannels_sc($atts=[], $content='') {
        $atts['mode'] = "visit";
        return self::sm_sc($atts, $content);
    }
    public function sm_sc($atts=[], $content='') {
        //debug($atts);
        $filter  = isset($atts['filter']) ? esc_attr($atts['filter']) : 'grayscale';
        $pull    = isset($atts['pull']) ? esc_attr($atts['pull']) : '';
        $radius  = isset($atts['border_radius']) ? helper::force_units(esc_attr($atts['border_radius'])) : '0px';
        $mode    = isset($atts['mode']) ? esc_attr($atts['mode']) : 'visit';
        $data    = self::get_smdata($atts);
        // sanitize
        $pull = str_replace("_", "", $pull);
        
        ob_start();
            echo "<div class='vc_sm $pull clear'>";
            foreach ($data as $plattform => $options) {
                // skip disabled sm
  			    if (!isset($atts[$plattform])) continue;
                // prepare variables
                $image = get_template_directory_uri()."/assets/icon/sm/".$options['image'];
                $title = $options[$mode]['title'];
                $url = $options[$mode]['url'];
                // output the channel
                echo "<a class='plattform $plattform $filter animate_fast'
                        style='border-radius: $radius; background-image: url(\"$image\")'
                        title='$title'
                        href='$url' target='_blank'></a>";
            }
            echo "</div>";
        $r = ob_get_contents();
        ob_end_clean();
        return $r;  
    }
    public function get_smdata($atts=[]) {
        $title = get_the_title();
        $url = urlencode(get_permalink());
        $share_pre = "Share on";
        $visit_pre = "Visit us on";
        if (get_language() == "de") {
            $share_pre = "Teile auf";
            $visit_pre = "Besuche uns auf";
        }
        return array(
			'facebook' => array(
                'image'  => 'facebook.svg',
				'share'	 => array(
                    'title' => "$share_pre Facebook",
                    'url'   => "https://www.facebook.com/sharer/sharer.php?u=$url",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre Facebook",
                    'url'   => isset($atts['facebook_url']) ? esc_attr($atts['facebook_url']) : "#",
                ),
            ),
			'twitter' => array(
				'image'  => 'twitter.svg',
				'share'	 => array(
                    'title' => "$share_pre Twitter",
                    'url'   => "https://twitter.com/intent/tweet?url=$url",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre Twitter",
                    'url'   => isset($atts['twitter_url']) ? esc_attr($atts['twitter_url']) : "#",
                ),
            ),
			'google' => array(
				'image'  => 'gplus.svg',
				'share'	 => array(
                    'title' => "$share_pre Google+",
                    'url'   => "https://plus.google.com/share?url=$url",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre Google+",
                    'url'   => isset($atts['google_url']) ? esc_attr($atts['google_url']) : "#",
                ),
            ),
			'soundcloud' => array(
				'image'  => 'soundcloud.svg',
				'share'	 => array(
                    'title' => '',
                    'url'   => "",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre SoundCloud",
                    'url'   => isset($atts['soundcloud_url']) ? esc_attr($atts['soundcloud_url']) : "#",
                ),
            ),
			'youtube' => array(
				'image'  => 'youtube.svg',
				'share'	 => array(
                    'title' => '',
                    'url'   => "",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre YouTube",
                    'url'   => isset($atts['youtube_url']) ? esc_attr($atts['youtube_url']) : "#",
                ),
            ),
			'xing' => array(
				'image'  => 'xing.svg',
				'share'	 => array(
                    'title' => "$share_pre XING",
                    'url'   => "https://xing.com/spi/shares/new?url=$url",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre XING",
                    'url'   => isset($atts['xing_url']) ? esc_attr($atts['xing_url']) : "#",
                ),
            ),
			'linkedin' => array(
				'image'  => 'linkedin.svg',
				'share'	 => array(
                    'title' => "$share_pre LinkedIn",
                    'url'   => "https://www.linkedin.com/shareArticle?mini=true&url=$url",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre LinkedIn",
                    'url'   => isset($atts['linkedin_url']) ? esc_attr($atts['linkedin_url']) : "#",
                ),
            ),
			'instagram' => array(
				'image'  => 'instagram.svg',
				'share'	 => array(
                    'title' => '',
                    'url'   => "",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre Instagram",
                    'url'   => isset($atts['instagram_url']) ? esc_attr($atts['instagram_url']) : "#",
                ),
            ),
			'snapchat' => array(
				'image'  => 'snapchat.svg',
				'share'	 => array(
                    'title' => '',
                    'url'   => "",
                ),
				'visit'	 => array(
                    'title' => "$visit_pre Snapchat",
                    'url'   => isset($atts['snapchat_url']) ? esc_attr($atts['snapchat_url']) : "#",
                ),
            ),
			'mail'  => array(
				'image'  => 'mail.svg',
				'share'	 => array(
                    'title' => "$share_pre email",
                    'url'   => "mailto:?subject=$title&body=$url",
                ),
				'visit'	 => array(
                    'title' => 'Send us an email',
                    'url'   => isset($atts['mail_url']) ? "mailto:".esc_attr($atts['mail_url'])."?subject=".esc_attr($atts['mail_txt'])."&body=$url" : "#",
                ),
            ),
        );
    }

    /* new search */
    public function search_sc($atts=[], $content='') {
        
        // Basic atts
        $styles     = $styles_md = $styles_sm = $styles_xs = ["" => ""];
        $form_id    = uniqid('search_');
        $display    = isset($atts['display']) && !empty($atts['display']) ? $atts['display'] : 'normal';
        $filter     = isset($atts['filter']) && !empty($atts['filter']) ? esc_attr($atts['filter']) : 'all';
        $content    = $filter === 'all' ? "" : "<input type='hidden' name='post_type' value='$filter'>";
        $extra_style = "";
        
        //debug($atts);
        
        // 0. SIMPLE SEARCH FIELD
        if ( $display === 'normal' ) {
            $content .= $this->render_search_field('input', $form_id, 'simple_field_', $atts);
        }
        
        // ...more complex layouts
        else {
            
            $fields = isset($atts['fields']) ? vc_param_group_parse_atts($atts['fields']) : '';

            // merge autofill atts with $fields if activated
            if (isset($atts['autofill']) && $atts['autofill'] == 'show') {

                $autofill_atts = array();
                foreach ($atts as $key => $value) {
                    if (strpos($key, 'autofill') === 0) {
                        $autofill_atts[$key] = $value;
                    }
                }
                $autofill_atts['autofill_filter'] = $filter;

                for ($i=0; $i < count($fields); $i++) {
                    if($fields[$i]['type'] == 'input') {
                        $fields[$i]  = array_merge($fields[$i], $autofill_atts);
                    }
                }
            }

            if ( empty($fields) ) return "";
            
            
            $classes    = [$display];
            $gap        = isset($atts['gap']) ? intval( str_replace("px", "", helper::force_units(esc_attr($atts['gap']))) ) / 2 : 5;

            // gap css
            $styles['.search_wrapper'] = "margin-left: -".$gap."px; margin-top: -".$gap."px; margin-right: -".$gap."px;";
            $styles['.search_wrapper > *'] = "margin: ".$gap."px; max-width: calc( 100% - (2 * ".$gap."px) );";
        }
        
        
        // 1. HORIZONTAL LAYOUT
        if ( $display === 'horizontal' ) {
            
            // stretch width & height
            $stretch_w  = isset($atts['stretch']) && strpos($atts['stretch'], 'width') !== false ? true : false;
            $stretch_h  = isset($atts['stretch']) && strpos($atts['stretch'], 'height') !== false ? true : false;
            if ( $stretch_w ) $classes[] = 'stretch_width';
            if ( $stretch_h ) $classes[] = 'stretch_height';
            
            // responsive layout
            $widths     = [];
            $breakpoint = isset($atts['breakpoint']) ? esc_attr($atts['breakpoint']) : 'xs';
            $ignore_radius  = isset($atts['ignore_radius']) && $atts['ignore_radius'] === 'ignore' ? true : false;
            if ($ignore_radius) {
                $ignore_radius = "
                    #$form_id .search_wrapper > :not(:first-child) button,
                    #$form_id .search_wrapper > :not(:first-child) input,
                    #$form_id .search_wrapper > :not(:first-child) .input,
                    #$form_id .search_wrapper > :not(:first-child) .select-selected {
                        border-top-left-radius: 0 !important;
                        border-bottom-left-radius: 0 !important;
                    }
                    #$form_id .search_wrapper > :not(:last-child) button,
                    #$form_id .search_wrapper > :not(:last-child) input,
                    #$form_id .search_wrapper > :not(:last-child) .input,
                    #$form_id .search_wrapper > :not(:last-child) .select-selected {
                        border-top-right-radius: 0 !important;
                        border-bottom-right-radius: 0 !important;
                    }";
            }
            if ( $breakpoint !== 'none' ) {
                $gap_mobile = isset($atts['gap_mobile']) ? intval( str_replace("px", "", helper::force_units(esc_attr($atts['gap_mobile']))) ) / 2 : 3;
                if ( $breakpoint === 'md' ) {
                    $styles_md['.search_wrapper'] = "flex-direction: column; align-items: flex-start; margin-left: -".$gap_mobile."px; margin-top: -".$gap_mobile."px; margin-right: -".$gap_mobile."px;";
                    $styles_md['.search_wrapper > .input-wrapper'] = "margin: ".$gap_mobile."px; width: 100% !important;";
                    if ($ignore_radius) $ignore_radius = "@media (min-width: var(grid_lg)) { $ignore_radius }";
                }
                else if ( $breakpoint === 'sm' ) {
                    $styles_sm['.search_wrapper'] = "flex-direction: column; align-items: flex-start; margin-left: -".$gap_mobile."px; margin-top: -".$gap_mobile."px; margin-right: -".$gap_mobile."px;";
                    $styles_sm['.search_wrapper > .input-wrapper'] = "margin: ".$gap_mobile."px; width: 100% !important;";
                    if ($ignore_radius) $ignore_radius = "@media (min-width: var(grid_md)) { $ignore_radius }";
                }
                else if ( $breakpoint === 'xs' ) {
                    $styles_xs['.search_wrapper'] = "flex-direction: column; align-items: flex-start; margin-left: -".$gap_mobile."px; margin-top: -".$gap_mobile."px; margin-right: -".$gap_mobile."px;";
                    $styles_xs['.search_wrapper > .input-wrapper'] = "margin: ".$gap_mobile."px; width: 100% !important;";
                    if ($ignore_radius) $ignore_radius = "@media (min-width: var(grid_sm)) { $ignore_radius }";
                }
            }
            if ($ignore_radius) $extra_style .= $ignore_radius;
            
            //render
            $content .= "<div class='search_wrapper ".implode( " ", $classes )."'>";
            
            foreach( (array) $fields as $i => $field ) {
                $type = isset($field['type']) ? str_replace("_", "", $field['type']) : "input";
                
                // log width
                if ( $stretch_w && isset($field[$type.'_width']) ){
                    $widths[$i] = helper::force_units( $field[$type.'_width'] , ['px','%'], '%');
                    unset($field[$type.'_width']);
                }
                
                // get filter
                if ( $type === 'filter' )
                    $field['filter'] = isset($field['filter_type_'.$filter]) ? esc_attr($field['filter_type_'.$filter]) : "";
                
                $content .= $this->render_search_field($type, $form_id, $type, $field);
            }
            
            $content .= "</div>";
            
            // calculate widths
            if ( $stretch_w && count($widths) > 0 ) {
                $width_so_far = " - ".implode(" - ", $widths);
                for ($i = 0; $i < count($fields); $i++) {
                    $width = isset($widths[$i]) ? $widths[$i] : "calc( (100%$width_so_far) / ".(count($fields) - count($widths))." )";
                    $styles[".search_wrapper > :nth-child(".($i+1).")"] = "width: $width;";
                }
            }
        }
        
        // 2. VERTICAL LAYOUT
        else if ( $display === 'vertical' ) {
            
            // render
            $content .= "<div class='search_wrapper ".implode( " ", $classes )."'>";
            
            foreach( (array) $fields as $i => $field ) {
                $type = isset($field['type']) ? str_replace("_", "", $field['type']) : "input";
                
                if ( $type === 'filter' ) $field['filter'] = isset($field['filter_type_'.$filter]) ? esc_attr($field['filter_type_'.$filter]) : "";
                
                $content .= $this->render_search_field($type, $form_id, $type, $field);
            }
            
            $content .= "</div>";
        }
        
        // 3. CUSTOM LAYOUT
        else if ( $display === 'custom' ) {
            
            // stretch width & height
            $stretch_w  = isset($atts['stretch']) && strpos($atts['stretch'], 'width') !== false ? true : false;
            $stretch_h  = isset($atts['stretch']) && strpos($atts['stretch'], 'height') !== false ? true : false;
            if ( $stretch_w ) $classes[] = 'stretch_width';
            if ( $stretch_h ) $classes[] = 'stretch_height';
            
            // responsive layout
            $breakpoint = isset($atts['breakpoint']) ? esc_attr($atts['breakpoint']) : 'xs';
            if ( $breakpoint !== 'none' ) {
                $gap_mobile = isset($atts['gap_mobile']) ? intval( str_replace("px", "", helper::force_units(esc_attr($atts['gap_mobile']))) ) / 2 : 3;
                if ( $breakpoint === 'md' ) {
                    $styles_md['.search_wrapper'] = "flex-direction: column; align-items: flex-start; margin-left: -".$gap_mobile."px; margin-top: -".$gap_mobile."px; margin-right: -".$gap_mobile."px;";
                    $styles_md['.search_wrapper > .input-wrapper'] = "margin: ".$gap_mobile."px; width: 100% !important;";
                }
                else if ( $breakpoint === 'sm' ) {
                    $styles_sm['.search_wrapper'] = "flex-direction: column; align-items: flex-start; margin-left: -".$gap_mobile."px; margin-top: -".$gap_mobile."px; margin-right: -".$gap_mobile."px;";
                    $styles_sm['.search_wrapper > .input-wrapper'] = "margin: ".$gap_mobile."px; width: 100% !important;";
                }
                else if ( $breakpoint === 'xs' ) {
                    $styles_xs['.search_wrapper'] = "flex-direction: column; align-items: flex-start; margin-left: -".$gap_mobile."px; margin-top: -".$gap_mobile."px; margin-right: -".$gap_mobile."px;";
                    $styles_xs['.search_wrapper > .input-wrapper'] = "margin: ".$gap_mobile."px; width: 100% !important;";
                }
            }
            
            // render
            $content .= "<div class='search_wrapper ".implode( " ", $classes )."'>";
            
            foreach( (array) $fields as $i => $field ) {
                $type = isset($field['type']) ? str_replace("_", "", $field['type']) : "input";
                
                if ( $type === 'filter' ) $field['filter'] = isset($field['filter_type_'.$filter]) ? esc_attr($field['filter_type_'.$filter]) : "";
                
                if ( $type === 'br' )
                    $content .= "</div><div class='search_wrapper ".implode( " ", $classes )."'>";
                else if ( $type === 'space' )
                    $content .= "<div class='flex_space'></div>";
                else
                    $content .= $this->render_search_field($type, $form_id, $type, $field);
            }
            
            $content .= "</div>";
        }
        
        // Render custom CSS
        $style = $extra_style && !empty($extra_style) ? $extra_style : "";
        foreach ( $styles as $selector => $css )
            if ( !empty($css) ) $style .= "#$form_id $selector { $css".( substr(trim($css), -1) !== ";" ? ";" : "" )." } ";
        foreach ( $styles_md as $selector => $css )
            if ( !empty($css) ) $style .= "@media (max-width: var(grid_lg)) { #$form_id $selector { $css".( substr(trim($css), -1) !== ";" ? ";" : "" )." } } ";
        foreach ( $styles_sm as $selector => $css )
            if ( !empty($css) ) $style .= "@media (max-width: var(grid_md)) { #$form_id $selector { $css".( substr(trim($css), -1) !== ";" ? ";" : "" )." } } ";
        foreach ( $styles_xs as $selector => $css )
            if ( !empty($css) ) $style .= "@media (max-width: var(grid_sm)) { #$form_id $selector { $css".( substr(trim($css), -1) !== ";" ? ";" : "" )." } } ";
        \enqueue::add_custom_style($style);
        
        // Render
        return "<form id='".$form_id."' role='search' method='get' class='search_form' action='".home_url( '/' )."'>$content</form>";
    }
    public function render_search_field($type='input', $parent_id='', $pre='', $atts=[]) {
        
        //debug($atts);
        // basic atts
        $content        = "";
        $id             = uniqid($type."_");
        $styles         = ['' => ''];
        $pre            = preg_replace("/_$/", "", $pre);
        $width          = isset($atts[$pre.'_width']) ? helper::force_units( esc_attr($atts[$pre.'_width']), ['px','%'] ) : "";
        $align          = isset($atts[$pre.'_align']) ? esc_attr($atts[$pre.'_align']) : "";
        $class          = isset($atts[$pre.'_style']) ? str_replace( array("_".$type, "_input", "_"), "", esc_attr($atts[$pre.'_style']) ) : "";
        $inline_style   = $class === 'custom' ? helper::make_custom_element($atts, $pre."_") : "";
        $autofill       = "";

        // basic styles
        if ( !empty($align) ) $styles[''] .= "display: flex; justify-content: $align";
        if ( !empty($width) ) $styles['#'.$id] = "width: $width;";
        
        // input field
        if ( $type === 'input' ) {
            
            // vars
            $placeholder    = isset($atts[$pre.'_placeholder']) ? strip_tags($atts[$pre.'_placeholder']) : __("Suche", "core");
            // icon
            $icon           = "";
            $pre           .= '_icon';
            $icon_pos       = isset($atts[$pre.'_position']) ? esc_attr($atts[$pre.'_position']) : "left";
            if ( $icon_pos === "left" || $icon_pos === "right" ) {
                $icon_cls       = isset($atts[$pre]) ? esc_attr($atts[$pre]) : "icon_search";
                $icon_margin    = isset($atts[$pre.'_margin']) ? helper::force_units( esc_attr($atts[$pre.'_margin']), ['px','em'] ) : "10px";
                $icon_size      = isset($atts[$pre.'_size']) ? helper::force_units( esc_attr($atts[$pre.'_size']), '%' ) : "100%";
                $icon_submit    = isset($atts[$pre.'_submit']) && $atts[$pre.'_submit'] === 'submit' ? "onclick='$(this).closest(\"form\").submit();'" : "";

                // add styles
                $styles['#'.$id.' .icon > span'] = "font-size: $icon_size;";
                $styles['#'.$id.' input'] = "padding-$icon_pos: calc( var(--FRMpaddingx) + $icon_margin + ".( intval(str_replace("%","",$icon_size)) / 100 )."em );";

                // icon html
                $icon = "<span class='icon pos_$icon_pos' $icon_submit>
                    <span class='$icon_cls'></span>
                </span>";
            }
            
            // autofill
            if (isset($atts['autofill']) && isset($atts['autofill']) == 'show') {
                $autofill = isset($atts['autofill']) ? $this->make_autofill_dropdown($atts) : '';
            }
            
            // input html
            $content = "<input type='search' name='s' placeholder='$placeholder' value='".get_search_query()."' class='$class' style='$inline_style'>$icon $autofill";
        }
        
        // filter select
        else if ( $type === 'filter' ) {

            // vars
            $filter         = isset($atts['filter']) && !empty($atts['filter']) ? esc_attr($atts['filter']) : '';
            $filter_name    = $filter === "category" ? "category_name" : ( $filter === "post_tag" ? "tag" : $filter );
            $placeholder    = isset($atts[$pre.'_placeholder']) ? esc_attr($atts[$pre.'_placeholder']) : "";
            $multiselect    = isset($atts[$pre.'_multiselect']) && $atts[$pre.'_multiselect'] === 'multiselect' ? true : false;
            $value          = get_query_var($filter_name);
            $value          = $filter === 'post_type' && $value === 'any' ? '' : $value; // post_type defaults to 'any'
            $options        = [];
            
            // build options
            if ( $filter === 'post_type' ) {
                $posttypes = helper::get_all_posttypes();
                foreach ( (array) $posttypes as $posttype )
                    if ( $posttype->slug !== 'attachment' ) $options[$posttype->slug] = $posttype->title;
            }
            else {
                $terms = get_terms( $filter, array( 'hide_empty' => true ) );
                if ( is_array($terms) )
                    foreach ( (array) $terms as $term ) $options[$term->slug] = $term->name;
            }
            
            // set default placeholder
            if ( empty($placeholder) ) {
                if ( $filter === 'post_type' ) {
                    $placeholder = __('Beitragstyp', 'core');
                }
                else if ( $taxonomy = get_taxonomy($filter) ) {
                    if ( $multiselect )
                        $placeholder = $taxonomy->label;
                    else
                        $placeholder = $taxonomy->labels->singular_name;
                }
                else {
                    $placeholder = __('bitte', 'core');
                }
                $placeholder = sprintf( __('%s wählen', 'core'), $placeholder );
            }
            
            // render
            if ( $multiselect ) {
                if ( empty($placeholder) ) {
                    $placeholder = get_taxonomy($filter) ? sprintf( __("%s wählen", "core"), get_taxonomy($filter)->label ) : __('bitte wählen', 'core');
                }
                $args = [
                    'placeholder'   => $placeholder,
                    'class'         => $class,
                    'style'         => $inline_style,
                    'value'         => $value
                ];
                $content = helper::render_multiselect( $filter_name, $options, $args );
            }
            else {
                $classes[]  = 'custom-select';
                $value      = trim( explode(",", $value)[0] ); // make single value
                
                $content = "<div class='custom-select $class' style='$inline_style'>
                    <select name='$filter_name'>
                        <option value=''>$placeholder</option>";
                        foreach( $options as $val => $label ) {
                            $content .= "<option value='$val' ".( $val === $value ? "selected='selected'" : "" ).">$label</option>";
                        }
                    $content .= "</select>
                </div>";
            }
            
        }
        
        // button
        else if ( $type === 'button' ) {
            
            // vars
            $text   = isset($atts[$pre.'_text']) ? esc_attr($atts[$pre.'_text']) : __("suchen", "core");
            $text   = \vc\helper::make_custom_icon($atts, $pre, $text);
            $size   = isset($atts[$pre.'_size']) ? str_replace( "_", "", esc_attr($atts[$pre.'_size']) ) : '';
            
            // html
            $content = "<button type='submit' class='$class $size' style='$inline_style'>$text</button>";
        }
        
        
        // enqueue custom css
        $style = "";
        foreach ( $styles as $selector => $css ) {
            if ( !empty($css) ) $style .= "#".$parent_id." $selector { ".$css.( strpos($css, ";") === false ? ";" : "" )." } ";
        }
        \enqueue::add_custom_style($style);
        
        // return html
        return "<div id='$id' class='input-wrapper'>$content</div>";
    }

    public function make_autofill_dropdown($atts=[]) {

        $max_results         = isset($atts['autofill_max_results']) ? esc_attr($atts['autofill_max_results']) : "5";
        $show_on_click       = isset($atts['autofill_show_on_click']) ? esc_attr($atts['autofill_show_on_click']) : "true";
        $sorting             = isset($atts['autofill_sorting']) ? explode(" ", esc_attr($atts['autofill_sorting'])) : array('relevance', 'DESC');
        $loading_text        = isset($atts['autofill_loading']) ? esc_attr($atts['autofill_loading']) : __('lädt...', 'core'); 
        $noresult_text       = isset($atts['autofill_noresult']) ? esc_attr($atts['autofill_noresult']) : __('keine Ergebnisse gefunden', 'core'); 
        $forward_on_click    = isset($atts['autofill_forward_on_click']) ? esc_attr($atts['autofill_forward_on_click']) : "false";
        // $search_title_only   = isset($atts['autofill_search_title_only']) ? esc_attr($atts['autofill_search_title_only']) : "true";

        $same_style_as_searchfield = !isset($atts['autofill_style']);
    
        $orderby = $sorting[0];
        $order   = strtolower($sorting[1]);

        // if the filter is "all" - we don't need it
        $filter  = isset($atts['autofill_filter']) ? esc_attr($atts['autofill_filter']) : "";
        $filter  = $filter === "all" ? "" : $filter;

        // Styling
        if ($same_style_as_searchfield) {
            $class          = isset($atts['input_style']) ? str_replace( array("_autofill", "_input", "_"), "", esc_attr($atts['input_style']) ) : "";
            $inline_style   = $class === 'custom' ? helper::make_custom_element($atts, "input_") : "";
        } else {
            $class          = isset($atts['autofill_style']) ? str_replace( array("_autofill", "_input", "_"), "", esc_attr($atts['autofill_style']) ) : "";
            $inline_style   = $class === 'custom' ? helper::make_custom_element($atts, "autofill_") : "";
        }

        $data_atts = array(
            "data-filter='".$filter."'",
            "data-max-results='".intval($max_results)."'",
            "data-show-on-click='".$show_on_click."'",
            "data-orderby='".$orderby."'",
            "data-order='".$order."'",
            "data-loading-text='".$loading_text."'",
            "data-noresult-text='".$noresult_text."'",
            "data-forward-on-click='".$forward_on_click."'",
            // "data-search-title-only='".$search_title_only."'"
        );

        $autofill =
        "<div class='custom-select autofill $class' style='$inline_style' ".implode(" ", $data_atts)." >
            <select>";
        $autofill .= "<option value=''></option>";
        $autofill .= "</select></div>";

        return $autofill;
    }

    /* extra navigation */
    public function extranav_sc($atts=[], $content='') {
        global $wp;

        $menu = isset($atts['menu']) ? esc_attr($atts['menu']) : false;
        if(!$menu) return; // helper::make_message("Please configure Menu Items");
        
        $text_size = isset($atts['text_size']) ? esc_attr($atts['text_size']) : 'normal';
        $sze = "";
        // if ($text_size == "normal") $sze .= "font-weight:400; ";
        // if ($text_size == "bold") $sze .= "font-weight:600; ";
        if ($text_size == "small") $sze .= "font-weight:400;font-size:0.85em; ";
        if ($text_size == "smaller") $sze .= "font-weight:400;font-size:0.7em; ";
        if ($text_size == "big") $sze .= "font-weight:400;font-size:1.1em; ";
        if ($text_size == "bigger") $sze .= "font-weight:400;font-size:1.2em; ";
        // if ($text_size == "biggest") $sze .= "font-weight:600;font-size:2.2em; ";

        $menu_class = isset($atts['direction']) ? esc_attr($atts['direction']) : '';
        if (strpos($menu_class, "_row") > -1)
            $menu_class .= isset($atts['justify']) ? " ".esc_attr($atts['justify']) : '';
        else if (strpos($menu_class, "_column") > -1)
            $menu_class .= isset($atts['align']) ? " ".esc_attr($atts['align']) : '';

        $menu_class_lg = isset($atts['direction_lg']) ? esc_attr($atts['direction_lg']) : '';
        if (strpos($menu_class_lg, "_row") > -1)
            $menu_class_lg .= isset($atts['justify_lg']) ? " ".esc_attr($atts['justify_lg']) : '';
        else if (strpos($menu_class_lg, "_column") > -1)
            $menu_class_lg .= isset($atts['align_lg']) ? " ".esc_attr($atts['align_lg']) : '';
        $menu_class .= ($menu_class_lg != "") ? " ".$menu_class_lg : '';

        $menu_class_md = isset($atts['direction_md']) ? esc_attr($atts['direction_md']) : '';
        if (strpos($menu_class_md, "_row") > -1)
            $menu_class_md .= isset($atts['justify_md']) ? " ".esc_attr($atts['justify_md']) : '';
        else if (strpos($menu_class_md, "_column") > -1)
            $menu_class_md .= isset($atts['align_md']) ? " ".esc_attr($atts['align_md']) : '';
        $menu_class .= ($menu_class_md != "") ? " ".$menu_class_md : '';

        $menu_class_sm = isset($atts['direction_sm']) ? esc_attr($atts['direction_sm']) : '';
        if (strpos($menu_class_sm, "_row") > -1)
            $menu_class_sm .= isset($atts['justify_sm']) ? " ".esc_attr($atts['justify_sm']) : '';
        else if (strpos($menu_class_sm, "_column") > -1)
            $menu_class_sm .= isset($atts['align_sm']) ? " ".esc_attr($atts['align_sm']) : '';
        $menu_class .= ($menu_class_sm != "") ? " ".$menu_class_sm : '';

        //
        // render
        $css = isset($atts['css']) ? vc_shortcode_custom_css_class($atts['css']) : '';
        ob_start();

        echo "<nav class='menu_wrapper ".$menu_class." ".$css."' style='".$sze."'>";
        if ($menu != 'custom') {
            $theme_location = "";
            $nav_menu = wp_get_nav_menus(array('slug' => $menu));
            if ( count($nav_menu) > 0 ) {
                $nav_menu   = $nav_menu[0];
                $menu_id    = $nav_menu->term_id;

                foreach (get_nav_menu_locations() as $loc_key => $loc_value)
                    if ($loc_key == 'main-menu' && $loc_value == $menu_id) $theme_location = "main-menu";
                
                $args = array(
                    'menu' => $menu_id,
                    /*  don't display a 'wp_page_menu' if menu is empty or doesn't exist
                        source: https://developer.wordpress.org/reference/functions/wp_nav_menu/ */
                    'fallback_cb' => false,
                    /**
                     * Add possibility to filter the menu walker.
                     * 
                     * @filter greyd_menu_render_walker
                     * @since 1.5.5
                     * 
                     * @param object $walker    Instance of a custom walker class.
                     * @param array  $atts      Menu block attributes.
                     */
                    'walker' => apply_filters( 'greyd_menu_render_walker', null, $atts )
                );
                if ( !empty($theme_location) ) $args['theme_location'] = $theme_location;
                wp_nav_menu( $args );
            }
        }
        else {
            $custom_menu = isset($atts['custom_menu']) ? vc_param_group_parse_atts(esc_attr($atts['custom_menu'])) : '';
            $menu_list = '<div class="menu-custom-container"><ul class="menu">';
            $count = 0;
            $submenu = false;
            foreach ($custom_menu as $menu_item ) {
                $menu_link = vc_build_link($menu_item['menu_link']);
                $title = $menu_link['title'];
                $link = $menu_link['url'] != "" ? 'href="'.$menu_link['url'].'"' : '';
                $class = $menu_link['url'] == home_url($wp->request.'/') ? 'current-menu-item' : 'menu-item';
                $target = $menu_link['target'] != "" ? 'target="'.$menu_link['target'].'"' : '';
                $rel = $menu_link['rel'] != "" ? 'rel="'.$menu_link['rel'].'"' : '';
                if ($menu_item['menu_link_level'] == 1) {
                    // $parent_id = $menu_item->ID;
                    $menu_list .= '<li class="'.$class.'">';
                    $menu_list .= '<a '.$link.' '.$target.' '.$rel.'>'.$title.'</a>';
                }
                if ($menu_item['menu_link_level'] == 2) {
                    if (!$submenu) {
                        $submenu = true;
                        $menu_list .= '<ul class="sub-menu">';
                    }
                    $menu_list .= '<li class="'.$class.'">';
                    $menu_list .= '<a '.$link.' '.$target.' '.$rel.'>'.$title.'</a>';
                    $menu_list .= '</li>';
                    if (isset($custom_menu[$count + 1]) && $custom_menu[$count + 1]['menu_link_level'] == 1 && $submenu ) {
                        $menu_list .= '</ul>';
                        $submenu = false;
                    }
                }
                if (isset($custom_menu[$count + 1]) && $custom_menu[$count + 1]['menu_link_level'] == 1) { 
                    $menu_list .= '</li>';      
                    $submenu = false;
                }
                $count++;
            }
            $menu_list .= '</ul></div>';
            echo $menu_list;
        }
        echo "</nav>";

        $r = ob_get_contents();
        ob_end_clean();
        return $r;
    }
    public function dropdownnav_sc($atts=[], $content='') {
        $menu = isset($atts['menu']) ? esc_attr($atts['menu']) : false;
        if(!$menu) return; // helper::make_message("Please configure Menu Items");
        
        //
        // get layout and style
        $layout = isset($atts['layout']) ? esc_attr($atts['layout']) : "horizontal";
        $layout = ($layout == 'horizontal') ? 'row' : 'column';
        $responsive = isset($atts['responsive']) ? true : false;
        if (!$responsive) {
            if ($layout == 'row') $layout .= '-fixed';
        }

        $fields_padding = isset($atts['fields_padding']) ? esc_attr($atts['fields_padding']) : 10;
        if (strpos($fields_padding, 'px') == false) $fields_padding .= "px";
        $half = str_replace('px', '', $fields_padding) / 2;
        $style_wrap = "margin-left:-".$half."px;margin-right:-".$half."px; ";
        $style_dropdown = "margin-left:".$half."px;margin-right:".$half."px; ";
        $style_dropdown_input = "margin-bottom:".$fields_padding."; ";
        $style_submit = "margin-left:".$half."px;margin-right:".$half."px; ";
        $style_submit_input = "margin-bottom:".$fields_padding."; ";

        //
        // get dropdown layout style
        $dropdown_width = isset($atts['dropdown_width']) ? helper::force_units(esc_attr($atts['dropdown_width']), ['%','px'], '%') : '100%';
        $dropdown_align = isset($atts['dropdown_align']) ? esc_attr($atts['dropdown_align']) : 'start';
        if ($dropdown_align != "center") $dropdown_align = "flex-".$dropdown_align;
        $style_dropdown .= "width:calc(".$dropdown_width." - ".$fields_padding.");align-self:".$dropdown_align."; ";
        if (strpos($dropdown_width, 'px') !== false) $style_dropdown .= "flex-shrink:0; ";
        $dropdown_style = isset($atts['dropdown_style']) ? esc_attr($atts['dropdown_style']) : '_dropdown';
        $dropdown_style = str_replace(array("_dropdown", "_"), "", $dropdown_style);
        if ($dropdown_style == 'custom') $style_dropdown_input = helper::make_custom_element($atts, 'dropdown', $style_dropdown_input);
        // make dropdown
        $dropdown_id = "pages_".substr(md5(microtime()),0,10);
        $dropdown_holder = isset($atts['dropdown_holder']) ? esc_attr($atts['dropdown_holder']) : '';
        $dropdown_input = "<div class='custom-select ".$dropdown_style."'><select style='".$style_dropdown_input."' name='".$dropdown_id."' id='".$dropdown_id."'>
                                <option value=''>".$dropdown_holder."</option>";
        if ($menu != 'custom') {
            $menu_items = wp_get_nav_menu_items($menu);
            if ( is_array($menu_items) ) {
                foreach ($menu_items as $menu_item) {
                    // debug($menu_item);
                    $title = $menu_item->title;
                    $link = $menu_item->url;
                    $anchor = get_post_meta( $menu_item->ID, 'menu-item-anchor', true );
                    if (!empty($anchor)) $link .= "#".$anchor;
                    if (!$menu_item->menu_item_parent) {
                        $dropdown_input .= '<option value="'.$link.'">';
                        $dropdown_input .=      '&nbsp;&nbsp;&nbsp;'.$title;
                        $dropdown_input .= '</option>';
                    }
                    else {
                        $dropdown_input .= '<option value="'.$link.'">';
                        $dropdown_input .=      '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$title;
                        $dropdown_input .= '</option>';
                    }
                }
            }
        }
        else {
            $custom_menu = isset($atts['custom_menu']) ? vc_param_group_parse_atts(esc_attr($atts['custom_menu'])) : '';
            // debug($custom_menu);
            foreach ($custom_menu as $menu_item) {
                $menu_link = vc_build_link($menu_item['menu_link']);
                $title = $menu_link['title'];
                $link = $menu_link['url'];
                $target = $menu_link['target'];
                $rel = $menu_link['rel'];
                if ($menu_item['menu_link_level'] == 1) {
                    $dropdown_input .= '<option value="'.$link.'">';
                    $dropdown_input .=      '&nbsp;&nbsp;&nbsp;'.$title;
                    $dropdown_input .= '</option>';
                }
                else {
                    $dropdown_input .= '<option value="'.$link.'">';
                    $dropdown_input .=      '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$title;
                    $dropdown_input .= '</option>';
                }
            }
        }
        $dropdown_input .=  "</select></div>";

        //
        // get button layout
        $btn_width = isset($atts['btn_width']) ? helper::force_units(esc_attr($atts['btn_width']), ['%', 'px'], '%') : '100%';
        $btn_align = isset($atts['btn_align']) ? esc_attr($atts['btn_align']) : 'start';
        if ($btn_align != "center") $btn_align = "flex-".$btn_align;
        $style_submit .= "width:calc(".$btn_width." - ".$fields_padding.");align-self:".$btn_align."; ";
        if (strpos($btn_width, 'px') !== false) $style_submit .= "flex-shrink:0; ";
        if ($btn_align == "flex-start") $style_submit .= "text-align:left; ";
        if ($btn_align == "center") $style_submit .= "text-align:center; ";
        if ($btn_align == "flex-end") $style_submit .= "text-align:right; ";
        // get button style
        $btn_style = isset($atts['btn_style']) ? esc_attr($atts['btn_style']) : '_button';
        $btn_style = str_replace(array("_link", "_"), "", $btn_style);
        if ($btn_style == 'custom') $style_submit_input = helper::make_custom_element($atts, 'btn', $style_submit_input);
        // make link content & icon
        $btn_text = isset($atts['btn']) ? nl2br(str_replace(array('<br />','<br>'), '', $atts['btn'])) : '';
        $btn_content = helper::make_custom_icon($atts, 'btn_', $btn_text);

        // make submit button
        $form_id = "form".substr(md5(microtime()),0,10);
        $submit_id = "form".substr(md5(microtime()),0,10);
        $submit_input = "<a id='".$submit_id."' class='submit ".$btn_style."' style='".$style_submit_input."'>".$btn_content."</a>";

        //
        // render
        ob_start();

        echo "<form id='".$form_id."'>
                <div class='wps-form'>
                    <div class='wps-form-".$layout."' style='".$style_wrap."'>";
        echo            "<div class='wps-form-column' style='".$style_dropdown."'>
                            ".$dropdown_input."
                        </div>";
        echo            "<div class='wps-form-column' style='".$style_submit."'>
                            ".$submit_input."
                        </div>
                    </div>
                </div>
            </form>";
        // render js form change
        echo "<script type='text/javascript'>
            /* <![CDATA[ */
            (function() {
                var submit = document.getElementById('".$submit_id."');
                var dropdown = document.getElementById('".$dropdown_id."');
                function onClick() {
                    if ( dropdown.options[ dropdown.selectedIndex ].value != '' ) {
                        location.href = dropdown.options[ dropdown.selectedIndex ].value;
                    }
                }
                submit.onclick = onClick;
            })();
            /* ]]> */
            </script>";

        $r = ob_get_contents();
        ob_end_clean();
        return $r;
    }

    /* copyright */
    public static function copyright_sc($atts=[], $content='') {        
        $home = esc_url(home_url('/'));
        $name = esc_html(get_bloginfo('name'));

        $tag_open = "<a href='$home' title='$name' rel='home'>";
        $tag_close = "</a>";
        if (isset($atts['no_link'])) {
            $tag_open = "<span style='white-space:pre'>";
            $tag_close = "</span>";
        }

        $text = isset($atts['text']) ? $atts['text'] : "_c_ _year_ _name_";
        $text = str_replace("_c_", "©", $text);
        $text = str_replace("_year_", esc_html(date_i18n('Y')), $text);
        $text = str_replace("_name_", $name, $text);
        if ($text != "") $text = $tag_open.$text.$tag_close;

        $img = isset($atts['img']) ? $atts['img'] : '';
        if ($img != "") {
            $img_src = get_image($img, 'full');
            $img_thumb = (\basics::get_setting(array('site', 'lazyload')) == 'true') ? get_image($img, 'medium') : $img_src;
            $srcset = " data-srcset='".json_encode(get_imageset($img))."'";
            $img = "<img alt='' class='vc_icon' src='".$img_thumb."' $srcset>";
        }
        if ($img != "") $img = $tag_open.$img.$tag_close;

        $layout = isset($atts['layout']) ? esc_attr($atts['layout']) : "";
        $link1 = "";
        $link2 = "";
        if ($layout == "") 
            return helper::make_message("Please configure Copyright layout");
        else if ($layout == 'left') {
            $link1 = "<div style='text-align:left '>
                        $text
                    </div>";
            $link2 = "<div style='text-align:right'>
                        $img
                    </div>";
        }
        else if ($layout == 'right') {
            $link1 = "<div style='text-align:left '>
                        $img
                    </div>";
            $link2 = "<div style='text-align:right'>
                        $text
                    </div>";          
        }
        else if ($layout == 'center') {
            $link1 = "<div style='text-align:center'>
                        $text
                    </div>";
            $link2 = "";           
        }
        else if ($layout == 'center2') {
            $link1 = "<div style='text-align:center'>
                        $img
                    </div>";
            $link2 = "";           
        }

        ob_start();
            echo "<div class='copyright animate_fast'><div class='container animate_fast'>
                    $link1
                    $link2
                </div></div>";
        $r = ob_get_contents();
        ob_end_clean();
        return $r;
    }

    /* content_box */
    public function content_box_sc($atts=[], $content='') {
        // debug($atts);
        $pre = 'vc_content_box';
        $id = $pre."_".uniqid();

        $event_type     = isset($atts[$pre.'_event_type']) ? esc_attr($atts[$pre.'_event_type']) : '';
        $link_html_atts = array();

        // trigger
        if ($event_type == "greyd_trigger") {
            $trigger_events = helper::get_trigger_events($atts, $pre."_");
            if ($trigger_events) {
                if (isset($trigger_events['click'])) {
                    $link_html_atts[] = "style='cursor: pointer'";
                    $link_html_atts[] = "onclick='".$trigger_events['click']."'";
                }
                else if (isset($trigger_events['hover'])) {
                    $link_html_atts[] = "style='cursor: pointer'";
                    $link_html_atts[] = "onmouseenter='".$trigger_events['hover']."'";
                    $link_html_atts[] = "onmouseleave='".$trigger_events['hover']."'";
                }
            }
        }

        // popup
        else if ($event_type == "popup_open") {
            $popup_id = isset($atts[$pre.'_popup']) ? esc_attr($atts[$pre.'_popup']) : '';
            if ( !empty($popup_id) ) {
                $link_html_atts[] = "style='cursor: pointer'";
                $link_html_atts[] = "onclick='popups.btnToggle(\"#popup_".$popup_id."\");'";
                \popup::add_popup_id($popup_id);
            }
        }

        // link
        else {
            $link = isset($atts[$pre.'_link']) ? vc_build_link($atts[$pre.'_link']) : '';
            if (!empty($link) && is_array($link) && !empty($link['url'])) {
                $target = empty($link['target']) ? "_self" : $link['target'];

                $link_html_atts[] = "style='cursor: pointer'";
                $link_html_atts[] = "onclick='window.open(\"".$link['url']."\", \"".$target."\");'";
                $link_html_atts[] = "title='".$link['title']."'";
            }
        }

        // transition
        $transition_duration = isset($atts[$pre.'_transition_duration']) ? helper::force_units(esc_attr($atts[$pre.'_transition_duration']), 's') : '0.3s';
        $transition_effect = isset($atts[$pre.'_transition_effect']) ? esc_attr($atts[$pre.'_transition_effect']) : 'ease';
        $transition = "transition: color ".$transition_duration." ".$transition_effect."; will-change: color; ";

        // extra class
        $extra_class = isset($atts[$pre.'_class']) ? esc_attr($atts[$pre.'_class']) : '';

        // trigger events
        $trigger_events = \vc\helper::make_trigger_action($atts);

        // minheight responsive
        $height_default = "";
        $height_sm = isset($atts[$pre.'_height_sm']) ? esc_attr(str_replace("px", "", $atts[$pre.'_height_sm'])."px") : '';
        if ($height_sm != "") {
            $height_sm = "min-height: ".$height_sm."; ";
            $height_default = $height_sm;
        }
        $height_md = isset($atts[$pre.'_height_md']) ? esc_attr(str_replace("px", "", $atts[$pre.'_height_md'])."px") : '';
        if ($height_md != "") {
            $height_md = "min-height: ".$height_md."; ";
            $height_default = $height_md;
        }
        else $height_md = $height_default;
        $height_lg = isset($atts[$pre.'_height_lg']) ? esc_attr(str_replace("px", "", $atts[$pre.'_height_lg'])."px") : '';
        if ($height_lg != "") {
            $height_lg = "min-height: ".$height_lg."; ";
            $height_default = $height_lg;
        }
        else $height_lg = $height_default;
        $height_xl = isset($atts[$pre.'_height_xl']) ? esc_attr(str_replace("px", "", $atts[$pre.'_height_xl'])."px") : '';
        if ($height_xl != "") {
            $height_xl = "min-height: ".$height_xl."; ";
        }
        else $height_xl = $height_default;
        
        // margin responsive
        $margin_top_default = "0px"; //"5px";
        $margin_right_default = "0px"; //"10px";

        $margin_top_sm = (isset($atts[$pre.'_margin_top_sm']) && $atts[$pre.'_margin_top_sm'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_margin_top_sm'])."px") : $margin_top_default;
        $margin_right_sm = (isset($atts[$pre.'_margin_right_sm']) && $atts[$pre.'_margin_right_sm'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_margin_right_sm'])."px") : $margin_right_default;
        $margin_sm = "margin: ".$margin_top_sm." ".$margin_right_sm."; ";
        $margin_top_default = $margin_top_sm;
        $margin_right_default = $margin_right_sm;

        $margin_top_md = (isset($atts[$pre.'_margin_top_md']) && $atts[$pre.'_margin_top_md'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_margin_top_md'])."px") : $margin_top_default;
        $margin_right_md = (isset($atts[$pre.'_margin_right_md']) && $atts[$pre.'_margin_right_md'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_margin_right_md'])."px") : $margin_right_default;
        $margin_md = "margin: ".$margin_top_md." ".$margin_right_md."; ";
        $margin_top_default = $margin_top_md;
        $margin_right_default = $margin_right_md;

        $margin_top_lg = (isset($atts[$pre.'_margin_top_lg']) && $atts[$pre.'_margin_top_lg'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_margin_top_lg'])."px") : $margin_top_default;
        $margin_right_lg = (isset($atts[$pre.'_margin_right_lg']) && $atts[$pre.'_margin_right_lg'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_margin_right_lg'])."px") : $margin_right_default;
        $margin_lg = "margin: ".$margin_top_lg." ".$margin_right_lg."; ";
        $margin_top_default = $margin_top_lg;
        $margin_right_default = $margin_right_lg;

        $margin_top_xl = (isset($atts[$pre.'_margin_top_xl']) && $atts[$pre.'_margin_top_xl'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_margin_top_xl'])."px") : $margin_top_default;
        $margin_right_xl = (isset($atts[$pre.'_margin_right_xl']) && $atts[$pre.'_margin_right_xl'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_margin_right_xl'])."px") : $margin_right_default;
        $margin_xl = "margin: ".$margin_top_xl." ".$margin_right_xl."; ";
        $margin_top_default = $margin_top_xl;
        $margin_right_default = $margin_right_xl;

        // padding responsive
        $padding_top_default = "0px"; //"5px";
        $padding_right_default = "0px"; //"10px";

        $padding_top_sm = (isset($atts[$pre.'_padding_top_sm']) && $atts[$pre.'_padding_top_sm'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_padding_top_sm'])."px") : $padding_top_default;
        $padding_right_sm = (isset($atts[$pre.'_padding_right_sm']) && $atts[$pre.'_padding_right_sm'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_padding_right_sm'])."px") : $padding_right_default;
        $padding_sm = "padding: ".$padding_top_sm." ".$padding_right_sm."; ";
        $padding_top_default = $padding_top_sm;
        $padding_right_default = $padding_right_sm;

        $padding_top_md = (isset($atts[$pre.'_padding_top_md']) && $atts[$pre.'_padding_top_md'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_padding_top_md'])."px") : $padding_top_default;
        $padding_right_md = (isset($atts[$pre.'_padding_right_md']) && $atts[$pre.'_padding_right_md'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_padding_right_md'])."px") : $padding_right_default;
        $padding_md = "padding: ".$padding_top_md." ".$padding_right_md."; ";
        $padding_top_default = $padding_top_md;
        $padding_right_default = $padding_right_md;

        $padding_top_lg = (isset($atts[$pre.'_padding_top_lg']) && $atts[$pre.'_padding_top_lg'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_padding_top_lg'])."px") : $padding_top_default;
        $padding_right_lg = (isset($atts[$pre.'_padding_right_lg']) && $atts[$pre.'_padding_right_lg'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_padding_right_lg'])."px") : $padding_right_default;
        $padding_lg = "padding: ".$padding_top_lg." ".$padding_right_lg."; ";
        $padding_top_default = $padding_top_lg;
        $padding_right_default = $padding_right_lg;

        $padding_top_xl = (isset($atts[$pre.'_padding_top_xl']) && $atts[$pre.'_padding_top_xl'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_padding_top_xl'])."px") : $padding_top_default;
        $padding_right_xl = (isset($atts[$pre.'_padding_right_xl']) && $atts[$pre.'_padding_right_xl'] != "") ? esc_attr(str_replace("px", "", $atts[$pre.'_padding_right_xl'])."px") : $padding_right_default;
        $padding_xl = "padding: ".$padding_top_xl." ".$padding_right_xl."; ";
        $padding_top_default = $padding_top_xl;
        $padding_right_default = $padding_right_xl;

        // text-color
        $text_color = helper::get_color($atts, $pre.'_text_', '', '');
        $text_color_hover = helper::get_color($atts, $pre.'_text_', '_hover', '');
        $text_color = empty($text_color) ? "" : "color: ".$text_color."; ";
        $text_color_hover = empty($text_color_hover) ? "" : "color: ".$text_color_hover."; ";

        // border
        $border = $border_hover = "";
        if (isset($atts[$pre.'_border'])) {
            $border_style = helper::make_border($atts, $pre);
            $border = $border_style['normal'];
            $border_hover = $border_style['hover'];
        }
        // border-radius
        $border_radius = $border_radius_hover = "0px";
        if (isset($atts[$pre.'_border_radius']) && $atts[$pre.'_border_radius'] != "") $border_radius = str_replace("px", "", $atts[$pre.'_border_radius'])."px";
        if (isset($atts[$pre.'_border_radius_hover']) && $atts[$pre.'_border_radius_hover'] != "") $border_radius_hover = str_replace("px", "", $atts[$pre.'_border_radius_hover'])."px";
        $border .= "border-radius: ".$border_radius."; ";
        $border_hover .= "border-radius: ".$border_radius_hover."; ";

        // Dropshadow
        $shadow = $shadow_hover = "";
        if (isset($atts[$pre.'_sdw'])) {
            $shadow_style = helper::make_shadow($atts, $pre);
            $shadow = $shadow_style['normal'];
            $shadow_hover = $shadow_style['hover'];
        }

        /**
         * Flexbox justify content.
         * @since 1.0.9
         */
        if ( isset($atts[$pre.'_flex_justify_content']) ) {
            $justify_content_class = esc_attr( trim( $atts[$pre.'_flex_justify_content'] ) );
            if ( !empty( $justify_content_class ) ) {
                $justify_content_class = "flex-justify-".$justify_content_class;
                $extra_class .= empty($extra_class) ? $justify_content_class : " ".$justify_content_class;
            }
        };

        /**
         * Get background
         */
        $type = isset($atts[$pre.'_type']) ? esc_attr($atts[$pre.'_type']) : '';
        $bg = array(
            'id' => $id,
            'inline_style' => "",
            'basic' => "",
        );
        if ($type != "") {
            $bg = helper::make_background($atts, $pre, $bg);
        }

        // build background element
        $background_element = $inline_style = "";
        if (
            !empty($bg['basic']) ||
            !empty($bg['inline_style']) || 
            !empty($border) || !empty($border_hover) || 
            !empty($shadow) || !empty($shadow_hover)
        ) {
            $background_element = "<div class='vc_bg vc-content-box-bg'>
                ".( empty($bg['basic']) ? "<div class='vc_bg_div'></div>" : $bg['basic'] )."
            </div>";
            $inline_style = $bg['inline_style'];
        }

        /**
         * inline styles
         */
        $inline_style .= "@media (min-width: var(grid_lg)) { #".$id." { ".$height_xl." ".$margin_xl." } } 
                        @media (min-width: var(grid_md)) and (max-width: var(grid_lg)) { #".$id." { ".$height_lg." ".$margin_lg." } } 
                        @media (min-width: var(grid_sm)) and (max-width: var(grid_md)) { #".$id." { ".$height_md." ".$margin_md." } } 
                        @media (max-width: var(grid_sm)) { #".$id." { ".$height_sm." ".$margin_sm." } }";

        $inline_style .= "#".$id." .vc-content-box-content,
                          #".$id." h1,
                          #".$id." h2,
                          #".$id." h3,
                          #".$id." h4,
                          #".$id." h5,
                          #".$id." h6,
                          #".$id." [class*='has-fontsize-h'],
                          #".$id."  [class*='has-h-'],
                          #".$id." p { ".$text_color." ".$transition." } 
                          #".$id.":hover .vc-content-box-content,
                          #".$id.":hover h1,
                          #".$id.":hover h2,
                          #".$id.":hover h3,
                          #".$id.":hover h4,
                          #".$id.":hover h5,
                          #".$id.":hover h6,
                          #".$id.":hover [class*='has-fontsize-h'],
                          #".$id.":hover  [class*='has-h-'],
                          #".$id.":hover p { ".$text_color_hover." } 
                        @media (min-width: var(grid_lg)) { #".$id." .vc-content-box-content { ".$padding_xl." } } 
                        @media (min-width: var(grid_md)) and (max-width: var(grid_lg)) { #".$id." .vc-content-box-content { ".$padding_lg." } } 
                        @media (min-width: var(grid_sm)) and (max-width: var(grid_md)) { #".$id." .vc-content-box-content { ".$padding_md." } } 
                        @media (max-width: var(grid_sm)) { #".$id." .vc-content-box-content { ".$padding_sm." } }";

        $transition .= " transition-property: box-shadow, border, border-radius, background; will-change: box-shadow, border, border-radius, background; ";
        $inline_style .= "#".$id." > .vc-content-box-bg { position: absolute; top:0;left:0;right:0;bottom:0; } 
                          #".$id." > .vc-content-box-bg .vc_bg_div { position: absolute; top:0;left:0;right:0;bottom:0; overflow: hidden; ".$transition." ".$border." ".$shadow." } 
                          #".$id.":hover > .vc-content-box-bg .vc_bg_div { ".$border_hover." ".$shadow_hover." } ";

        ob_start();

        // custom css
        \enqueue::add_custom_style($inline_style);
        
        // div
        echo "<div id='".$id."' class='vc-content-box ".$extra_class."' ".implode(" ", $link_html_atts)." $trigger_events>
            $background_element
            <div class='vc-content-box-content'><div>
                ".do_shortcode($content)."
            </div></div>
        </div>";
            
        $r = ob_get_contents();
        ob_end_clean();
        return $r;
    }

    /* list */
    public function list_item_sc($atts=[], $content='') {
        if ( empty($content) ) return '';

        $icon = isset($atts['icon']) ? $atts['icon'] : '';
        $content = trim( preg_replace( "/(^<\/p>)|(<p>$)/", "", $content ) );
        
        return "<li>$icon<span class='list_content'>$content</span></li>";
    }
    public function list_sc($atts=[], $content='') {
        // debug($atts);
        
        $list_type = isset($atts['vc_list_type']) ? esc_attr($atts['vc_list_type']) : '';

        // basic style
        $list_wrapper_style = "";
        $list_style = "";
        $list_icon_style = "display: inline-block; ";
        $list_content_style = "display: inline-block; ";
                
        // icon
        $list_icon = "";
        if ($list_type == "web") {
            $list_web = isset($atts['vc_list_web']) ? esc_attr($atts['vc_list_web']) : 'disc';
            $list_wrapper_style .= "list-style: ".$list_web."; ";
            $list_icon_size = "";
            $list_icon_margin = "";
        }
        else {
            $list_wrapper_style .= "list-style: none; ";
            $list_style .= "display: flex; margin-left: 0px; margin-right: 0px; ";

            $list_icon_size = isset($atts['vc_list_icon_size']) ? helper::force_units(esc_attr($atts['vc_list_icon_size'])) : '20px';
            $list_icon_margin = isset($atts['vc_list_icon_margin']) ? helper::force_units(esc_attr($atts['vc_list_icon_margin'])) : '10px';

            if ($list_type == "icon") {
                $list_icon_src = isset($atts['vc_list_icon']) ? esc_attr($atts['vc_list_icon']) : '';
                if ($list_icon_src != '') {
                    $list_icon_color = helper::get_color($atts, 'vc_list_', '', 'inherit');
                    $list_icon_color = helper::process_color($list_icon_color);
                    $list_icon_style .= "color: ".$list_icon_color."; 
                                         font-size: ".$list_icon_size."; ";
                    $list_icon = "<span class='list_icon ".$list_icon_src."' aria-hidden='true'></span>";
                }
            }
            else if ($list_type == "img") {
                $list_image_id = isset($atts['vc_list_image']) ? esc_attr($atts['vc_list_image']) : -1;
                if (is_numeric($list_image_id)) $list_image_src = wp_get_attachment_url($list_image_id);
                else $list_image_src = $list_image_id;
                if (isset($list_image_src)) {
                    $list_icon_style .= "width: ".$list_icon_size."; min-width: ".$list_icon_size."; height: ".$list_icon_size.";
                                         background: url(".$list_image_src.");
                                         background-repeat: no-repeat;
                                         background-position: center;
                                         background-size: contain; ";
                    $list_icon = "<span class='list_icon'></span>";
                }
            }
        }

        // get layout
        $list_icon_array = array( 'type' => $list_type, 'size' => $list_icon_size, 'margin' => $list_icon_margin);
        $list_style_array = $this->make_list_layout($atts, $list_icon_array, 'list_', '');
        $list_style_mobile = $this->make_list_layout($atts, $list_icon_array, 'list_', '_mobile');

        $list_wrapper_style .= $list_style_array['wrapper_style'];
        $list_style .= $list_style_array['list_style'];
        $list_icon_style .= $list_style_array['icon_style'];
        $list_content_style .= $list_style_array['content_style'];

        // content
        // debug($content);
        $list = array();
        if ($content != "") {
            if ($list_icon != "")
                $content = str_replace('[vc_list_item', '[vc_list_item icon="'.$list_icon.'"', $content);
            $content = do_shortcode($content);
        }
        else {
            $list_content = isset($atts['vc_list_content']) ? vc_param_group_parse_atts($atts['vc_list_content']) : array();
            foreach ($list_content as $item) {
                if ( !empty( trim($item['list_item']) ) ) 
                    $list[] = "<span class='list_content'>".trim($item['list_item'])."</span>";
            }
        }
        // debug($list);

        // render
        $id = "vc_list_".uniqid();
        $style = "";
        // $style .= "#".$id." { border: 1px solid black; background: rgba(255,255,255,0.5); } ";
        $style .= "#".$id." > ul { ".$list_wrapper_style." } 
                   #".$id." > ul li { ".$list_style." } 
                   #".$id." > ul li:first-child { margin-top: 0px !important; } 
                   #".$id." > ul li > .list_icon { ".$list_icon_style." } 
                   #".$id." > ul li > .list_content { ".$list_content_style." } 
                   #".$id." > ul li > .list_content p { margin: 0 } ";
        $style .= "@media (max-width: var(grid_md)) { 
                    #".$id." > ul { ".$list_style_mobile['wrapper_style']." } 
                    #".$id." > ul li { ".$list_style_mobile['list_style']." } 
                    #".$id." > ul li > .list_icon { ".$list_style_mobile['icon_style']." } 
                    #".$id." > ul li > .list_content { ".$list_style_mobile['content_style']." } 
                   }";

        $css = isset($atts['css']) ? vc_shortcode_custom_css_class($atts['css']) : '';
        ob_start();

            // custom css
            \enqueue::add_custom_style($style);
            
            echo "<div id='".$id."' class='vc-list ".$css."'>";
                echo "<ul>";
            if ($content != "") {
                echo $content;
            }
            else {
                $first = " style='margin-top: 0px'";
                foreach ($list as $list_item) {
                    echo "<li".$first.">".$list_icon.$list_item."</li>";
                    $first = "";
                }
            }
                echo "</ul>";
            echo "</div>";
        $r = ob_get_contents();
        ob_end_clean();
        return $r;
    }
    public function make_list_layout($atts, $icon, $pre, $post="") {

        if ($post != "") {
            if (isset($atts[$pre.'gap']) && (!isset($atts[$pre.'gap'.$post]) || $atts[$pre.'gap'.$post] == "")) $atts[$pre.'gap'.$post] = $atts[$pre.'gap'];
            if (isset($atts[$pre.'fullwidth']) && !isset($atts[$pre.'fullwidth'.$post])) $atts[$pre.'fullwidth'.$post] = $atts[$pre.'fullwidth'];
            if (isset($atts[$pre.'text_align']) && (!isset($atts[$pre.'text_align'.$post]) || $atts[$pre.'text_align'.$post] == "")) $atts[$pre.'text_align'.$post] = $atts[$pre.'text_align'];
            if ($icon['type'] == "web") {
                if (isset($atts[$pre.'icon_position_web']) && (!isset($atts[$pre.'icon_position_web'.$post]) || $atts[$pre.'icon_position_web'.$post] == "")) $atts[$pre.'icon_position_web'.$post] = $atts[$pre.'icon_position_web'];
                if (isset($atts[$pre.'icon_align_web']) && (!isset($atts[$pre.'icon_align_web'.$post]) || $atts[$pre.'icon_align_web'.$post] == "")) $atts[$pre.'icon_align_web'.$post] = $atts[$pre.'icon_align_web'];
            }
            else {
                if (isset($atts[$pre.'icon_position']) && (!isset($atts[$pre.'icon_position'.$post]) || $atts[$pre.'icon_position'.$post] == "")) $atts[$pre.'icon_position'.$post] = $atts[$pre.'icon_position'];
                if (isset($atts[$pre.'icon_align_y']) && (!isset($atts[$pre.'icon_align_y'.$post]) || $atts[$pre.'icon_align_y'.$post] == "")) $atts[$pre.'icon_align_y'.$post] = $atts[$pre.'icon_align_y'];
                if (isset($atts[$pre.'icon_align_x']) && (!isset($atts[$pre.'icon_align_x'.$post]) || $atts[$pre.'icon_align_x'.$post] == "")) $atts[$pre.'icon_align_x'.$post] = $atts[$pre.'icon_align_x'];
            }
        }

        $wrapper_style = "";
        $list_style = "";
        $icon_style = "";
        $content_style = "";

        $gap = isset($atts[$pre.'gap'.$post]) ? esc_attr($atts[$pre.'gap'.$post]) : '10px';        // xxpx
        $fullwidth = isset($atts[$pre.'fullwidth'.$post]) ? '100%' : 'auto';                 // checkbox
        
        // style
        $list_style .= "margin-top: ".$gap."; ";
        $content_style .= "margin: 0px; width: ".$fullwidth."; ";

        // text align (default: left)
        $text_align = isset($atts[$pre.'text_align'.$post]) ? esc_attr($atts[$pre.'text_align'.$post]) : 'left'; // (left center right)
        if ($text_align == 'left') {
            $wrapper_style .= "text-align: left; ";
            if ($icon['type'] != "web") $list_style .= "justify-content: flex-start; ";
        }
        if ($text_align == 'center') {
            $wrapper_style .= "text-align: center; ";
            if ($icon['type'] != "web") $list_style .= "justify-content: center; ";
        }
        else if ($text_align == 'right') {
            $wrapper_style .= "text-align: right; ";
            if ($icon['type'] != "web") $list_style .= "justify-content: flex-end; ";
        }

        // icons position (default: left start)
        if ($icon['type'] == "web") {
            $icon_position = isset($atts[$pre.'icon_position_web'.$post]) ? esc_attr($atts[$pre.'icon_position_web'.$post]) : 'left'; // (left right)
            if ($icon_position == 'left') {
                $list_style .= "margin-left: 20px; ";
            }
            if ($icon_position == 'right') {
                $list_style .= "margin-left: 0px; margin-right: 20px; ";
                $list_style .= "direction: rtl; ";
                $content_style .= "direction: ltr; ";
            }
            // vertical align when icon position left or right
            $icon_align = isset($atts[$pre.'icon_align_web'.$post]) ? esc_attr($atts[$pre.'icon_align_web'.$post]) : 'start'; // (start first center end)
            if ($icon_align == "first") $content_style .= "vertical-align: top; ";
            if ($icon_align == "start") $content_style .= "vertical-align: text-top; ";
            if ($icon_align == "center") $content_style .= "vertical-align: middle; ";
            if ($icon_align == "end") $content_style .= "vertical-align: baseline; ";
        }
        else {
            // only icon or img
            $icon_position = isset($atts[$pre.'icon_position'.$post]) ? esc_attr($atts[$pre.'icon_position'.$post]) : 'left'; // (left right top bottom)
            if ($icon_position == 'left' || $icon_position == 'right') {
                if ($icon_position == 'left') {
                    $list_style .= "flex-direction: row; ";
                    // $icon_style .= "margin-right: ".$icon['margin']."; ";
                    $icon_style .= "margin: 0 ".$icon['margin']." 0 0; ";
                }
                if ($icon_position == 'right') {
                    $list_style .= "flex-direction: row-reverse; ";
                    // $icon_style .= "margin-left: ".$icon['margin']."; ";
                    $icon_style .= "margin: 0 0 0 ".$icon['margin']."; ";
                }
                // vertical align when icon position left or right
                $icon_align = isset($atts[$pre.'icon_align_y'.$post]) ? esc_attr($atts[$pre.'icon_align_y'.$post]) : 'start'; // (start first center end)
                
                if ($icon_align == "first") {
                    $list_style .= "align-items: start; ";
                    $height = str_replace('px', '', $icon['size'])*1.0;
                    $content_style .= "margin-top: ".(($height-20.0)/2)."px; ";
                }
                if ($icon_align == "start") {
                    $list_style .= "align-items: start; ";
                }
                if ($icon_align == "center") {
                    $list_style .= "align-items: center; ";
                }
                if ($icon_align == "end") {
                    $list_style .= "align-items: end; ";
                }
            }
            else if ($icon_position == 'top' || $icon_position == 'bottom') {
                if ($icon_position == 'top') {
                    $list_style .= "flex-direction: column; ";
                    // $icon_style .= "margin-bottom: ".$icon['margin']."; ";
                    $icon_style .= "margin: 0 0 ".$icon['margin']." 0; ";
                }
                if ($icon_position == 'bottom') {
                    $list_style .= "flex-direction: column-reverse; ";
                    // $icon_style .= "margin-top: ".$icon['margin']."; ";
                    $icon_style .= "margin: ".$icon['margin']." 0 0 0; ";
                }
                // horizontal align when icon position top or bottom
                $icon_align = isset($atts[$pre.'icon_align_x'.$post]) ? esc_attr($atts[$pre.'icon_align_x'.$post]) : 'start'; // (start center end)
                if ($icon_align == "start") {
                    if ($icon['type'] == "icon") $icon_style .= "text-align: left; ";
                    $list_style .= "align-items: start; ";
                }
                if ($icon_align == "center") {
                    if ($icon['type'] == "icon") $icon_style .= "text-align: center; ";
                    $list_style .= "align-items: center; ";
                }
                if ($icon_align == "end") {
                    if ($icon['type'] == "icon") $icon_style .= "text-align: right; ";
                    $list_style .= "align-items: end; ";
                }
            }
        }

        return array(
            'wrapper_style' => $wrapper_style,
            'list_style' => $list_style,
            'icon_style' => $icon_style,
            'content_style' => $content_style,
        );
    }
    
    /* conditional content */
    public function cond_content_sc($atts=[], $content='') {
        
        $debug = isset($atts['debug']) ? $atts['debug'] : null;
        
        if ( $debug === 'true' ) {
            // get all cond items
            preg_match_all('/\[vc_cond_content_item(.*?)\]\[\/vc_cond_content_item\]/', $content, $shortcodes );
        
            if ( isset($shortcodes[1]) ) {
                $_content = "";
                foreach ( $shortcodes[1] as $shortcode ) {
                    $_content .= '[vc_cond_content_item debug="'.$debug.'" '.$shortcode.'][/vc_cond_content_item]';
                }
                $content = $_content;
            }
        }
        
        
        // Render
        ob_start();
        echo do_shortcode($content);
        $r = ob_get_contents();
        ob_end_clean();
        return $r;
        
    }
    
    /* conditional content item */
    public static function cond_content_item_sc($atts=[], $content='') {
        //debug($atts);
        
        // Attributes
        $debug          = isset($atts['debug']) && $atts['debug'] === 'true' ? true : false;
        $title          = isset($atts['title']) ? $atts['title'] : null;
        $condition_type = isset($atts['condition_type']) ? $atts['condition_type'] : '||';
        $matches        = array(); // collect matches
        $options        = isset($atts['options']) ? vc_param_group_parse_atts($atts['options']) : array();
        //debug($options);
        
        // get current values
        $values                         = array(); // collect values
        $values["urlparam"]             = class_exists("url_handler") ? \url_handler::get_url_values() : array(); // get default url params
        $values["cookie"]               = class_exists("url_handler") ? \url_handler::get_cookie_values() : array(); // get default cookies
        $values["time"]["time"]         = intval(current_time("Hi")); // get hour + minutes as intval (13:15h is 1315, 07:30h is 730)
        $values["userrole"]["userrole"] = is_user_logged_in() ? wp_get_current_user()->roles : array("none"); // get assigned userroles
        //debug($values);
        
        if ($debug) {
            echo "<pre>";
            echo "<h6>".$title."</h6>";
            echo "<ul>";
        }
        
        // loop through all options
        if (is_array($options) && count($options) > 0 ) {
            foreach ($options as $option) {
                if (isset($option['type'])) { // only if type is defined
                    
                    // get type of dependency
                    $type = $option['type'];
                    // get $param and $_type
                    if ($type === "urlparam" || $type === "cookie") {
                        $_type = "urlparam"; // cookie uses same dropdown & input
                        if ($option['urlparam'] !== "custom") {
                            $param = $option['urlparam'];
                        } else {
                            // use custom-urlparam as param
                            $param = urlencode($option['custom_urlparam']);
                            $values["cookie"] = class_exists("url_handler") ? \url_handler::get_all_cookie_values() : array(); // get real cookies
                            $values["urlparam"] = class_exists("url_handler") ? \url_handler::get_all_url_values() : array(); // get all url_params
                        }
                    } else {
                        $_type = $param = $type;
                    }
                    // define other vars
                    $condition  = isset($option['condition_'.$_type]) ? $option['condition_'.$_type] : "is";
                    $should     = isset($option[$_type.'_value']) ? $option[$_type.'_value'] : '';
                    $is         = isset($values[$type]) && isset($values[$type][$param]) ? $values[$type][$param] : NULL;
                    
                    // use custom-time as value
                    if ( isset($option['time_value']) && $option['time_value'] === "custom" ) {
                        $custom_time = isset($option['custom_time']) ? $option['custom_time'] : '';
                        $should = strtolower(preg_replace("/\s/", "", $custom_time));
                    }
                    
                    // check if condition is true
                    
                    // COOKIE & URL_PARAMS
                    if ($type === "urlparam" || $type === "cookie") {
                        if ($condition === "is") {
                            if ($should === $is) $match = true;
                            else $match = false;
                        } else if ($condition === "is_not") {
                            if ($should !== $is) $match = true;
                            else $match = false;
                        } else if ($condition === "has") {
                            if (strpos($is, $should) !== false) $match = true;
                            else $match = false;
                        } else if ($condition === "empty") {
                            if (empty($is)) $match = true;
                            else $match = false;
                        } else if ($condition === "not_empty") {
                            if (!empty($is)) $match = true;
                            else $match = false;
                        }
                    }
                    // USERROLES
                    else if ($type === "userrole") {
                        $flipped = array_flip($is); // get userroles as keys of array
                        if ($condition === "is") {
                            if (isset($flipped[$should])) $match = true; // check if key isset
                            else $match = false;
                        } else if ($condition === "is_not") {
                            if (!isset($flipped[$should])) $match = true;
                            else $match = false;
                        }
                    }
                    // TIME
                    else if ($type === "time") {
                        $_matches   = array(); // collect all the matches
                        $_times     = explode(",", $should); // enable multiple timeframes
                        foreach ((array) $_times as $_time) {
                            $_time = explode("-", $_time); // explode "start-end" to ["start","end"]
                            if (!isset($_time[1])) $_time[1] = intval($_time[0])+1; // if no end isset -> use start+1 (12 -> 12-13)
                            
                            // enable minutes
                            foreach ( $_time as $i => $t ) {
                                $t = strval($t);
                                // convert hour to hour + minutes (13 -> 1300)
                                if ( strpos($t, ":") === false ) {
                                    $t = str_pad($t, 4, "0");
                                }
                                // convert hour and minutes to string (13:15 -> 1315, 07:1 -> 0701)
                                else {
                                    $t = explode(":", $t);
                                    if ( isset($t[1]) && !empty($t[1]) ) {
                                        $t[1] = strlen(strval($t[1])) > 2 ? substr($t[1], 0, 2) : strval($t[1]); // max length of 2
                                        $t[1] = strlen($t[1]) < 2 ? "0"+$t[1] : $t[1]; // min length of 2
                                    } else {
                                        $t[1] = "00";
                                    }
                                    $t = implode("", $t);
                                }
                                $_time[$i] = $t;
                            }
                            
                            if ($condition === "is") {
                                if ( intval($_time[0]) <= $is && $is < intval($_time[1]) ) array_push($_matches, true);
                                else array_push($_matches, false);
                            } else if ($condition === "is_not") {
                                if ( $is < intval($_time[0]) || intval($_time[1]) <= $is ) array_push($_matches, true);
                                else array_push($_matches, false);
                            }
                        }
                        $match = false; // default match value
                        foreach((array)$_matches as $_match) {
                            if ($_match) {
                                $match = true; // if 1 of the matches is true --> match = true
                                break;
                            }
                        }
                    }
                    // SEARCH
                    else if ($type === "search") {
                        if ( is_search() || is_archive() ) {
                            $condition = $should = $condition === 'is' ? 'multiple' : $condition; // default to 'multiple'
                            global $wp_query;
                            $count = $wp_query->found_posts;
                            $is = $count === 0 ? 'empty' : ( $count === 1 ? 'single' : 'multiple' );
                            $match = $is === $condition;
                        } else {
                            $match = false;
                        }
                    }
                    // TAXONOMIES
                    else if ($type === "taxonomy") {
                        // $condition holds the taxonomy name
                        global $post;
                        $should     = isset($option[ $condition.'_terms' ]) ? $option[ $condition.'_terms' ] : 'none';
                        $match      = has_term( explode(',', $should), $condition, $post);
                        $condition  = 'has terms'; // for debug mode
                    }
                    // Debug
                    if ($debug) {
                        $word = $should;
                        if ($condition === "is_not") {
                            $word = "not ".$should;
                        } else if ($condition === "empty" || $condition === "not_empty") {
                            $word = $condition;
                        }
                        echo "<li>is [".$type."] ".$param." ".$word."? <strong>".($e = $match ? "yes" : "no")."</strong> it is ".( $is == "" ? "empty" : $is )."</li>";
                        //debug($match);
                    }
                    // collect match
                    array_push($matches, $match);
                }
            }
        }
        
        
        // check if content should be rendered
        $render = $condition_type == '||' ? false : true; // default value
        foreach( (array)$matches as $match ) {
            if ($condition_type !== "||") {
                if (!$match) $render = false;
            } else {
                if ($match) $render = true;
            }
        }
        if ($debug) {
            echo "--> render (".($q = $condition_type === '||' ? 'or' : 'and')."): <strong>".($e = $render ? "yes" : "no")."</strong>";
            echo "</ul></pre>";
        }
        
        // Render
        ob_start();
        
        if ($render) echo do_shortcode($content);
            
        $r = ob_get_contents();
        ob_end_clean();
        return $r;
        
    }
    
    /* counter */
    public static function counter_sc($atts=[], $content='') {
        // debug( $atts );
        
        $value  = "0";
        $type   = isset($atts['type']) ? esc_attr($atts['type']) : 'manual';
        
        // manual value
        if ( $type === 'manual' ) {
            $value = isset($atts['manual']) ? preg_replace( "/[^0-9]/", "", $atts['manual'] ) : "42";
        }
        // dynamic value
        else if ( $type === 'dynamic' ) {
            
            $posttype = isset($atts['posttype']) ? esc_attr($atts['posttype']) : "";
            if ( !empty($posttype) && post_type_exists($posttype) ) {
                
                $value = wp_count_posts($posttype)->publish;
                
                $taxonomy = isset($atts[$posttype.'_taxonomy']) ? esc_attr($atts[$posttype.'_taxonomy']) : "";
                
                if ( !empty($taxonomy) && taxonomy_exists($taxonomy) ) {
                    
                    $value  = "0";
                    $term   = isset($atts[$taxonomy.'_term']) ? esc_attr($atts[$taxonomy.'_term']) : "";
                    
                    if ( !empty($term) ) {
                        $wp_term = get_term($term);
                        if (!is_wp_error($wp_term) && !empty($wp_term)) $value = $wp_term->count;
                    }
                    
                }
            }
        }
        else if ( $type === 'found' ) {
            if ( is_search() || is_archive() ) {
                global $wp_query;
                $value = $wp_query->found_posts;
            }
        }
        
        $time       = isset($atts['anim_time']) ? floatval( str_replace( ",", ".", preg_replace( "/[^0-9,.]/", "", $atts['anim_time'] ) ) ) : 1;
        $time       = $time < 0 ? 0 : $time;
        $start      = $time > 0 ? "0" : $value;
        $counter    = "<span class='count".($type === 'found' ? " query--found-posts" : "")."' data-time='$time' data-end='$value'>$start</span>";
        
        return "<div class='greyd_counter'>".str_replace( "_count_", $counter, $content )."</div>";
    }

    /* vc mods */
    public static function vc_bg_sc($atts=[], $content='') {

        $pre = 'vc_bg';
        // background extension
        $background = "";
        $extra_classes = [];

        $bg_class = "vc_bg";
        $bg = array(
            'id'        => "vc_bg_".uniqid(),
            'inline_style' => "",
            'basic'     => "",
            'overlay'   => "",
            'seperator' => "",
        );

        // size
        $vc_bg_size = isset($atts['vc_bg_size']) && $atts['vc_bg_size'] != "" ? esc_attr($atts['vc_bg_size']) : 'vc_bg_full';
        $bg_class .= " ".$vc_bg_size;
        if ($vc_bg_size == "vc_bg_window") $extra_classes[] = $vc_bg_size;
        
        // basic background
        $type = isset($atts[$pre.'_type']) ? esc_attr($atts[$pre.'_type']) : '';
        if ($type != "") {
            $bg = helper::make_background($atts, $pre, $bg);
        }
        // overlay
        $overlay = isset($atts[$pre.'_overlay']) ? esc_attr($atts[$pre.'_overlay']): null;
        if ($overlay) {
            $bg = helper::make_overlay($atts, $pre, $bg);
        }
        // seperator
        $seperator = isset($atts[$pre.'_seperator']) ? esc_attr($atts[$pre.'_seperator']) : null;
        if ($seperator) {
            $bg = helper::make_seperator($atts, $pre, $bg);
        }
        
        // make background div
        if ($bg['basic'] != "" || $bg['overlay'] != "" || $bg['seperator'] != "") {
            $extra_classes[] = "vc_background";
            
            // custom css
            \enqueue::add_custom_style($bg['inline_style']);

            $background = "<div id='".$bg['id']."' class='".$bg_class."'>
                                ".( isset($bg_style) ? $bg_style : "" )."
                                ".$bg['basic']."
                                ".$bg['overlay']."
                                ".$bg['seperator']."
                            </div>";
            return array(
                'content' => $background,
                'classes' => $extra_classes
            );
        }
        else return false;
    }
    
    /* form message when not installed */
    public static function form_message_sc($atts=[], $content='') {
        $message = sprintf(__("Installiere und aktiviere %s, um dieses Formular darstellen zu können.", 'core'), '<strong>'.__('GREYD.Forms', 'core').'</strong>').
            '<br><a class="button small" style="display:inline-block;margin:10px 0 0" href="'.admin_url( 'admin.php?page=install-required-plugins').'" target="_blank">'.
            _x('Jetzt installieren', 'small', 'core').
            '<span style="margin-left:10px; font-size:150%" aria-hidden="true" class="arrow_right"></span>'.
            '</a>';
        return helper::make_message( $message );
    }
    
}
