Skip to content

Instantly share code, notes, and snippets.

@sudipto-me
Created May 24, 2019 09:14
Show Gist options
  • Save sudipto-me/c7e441c77593e611f4aa494601477414 to your computer and use it in GitHub Desktop.
Save sudipto-me/c7e441c77593e611f4aa494601477414 to your computer and use it in GitHub Desktop.
Visual Composer Custom Element Settings. This settings will show when the element is used in the backend.
/*
* Wp Bakery Page Builder custom Element Code
*/
/*
* vc element single post 2
*/
function fts_single_post_two_vc_callback(){
vc_map( array(
'name' => __('Single Post 2','js_composer'),
'description' => __('Single post section', 'js_composer'),
'base' => 'single_post_two',
'category' => __('Content','js_composer'),
'params' => array(
array(
'type' => 'attach_image',
'heading' => esc_attr__( 'Image', 'js_composer' ),
'param_name' => 'post_image',
'description' => esc_attr__( 'Upload Image.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => esc_attr__( 'Height', 'js_composer' ),
'param_name' => 'post_height',
'description' => esc_attr__( 'Give the post section height.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => esc_attr__( 'Button Text', 'js_composer' ),
'param_name' => 'post_button_text',
'description' => esc_attr__( 'Give the button text.', 'js_composer' ),
'value' => esc_attr__('Read More','js_composer')
),
array(
'type' => 'dropdown',
'heading' => __( 'Button size', 'js_composer' ),
'value' => array(
esc_attr__( 'Large', 'js_composer' ) => 'large',
esc_attr__( 'Small', 'js_composer' ) => 'small',
),
'param_name' => 'post_button_size',
'description' => __( 'Select button size', 'js_composer' ),
),
array(
'type' => 'vc_link',
'heading' => esc_attr__( 'Button Link', 'js_composer' ),
'param_name' => 'post_button_link',
'description' => esc_attr__( 'Change link of button.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => esc_attr__( 'Category', 'js_composer' ),
'param_name' => 'post_category',
'description' => esc_attr__( 'Use comma(,) for multiple.', 'js_composer' ),
),
array(
'type' => 'textfield',
'heading' => esc_attr__( 'Title', 'js_composer' ),
'param_name' => 'post_title',
'admin_label' => true,
),
array(
'type' => 'font_container',
'param_name' => 'title_font_container',
'value' => 'tag:h2|text_align:center',
'settings' => array(
'fields' => array(
'tag' => 'h2',
// default value h2
'text_align' => 'center',
'font_size',
'line_height',
'color',
'tag_description' => __( 'Select element tag.', 'js_composer' ),
'text_align_description' => __( 'Select text alignment.', 'js_composer' ),
'font_size_description' => __( 'Enter font size in px e.g. 30px.', 'js_composer' ),
'line_height_description' => __( 'Enter line height in px e.g. 35px.', 'js_composer' ),
'color_description' => __( 'Select heading color.', 'js_composer' ),
),
),
),
array(
'type' => 'checkbox',
'heading' => __( 'Use theme default font family?', 'js_composer' ),
'param_name' => 'title_use_theme_fonts1',
'value' => array( __( 'Yes', 'js_composer' ) => 'yes' ),
'description' => __( 'Use font family from the theme.', 'js_composer' ),
),
array(
'type' => 'google_fonts',
'param_name' => 'title_google_fonts',
'value' => 'font_family:Abril%20Fatface%3Aregular|font_style:400%20regular%3A400%3Anormal',
'settings' => array(
'fields' => array(
'font_family_description' => __( 'Select font family.', 'js_composer' ),
'font_style_description' => __( 'Select font styling.', 'js_composer' ),
),
),
'dependency' => array(
'element' => 'title_use_theme_fonts1',
'value_not_equal_to' => 'yes',
),
),
),
) );
}
add_action( 'vc_before_init', 'fts_single_post_two_vc_callback' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment