Visual Composer - How to create dependent custom element with vc_add_shortcode_param?


My ticket to WP Bakery support is 2 weeks old and no official response. So I’ll try my luck on the forum

I am trying to create a custom option vc_add_shortcode_param

I have read

Unfortunately this creates the param type but with no dependencies
In the past there was vc_generate_dependencies_attributes but it does not exist anymore…

Any solutions ?

Hi! Can you share your code of the param here, please? It seems that your custom param miss the input with param value

Yes of course

function vc_dzs_add_media($settings, $value) {
        $dependency = '';

            $dependency = vc_generate_dependencies_attributes($settings);

        $fout = '';

        $fout.= '    <div class="setting setting-medium setting-three-floats">
    <div class="preview-media-con-left"></div>
    <div class="change-media-con">
        <button class="button-secondary dzsprx-btn-add-media"><i class="fa fa-plus-square-o"></i> Add Media</button>
    <div class="setting-input type-input overflow-it">
    <input style="" name="'.esc_attr($settings['param_name'])
            .'" class="wpb_vc_param_value wpb-textinput setting-field dzsprx-preview-changer '
            .$settings['param_name'].' '.$settings['type'].'_field';

            $fout.= esc_attr( $settings['param_name'] ) . ' ' .esc_attr( $settings['type'] );

            $fout.='" type="text" value="'.$value.'" ' . $dependency . '/>
    <div class="clear"></div>

        return $fout;

( of course, vc_generate_dependencies_attributes is fully deprecated with no alternative ( why? ) )

__ and I add the setting with :

            "type" => "dzs_add_media",

            "class" => "",
            "heading" => __("Media"),
            "param_name" => "media",
            "value" => __(""),
            "description" => __('This is the media you are going to use.'),



but it will not listen to the dependency

Why do you have two arrays on dependency? Try this.

‘dependency’ => array(
‘element’ => ‘parallax_content_type’,
‘value’ => ‘image’

Makes no difference. I don’t think that is the issue

Just checked on my side your code and it works with dependecies, it possible something wrong with the JS

Are you using custom param for this element parallax_content_type issue in this param. Check param_name and param type with class wpb_vc_param_value.
class="wpb_vc_param_value wpb-textinput setting-field dzsprx-preview-changer ‘
.$settings[‘param_name’].’ ‘.$settings[‘type’].’_field’


Ok guys I found the problem


I was using

'image' => esc_html__("Image",'dzsprx'),
 'video' => esc_html__("Video",'dzsprx'),
 'gmaps' => esc_html__("Google Maps",'dzsprx'),

instead of

				        'label'=>esc_html__("Google Maps",'dzsprx'),



instead of

	        "dependency" => array(
		        "element" => "parallax_content_type",
		        "value" => array("gmaps"),