
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php
/**
 * Shortcode MailChimp Page
 *
 * @link       https://codesupply.co
 * @since      1.0.0
 *
 * @package    Basic MailChimp
 */

/**
 * MailChimp Shortcode
 *
 * @param array  $atts      User defined attributes in shortcode tag.
 * @param string $content   Shorcode tag content.
 * @return string           Shortcode result HTML.
 */
function bmc_mailchimp_shortcode( $atts, $content = '' ) {

	$params = shortcode_atts( array(
		'title'                  => '',
		'text'                   => '',
		'list_id'                => 'default',
	), $atts );

	ob_start();

	?>
	<div class="bmc-wrap">

		<?php if ( $params['title'] ) { ?>
			<h2 class="bmc-title"><?php echo esc_html( $params['title'] ); ?></h2>
		<?php } ?>

		<?php if ( $params['text'] ) { ?>
			<p class="bmc-message"><?php echo esc_html( $params['text'] ); ?></p>
		<?php } ?>

		<?php do_action( 'bmc_mailchimp_template', $params['list_id'] ); ?>

	</div>

	<?php return ob_get_clean();

}
add_shortcode( 'basic_mailchimp', 'bmc_mailchimp_shortcode' );

/**
 * Map Facebook Page Shortcode into the Basic Shortcodes Plugin
 */
if ( function_exists( 'bsc_register_shortcode' ) ) {

	$shortcode_map = array(
		'name'			=> 'mailchimp',
		'title'			=> esc_html__( 'MailChimp', 'basic-mailchimp' ),
		'priority'		=> 160,
		'base'			=> 'basic_mailchimp',
		'autoregister'	=> false,
		'fields'		=> array(
			array(
				'type'		=> 'input',
				'name'		=> 'title',
				'label'		=> esc_html__( 'Title', 'basic-mailchimp' ),
			),
			array(
				'type'		=> 'input',
				'name'		=> 'text',
				'label'		=> esc_html__( 'Message', 'basic-mailchimp' ),
			),
		),
	);

	if ( bmc_get_lists_options() ) {
		$shortcode_map['fields'][] = array(
			'type'		=> 'select',
			'name'		=> 'list_id',
			'label'		=> esc_html__( 'List', 'basic-mailchimp' ),
			'default'	=> 'default',
			'options'	=> bmc_get_lists_options(),
		);
	}

	bsc_register_shortcode( $shortcode_map );
}
