Exemple #1
0
        function config_page()
        {
            if (isset($_POST['submit'])) {
                $options = get_option($this->optionname);
                if (!current_user_can('manage_options')) {
                    die(__('You cannot edit the WordPress-to-Lead options.', 'salesforce'));
                }
                check_admin_referer('salesforce-udpatesettings');
                foreach (array('usecss') as $option_name) {
                    if (isset($_POST[$option_name])) {
                        $options[$option_name] = true;
                    } else {
                        $options[$option_name] = false;
                    }
                }
                $newinputs = array();
                foreach ($options['inputs'] as $id => $input) {
                    foreach (array('show', 'required') as $option_name) {
                        if (isset($_POST[$id . '_' . $option_name])) {
                            $newinputs[$id][$option_name] = true;
                            unset($_POST[$id . '_' . $option_name]);
                        } else {
                            $newinputs[$id][$option_name] = false;
                        }
                    }
                    foreach (array('type', 'label', 'pos') as $option_name) {
                        if (isset($_POST[$id . '_' . $option_name])) {
                            $newinputs[$id][$option_name] = $_POST[$id . '_' . $option_name];
                            unset($_POST[$id . '_' . $option_name]);
                        }
                    }
                }
                w2l_sksort($newinputs, 'pos', true);
                $options['inputs'] = $newinputs;
                foreach (array('successmsg', 'errormsg', 'sferrormsg', 'org_id', 'source', 'submitbutton') as $option_name) {
                    if (isset($_POST[$option_name])) {
                        $options[$option_name] = $_POST[$option_name];
                    }
                }
                update_option($this->optionname, $options);
            }
            $options = get_option($this->optionname);
            if (!is_array($options['inputs'])) {
                $options = salesforce_default_settings();
            }
            ?>
			<div class="wrap">
				<a href="http://salesforce.com/"><div id="yoast-icon" style="background: url(<?php 
            echo plugins_url('', __FILE__);
            ?>
/salesforce-50x50.png) no-repeat;" class="icon32"><br /></div></a>
				<h2 style="line-height: 50px;"><?php 
            echo $this->longname;
            ?>
</h2>
				<div class="postbox-container" style="width:70%;">
					<div class="metabox-holder">	
						<div class="meta-box-sortables">
							<?php 
            if (!isset($_GET['tab']) || $_GET['tab'] == 'home') {
                ?>
							<form action="" method="post" id="salesforce-conf">
								<?php 
                if (function_exists('wp_nonce_field')) {
                    wp_nonce_field('salesforce-udpatesettings');
                }
                ?>
								<input type="hidden" value="<?php 
                echo $options['version'];
                ?>
" name="version"/>
								<?php 
                $content = $this->textinput('successmsg', __('Success message after sending message', 'salesforce'));
                $content .= $this->textinput('errormsg', __('Error message when not all form fields are filled', 'salesforce'));
                $content .= $this->textinput('sferrormsg', __('Error message when Salesforce.com connection fails', 'salesforce'));
                $this->postbox('basicsettings', __('Basic Settings', 'salesforce'), $content);
                $content = $this->textinput('org_id', __('Your Salesforce.com organisation ID', 'salesforce'));
                $content .= '<small>' . __('To find your Organisation ID, in your Salesforce.com account, go to Setup &raquo; Company Profile &raquo; Company Information', 'salesforce') . '</small><br/><br/><br/>';
                $content .= $this->textinput('source', __('Lead Source to display in Salesforce.com'));
                $this->postbox('sfsettings', __('Salesforce.com Settings', 'salesforce'), $content);
                $content = $this->textinput('submitbutton', __('Submit button text', 'salesforce'));
                $content .= $this->textinput('requiredfieldstext', __('Required fields text', 'salesforce'));
                $content .= $this->checkbox('usecss', __('Use Form CSS?', 'salesforce'));
                $content .= '<br/><small><a href="' . $this->plugin_options_url() . '&amp;tab=css">' . __('Read how to copy the CSS to your own CSS file') . '</a></small>';
                $this->postbox('formsettings', __('Form Settings', 'salesforce'), $content);
                $content = '<style type="text/css">th{text-align:left;}</style><table>';
                $content .= '<tr>' . '<th width="15%">ID</th>' . '<th width="10%">Show</th>' . '<th width="10%">Required</th>' . '<th width="10%">Type</th>' . '<th width="40%">Label</th>' . '<th width="10%">Position</th>' . '</tr>';
                $i = 1;
                foreach ($options['inputs'] as $id => $input) {
                    if (empty($input['pos'])) {
                        $input['pos'] = $i;
                    }
                    $content .= '<tr>';
                    $content .= '<th>' . $id . '</th>';
                    $content .= '<td><input type="checkbox" name="' . $id . '_show" ' . checked($input['show'], true, false) . '/></td>';
                    $content .= '<td><input type="checkbox" name="' . $id . '_required" ' . checked($input['required'], true, false) . '/></td>';
                    $content .= '<td><select name="' . $id . '_type">';
                    $content .= '<option ' . selected($input['type'], 'text', false) . '>text</option>';
                    $content .= '<option ' . selected($input['type'], 'textarea', false) . '>textarea</option>';
                    $content .= '</select></td>';
                    $content .= '<td><input size="40" name="' . $id . '_label" type="text" value="' . $input['label'] . '"/></td>';
                    $content .= '<td><input size="2" name="' . $id . '_pos" type="text" value="' . $input['pos'] . '"/></td>';
                    $content .= '</tr>';
                    $i++;
                }
                $content .= '</table>';
                $this->postbox('sffields', __('Form Fields', 'salesforce'), $content);
                ?>
								<div class="submit"><input type="submit" class="button-primary" name="submit" value="<?php 
                _e("Save WordPress-to-Lead Settings", 'salesforce');
                ?>
" /></div>
							</form>
							<?php 
            } else {
                if ($_GET['tab'] == 'css') {
                    ?>
							<p><a href="<?php 
                    echo $this->plugin_options_url();
                    ?>
">&laquo; Back to config page.</a></p>
							<p>If you don't want the inline styling this plugins uses, but add the CSS for the form to your own theme's CSS, you can start by just copying the proper CSS below into your CSS file. Just copy the correct text, and then you can usually find &amp; edit your CSS file <a href="<?php 
                    echo admin_url('theme-editor.php');
                    ?>
?file=<?php 
                    echo str_replace(WP_CONTENT_DIR, '', get_stylesheet_directory());
                    ?>
/style.css&amp;theme=<?php 
                    echo urlencode(get_current_theme());
                    ?>
&amp;dir=style">here</a>.</p>
							<div style="width:260px;margin:0 10px 0 0;float:left;">
								<div id="normalcss" class="postbox">
									<div class="handlediv" title="Click to toggle"><br /></div>
									<h3 class="hndle"><span>CSS for the normal form</span></h3>
									<div class="inside">
<pre>form.w2llead {
  text-align: left;
  clear: both;
}
.w2llabel, .w2linput {
  display: block;
  width: 120px;
  float: left;
}
.w2llabel.error {
  color: #f00;
}
.w2llabel {
  clear: left;
  margin: 4px 0;
}
.w2linput.text {
  width: 200px;
  height: 18px;
  margin: 4px 0;
}
.w2linput.textarea {
  clear: both;
  width: 320px;
  height: 75px;
  margin: 10px 0;
}
.w2linput.submit {
  float: none;
  margin: 10px 0 0 0;
  clear: both;
  width: 150px;
}
#salesforce {
  margin: 3px 0 0 0;
  color: #aaa;
}
#salesforce a {
  color: #999;
}</pre>
</div>
</div></div>
<div style="width:260px;float:left;">
	<div id="widgetcss" class="postbox">
		<div class="handlediv" title="Click to toggle"><br /></div>
		<h3 class="hndle"><span>CSS for the sidebar widget form</span></h3>
		<div class="inside">
