<?php

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * VC registration only as shortcodes are handled by plugin
 * Shortcodes: [mc4wp_form id="%d"]
 */

add_filter( 'shrk_filter_vc_mappings', function ( $shrk_vc_shortcodes, $d ) {
	$mc_forms     = array();
	$mc_forms_obj = function_exists( 'mc4wp_get_forms' ) ? mc4wp_get_forms() : array();

	foreach ($mc_forms_obj as $mc_form_obj) {
		if ( is_object( $mc_form_obj ) ) {
			$mc_forms[$mc_form_obj->name] = $mc_form_obj->ID;
		}
	}

	if ( shortcode_exists( 'mc4wp_form' ) ) {
		$shrk_vc_shortcodes['shrk_mailchimp'] =  array(
			'name' => esc_html__('MailChimp newsletter form', 'dvl-uxshop-shortcodes'), /* */
			'base' => 'mc4wp_form',
			'category' => esc_html__('Theme Specific', 'dvl-uxshop-shortcodes'),
			'icon' => 'icon-wpb-shrk',
			'show_settings_on_create' => true,
			'params' => array(
				array(
					'type' => 'dropdown',
					'heading' => esc_html__('Mailchimp form', 'dvl-uxshop-shortcodes'),
					'param_name' => 'id',
					'value' => $mc_forms
					),
				)
			);		
	}

	return $shrk_vc_shortcodes;
},10 ,2 );

?>