kalponikoronno

Visual Composer Param group

Aug 8th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 KB | None | 0 0
  1. <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
  2.  
  3. vc_map(array(
  4.   'name' => 'Client Logos',
  5.   'base' => 'maxima_accordion',
  6.   'category' => 'Amq',
  7.   'params' => array(
  8.     array(
  9.       'type' => 'textfield',
  10.       'name' => __('Title', 'amqtheme'),
  11.       'holder' => 'div',
  12.       'heading' => __('Title', 'amqtheme'),
  13.       'param_name' => 'title',
  14.     ),
  15.     array(
  16.         'type' => 'param_group',
  17.         'param_name' => 'values',
  18.         'params' => array(
  19.             array(
  20.                 'type' => 'attach_image',
  21.                 'name' => 'label',
  22.                 'heading' => __('Image', 'amqtheme'),
  23.                 'param_name' => 'label',
  24.             ),
  25.             array(
  26.                 'type' => 'textfield',
  27.                 'name' => 'Content',
  28.                 'admin_label' => true,
  29.                 'heading' => __('Link', 'amqtheme'),
  30.                 'param_name' => 'excerpt',
  31.             )
  32.       )
  33.  
  34.     ),
  35.   ),
  36.  
  37. ));
  38.  
  39.  
  40. function maxima_accordion_shortcode($atts){
  41.   extract(shortcode_atts(array(
  42.     'values' => '',
  43.   ), $atts));
  44.  
  45.   $list = '';
  46.  
  47.  
  48.   $values = vc_param_group_parse_atts($atts['values']);
  49.  
  50.   $param_group_items = array();
  51.    
  52.   foreach($values as $data){
  53.     $new_line = $data;
  54.     $new_line['label'] = isset($new_line['label']) ? $new_line['label'] : '';
  55.     $new_line['excerpt'] = isset($new_line['excerpt']) ? $new_line['excerpt'] : '';
  56.  
  57.     $param_group_items[] = $new_line;
  58.  
  59.   }
  60.  
  61.    
  62.    
  63.     $list .='<div class="partners-list">';
  64.     $list .='<ul class="partners-logo list-inline text-center">';
  65.    
  66.         foreach($param_group_items as $single_item):
  67.  
  68.         $logo_array = wp_get_attachment_image_src($single_item['label'], 'large', false);
  69.  
  70.             $list .='<li><a href="'.$single_item['excerpt'].'"><img src="'.$logo_array[0].'" alt=""/></a></li>';
  71.  
  72.         endforeach;
  73.    
  74.     $list .='</ul>';    
  75.     $list .='</div>';    
  76.    
  77.     return $list;
  78.     wp_reset_query();
  79.  
  80. }
  81. add_shortcode('maxima_accordion', 'maxima_accordion_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment