<?php
add_action( 'vc_before_init', 'rockon_team_WITHVS' );
function rockon_team_WITHVS() {
   vc_map( array(
      "name" => __("Rockon Team",'rockon'),
      "base" => "rockon_team_post",
      "class" => "",
      "category" => __('Content','rockon'),
      'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
      'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
      "params" => array(
         array(
            "type" => "textfield",
            "holder" => "div",
            "class" => "",
            "heading" => __("Title",'rockon'),
            "param_name" => "title",
            "value" => __("Rockon Disc Jockey",'rockon'),
            "description" => __("Title text Here.",'rockon')
         ),
		  array(
            "type" => "dropdown",
            "holder" => "div",
            "class" => "",
            "heading" => __("Number Of Post",'rockon'),
            "param_name" => "no_of_post",
            "value" => array('4','8','12'),
            "description" => __("Choose no of post.",'rockon')
         )
      )
   ) );
}
add_shortcode( 'rockon_team_post', 'rockon_team_post_func' );
function rockon_team_post_func( $atts ) { // New function parameter $content is added!
   extract( shortcode_atts( array(
      'title' => 'something',
	  'no_of_post' => '8'
   ), $atts ) );
   $result = '';
   $result .= '<div class="row">
    <div class="col-lg-12 col-md-12 col-sm-12">
      <div class="rock_heading_div">
        <div class="rock_heading">
          <h1>'.__(esc_attr($title),'rockon').'</h1>
          <p>X</p>
        </div>
      </div>
      <div class="rock_disc_jockcy">
        <div id="rock_disc_jockcy_slider" class="owl-carousel owl-theme">';
		$i = 0;
	  $club_query = new WP_Query( array( 'post_type' => 'disc_jockey_team', 'posts_per_page' => $no_of_post) );
	 if($club_query->have_posts()): 
		while($club_query->have_posts()) : $club_query->the_post();
		
          $result .= '<div class="rock_disc_jockcy_slider_item">'; 
		  //$image = get_the_post_thumbnail( $post->ID, 'rockon-team-img-size' );
		  if (has_post_thumbnail($post->ID))
		  {	
			$src = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) , 'full' );
			$thumb_w = '265';
			$thumb_h = '312';
			$image = aq_resize($src, $thumb_w, $thumb_h, true);
			$result .= '<img src="'.esc_url($image).'"  alt="">';
			//$result .= $image;
    	  }
		  $result .= '<a href="#rockondj'.$i.'" class="fancybox">
            <h4>'.__(get_the_title($post->ID),'rockon').'</h4>
            </a> </div>';
		 $i++;
		 $image = '';
		endwhile; 
	 endif; 	
    $result .= '</div>
        <div class="customNavigation"> <a class="rock_slider_button  prev"><i class="fa fa-angle-left"></i></a> <a class="rock_slider_button  next"><i class="fa fa-angle-right"></i></a> </div>
      </div>
    </div>
  </div>';
	$i = 0;
	$club_query = new WP_Query( array( 'post_type' => 'disc_jockey_team', 'posts_per_page' => $no_of_post) );
	if($club_query->have_posts()): 
	while($club_query->have_posts()) : $club_query->the_post();
	
	  //$image = get_the_post_thumbnail( $post->ID, 'rockon-team-img-size' );
	  $result .= '<div id="rockondj'.$i.'" class="rock_dj_profile">
		<div class="row">
		  <div class="col-lg-6"> ';
		if (has_post_thumbnail($post->ID))
		{	
			$src = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) , 'full' );
			$thumb_w = '265';
			$thumb_h = '312';
			$image = aq_resize($src, $thumb_w, $thumb_h, true);
			$result .= '<img src="'.esc_url($image).'"  alt="">';
		}
		  $result .=' </div>
		  <div class="col-lg-6">
			<h2><i class="fa fa-headphones"></i> '.__(get_the_title($post->ID),'rockon').'</h2>
			<p>'.__(get_excerpt(550),'rockon').'</p>
		  </div>
		</div>
	  </div>';
	 $i++;
	  $image = '';
	endwhile; 
	endif; 	
	return $result;
   
}
?>