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

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

new defaults;
class defaults {

    /*
        General constructor
    */
    public function __construct() {
        
        // basic script calls
        add_action( 'vc_base_register_front_css', array($this, 'vc_backend_register_style') );
        add_action( 'vc_frontend_editor_enqueue_js_css', array($this, 'vc_backend_enqueue_style') );
        add_action( 'vc_frontend_editor_render_template', array($this, 'vc_add_mods_script') );
        add_action( 'vc_frontend_editor_hook_load_edit', array($this, 'mod_dynamic_vc') );
        add_action( 'vc_load_iframe_jscss', array($this, 'vc_frontend_enqueue_script') );
        
        // exit if vc is not installed  
        if (!helper::is_active_plugin('js_composer/js_composer.php')) return; 
        
        // modify js_composer update message
        add_action( "in_plugin_update_message-js_composer/js_composer.php", array($this, 'js_composer_update_message_start'), 1, 2 );
        add_action( "in_plugin_update_message-js_composer/js_composer.php", array($this, 'js_composer_update_message_end'), 99, 2 );   

        // define new vc param_types (controls)
        add_action( 'vc_before_init', array($this, 'add_param_types_vc') );

        // mod default vc elements
        add_action( 'init', array($this, 'add_row_background_vc') );
        add_action( 'vc_after_init', array($this, 'mod_row_params_vc') );
        add_action( 'vc_after_init', array($this, 'mod_column_params_vc') );
        add_action( 'vc_after_init', array($this, 'mod_default_params_vc') );
        add_filter( 'vc_param_animation_style_list', array($this, 'mod_css_animation') );
        add_filter( 'embed_oembed_html', array($this, 'mod_youtube_player') , 10, 3);
        add_action( 'admin_notices', array($this, 'mod_dynamic_vc') );
        add_action( 'admin_init', array($this, 'mod_defaults_vc') );
        
        // remove vc menu item
        // add_action( 'admin_menu', array($this, 'remove_vc_menu'), 99 );
        
        // set vc roles
        add_action( 'vc_before_init', array($this, 'set_vc_roles') );
        // always enable backend-editor & html-module on all posttypes
        add_filter( 'vc_role_access_with_backend_editor_get_state', array($this, 'enable_for_all_posttypes'), 10, 2 );
        add_filter( 'vc_role_access_with_unfiltered_html_get_state', array($this, 'enable_for_admin_only'), 10, 2 );
        // disable frontend-editor & grid-builder
        add_filter( 'vc_role_access_with_grid_builder_get_state', '__return_false');
        add_filter( 'vc_role_access_with_frontend_editor_get_state', '__return_false' );
        // you can find the hooks here: js_composer/include/autoload/vc-pages/page-role-manager.php
        add_filter( 'page_row_actions', array( $this, 'remove_vc_fe_editor_row_action' ), 99, 2 );

        // enqueue styles for custom vc elements
        add_action( 'vc_base_register_admin_css', array($this, 'vc_backend_register_style') );
        add_action( 'vc_backend_editor_enqueue_js_css', array($this, 'vc_backend_enqueue_style') );
        add_action( 'vc_backend_editor_footer_render', array($this, 'vc_add_mods_script') );

		add_action( 'wp_before_admin_bar_render', array($this, 'vc_adminbar_links'), 99 );
		add_filter( 'page_row_actions', array($this, 'vc_row_action'), 99, 2 );
		add_filter( 'post_row_actions', array($this, 'vc_row_action'), 99, 2 );
		add_filter( 'edit_post_link', array($this, 'vc_edit_post_link'), 99 );
    }
    
    public function js_composer_update_message_start( $plugin_data, $r ) {
        echo "<br><br>".
            sprintf(
            __("Du kannst WPBakery ganz einfach unter %sGREYD.SUITE > Plugins%s aktualisieren.", "core" ),
            "<a href='".admin_url( 'admin.php?page=install-required-plugins')."'>",
            "</a>"
        )."<span class='hidden'>";
    }
    public function js_composer_update_message_end( $plugin_data, $r ) {
        echo "</span>";
    }
    