<pre>.sidebar form.w2llead {
  clear: none;
  text-align: left;
}
.sidebar .w2linput, 
.sidebar .w2llabel {
  float: none;
  display: inline;
}
.sidebar .w2llabel.error {
  color: #f00;
}
.sidebar .w2llabel {
  margin: 4px 0;
}
.sidebar .w2linput.text {
  width: 160px;
  height: 18px;
  margin: 4px 0;
}
.sidebar .w2linput.textarea {
  width: 160px;
  height: 50px;
  margin: 10px 0;
}
.sidebar .w2linput.submit {
  margin: 10px 0 0 0;
}
#salesforce {
  margin: 3px 0 0 0;
  color: #aaa;
}
#salesforce a {
  color: #999;
}</pre>
</div></div></div>
							<?php 
                }
            }
            ?>
						</div>
					</div>
				</div>
				<div class="postbox-container" style="width:20%;">
					<div class="metabox-holder">	
						<div class="meta-box-sortables">
							<?php 
            $this->postbox('usesalesforce', __('How to Use This Plugin', 'salesforce'), __('<p>To use this form, copy the following shortcode into a post or page:</p><pre style="padding:5px 10px;margin:10px 0;background-color:lightyellow;">[salesforce]</pre><p>Make sure you have entered all the correct settings on the left, including your Organisation ID.</p>', 'salesforce'));
            $this->plugin_like(false);
            $this->plugin_support();
            // $this->news();
            ?>
						</div>
						<br/><br/><br/>
					</div>
				</div>
			</div>
			<?php 
        }
