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