/**
  * Formats array for drop down in terms of Visual Composer.
  *
  * @since  0.3.0
  * @access private
  * @param  string
  *
  * @return array
  */
 private function get_values($param)
 {
     $return = array();
     $items = array();
     $defined_options = $this->helper->get_option_group();
     if ($this->client->has_valid_api_key() && $defined_options['list_id']) {
         if ('list' == $param) {
             $group = new Api\Cleverreach_Group_Adapter($this->client);
             $items = $this->helper->parse_list($group->get_list(), 'list_id');
         } elseif ('form' == $param) {
             $form = new Api\Cleverreach_Form_Adapter($this->client);
             $items = $this->helper->parse_list($form->get_list($defined_options['list_id']), 'form_id', true);
         }
         // Prepare drop down lists in terms of Visual Composer.
         foreach ($items as $item) {
             $return[$item['name']] = $item['id'];
         }
     }
     return $return;
 }
 /**
  * Render form input field and description.
  *
  * @since 0.1.0
  */
 public function render_form_field()
 {
     $html = '<select class="cre-admin-select-form" name="cleverreach_extension[form_id]">';
     $client = new Api\Cleverreach();
     $helper = new Core\Cre_Helper();
     if ($client->has_valid_api_key() && $helper->has_option('list_id')) {
         $form = new Api\Cleverreach_Form_Adapter($client);
         $html .= $helper->parse_list_html($this->form_id, $form->get_list($this->list_id), 'form_id', esc_html__('Please select a form', 'cleverreachextension'));
     }
     $html .= '</select>';
     echo wp_kses($html, $helper->allowed_html_select());
 }
<?php

/**
 * Visual Composer Integration
 * Hooks into `cleverreach_extension` shortcode
 *
 * @since 0.2.0
 *
 * Optimized for Visual Composer v4.6.2
 * @link http://vc.wpbakery.com/
 * @docs https://wpbakery.atlassian.net/wiki/display/VC/Visual+Composer+Pagebuilder+for+WordPress
 */
use CleverreachExtension\Core;
use CleverreachExtension\Core\Api;
$values = array();
$client = new Api\Cleverreach();
$helper = new Core\Cre_Helper();
if ($client->has_valid_api_key() && $helper->has_option('list_id')) {
    $form = new Api\Cleverreach_Form_Adapter($client);
    $forms = $helper->parse_list($form->get_list($helper->get_option('list_id')), 'form_id');
    // Prepare dropdown list in terms of Visual Composer.
    foreach ($forms as $form) {
        $values[$form['name']] = $form['id'];
    }
    // Append `Custom` at the very end of the list.
    $values[esc_html__('Custom', 'cleverreachextension')] = 'custom';
}
vc_map(array('name' => esc_html__('CleverReach Form', 'cleverreachextension'), 'base' => 'cleverreach_extension', 'class' => 'cleverreach_extension', 'icon' => '', 'category' => esc_html__('CleverReach', 'cleverreachextension'), 'admin_enqueue_js' => array(), 'admin_enqueue_css' => array(), 'params' => array(array('type' => 'dropdown', 'holder' => 'div', 'class' => 'cre_form_id', 'heading' => esc_html__('Form', 'cleverreachextension'), 'param_name' => 'form_id', 'value' => $values, 'std' => $helper->get_option('form_id'), 'description' => esc_html__('Check the wiki on how to customize your form.', 'cleverreachextension')))));
 /**
  * Render section intro message.
  *
  * @since 0.1.0
  */
 public function render_section_info()
 {
     echo '<p>' . esc_html__('Use the fields below to connect WordPress and CleverReach.', 'cleverreach-extension') . '</p>';
     // Check if `$client` is available.
     $client = new Api\Cleverreach();
     if ($client->has_error()) {
         echo '<p class="error">';
         echo '<strong>' . esc_html__('Error:', 'cleverreach-extension') . '</strong> ';
         esc_html_e('Could not load data from CleverReach.', 'cleverreach-extension');
         echo '<p>';
     }
 }