Exemple #2
0
function salesforce_activate()
{
    $options = get_option('salesforce2');
    if ($options['version'] == '2.0') {
        return;
    }
    $oldoptions = get_option('salesforce');
    if (!empty($oldoptions) && $oldoptions['version'] != '2.0') {
        $options = salesforce_default_settings();
        //migrate existing data
        $options['successmsg'] = $oldoptions['successmsg'];
        $options['errormsg'] = $oldoptions['errormsg'];
        $options['requiredfieldstext'] = $oldoptions['requiredfieldstext'];
        $options['sferrormsg'] = $oldoptions['sferrormsg'];
        $options['source'] = $oldoptions['source'];
        $options['submitbutton'] = $oldoptions['submitbutton'];
        $options['usecss'] = $oldoptions['usecss'];
        $options['wpcf7css'] = $oldoptions['wpcf7css'];
        //$options['hide_salesforce_link'] 		= $oldoptions['hide_salesforce_link'];
        $options['ccusermsg'] = false;
        //default to off for upgrades
        $options['org_id'] = $oldoptions['org_id'];
        //copy existing form input data
        if (is_array($oldoptions['inputs'])) {
            foreach ($oldoptions['inputs'] as $key => $val) {
                $newinputs[$key] = $val;
            }
        }
        //sort merged inputs
        w2l_sksort($newinputs, 'pos', true);
        //save merged and sorted inputs
        $options['forms'][1]['inputs'] = $newinputs;
        //source is now saved per form
        $options['forms'][1]['source'] = $oldoptions['source'];
        update_option('salesforce2', $options);
        //$options = get_option('salesforce');
    }
    if (empty($oldoptions)) {
        salesforce_default_settings();
    }
}
    function config_page()
    {
        wp_enqueue_style('sfwp2lcssadmin', plugins_url('assets/css/sfwp2l-admin.css', dirname(__FILE__)));
        $options = get_option($this->optionname);
        if (isset($_POST['submit'])) {
            //die('<pre>'.print_r($_POST,true)); //DEBUG
            if (isset($_POST['mode']) && $_POST['mode'] == 'editform') {
                $form_id = (int) $_POST['form_id'];
                if (!isset($options['forms'][$form_id])) {
                    $options['forms'][$form_id] = $this->default_form();
                }
                //Begin Save Form Data
                $newinputs = array();
                foreach ($options['forms'][$form_id]['inputs'] as $id => $input) {
                    if (!empty($_POST['inputs'][$id . '_delete'])) {
                        continue;
                    }
                    foreach (array('show', 'required') as $option_name) {
                        if (isset($_POST['inputs'][$id . '_' . $option_name])) {
                            $newinputs[$id][$option_name] = true;
                            unset($_POST['inputs'][$id . '_' . $option_name]);
                        } else {
                            $newinputs[$id][$option_name] = false;
                        }
                    }
                    foreach (array('type', 'label', 'value', 'pos', 'opts') as $option_name) {
                        if (isset($_POST['inputs'][$id . '_' . $option_name])) {
                            $newinputs[$id][$option_name] = $_POST['inputs'][$id . '_' . $option_name];
                            unset($_POST['inputs'][$id . '_' . $option_name]);
                        }
                    }
                }
                //add any new fields
                if (isset($_POST['add_inputs'])) {
                    foreach ($_POST['add_inputs'] as $key => $input) {
                        $id = $input['field_name'];
                        if (!empty($id)) {
                            foreach (array('show', 'required') as $option_name) {
                                if (isset($_POST['add_inputs'][$key][$option_name])) {
                                    $newinputs[$id][$option_name] = true;
                                    unset($_POST['add_inputs'][$key][$option_name]);
                                } else {
                                    $newinputs[$id][$option_name] = false;
                                }
                            }
                            foreach (array('type', 'label', 'value', 'pos', 'opts') as $option_name) {
                                if (isset($_POST['add_inputs'][$key][$option_name])) {
                                    $newinputs[$id][$option_name] = $_POST['add_inputs'][$key][$option_name];
                                    unset($_POST['add_inputs'][$key][$option_name]);
                                }
                            }
                        }
                    }
                }
                w2l_sksort($newinputs, 'pos', true);
                $options['forms'][$form_id]['inputs'] = $newinputs;
                //TODO
                foreach (array('form_name', 'source', 'returl', 'successmsg', 'captchaform', 'labellocation', 'submitbutton', 'requiredfieldstext', 'requiredfieldstextpos', 'type', 'org_id') as $option_name) {
                    if (isset($_POST[$option_name])) {
                        $options['forms'][$form_id][$option_name] = $_POST[$option_name];
                    }
                }
                //End Save Form Data
            } elseif (isset($_POST['mode']) && $_POST['mode'] == 'delete') {
                if (isset($_POST['form_id']) && $_POST['form_id'] != 1) {
                    unset($options['forms'][$_POST['form_id']]);
                }
            } elseif (isset($_POST['mode']) && $_POST['mode'] == 'clone') {
                if (isset($_POST['form_id']) && $_POST['form_id'] != 1) {
                    $new_id = max(array_keys($options['forms'])) + 1;
                    $options['forms'][$new_id] = $options['forms'][$_POST['form_id']];
                }
            } else {
                //Save general settings
                $options = get_option($this->optionname);
                if (!current_user_can('manage_options')) {
                    die(__('You cannot edit the WordPress-to-Lead options.', 'salesforce'));
                }
                check_admin_referer('salesforce-udpatesettings');
                foreach (array('usecss', 'showccuser', 'ccadmin', 'captcha', 'wpcf7css', 'hide_salesforce_link', 'commentstoleads', 'commentsnamefields') as $option_name) {
                    if (isset($_POST[$option_name])) {
                        $options[$option_name] = true;
                    } else {
                        $options[$option_name] = false;
                    }
                }
                foreach (array('successmsg', 'errormsg', 'emailerrormsg', 'captchaerrormsg', 'sferrormsg', 'org_id', 'submitbutton', 'subject', 'ccusermsg', 'requiredfieldstext', 'da_token', 'da_url', 'da_site') as $option_name) {
                    if (isset($_POST[$option_name])) {
                        $options[$option_name] = $_POST[$option_name];
                    }
                }
            }
            //save changes to DB
            update_option($this->optionname, $options);
        }
        //$options = get_option($this->optionname);
        if (empty($options)) {
            $options = salesforce_default_settings();
        }
        ?>
		<div class="wrap">
			<a href="http://salesforce.com/"><div id="yoast-icon" style="background: url(<?php 
        echo plugins_url('/salesforce-50x50.png', dirname(__FILE__));
        ?>
) no-repeat;" class="icon32"><br /></div></a>
			<h2 style="line-height: 50px;"><?php 
        echo $this->longname;
        ?>