    /* enqueue additional styles */
    public function vc_backend_register_style() {
        global $config;   
        wp_register_style( 'vc_extensions', get_template_directory_uri().'/assets/css/deprecated/vc_extensions.css', null, $config->theme_version, 'all' );
    }
    public function vc_backend_enqueue_style() {
        wp_enqueue_style( 'vc_extensions' );
        // wp_enqueue_editor();
    }
    public function vc_frontend_enqueue_script() {
        wp_add_inline_script('vc_inline_iframe_js', 
        '$(function() {
            theme.init();    
            console.log("Frontend Editor Scripts: loaded");
        } );', 'after' ); 
    }
    public function vc_edit_post_link($link) {
        // debug($link);
        return $link;
    }
    public function vc_row_action($actions, $post) {
        if ( isset($actions['edit_vc']) ) {
            if ($post->post_type == 'page') {
                preg_match('/href=["\']?([^"\'>]+)["\']?/', $actions['edit_vc'], $match);
                $actions['edit_vc'] = "<a href='".$match[1]."'>".__('Frontend Editor', 'core')."</a>";
            }
            else unset($actions['edit_vc']);
        }
        return $actions;
    }
    public function vc_adminbar_links() {
        global $wp_admin_bar;
        $vc_admin_item = $wp_admin_bar->get_node('vc_inline-admin-bar-link');
        if ($vc_admin_item) {
            $wp_admin_bar->remove_node('vc_inline-admin-bar-link');
            if (is_page()) {
                $vc_admin_item->title = __('Frontend Editor', 'core');
                $wp_admin_bar->add_node($vc_admin_item);
            }
        }
    }
	public function vc_add_mods_script() {
        if (count(\processor::$mods) == 0) 
            \processor::process_defaults();
        ?>
        <script type="text/javascript">
            var post_id = "<?= get_the_ID() ?>";
            var post_type = "<?= get_post_type() ?>";
            <?php if (get_post_type() == 'dynamic_template') { ?>
                var template_type = "<?= get_the_terms(get_the_ID(), 'template_type')[0]->slug ?>";
                var template_slug = "<?= get_post_field( 'post_name'); ?>";
            <?php } ?>
            var root = <?= json_encode(\processor::$root) ?>;
            var themeurl = "<?= get_stylesheet_directory_uri() ?>";
            var patterns = {
                "pattern_01": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAADklEQVQIW2NggID/cAIADwMB/zSts64AAAAASUVORK5CYII=",
                "pattern_02": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAE0lEQVR4AWMAgv9gjAMgFAxrAADDbwP9sI02swAAAABJRU5ErkJggg==",
                "pattern_03": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAEklEQVR4AWMAgs0YGEygAQoFAc1BBkwbUqhOAAAAAElFTkSuQmCC",
                "pattern_04": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAEklEQVR4AWMYKuA/jMariGwTACH1BPyE5LjvAAAAAElFTkSuQmCC",
                "pattern_05": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAQAAAAziH6sAAAADklEQVR4AWNg+M/AwAAABAIBAMMz9ccAAAAASUVORK5CYII=",
                "pattern_06": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABAQMAAADO7O3JAAAABlBMVEUAAAAAAAClZ7nPAAAAAXRSTlMAQObYZgAAAApJREFUCNdjcAAAAEIAQYO57K0AAAAASUVORK5CYII=",
                "pattern_07": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAECAYAAABGM/VAAAAADklEQVR4AWMgBP6TrgIARBAB/8Id9pYAAAAASUVORK5CYII=",
                "pattern_08": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAADklEQVR4AWMAgv8MowAABBMBANYOezsAAAAASUVORK5CYII=",
                "pattern_09": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAD0lEQVQIW2NgYGD4z4AMAA4EAQAMvbGxAAAAAElFTkSuQmCC",
            };
            function getSeperator(type, height, color) {
                var seperators = {
                    // triangles
                    'triangle_seperator': '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 0.156661 0.1"><polygon points="0.156661,3.93701e-006 0.156661,0.000429134 0.117665,0.05 0.0783307,0.0999961 0.0389961,0.05 -0,0.000429134 -0,3.93701e-006 0.0783307,3.93701e-006 "/></svg>',
                    'triangle_big_seperator': '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 4.66666 0.333331" preserveAspectRatio="none"><path class="fil0" d="M-0 0.333331l4.66666 0 0 -3.93701e-006 -2.33333 0 -2.33333 0 0 3.93701e-006zm0 -0.333331l4.66666 0 0 0.166661 -4.66666 0 0 -0.166661zm4.66666 0.332618l0 -0.165953 -4.66666 0 0 0.165953 1.16162 -0.0826181 1.17171 -0.0833228 1.17171 0.0833228 1.16162 0.0826181z"/></svg>',
                    'triangle_big_left_seperator': '<svg class="svg_mirror_y" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 2000 90" preserveAspectRatio="none"><polygon xmlns="http://www.w3.org/2000/svg" points="535.084,64.886 0,0 0,90 2000,90 2000,0 "></polygon></svg>',
                    'triangle_big_right_seperator': '<svg class="svg_mirror_xy" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 2000 90" preserveAspectRatio="none"><polygon xmlns="http://www.w3.org/2000/svg" points="535.084,64.886 0,0 0,90 2000,90 2000,0 "></polygon></svg>',
                    // curves
                    'circle_seperator': '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 0.2 0.1"><path d="M0.200004 0c-3.93701e-006,0.0552205 -0.0447795,0.1 -0.100004,0.1 -0.0552126,0 -0.0999921,-0.0447795 -0.1,-0.1l0.200004 0z"/></svg>',
                    'curve_seperator': '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 4.66666 0.333331" preserveAspectRatio="none"><path class="fil1" d="M4.66666 0l0 7.87402e-006 -3.93701e-006 0c0,0.0920315 -1.04489,0.166665 -2.33333,0.166665 -1.28844,0 -2.33333,-0.0746339 -2.33333,-0.166665l-3.93701e-006 0 0 -7.87402e-006 4.66666 0z"/></svg>',
                    'curve_left_seperator': '<svg class="svg_mirror_y" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 4.66666 0.333331" preserveAspectRatio="none"><path class="fil0" d="M-7.87402e-006 0.0148858l0.00234646 0c0.052689,0.0154094 0.554437,0.154539 1.51807,0.166524l0.267925 0c0.0227165,-0.00026378 0.0456102,-0.000582677 0.0687992,-0.001 1.1559,-0.0208465 2.34191,-0.147224 2.79148,-0.165524l0.0180591 0 0 0.166661 -7.87402e-006 0 0 0.151783 -4.66666 0 0 -0.151783 -7.87402e-006 0 0 -0.166661z"/></svg>',
                    'curve_right_seperator': '<svg class="svg_mirror_xy" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 4.66666 0.333331" preserveAspectRatio="none"><path class="fil0" d="M-7.87402e-006 0.0148858l0.00234646 0c0.052689,0.0154094 0.554437,0.154539 1.51807,0.166524l0.267925 0c0.0227165,-0.00026378 0.0456102,-0.000582677 0.0687992,-0.001 1.1559,-0.0208465 2.34191,-0.147224 2.79148,-0.165524l0.0180591 0 0 0.166661 -7.87402e-006 0 0 0.151783 -4.66666 0 0 -0.151783 -7.87402e-006 0 0 -0.166661z"/></svg>',
                    // cuts
                    'tilt_left_seperator': '<svg class="svg_mirror_xy" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 4 0.266661" preserveAspectRatio="none"><polygon class="fil0" points="4,0 4,0.266661 -0,0.266661 "/></svg>',
                    'tilt_right_seperator': '<svg class="svg_mirror_y" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 4 0.266661" preserveAspectRatio="none"><polygon class="fil0" points="4,0 4,0.266661 -0,0.266661 "/></svg>',
                    // fancy
                    'waves_seperator': '<svg class="svg_mirror_y" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 6 0.1" preserveAspectRatio="none"><path d="M0.199945 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c-0.0541102,0 -0.0981929,-0.0430079 -0.0999409,-0.0967008l0 0.0967008 0.0999409 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm0.200004 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm0.200004 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm0.200004 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm0.200004 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm2.00004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm-0.1 0.1l-0.200008 0c-0.0552126,0 -0.0999921,-0.0447795 -0.1,-0.1 -7.87402e-006,0.0552205 -0.0447874,0.1 -0.1,0.1l0.2 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1 3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1zm-0.400008 0l-0.200008 0c-0.0552126,0 -0.0999921,-0.0447795 -0.1,-0.1 -7.87402e-006,0.0552205 -0.0447874,0.1 -0.1,0.1l0.2 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1 3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1zm-0.400008 0l-0.200008 0c-0.0552126,0 -0.0999921,-0.0447795 -0.1,-0.1 -7.87402e-006,0.0552205 -0.0447874,0.1 -0.1,0.1l0.2 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1 3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1zm-0.400008 0l-0.200008 0c-0.0552126,0 -0.0999921,-0.0447795 -0.1,-0.1 -7.87402e-006,0.0552205 -0.0447874,0.1 -0.1,0.1l0.2 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1 3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1zm-0.400008 0l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1 3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1zm1.90004 -0.1c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm0.200004 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm0.200004 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm0.200004 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.200004 0c7.87402e-006,0.0552205 0.0447874,0.1 0.1,0.1l-0.2 0c0.0552126,0 0.0999921,-0.0447795 0.1,-0.1zm0.200004 0c3.93701e-006,0.0552205 0.0447795,0.1 0.100004,0.1l-0.200008 0c0.0552244,0 0.1,-0.0447795 0.100004,-0.1zm0.199945 0.00329921l0 0.0967008 -0.0999409 0c0.0541102,0 0.0981929,-0.0430079 0.0999409,-0.0967008z"/></svg>',
                    'clouds_seperator': '<svg class="svg_mirror_y" xmlns="http://www.w3.org/2000/svg" version="1.1" fill="'+color+'" width="100%" height="'+height+'" viewBox="0 0 2.23333 0.1" preserveAspectRatio="none"><path class="fil0" d="M2.23281 0.0372047c0,0 -0.0261929,-0.000389764 -0.0423307,-0.00584252 0,0 -0.0356181,0.0278268 -0.0865354,0.0212205 0,0 -0.0347835,-0.00524803 -0.0579094,-0.0283701 0,0 -0.0334252,0.0112677 -0.0773425,-0.00116929 0,0 -0.0590787,0.0524724 -0.141472,0.000779528 0,0 -0.0288189,0.0189291 -0.0762362,0.0111535 -0.00458268,0.0141024 -0.0150945,0.040122 -0.0656811,0.0432598 -0.0505866,0.0031378 -0.076126,-0.0226614 -0.0808425,-0.0308228 -0.00806299,0.000854331 -0.0819961,0.0186969 -0.111488,-0.022815 -0.0076378,0.0114843 -0.059185,0.0252598 -0.083563,-0.000385827 -0.0295945,0.0508661 -0.111996,0.0664843 -0.153752,0.019 -0.0179843,0.00227559 -0.0571181,0.00573622 -0.0732795,-0.0152953 -0.027748,0.0419646 -0.110602,0.0366654 -0.138701,0.00688189 0,0 -0.0771732,0.0395709 -0.116598,-0.0147677 0,0 -0.0497598,0.02 -0.0773346,-0.00166929 0,0 -0.0479646,0.0302756 -0.0998937,0.00944094 0,0 -0.0252638,0.0107874 -0.0839488,0.00884646 0,0 -0.046252,0.000775591 -0.0734567,-0.0237087 0,0 -0.046252,0.0101024 -0.0769567,-0.00116929 0,0 -0.0450827,0.0314843 -0.118543,0.0108858 0,0 -0.0715118,0.0609803 -0.144579,0.00423228 0,0 -0.0385787,0.00770079 -0.0646299,0.000102362 0,0 -0.0387559,0.0432205 -0.125039,0.0206811 0,0 -0.0324409,0.0181024 -0.0621457,0.0111063l-3.93701e-005 0.0412205 2.2323 0 0 -0.0627953z"/></svg>',
                    'multi_triangle_seperator': 
                        '<svg class="svg_mirror_y" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" preserveAspectRatio="none" width="100%" height="'+height+'">\
                            <path class="large left" d="M0 0 L50 50 L0 100" fill="rgba(128, 128, 128, .1)"></path>\
                            <path class="large right" d="M100 0 L50 50 L100 100" fill="rgba(128, 128, 128, .1)"></path>\
                            <path class="medium left" d="M0 100 L50 50 L0 33.3" fill="rgba(128, 128, 128, .3)"></path>\
                            <path class="medium right" d="M100 100 L50 50 L100 33.3" fill="rgba(128, 128, 128, .3)"></path>\
                            <path class="small left" d="M0 100 L50 50 L0 66.6" fill="rgba(128, 128, 128, .5)"></path>\
                            <path class="small right" d="M100 100 L50 50 L100 66.6" fill="rgba(128, 128, 128, .5)"></path>\
                            <path d="M0 99.9 L50 49.9 L100 99.9 L0 99.9" fill="rgba(128, 128, 128, 1)"></path>\
                            <path d="M48 52 L50 49 L52 52 L48 52" fill="rgba(128, 128, 128, 1)"></path>\
                        </svg>'
                };
                return seperators[type];
            }
        </script>
        <?php
    }

    /*
        define new vc types (controls)
    */
    public function add_param_types_vc() {
        global $config; 
        // debug("adding param types");

        vc_add_shortcode_param('seperator', function( $settings, $value ) {
            $param = esc_attr($settings['param_name']);
            return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />";
        } );
        vc_add_shortcode_param('sub_seperator', function( $settings, $value ) {
            $param = esc_attr($settings['param_name']);
            return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />";
        } );
        vc_add_shortcode_param('new_line', function( $settings, $value ) {
            $param = esc_attr($settings['param_name']);
            return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />";
        } );
        vc_add_shortcode_param('info_text', function ( $settings, $value ) {
            $param = esc_attr($settings['param_name']);
            return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />".
                    helper::render_info_box($settings);
        });

        vc_add_shortcode_param('range', function( $settings, $value ) {
            return self::render_range_control($settings, $value);
        } );
        vc_add_shortcode_param('switch', function( $settings, $value ) {
            $param = esc_attr($settings['param_name']);
            // return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />";
            $options = array(
                array( 'val' => 'off', 'title' => 'off' ),
                array( 'val' => 'on', 'title' => 'on' )
            );
            if (isset($settings['params']) && is_array($settings['params'])) {
                $options = array();
                foreach ($settings['params'] as $val => $title) {
                    $options[] = array( 'val' => $val, 'title' => $title );
                }
            }
            if ($value == "") $value =$options[0]['val'];
            return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />
                    <div class='greyd_switch'>
                        <label>
                            <span>".$options[0]['title']."</span>
                            <span>
                                <input data-off='".$options[0]['val']."' data-on='".$options[1]['val']."' type='checkbox' ".($value == $options[1]['val'] ? 'checked=""' : '').">
                                <span>".$options[1]['title']."</span>
                            </span>
                        </label>
                    </div>";
        } );
        vc_add_shortcode_param('select', function( $settings, $value ) {
            $param = esc_attr($settings['param_name']);
            $options = $settings['options'];
            $show_message = false;

            if ($param == 'template' || $param == 'post_template') {
                
                // template is linked by slug
                if ( !is_numeric($value) || $value == "404" ) {
                    // $post = get_page_by_path($value, OBJECT, 'dynamic_template');
                    // if ($post) $value = $post->ID;
                    if ( $post = \dynamic::get_template($value) ) $value = $post[0]->ID;
                }
                // debug( $value, true );
                
                // look for wpml translations
                if (count($options) > 0) {
                    // get default language
                    $language_default = apply_filters( 'wpml_default_language', NULL );
                    // debug($language_default);
                    // get post language
                    $language_post = "";
                    $tmp = explode('?', $_SERVER['HTTP_REFERER']);
                    $tmp = explode('&', $tmp[1]);
                    foreach ($tmp as $t) {
                        if (strpos($t, 'post=') === 0) {
                            $id = str_replace('post=', '', $t);
                            $language_details = apply_filters( 'wpml_post_language_details', NULL, $id );
                            if ($language_details) $language_post = $language_details['language_code'];
                        }
                    }
                    // debug($language_post);
                    // filter templates
                    if ($language_default && $language_post != "") {
                        foreach ($options as $grouptitle => $groupoptions) {
                            if ($grouptitle == $language_post || $grouptitle == $language_default || $grouptitle == 'default') {
                                if ($language_post != $language_default && $grouptitle == $language_post) {
                                    foreach ($groupoptions as $title => $id) {
                                        $id_original = apply_filters( 'wpml_object_id', $id, 'dynamic_template', false, $language_default );
                                        if ($id_original != $value) {
                                            foreach ($options[$language_default] as $title_default => $id_default) {
                                                if ($id_default == $id_original) {
                                                    unset($options[$language_default][$title_default]);
                                                    break;
                                                }
                                            }
                                        }
                                        else $show_message = array( 'id' => $id, 'title' => $title );
                                    }
                                }
                            }
                            else unset($options[$grouptitle]);
                        }
                        // debug($options);
                    }
                }
            }

            $select = "<select name='$param' class='wpb_vc_param_value wpb-input wpb-select $param' data-option='$value'>";
            if (count($options['default']) > 0) {
                foreach ($options['default'] as $title => $id) {
                    $select .= "<option value='".$id."' ".selected($id, $value, false).">".$title."</option>";
                }
            }
            unset($options['default']);
            if (count($options) > 0) {
                foreach ($options as $grouptitle => $groupoptions) {
                    $select .= '<optgroup label="'.$grouptitle.'">';
                    foreach ($groupoptions as $title => $id) {
                        $select .= "<option value='".$id."' ".selected($id, $value, false).">".$title."</option>";
                    }
                    $select .= "</optgroup>";
                }
            }
            $select .= "</select>"; 
            if ($show_message) {
                $link = "<a href='".admin_url('post.php?post='.$show_message['id'].'&action=edit')."' target='_blank'>".$show_message['title']."</a>";
                $text = "<div>".__("Für das eingebundene Template wurde eine Übersetzung gefunden", 'core').": ".$link."</div>";
                $btn = "<div class='button' style='margin-top:10px' onclick='dyncontrol.changeContent(this,".$show_message['id'].")'><span class='dashicons dashicons-update-alt'></span>&nbsp;".__("jetzt austauschen", 'core')."</div>";
                $select .= "<div class='greyd_info_box info' style='margin: 10px 0px 0px'>
                                <span class='dashicons dashicons-info'></span>
                                <div>".$text.$btn."</div>
                            </div>";
            }
            return $select;
        } );

        vc_add_shortcode_param('dynamic', function( $settings, $value ) {
            $values = explode('|', $value);
            $param = esc_attr($settings['param_name']);
            // return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />";
            $placeholder = __("Standard", 'core').": \"".$settings['params']['field'].'_'.uniqid()."\"";
            $text = isset($settings['text']) ? html_entity_decode(esc_attr($settings['text'])) : '';
            if ($text != "") {
                $text = "<div class='greyd_info_box info'>
                            <span class='dashicons dashicons-info'></span>
                            <div><span>".$text."</span></div>
                        </div>";
            }
            $stext = isset($settings['params']['static']) ? html_entity_decode(esc_attr($settings['params']['static'])) : _x("statisch", 'small', 'core');
            $dtext = isset($settings['params']['dynamic']) ? html_entity_decode(esc_attr($settings['params']['dynamic'])) : _x("dynamisch", 'small', 'core');
            return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />
                    <select class='dynamic_type hidden'>
                        <option value='static' ".($value == 'static' ? 'selected="selected"' : '').">"._x("statisch", 'small', 'core')."</option>
                        <option value='dynamic' ".($value != 'static' ? 'selected="selected"' : '').">"._x("dynamisch", 'small', 'core')."</option>
                    </select>
                    <div class='flex'>
                        <div class='greyd_switch'>
                            <label>
                                <span>".$stext."</span>
                                <span>
                                    <input class='dynamic_type_checkbox' type='checkbox' ".($value != 'static' ? 'checked=""' : '').">
                                    <span>".$dtext."</span>
                                </span>
                            </label>
                        </div>
                        ".$text."
                    </div>
                    <div class='dynamic_name' ".($value == 'static' ? "style='display:none'" : "").">
                        <div class='wpb_element_label'>".__('Feldname', 'core')."</div>
                        <input class='dynamic_name_input' type='text' value='".(isset($values[2]) ? rawurldecode($values[2]) : "")."' placeholder='".$placeholder."' style='width: calc(100% - 230px)'>
                        <div class='change_name_alert right'>".__('Achtung! Wenn du den Namen dieses Feldes änderst, gehen die bisherigen dynamischen Inhalte verloren!', 'core')."</div>
                        <span class='vc_description vc_clearfix'>".__('Wenn du mehreren Inhalten denselben Namen gibst, werden diese später mit demselben Inhalt befüllt.', 'core')."</span>
                    </div>";
        } );
        vc_add_shortcode_param('dynamic_content', function( $settings, $value ) {
            $values = explode('::', $value);
            $param = esc_attr($settings['param_name']);
            // return "<input type='hidden' name='$param' class='wpb_vc_param_value $param' value='$value' />";
            $html = "<div class='dynamic_content_block'>
                        <div class='edit_buttons'>
                            <a class='button button-ghost template_link reload' disabled style='margin-right:6px;'><span class='dashicons dashicons-update'></span>&nbsp;".__('neu laden', 'core')."</a>
                            <a class='button template_link edit' href='' target='_blank' disabled>".__('Template bearbeiten', 'core')."&nbsp;<span class='dashicons dashicons-external'></span></a>
                        </div>
                        <input type='hidden' name='".$param."' class='dynamic_value wpb_vc_param_value ".$param."' value='".esc_attr($value)."' />
                        <input type='hidden' class='dynamic_template' value='".$values[0]."' />
                        <div class='dynamic_content_src' data-".$values[0]."='".esc_attr($value)."'></div>
                    </div>";
            return $html;
        } );

        vc_add_shortcode_param('file_picker', function( $settings, $value ) {
            return self::vc_file_picker_form_field($settings, $value);
        }, get_template_directory_uri().'/assets/js/vc.js?ver='.$config->theme_version );

        // colors
        vc_add_shortcode_param('colorselect', function( $settings, $value ) {
            return self::render_colorselect_control($settings, $value);
        } );
        vc_add_shortcode_param('colorgradient', function( $settings, $value ) {
            $param = esc_attr($settings['param_name']);
            if ($value == "") {
                // default setup
                // debug($param);
                $gradient = array(
                    'type' => 'angle', 'angle' => 45, 'scroll' => 'scroll',
                    'colors' => array(
                        array( 'color' => 'color_21', 'position' => '0' ),
                        array( 'color' => 'color_33', 'position' => '100' ),
                    ),
                );
                $old = isset($settings['old']) ? json_encode($settings['old']) : "";
            }
            else {
                // read value
                $tmp = explode('|', $value);
                $gradient = array( 'type' => $tmp[1], 'angle' => $tmp[2], 'scroll' => $tmp[0], 'colors' => array(),
                );
                for ($i=3; $i<count($tmp); $i++) {
                    $color = explode(':', $tmp[$i]);
                    $gradient['colors'][] = array( 'color' => $color[0], 'position' => $color[1] );
                }
            }

            // original input
            $div = "<input type='hidden' name='$param' class='wpb_vc_param_value $param gradient_value' value='$value' />
                    <input type='text' class='hidden gradient_dev' value='$value' />";
            // gradient input items
            $div .= "<div class='gradient_holder' ".($old ? "data-old='".$old."'" : "").">
                        <span class='gradient_grid'></span>
                        <span class='gradient_thumb'></span>
                        <span class='gradient_colors_holder'>";
                        foreach ($gradient['colors'] as $color)
                            $div .= "<span class='gradient_color' data-color='".$color['color']."' data-position='".$color['position']."' >
                                        <span class='color_grid'></span>
                                        <span class='color_thumb'></span>
                                    </span>";
            $div .=    "</span>
                    </div>";
            // item color
            $div .= "<div class='gradient_item' style='display: none;'>
                        <div class='gradient_item_details'>
                            <span class='item_position'>".__("Position", 'core').": <span>55</span>%</span>
                            <span class='item_hide' title='".__("Info verstecken", 'core')."'><i class='vc-composer-icon vc-c-icon-minimize'></i></span>
                            <span class='item_close' title='".__("Farbe löschen", 'core')."'><i class='vc-composer-icon vc-c-icon-close'></i></span>
                        </div>
                        <div class='gradient_item_colors'>
                            <div class='color_wrapper'>"
                                .$this->make_type_colorselect("").
                           "</div>
                            <div class='color_custom' style='display: none;'>
                                <input type='text' name='gradient_item_color_custom' value='' class='vc_color-control'>
                            </div>
                        </div>
                    </div>";
            // setup angle scroll
            $div .= "<div class='gradient_setup'>
                        <div class='vc_element_label'>".__("Richtung des Verlaufs", 'core')."</div>
                        <select class='gradient_type'>
                        <option value='top' ".selected($gradient['type'], 'top', false).">↓ "._x("von oben nach unten", 'small', 'core')."</option>
                        <option value='bottom' ".selected($gradient['type'], 'bottom', false).">↑ "._x("von unten nach oben", 'small', 'core')."</option>
                        <option value='left' ".selected($gradient['type'], 'left', false).">→ "._x("von links nach rechts", 'small', 'core')."</option>
                        <option value='right' ".selected($gradient['type'], 'right', false).">← "._x("von rechts nach links", 'small', 'core')."</option>
                        <option value='angle' ".selected($gradient['type'], 'angle', false).">↘ "._x("gewinkelt", 'small', 'core')."</option>
                        </select>
                        <div class='gradient_angle_div' ".($gradient['type'] != "angle" ? "style='display: none;'" : "").">
                            <label style='float:right'>".$gradient['angle']."°</label>
                            <input type='range' class='gradient_angle' value='".$gradient['angle']."' min='0' max='360' step='1' />
                        </div>
                        <div class='vc_element_label'>".__("Scroll-Verhalten", 'core')."</div>
                        <select class='gradient_scroll'>
                            <option value='scroll' ".selected($gradient['scroll'], 'scroll', false).">"._x("mit Inhalt bewegen", 'small', 'core')."</option>
                            <option value='fixed' ".selected($gradient['scroll'], 'fixed', false).">"._x("fixieren", 'small', 'core')."</option>
                        </select>
                    </div>";
            // preview
            $div .= "<div class='gradient_preview'>
                        <div class='vc_element_label'>".__("Vorschau", 'core')."</div>
                        <div class='gradient_wrapper'>
                            <span class='gradient_grid'></span>
                            <span class='gradient_thumb'></span>
                            <span class='gradient_code'></span>
                        </div>
                    </div>";
            
            return $div;
        } );
        vc_add_shortcode_param('shadow', function( $settings, $value ) {
            return self::render_shadow_control($settings, $value);
        }, get_template_directory_uri().'/assets/js/vc_colors.js?ver='.$config->theme_version );
        
    }
    public static function render_shadow_control( $settings, $value, $class='wpb_vc_param_value' ) {
        $param = esc_attr($settings['param_name']);
        $old = $value == "" && isset($settings['old']) ? json_encode($settings['old']) : "";
        $val = array( 'type' => '', 'x' => 0, 'y' => 0, 'blur' => 0, 'spread' => 0, 'color' => 'color_31', 'opacity' => 25 );
        if ($value != 'none') {
            // debug($value);
            $tmp = explode(" ", str_replace('+', ' ', $value));
            if (count($tmp) == 7) {
                $val['type'] = $tmp[0];
                array_splice($tmp, 0, 1);
            }
            if (count($tmp) < 6) return "";
            $val['x'] = str_replace('px', '', $tmp[0]);
            $val['y'] = str_replace('px', '', $tmp[1]);
            $val['blur'] = str_replace('px', '', $tmp[2]);
            $val['spread'] = str_replace('px', '', $tmp[3]);
            $val['color'] = $tmp[4];
            $val['opacity'] = $tmp[5];
        }

        $div  = "<input type='hidden' name='$param' class='shadow_value ".$class." $param' value='$value' />";
        $div .= "<input type='hidden' class='value_dev' value='$value' />";
        
        $div .= "<div class='shadow_setup' style='float:left;width:75%' ".($old ? "data-old='".$old."'" : "").">";
            $div .= "<div style='display:flex;padding-top: 15px;'>";
                // range controls
                $div .= "<div class='shadow_option' style='width:25%;'>
                            <label class='wpb_element_label' style='' data-label='".__('Horizontal', 'core')."' data-unit='px'></label>
                            <input type='range' class='horizontal' value='".$val['x']."' min='-25' max='25' step='1' />
                        </div>";
                $div .= "<div class='shadow_option' style='width:25%;'>
                            <label class='wpb_element_label' style='' data-label='".__('Vertikal', 'core')."' data-unit='px'></label>
                            <input type='range' class='vertical' value='".$val['y']."' min='-25' max='25' step='1' />
                        </div>";
                $div .= "<div class='shadow_option' style='width:25%;'>
                            <label class='wpb_element_label' style='' data-label='".__('Verwischen', 'core')."' data-unit='px'></label>
                            <input type='range' class='blur' value='".$val['blur']."' min='0' max='50' step='1' />
                        </div>";
                $div .= "<div class='shadow_option' style='width:25%;'>
                            <label class='wpb_element_label' style='' data-label='".__('Ausdehnen', 'core')."' data-unit='px'></label>
                            <input type='range' class='spread' value='".$val['spread']."' min='-25' max='25' step='1' />
                        </div>";
            $div .= "</div>";
            $div .= "<div style='display:flex;padding-top: 15px;'>";
                // color
                $div .= "<div class='shadow_color' style='width:50%;'>
                            <input type='hidden' class='colorselect_value' value='".$val['color']."' />
                            <label class='wpb_element_label'>".__('Farbe', 'core')."</label>
                            <div class='color_wrapper'>"
                                .self::make_type_colorselect($val['color']).
                            "</div>".
                            "<div class='color_custom' style='display: ".(!empty($val['color']) && $val['color'] != "transparent" && strpos($val['color'], "color_") === false ? "block" : "none").";'>
                                <input type='text' name='colorselect_color_custom' value='".$val['color']."' class='vc_color-control'>
                            </div>
                        </div>";
                // opacity
                $div .= "<div class='shadow_option' style='width:25%;'>
                            <label class='wpb_element_label' style='' data-label='".__('Deckkraft', 'core')."' data-unit='%'></label>
                            <input type='range' class='opacity' value='".$val['opacity']."' min='0' max='100' step='1' />
                        </div>";
                // type
                $div .= "<div class='shadow_type' style='width:25%;'>
                            <label class='wpb_element_label'>".__('Position', 'core')."</label>
                            <select class='type' >
                                <option value=''>"._x('außen', 'small', 'core')."</option>
                                <option value='inset' ".selected($val['type'], 'inset', false).">"._x('innen', 'small', 'core')."</option>
                            </select>
                        </div>";
            $div .= "</div>";
        $div .= "</div>";
        $div .= "<div class='shadow_preview' style='float:left;width: calc(25% - 30px);padding:15px'>";
            $div .= "<label class='wpb_element_label'>".__("Vorschau", 'core')."</label>
                     <div class='shadow_holder' style='height:65px;margin:25px;background:#eeeeee;'></div>";
        $div .= "</div>";

        return $div;
    }
    public static function render_colorselect_control( $settings, $value, $class='wpb_vc_param_value' ) {
        $param = esc_attr($settings['param_name']);
        $old = $value == "" && isset($settings['old']) ? json_encode($settings['old']) : "";

        $div = "<input type='hidden' name='$param' class='".$class." $param colorselect_value' value='$value' />
                <div class='color_wrapper' ".($old ? "data-old='".$old."'" : "").">"
                    .self::make_type_colorselect($value).
               "</div>";
        $div .= "<div class='color_custom' style='display: ".(!empty($value) && $value != "transparent" && strpos($value, "color_") === false ? "block" : "none").";'>
                    <input type='text' name='colorselect_color_custom' value='".$value."' class='vc_color-control'>
                </div>";
        return $div;
    }
    public static function render_range_control( $settings, $value, $class='wpb_vc_param_value' ) {
        $value = str_replace(array('px','%','em'), '', $value);
        $param = esc_attr($settings['param_name']);
        $input_attrs = isset($settings['input_attrs']) ? $settings['input_attrs'] : array( "min" => 0, "max" => 100, "step" => 1 );
        $label = isset($settings['label']) ? $settings['label'] : array( "lbl" => "", "unit" => "", "factor" => 1, "delta" => 0 );
        if (!isset($label['lbl'])) $label['lbl'] = "";
        if (!isset($label['unit'])) $label['unit'] = "";
        if (!isset($label['factor'])) $label['factor'] = 1;
        if (!isset($label['delta'])) $label['delta'] = 0;

        $dir = "";
        if ($input_attrs['min'] > $input_attrs['max']) {
            $tmp = $input_attrs['min'];
            $input_attrs['min'] = $input_attrs['max'];
            $input_attrs['max'] = $tmp;
            $dir = "style='direction:rtl' ";
        }
        $atts = "min='".esc_attr($input_attrs['min'])."' max='".esc_attr($input_attrs['max'])."' step='".esc_attr($input_attrs['step'])."' ";
        $js = "jQuery(this).prev().html(\"".esc_attr($label['lbl'])."\"+(jQuery(this).val()*".esc_attr($label['factor'])."+".esc_attr($label['delta']).")+\"".esc_attr($label['unit'])."\")";
        $inlinejs = "onchange='".$js."' oninput='".$js."' ";
        
        return "<label>".esc_attr($label['lbl']).( intval($value) * intval(esc_attr($label['factor'])) + intval(esc_attr($label['delta'])) ).esc_attr($label['unit'])."</label>
                <input type='range' name='$param' class='".$class." $param' value='$value' $dir $atts $inlinejs />";
    }
    public static function make_type_colorselect($value) {
        $colors = helper::get_colors_array();
        // \processor::process_defaults();

        $first = key(array_slice($colors, 0, 1, true));
        $div = "<div class='color_thumb no_thumb ".($value == "" || $value == "transparent" ? "selected" : "")."' data-color='0' data-colormod='' title='".$first."'>
                </div>
                <div><div>";
                $i = 0;
                foreach ($colors as $title => $color) {
                    if ($i == 4 || $i == 7 || $i == 13 || $i == 14 || $i == 15)
                        $div .= "<div class='color_sep'></div>";
                    if ($i == 10)
                        $div .= "</div><div>";
                    if ($color != "transparent" && !empty($color) && $color != "color_custom") {
                        $key = '--'.str_replace("_", "", $color);
                        $col = isset(\processor::$mods[$key]) ? \processor::$mods[$key] : "";
                        $div .= "<div class='color_thumb ".($value == $color ? "selected" : "")."' data-color='".$i."' data-colormod='".$color."' title='".$title." - ".$col."'>
                                    <span class='color_grid'></span>
                                    <span class='color_th' style='background-color:".$col."'></span>
                                </div>";
                    } $i++;
                }
        $last = key(array_slice($colors, -1, 1, true));
        $div .= "</div></div>
                <div class='color_thumb no_thumb ".($value != "" && $value != "transparent" && strpos($value, "color_") === false ? "selected" : "")."' data-color='19' data-colormod='color_custom' title='".$last."'>
                </div>";
        return $div;
    }

    /*
        form field markups
    */
    public static function vc_file_picker_form_field( $settings, $value, $class='wpb_vc_param_value' ) {
        $param = esc_attr($settings['param_name']);
        $select_file_class = '';
        $remove_file_class = $json_fix = ' hidden';
        $attachment_url = wp_get_attachment_url( $value );
        if ( $attachment_url ) {
            $select_file_class = ' hidden';
            $remove_file_class = $json_fix = '';
        }
        // make preview
        $filetype = isset($settings['filetype']) ? $settings['filetype'] : 'image';
        if (!is_array($filetype)) $filetype = [ $filetype ];
        $preview = "";
        if (in_array('json', $filetype)) {
            if (strpos($attachment_url, '.json')) {
                $icon_id = 'bm_'.uniqid();
                $preview .= "<div class='file_picker_anim bm_icon $remove_file_class' id='$icon_id' data-src='$attachment_url' data-anim='auto' ></div>";
            }
            else
                $preview .= "<div class='file_picker_anim bm_icon hidden' id='' data-src='' data-anim='auto' ></div>";
        }
        if (in_array('image', $filetype)) {
            if (strpos($attachment_url, '.svg') ||
                strpos($attachment_url, '.png') ||
                strpos($attachment_url, '.jpg') ||
                strpos($attachment_url, '.gif'))
                $preview .= "<img class='file_picker_img $remove_file_class' src='$attachment_url'>";
            else
                $preview .= "<img class='file_picker_img hidden' src=''>";
        }
        $filetype = json_encode($filetype);

        return "<div class='file_picker_block'>
                    <input type='hidden' name='file_picker_type' class='file_picker_type' value='$filetype' />
                    <input type='hidden' name='$param' class='".$class." wpb-textinput $param file_picker_input' value='$value' />
                    <div class='file_picker_preview'>
                        <div class='image_grid'></div>
                        $preview
                    </div>
                    <div class='file_picker_url $remove_file_class' style='padding-bottom:10px;'>$attachment_url</div>
                    <button class='button file_picker_button $select_file_class'>".__("Auswählen", 'core')."</button>
                    <button class='button file_remover_button $remove_file_class'>".__("Entfernen", 'core')."</button>
                </div>";
    }
    public static function vc_textarea_html_form_field($settings, $value) {
        ob_start();
        wp_editor( '', 'dyn_'.uniqid(), array(
            'editor_class' => 'dynamic_html wpb_vc_param_value',
            'textarea_rows' => 10,
            'media_buttons' => true,
            'quicktags' => true,
            'tinymce' => false,
            'wpautop' => false,
        ) );
        $output_value = ob_get_contents();
        ob_end_clean();
        return $output_value;
    }
    public static function vc_textarea_form_field($settings, $value) {
        if (function_exists('vc_textarea_form_field')) 
            return vc_textarea_form_field($settings, $value);
        else return json_encode($settings);
    }
    public static function vc_textfield_form_field($settings, $value) {
        if (function_exists('vc_textfield_form_field')) 
            return vc_textfield_form_field($settings, $value);
        else return json_encode($settings);
    }
    public static function vc_vc_link_form_field($settings, $value) {
        if (function_exists('vc_vc_link_form_field')) 
            return vc_vc_link_form_field($settings, $value);
        else return json_encode($settings);
    }
    public static function vc_dropdown_form_field($settings, $value) {
        if (function_exists('vc_dropdown_form_field')) 
            return vc_dropdown_form_field($settings, $value);
        else return json_encode($settings);
    }

    /* 
        vc mods 
    */
    public function add_row_background_vc() {
        // backgrounds
        $group = __('Zeilenhintergrund', 'core');
        $pre = 'vc_bg';
        
        // vc_row backgrounds
        vc_add_params("vc_row", array_merge(array(
                array(
                    "group"         => $group,
                    "type"        => 'sub_seperator',
                    "heading"     => __('Größe', 'core'),
                    "param_name"  => 'sub_seperator_'.$pre.'_size',
                ),
                array(
                    "group"         => $group,
                    "type"          => "dropdown",
                    "heading"       => __('Hintergrundgröße', 'core'),
                    "param_name"    => $pre."_size",
                    "value"         => array(
                        _x('Standard (volle Breite)', 'small', 'core') => "vc_bg_full",
                        _x('wie Zeile', 'small', 'core') => 'vc_bg_default',
                        _x('Zeile', 'small', 'core').' S' => 'vc_bg_row_l',
                        _x('Zeile', 'small', 'core').' M' => 'vc_bg_row_xl',
                        _x('Zeile', 'small', 'core').' L' => 'vc_bg_row_xxl',
                        _x('Zeile', 'small', 'core').' XL' => 'vc_bg_row_xxxl',
                        _x('volle Breite und Höhe', 'small', 'core') => 'vc_bg_window',
                    ),
                    'edit_field_class' => 'vc_col-xs-6',
                ),
            // background
                array(
                    "group"         => $group,
                    "type"        => 'seperator',
                    "heading"     => __('Zeilenhintergrund', 'core'),
                    "param_name"  => 'seperator_'.$pre.'_type',
                ),
                // background all
                array(
                    "group"         => $group,
                    "type"        => 'new_line',
                    "param_name"  => 'new_line_background',
                ),
            ),
            helper::background_params_vc($pre, $group, true, false),
            array(
                // background image / animation / video
                array(
                    "group"         => $group,
                    "type"        => 'sub_seperator',
                    "heading"     => __('Scroll-Verhalten', 'core'),
                    "param_name"  => 'sub_seperator_'.$pre.'_scroll',
                    'dependency'  => array(
                        'element' => $pre.'_type',
                        'value' => array($pre.'_image', $pre.'_animation', $pre.'_video'),
                    ),
                ),
                array(
                    "group"         => $group,
                    "type"          => "dropdown",
                    // "heading"       => __('Scroll-Verhalten', 'core'),
                    "param_name"    => $pre."_image_scroll",
                    "value"         => array(
                        _x('mit Inhalt bewegen', 'small', 'core') => "",
                        _x('fixieren', 'small', 'core') => 'fixed',
                        _x('Parallax vertikal', 'small', 'core') => 'vparallax',
                        _x('Parallax horizontal', 'small', 'core') => 'hparallax',
                    ),
                    'dependency'  => array(
                        'element' => $pre.'_type',
                        'value' => array($pre.'_image', $pre.'_animation', $pre.'_video'),
                    ),
                    'edit_field_class' => 'vc_col-xs-4',
                ),
                array(
                    "group"         => $group,
                    'type'          => 'range',
                    'heading'       => __('Parallax Geschwindigkeit', 'core'),
                    'description'   => __('0% = fixiert bis 200% = doppelt so schnell wie normal', 'core'),
                    'param_name'    => $pre.'_image_parallax',
                    'input_attrs'   => array(
                        "min" => 100,
                        "max" => -100,
                        "step" => 1,
                    ),
                    'label'   => array(
                        "lbl" => "",
                        "unit" => "%",
                        "factor" => -1,
                        "delta" => 100,
                    ),
                    'dependency'  => array(
                        'element' => $pre.'_image_scroll',
                        'value' => array('vparallax', 'hparallax'),
                    ),
                    'edit_field_class' => 'vc_col-xs-5',
                ),
                array(
                    "group"         => $group,
                    "type"          => "checkbox",
                    "heading"       => __("Parallax auf mobilen Geräten aktivieren", 'core'),
                    "param_name"    => $pre."_image_parallax_mobile",
                    'dependency'  => array(
                        'element' => $pre.'_image_scroll',
                        'value' => array('vparallax', 'hparallax'),
                    ),
                    'edit_field_class' => 'vc_col-xs-3',
                ),
                // background all
                array(
                    "group"         => $group,
                    "type"        => 'new_line',
                    "param_name"  => 'new_line_all',
                ),
            ),            
            // background effekts
            // overlay
            array(
                array(
                    "group"         => $group,
                    "type"        => 'seperator',
                    "heading"     => __('Zeilenhintergrund überlagern', 'core'),
                    "param_name"  => 'seperator_'.$pre.'_overlay',
                ),
                array(
                    "group"         => $group,
                    "type"        => "checkbox",
                    "heading"     => __("Effekt aktivieren", 'core'),
                    "param_name"  => $pre."_overlay",
                ),
            ),
            helper::overlay_params_vc($pre, $group, $pre."_overlay", "not_empty"),
            // seperator
            array(
                array(
                    "group"         => $group,
                    "type"        => 'seperator',
                    "heading"     => __('Trenner', 'core'),
                    "param_name"  => 'seperator_'.$pre.'_sep',
                ),
                array(
                    "group"         => $group,
                    "type"        => "checkbox",
                    "heading"     => __("Effekt aktivieren", 'core'),
                    "param_name"  => $pre."_seperator",
                ),
            ),
            helper::seperator_params_vc($pre, $group, $pre."_seperator", "not_empty"),
            array(
                array(
                    'type'          => 'textarea',
                    'heading'       => __('Backend-Beschreibung', 'core'),
                    'description'   => __('Die Beschreibung dient der Übersichtlichkeit im Backend Editor.', 'core'),
                    'param_name'    => $pre.'_description',
                    // 'holder'        => 'div',
                    'group'         => __('Info', 'core'),
                ), 
            )

        )); 

    }

    public function mod_row_params_vc() {
        // update modul in tiles
        vc_map_update( "vc_row", array(
            'name'          => __('Zeile', 'core'),
            'description'   => __('Inhaltselemente in eine Zeile einbinden', 'core'),
            'icon'          => get_template_directory_uri()."/assets/icon/vc.svg"
        ));
        // remove/add some params
        vc_remove_param("vc_row", "full_width");
        $row_default = get_theme_mod('grid_row_default', 'row_xxl');
        if ($row_default == 'row_l') $row_default = " (S)";
        else if ($row_default == 'row_xl') $row_default = " (M)";
        else if ($row_default == 'row_xxl') $row_default = " (L)";
        else if ($row_default == 'row_xxxl') $row_default = " (XL)";
        else $row_default = "";
        vc_add_params("vc_row", array(
            array(
                "type"          => "seperator",
                "heading"       => __('Layout', 'core'),
                "param_name"    => "seperator_layout",
                "weight"        => 20,
            ),
            array(
                "type"          => "dropdown",
                "heading"       => __('Zeilenbreite', 'core'),
                "param_name"    => "row_type",
                "weight"        => 20,
                'edit_field_class' => 'vc_col-xs-6',
                "value"         => array(
                    _x('Standard', 'small', 'core').$row_default => "",
                    _x('Zeile', 'small', 'core').' S' => 'row_l',
                    _x('Zeile', 'small', 'core').' M' => 'row_xl',
                    _x('Zeile', 'small', 'core').' L' => 'row_xxl',
                    _x('Zeile', 'small', 'core').' XL' => 'row_xxxl',
                )
            ),
            array(
                'type'        => 'checkbox',
                'heading'     => __('Zeilenbreite überschreiben', 'core'),
                'description' => __('Wenn aktiviert, wird ab dem jeweiligen Breakpoint die Zeilenbreite auf 100% (Zeile XL) gesetzt.','core'),
                'param_name'  => 'override_type',
                "weight"        => 20,
                'value' => array(
                    __('Mobil (< 481px)', 'core') => 'override_sm',
                    __('Tablet klein (481-767px)', 'core') => 'override_md',
                    __('Tablet (768-1024px)', 'core') => 'override_lg',
                    __('Desktop (> 1024px)', 'core') => 'override_xl',
                ),
            ),
            // ...
            array(
                "type"          => "sub_seperator",
                "heading"       => __('Spalten', 'core'),
                "param_name"    => "seperator_inner_rows",
                "weight"        => 10,
            ),   
            array(
                'type'        => 'checkbox',
                'heading'     => __('Innere Spalten seitlich bündig', 'core'),
                'description' => __('Wenn aktiviert, werden die inneren Spalten nicht mehr rechts und links eingerückt.','core'),
                'param_name'  => 'ignore_inner_gutter',
                'edit_field_class' => 'vc_col-xs-4',
                "weight"        => 5,
            ),
            array(
                'type'        => 'checkbox',
                'heading'     => __('Spaltengutter überschreiben', 'core'),
                'description' => __('Wenn aktiviert, wird ab dem jeweiligen Breakpoint der Abstand zwischen den Spalten auf 0px gesetzt.','core'),
                'param_name'  => 'override_gutter',
                'edit_field_class' => 'vc_col-xs-8',
                "weight"        => 6,
                'value' => array(
                    __('Mobil (< 481px)', 'core') => 'override_sm',
                    __('Tablet klein (481-767px)', 'core') => 'override_md',
                    __('Tablet (768-1024px)', 'core') => 'override_lg',
                    __('Desktop (> 1024px)', 'core') => 'override_xl',
                ),
            ),
            // ...
            /**
             * Flexbox stretch content.
             * @since 1.0.9
             */
            array(
                'type'          => 'dropdown',
                'heading'       => __('Inhalte auf gleiche Höhe strecken', 'core'),
                'description'   => __('Spalten und Inhalte wie Content-Boxen werden auf die gleiche Höhe gestreckt.', 'core'),
                'param_name'    => 'flex_stretch_content',
                'edit_field_class' => 'vc_col-xs-4',
                "weight"        => 8,
                'value'         => array(
                    _x('nicht strecken', 'small', 'core') => '',
                    _x('ab Tablet klein (481px)', 'small', 'core') => 'sm',
                    _x('ab Tablet (768px - empfohlen)', 'small', 'core') => 'md',
                    _x('ab Desktop (1024px)', 'small', 'core') => 'lg',
                )
            ),
            // ...
            // seperator Erweitert
            // ...
            array(
                "type"          => "checkbox",
                "heading"       => __("Content Wrapper Zeile", 'core'),
                "description"   => __("Aktiviert die Content Wrapper Funktion für die Zeile.", 'core'),
                "param_name"    => "cwp",
                "admin_label"   => true,
                'edit_field_class' => 'vc_col-xs-4',
                "weight"        => -13,
            ),
            array(
                "type"    => "info_text",
                "text"    => __("Die Content Wrapper Funktion ermöglicht das Verstecken einer Zeile hinter einem Button. Wird dieser angeklickt, erscheint die versteckte Zeile anstelle des Buttons. Lege dazu einen Content Wrapper Button in die Content Wrapper Zeile und setze darunter die Zeile, die mit Klick auf den Button sichtbar werden soll.", 'core'),
                "styling" => "info", 
                "param_name" => 'info_cwp',
                "weight"        => -14,
                'dependency'  => array(
                    'element' => 'cwp',
                    'not_empty' => true,
                ),
            )
            // ...
        ));
        // update vc_row params
        // https://hotexamples.com/de/examples/-/WPBMap/-/php-wpbmap-class-examples.html
        $this->update_design_params_vc( 'vc_row' );
        $this->update_common_params_vc( 'vc_row' );
        $map = \WPBMap::getShortCode( 'vc_row' );
        foreach ( (array) $map['params'] as $params) {
            // seperator Layout (20)
            if ($params['param_name'] == 'full_height') {
                $params['heading'] = __( 'Zeile mit voller Höhe?', 'core' );
                $params['description'] = __( 'Setzt die Sektion auf volle Bildschirm-Höhe.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 19;
                vc_update_shortcode_param( 'vc_row', $params );
            }
            if ($params['param_name'] == 'columns_placement') {
                $params['heading'] = __( 'Position der Spalten', 'core' );
                $params['description'] = __( 'Anordnung der Spalten in der Zeile.', 'core' );
                $params['value'] = array(
                    _x( 'mittig', 'small', 'core' ) => 'middle',
                    _x( 'oben', 'small', 'core' ) => 'top',
                    _x( 'unten', 'small', 'core' ) => 'bottom',
                    _x( 'ausdehnen (volle Höhe)', 'small', 'core' ) => 'stretch',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 18;
                vc_update_shortcode_param( 'vc_row', $params );
            }
            // seperator Spalten (10)
            if ($params['param_name'] == 'content_placement') {
                $params['heading'] = __( 'Ausrichtung des Inhalts', 'core' );
                $params['description'] = __( 'Position des Inhalts in der Spalte.', 'core' );
                $params['value'] = array(
                    _x( 'Standard', 'small', 'core' ) => '',
                    _x( 'oben', 'small', 'core' ) => 'top',
                    _x( 'mittig', 'small', 'core' ) => 'middle',
                    _x( 'unten', 'small', 'core' ) => 'bottom',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 9;
                vc_update_shortcode_param( 'vc_row', $params );
            }
            if ($params['param_name'] == 'equal_height') {
                $params['heading'] = __( 'Gleiche Höhe?', 'core' );
                $params['description'] = "";
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 7;
                vc_update_shortcode_param( 'vc_row', $params );
            }
            // seperator Erweitert (-10)
            if ($params['param_name'] == 'disable_element') {
                $params['heading'] = __( 'Zeile ausblenden', 'core' );
                $params['description'] = __( 'Wenn aktiviert, wird die Zeile nicht öffentlich auf der Website angezeigt.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = -11;
                vc_update_shortcode_param( 'vc_row', $params );
            }
            if ($params['param_name'] == 'gap') {
                $params['heading'] = __( 'Zusätzliches Spaltengutter', 'core' );
                $params['description'] = __( 'Abstand zwischen den Spalten in einer Zeile.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = -12;
                vc_update_shortcode_param( 'vc_row', $params );
            }
            // content wrapper (-13)
        };
        
        // update vc_row_inner
        vc_map_update( "vc_row_inner", array(
            'name'          => __('Innere Zeile', 'core'),
            'description'   => __('', 'core'),
            'icon'           => get_template_directory_uri()."/assets/icon/vc.svg"
        ));
        vc_add_params("vc_row_inner", array(
            array(
                "type"          => "seperator",
                "heading"       => __('Layout', 'core'),
                "param_name"    => "seperator_layout",
                "weight"        => 20,
            ),
            array(
                'type'        => 'checkbox',
                'heading'     => __('Spaltengutter überschreiben', 'core'),
                'description' => __('Wenn aktiviert, wird ab dem jeweiligen Breakpoint der Abstand zwischen den Spalten auf 0px gesetzt.','core'),
                'param_name'  => 'override_gutter',
                // "group"         => __('Zeileneinstellungen', 'core'),
                "weight"        => 20,
                'value' => array(
                    _x('Mobil (< 481px)', 'small', 'core') => 'override_sm',
                    _x('Tablet klein (481-767px)', 'small', 'core') => 'override_md',
                    _x('Tablet (768-1024px)', 'small', 'core') => 'override_lg',
                    _x('Desktop (> 1024px)', 'small', 'core') => 'override_xl',
                ),
            ),
            // ...
        )); 
        $this->update_common_params_vc( 'vc_row_inner' );
        $map = \WPBMap::getShortCode( 'vc_row_inner' );
        foreach ( (array) $map['params'] as $params) {
            // seperator Layout (20)
            if ($params['param_name'] == 'content_placement') {
                $params['heading'] = __( 'Ausrichtung des Inhalts', 'core' );
                $params['description'] = __( 'Position des Inhalts in der Zeile.', 'core' );
                $params['value'] = array(
                    _x( 'Standard', 'small', 'core' ) => '',
                    _x( 'oben', 'small', 'core' ) => 'top',
                    _x( 'mittig', 'small', 'core' ) => 'middle',
                    _x( 'unten', 'small', 'core' ) => 'bottom',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 19;
                vc_update_shortcode_param( 'vc_row_inner', $params );
            }
            if ($params['param_name'] == 'equal_height') {
                $params['heading'] = __( 'Gleiche Höhe?', 'core' );
                $params['description'] = "";
                $params['edit_field_class'] = "vc_col-xs-8";
                $params['weight'] = 18;
                vc_update_shortcode_param( 'vc_row_inner', $params );
            }
            // seperator Erweitert (-10)
            if ($params['param_name'] == 'disable_element') {
                $params['heading'] = __( 'Zeile ausblenden', 'core' );
                $params['description'] = __( 'Wenn aktiviert, wird die Zeile nicht öffentlich auf der Website angezeigt.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-6";
                $params['weight'] = -11;
                vc_update_shortcode_param( 'vc_row_inner', $params );
            }
            if ($params['param_name'] == 'gap') {
                $params['heading'] = __( 'Spaltenabstand', 'core' );
                $params['description'] = __( 'Abstand zwischen den Spalten in einer Zeile.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-6";
                $params['weight'] = -12;
                vc_update_shortcode_param( 'vc_row_inner', $params );
            }
        };

        // update vc_section
        vc_map_update( "vc_section", array(
            'name'          => __('Inhaltsbereich', 'core'),
            'description'   => __('Zeilen in Bereiche gruppieren', 'core'),
            'icon'          => get_template_directory_uri()."/assets/icon/section.svg"
        ));
        vc_remove_param("vc_section", "full_width");
        vc_add_params("vc_section", array(
            array(
                "type"          => "seperator",
                "heading"       => __('Layout', 'core'),
                "param_name"    => "seperator_layout",
                "weight"        => 20,
            ),
            // ...
        ));
        $this->update_design_params_vc( 'vc_section' );
        $this->update_common_params_vc( 'vc_section' );
        $map = \WPBMap::getShortCode( 'vc_section' );
        foreach ( (array) $map['params'] as $params) {
            // seperator Layout (20)
            if ($params['param_name'] == 'full_height') {
                $params['heading'] = __( 'Inhaltsbereich mit voller Höhe?', 'core' );
                $params['description'] = __( 'Setzt den Bereich auf volle Bildschirmhöhe.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 19;
                vc_update_shortcode_param( 'vc_section', $params );
            }
            if ($params['param_name'] == 'content_placement') {
                $params['heading'] = __( 'Ausrichtung des Inhalts', 'core' );
                $params['description'] = __( '', 'core' );
                $params['value'] = array(
                    _x( 'Standard (oben)', 'small', 'core' ) => '',
                    _x( 'oben', 'small', 'core' ) => 'top',
                    _x( 'mittig', 'small', 'core' ) => 'middle',
                    _x( 'unten', 'small', 'core' ) => 'bottom',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 9;
                vc_update_shortcode_param( 'vc_section', $params );
            }
            // seperator Erweitert (-10)
            if ($params['param_name'] == 'disable_element') {
                $params['heading'] = __( 'Inhaltsbereich ausblenden', 'core' );
                $params['description'] = __( 'Wenn aktiviert, wird der Bereich nicht öffentlich auf der Website angezeigt.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-12";
                $params['weight'] = -11;
                vc_update_shortcode_param( 'vc_section', $params );
            }
        }

        // update vc_tta_accordion
        vc_map_update( "vc_tta_accordion", array(
            'name'          => __('Akkordeon', 'core'),
            'description'   => __('Zusammenklappbare Inhalte', 'core'),
            'icon'          => get_template_directory_uri()."/assets/icon/accordion.svg"
        ));
        vc_remove_param("vc_tta_accordion", "title");
        vc_remove_param("vc_tta_accordion", "css_animation");
        vc_add_params("vc_tta_accordion", array(
            array(
                "type"          => "seperator",
                "heading"       => __('Layout', 'core'),
                "param_name"    => "seperator_layout",
                "weight"        => 20,
            ),
            // ...
            array(
                "type"          => "seperator",
                "heading"       => __('Darstellung', 'core'),
                "param_name"    => "seperator_design",
                "weight"        => 10,
            ),
            // ...
        ) ); 
        $this->update_common_params_vc( 'vc_tta_accordion' );
        $map = \WPBMap::getShortCode( 'vc_tta_accordion' );
        // debug($map);
        foreach ( (array) $map['params'] as $params) {
            // seperator Layout (20)
            if ($params['param_name'] == 'active_section') {
                $params['heading'] = __( 'Akkordeon Bereich', 'core' );
                $params['description'] = __( 'Welcher Abschnitt soll initial ausgeklappt sein? (Hinweis: Wenn alle Abschnitte beim ersten Laden geschlossen sein sollen, gib eine nicht vorhandene Nummer ein)', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 19;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'autoplay') {
                $params['heading'] = __( 'Autoplay', 'core' );
                $params['description'] = __( 'Nach wie vielen Sekunden soll automatisch der nächste Abschnitt angezeigt werden? (Standard: aus)', 'core' );
                foreach( (array) $params['value'] as $k => $val) {
                    if ($val === 'none') unset($params['value'][$k]);
                    $params['value'] = array_merge(array(__('aus','core') => 'none'), $params['value']);
                }
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 18;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'collapsible_all') {
                $params['heading'] = __( 'Alle schließen', 'core' );
                $params['description'] = __( 'Erlaubt dem Nutzer, alle Bereiche einzuklappen.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 17;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'spacing') {
                $params['type'] = 'textfield';
                $params['heading'] = __( 'Abstand Titel', 'core' );
                $params['description'] = __( 'Abstand zum Inhaltselement. (Einheit: in px)', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 16;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'gap') {
                $params['type'] = 'textfield';
                $params['heading'] = __( 'Abstand Abschnitt', 'core' );
                $params['description'] = __( 'Abstand unter dem Inhaltselement. (Einheit: in px)', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 15;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'c_align') {
                $params['heading'] = __( 'Ausrichtung Titel', 'core' );
                $params['description'] = '';
                $params['value'] = array(
                    _x( 'linksbündig', 'small', 'core' ) => 'left',
                    _x( 'zentriert', 'small', 'core' ) => 'center',
                    _x( 'rechtsbündig', 'small', 'core' ) => 'right',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 14;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            // seperator Darstellung (10)
            if ($params['param_name'] == 'style') {
                $params['heading'] = __( 'Stil', 'core' );
                $params['description'] = __( '', 'core' );
                $params['value'] = array(
                    _x( 'klassisch', 'small', 'core' ) => 'classic',
                    _x( 'modern', 'small', 'core' ) => 'modern',
                    _x( 'flach', 'small', 'core' ) => 'flat',
                    _x( 'umrandet', 'small', 'core' ) => 'outline',
                );
                $params['edit_field_class'] = "vc_col-xs-6";
                $params['weight'] = 9;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'shape') {
                $params['heading'] = __( 'Form', 'core' );
                $params['description'] = __( '', 'core' );
                $params['value'] = array(
                    _x( 'abgerundet', 'small', 'core' ) => 'rounded',
                    _x( 'eckig', 'small', 'core' ) => 'square',
                    _x( 'rund', 'small', 'core' ) => 'round',
                );
                $params['edit_field_class'] = "vc_col-xs-6";
                $params['weight'] = 8;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'color') {
                $params['heading'] = __( 'Hintergrundfarbe', 'core' );
                $params['description'] = __( '', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 7;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'no_fill') {
                $params['heading'] = __( 'Inhaltsbereich nicht füllen?', 'core' );
                $params['description'] = __( '', 'core' );
                $params['edit_field_class'] = "vc_col-xs-8";
                $params['weight'] = 6;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }

            if ($params['param_name'] == 'c_icon') {
                $params['heading'] = __( 'Navigations-Icon', 'core' );
                $params['description'] = __( '', 'core' );
                $params['value'] = array(
                    _x( 'kein Icon', 'small', 'core' ) => '',
                    _x( 'Pfeil', 'small', 'core' ) => 'chevron',
                    _x( 'Plus', 'small', 'core' ) => 'plus',
                    _x( 'Dreieck', 'small', 'core' ) => 'triangle',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 5;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            if ($params['param_name'] == 'c_position') {
                $params['heading'] = __( 'Icon Position', 'core' );
                $params['description'] = __( '', 'core' );
                $params['value'] = array(
                    _x( 'links', 'small', 'core' ) => 'left',
                    _x( 'rechts', 'small', 'core' ) => 'right',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 4;
                vc_update_shortcode_param( 'vc_tta_accordion', $params );
            }
            // seperator Erweitert (-10)
        }

        // update vc_tta_section
        vc_map_update( "vc_tta_section", array(
            'name'          => __('Inhaltsbereich', 'core'),
            'description'   => __('', 'core'),
            'icon'          => get_template_directory_uri()."/assets/icon/accordion.svg"
        ));
        vc_add_params("vc_tta_section", array(
            array(
                "type"          => "seperator",
                "heading"       => __('Titel', 'core'),
                "param_name"    => "seperator_title",
                "weight"        => 20,
            ),
            // ...
        ));
        $this->update_common_params_vc( 'vc_tta_section' );
        $map = \WPBMap::getShortCode( 'vc_tta_section' );
        foreach ( (array) $map['params'] as $params) {
            // seperator Titel (20)
            if ($params['param_name'] == 'title') {
                $params['heading'] = __( 'Titel', 'core' );
                $params['description'] = __( 'Hinweis: Lasse das Feld leer, um keinen Titel anzuzeigen.', 'core' );
                $params['edit_field_class'] = "vc_col-xs-12";
                $params['weight'] = 19;
                vc_update_shortcode_param( 'vc_tta_section', $params );
            }
            if ($params['param_name'] == 'add_icon') {
                $params['heading'] = __( 'Icon hinzufügen?', 'core' );
                $params['description'] = __( '', 'core' );
                $params['edit_field_class'] = "vc_col-xs-12";
                $params['weight'] = 10;
                vc_update_shortcode_param( 'vc_tta_section', $params );
            }
            if ($params['param_name'] == 'i_type') {
                $params['heading'] = __( 'Icon Bibliothek', 'core' );
                $params['description'] = __( '', 'core' );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 9;
                vc_update_shortcode_param( 'vc_tta_section', $params );
            }
            if ($params['param_name'] == 'i_icon_fontawesome' ||
                $params['param_name'] == 'i_icon_openiconic' ||
                $params['param_name'] == 'i_icon_typicons' ||
                $params['param_name'] == 'i_icon_entypo' ||
                $params['param_name'] == 'i_icon_linecons' ||
                $params['param_name'] == 'i_icon_monosocial' ||
                $params['param_name'] == 'i_icon_material' ) {
                $params['heading'] = __( 'Icon', 'core' );
                $params['description'] = __( 'Icon aus Bibliothek auswählen', 'core' );
                $params['edit_field_class'] = "vc_col-xs-8";
                $params['weight'] = 8;
                vc_update_shortcode_param( 'vc_tta_section', $params );
            }
            if ($params['param_name'] == 'i_position') {
                $params['heading'] = __( 'Icon Position', 'core' );
                $params['description'] = __( '', 'core' );
                $params['value'] = array(
                    _x( 'vor dem Titel', 'small', 'core' ) => 'left',
                    _x( 'hinter dem Titel', 'small', 'core' ) => 'right',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = 7;
                vc_update_shortcode_param( 'vc_tta_section', $params );
            }
            // seperator Erweitert (-10)
            if ($params['param_name'] == 'tab_id') {
                $params['heading'] = __( 'Inhaltsbereich ID', 'core' );
                $params['description'] = sprintf( __( "Eindeutige ID für individuelle CSS Anpassungen (Hinweis: Bitte Spezifikationen beachten: <a href='%s' target='_blank'>w3c specification</a>).", 'core' ), 'http://www.w3schools.com/tags/att_global_id.asp' );
                $params['edit_field_class'] = "vc_col-xs-6";
                $params['weight'] = -20;
                vc_update_shortcode_param( 'vc_tta_section', $params );
            }
        }

    }

    public function mod_column_params_vc() {

        // update vc_column
        $this->update_design_params_vc( 'vc_column' );
        $this->update_common_params_vc( 'vc_column' );
        $map = \WPBMap::getShortCode( 'vc_column' );
        foreach ( (array) $map['params'] as $params) {
            // seperator Erweitert (-10)
            // group responsive (-30)
            if ($params['param_name'] == 'width') {
                $params['heading'] = __( 'Breite', 'core' );
                $params['description'] = __( 'Wähle die Anzahl der Spalten.', 'core' );
                $params['group'] = __( 'Responsive Options', 'core' );
                $params['weight'] = -30;
                vc_update_shortcode_param( 'vc_column', $params );
            }
            if ($params['param_name'] == 'offset') {
                $params['heading'] = __( 'Darstellung je Breakpoint', 'core' );
                $params['description'] = __( 'Passe die Spalte für verschiedene Bildschirmgrößen an, indem du Breite, Versatz und Sichtbarkeit bestimmst.', 'core' );
                $params['group'] = __( 'Responsive Options', 'core' );
                $params['weight'] = -31;
                vc_update_shortcode_param( 'vc_column', $params );
            }
        }

        // update vc_column_inner
        $this->update_common_params_vc( 'vc_column_inner' );
        $map = \WPBMap::getShortCode( 'vc_column_inner' );
        foreach ( (array) $map['params'] as $params) {
            // seperator Erweitert (-10)
            // group responsive (-30)
            if ($params['param_name'] == 'width') {
                $params['heading'] = __( 'Breite', 'core' );
                $params['description'] = __( 'Wähle die Anzahl der Spalten.', 'core' );
                $params['group'] = __( 'Responsive Options', 'core' );
                $params['weight'] = -30;
                vc_update_shortcode_param( 'vc_column_inner', $params );
            }
            if ($params['param_name'] == 'offset') {
                $params['heading'] = __( 'Responsiveness', 'core' );
                $params['description'] = __( 'Passe die Spalte für verschiedene Bildschirmgrößen an, indem du Breite, Versatz und Sichtbarkeit bestimmst.', 'core' );
                $params['group'] = __( 'Responsive Options', 'core' );
                $params['weight'] = -31;
                vc_update_shortcode_param( 'vc_column_inner', $params );
            }
        }

        // update vc_column_text
        vc_map_update( "vc_column_text", array(
            'name'          => __('Text', 'core'),
            'description'   => __('Konfigurierbarer Textbereich', 'core'),
            'icon'           => get_template_directory_uri()."/assets/icon/txt.svg"
        ));
        vc_add_params( "vc_column_text", array(
            // dynamic text
            array(
                'type'          => 'dynamic',
                'param_name'    => 'dynamic_content',
                'heading'       => __( 'Typ', 'core' ),
                'text'          => __('Indem du Inhalte von Modulen in Templates dynamisch machst, kannst du diese beim späteren Einbinden in eine Seite befüllen. Dadurch kannst du das Template an verschiedenen Stellen mit unterschiedlichen Inhalten verwenden.', 'core'),
                'value'         => 'static',
                'params'        => array(
                    'type' => 'textarea_html',
                    'field' => 'content',
                ),
                'edit_field_class' => 'vc_col-xs-12',
                "weight"        => 1,
            ),
            // ...
        ) ); 
        $this->update_common_params_vc( 'vc_column_text' );
        $map = \WPBMap::getShortCode( 'vc_column_text' );
        foreach ( (array) $map['params'] as $params) {
            if ($params['param_name'] == 'content') {
                $params['heading'] = __( 'Text', 'core' );
                $params['value'] = '<p>'.__( 'Ich bin ein Textblock.', 'core' ).' Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.</p>';
                $params['weight'] = 0;
                vc_update_shortcode_param( 'vc_column_text', $params );
            }
            // seperator Erweitert (-10)
        }

    }

    public function mod_default_params_vc() {

        // update vc_video
        vc_map_update( "vc_video", array(
            'name'          => __('Video', 'core'),
            'description'   => __('Videos von YouTube / Vimeo einbinden', 'core'),
            'icon'          => get_template_directory_uri()."/assets/icon/video.svg"
        ) );
        vc_remove_param( "vc_video", "title" );
        vc_add_params( "vc_video", array(
            array(
                "type"          => "seperator",
                "heading"       => __('Darstellung', 'core'),
                "param_name"    => "seperator_basic",
                "weight"        => 0,
            ),
            // dynamic link
            array(
                'type'          => 'dynamic',
                'param_name'    => 'dynamic_link',
                'heading'       => __( 'Typ', 'core' ),
                'text'          => __('Indem du Inhalte von Modulen in Templates dynamisch machst, kannst du diese beim späteren Einbinden in eine Seite befüllen. Dadurch kannst du das Template an verschiedenen Stellen mit unterschiedlichen Inhalten verwenden.', 'core'),
                'value'         => 'static',
                'params'        => array(
                    'type' => 'textfield',
                    'field' => 'link',
                ),
                'edit_field_class' => 'vc_col-xs-12',
                "weight"        => 0,
            ),
            // ...
            array(
                "type"          => "checkbox",
                "heading"       => __('Zeige allgemeine YouTube Vorschläge nach dem Video', 'core'),
                "description"   => __('Standardmäßig werden nur Videos aus dem dazugehörigen Channel vorgeschlagen.', 'core'),
                "param_name"    => "rel",
                'edit_field_class' => 'vc_col-xs-6',
                "weight"        => -2,
            )
            // ...
        ) ); 
        $this->update_common_params_vc( 'vc_video' );
        $map = \WPBMap::getShortCode( 'vc_video' );
        foreach ( (array) $map['params'] as $params) {
            // seperator Darstellung (0)
            if ($params['param_name'] == 'link') {
                $params['heading'] = __( 'Video Link', 'core' );
                $params['description'] = sprintf( __( 'Informationen zu möglichen Formaten findest du im WordPress Codex <a href="%s" target="_blank">codex page</a>.', 'core' ), 'http://codex.wordpress.org/Embeds#Okay.2C_So_What_Sites_Can_I_Embed_From.3F' );
                $params['edit_field_class'] = "vc_col-xs-6";
                $params['weight'] = -1;
                vc_update_shortcode_param( 'vc_video', $params );
            }
            // checkbox rel (-2)
            if ($params['param_name'] == 'el_width') {
                $params['heading'] = __( 'Breite', 'core' );
                $params['description'] = "";
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = -3;
                vc_update_shortcode_param( 'vc_video', $params );
            }
            if ($params['param_name'] == 'el_aspect') {
                $params['heading'] = __( 'Format', 'core' );
                $params['description'] = "";
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = -4;
                vc_update_shortcode_param( 'vc_video', $params );
            }
            if ($params['param_name'] == 'align') {
                $params['heading'] = __( 'Ausrichtung', 'core' );
                $params['description'] = "";
                $params['value'] = array(
                    _x( 'linksbündig', 'small', 'core' ) => 'left',
                    _x( 'rechtsbündig', 'small', 'core' ) => 'right',
                    _x( 'zentriert', 'small', 'core' ) => 'center',
                );
                $params['edit_field_class'] = "vc_col-xs-4";
                $params['weight'] = -5;
                vc_update_shortcode_param( 'vc_video', $params );
            }
            // seperator Erweitert (-10)
        }
        
        // update vc_raw_html
        vc_map_update( "vc_raw_html", array(
            'name'          => __('HTML', 'core'),
            'description'   => __('Ungefilterter HTML Code', 'core'),
            'icon'          => get_template_directory_uri()."/assets/icon/wp.svg"
        ));
        $this->update_common_params_vc( 'vc_raw_html' );
        $map = \WPBMap::getShortCode( 'vc_raw_html' );
        foreach ( (array) $map['params'] as $params) {
            if ($params['param_name'] == 'content') {
                $params['description'] =  __( 'Gib hier deinen HTML Inhalt ein.', 'core' );
                vc_update_shortcode_param( 'vc_raw_html', $params );
            }
        }

        // update vc_raw_js
        vc_map_update( "vc_raw_js", array(
            'name'          => __('JavaScript', 'core'),
            'description'   => __('Ungefilterter JavaScript Code', 'core'),
            'icon'          => get_template_directory_uri()."/assets/icon/wp.svg"
        ));
        $this->update_common_params_vc( 'vc_raw_js' );
        $map = \WPBMap::getShortCode( 'vc_raw_js' );
        foreach ( (array) $map['params'] as $params) {
            if ($params['param_name'] == 'content') {
                $params['description'] =  __( 'Gib hier deinen JavaScript Inhalt ein.', 'core' );
                vc_update_shortcode_param( 'vc_raw_js', $params );
            }
        }

        // update vc_gutenberg
        vc_map_update( "vc_gutenberg", array(
            'name'          => __('Gutenberg', 'core'),
            'description'   => __('Gutenberg Editor einbinden', 'core'),
            "deprecated"    => "0.8.4",
            'icon'          => get_template_directory_uri()."/assets/icon/gutenberg.svg"
        ));
        $this->update_common_params_vc( 'vc_gutenberg' );

    }

    public function mod_youtube_player( $html, $url, $args ) {
        // debug($args);
        if (strpos($html, 'youtube') != FALSE && isset($args['rel']) && $args['rel'] != 1)
            $html = str_replace( '?feature=oembed', '?feature=oembed&rel=0', $html );
        return $html;
    }
    
    public function update_design_params_vc($base) {
        // remove params
        vc_remove_param( $base, "video_bg" );
        vc_remove_param( $base, "video_bg_url" );
        vc_remove_param( $base, "video_bg_parallax" );
        vc_remove_param( $base, "parallax" );
        vc_remove_param( $base, "parallax_speed_video" );
        vc_remove_param( $base, "parallax_speed_bg" );
        vc_remove_param( $base, "parallax_image" );
    }
    public function update_common_params_vc($base) {
        // add seperator
        vc_remove_param( $base, "rtl_reverse" );
        vc_add_params( $base, array(
            // ...
            array(
                "type"          => "seperator",
                "heading"       => __('Erweitert', 'core'),
                "param_name"    => "seperator_more",
                "weight"        => -10,
            )
            // ...
        )); 
        // update default params
        $map = \WPBMap::getShortCode( $base );
        // debug($map);
        foreach ( (array) $map['params'] as $params) {
            if ($params['param_name'] == 'css_animation') {
                // debug($params);
                $params['heading'] = __( 'CSS Animation', 'core' );
                $params['description'] = __( 'Wie soll das Element animiert werden, wenn es im Browser Bildschirm erscheint? (Hinweis: funktioniert nur mit modernen Browsern)', 'core' );
                $params['edit_field_class'] = "vc_col-xs-12";
                $params['weight'] = -9;
                $params['settings']['custom'] = array(
                    array(
                        'label' => __( 'Default2', 'core' ),
                        'values' => array(
                            _x( 'von oben nach unten', 'small', 'core' ) => 'top-to-bottom',
                            _x( 'von unten nach oben', 'small', 'core' ) => 'bottom-to-top',
                            _x( 'von links nach rechts', 'small', 'core' ) => 'left-to-right',
                            _x( 'von rechts nach links', 'small', 'core' ) => 'right-to-left',
                            _x( 'aufzoomen', 'small', 'core' ) => 'appear',
                        )
                    ),
                );
                vc_update_shortcode_param( $base, $params );
            }
            // seperator Erweitert (-10)
            if ($params['param_name'] == 'el_id') {
                $params['heading'] = __( 'Element ID', 'core' );
                $params['description'] = sprintf( __( "Eindeutige ID für individuelle CSS Anpassungen (Hinweis: Bitte Spezifikationen beachten: <a href='%s' target='_blank'>w3c specification</a>).", 'core' ), 'http://www.w3schools.com/tags/att_global_id.asp' );
                $params['edit_field_class'] = "vc_col-xs-6";
                $params['weight'] = -20;
                vc_update_shortcode_param( $base, $params );
            }
            if ($params['param_name'] == 'el_class') {
                $params['heading'] = __( 'CSS Klasse', 'core' );
                $params['description'] = __( 'Gestalte dieses Element individuell - vergebe einen Klassennamen und beziehe dich in deinem CSS darauf (Hinweis: Eingabe ohne Punkt oder Raute davor).', 'core' );
                $params['edit_field_class'] = "vc_col-xs-6";
                $params['weight'] = -21;
                vc_update_shortcode_param( $base, $params );
            }
            // group design (-25)
            if ($params['param_name'] == 'css') {
                $params['heading'] = __( 'CSS Box', 'core' );
                $params['description'] = __( '', 'core' );
                $params['edit_field_class'] = "vc_col-xs-12";
                $params['weight'] = -26;
                $params['group'] = __( 'Design', 'core' );
                vc_update_shortcode_param( $base, $params );
            }
        }
    }
    public function mod_css_animation($styles) {
        return array(
            array(
                'values' => array(
                    __( 'keine', 'core' ) => 'none',
                ),
            ),
            array(
                'label' => __( 'Attention Seekers', 'core' ),
                'values' => array(
                    __( 'bounce', 'core' ) => array( 'value' => 'bounce', 'type' => 'other' ),
                    __( 'flash', 'core' ) => array( 'value' => 'flash', 'type' => 'other' ),
                    __( 'pulse', 'core' ) => array( 'value' => 'pulse', 'type' => 'other' ),
                    __( 'rubberBand', 'core' ) => array( 'value' => 'rubberBand', 'type' => 'other' ),
                    __( 'shake', 'core' ) => array( 'value' => 'shake', 'type' => 'other' ),
                    __( 'swing', 'core' ) => array( 'value' => 'swing', 'type' => 'other' ),
                    __( 'tada', 'core' ) => array( 'value' => 'tada', 'type' => 'other' ),
                    __( 'wobble', 'core' ) => array( 'value' => 'wobble', 'type' => 'other' ),
                ),
            ),
            array(
                'label' => __( 'Bounce Animationen', 'core' ),
                'values' => array(
                    __( 'bounceIn', 'core' ) => array( 'value' => 'bounceIn', 'type' => 'in' ),
                    __( 'bounceInDown', 'core' ) => array( 'value' => 'bounceInDown', 'type' => 'in' ),
                    __( 'bounceInLeft', 'core' ) => array( 'value' => 'bounceInLeft', 'type' => 'in' ),
                    __( 'bounceInRight', 'core' ) => array( 'value' => 'bounceInRight', 'type' => 'in' ),
                    __( 'bounceInUp', 'core' ) => array( 'value' => 'bounceInUp', 'type' => 'in' ),
                ),
            ),
            array(
                'label' => __( 'Bouncing Exits', 'core' ),
                'values' => array(
                    __( 'bounceOut', 'core' ) => array( 'value' => 'bounceOut', 'type' => 'out' ),
                    __( 'bounceOutDown', 'core' ) => array( 'value' => 'bounceOutDown', 'type' => 'out' ),
                    __( 'bounceOutLeft', 'core' ) => array( 'value' => 'bounceOutLeft', 'type' => 'out' ),
                    __( 'bounceOutRight', 'core' ) => array( 'value' => 'bounceOutRight', 'type' => 'out' ),
                    __( 'bounceOutUp', 'core' ) => array( 'value' => 'bounceOutUp', 'type' => 'out' ),
                ),
            ),
            array(
                'label' => __( 'Fade Animationen', 'core' ),
                'values' => array(
                    __( 'fadeIn', 'core' ) => array( 'value' => 'fadeIn', 'type' => 'in' ),
                    __( 'fadeInDown', 'core' ) => array( 'value' => 'fadeInDown', 'type' => 'in' ),
                    __( 'fadeInDownBig', 'core' ) => array( 'value' => 'fadeInDownBig', 'type' => 'in' ),
                    __( 'fadeInLeft', 'core' ) => array( 'value' => 'fadeInLeft', 'type' => 'in' ),
                    __( 'fadeInLeftBig', 'core' ) => array( 'value' => 'fadeInLeftBig', 'type' => 'in' ),
                    __( 'fadeInRight', 'core' ) => array( 'value' => 'fadeInRight', 'type' => 'in' ),
                    __( 'fadeInRightBig', 'core' ) => array( 'value' => 'fadeInRightBig', 'type' => 'in' ),
                    __( 'fadeInUp', 'core' ) => array( 'value' => 'fadeInUp', 'type' => 'in' ),
                    __( 'fadeInUpBig', 'core' ) => array( 'value' => 'fadeInUpBig', 'type' => 'in' ),
                ),
            ),
            array(
                'label' => __( 'Fading Exits', 'core' ),
                'values' => array(
                    __( 'fadeOut', 'core' ) => array( 'value' => 'fadeOut', 'type' => 'out' ),
                    __( 'fadeOutDown', 'core' ) => array( 'value' => 'fadeOutDown', 'type' => 'out' ),
                    __( 'fadeOutDownBig', 'core' ) => array( 'value' => 'fadeOutDownBig', 'type' => 'out' ),
                    __( 'fadeOutLeft', 'core' ) => array( 'value' => 'fadeOutLeft', 'type' => 'out' ),
                    __( 'fadeOutLeftBig', 'core' ) => array( 'value' => 'fadeOutLeftBig', 'type' => 'out' ),
                    __( 'fadeOutRight', 'core' ) => array( 'value' => 'fadeOutRight', 'type' => 'out' ),
                    __( 'fadeOutRightBig', 'core' ) => array( 'value' => 'fadeOutRightBig', 'type' => 'out' ),
                    __( 'fadeOutUp', 'core' ) => array( 'value' => 'fadeOutUp', 'type' => 'out' ),
                    __( 'fadeOutUpBig', 'core' ) => array( 'value' => 'fadeOutUpBig', 'type' => 'out' ),
                ),
            ),
            array(
                'label' => __( 'Flipper', 'core' ),
                'values' => array(
                    __( 'flip', 'core' ) => array( 'value' => 'flip', 'type' => 'other' ),
                    __( 'flipInX', 'core' ) => array( 'value' => 'flipInX', 'type' => 'in' ),
                    __( 'flipInY', 'core' ) => array( 'value' => 'flipInY', 'type' => 'in' ),
                    __( 'flipOutX', 'core' ) => array( 'value' => 'flipOutX', 'type' => 'out' ),
                    __( 'flipOutY', 'core' ) => array( 'value' => 'flipOutY', 'type' => 'out' ),
                ),
            ),
            array(
                'label' => __( 'Lightspeed', 'core' ),
                'values' => array(
                    __( 'lightSpeedIn', 'core' ) => array( 'value' => 'lightSpeedIn', 'type' => 'in' ),
                    __( 'lightSpeedOut', 'core' ) => array( 'value' => 'lightSpeedOut', 'type' => 'out' ),
                ),
            ),
            array(
                'label' => __( 'Drehende Animationen', 'core' ),
                'values' => array(
                    __( 'rotateIn', 'core' ) => array( 'value' => 'rotateIn', 'type' => 'in' ),
                    __( 'rotateInDownLeft', 'core' ) => array( 'value' => 'rotateInDownLeft', 'type' => 'in' ),
                    __( 'rotateInDownRight', 'core' ) => array( 'value' => 'rotateInDownRight', 'type' => 'in' ),
                    __( 'rotateInUpLeft', 'core' ) => array( 'value' => 'rotateInUpLeft', 'type' => 'in' ),
                    __( 'rotateInUpRight', 'core' ) => array( 'value' => 'rotateInUpRight', 'type' => 'in' ),
                ),
            ),
            array(
                'label' => __( 'Rotating Exits', 'core' ),
                'values' => array(
                    __( 'rotateOut', 'core' ) => array( 'value' => 'rotateOut', 'type' => 'out' ),
                    __( 'rotateOutDownLeft', 'core' ) => array( 'value' => 'rotateOutDownLeft', 'type' => 'out' ),
                    __( 'rotateOutDownRight', 'core' ) => array( 'value' => 'rotateOutDownRight', 'type' => 'out' ),
                    __( 'rotateOutUpLeft', 'core' ) => array( 'value' => 'rotateOutUpLeft', 'type' => 'out' ),
                    __( 'rotateOutUpRight', 'core' ) => array( 'value' => 'rotateOutUpRight', 'type' => 'out' ),
                ),
            ),
            array(
                'label' => __( 'Specials', 'core' ),
                'values' => array(
                    __( 'hinge', 'core' ) => array( 'value' => 'hinge', 'type' => 'out' ),
                    __( 'rollIn', 'core' ) => array( 'value' => 'rollIn', 'type' => 'in' ),
                    __( 'rollOut', 'core' ) => array( 'value' => 'rollOut', 'type' => 'out' ),
                ),
            ),
            array(
                'label' => __( 'Zoom Animationen', 'core' ),
                'values' => array(
                    __( 'zoomIn', 'core' ) => array( 'value' => 'zoomIn', 'type' => 'in' ),
                    __( 'zoomInDown', 'core' ) => array( 'value' => 'zoomInDown', 'type' => 'in' ),
                    __( 'zoomInLeft', 'core' ) => array( 'value' => 'zoomInLeft', 'type' => 'in' ),
                    __( 'zoomInRight', 'core' ) => array( 'value' => 'zoomInRight', 'type' => 'in' ),
                    __( 'zoomInUp', 'core' ) => array( 'value' => 'zoomInUp', 'type' => 'in' ),
                ),
            ),
            array(
                'label' => __( 'Zoom Exits', 'core' ),
                'values' => array(
                    __( 'zoomOut', 'core' ) => array( 'value' => 'zoomOut', 'type' => 'out' ),
                    __( 'zoomOutDown', 'core' ) => array( 'value' => 'zoomOutDown', 'type' => 'out' ),
                    __( 'zoomOutLeft', 'core' ) => array( 'value' => 'zoomOutLeft', 'type' => 'out' ),
                    __( 'zoomOutRight', 'core' ) => array( 'value' => 'zoomOutRight', 'type' => 'out' ),
                    __( 'zoomOutUp', 'core' ) => array( 'value' => 'zoomOutUp', 'type' => 'out' ),
                ),
            ),
            array(
                'label' => __( 'Slide Animationen', 'core' ),
                'values' => array(
                    __( 'slide In Down', 'core' ) => array( 'value' => 'slideInDown', 'type' => 'in' ),
                    __( 'slide In Left', 'core' ) => array( 'value' => 'slideInLeft', 'type' => 'in' ),
                    __( 'slide In Right', 'core' ) => array( 'value' => 'slideInRight', 'type' => 'in' ),
                    __( 'slide In Up', 'core' ) => array( 'value' => 'slideInUp', 'type' => 'in' ),
                ),
            ),
            array(
                'label' => __( 'Slide Exits', 'core' ),
                'values' => array(
                    __( 'slideOutDown', 'core' ) => array( 'value' => 'slideOutDown', 'type' => 'out' ),
                    __( 'slideOutLeft', 'core' ) => array( 'value' => 'slideOutLeft', 'type' => 'out' ),
                    __( 'slideOutRight', 'core' ) => array( 'value' => 'slideOutRight', 'type' => 'out' ),
                    __( 'slideOutUp', 'core' ) => array( 'value' => 'slideOutUp', 'type' => 'out' ),
                ),
            ),
        );
    }

    
    public function mod_dynamic_vc() {
        
        if (get_post_type() == 'dynamic_template') {
            $template_type = get_the_terms(get_the_ID(), 'template_type')[0]->slug;
            if ($template_type == 'single') {
                vc_remove_element( "vc_posts_tp" );
                vc_remove_element( "vc_posts_details_tp" );
                vc_remove_element( "vc_copyright" );
            }
            else if ($template_type == 'archives' || $template_type == 'search') {
                vc_remove_element( "vc_post_tp" );
                vc_remove_element( "vc_copyright" );
            }
            else if ($template_type == 'navigation') {
                vc_remove_element( "vc_post_tp" );
                vc_remove_element( "vc_posts_tp" );
                vc_remove_element( "vc_posts_details_tp" );
            }
            else {
                vc_remove_element( "vc_post_tp" );
                vc_remove_element( "vc_posts_tp" );
                vc_remove_element( "vc_posts_details_tp" );
                vc_remove_element( "vc_copyright" );
            }
        }
        else {
            vc_remove_element( "vc_post_tp" );
            vc_remove_element( "vc_posts_tp" );
            vc_remove_element( "vc_posts_details_tp" );
            vc_remove_element( "vc_copyright" );
        }

    }
    public function mod_defaults_vc() {
        if ( !is_admin() ) return;
        
        if(!is_callable('vc_remove_element')) return;
        if(!is_callable('vc_map_update')) return;

        /* plugins */
        vc_map_update("contact-form-7", array('icon' => get_template_directory_uri()."/assets/icon/cf7.svg",));
        vc_map_update("rev_slider_vc", array('icon' => get_template_directory_uri()."/assets/icon/rev.svg",));
        vc_map_update("rev_slider", array('icon' => get_template_directory_uri()."/assets/icon/rev.svg",));

        /* remove social media */
        vc_remove_element( "vc_facebook" );
        vc_remove_element( "vc_tweetmeme" );
        vc_remove_element( "vc_googleplus" );
        vc_remove_element( "vc_pinterest" );

        /* remove and update inhalt */
        //vc_remove_element( "vc_section" );
        //vc_remove_element( "vc_row" );
        //vc_remove_element( "vc_column_text" );
        vc_remove_element( "vc_separator" );
        vc_remove_element( "vc_zigzag" );
        vc_remove_element( "vc_text_separator" );
        vc_remove_element( "vc_hoverbox" );
        vc_remove_element( "vc_single_image" );
        vc_remove_element( "vc_gallery" );
        vc_remove_element( "vc_images_carousel" );
        if (apply_filters( "greyd_remove_vc_icon",true)) vc_remove_element( "vc_icon" );
        vc_remove_element( "vc_message" );
        vc_remove_element( "vc_toggle" );
        vc_remove_element( "vc_tta_tabs" );
        vc_remove_element( "vc_tta_tour" );
        // vc_remove_element( "vc_tta_accordion" );
        // vc_remove_element( "vc_tta_section" );
        vc_remove_element( "vc_tta_pageable" );
        vc_remove_element( "vc_custom_heading" );
        vc_remove_element( "vc_btn" );
        vc_remove_element( "vc_cta" );
        vc_remove_element( "vc_posts_slider" );
        // vc_remove_element( "vc_video" );
        vc_remove_element( "vc_gmaps" );
        vc_remove_element( "vc_flickr" );
        vc_remove_element( "vc_progress_bar" );
        vc_remove_element( "vc_pie" );
        vc_remove_element( "vc_round_chart" );
        vc_remove_element( "vc_line_chart" );
        vc_remove_element( "vc_basic_grid" );
        vc_remove_element( "vc_media_grid" );
        vc_remove_element( "vc_masonry_grid" );
        vc_remove_element( "vc_masonry_media_grid" );
        vc_remove_element( "vc_empty_space" );

        /* struktur */
        vc_remove_element( "vc_widget_sidebar" );
        // vc_remove_element( "vc_raw_html" );
        // vc_remove_element( "vc_raw_js" );
        // vc_remove_element( "vc_gutenberg" );

        /* remove WP widgets */
        vc_remove_element( "vc_wp_search" );
        vc_remove_element( "vc_wp_meta" );
        vc_remove_element( "vc_wp_recentcomments" );
        vc_remove_element( "vc_wp_calendar" );
        vc_remove_element( "vc_wp_pages" );
        vc_remove_element( "vc_wp_tagcloud" );
        vc_remove_element( "vc_wp_custommenu" );
        vc_remove_element( "vc_wp_text" );
        vc_remove_element( "vc_wp_posts" );
        vc_remove_element( "vc_wp_categories" );
        vc_remove_element( "vc_wp_archives" );
        vc_remove_element( "vc_wp_rss" );
        vc_remove_element( "vc_wp_links" );

        /* remove deprecated */
        vc_remove_element( "vc_tabs" );
        vc_remove_element( "vc_tab" );
        vc_remove_element( "vc_tour" );
        vc_remove_element( "vc_accordion" );
        vc_remove_element( "vc_accordion_tab" );
        vc_remove_element( "vc_button" );
        vc_remove_element( "vc_cta_button" );
        vc_remove_element( "vc_button2" );
        vc_remove_element( "vc_cta_button2" );
        
        // reorder Modules
        // important
        vc_map_update("vc_section", array('weight' => 99));
        vc_map_update("vc_row", array('weight' => 98));
        vc_map_update("vc_row_inner", array('weight' => 97));
        vc_map_update("vc_blank_space", array('weight' => 96));
        vc_map_update("vc_headlines", array('weight' => 95));
        vc_map_update("vc_column_text", array('weight' => 94));
        // content elements
        vc_map_update("vc_list", array('weight' => 89));
        vc_map_update("vc_cbutton", array('weight' => 88));
        vc_map_update("vc_icons", array('weight' => 87));
        vc_map_update("vc_video", array('weight' => 86));
        vc_map_update("vc_close", array('weight' => 86));
        // dynamics
        vc_map_update("vc_content_box", array('weight' => 79));
        vc_map_update("dynamic", array('weight' => 78));
        vc_map_update("vc_form", array('weight' => 77));
        // posts
        vc_map_update("vc_search", array('weight' => 76));
        vc_map_update("vc_posts_tp", array('weight' => 75));
        vc_map_update("vc_posts_details_tp", array('weight' => 74));
        vc_map_update("vc_post_tp", array('weight' => 73));
        vc_map_update("vc_posts_overview", array('weight' => 72));
        vc_map_update("vc_posts_links", array('weight' => 70));
        vc_map_update("vc_tta_accordion", array('weight' => 69));
        // embed raw
        vc_map_update("vc_multimedia", array('weight' => 63));
        vc_map_update("vc_cond_content", array('weight' => 62));
        vc_map_update("vc_raw_html", array('weight' => 61));
        vc_map_update("vc_raw_js", array('weight' => 60));
        // bottom
        vc_map_update("vc_footernav", array('weight' => 53));
        vc_map_update("vc_dropdownnav", array('weight' => 52));
        vc_map_update("vc_cbutton_anchor", array('weight' => 51));
        // way bottom
        vc_map_update("vc_smchannels", array('weight' => 44));
        vc_map_update("vc_smshare", array('weight' => 43));
        vc_map_update("vc_copyright", array('weight' => 42));
        vc_map_update("vc_gutenberg", array('weight' => 41));
        // plugins
        // api_precire => 26
        vc_map_update("newsletter_vc", array('weight' => 25));
        vc_map_update("contact-form-7", array('weight' => 24));
        vc_map_update("rev_slider_vc", array('weight' => 23));
        vc_map_update("rev_slider", array('weight' => 22));
        // woo
        // woo_content => 10
        // woo_default => 9
        // woo_grmnzd => 8
    }
    
    public function remove_vc_menu() {
        remove_menu_page('vc-general');
        remove_menu_page('vc-welcome');
    }
    
    /*
        Manually set WPBakery Backend Editor for all our posttypes
    */
    public function set_vc_roles() {
        if ( !is_admin() ) return;
        
        $vc_roles = helper::get_vc_roles();
        
        // set vc roles
        vc_set_default_editor_post_types( $vc_roles );
        vc_editor_set_post_types( $vc_roles );
    }
    
    /**
     * Bugfix for 'WPBakery Editor not displayed' (since Version 6.4.0)
     * 
     * this function returns true when the user is in the edit screen & vc is enabled for the posttype
     * @source: js_composer/include/autoload/vc-pages/page-role-manager.php
    */
    function enable_for_all_posttypes( $state, $role ) {
        
        if ( is_admin() && $state !== true ) {
            
            $posttype   = get_post_type() ? get_post_type() : (function_exists('get_current_screen') ? ( is_object(get_current_screen()) ? get_current_screen()->post_type : NULL ) : NULL);
            $roles      = array_flip(helper::get_vc_roles());
            // if current posttype is part of roles array
            if ( !empty($posttype) && isset($roles[$posttype]) ) $state = true;
        }
        return $state;
    }
    
    function enable_for_admin_only( $state, $role ) {
        if ( current_user_can('manage_options') ) return true;
        return false;
    }

    /**
     * Remove VC Frontend Editor row action
     */
    public function remove_vc_fe_editor_row_action( $actions, $post ) {
        if ( isset($actions['edit_vc']) ) {
            unset( $actions['edit_vc'] );
        }
        return $actions;
    }

}


