Forked from hasanm95/Visual comoposer with param_group
Created
September 26, 2018 19:43
-
-
Save cristianstan/3548458bea9b49c5511208d5fe10bb11 to your computer and use it in GitHub Desktop.
Create visual composer with param_group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Backend visual composer add-on code | |
vc_map(array( | |
'name' => 'Accordions', | |
'base' => 'maxima_accordion', | |
'category' => 'Maxima', | |
'params' => array( | |
array( | |
'type' => 'textfield', | |
'name' => __('Title', 'rrf-maxima'), | |
'holder' => 'div', | |
'heading' => __('Title', 'rrf-maxima'), | |
'param_name' => 'title', | |
), | |
array( | |
'type' => 'param_group', | |
'param_name' => 'values', | |
'params' => array( | |
array( | |
'type' => 'textfield', | |
'name' => 'label', | |
'heading' => __('Heading', 'rrf-maxima'), | |
'param_name' => 'label', | |
), | |
array( | |
'type' => 'textarea', | |
'name' => 'Content', | |
'heading' => __('Content', 'rrf-maxima'), | |
'param_name' => 'excerpt', | |
) | |
) | |
), | |
), | |
)); | |
//shortcode | |
function maxima_accordion_shortcode($atts){ | |
extract(shortcode_atts(array( | |
'title' => '', | |
'values' => '', | |
), $atts)); | |
$list = '<h4>'.$title.'</h4>'; | |
$values = vc_param_group_parse_atts($atts['values']); | |
$new_accordion_value = array(); | |
foreach($values as $data){ | |
$new_line = $data; | |
$new_line['label'] = isset($new_line['label']) ? $new_line['label'] : ''; | |
$new_line['excerpt'] = isset($new_line['excerpt']) ? $new_line['excerpt'] : ''; | |
$new_accordion_value[] = $new_line; | |
} | |
$idd = 0; | |
foreach($new_accordion_value as $accordion): | |
$idd++; | |
$list .= | |
'<div class="panel panel-default"> | |
<div class="panel-heading"> | |
<h4 class="panel-title"> | |
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse'.$idd.'"> | |
'.$accordion['label'].' | |
<span class="fa fa-plus"></span> | |
</a> | |
</h4> | |
</div> | |
<div id="collapse'.$idd.'" class="panel-collapse collapse"> | |
<div class="panel-body"> | |
<p>'.$accordion['excerpt'].'</p> | |
</div> | |
</div> | |
</div>'; | |
endforeach; | |
return $list; | |
wp_reset_query(); | |
} | |
add_shortcode('maxima_accordion', 'maxima_accordion_shortcode'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment