function form($instance) { $default = array('nm_mc_title' => __('join the revolution'), 'headline_font_size' => '86px', 'headline_font_color' => '#59ba47', 'nm_mc_detail' => 'Lorem ipsum dolor sit amet consultiteur. Erat sit amet lorem dolor. Lorem ipsum dolor sit amet con. Lorem ipsum dolor sit amet consultiteur. Erat sit amet lorem dolor. Lorem ipsum dolor sit amet con.', 'nm_mc_form_id' => 0, 'nm_mc_button_text' => 'Sign up'); $instance = wp_parse_args((array) $instance, $default); $field_id_title = $this->get_field_id('nm_mc_title'); $field_name_title = $this->get_field_name('nm_mc_title'); $field_id_detail = $this->get_field_id('nm_mc_detail'); $field_name_detail = $this->get_field_name('nm_mc_detail'); $field_id_form = $this->get_field_id('nm_mc_form_id'); $field_name_form = $this->get_field_name('nm_mc_form_id'); $field_id_button = $this->get_field_id('nm_mc_button_text'); $field_name_button = $this->get_field_name('nm_mc_button_text'); /* $api_dir = dirname(__FILE__).'/api_mailchimp/mcapi_lists.php'; include($api_dir); */ $arrList = nmMailChimp::getAccountLists(); $file = dirname(__FILE__) . '/mc-widget-options.php'; include $file; }
<?php //don't remove this $selected = 'selected="selected"'; $arrForms = nmMailChimp::getForms(); ?> <p> <label><?php _e('Title', 'nm_mailchimp_plugin'); ?> <br> <input type="text" class="widefat" id="<?php echo $field_id_title; ?> " name="<?php echo $field_name_title; ?> " value="<?php echo attribute_escape($instance['nm_mc_title']); ?> " /> </label> </p> <p> <label><?php _e('Detail', 'nm_mailchimp_plugin'); ?> <br> <textarea rows="5" cols="20" class="widefat" id="<?php echo $field_id_detail;
<?php /** rendering form for user **/ $old_error_reporting = error_reporting(0); $form = nmMailChimp::getForm($fid); if (!empty($form)) { $meta = json_decode($form->form_meta); $arrVars = $meta->vars; /* echo '<pre>'; print_r($meta); echo '</pre>'; */ ?> <div class="nm_mc_form"> <form id="nm_mc_form_<?php echo $widget_id; ?> " onsubmit="return postToMailChimp(this)"> <input type="hidden" value="<?php echo $fid; ?> " name="nm_mc_form_id" /> <ul> <?php if ($arrVars) { foreach ($arrVars as $key => $val) { $tag = $val->tag; $label = $val->label; $the_id = $tag . '-' . $widget_id;
/* ** this file is generting shortcode */ $mailchimp = dirname(__FILE__) . '/class.mailchimp.php'; include $mailchimp; $mc = new clsMailchimp(); $arrList = $mc->getAccountLists(); if (!is_array($arrList)) { echo '<div class="error">' . __("You did not enter API Keys please enter your API Keys from Nmedia Mailchimp Setting area") . '</div>'; } /*saving form */ if (isset($_POST['btn-form'])) { /*echo '<pre>'; print_r($_POST); echo '</pre>';*/ if (nmMailChimp::saveForm($_POST['form-name'], $_POST['form-detail'], $_POST['lid'], $_POST['chk-groups'], $_POST['chk-vars'])) { } echo '<div class="updated">Form saved</div>'; } ?> <h2><?php _e('Form shortcode Wizard', 'nm_mailchimp_plugin'); ?> </h2> <p><?php _e('This wizard will create shortcode based on your selected List, Groups and Vars, unlimited forms shortcodes can be genegrated. Once form shortcode is created you can simply put it in your Post/Page and even can put into widgets.', 'nm_mailchimp_plugin'); ?> </p> <div id="shortcode-container">
<tr> <th width="6%">Sr #</th> <th width="30%">Form name</th> <th width="26%">Detail</th> <th width="25%">Shortcode</th> <th width="13%">Delete</th> </tr> </thead> <tbody> <?php $c = 0; foreach ($arrForms as $form) { $fid = $form->form_id; $fname = $form->form_name; $urlDel = nmMailChimp::fixRequestURI(array('fid' => $fid)); //$meta = json_decode($form -> form_meta); ?> <tr> <td><?php echo ++$c; ?> </td> <td><?php echo $fname; ?> </td> <td><?php echo $form->form_detail; ?> </td>
function form($instance) { $default = array('nm_mc_title' => __('MailChimp Widget'), 'nm_mc_form_id' => 0, 'nm_mc_button_text' => 'Subscribe'); $instance = wp_parse_args((array) $instance, $default); $field_id_title = $this->get_field_id('nm_mc_title'); $field_name_title = $this->get_field_name('nm_mc_title'); $field_id_detail = $this->get_field_id('nm_mc_detail'); $field_name_detail = $this->get_field_name('nm_mc_detail'); $field_id_form = $this->get_field_id('nm_mc_form_id'); $field_name_form = $this->get_field_name('nm_mc_form_id'); $field_id_button = $this->get_field_id('nm_mc_button_text'); $field_name_button = $this->get_field_name('nm_mc_button_text'); /*$api_dir = dirname(__FILE__).'/api_mailchimp/mcapi_lists.php'; include($api_dir);*/ $arrList = nmMailChimp::getAccountLists(); $file = dirname(__FILE__) . '/mc-widget-options.php'; include $file; }
$this->err = true; } if ($this->api_key == '') { $this->errMessage .= 'No API key found, please set API from plugin option in admin<br />'; $this->err = true; } if ($this->list_id == '') { $this->errMessage .= 'No List ID found, please set List ID from plugin option in admin<br />'; $this->err = true; } /* checking validation for email, list id and api key */ $this->errMessage .= '</div>'; } } $mailchimp = new postToMailChimp(); $form = nmMailChimp::getForm($_POST['nm_mc_form_id']); /* print_r($_POST['form_meta']); exit; */ $meta = json_decode($form->form_meta); $mailchimp->list_id = $meta->list_id; $mailchimp->api_key = get_option('nm_mc_api_key'); $mailchimp->thanks = get_option('nm_mc_thanks_message'); $mailchimp->validateCredentials($posted_data, $meta->vars); /* pushing list interest/groups into VARS array */ if ($_POST['group']) { foreach ($_POST['group'] as $interest => $groups) { /* $temp['id'] = $grouping -> id; $temp['groups'] = $grouping -> groups; array_push($interest, $temp); $mailchimp -> vars ['GROUPINGS'] = $interest; */