I am trying to add an ID attribute to row in Visual Composer via documented function vc_add_param()
in such a way:
$attributes = array(
\'type\
Solution:
We have to remap a shortcode and change its template to add additional parameters.
So, in my case:
// Add custom row options
function change_vc_rows() {
// Add parameters we want
vc_add_param('vc_row', array(
'type' => 'textfield',
'heading' => "HTML ID",
'param_name' => 'element_id',
'value' => '',
'description' => __("Assign an ID to the row", "discprofile")
));
// Update 'vc_row' to include custom vc_row template and remap shortcode
$new_map = vc_map_update( 'vc_row', array('html_template' => locate_template('templates/vc_row.php')) );
// Remove default vc_row
vc_remove_element('vc_row');
// Remap shortcode with custom template
vc_map($new_map['vc_row']);
}
// Include our function when all wordpress stuff is loaded
add_action( 'wp_loaded', 'change_vc_rows' );
We included templates/vc_rows.php file. It is the row template file, copied from plugins/js_composer/include/templates/shortcodes/vc_rows.php with some changes. Here it is:
'',
'el_class' => '',
'bg_image' => '',
'bg_color' => '',
'bg_image_repeat' => '',
'font_color' => '',
'padding' => '',
'margin_bottom' => '',
'full_width' => false,
'css' => '',
), $atts ) );
// wp_enqueue_style( 'js_composer_front' );
wp_enqueue_script( 'wpb_composer_front_js' );
// wp_enqueue_style('js_composer_custom_css');
$el_class = $this->getExtraClass( $el_class );
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, 'vc_row wpb_row ' . ( $this->settings( 'base' ) === 'vc_row_inner' ? 'vc_inner ' : '' ) . get_row_css_class() . $el_class . vc_shortcode_custom_css_class( $css, ' ' ), $this->settings['base'], $atts );
$style = $this->buildStyle( $bg_image, $bg_color, $bg_image_repeat, $font_color, $padding, $margin_bottom );
?>
class="" id="" >endBlockComment( 'row' );
echo '';