public static function notify_moderator($template, $comment_id)
 {
     $comment = get_comment($comment_id);
     if (empty($comment)) {
         return false;
     }
     $post = get_post($comment->comment_post_ID);
     $author = get_userdata($post->post_author);
     /* Ignore Pingbacks & Trackbacks */
     switch ($comment->comment_type) {
         case 'trackback':
             return $template;
             break;
         case 'pingback':
             return $template;
             break;
     }
     /* Sets Email Type as HTML */
     self::set_email_type();
     /* Get Template Array */
     $Inbound_Templating_Engine = Inbound_Templating_Engine();
     $template_array = self::get_template('wp-notify-moderator');
     /* Discover if Subject or Body Template is Needed */
     if (current_filter() == 'comment_moderation_subject') {
         $template = $template_array['subject'];
     } else {
         if (current_filter() == 'comment_moderation_text') {
             $template = $template_array['body'];
         }
     }
     $args = array(array('wp_comment_id' => $comment->comment_ID, 'wp_comment_url' => get_permalink($comment->comment_post_ID) . '#comments-' . $comment->comment_post_ID, 'wp_comment_author' => $comment->comment_author, 'wp_comment_author_email' => $comment->comment_author_email, 'wp_comment_author_url' => $comment->comment_author_url, 'wp_comment_author_ip' => $comment->comment_author_IP, 'wp_comment_date' => $comment->comment_date, 'wp_comment_content' => $comment->comment_content, 'wp_comment_karma' => $comment->comment_karma, 'wp_comment_type' => $comment->comment_type), array('wp_post_id' => $post->ID, 'wp_post_title' => $post->post_title, 'wp_post_url' => get_permalink($post->ID), 'wp_post_date' => $post->post_date, 'wp_post_content' => $post->post_content, 'wp_post_excerpt' => $post->post_excerpt), array('wp_user_id' => $author->ID, 'wp_user_login' => stripslashes($author->user_login), 'wp_user_email' => stripslashes($author->user_email), 'wp_user_first_name' => stripslashes($author->first_name), 'wp_user_last_name' => stripslashes($author->last_name), 'wp_user_nicename' => stripslashes($author->nice_name), 'wp_user_displayname' => stripslashes($author->display_name)));
     /* Replace Tokens */
     $template = $Inbound_Templating_Engine->replace_tokens($template, $args);
     return $template;
 }
 /**
  *  Sends An Email to Lead After Conversion
  */
 public static function send_conversion_lead_notification($form_post_data, $form_meta_data)
 {
     /* If Notifications Are Off Then Exit */
     if (!isset($form_meta_data['inbound_email_send_notification'][0]) || $form_meta_data['inbound_email_send_notification'][0] != 'on') {
         return;
     }
     /* Listen for Inbound Mailer takeover */
     if (apply_filters('inbound-forms/email-reponse-hijack', false, $form_meta_data, $form_post_data)) {
         return;
     }
     /* Get Lead Email Address */
     $lead_email = false;
     foreach ($form_post_data as $key => $value) {
         if (preg_match('/email|e-mail/i', $key)) {
             $lead_email = $form_post_data[$key];
         }
     }
     /* Redundancy */
     if (!$lead_email) {
         if (isset($form_post_data['email'])) {
             $lead_email = $form_post_data['email'];
         } else {
             if (isset($form_post_data['e-mail'])) {
                 $lead_email = $form_post_data['e-mail'];
             } else {
                 if (isset($form_post_data['wpleads_email_address'])) {
                     $lead_email = $form_post_data['wpleads_email_address'];
                 } else {
                     $lead_email = 'null map email field';
                 }
             }
         }
     }
     if (!$lead_email) {
         return;
     }
     $Inbound_Templating_Engine = Inbound_Templating_Engine();
     $form_id = $form_meta_data['post_id'];
     //This is page id or post id
     /* Rebuild Form Meta Data to Load Single Values	*/
     foreach ($form_meta_data as $key => $value) {
         $form_meta_data[$key] = $value[0];
     }
     $template = get_post($form_id);
     $content = $template->post_content;
     $confirm_subject = get_post_meta($form_id, 'inbound_confirmation_subject', TRUE);
     $content = apply_filters('the_content', $content);
     $content = str_replace(']]>', ']]>', $content);
     $confirm_email_message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><meta http-equiv="Content-Type" content="text/html;' . get_option('blog_charset') . '" /></head><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"><table cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff" border="0"><tr>';
     $confirm_email_message .= $content;
     $confirm_email_message .= '</tr></table></body></html>';
     $confirm_subject = apply_filters('inbound_email_response/subject', $confirm_subject, $form_meta_data, $form_post_data);
     $confirm_email_message = apply_filters('inbound_email_response/body', $confirm_email_message, $form_meta_data, $form_post_data);
     $confirm_subject = $Inbound_Templating_Engine->replace_tokens($confirm_subject, array($form_post_data, $form_meta_data));
     /* add default subject if empty */
     if (!$confirm_subject) {
         $confirm_subject = __('Thank you!', INBOUNDNOW_TEXT_DOMAIN);
     }
     $confirm_email_message = $Inbound_Templating_Engine->replace_tokens($confirm_email_message, array($form_post_data, $form_meta_data));
     $from_name = get_option('blogname', '');
     $from_email = get_option('admin_email');
     $headers = "From: " . $from_name . " <" . $from_email . ">\n";
     $headers .= 'Content-type: text/html';
     wp_mail($lead_email, $confirm_subject, $confirm_email_message, $headers);
 }
        public static function preview_template()
        {
            global $post;
            if (isset($post) && $post->post_type == 'email-template') {
                $user = wp_get_current_user();
                $Inbound_Templating_Engine = Inbound_Templating_Engine();
                $body = get_post_meta($post->ID, 'inbound_email_body_template', true);
                /* Prepare Demo Data */
                $args = array(array('wp_comment_id' => 1, 'wp_comment_url' => get_permalink(1) . '#comments-1', 'wp_comment_author' => 'Comment Author', 'wp_comment_author_email' => '*****@*****.**', 'wp_comment_author_url' => 'http://www.inboundnow.com/about/', 'wp_comment_author_ip' => '1.1.1.1.1', 'wp_comment_date' => date('F jS, Y \\a\\t g:ia', current_time('timestamp', 0)), 'wp_comment_content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'), array('wp_post_id' => '1', 'wp_post_title' => 'Hello World', 'wp_post_url' => 'http://www.google.com/earth/', 'wp_post_date' => date('F jS, Y \\a\\t g:ia', current_time('timestamp', 0)), 'wp_post_content' => 'The standard Lorem Ipsum passage, used since the 1500s

"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC

"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"', 'wp_post_excerpt' => '"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."'), array('wp_user_id' => $user_id, 'wp_user_login' => stripslashes($user->user_login), 'wp_user_email' => stripslashes($user->user_email), 'wp_user_first_name' => stripslashes($user->first_name), 'wp_user_last_name' => stripslashes($user->last_name), 'wp_user_password' => stripslashes($plaintext_pass), 'wp_user_nicename' => stripslashes($user->nice_name), 'wp_user_displayname' => stripslashes($user->display_name), 'wp_user_gravatar_url' => '//www.gravatar.com/avatar/00000000000000000000000000000000'), array('lead_id' => '101', 'lead_email_address' => '*****@*****.**', 'lead_first_name' => 'Example', 'lead_last_name' => 'Lead', 'lead_company_name' => 'Inbound Now', 'lead_address_line_1' => '700 Grapefruit Dr.', 'lead_address_line_2' => 'Suite 101', 'lead_city' => 'San Francisco', 'lead_region' => 'California', 'form_name' => 'Call to Action Singup Form', 'source' => 'http://www.mysite.com/some-page/'));
                $_POST = array('First Name' => 'Example', 'Last Name' => 'Lead', 'Email Address' => '*****@*****.**');
                $body = $Inbound_Templating_Engine->replace_tokens($body, $args);
                echo $body;
                exit;
            }
        }