PageRenderTime 106ms CodeModel.GetById 12ms app.highlight 84ms RepoModel.GetById 1ms app.codeStats 0ms

/shared/classes/class.form.php

https://github.com/deltafactory/leads
PHP | 1085 lines | 860 code | 152 blank | 73 comment | 142 complexity | 1ab50bc18470e7ab40cb2ecea0e7b874 MD5 | raw file
   1<?php
   2/**
   3 * Creates Inbound Form Shortcode
   4 */
   5
   6if (!class_exists('Inbound_Forms')) {
   7class Inbound_Forms {
   8	static $add_script;
   9	//=============================================
  10	// Hooks and Filters
  11	//=============================================
  12	static function init()	{
  13
  14		add_shortcode('inbound_form', array(__CLASS__, 'inbound_forms_create'));
  15		add_shortcode('inbound_forms', array(__CLASS__, 'inbound_short_form_create'));
  16		add_action('init', array(__CLASS__, 'register_script'));
  17		add_action('wp_footer', array(__CLASS__, 'print_script'));
  18		add_action('wp_footer', array(__CLASS__, 'inline_my_script'));
  19		add_action( 'init',	array(__CLASS__, 'do_actions'));
  20		add_filter( 'inbound_replace_email_tokens' , array( __CLASS__ , 'replace_tokens' ) , 10 , 3 );
  21
  22	}
  23
  24	/* Create Longer shortcode for [inbound_form] */
  25	static function inbound_forms_create( $atts, $content = null )
  26	{
  27
  28		global $post;
  29
  30		self::$add_script = true;
  31
  32		$email = get_option('admin_email');
  33
  34		extract(shortcode_atts(array(
  35			'id' => '',
  36			'name' => '',
  37			'layout' => '',
  38			'notify' => $email,
  39			'notify_subject' => '{{site-name}} {{form-name}} - New Lead Conversion',
  40			'labels' => '',
  41			'font_size' => '', // set default from CSS
  42			'width' => '',
  43			'redirect' => '',
  44			'icon' => '',
  45			'lists' => '',
  46			'submit' => 'Submit',
  47			'submit_colors' => '',
  48			'submit_text_color' => '',
  49			'submit_bg_color' => ''
  50		), $atts));
  51
  52
  53		if ( !$id && isset($_GET['post']) ) {
  54			$id = $_GET['post'];
  55		}
  56
  57
  58		$form_name = $name;
  59		//$form_name = strtolower(str_replace(array(' ','_', '"', "'"),'-',$form_name));
  60		$form_layout = $layout;
  61		$form_labels = $labels;
  62		$form_labels_class = (isset($form_labels)) ? "inbound-label-".$form_labels : 'inbound-label-inline';
  63		$submit_button = ($submit != "") ? $submit : 'Submit';
  64		$icon_insert = ($icon != "" && $icon != 'none') ? '<i class="fa-'. $icon . '" font-awesome fa"></i>' : '';
  65
  66		// Set submit button colors
  67		if(isset($submit_colors) && $submit_colors === 'on'){
  68			$submit_bg = " background:" . $submit_bg_color . "; border: 5px solid ".$submit_bg_color."; border-radius: 3px;";
  69			$submit_color = " color:" . $submit_text_color . ";";
  70
  71		} else {
  72			$submit_bg = "";
  73			$submit_color = "";
  74		}
  75
  76		if (preg_match("/px/", $font_size)){
  77			$font_size = (isset($font_size)) ? " font-size: $font_size;" : '';
  78		} else if (preg_match("/%/", $font_size)) {
  79			$font_size = (isset($font_size)) ? " font-size: $font_size;" : '';
  80		} else if (preg_match("/em/", $font_size)) {
  81			$font_size = (isset($font_size)) ? " font-size: $font_size;" : '';
  82		} else if ($font_size == "") {
  83			$font_size = '';
  84		} else {
  85			$font_size = (isset($font_size)) ? " font-size:" . $font_size . "px;" : '';
  86		}
  87
  88		// Check for image in submit button option
  89		if (preg_match('/\.(jpg|jpeg|png|gif)(?:[\?\#].*)?$/i',$submit_button)) {
  90			$image_button = ' color: rgba(0, 0, 0, 0);border: none;box-shadow: none;background: transparent; border-radius:0px;padding: 0px;';
  91			$inner_button = "<img src='$submit_button' width='100%'>";
  92			$icon_insert = '';
  93			$submit_button = '';
  94		} else {
  95			$image_button = '';
  96			$inner_button = '';
  97
  98		}
  99
 100		/* Sanitize width input */
 101		if (preg_match('/px/i',$width)) {
 102			$fixed_width = str_replace("px", "", $width);
 103			$width_output = "width:" . $fixed_width . "px;";
 104		} elseif (preg_match('/%/i',$width)) {
 105			$fixed_width_perc = str_replace("%", "", $width);
 106			$width_output = "width:" . $fixed_width_perc . "%;";
 107		} else {
 108			$width_output = "width:" . $width . "px;";
 109		}
 110
 111		$form_width = ($width != "") ? $width_output : '';
 112
 113		//if (!preg_match_all("/(.?)\[(inbound_field)\b(.*?)(?:(\/))?\](?:(.+?)\[\/inbound_field\])?(.?)/s", $content, $matches)) {
 114		if (!preg_match_all('/(.?)\[(inbound_field)(.*?)\]/s',$content, $matches))
 115		{
 116			return '';
 117
 118		}
 119		else
 120		{
 121			for($i = 0; $i < count($matches[0]); $i++)
 122			{
 123				$matches[3][$i] = shortcode_parse_atts($matches[3][$i]);
 124			}
 125			//print_r($matches[3]);
 126			// matches are $matches[3][$i]['label']
 127			$clean_form_id = preg_replace("/[^A-Za-z0-9 ]/", '', trim($name));
 128			$form_id = strtolower(str_replace(array(' ','_'),'-',$clean_form_id));
 129
 130
 131			$form = '<div id="inbound-form-wrapper" class="">';
 132			$form .= '<form class="inbound-now-form wpl-track-me" method="post" id="'.$form_id.'" action="" style="'.$form_width.'">';
 133			$main_layout = ($form_layout != "") ? 'inbound-'.$form_layout : 'inbound-normal';
 134			for($i = 0; $i < count($matches[0]); $i++)
 135			{
 136
 137				$label = (isset($matches[3][$i]['label'])) ? $matches[3][$i]['label'] : '';
 138
 139
 140				$clean_label = preg_replace("/[^A-Za-z0-9 ]/", '', trim($label));
 141				$formatted_label = strtolower(str_replace(array(' ','_'),'-',$clean_label));
 142				$field_placeholder = (isset($matches[3][$i]['placeholder'])) ? $matches[3][$i]['placeholder'] : '';
 143
 144				$placeholder_use = ($field_placeholder != "") ? $field_placeholder : $label;
 145
 146				if ($field_placeholder != "")
 147				{
 148					$form_placeholder = "placeholder='".$placeholder_use."'";
 149				}
 150				else if (isset($form_labels) && $form_labels === "placeholder")
 151				{
 152					$form_placeholder = "placeholder='".$placeholder_use."'";
 153				}
 154				else
 155				{
 156					$form_placeholder = "";
 157				}
 158
 159				$description_block = (isset($matches[3][$i]['description'])) ? $matches[3][$i]['description'] : '';
 160				$field_container_class = (isset($matches[3][$i]['field_container_class'])) ? $matches[3][$i]['field_container_class'] : '';
 161				$field_input_class = (isset($matches[3][$i]['field_input_class'])) ? $matches[3][$i]['field_input_class'] : '';
 162				$required = (isset($matches[3][$i]['required'])) ? $matches[3][$i]['required'] : '0';
 163				$req = ($required === '1') ? 'required' : '';
 164				$req_label = ($required === '1') ? '<span class="inbound-required">*</span>' : '';
 165				$map_field = (isset($matches[3][$i]['map_to'])) ? $matches[3][$i]['map_to'] : '';
 166				if ($map_field != "") {
 167					$field_name = $map_field;
 168				} else {
 169					$field_name = strtolower(str_replace(array(' ','_'),'-',$label));
 170				}
 171
 172
 173				/* Map Common Fields */
 174				(preg_match( '/Email|e-mail|email/i', $label, $email_input)) ? $email_input = " inbound-email" : $email_input = "";
 175
 176				// Match Phone
 177				(preg_match( '/Phone|phone number|telephone/i', $label, $phone_input)) ? $phone_input = " inbound-phone" : $phone_input = "";
 178
 179				// match name or first name. (minus: name=, last name, last_name,)
 180				(preg_match( '/(?<!((last |last_)))name(?!\=)/im', $label, $first_name_input)) ? $first_name_input = " inbound-first-name" : $first_name_input =	"";
 181
 182				// Match Last Name
 183				(preg_match( '/(?<!((first)))(last name|last_name|last)(?!\=)/im', $label, $last_name_input)) ? $last_name_input = " inbound-last-name" : $last_name_input =	"";
 184
 185				$input_classes = $email_input . $first_name_input . $last_name_input . $phone_input;
 186
 187				$type = (isset($matches[3][$i]['type'])) ? $matches[3][$i]['type'] : '';
 188				$show_labels = true;
 189
 190				if ($type === "hidden" || $type === "honeypot" || $type === "html-block" || $type === "divider") {
 191					$show_labels = false;
 192				}
 193
 194				$form .= '<div class="inbound-field '.$main_layout.' label-'.$form_labels_class.' '.$field_container_class.'">';
 195
 196				if ($show_labels && $form_labels != "bottom" || $type === "radio")
 197				{
 198					$form .= '<label for="'. $field_name .'" class="inbound-label '.$formatted_label.' '.$form_labels_class.' inbound-input-'.$type.'" style="'.$font_size.'">' . $matches[3][$i]['label'] . $req_label . '</label>';
 199				}
 200
 201				if ($type === 'textarea') {
 202					$form .=	'<textarea class="inbound-input inbound-input-textarea '.$field_input_class.'" name="'.$field_name.'" id="in_'.$field_name.'" '.$req.'/>'.$placeholder_use.'</textarea>';
 203				}
 204				else if ($type === 'dropdown')
 205				{
 206					$dropdown_fields = array();
 207					$dropdown = $matches[3][$i]['dropdown'];
 208					$dropdown_fields = explode(",", $dropdown);
 209
 210					$form .= '<select name="'. $field_name .'" class="'.$field_input_class.'"  '.$req.'>';
 211
 212					if ($placeholder_use) {
 213						$form .= '<option value="" disabled selected>'.str_replace( '%3F' , '?' , $placeholder_use).'</option>';
 214					}
 215
 216					foreach ($dropdown_fields as $key => $value) {
 217						//$drop_val_trimmed =	trim($value);
 218						//$dropdown_val = strtolower(str_replace(array(' ','_'),'-',$drop_val_trimmed));
 219						$form .= '<option value="'. trim(str_replace('"', '\"' , $value)) .'">'. $value .'</option>';
 220					}
 221					$form .= '</select>';
 222
 223				} else if ($type === 'dropdown_countries') {
 224
 225					$dropdown_fields = self::get_countries_array();
 226
 227					$form .= '<select name="'. $field_name .'" class="'.$field_input_class.'" '.$req.'>';
 228
 229					if ($field_placeholder) {
 230						$form .= '<option value="" disabled selected>'.$field_placeholder.'</option>';
 231					}
 232
 233					foreach ($dropdown_fields as $key => $value) {
 234						$form .= '<option value="'.$key.'">'. utf8_encode($value) .'</option>';
 235					}
 236					$form .= '</select>';
 237				}
 238				else if ($type === 'date-selector')
 239				{
 240					$m = date('m');
 241					$d = date('d');
 242					$y = date('Y');
 243
 244					$months = self::get_date_selectons('months');
 245					$days = self::get_date_selectons('days');
 246					$years = self::get_date_selectons('years');
 247
 248					$form .= '<div class="dateSelector">';
 249					$form .= '	<select id="formletMonth" name="'. $field_name .'[month]" >';
 250					foreach ($months as $key => $value) {
 251						( $m == $key ) ? $sel = 'selected="selected"' : $sel = '';
 252						$form .= '<option value="'.$key.'" '.$sel.'>'.$value.'</option>';
 253					}
 254					$form .= '	</select>';
 255					$form .= '	<select id="formletDays" name="'. $field_name .'[day]" >';
 256					foreach ($days as $key => $value) {
 257						( $d == $key ) ? $sel = 'selected="selected"' : $sel = '';
 258						$form .= '<option value="'.$key.'" '.$sel.'>'.$value.'</option>';
 259					}
 260					$form .= '	</select>';
 261					$form .= '	<select id="formletYears" name="'. $field_name .'[year]" >';
 262					foreach ($years as $key => $value) {
 263						( $y == $key ) ? $sel = 'selected="selected"' : $sel = '';
 264						$form .= '<option value="'.$key.'" '.$sel.'>'.$value.'</option>';
 265					}
 266					$form .= '	</select>';
 267					$form .= '</div>';
 268
 269				}
 270				else if ($type === 'radio')
 271				{
 272					$radio_fields = array();
 273					$radio = $matches[3][$i]['radio'];
 274					$radio_fields = explode(",", $radio);
 275					// $clean_radio = str_replace(array(' ','_'),'-',$value) // clean leading spaces. finish
 276
 277					foreach ($radio_fields as $key => $value)
 278					{
 279						$radio_val_trimmed =	trim($value);
 280						$radio_val =	strtolower(str_replace(array(' ','_'),'-',$radio_val_trimmed));
 281						$form .= '<span class="radio-'.$main_layout.' radio-'.$form_labels_class.' '.$field_input_class.'"><input type="radio" name="'. $field_name .'" value="'. $radio_val .'">'. $radio_val_trimmed .'</span>';
 282					}
 283				} else if ($type === 'checkbox') {
 284					$checkbox_fields = array();
 285
 286					$checkbox = $matches[3][$i]['checkbox'];
 287					$checkbox_fields = explode(",", $checkbox);
 288					// $clean_radio = str_replace(array(' ','_'),'-',$value) // clean leading spaces. finish
 289					foreach ($checkbox_fields as $key => $value) {
 290						$value = html_entity_decode($value);
 291						$checkbox_val_trimmed =	strip_tags(trim($value));
 292						$checkbox_val =	strtolower(str_replace(array(' ','_'),'-',$checkbox_val_trimmed));
 293
 294
 295						$required_id = ( $key == 0 ) ? $req : '';
 296
 297						$form .= '<input class="checkbox-'.$main_layout.' checkbox-'.$form_labels_class.' '.$field_input_class.'" type="checkbox" name="'. $field_name .'" value="'. $checkbox_val .'" '.$required_id.'>'.$value.'<br>';
 298					}
 299				} else if ($type === 'html-block') {
 300					$html = $matches[3][$i]['html'];
 301					//echo $html;
 302					$form .= "<div class={$field_input_class}>";
 303					$form .= do_shortcode(html_entity_decode($html));
 304					$form .= "</div>";
 305				} else if ($type === 'divider') {
 306					$divider = $matches[3][$i]['divider_options'];
 307					//echo $html;
 308					$form .= "<div class='inbound-form-divider {$field_input_class}'>" . $divider . "<hr></div>";
 309				} else if ($type === 'editor') {
 310					//wp_editor(); // call wp editor
 311				} else if ($type === 'honeypot') {
 312					$form .= '<input type="hidden" name="stop_dirty_subs" class="stop_dirty_subs" value="">';
 313				} else {
 314					$hidden_param = (isset($matches[3][$i]['dynamic'])) ? $matches[3][$i]['dynamic'] : '';
 315					$fill_value = (isset($matches[3][$i]['default'])) ? $matches[3][$i]['default'] : '';
 316					$dynamic_value = (isset($_GET[$hidden_param])) ? $_GET[$hidden_param] : '';
 317					if ($type === 'hidden' && $dynamic_value != "") {
 318						$fill_value = $dynamic_value;
 319					}
 320					$form .=	'<input class="inbound-input inbound-input-text '.$formatted_label . $input_classes.' '.$field_input_class.'" name="'.$field_name.'" '.$form_placeholder.' id="'.$formatted_label.'" value="'.$fill_value.'" type="'.$type.'" '.$req.'/>';
 321				}
 322				if ($show_labels && $form_labels === "bottom" && $type != "radio") {
 323					$form .= '<label for="'. $field_name .'" class="inbound-label '.$formatted_label.' '.$form_labels_class.' inbound-input-'.$type.'" style="'.$font_size.'">' . $matches[3][$i]['label'] . $req_label . '</label>';
 324				}
 325
 326				if ($description_block != "" && $type != 'hidden'){
 327					$form .= "<div class='inbound-description'>".$description_block."</div>";
 328				}
 329
 330				$form .= '</div>';
 331			}
 332			// End Loop
 333
 334			$current_page =  "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
 335			$form .= '<div class="inbound-field '.$main_layout.' inbound-submit-area"><button type="submit" class="inbound-button-submit inbound-submit-action" value="'.$submit_button.'" name="send" id="inbound_form_submit" style="'.$submit_bg.$submit_color.$image_button.'">
 336						'.$icon_insert.''.$submit_button.$inner_button.'</button></div><input type="hidden" name="inbound_submitted" value="1">';
 337					// <!--<input type="submit" '.$submit_button_type.' class="button" value="'.$submit_button.'" name="send" id="inbound_form_submit" />-->
 338
 339			$form .= '<input type="hidden" name="inbound_form_name" class="inbound_form_name" value="'.$form_name.'"><input type="hidden" name="inbound_form_lists" id="inbound_form_lists" value="'.$lists.'"><input type="hidden" name="inbound_form_id" class="inbound_form_id" value="'.$id.'"><input type="hidden" name="inbound_current_page_url" value="'.$current_page.'"><input type="hidden" name="inbound_furl" value="'. base64_encode($redirect) .'"><input type="hidden" name="inbound_notify" value="'. base64_encode($notify) .'"><input type="hidden" name="inbound_params" value=""></form></div>';
 340			$form .= "<style type='text/css'>.inbound-button-submit{ {$font_size} }</style>";
 341			$form = preg_replace('/<br class="inbr".\/>/', '', $form); // remove editor br tags
 342
 343			return $form;
 344		}
 345	}
 346
 347	/* Create shorter shortcode for [inbound_forms] */
 348	static function inbound_short_form_create( $atts, $content = null )
 349	{
 350		extract(shortcode_atts(array(
 351			'id' => '',
 352		), $atts));
 353
 354		$shortcode = get_post_meta( $id, 'inbound_shortcode', TRUE );
 355
 356		// If form id missing add it
 357		if (!preg_match('/id="/', $shortcode)) {
 358		$shortcode = str_replace("[inbound_form", "[inbound_form id=\"" . $id . "\"", $shortcode);
 359		}
 360		if ($id === 'default_3'){
 361			$shortcode = '[inbound_form name="Form Name" layout="vertical" labels="top" submit="Submit" ][inbound_field label="Email" type="text" required="1" ][/inbound_form]';
 362		}
 363		if ($id === 'default_1'){
 364			$shortcode = '[inbound_form name="3 Field Form" layout="vertical" labels="top" submit="Submit" ][inbound_field label="First Name" type="text" required="0" ][inbound_field label="Last Name" type="text" required="0" ][inbound_field label="Email" type="text" required="1" placeholder="Enter Your Email Address" ][/inbound_form]';
 365		}
 366		if ($id === 'default_2'){
 367			$shortcode = '[inbound_form name="Standard Company Form" layout="vertical" labels="top" submit="Submit" ]
 368
 369						[inbound_field label="First Name" type="text" required="0" placeholder="Enter Your First Name" ]
 370
 371						[inbound_field label="Last Name" type="text" required="0" placeholder="Enter Your Last Name" ]
 372
 373						[inbound_field label="Email" type="text" required="1" placeholder="Enter Your Email Address" ]
 374
 375						[inbound_field label="Company Name" type="text" required="0" placeholder="Enter Your Company Name" ]
 376
 377						[inbound_field label="Job Title" type="text" required="0" placeholder="Enter Your Job Title" ]
 378
 379						[/inbound_form]';
 380		}
 381		if (empty($shortcode)) {
 382			$shortcode = "Form ID: " . $id . " Not Found";
 383		}
 384		if ($id === 'none'){
 385			$shortcode = "";
 386		}
 387
 388		return do_shortcode( $shortcode );
 389	}
 390
 391	/* Enqueue JS & CSS */
 392	static function register_script()
 393	{
 394		wp_enqueue_style( 'inbound-shortcodes' );
 395	}
 396
 397	// only call enqueue once
 398	static function print_script()
 399	{
 400		if ( ! self::$add_script )
 401		return;
 402		wp_enqueue_style( 'inbound-shortcodes' );
 403	}
 404
 405	// move to file
 406	static function inline_my_script()
 407	{
 408		if ( ! self::$add_script )
 409			return;
 410
 411		echo '<script type="text/javascript">
 412			jQuery(document).ready(function($){
 413
 414
 415			jQuery("form").submit(function(e) {
 416				jQuery(this).find("input").each(function(){
 417				    if(!jQuery(this).prop("required")){
 418				    } else if (!jQuery(this).val()) {
 419					alert("Oops! Looks like you have not filled out all of the required fields!");
 420					e.preventDefault();
 421					e.stopImmediatePropagation();
 422					return false;
 423				    }
 424				});
 425			});
 426
 427			jQuery("#inbound_form_submit br").remove(); // remove br tags
 428			function validateEmail(email) {
 429
 430				var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
 431				return re.test(email);
 432			}
 433			var parent_redirect = parent.window.location.href;
 434			jQuery("#inbound_parent_page").val(parent_redirect);
 435
 436
 437		// validate email
 438			$("input.inbound-email").on("change keyup", function (e) {
 439				var email = $(this).val();
 440				if (validateEmail(email)) {
 441					$(this).css("color", "green");
 442					$(this).addClass("valid-email");
 443					$(this).removeClass("invalid-email");
 444				} else {
 445					$(this).css("color", "red");
 446					$(this).addClass("invalid-email");
 447					$(this).removeClass("valid-email");
 448				}
 449				if($(this).hasClass("valid-email")) {
 450					$(this).parent().parent().find("#inbound_form_submit").removeAttr("disabled");
 451				}
 452			});
 453
 454			});
 455			</script>';
 456
 457		echo "<style type='text/css'>
 458		/* Add button style options http://medleyweb.com/freebies/50-super-sleek-css-button-style-snippets/ */
 459		input.invalid-email {-webkit-box-shadow: 0 0 6px #F8B9B7;
 460							-moz-box-shadow: 0 0 6px #f8b9b7;
 461							box-shadow: 0 0 6px #F8B9B7;
 462							color: #B94A48;
 463							border-color: #E9322D;}
 464		input.valid-email {-webkit-box-shadow: 0 0 6px #B7F8BA;
 465					-moz-box-shadow: 0 0 6px #f8b9b7;
 466					box-shadow: 0 0 6px #98D398;
 467					color: #008000;
 468					border-color: #008000;}
 469			</style>";
 470	}
 471
 472	public static function replace_tokens( $content , $form_data = null , $form_meta_data = null ) {
 473
 474		/* replace core tokens */
 475		$content = str_replace('{{site-name}}', get_bloginfo( 'name' ) , $content);
 476		//$content = str_replace('{{form-name}}', $form_data['inbound_form_name']		, $content);
 477
 478		foreach ($form_data as $key => $value) {
 479			$token_key = str_replace('_','-', $key);
 480			$token_key = str_replace('inbound-','', $token_key);
 481
 482			$content = str_replace( '{{'.trim($token_key).'}}' , $value , $content );
 483		}
 484
 485		return $content;
 486	}
 487	// Save Form Conversion to Form CPT
 488	static function store_form_stats($form_id, $email) {
 489
 490			//$time = current_time( 'timestamp', 0 ); // Current wordpress time from settings
 491			// $wordpress_date_time = date("Y-m-d G:i:s", $time);
 492			$form_conversion_num = get_post_meta($form_id, 'inbound_form_conversion_count', true);
 493			$form_conversion_num++;
 494			update_post_meta( $form_id, 'inbound_form_conversion_count', $form_conversion_num );
 495
 496			// Add Lead Email to Conversions List
 497			$lead_conversion_list = get_post_meta( $form_id, 'lead_conversion_list', TRUE );
 498			$lead_conversion_list = json_decode($lead_conversion_list,true);
 499			if (is_array($lead_conversion_list)) {
 500				$lead_count = count($lead_conversion_list);
 501				$lead_conversion_list[$lead_count]['email'] = $email;
 502				// $lead_conversion_list[$lead_count]['date'] = $wordpress_date_time;
 503				$lead_conversion_list = json_encode($lead_conversion_list);
 504				update_post_meta( $form_id, 'lead_conversion_list', $lead_conversion_list );
 505			} else {
 506				$lead_conversion_list = array();
 507				$lead_conversion_list[0]['email'] = $email;
 508				//	$lead_conversion_list[0]['date'] = $wordpress_date_time;
 509				$lead_conversion_list = json_encode($lead_conversion_list);
 510				update_post_meta( $form_id, 'lead_conversion_list', $lead_conversion_list );
 511			}
 512
 513	}
 514	/* Perform Actions After a Form Submit */
 515	static function do_actions(){
 516
 517		if(isset($_POST['inbound_submitted']) && $_POST['inbound_submitted'] === '1')
 518		{
 519
 520			if(isset($_POST['stop_dirty_subs']) && $_POST['stop_dirty_subs'] != "") {
 521				wp_die( $message = 'Die You spam bastard' );
 522				return false;
 523			}
 524			/* get form submitted form's meta data */
 525			$form_meta_data = get_post_meta( $_POST['inbound_form_id'] );
 526
 527			if(isset($_POST['inbound_furl']) && $_POST['inbound_furl'] != "") {
 528				$redirect = base64_decode($_POST['inbound_furl']);
 529			} else if (isset($_POST['inbound_current_page_url'])) {
 530				$redirect = $_POST['inbound_current_page_url'];
 531			}
 532
 533			if(isset($_POST['inbound_furl']) && $_POST['inbound_furl'] != "") {
 534
 535				$params = json_decode($_POST['inbound_params'],true);
 536				print_r($params);
 537				exit;
 538			}
 539
 540			//print_r($_POST);
 541			foreach ( $_POST as $field => $value ) {
 542
 543				if ( get_magic_quotes_gpc() ) {
 544					$value = stripslashes( $value );
 545				}
 546
 547				$field = strtolower($field);
 548
 549				if (preg_match( '/Email|e-mail|email/i', $field)) {
 550					$field = "wpleads_email_address";
 551					if(isset($_POST['inbound_form_id']) && $_POST['inbound_form_id'] != "") {
 552						self::store_form_stats($_POST['inbound_form_id'], $value);
 553					}
 554				}
 555
 556				if (preg_match( '/(?<!((last |last_)))name(?!\=)/im', $field) && !isset($form_post_data['wpleads_first_name'])) {
 557					$field = "wpleads_first_name";
 558				}
 559
 560				if (preg_match( '/(?<!((first)))(last name|last_name|last)(?!\=)/im', $field) && !isset($form_post_data['wpleads_last_name'])) {
 561					$field = "wpleads_last_name";
 562				}
 563
 564				if (preg_match( '/Phone|phone number|telephone/i', $field)) {
 565					$field = "wpleads_work_phone";
 566				}
 567
 568				$form_post_data[$field] = strip_tags( $value );
 569			}
 570
 571			$form_meta_data['post_id'] = $_POST['inbound_form_id']; // pass in form id
 572
 573			/* Send emails if passes spam checks - spam checks happen on lead store ajax script and here on the email actions script - redundantly */
 574			if (!apply_filters( 'form_actions_spam_check' , $form_post_data ) ) {
 575				self::send_conversion_admin_notification($form_post_data , $form_meta_data);
 576				self::send_conversion_lead_notification($form_post_data , $form_meta_data);
 577			}
 578
 579			/* hook runs after form actions are completed and before page redirect */
 580			do_action('inboundnow_form_submit_actions', $form_post_data, $form_meta_data);
 581
 582			/* redirect now */
 583			if ($redirect != "") {
 584				wp_redirect( $redirect );
 585				exit();
 586			}
 587
 588		}
 589
 590	}
 591
 592	/* Sends Notification of New Lead Conversion to Admin & Others Listed on the Form Notification List */
 593	public static function send_conversion_admin_notification( $form_post_data , $form_meta_data ) {
 594
 595		if ( $template = self::get_new_lead_email_template()) {
 596
 597			add_filter( 'wp_mail_content_type', 'set_html_content_type' );
 598			function set_html_content_type() {
 599				return 'text/html';
 600			}
 601
 602			/* Rebuild Form Meta Data to Load Single Values	*/
 603			foreach( $form_meta_data as $key => $value ) {
 604				$form_meta_data[$key] = $value[0];
 605			}
 606
 607			/* Get Email We Should Send Notifications To */
 608			$email_to = $form_meta_data['inbound_notify_email'];
 609
 610			/* Check for Multiple Email Addresses */
 611			$addresses = explode(",", $email_to);
 612			if(is_array($addresses) && count($addresses) > 1) {
 613				$to_address = $addresses;
 614			} else {
 615				$to_address[] = $email_to;
 616			}
 617
 618			/* Look for Custom Subject Line ,	Fall Back on Default */
 619			$subject = (isset($form_meta_data['inbound_notify_email_subject'])) ? $form_meta_data['inbound_notify_email_subject'] :	$template['subject'];
 620
 621			/* Discover From Email Address */
 622			foreach ($form_post_data as $key => $value) {
 623				if (preg_match('/email|e-mail/i', $key)) {
 624					$from_email = $form_post_data[$key];
 625				}
 626			}
 627
 628			/* Prepare Additional Data For Token Engine */
 629			$form_post_data['redirect_message'] = (isset($form_post_data['inbound_redirect']) && $form_post_data['inbound_redirect'] != "") ? "They were redirected to " . $form_post_data['inbound_redirect'] : '';
 630
 631			/* Discover From Name */
 632			$from_name = get_option( 'blogname' , '' );
 633			$Inbound_Templating_Engine = Inbound_Templating_Engine();
 634			$subject = $Inbound_Templating_Engine->replace_tokens( $subject , array( $form_post_data , $form_meta_data )	);
 635			$body = $Inbound_Templating_Engine->replace_tokens( $template['body'] , array( $form_post_data , $form_meta_data )	);
 636
 637
 638			$headers = 'From: '. $from_name .' <'. $from_email .'>' . "\r\n";
 639			$headers = apply_filters( 'inbound_lead_notification_email_headers' , $headers );
 640
 641			foreach ($to_address as $key => $recipient) {
 642				$result = wp_mail( $recipient , $subject , $body , $headers );
 643			}
 644
 645		}
 646
 647	}
 648
 649	/* Sends An Email to Lead After Conversion */
 650	public static function send_conversion_lead_notification( $form_post_data , $form_meta_data ) {
 651
 652
 653		/* If Notifications Are Off Then Exit */
 654		if ( !isset($form_meta_data['inbound_email_send_notification'][0]) || $form_meta_data['inbound_email_send_notification'][0] != 'on' ){
 655			return;
 656		}
 657
 658		/* Get Lead Email Address */
 659		$lead_email = false;
 660		foreach ($form_post_data as $key => $value) {
 661			if (preg_match('/email|e-mail/i', $key)) {
 662				$lead_email = $form_post_data[$key];
 663			}
 664		}
 665
 666		/* Redundancy */
 667		if (!$lead_email) {
 668			if (isset($form_post_data['email'])) {
 669				$lead_email = $form_post_data['email'];
 670			} else if (isset($form_post_data['e-mail'])) {
 671				$lead_email = $form_post_data['e-mail'];
 672			} else if (isset($form_post_data['wpleads_email_address'])) {
 673				$lead_email = $form_post_data['wpleads_email_address'];
 674			} else {
 675				$lead_email = 'null map email field';
 676			}
 677		}
 678
 679		if ( !$lead_email ) {
 680			return;
 681		}
 682
 683
 684		$Inbound_Templating_Engine = Inbound_Templating_Engine();
 685		$form_id = $form_meta_data['post_id']; //This is page id or post id
 686		$template_id = $form_meta_data['inbound_email_send_notification_template'][0];
 687
 688		/* Rebuild Form Meta Data to Load Single Values	*/
 689		foreach( $form_meta_data as $key => $value ) {
 690			$form_meta_data[$key] = $value[0];
 691		}
 692
 693		/* If Email Template Selected Use That */
 694		if ( $template_id && $template_id != 'custom' ) {
 695
 696			$template_array = self::get_email_template( $template_id );
 697			$confirm_subject = $template_array['subject'];
 698			$confirm_email_message = $template_array['body'];
 699
 700		}
 701		/* Else Use Custom Template */
 702		else {
 703
 704			$template = get_post($form_id);
 705			$content = $template->post_content;
 706			$confirm_subject = get_post_meta( $form_id, 'inbound_confirmation_subject', TRUE );
 707			$content = apply_filters('the_content', $content);
 708			$content = str_replace(']]>', ']]&gt;', $content);
 709
 710			$confirm_email_message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 711				<html>
 712				<head>
 713					<meta http-equiv="Content-Type" content="text/html;' . get_option('blog_charset') . '" />
 714				</head>
 715				<body style="margin: 0px; background-color: #F4F3F4; font-family: Helvetica, Arial, sans-serif; font-size:12px;" text="#444444" bgcolor="#F4F3F4" link="#21759B" alink="#21759B" vlink="#21759B" marginheight="0" topmargin="0" marginwidth="0" leftmargin="0">
 716					<table cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff" border="0">
 717					<tr>';
 718			$confirm_email_message .= $content;
 719			$confirm_email_message .= '</tr>
 720							</table>
 721						</body>
 722						</html>';
 723		}
 724
 725
 726
 727		$confirm_subject = $Inbound_Templating_Engine->replace_tokens( $confirm_subject , array( $form_post_data , $form_meta_data )	);
 728		$confirm_email_message = $Inbound_Templating_Engine->replace_tokens( $confirm_email_message , array( $form_post_data , $form_meta_data )	);
 729
 730
 731		$from_name = get_option( 'blogname' , '' );
 732		$from_email = get_option( 'admin_email' );
 733
 734		$headers	= "From: " . $from_name . " <" . $from_email . ">\n";
 735		$headers .= 'Content-type: text/html';
 736
 737		wp_mail( $lead_email, $confirm_subject , $confirm_email_message, $headers );
 738
 739	}
 740
 741	/* Get Email Template for New Lead Notification */
 742	public static function get_new_lead_email_template( ) {
 743
 744		$email_template = array();
 745
 746		$templates = get_posts(array(
 747			'post_type' => 'email-template',
 748			'posts_per_page' => 1,
 749			'meta_key' => '_inbound_template_id',
 750			'meta_value' => 'inbound-new-lead-notification'
 751		));
 752
 753		foreach ( $templates as $template ) {
 754			$email_template['ID'] = $template->ID;
 755			$email_template['subject'] = get_post_meta( $template->ID , 'inbound_email_subject_template' , true );
 756			$email_template['body'] = get_post_meta( $template->ID , 'inbound_email_body_template' , true );
 757		}
 758
 759		return $email_template;
 760	}
 761
 762	/* Get Email Template by ID */
 763	public static function get_email_template( $ID ) {
 764
 765		$email_template = array();
 766
 767		$template = get_post($ID);
 768
 769		$email_template['ID'] = $template->ID;
 770		$email_template['subject'] = get_post_meta( $template->ID , 'inbound_email_subject_template' , true );
 771		$email_template['body'] = get_post_meta( $template->ID , 'inbound_email_body_template' , true );
 772
 773		return $email_template;
 774	}
 775
 776	/**
 777	*  Prepare an array of days, months, years. Make i18n ready
 778	*  @param STRING $case lets us know which array to return
 779	*
 780	*  @returns ARRAY of data
 781	*/
 782	public static function get_date_selectons( $case ) {
 783
 784		switch( $case ) {
 785
 786			case 'months':
 787				return array(
 788					'01' => __( 'Jan' , 'leads' ),
 789					'02' => __( 'Feb' , 'leads' ),
 790					'03' => __( 'Mar' , 'leads' ),
 791					'04' => __( 'Apr' , 'leads' ),
 792					'05' => __( 'May' , 'leads' ),
 793					'06' => __( 'Jun' , 'leads' ),
 794					'07' => __( 'Jul' , 'leads' ),
 795					'08' => __( 'Aug' , 'leads' ),
 796					'09' => __( 'Sep' , 'leads' ),
 797					'10' => __( 'Oct' , 'leads' ),
 798					'11' => __( 'Nov' , 'leads' ),
 799					'12' => __( 'Dec' , 'leads' )
 800				);
 801				break;
 802			case 'days' :
 803				return array (
 804					'01' => '01',	'02' => '02',	'03' => '03',	'04' => '04',	'05' => '05',
 805					'06' => '06',	'07' => '07',	'08' => '08',	'09' => '09',	'10' => '10',
 806					'11' => '11',	'12' => '12',	'13' => '13',	'14' => '14',	'15' => '15',
 807					'16' => '16',	'17' => '17',	'18' => '18',	'19' => '19',	'20' => '20',
 808					'21' => '21',	'22' => '22',	'23' => '23',	'24' => '24',	'25' => '25',
 809					'26' => '26',	'27' => '27',	'28' => '28',	'29' => '29',	'30' => '30',
 810					'31' => '31'
 811				);
 812				break;
 813			case 'years' :
 814
 815				for ($i=1920;$i<2101;$i++) {
 816					$years[$i] = $i;
 817				}
 818
 819				return $years;
 820				break;
 821		}
 822	}
 823
 824	/**
 825	*  Prepare an array of country codes and country names. Make i18n ready
 826	*/
 827	public static function get_countries_array() {
 828		return array (
 829			 __( 'AF' , 'leads') => __( 'Afghanistan' , 'leads' ) ,
 830			 __( 'AX' , 'leads') => __( 'Aland Islands' , 'leads' ) ,
 831			 __( 'AL' , 'leads') => __( 'Albania' , 'leads' ) ,
 832			 __( 'DZ' , 'leads') => __( 'Algeria' , 'leads' ) ,
 833			 __( 'AS' , 'leads') => __( 'American Samoa' , 'leads' ) ,
 834			 __( 'AD' , 'leads') => __( 'Andorra' , 'leads' ) ,
 835			 __( 'AO' , 'leads') => __( 'Angola' , 'leads' ) ,
 836			 __( 'AI' , 'leads') => __( 'Anguilla' , 'leads' ) ,
 837			 __( 'AQ' , 'leads') => __( 'Antarctica' , 'leads' ) ,
 838			 __( 'AG' , 'leads') => __( 'Antigua and Barbuda' , 'leads' ) ,
 839			 __( 'AR' , 'leads') => __( 'Argentina' , 'leads' ) ,
 840			 __( 'AM' , 'leads') => __( 'Armenia' , 'leads' ) ,
 841			 __( 'AW' , 'leads') => __( 'Aruba' , 'leads' ) ,
 842			 __( 'AU' , 'leads') => __( 'Australia' , 'leads' ) ,
 843			 __( 'AT' , 'leads') => __( 'Austria' , 'leads' ) ,
 844			 __( 'AZ' , 'leads') => __( 'Azerbaijan' , 'leads' ) ,
 845			 __( 'BS' , 'leads') => __( 'Bahamas' , 'leads' ) ,
 846			 __( 'BH' , 'leads') => __( 'Bahrain' , 'leads' ) ,
 847			 __( 'BD' , 'leads') => __( 'Bangladesh' , 'leads' ) ,
 848			 __( 'BB' , 'leads') => __( 'Barbados' , 'leads' ) ,
 849			 __( 'BY' , 'leads') => __( 'Belarus' , 'leads' ) ,
 850			 __( 'BE' , 'leads') => __( 'Belgium' , 'leads' ) ,
 851			 __( 'BZ' , 'leads') => __( 'Belize' , 'leads' ) ,
 852			 __( 'BJ' , 'leads') => __( 'Benin' , 'leads' ) ,
 853			 __( 'BM' , 'leads') => __( 'Bermuda' , 'leads' ) ,
 854			 __( 'BT' , 'leads') => __( 'Bhutan' , 'leads' ) ,
 855			 __( 'BO' , 'leads') => __( 'Bolivia' , 'leads' ) ,
 856			 __( 'BA' , 'leads') => __( 'Bosnia and Herzegovina' , 'leads' ) ,
 857			 __( 'BW' , 'leads') => __( 'Botswana' , 'leads' ) ,
 858			 __( 'BV' , 'leads') => __( 'Bouvet Island' , 'leads' ) ,
 859			 __( 'BR' , 'leads') => __( 'Brazil' , 'leads' ) ,
 860			 __( 'IO' , 'leads') => __( 'British Indian Ocean Territory' , 'leads' ) ,
 861			 __( 'BN' , 'leads') => __( 'Brunei Darussalam' , 'leads' ) ,
 862			 __( 'BG' , 'leads') => __( 'Bulgaria' , 'leads' ) ,
 863			 __( 'BF' , 'leads') => __( 'Burkina Faso' , 'leads' ) ,
 864			 __( 'BI' , 'leads') => __( 'Burundi' , 'leads' ) ,
 865			 __( 'KH' , 'leads') => __( 'Cambodia' , 'leads' ) ,
 866			 __( 'CM' , 'leads') => __( 'Cameroon' , 'leads' ) ,
 867			 __( 'CA' , 'leads') => __( 'Canada' , 'leads' ) ,
 868			 __( 'CV' , 'leads') => __( 'Cape Verde' , 'leads' ) ,
 869			 __( 'BQ' , 'leads') => __( 'Caribbean Netherlands ' , 'leads' ) ,
 870			 __( 'KY' , 'leads') => __( 'Cayman Islands' , 'leads' ) ,
 871			 __( 'CF' , 'leads') => __( 'Central African Republic' , 'leads' ) ,
 872			 __( 'TD' , 'leads') => __( 'Chad' , 'leads' ) ,
 873			 __( 'CL' , 'leads') => __( 'Chile' , 'leads' ) ,
 874			 __( 'CN' , 'leads') => __( 'China' , 'leads' ) ,
 875			 __( 'CX' , 'leads') => __( 'Christmas Island' , 'leads' ) ,
 876			 __( 'CC' , 'leads') => __( 'Cocos (Keeling) Islands' , 'leads' ) ,
 877			 __( 'CO' , 'leads') => __( 'Colombia' , 'leads' ) ,
 878			 __( 'KM' , 'leads') => __( 'Comoros' , 'leads' ) ,
 879			 __( 'CG' , 'leads') => __( 'Congo' , 'leads' ) ,
 880			 __( 'CD' , 'leads') => __( 'Congo, Democratic Republic of' , 'leads' ) ,
 881			 __( 'CK' , 'leads') => __( 'Cook Islands' , 'leads' ) ,
 882			 __( 'CR' , 'leads') => __( 'Costa Rica' , 'leads' ) ,
 883			 __( 'CI' , 'leads') => __( 'Cote d\'Ivoire' , 'leads' ) ,
 884			 __( 'HR' , 'leads') => __( 'Croatia' , 'leads' ) ,
 885			 __( 'CU' , 'leads') => __( 'Cuba' , 'leads' ) ,
 886			 __( 'CW' , 'leads') => __( 'Curacao' , 'leads' ) ,
 887			 __( 'CY' , 'leads') => __( 'Cyprus' , 'leads' ) ,
 888			 __( 'CZ' , 'leads') => __( 'Czech Republic' , 'leads' ) ,
 889			 __( 'DK' , 'leads') => __( 'Denmark' , 'leads' ) ,
 890			 __( 'DJ' , 'leads') => __( 'Djibouti' , 'leads' ) ,
 891			 __( 'DM' , 'leads') => __( 'Dominica' , 'leads' ) ,
 892			 __( 'DO' , 'leads') => __( 'Dominican Republic' , 'leads' ) ,
 893			 __( 'EC' , 'leads') => __( 'Ecuador' , 'leads' ) ,
 894			 __( 'EG' , 'leads') => __( 'Egypt' , 'leads' ) ,
 895			 __( 'SV' , 'leads') => __( 'El Salvador' , 'leads' ) ,
 896			 __( 'GQ' , 'leads') => __( 'Equatorial Guinea' , 'leads' ) ,
 897			 __( 'ER' , 'leads') => __( 'Eritrea' , 'leads' ) ,
 898			 __( 'EE' , 'leads') => __( 'Estonia' , 'leads' ) ,
 899			 __( 'ET' , 'leads') => __( 'Ethiopia' , 'leads' ) ,
 900			 __( 'FK' , 'leads') => __( 'Falkland Islands' , 'leads' ) ,
 901			 __( 'FO' , 'leads') => __( 'Faroe Islands' , 'leads' ) ,
 902			 __( 'FJ' , 'leads') => __( 'Fiji' , 'leads' ) ,
 903			 __( 'FI' , 'leads') => __( 'Finland' , 'leads' ) ,
 904			 __( 'FR' , 'leads') => __( 'France' , 'leads' ) ,
 905			 __( 'GF' , 'leads') => __( 'French Guiana' , 'leads' ) ,
 906			 __( 'PF' , 'leads') => __( 'French Polynesia' , 'leads' ) ,
 907			 __( 'TF' , 'leads') => __( 'French Southern Territories' , 'leads' ) ,
 908			 __( 'GA' , 'leads') => __( 'Gabon' , 'leads' ) ,
 909			 __( 'GM' , 'leads') => __( 'Gambia' , 'leads' ) ,
 910			 __( 'GE' , 'leads') => __( 'Georgia' , 'leads' ) ,
 911			 __( 'DE' , 'leads') => __( 'Germany' , 'leads' ) ,
 912			 __( 'GH' , 'leads') => __( 'Ghana' , 'leads' ) ,
 913			 __( 'GI' , 'leads') => __( 'Gibraltar' , 'leads' ) ,
 914			 __( 'GR' , 'leads') => __( 'Greece' , 'leads' ) ,
 915			 __( 'GL' , 'leads') => __( 'Greenland' , 'leads' ) ,
 916			 __( 'GD' , 'leads') => __( 'Grenada' , 'leads' ) ,
 917			 __( 'GP' , 'leads') => __( 'Guadeloupe' , 'leads' ) ,
 918			 __( 'GU' , 'leads') => __( 'Guam' , 'leads' ) ,
 919			 __( 'GT' , 'leads') => __( 'Guatemala' , 'leads' ) ,
 920			 __( 'GG' , 'leads') => __( 'Guernsey' , 'leads' ) ,
 921			 __( 'GN' , 'leads') => __( 'Guinea' , 'leads' ) ,
 922			 __( 'GW' , 'leads') => __( 'Guinea-Bissau' , 'leads' ) ,
 923			 __( 'GY' , 'leads') => __( 'Guyana' , 'leads' ) ,
 924			 __( 'HT' , 'leads') => __( 'Haiti' , 'leads' ) ,
 925			 __( 'HM' , 'leads') => __( 'Heard and McDonald Islands' , 'leads' ) ,
 926			 __( 'HN' , 'leads') => __( 'Honduras' , 'leads' ) ,
 927			 __( 'HK' , 'leads') => __( 'Hong Kong' , 'leads' ) ,
 928			 __( 'HU' , 'leads') => __( 'Hungary' , 'leads' ) ,
 929			 __( 'IS' , 'leads') => __( 'Iceland' , 'leads' ) ,
 930			 __( 'IN' , 'leads') => __( 'India' , 'leads' ) ,
 931			 __( 'ID' , 'leads') => __( 'Indonesia' , 'leads' ) ,
 932			 __( 'IR' , 'leads') => __( 'Iran' , 'leads' ) ,
 933			 __( 'IQ' , 'leads') => __( 'Iraq' , 'leads' ) ,
 934			 __( 'IE' , 'leads') => __( 'Ireland' , 'leads' ) ,
 935			 __( 'IM' , 'leads') => __( 'Isle of Man' , 'leads' ) ,
 936			 __( 'IL' , 'leads') => __( 'Israel' , 'leads' ) ,
 937			 __( 'IT' , 'leads') => __( 'Italy' , 'leads' ) ,
 938			 __( 'JM' , 'leads') => __( 'Jamaica' , 'leads' ) ,
 939			 __( 'JP' , 'leads') => __( 'Japan' , 'leads' ) ,
 940			 __( 'JE' , 'leads') => __( 'Jersey' , 'leads' ) ,
 941			 __( 'JO' , 'leads') => __( 'Jordan' , 'leads' ) ,
 942			 __( 'KZ' , 'leads') => __( 'Kazakhstan' , 'leads' ) ,
 943			 __( 'KE' , 'leads') => __( 'Kenya' , 'leads' ) ,
 944			 __( 'KI' , 'leads') => __( 'Kiribati' , 'leads' ) ,
 945			 __( 'KW' , 'leads') => __( 'Kuwait' , 'leads' ) ,
 946			 __( 'KG' , 'leads') => __( 'Kyrgyzstan' , 'leads' ) ,
 947			 __( 'LA' , 'leads') => __( 'Lao People\'s Democratic Republic' , 'leads' ) ,
 948			 __( 'LV' , 'leads') => __( 'Latvia' , 'leads' ) ,
 949			 __( 'LB' , 'leads') => __( 'Lebanon' , 'leads' ) ,
 950			 __( 'LS' , 'leads') => __( 'Lesotho' , 'leads' ) ,
 951			 __( 'LR' , 'leads') => __( 'Liberia' , 'leads' ) ,
 952			 __( 'LY' , 'leads') => __( 'Libya' , 'leads' ) ,
 953			 __( 'LI' , 'leads') => __( 'Liechtenstein' , 'leads' ) ,
 954			 __( 'LT' , 'leads') => __( 'Lithuania' , 'leads' ) ,
 955			 __( 'LU' , 'leads') => __( 'Luxembourg' , 'leads' ) ,
 956			 __( 'MO' , 'leads') => __( 'Macau' , 'leads' ) ,
 957			 __( 'MK' , 'leads') => __( 'Macedonia' , 'leads' ) ,
 958			 __( 'MG' , 'leads') => __( 'Madagascar' , 'leads' ) ,
 959			 __( 'MW' , 'leads') => __( 'Malawi' , 'leads' ) ,
 960			 __( 'MY' , 'leads') => __( 'Malaysia' , 'leads' ) ,
 961			 __( 'MV' , 'leads') => __( 'Maldives' , 'leads' ) ,
 962			 __( 'ML' , 'leads') => __( 'Mali' , 'leads' ) ,
 963			 __( 'MT' , 'leads') => __( 'Malta' , 'leads' ) ,
 964			 __( 'MH' , 'leads') => __( 'Marshall Islands' , 'leads' ) ,
 965			 __( 'MQ' , 'leads') => __( 'Martinique' , 'leads' ) ,
 966			 __( 'MR' , 'leads') => __( 'Mauritania' , 'leads' ) ,
 967			 __( 'MU' , 'leads') => __( 'Mauritius' , 'leads' ) ,
 968			 __( 'YT' , 'leads') => __( 'Mayotte' , 'leads' ) ,
 969			 __( 'MX' , 'leads') => __( 'Mexico' , 'leads' ) ,
 970			 __( 'FM' , 'leads') => __( 'Micronesia, Federated States of' , 'leads' ) ,
 971			 __( 'MD' , 'leads') => __( 'Moldova' , 'leads' ) ,
 972			 __( 'MC' , 'leads') => __( 'Monaco' , 'leads' ) ,
 973			 __( 'MN' , 'leads') => __( 'Mongolia' , 'leads' ) ,
 974			 __( 'ME' , 'leads') => __( 'Montenegro' , 'leads' ) ,
 975			 __( 'MS' , 'leads') => __( 'Montserrat' , 'leads' ) ,
 976			 __( 'MA' , 'leads') => __( 'Morocco' , 'leads' ) ,
 977			 __( 'MZ' , 'leads') => __( 'Mozambique' , 'leads' ) ,
 978			 __( 'MM' , 'leads') => __( 'Myanmar' , 'leads' ) ,
 979			 __( 'NA' , 'leads') => __( 'Namibia' , 'leads' ) ,
 980			 __( 'NR' , 'leads') => __( 'Nauru' , 'leads' ) ,
 981			 __( 'NP' , 'leads') => __( 'Nepal' , 'leads' ) ,
 982			 __( 'NC' , 'leads') => __( 'New Caledonia' , 'leads' ) ,
 983			 __( 'NZ' , 'leads') => __( 'New Zealand' , 'leads' ) ,
 984			 __( 'NI' , 'leads') => __( 'Nicaragua' , 'leads' ) ,
 985			 __( 'NE' , 'leads') => __( 'Niger' , 'leads' ) ,
 986			 __( 'NG' , 'leads') => __( 'Nigeria' , 'leads' ) ,
 987			 __( 'NU' , 'leads') => __( 'Niue' , 'leads' ) ,
 988			 __( 'NF' , 'leads') => __( 'Norfolk Island' , 'leads' ) ,
 989			 __( 'KP' , 'leads') => __( 'North Korea' , 'leads' ) ,
 990			 __( 'MP' , 'leads') => __( 'Northern Mariana Islands' , 'leads' ) ,
 991			 __( 'NO' , 'leads') => __( 'Norway' , 'leads' ) ,
 992			 __( 'OM' , 'leads') => __( 'Oman' , 'leads' ) ,
 993			 __( 'PK' , 'leads') => __( 'Pakistan' , 'leads' ) ,
 994			 __( 'PW' , 'leads') => __( 'Palau' , 'leads' ) ,
 995			 __( 'PS' , 'leads') => __( 'Palestinian Territory, Occupied' , 'leads' ) ,
 996			 __( 'PA' , 'leads') => __( 'Panama' , 'leads' ) ,
 997			 __( 'PG' , 'leads') => __( 'Papua New Guinea' , 'leads' ) ,
 998			 __( 'PY' , 'leads') => __( 'Paraguay' , 'leads' ) ,
 999			 __( 'PE' , 'leads') => __( 'Peru' , 'leads' ) ,
1000			 __( 'PH' , 'leads') => __( 'Philippines' , 'leads' ) ,
1001			 __( 'PN' , 'leads') => __( 'Pitcairn' , 'leads' ) ,
1002			 __( 'PL' , 'leads') => __( 'Poland' , 'leads' ) ,
1003			 __( 'PT' , 'leads') => __( 'Portugal' , 'leads' ) ,
1004			 __( 'PR' , 'leads') => __( 'Puerto Rico' , 'leads' ) ,
1005			 __( 'QA' , 'leads') => __( 'Qatar' , 'leads' ) ,
1006			 __( 'RE' , 'leads') => __( 'Reunion' , 'leads' ) ,
1007			 __( 'RO' , 'leads') => __( 'Romania' , 'leads' ) ,
1008			 __( 'RU' , 'leads') => __( 'Russian Federation' , 'leads' ) ,
1009			 __( 'RW' , 'leads') => __( 'Rwanda' , 'leads' ) ,
1010			 __( 'BL' , 'leads') => __( 'Saint Barthelemy' , 'leads' ) ,
1011			 __( 'SH' , 'leads') => __( 'Saint Helena' , 'leads' ) ,
1012			 __( 'KN' , 'leads') => __( 'Saint Kitts and Nevis' , 'leads' ) ,
1013			 __( 'LC' , 'leads') => __( 'Saint Lucia' , 'leads' ) ,
1014			 __( 'VC' , 'leads') => __( 'Saint Vincent and the Grenadines' , 'leads' ) ,
1015			 __( 'MF' , 'leads') => __( 'Saint-Martin (France)' , 'leads' ) ,
1016			 __( 'SX' , 'leads') => __( 'Saint-Martin (Pays-Bas)' , 'leads' ) ,
1017			 __( 'WS' , 'leads') => __( 'Samoa' , 'leads' ) ,
1018			 __( 'SM' , 'leads') => __( 'San Marino' , 'leads' ) ,
1019			 __( 'ST' , 'leads') => __( 'Sao Tome and Principe' , 'leads' ) ,
1020			 __( 'SA' , 'leads') => __( 'Saudi Arabia' , 'leads' ) ,
1021			 __( 'SN' , 'leads') => __( 'Senegal' , 'leads' ) ,
1022			 __( 'RS' , 'leads') => __( 'Serbia' , 'leads' ) ,
1023			 __( 'SC' , 'leads') => __( 'Seychelles' , 'leads' ) ,
1024			 __( 'SL' , 'leads') => __( 'Sierra Leone' , 'leads' ) ,
1025			 __( 'SG' , 'leads') => __( 'Singapore' , 'leads' ) ,
1026			 __( 'SK' , 'leads') => __( 'Slovakia (Slovak Republic)' , 'leads' ) ,
1027			 __( 'SI' , 'leads') => __( 'Slovenia' , 'leads' ) ,
1028			 __( 'SB' , 'leads') => __( 'Solomon Islands' , 'leads' ) ,
1029			 __( 'SO' , 'leads') => __( 'Somalia' , 'leads' ) ,
1030			 __( 'ZA' , 'leads') => __( 'South Africa' , 'leads' ) ,
1031			 __( 'GS' , 'leads') => __( 'South Georgia and the South Sandwich Islands' , 'leads' ) ,
1032			 __( 'KR' , 'leads') => __( 'South Korea' , 'leads' ) ,
1033			 __( 'SS' , 'leads') => __( 'South Sudan' , 'leads' ) ,
1034			 __( 'ES' , 'leads') => __( 'Spain' , 'leads' ) ,
1035			 __( 'LK' , 'leads') => __( 'Sri Lanka' , 'leads' ) ,
1036			 __( 'PM' , 'leads') => __( 'St. Pierre and Miquelon' , 'leads' ) ,
1037			 __( 'SD' , 'leads') => __( 'Sudan' , 'leads' ) ,
1038			 __( 'SR' , 'leads') => __( 'Suriname' , 'leads' ) ,
1039			 __( 'SJ' , 'leads') => __( 'Svalbard and Jan Mayen Islands' , 'leads' ) ,
1040			 __( 'SZ' , 'leads') => __( 'Swaziland' , 'leads' ) ,
1041			 __( 'SE' , 'leads') => __( 'Sweden' , 'leads' ) ,
1042			 __( 'CH' , 'leads') => __( 'Switzerland' , 'leads' ) ,
1043			 __( 'SY' , 'leads') => __( 'Syria' , 'leads' ) ,
1044			 __( 'TW' , 'leads') => __( 'Taiwan' , 'leads' ) ,
1045			 __( 'TJ' , 'leads') => __( 'Tajikistan' , 'leads' ) ,
1046			 __( 'TZ' , 'leads') => __( 'Tanzania' , 'leads' ) ,
1047			 __( 'TH' , 'leads') => __( 'Thailand' , 'leads' ) ,
1048			 __( 'NL' , 'leads') => __( 'The Netherlands' , 'leads' ) ,
1049			 __( 'TL' , 'leads') => __( 'Timor-Leste' , 'leads' ) ,
1050			 __( 'TG' , 'leads') => __( 'Togo' , 'leads' ) ,
1051			 __( 'TK' , 'leads') => __( 'Tokelau' , 'leads' ) ,
1052			 __( 'TO' , 'leads') => __( 'Tonga' , 'leads' ) ,
1053			 __( 'TT' , 'leads') => __( 'Trinidad and Tobago' , 'leads' ) ,
1054			 __( 'TN' , 'leads') => __( 'Tunisia' , 'leads' ) ,
1055			 __( 'TR' , 'leads') => __( 'Turkey' , 'leads' ) ,
1056			 __( 'TM' , 'leads') => __( 'Turkmenistan' , 'leads' ) ,
1057			 __( 'TC' , 'leads') => __( 'Turks and Caicos Islands' , 'leads' ) ,
1058			 __( 'TV' , 'leads') => __( 'Tuvalu' , 'leads' ) ,
1059			 __( 'UG' , 'leads') => __( 'Uganda' , 'leads' ) ,
1060			 __( 'UA' , 'leads') => __( 'Ukraine' , 'leads' ) ,
1061			 __( 'AE' , 'leads') => __( 'United Arab Emirates' , 'leads' ) ,
1062			 __( 'GB' , 'leads') => __( 'United Kingdom' , 'leads' ) ,
1063			 __( 'US' , 'leads') => __( 'United States' , 'leads' ) ,
1064			 __( 'UM' , 'leads') => __( 'United States Minor Outlying Islands' , 'leads' ) ,
1065			 __( 'UY' , 'leads') => __( 'Uruguay' , 'leads' ) ,
1066			 __( 'UZ' , 'leads') => __( 'Uzbekistan' , 'leads' ) ,
1067			 __( 'VU' , 'leads') => __( 'Vanuatu' , 'leads' ) ,
1068			 __( 'VA' , 'leads') => __( 'Vatican' , 'leads' ) ,
1069			 __( 'VE' , 'leads') => __( 'Venezuela' , 'leads' ) ,
1070			 __( 'VN' , 'leads') => __( 'Vietnam' , 'leads' ) ,
1071			 __( 'VG' , 'leads') => __( 'Virgin Islands (British)' , 'leads' ) ,
1072			 __( 'VI' , 'leads') => __( 'Virgin Islands (U.S.)' , 'leads' ) ,
1073			 __( 'WF' , 'leads') => __( 'Wallis and Futuna Islands' , 'leads' ) ,
1074			 __( 'EH' , 'leads') => __( 'Western Sahara' , 'leads' ) ,
1075			 __( 'YE' , 'leads') => __( 'Yemen' , 'leads' ) ,
1076			 __( 'ZM' , 'leads') => __( 'Zambia' , 'leads' ) ,
1077			 __( 'ZW' , 'leads') => __( 'Zimbabwe' , 'leads' )
1078		);
1079	}
1080
1081	}
1082}
1083
1084Inbound_Forms::init();
1085?>