<?php

function flo_slider_element_vc() {

  $args = array(
    'post_type' => 'flo-slider',
    'posts_per_page' => -1
  );
  $the_query = new WP_Query( $args );

  $slideshows = array();

  while ( $the_query->have_posts() ) {
    $the_query->the_post();

    $slideshows[] = array(
      'id' => $the_query->post->ID,
      'title' => get_the_title()
    );
  }

  vc_map( array(
    "name" => __( "Flo Slider", "flotheme" ),
    "base" => "floslider",
    "category" => __( "Flothemes", "flotheme"),
    // "icon" => get_template_directory_uri().'/assets/admin/images/vc_icon.png',
    "icon" => plugins_url('/assets/admin/images/vc_icon.png', __FILE__ ),
    "params" => array(

      array(
        "type" => "dropdown",
        "heading" => __( "Choose Slideshow:", "flotheme" ),
        "param_name" => "id",
        "value" => $slideshows,
        "description" => __( "Choose a slideshow from the ones you've created at Dashboard -> Slideshow." )
      )

    )

  ) );

}

add_action( 'vc_before_init', "flo_slider_element_vc" );

?>
