function html()
 {
     $email_id = get_query_var('spemail');
     global $post;
     if (is_object($this->data()) && $this->data()->id) {
         $email_id = $this->data()->id;
     }
     if (isset($_GET['eid'])) {
         $email_id = SPNL()->validate->int(base64_decode($_GET['eid']));
     }
     // If there's a subscriber ID in the URL, we need to get the subscriber object from it to use for the str_replace below.
     if (isset($_GET['sid'])) {
         $subscriber_id = SPNL()->validate->int(base64_decode($_GET['sid']));
     } else {
         $subscriber_id = 0;
     }
     //$post = get_post($email_id);
     $inline = false;
     if (isset($_GET['inline'])) {
         $inline = true;
     }
     SendPress_Email_Cache::build_cache_for_email($email_id);
     $message = new SendPress_Email();
     $message->id($email_id);
     $message->subscriber_id($subscriber_id);
     $message->list_id(0);
     $body = $message->html();
     //print_r( $body );
     unset($message);
     echo $body;
     //echo SendPress_Template::get_instance()->render_html(false, true, $inline );
 }
 /**
  * Used to add Overwrite send info for testing. 
  *
  * @return boolean true if mail sent successfully, false if an error
  */
 static function send_test_email($email)
 {
     SendPress_Email_Cache::build_cache_for_email($email->emailID);
     $message = new SendPress_Email();
     $message->id($email->emailID);
     $message->purge(true);
     $message->subscriber_id($email->subscriberID);
     $message->list_id($email->listID);
     $body = $message->html();
     $subject = $message->subject();
     $to = $email->to_email;
     $text = $message->text();
     if (empty($text) || $text == '' || empty($body) || $body == '' || $body == " ") {
         SPNL()->log->add('Email Skiped', 'Email id #' . $email->emailID . ' to ' . $to . ' did not have any content. Was the email or template deleted?', 0, 'sending');
         return false;
     }
     return SendPress_Manager::send($to, $subject, $body, $text, true, $email->subscriberID, $email->listID, $email->emailID);
 }
 function template_include($template)
 {
     global $post;
     if (get_query_var('sendpress') || isset($_POST['sendpress'])) {
         $action = isset($_POST['sendpress']) ? $_POST['sendpress'] : get_query_var('sendpress');
         //Look for encrypted data
         $data = SendPress_Data::decrypt($action);
         $view = false;
         if (is_object($data)) {
             $view = isset($data->view) ? $data->view : false;
         } else {
             $view = $action;
         }
         $view_class = SendPress_Data::get_public_view_class($view);
         if (class_exists($view_class)) {
             $view_class = new $view_class();
             $view_class->data($data);
             if (isset($_POST['sp']) && wp_verify_nonce($_POST['sp'], 'sendpress-form-post') && method_exists($view_class, 'save')) {
                 $view_class->save();
             }
             $view_class->prerender();
             $view_class->render();
         }
         //$this->load_default_screen($action);
         die;
     }
     if (isset($post)) {
         if ($post->post_type == $this->_email_post_type || $post->post_type == $this->_report_post_type) {
             $inline = false;
             if (isset($_GET['inline'])) {
                 $inline = true;
             }
             SendPress_Email_Cache::build_cache_for_email($post->ID);
             $message = new SendPress_Email();
             $message->id($post->ID);
             $message->subscriber_id(0);
             $message->list_id(0);
             $body = $message->html();
             //print_r( $body );
             unset($message);
             echo $body;
             die;
             //SendPress_Template::get_instance()->render_html(false, true, $inline );
             //return SENDPRESS_PATH. '/template-loader.php';
             //return dirname(__FILE__) . '/my_special_template.php';
         }
         /**
          *
          * if($post->post_type == 'sp-standard' ){
          *    return 'You Bet';
          * }
          **/
     }
     return $template;
 }