</h2>

		<?php 
        $this->admin_tabs();
        ?>

			<div class="postbox-container" style="width:70%;">
				
				<?php 
        if (isset($_POST['submit']) && empty($_POST['mode'])) {
            echo '<div id="message" class="updated"><p>' . __('Configuration Saved', 'salesforce') . '</p></div>';
        }
        ?>
									
				<div class="metabox-holder col-wrap">	
					<div class="meta-box-sortables">

						<?php 
        if (!isset($_GET['tab']) || $_GET['tab'] == 'forms') {
            $content = '<table border="0" cellspacing="0" cellpadding="4">';
            $content .= '<tr><th>ID</th><th>Name</th></tr>';
            foreach ($options['forms'] as $key => $form) {
                $content .= '<tr><td>' . $key . '</td><td><a href="' . $this->plugin_options_url() . '&tab=form&id=' . $key . '">' . $form['form_name'] . '</a><td></tr>';
            }
            $content .= '</table>';
            $content .= '<p><a class="button-secondary" href="' . $this->plugin_options_url() . '&tab=form">' . __('Add a new form', 'salesforce') . ' &raquo;</a></p>';
            $this->postbox('sfforms', __('Forms', 'salesforce'), $content);
            $loc = 'banner-main';
            $ad = $this->get_ad_code($loc);
            if ($ad) {
                $link = $this->get_ad_link($ad['id'], $loc, $ad['url']);
                echo '<p style="text-align: center;"><a href="' . $link . '" target="_blank"><img src="' . plugins_url($ad['content'], dirname(__FILE__)) . '"></a></p>';
            }
        }
        if (isset($_GET['tab']) && $_GET['tab'] == 'settings') {
            ?>
						<form action="" method="post" id="salesforce-conf">
							<?php 
            if (function_exists('wp_nonce_field')) {
                wp_nonce_field('salesforce-udpatesettings');
            }
            ?>
							<input type="hidden" value="<?php 
            echo $options['version'];
            ?>
" name="version"/>
							<?php 
            //if( $options['org_id'] )
            //$class='closed';
            $content = $this->textinput('org_id', __('Your Salesforce.com Organization ID', 'salesforce'), __('To find your Salesforce.com Organization ID, in your Salesforce.com account, go to Setup &raquo; Company Profile &raquo; Company Information', 'salesforce'));
            $this->postbox('sfsettings', __('Salesforce.com Settings', 'salesforce'), $content);
            $loc = 'banner-main';
            $ad = $this->get_ad_code($loc);
            if ($ad) {
                $link = $this->get_ad_link($ad['id'], $loc, $ad['url']);
                echo '<p style="text-align: center;"><a href="' . $link . '" target="_blank"><img src="' . plugins_url($ad['content'], dirname(__FILE__)) . '"></a></p>';
            }
            $loc = 'text';
            $ad = $this->get_ad_code($loc);
            if ($ad) {
                $link1 = $this->get_ad_link($ad['id'], $loc, 'http://try.daddyanalytics.com/watch-a-video-wp2l/?utm_source=ThoughtRefinery&utm_medium=text&utm_campaign=WP2L_Plugin_01&utm_content=da1_7');
                $link2 = $this->get_ad_link($ad['id'], $loc, 'http://try.daddyanalytics.com/start-free-trial-wp2l/?utm_source=ThoughtRefinery&utm_medium=text&utm_campaign=WP2L_Plugin_01&utm_content=da1_8');
                $ad['content'] = str_replace(array('%link1%', '%link2%'), array($link1, $link2), $ad['content']);
                $content = $ad['content'] . '<br/><br/>';
                $class = '';
            } else {
                //$class = 'closed';
                $content = 'Thank you for using <a href="http://daddyanalytics.com/" target="_blank">Daddy Analytics</a>!<br/><br/>';
            }
            $content .= $this->textinput('da_token', __('Daddy Analytics Token', 'salesforce'));
            $content .= $this->textinput('da_url', __('Daddy Analytics Web to Lead URL ID', 'salesforce'));
            $content .= $this->textinput('da_site', __('Daddy Analytics Site ID', 'salesforce'));
            $this->postbox('sfsettings', __('Daddy Analytics Settings', 'salesforce'), $content);
            $content = $this->textinput('successmsg', __('Success message after sending lead to SalesForce', 'salesforce'));
            $content .= $this->textinput('errormsg', __('Error message shown when required fields are not filled out', 'salesforce'));
            $content .= $this->textinput('emailerrormsg', __('Error message shown when email field is invalid', 'salesforce'), 'Default: The email address you entered is not valid.');
            $content .= $this->textinput('captchaerrormsg', __('Error message shown when captcha is invalid', 'salesforce'), 'Default: The text you entered did not match the image.');
            $content .= $this->textinput('sferrormsg', __('Error message when Salesforce.com connection fails', 'salesforce'));
            $this->postbox('basicsettings', __('Basic Settings', 'salesforce'), $content);
            $content = $this->checkbox('showccuser', __('Allow user to request a copy of their submission', 'salesforce'));
            $content .= '<br/>';
            $content .= $this->textinput('ccusermsg', __('Request a copy text', 'salesforce'));
            $content .= $this->textinput('subject', __('Email subject', 'salesforce'), __('Use %BLOG_NAME% to auto-insert the blog title into the subject', 'salesforce'));
            $content .= $this->checkbox('ccadmin', __('Send blog admin an email notification', 'salesforce'));
            //$content .= $this->checkbox('email_sender',__('Use this sender', 'salesforce') );
            $this->postbox('sfsettings', __('Email Settings', 'salesforce'), $content);
            $content = $this->textinput('submitbutton', __('Submit button text', 'salesforce'));
            $content .= $this->textinput('requiredfieldstext', __('Required fields text', 'salesforce'));
            $content .= $this->checkbox('captcha', __('Use CAPTCHA?', 'salesforce'));
            $content .= '<br/><small><a href="http://en.wikipedia.org/wiki/CAPTCHA" target="_blank">' . __('Learn more about CAPTCHAs at Wikipedia') . '</a></small>';
            $this->postbox('formsettings', __('Form Settings', 'salesforce'), $content);
            $content = $this->checkbox('usecss', __('Use Default CSS?', 'salesforce'));
            $content .= $this->checkbox('wpcf7css', __('Use WPCF7 CSS integration?', 'salesforce'));
            //$content .= $this->checkbox('hide_salesforce_link',__('Hide "Powered by Salesforce CRM" on form?', 'salesforce') );
            $content .= '<br/><small><a href="' . $this->plugin_options_url() . '&amp;tab=css">' . __('Read how to override the default CSS with your own CSS file') . '</a></small><br><br>';
            $this->postbox('csssettings', __('Style Settings', 'salesforce'), $content);
            $content = $this->checkbox('commentstoleads', __('Create a lead when an approved comment is published', 'salesforce'));
            $content .= $this->checkbox('commentsnamefields', __('Replace the "Name" field on the comment form with "First Name" and "Last Name"', 'salesforce'));
            $content .= sprintf('<p class="description">%s</p>', __('<small>Using first and last name fields allows for cleaner Salesforce leads, otherwise the "first name" on the lead will contain the full name, but it may create issues with some WordPress themes.</small>', 'salesforce'));
            $this->postbox('commentsettings', __('Comment Settings', 'salesforce'), $content);
            ?>
								<div class="submit"><input type="submit" class="button-primary" name="submit" value="<?php 
            _e("Save WordPress-to-Lead Settings", 'salesforce');
            ?>
" /></div>
								<?php 
            if (WP_DEBUG) {
                $this->postbox('options', 'DEBUG: Options', '<small>This dump of the plugin options is only shown when WP_DEBUG is enabled.</small><br><br>' . '<pre>' . print_r($options, true) . '</pre>', 'closed');
            }
            //DEBUG
            ?>
							
						</form>
						<?php 
        }
        if (isset($_GET['tab']) && $_GET['tab'] == 'css') {
            wp_enqueue_style('prismcss', plugins_url('assets/css/prism.css', dirname(__FILE__)));
            wp_enqueue_script('prismjs', plugins_url('assets/js/prism/prism.min.js', dirname(__FILE__)));
            //echo '<p>'.salesforce_back_link($this->plugin_options_url()).'</p>';
            ?>
						<p>
						<?php 
            echo __("<p>If you don't want the default styling this plugin uses, you can add the CSS for the form to your own theme by creating a folder named <i>salesforce-wordpress-to-lead</i> in your theme folder, then creating a file called <i>custom.css</i> within that with your custom CSS.</p>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<p>" . get_stylesheet_directory() . "/<b>salesforce-wordpress-to-lead</b>/<b>custom.css</b></p>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<p>If found, that file will be enqueued after the default CSS, or by itself if the default CSS is disabled on the main options screen.</p>\n\t\t\t\t\t\t\t");
            echo '<pre><code class="language-css">' . file_get_contents(dirname(plugin_dir_path(__FILE__)) . '/assets/css/sfwp2l.css') . '</code><pre>';
            ?>

<?php 
        } else {
            if (isset($_GET['tab']) && $_GET['tab'] == 'form') {
                if (isset($_POST['mode']) && $_POST['mode'] == 'delete' && $form_id != 1) {
                    echo '<div id="message" class="updated"><p>' . __('Deleted Form #', 'salesforce') . $form_id . '</p></div>';
                } else {
                    if (isset($_POST['mode']) && $_POST['mode'] == 'clone' && $form_id != 1) {
                        echo '<div id="message" class="updated"><p>' . __('Duplicated Form #', 'salesforce') . $form_id . '</p></div>';
                    } else {
                        if (!isset($form_id) && isset($_GET['id'])) {
                            $form_id = (int) $_GET['id'];
                        }
                        if (isset($_POST['form_id'])) {
                            $form_id = (int) $_POST['form_id'];
                        }
                        if (!isset($form_id) || $form_id == 0) {
                            //generate a new default form
                            end($options['forms']);
                            $form_id = key($options['forms']) + 1;
                            $options['forms'][$form_id] = $this->default_form();
                        }
                        //check for deleted forms
                        if ($form_id && !isset($options['forms'][$form_id])) {
                            echo '<div id="message" class="error"><p>' . __('This form could not be found.', 'salesforce') . '</p></div>';
                        } else {
                            if (isset($_POST['submit']) && $_POST['submit']) {
                                echo '<div id="message" class="updated"><p>' . __('Form settings updated.', 'salesforce') . '</p></div>';
                            }
                            ?>

						<form action="" method="post" id="salesforce-conf">
							<?php 
                            if (function_exists('wp_nonce_field')) {
                                wp_nonce_field('salesforce-udpatesettings');
                            }
                            ?>
							<input type="hidden" value="<?php 
                            echo $options['version'];
                            ?>
" name="version"/>
							<input type="hidden" value="editform" name="mode"/>								
							<?php 
                            //$this->postbox('options','Options','<pre>'.print_r($options,true).'</pre>'); //DEBUG
                            $content = '<p>';
                            $content .= '<input type="text" name="form_name" style="width:50%;" value="' . esc_html($options['forms'][$form_id]['form_name']) . '">';
                            //$content .= '<br/><small>'.__('').'</small>';
                            $content .= '</p>';
                            $this->postbox('sfformtitle', __('Form Name', 'salesforce'), $content);
                            $loc = 'banner-main';
                            $ad = $this->get_ad_code($loc);
                            if ($ad) {
                                $link = $this->get_ad_link($ad['id'], $loc, $ad['url']);
                                echo '<p style="text-align: center;"><a href="' . $link . '" target="_blank"><img src="' . plugins_url($ad['content'], dirname(__FILE__)) . '"></a></p>';
                            }
                            $content = '<table id="salesforce_form_editor" class="wp-list-table widefat fixed">';
                            $content .= '<tr>' . '<th width="10%">' . __('Field', 'salesforce') . '</th>' . '<th width="15%">' . __('Operations', 'salesforce') . '</th>' . '<th width="12%">' . __('Type', 'salesforce') . '</th>' . '<th width="13%">' . __('Label/Value', 'salesforce') . '</th>' . '<th width="20%">' . __('Options', 'salesforce') . '</th>' . '<th width="8%">' . __('Order', 'salesforce') . '</th>' . '</tr>';
                            $i = 1;
                            foreach ($options['forms'][$form_id]['inputs'] as $field => $input) {
                                $trclass = 'disabled';
                                if ($input['show']) {
                                    $trclass = 'enabled';
                                }
                                if (empty($input['pos'])) {
                                    $input['pos'] = $i;
                                }
                                $content .= '<tr class="' . $trclass . ' ' . ($i % 2 ? 'alternate' : '') . '">';
                                $content .= '<th>' . $field . '</th>';
                                $content .= '<td>';
                                $content .= '<table>';
                                $content .= '<tr>';
                                $content .= '<td><label for="inputs[' . $field . '_show]">Enabled</label></td>';
                                $content .= '<td><input type="checkbox" name="inputs[' . $field . '_show]" id="inputs[' . $field . '_show]" ' . checked($input['show'], true, false) . '/></td>';
                                $content .= '</tr><tr>';
                                $content .= '<td><label for="inputs[' . $field . '_required]">Required</label></td>';
                                $content .= '<td><input type="checkbox" name="inputs[' . $field . '_required]" id="inputs[' . $field . '_required]" ' . checked($input['required'], true, false) . '/></td>';
                                $content .= '</tr><tr>';
                                $content .= '<td><label for="inputs[' . $field . '_delete]">Delete</label></td>';
                                $content .= '<td><input type="checkbox" name="inputs[' . $field . '_delete]" id="inputs[' . $field . '_delete]" /></td>';
                                $content .= '</tr>';
                                $content .= '</table>';
                                $content .= '</td>';
                                $content .= '<td><select name="inputs[' . $field . '_type]">';
                                $content .= '<option value="text" ' . selected($input['type'], 'text', false) . '>text</option>';
                                $content .= '<option value="textarea" ' . selected($input['type'], 'textarea', false) . '>textarea</option>';
                                $content .= '<option value="hidden" ' . selected($input['type'], 'hidden', false) . '>hidden</option>';
                                $content .= '<option value="select" ' . selected($input['type'], 'select', false) . '>select (picklist)</option>';
                                $content .= '<option ' . selected($input['type'], 'checkbox', false) . '>checkbox</option>';
                                //$content .= '<option '.selected($input['type'],'current_date',false).'>current_date</option>';
                                $content .= '<option value="html" ' . selected($input['type'], 'html', false) . '>html</option>';
                                $content .= '</select></td>';
                                $content .= '<td><small>Label:</small> <input size="10" name="inputs[' . $field . '_label]" type="text" value="' . esc_html(stripslashes($input['label'])) . '"/>';
                                //</td>'.'<td>';
                                $content .= '<br><small>Value:</small> <input size="10" name="inputs[' . $field . '_value]" type="text" value="';
                                if (isset($input['value'])) {
                                    $content .= esc_html(stripslashes($input['value']));
                                }
                                $content .= '"/></td>';
                                $opts = '';
                                if (isset($input['opts'])) {
                                    $opts = $input['opts'];
                                }
                                $content .= '<td><textarea rows="4" name="inputs[' . $field . '_opts]"  >' . esc_textarea(stripslashes($opts)) . '</textarea></td>';
                                $content .= '<td><input size="2" name="inputs[' . $field . '_pos]" type="text" value="' . esc_html($input['pos']) . '"/></td>';
                                $content .= '</tr>';
                                $i++;
                            }
                            $content .= '</table>';
                            ?>
<script>

var pos = <?php 
                            echo $i;
                            ?>
;
var i = 1;
function salesforce_add_field(){
pos++;

var row = '<tr>';
row += '<td><input type="text" size="10" name="add_inputs['+i+'][field_name]"></td>';
row += '<td><table>'
row += '<tr><td><label for="add_inputs['+i+'][show]">Enabled</label></td><td><input type="checkbox" name="add_inputs['+i+'][show]"></td></tr>';
row += '<tr><td><label for="add_inputs['+i+'][required]">Required</label></td><td><input type="checkbox" name="add_inputs['+i+'][required]"></td></tr>';
row += '</table></td>';
row += '<td><select name="add_inputs['+i+'][type]">'
	+ '<option value="text">Text</option>'
	+ '<option value="textarea">Textarea</option>'
	+ '<option valur="hidden">Hidden</option>'
	+ '<option value="select">Select (picklist)</option>'
	+ '<option value="checkbox">Checkbox</option>'
	//+ '<option value="current_date">current_date</option>'
	+ '<option value="html">HTML</option>'
	+ '</select></td>';
row += '<td><small>Label:</small><input size="10" type="text" name="add_inputs['+i+'][label]">';
row += '<small>Value:</small><input size="14" type="text" name="add_inputs['+i+'][value]"></td>';
row += '<td><textarea rows="4" name="add_inputs['+i+'][opts]"></textarea></td>';
row += '<td><input type="text" size="2" name="add_inputs['+i+'][pos]" value="'+pos+'"></td>';
row += '</tr>';

jQuery('#salesforce_form_editor > tbody').append(row);

i++;

}

</script>
									<?php 
                            $content .= '<p><a class="button-secondary" href="javascript:salesforce_add_field();">Add a field</a></p>';
                            // $this->postbox('sffields',__('Form Fields', 'salesforce'),$content);
                            echo $content;
                            $content = '';
                            if ($options['forms'][$form_id]['type'] == '') {
                                $options['forms'][$form_id]['type'] = 'lead';
                            }
                            $content .= '<p>';
                            $content .= '<label>' . __('Form Type:', 'salesforce') . '</label><br/>';
                            $content .= '<input type="radio" name="type" value="lead" ' . checked($options['forms'][$form_id]['type'], 'lead', false) . '> Web to Lead <br>';
                            $content .= '<input type="radio" name="type" value="case"' . checked($options['forms'][$form_id]['type'], 'case', false) . '> Web to Case';
                            $content .= '<br/><small>' . __('<b>Note:</b> Daddy Analytics does not support cases at this time.') . '</small>';
                            $content .= '</p>';
                            $content .= '<p>';
                            $content .= '<label>' . __('Lead Source:', 'salesforce') . '</label><br/>';
                            $content .= '<input type="text" name="source" style="width:50%;" value="' . esc_html($options['forms'][$form_id]['source']) . '">';
                            $content .= '<br/><small>' . __('Lead Source (up to 40 characters) to display in Salesforce.com, use %URL% to include the URL of the page containing the form.') . '</small>';
                            if (!defined('SFWP2L_HIDE_ADS')) {
                                $content .= '<br/><br/><small>' . __('<b>Daddy Analytics</b> will populate the Lead Source field with the web source of the Lead (such as Organic - Google, Paid - Bing, or Google Adwords). Daddy Analytics will also populate the Salesforce Address field with the estimated GeoLocation of your Leads. <br><i>Leave the Lead Source field blank if you have a subscription to <a href="' . $this->get_ad_link('da_ls', 'text') . '">Daddy Analytics.</a></i>') . '</small>';
                            }
                            $content .= '</p>';
                            $content .= '<p>';
                            $content .= '<label>' . __('Return/Thanks URL:', 'salesforce') . '</label><br/>';
                            $content .= '<input type="text" name="returl" style="width:50%;" value="' . esc_html($options['forms'][$form_id]['returl']) . '">';
                            $content .= '<br/><small>' . __('e.g.http://yoursite.com/thanks/') . '</small>';
                            $content .= '</p>';
                            $content .= '<p>';
                            $content .= '<label>' . __('Success Message:', 'salesforce') . '</label><br/>';
                            $content .= '<input type="text" name="successmsg" style="width:50%;" value="' . esc_html($options['forms'][$form_id]['successmsg']) . '">';
                            $content .= '<br/><small>' . __('Overrides the default message for this form.(leave blank to use the global setting)') . '</small>';
                            $content .= '</p>';
                            $content .= '<p>';
                            $content .= '<label>' . __('Submit button text (override):', 'salesforce') . '</label><br/>';
                            $content .= '<input type="text" name="submitbutton" style="width:50%;" value="' . esc_html(stripslashes($options['forms'][$form_id]['submitbutton'])) . '">';
                            $content .= '<br/><small>' . __('Overrides the default message for this form.(leave blank to use the global setting)') . '</small>';
                            $content .= '</p>';
                            $content .= '<p>';
                            $content .= '<label>' . __('Required fields text (override):', 'salesforce') . '</label><br/>';
                            $content .= '<input type="text" name="requiredfieldstext" style="width:50%;" value="' . esc_html(stripslashes($options['forms'][$form_id]['requiredfieldstext'])) . '">';
                            $content .= '<br/><small>' . __('Overrides the default message for this form (leave blank to use the global setting).') . '</small>';
                            $content .= '</p>';
                            $content .= '<p>';
                            $content .= '<label>' . __('Captcha:', 'salesforce') . '</label><br/>';
                            $content .= '<input type="radio" name="captchaform" value=""' . checked($options['forms'][$form_id]['captchaform'], '', false) . '> Use global setting <br>';
                            $content .= '<input type="radio" name="captchaform" value="enabled" ' . checked($options['forms'][$form_id]['captchaform'], 'enabled', false) . '> Enabled for this form<br>';
                            $content .= '<input type="radio" name="captchaform" value="disabled"' . checked($options['forms'][$form_id]['captchaform'], 'disabled', false) . '> Disabled for this form';
                            $content .= '<br/><small>' . __('Overrides the default captcha settings for this form.') . '</small>';
                            $content .= '</p>';
                            $content .= '<p>';
                            $content .= '<label>' . __('Required Fields Text Location:', 'salesforce') . '</label><br/>';
                            $content .= '<input type="radio" name="requiredfieldstextpos" value=""' . checked($options['forms'][$form_id]['requiredfieldstextpos'], '', false) . '> Below Form <br>';
                            $content .= '<input type="radio" name="requiredfieldstextpos" value="top" ' . checked($options['forms'][$form_id]['requiredfieldstextpos'], 'top', false) . '> Above Form <br>';
                            $content .= '<input type="radio" name="requiredfieldstextpos" value="hidden"' . checked($options['forms'][$form_id]['requiredfieldstextpos'], 'hidden', false) . '> None';
                            $content .= '</p>';
                            $content .= '<p>';
                            $content .= '<label>' . __('Label Location:', 'salesforce') . '</label><br/>';
                            $content .= '<input type="radio" name="labellocation" value="top-aligned" ' . checked($options['forms'][$form_id]['labellocation'], '', false) . '> Top Aligned <br>';
                            $content .= '<input type="radio" name="labellocation" value="left-aligned"' . checked($options['forms'][$form_id]['labellocation'], 'left-aligned', false) . '> Left Aligned <br>';
                            $content .= '<input type="radio" name="labellocation" value="placeholders"' . checked($options['forms'][$form_id]['labellocation'], 'placeholders', false) . '> Placeholders';
                            $content .= '</p>';
                            $content .= '<input type="hidden" name="form_id" id="form_id" value="' . $form_id . '">';
                            $content .= '<p>';
                            $content .= '<label>' . __('Salesforce.com Organization ID (override):', 'salesforce') . '</label><br/>';
                            $content .= '<input type="text" name="org_id" style="width:50%;" value="' . esc_html(stripslashes($options['forms'][$form_id]['org_id'])) . '">';
                            $content .= '<br/><small>' . __('Overrides the default org_id for this form (leave blank to use the global setting).') . '</small>';
                            $content .= '</p>';
                            $this->postbox('sfformmeta', __('Form Settings', 'salesforce'), $content);
                            ?>
							
							<div class="submit"><input type="submit" class="button-primary" name="submit" value="<?php 
                            _e("Save Form", 'salesforce');
                            ?>
" /></div>
						</form>
						
							<?php 
                            if (!empty($_GET['id']) && $_GET['id'] != 1) {
                                ?>
							<form action="" method="post" id="salesforce-delete">
							<?php 
                                if (function_exists('wp_nonce_field')) {
                                    wp_nonce_field('salesforce-udpatesettings');
                                }
                                ?>
								<input type="hidden" value="delete" name="mode"/>
								<input type="hidden" value="<?php 
                                echo $form_id;
                                ?>
" name="form_id"/>
								<input type="submit" name="submit" class="button-secondary" value="Delete this form">
							</form>
							<form action="" method="post" id="salesforce-clone">
							<?php 
                                if (function_exists('wp_nonce_field')) {
                                    wp_nonce_field('salesforce-udpatesettings');
                                }
                                ?>
								<input type="hidden" value="clone" name="mode"/>
								<input type="hidden" value="<?php 
                                echo $form_id;
                                ?>
" name="form_id"/>
								<input type="submit" name="submit" class="button-secondary" value="Duplicate this form">
							</form>
							<?php 
                            }
                        }
                        ?>
				<?php 
                    }
                }
                ?>
				
				<?php 
                //echo '<p>'.salesforce_back_link($this->plugin_options_url()).'</p>';
                ?>
				
						<?php 
            }
        }
        ?>
					</div>
				</div>
			</div>
			<div class="postbox-container" style="width:20%;">
				<div class="metabox-holder">	
					<div class="meta-box-sortables">
						<?php 
        if (isset($_GET['id']) && $_GET['id']) {
            $fid = absint($_GET['id']);
            $this->postbox('usesalesforce', __('How to Use This Form', 'salesforce'), __('<p>To embed this form, copy the following shortcode into a post or page:</p><p> [salesforce form="' . $fid . '"] </p>', 'salesforce'));
        } else {
            $this->postbox('usesalesforce', __('How to Use This Plugin', 'salesforce'), __('<p>To embed a form, copy the following shortcode into a post or page:</p><p> [salesforce form="X"] </p><p>Replace X with the form number for the form you want to show.</p><p><i>Make sure you have entered all the correct settings on the left, including your Organization ID.</i></p>', 'salesforce'));
        }
        $this->plugin_like(false);
        $content = '<p>' . __('<b>Community</b><br>If you have any problems with this plugin, ideas for improvements, or  feature requests, please talk about them in the community support forum.<p><i>Be sure to read the <a target="_blank" href="http://wordpress.org/support/topic/support-guidelines/">support guidelines</a> before posting.</i></p>', 'ystplugin') . '</p><p><a target="_blank" class="button-secondary" href="http://wordpress.org/support/plugin/' . $this->hook . '">' . __("Get Community Support", 'ystplugin') . '</a></p>';
        $content .= '<p>' . __('<b>Premium</b><br>Need guaranteed support, customization help, or want to sponsor a feature addition?', 'ystplugin') . '</p><p> <a target="_blank" class="button-secondary" href="http://thoughtrefinery.com/plugins/support/?plugin=' . $this->hook . '">' . __("Request Premium Support", 'ystplugin') . '</a></p>';
        $this->postbox($this->hook . 'support', 'Need support?', $content);
        $loc = 'banner-side';
        $ad = $this->get_ad_code($loc);
        if ($ad) {
            $link = $this->get_ad_link($ad['id'], $loc, $ad['url']);
            $this->postbox('usesalesforce', __('Plugin Sponsor: Daddy Analytics', 'salesforce'), __('<p style="text-align: center;"><a href="' . $link . '" target="_blank"><img src="' . plugins_url($ad['content'], dirname(__FILE__)) . '"></a></p>', 'salesforce'));
        }
        $this->postbox('usesalesforce', __('Want to contribute?', 'salesforce'), __('<p class="aligncenter">Pull requests welcome!<br><br>
							
							<a class="button-secondary" href="https://github.com/nciske/salesforce-wordpress-to-lead" target="_blank">Fork me on GitHub</a><br><br>

							<a class="button-secondary" href="https://github.com/nciske/salesforce-wordpress-to-lead/issues" target="_blank">Submit an issue</a>

							
							
							
							</p>', 'salesforce'));
        // $this->news();
        ?>
					</div>
					<br/><br/><br/>
				</div>
			</div>
		</div>
		<?php 
    }