static function external($template_id, $email_id, $subscriber_id, $e)
 {
     $link = SendPress_Manager::public_url('unsubscribe');
     $email_key = str_replace('=', '', base64_encode($email_id));
     //Uses a know url 4/20
     return add_query_arg(array('sid' => '{sp-subscriber-id-encoded}', 'rid' => $email_key), $link);
 }
 static function external($template_id, $email_id, $subscriber_id, $e)
 {
     /*
     $open_info = array(
     	"id"=>$email_id,
     	"view"=>"email"
     );
     $code = SendPress_Data::encrypt( $open_info );
     $xlink = SendPress_Manager::public_url($code);
     */
     $link = SendPress_Manager::public_url('email');
     $email_key = str_replace('=', '', base64_encode($email_id));
     return add_query_arg(array('sid' => '{sp-subscriber-id-encoded}', 'eid' => $email_key), $link);
     return $xlink;
 }
 static function external($template_id, $email_id, $subscriber_id, $e)
 {
     //maybe saved link?
     $link_data = array("id" => $subscriber_id, "view" => 'manage');
     $code = SendPress_Data::encrypt($link_data);
     $link = SendPress_Manager::public_url($code);
     if (SendPress_Option::get('manage-page') == 'custom') {
         $page = SendPress_Option::get('manage-page-id');
         if ($page != false) {
             $plink = get_permalink($page);
             if ($plink != "") {
                 $link = $plink . '?spms=' . $code;
             }
         }
     }
     return $link;
 }
 function prerender()
 {
     $r = $_GET['rid'];
     $s = $_GET['sid'];
     $r = (int) base64_decode($r);
     $s = (int) base64_decode($s);
     if (is_numeric($r)) {
         $lists = get_post_meta($r, '_send_lists', true);
         $lists = explode(",", $lists);
         foreach ($lists as $list) {
             SendPress_Data::unsubscribe_from_list($s, $r, $list);
         }
     }
     $link_data = array("id" => $s, "report" => $r, "urlID" => '0', "view" => "manage", "listID" => "0", "action" => "");
     $code = SendPress_Data::encrypt($link_data);
     $link = SendPress_Manager::public_url($code);
     $this->redirect($link);
     exit;
 }
Пример #5
0
 function html()
 {
     $post_template = $this->id();
     global $wpdb;
     //$email =  $this->email();
     // Get any existing copy of our transient data
     if (SendPress_Email_Cache::get($this->id()) != null) {
         $body_html = SendPress_Email_Cache::get($this->id());
         $post_template = get_post_meta($this->id(), '_sendpress_template', true);
         $body_html = spnl_do_email_tags($body_html, $post_template, $this->id(), $this->subscriber_id(), true);
     } else {
         if (false === ($body_html = get_transient('sendpress_report_body_html_' . $this->id())) || $this->purge() == true) {
             // It wasn't there, so regenerate the data and save the transient
             if (!$this->post_info) {
                 $this->post_info = get_post($this->id());
             }
             if ($this->cache() !== false) {
                 $body_html = $this->cache();
             } else {
                 $body_html = SendPress_Template::get_instance()->render($this->id(), false, false, $this->remove_links());
                 $this->cache($body_html);
             }
             set_transient('sendpress_report_body_html_' . $this->id(), $body_html, 60 * 60 * 2);
         }
     }
     $subscriber = SendPress_Data::get_subscriber($this->subscriber_id());
     if (!is_null($subscriber)) {
         $body_html = str_replace("*|FNAME|*", $subscriber->firstname, $body_html);
         $body_html = str_replace("*|LNAME|*", $subscriber->lastname, $body_html);
         $body_html = str_replace("*|EMAIL|*", $subscriber->email, $body_html);
         $body_html = str_replace("*|ID|*", $subscriber->subscriberID, $body_html);
     }
     $open_info = array("id" => $this->subscriber_id(), "report" => $this->id(), "view" => "open");
     $code = SendPress_Data::encrypt($open_info);
     $link = SendPress_Manager::public_url($code);
     $tracker = "<img src='" . $link . "' width='1' height='1'/></body>";
     $body_html = str_replace("</body>", $tracker, $body_html);
     $body_link = get_post_meta($this->id(), 'body_link', true);
     $body_html = spnl_do_subscriber_tags($body_html, $post_template, $this->id(), $this->subscriber_id(), true);
     //$pattern ="/(?<=href=(\"|'))[^\"']+(?=(\"|'))/";
     //$body_html = preg_replace( $pattern , site_url() ."?sendpress=link&fxti=".$subscriber_key."&spreport=". $this->id ."&spurl=$0", $body_html );
     if (class_exists("DomDocument")) {
         $dom = new DomDocument();
         $dom->strictErrorChecking = false;
         @$dom->loadHtml($body_html);
         $pTags = $dom->getElementsByTagName('p');
         foreach ($pTags as $pElement) {
             $px = $pElement->getAttribute('style');
             $pElement->setAttribute('style', $px . ' margin-top:0;margin-bottom:10px;');
         }
         if ($this->tracker()) {
             $aTags = $dom->getElementsByTagName('a');
             foreach ($aTags as $aElement) {
                 $href = $aElement->getAttribute('href');
                 /*
                 $style = $aElement->getAttribute('style');
                 
                 if($style == ""){
                 	$aElement->setAttribute('style');
                 }
                 */
                 //ADD TO DB?
                 if (strrpos($href, "*|") === false && strrpos($href, "#") !== 0) {
                     if (SendPress_Option::get('skip_mailto', false) == true && strrpos($href, "mailto") !== false) {
                         continue;
                     }
                     /*
                     $urlinDB = SendPress_Data::get_url_by_report_url( $this->id(), $href );
                     if(!isset($urlinDB[0])){
                     
                     	$urlData = array(
                     		'url' => trim($href),
                     		'reportID' => $this->id(),
                     	);
                     	$urlID = SendPress_Data::insert_report_url( $urlData );
                     
                     } else {
                     	$urlID  = $urlinDB[0]->urlID;
                     }
                     $link = array(
                     	"id"=>$this->subscriber_id(),
                     	"report"=> $this->id(),
                     	"urlID"=> $urlID,
                     	"view"=>"link"
                     );
                     */
                     $link = array("id" => $this->subscriber_id(), "report" => $this->id(), "view" => "tracker", "url" => $href);
                     $code = SendPress_Data::encrypt($link);
                     $link = SendPress_Manager::public_url($code);
                     $href = $link;
                     $aElement->setAttribute('href', $href);
                 }
             }
         }
         $body_html = $dom->saveHtml();
     }
     $link_data = array("id" => $this->subscriber_id(), "report" => $this->id(), "urlID" => '0', "view" => "manage", "listID" => $this->list_id(), "action" => "unsubscribe");
     $code = SendPress_Data::encrypt($link_data);
     $link = SendPress_Manager::public_url($code);
     if (SendPress_Option::get('old_unsubscribe_link', false) === true) {
         $start_text = __("Not interested anymore?", "sendpress");
         $unsubscribe = __("Unsubscribe", "sendpress");
         $instantly = __("Instantly", "sendpress");
         $remove_me_old = $start_text . ' <a href="' . $link . '"  style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> ' . $instantly . '.';
         $body_html = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me_old, $body_html);
         $body_html = str_replace("*|SP:MANAGE|*", '', $body_html);
     } else {
         $link_data = array("id" => $this->subscriber_id(), "report" => $this->id(), "urlID" => '0', "view" => "manage", "listID" => $this->list_id(), "action" => "");
         $code = SendPress_Data::encrypt($link_data);
         $manage_link = SendPress_Manager::public_url($code);
         $unsubscribe = __("Unsubscribe", "sendpress");
         $manage = __("Manage Subscription", "sendpress");
         $remove_me = ' <a href="' . $link . '"  style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> | ';
         $manage = ' <a href="' . $manage_link . '"  style="color: ' . $body_link . ';" >' . $manage . '</a> ';
         $body_html = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me, $body_html);
         $body_html = str_replace("*|SP:MANAGE|*", $manage, $body_html);
     }
     if (!is_null($subscriber)) {
         $body_html = str_replace("*|FNAME|*", $subscriber->firstname, $body_html);
         $body_html = str_replace("*|LNAME|*", $subscriber->lastname, $body_html);
         $body_html = str_replace("*|EMAIL|*", $subscriber->email, $body_html);
         $body_html = str_replace("*|ID|*", $subscriber->subscriberID, $body_html);
     }
     //$body_html = apply_filters('sendpress_post_render_email', $body_html);
     //echo  $body_html;
     //print_r($email);
     return $body_html;
 }
 function render_html($post_id = false, $render = true, $inline = false, $no_links = false, $custom_html = false)
 {
     global $post;
     remove_filter('the_content', 'sharing_display', 19);
     remove_filter('the_excerpt', 'sharing_display', 19);
     $saved = false;
     if ($post_id !== false) {
         $post = get_post($post_id);
         $saved = $post;
     }
     $saved = $post;
     if (!isset($post)) {
         //echo __('Sorry we could not find your email.','sendpress');
         return;
     }
     //$selected_template = $this->get_template( $post_id );
     //$template_list = $this->info();
     $post_template = get_post_meta($post->ID, '_sendpress_template', true);
     if ($post_template != '' && is_numeric($post_template) && $post_template > 0) {
         $HtmlCode = SendPress_Email_Render_Engine::render_template($post_template, $post_id, $custom_html);
     } else {
         $old = get_post_meta($post->ID, '_sendpress_system', true);
         if ($old == 'old') {
             $HtmlCode = file_get_contents(SENDPRESS_PATH . '/templates/original.html');
         } else {
             $HtmlCode = file_get_contents(SENDPRESS_PATH . '/templates/simple.html');
         }
     }
     if ($HtmlCode != false) {
         /*
         ob_start();
         require_once( $template_list[$selected_template]['file'] );
         $HtmlCode= ob_get_clean(); 
         */
         $HtmlCode = do_shortcode($HtmlCode);
         add_filter('the_content', 'do_shortcode', 11);
         if ($custom_html == false) {
             $content = $post->post_content;
         } else {
             $content = $custom_html;
         }
         $content = apply_filters('the_content', $content);
         //print_r($post->post_content);
         $content = str_replace(']]>', ']]&gt;', $content);
         //$content = do_shortcode( $content );
         $HtmlCode = str_replace("*|SP:CONTENT|*", $content, $HtmlCode);
         $post = $saved;
         $HtmlCode = str_replace("*|SP:SUBJECT|*", $post->post_title, $HtmlCode);
         $body_bg = get_post_meta($post->ID, 'body_bg', true);
         $body_text = get_post_meta($post->ID, 'body_text', true);
         $body_link = get_post_meta($post->ID, 'body_link', true);
         $header_bg = get_post_meta($post->ID, 'header_bg', true);
         $active_header = get_post_meta($post->ID, 'active_header', true);
         $upload_image = get_post_meta($post->ID, 'upload_image', true);
         $header_text_color = get_post_meta($post->ID, 'header_text_color', true);
         $header_text = get_post_meta($post->ID, 'header_text', true);
         //needs adding to the template
         $header_link = get_post_meta($post->ID, 'header_link', true);
         //needs adding to the template
         $sub_header_text = get_post_meta($post->ID, 'sub_header_text', true);
         //needs adding to the template
         $image_header_url = get_post_meta($post->ID, 'image_header_url', true);
         //needs adding to the template
         $content_bg = get_post_meta($post->ID, 'content_bg', true);
         $content_text = get_post_meta($post->ID, 'content_text', true);
         $content_link = get_post_meta($post->ID, 'sp_content_link_color', true);
         $content_border = get_post_meta($post->ID, 'content_border', true);
         $header_link_open = '';
         $header_link_close = '';
         if ($active_header == 'image') {
             if (!empty($image_header_url)) {
                 $header_link_open = "<a style='color:" . $header_text_color . "' href='" . $image_header_url . "'>";
                 $header_link_close = "</a>";
             }
             $headercontent = $header_link_open . "<img style='display:block;' src='" . $upload_image . "' border='0' />" . $header_link_close;
             $HtmlCode = str_replace("*|SP:HEADERCONTENT|*", $headercontent, $HtmlCode);
         } else {
             if (!empty($header_link)) {
                 $header_link_open = "<a style='color:" . $header_text_color . "' href='" . $header_link . "'>";
                 $header_link_close = "</a>";
             }
             $headercontent = "<div style='padding: 10px; text-align:center;'><h1 style='text-align:center; color: " . $header_text_color . " !important;'>" . $header_link_open . $header_text . $header_link_close . "</h1>" . $sub_header_text . "</div>";
             $HtmlCode = str_replace("*|SP:HEADERCONTENT|*", $headercontent, $HtmlCode);
         }
         $HtmlCode = str_replace("*|SP:HEADERBG|*", $header_bg, $HtmlCode);
         $HtmlCode = str_replace("*|SP:HEADERTEXT|*", $header_text_color, $HtmlCode);
         $HtmlCode = str_replace("*|SP:BODYBG|*", $body_bg, $HtmlCode);
         $HtmlCode = str_replace("*|SP:BODYTEXT|*", $body_text, $HtmlCode);
         $HtmlCode = str_replace("*|SP:BODYLINK|*", $body_link, $HtmlCode);
         $HtmlCode = str_replace("*|SP:CONTENTBG|*", $content_bg, $HtmlCode);
         $HtmlCode = str_replace("*|SP:CONTENTTEXT|*", $content_text, $HtmlCode);
         $HtmlCode = str_replace("*|SP:CONTENTLINK|*", $content_link, $HtmlCode);
         $HtmlCode = str_replace("*|SP:CONTENTBORDER|*", $content_border, $HtmlCode);
         $HtmlCode = $this->tag_replace($HtmlCode);
         // Date processing
         $canspam = wpautop(SendPress_Option::get('canspam'));
         $HtmlCode = str_replace("*|SP:CANSPAM|*", $canspam, $HtmlCode);
         $social = '';
         if ($twit = SendPress_Option::get('twitter')) {
             $social .= "<a href='{$twit}' style='color: {$body_link};'>Twitter</a>";
         }
         if ($fb = SendPress_Option::get('facebook')) {
             if ($social != '') {
                 $social .= " | ";
             }
             $social .= "<a href='{$fb}'  style='color: {$body_link};'>Facebook</a>";
         }
         if ($ld = SendPress_Option::get('linkedin')) {
             if ($social != '') {
                 $social .= " | ";
             }
             $social .= "<a href='{$ld}'  style='color: {$body_link};'>LinkedIn</a>";
         }
         $social = SendPress_Data::build_social($body_link);
         $HtmlCode = str_replace("*|SP:SOCIAL|*", $social, $HtmlCode);
         /*
         $dom = new DomDocument();
         	$dom->strictErrorChecking = false;
         	@$dom->loadHtml($HtmlCode);
         	$iTags = $dom->getElementsByTagName('img');
         	foreach ($iTags as $iElement) {
         		$class = $iElement->getAttribute('class');
         	}
         	$body_html = $dom->saveHtml();
         */
         /*
         			$simplecss = file_get_contents(SENDPRESS_PATH.'/templates/simple.css');
         				
         			// create instance
         			$cssToInlineStyles = new CSSToInlineStyles($HtmlCode, $simplecss);
         // grab the processed HTML
         			$HtmlCode = $cssToInlineStyles->convert();
         */
         $display_correct = __("Is this email not displaying correctly?", "sendpress");
         $view = __("View it in your browser", "sendpress");
         $start_text = __("Not interested anymore?", "sendpress");
         $unsubscribe = __("Unsubscribe", "sendpress");
         $instantly = __("Instantly", "sendpress");
         $manage = __("Manage Subscription", "sendpress");
         if ($render) {
             //RENDER IN BROWSER
             if ($inline) {
                 $link = get_permalink($post->ID);
                 $browser = $display_correct . ' <a style="color: ' . $body_link . ';" href="' . $link . '">' . $view . '</a>.';
                 $HtmlCode = str_replace("*|SP:BROWSER|*", $browser, $HtmlCode);
                 $remove_me = ' <a href="#"  style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> | ';
                 $manage = ' <a href="#"  style="color: ' . $body_link . ';" >' . $manage . '</a> ';
                 $HtmlCode = str_replace("*|SP:MANAGE|*", $manage, $HtmlCode);
                 $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me, $HtmlCode);
             } else {
                 $HtmlCode = str_replace("*|SP:BROWSER|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|SP:MANAGE|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|ID|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|FNAME|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|LNAME|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|EMAIL|*", '', $HtmlCode);
             }
             echo $HtmlCode;
         } else {
             //PREP FOR SENDING
             if ($no_links == false) {
                 $link = get_permalink($post->ID);
                 $open_info = array("id" => $post->ID, "view" => "email");
                 $code = SendPress_Data::encrypt($open_info);
                 $xlink = SendPress_Manager::public_url($code);
                 $browser = $display_correct . ' <a style="color: ' . $body_link . ';" href="' . $xlink . '">' . $view . '</a>.';
                 $HtmlCode = str_replace("*|SP:BROWSER|*", $browser, $HtmlCode);
             } else {
                 $HtmlCode = str_replace("*|SP:BROWSER|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|SP:MANAGE|*", '', $HtmlCode);
             }
             return $HtmlCode;
         }
     } else {
         //echo __('Sorry we could not find your email template.','sendpress');
         return;
     }
 }
    function html($sp)
    {
        global $current_user;
        global $post_ID, $post;
        $view = isset($_GET['view']) ? $_GET['view'] : '';
        $list = '';
        if (isset($_GET['emailID'])) {
            $emailID = $_GET['emailID'];
            $post = get_post($_GET['emailID']);
            $post_ID = $post->ID;
        }
        $post_type = $sp->_email_post_type;
        $post_type_object = get_post_type_object($sp->_email_post_type);
        ?>
<div class="alert alert-danger fade hide">
  <?php 
        _e('<strong>Notice!</strong> You must select a list below before an email can be sent.', 'sendpress');
        ?>
</div>
<form method="POST" name="sendpress_post" id="sendpress_post">
<div style="float:right;"  class="btn-toolbar">
<div id="sp-cancel-btn" class="btn-group">
<a href="?page=<?php 
        echo $_GET['page'];
        ?>
"  class="btn btn-default "><?php 
        echo __('Cancel', 'sendpress');
        ?>
</a>
</div> 

<div class="btn-group">
    

    <!--<button class="btn btn-default " type="submit" value="save" name="submit"><i class="icon-white icon-ok"></i> <?php 
        echo __('Edit', 'sendpress');
        ?>
</button>-->
    <button class="btn btn-primary " type="submit" value="save-next" id="sp-send-next" name="submit"><i class="icon-envelope icon-white"></i> <?php 
        echo __('Send', 'sendpress');
        ?>
</button>
</div>
</div>

<input type="hidden" id="user-id" name="user_ID" value="<?php 
        echo $current_user->ID;
        ?>
" />
<input type="hidden" id="post_ID" name="post_ID" value="<?php 
        echo $post->ID;
        ?>
" />
<input type="hidden" id="post_type" name="post_type" value="sp_newsletters" />

<h2><?php 
        _e('Send Email', 'sendpress');
        ?>
</h2>
<br>
<div class="boxer">
<div class="boxer-inner">

<?php 
        $this->panel_start('<span class="glyphicon glyphicon-inbox"></span> ' . __('Subject', 'sendpress'));
        ?>
<input type="text" class="form-control" name="post_subject" size="30" tabindex="1" value="<?php 
        echo esc_attr(htmlspecialchars(get_post_meta($post->ID, '_sendpress_subject', true)));
        ?>
" id="email-subject" autocomplete="off" />
<?php 
        $this->panel_end();
        ?>
<div class="leftcol">
<?php 
        $this->panel_start('<span class="glyphicon glyphicon-calendar"></span> ' . __('Date & Time', 'sendpress'));
        ?>
<input type="radio" name="send-date" value="now" checked/> <?php 
        _e('Start Sending Now', 'sendpress');
        ?>
<br>
<input type="radio" name="send-date" value="later"/> <?php 
        _e('Send Later', 'sendpress');
        ?>
<br>
<div class="date-holder" style="display:none">
	<br>
<input type="text" name="date-pickit" id="date-pickit" class=" fifty float-left" value="<?php 
        echo date_i18n('Y/m/d');
        ?>
"/>&nbsp;at
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".date-holder").hide();

$('input[type=radio][name=send-date]').change(function() {
        if (this.value == 'now') {
            $(".date-holder").hide();
        }
        else if (this.value == 'later') {
           $(".date-holder").show();
        }
    });
$('#date-pickit').datepicker({
dateFormat : 'yy/mm/dd'
});
});
</script>
<select name="send-later-time" id="datepicker-time" class="fifty">
<option value="00:00:00">12:00 am</option>
<option value="01:00:00">1:00 am</option>
<option value="02:00:00">2:00 am</option>
<option value="03:00:00">3:00 am</option>
<option value="04:00:00">4:00 am</option>
<option value="05:00:00">5:00 am</option>
<option value="06:00:00">6:00 am</option>
<option value="07:00:00">7:00 am</option>
<option value="08:00:00">8:00 am</option>
<option value="09:00:00">9:00 am</option>
<option value="10:00:00">10:00 am</option>
<option value="11:00:00">11:00 am</option>
<option value="12:00:00">12:00 pm</option>
<option value="13:00:00">1:00 pm</option>
<option value="14:00:00">2:00 pm</option>
<option value="15:00:00">3:00 pm</option>
<option value="16:00:00">4:00 pm</option>
<option value="17:00:00">5:00 pm</option>
<option value="18:00:00">6:00 pm</option>
<option value="19:00:00">7:00 pm</option>
<option value="20:00:00">8:00 pm</option>
<option value="21:00:00">9:00 pm</option>
<option value="22:00:00">10:00 pm</option>
<option value="23:00:00">11:00 pm</option>
</select>
</div>
<?php 
        $this->panel_end();
        do_action('spnl_add_to_sending', $this);
        $this->panel_start('<span class="glyphicon glyphicon-list"></span> ' . __('Lists', 'sendpress'));
        $post_args = array('post_type' => 'sendpress_list', 'numberposts' => -1, 'offset' => 0, 'orderby' => 'post_title', 'order' => 'DESC');
        $current_lists = get_posts($post_args);
        foreach ($current_lists as $list) {
            $t = '';
            $tlist = '';
            if (get_post_meta($list->ID, '_test_list', true) == 1) {
                $t = '  <span class="label label-info">Test List</span>';
                $tlist = ' test-list-add';
            }
            echo "<input name='listIDS[]' type='checkbox' id='listIDS' class='sp-send-lists " . $tlist . "' value=" . $list->ID . "> " . $list->post_title . " <small>(" . SendPress_Data::get_count_subscribers($list->ID) . ")</small>{$t}<br>";
        }
        $this->panel_end();
        $this->panel_start('<span class="glyphicon glyphicon-tag"></span> ' . __('Mark as Test', 'sendpress'));
        echo "<input name='test_report' type='checkbox' id='test_report' value='1'> " . __('Test', 'sendpress') . "<br>";
        echo "<small class='text-muted'> " . __('This puts the report into the Test tab on the Reports screen', 'sendpress') . ".</small>";
        $this->panel_end();
        ?>

<!--
<div class="style-unit">
<h4><?php 
        _e('Settings', 'sendpress');
        ?>
</h4>
<input type="checkbox" name="test-send" value="1" /> Mark as Test

<textarea name="test-add" cols='26' rows='6'></textarea>


</div>
-->
<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
</div>
<div style="margin-left: 250px;">
<div class="widerightcol">
<?php 
        $url = get_site_url();
        //$link =  get_permalink( $post->ID );
        $open_info = array("id" => $post->ID, "view" => "email");
        $code = SendPress_Data::encrypt($open_info);
        $url = SendPress_Manager::public_url($code);
        $sep = strstr($url, '?') ? '&' : '?';
        $link = $url . $sep . 'inline=true';
        ?>
<iframe src="<?php 
        echo $link;
        ?>
" width="100%" height="600px"></iframe>
<small><?php 
        _e('Displaying a 404? Please try saving your permalinks', 'sendpress');
        ?>
 <a href="<?php 
        echo admin_url('options-permalink.php');
        ?>
"><?php 
        _e('here', 'sendpress');
        ?>
</a>.</small>

</div>
</div>
<br class="clear" />
</div>
</form>
<?php 
    }
 private static function manage_sub_prerender()
 {
     $info = self::data();
     if (isset($info->action) && $info->action == 'unsubscribe') {
         SendPress_Data::unsubscribe_from_list($info->id, $info->report, $info->listID);
         $link_data = array("id" => $info->id, "report" => $info->report, "urlID" => '0', "view" => "manage", "listID" => $info->listID, "action" => "");
         $code = SendPress_Data::encrypt($link_data);
         $link = SendPress_Manager::public_url($code);
         //$this->redirect(  $link );
         //exit;
     }
 }
    function html($sp)
    {
        global $post_ID, $post;
        $view = isset($_GET['view']) ? $_GET['view'] : '';
        $list = '';
        if (isset($_GET['emailID'])) {
            $emailID = $_GET['emailID'];
            $post = get_post($_GET['emailID']);
            $post_ID = $post->ID;
        }
        ?>
		<form  method="POST" name="post" id="post">
<?php 
        $info = SendPress_Option::get('current_send_' . $post->ID);
        $subject = SendPress_Option::get('current_send_subject_' . $post->ID, true);
        ?>
<div id="styler-menu">
    <div style="float:right;" class="btn-group">
<a class="btn btn-primary btn-large " id="confirm-send" href="#"><i class="icon-white  icon-thumbs-up"></i> <?php 
        _e('Confirm Send', 'sendpress');
        ?>
</a>
  </div>
</div>
<div id="sp-cancel-btn" style="float:right; ">
<a class="btn btn-default" href="<?php 
        echo '?page=' . $_GET['page'] . '&view=send&emailID=' . $_GET['emailID'];
        ?>
"><?php 
        _e('Cancel Send', 'sendpress');
        ?>
</a>&nbsp;
</div>
<h2><?php 
        _e('Confirm Send', 'sendpress');
        ?>
</h2>
<br>

<input type="hidden" id="user-id" name="user_ID" value="<?php 
        //echo $current_user->ID;
        ?>
" />
<input type="hidden" id="post_ID" name="post_ID" value="<?php 
        echo $post->ID;
        ?>
" />
<div class="boxer">
<div class="boxer-inner">
<?php 
        $this->panel_start('<span class="glyphicon glyphicon-inbox"></span> ' . __('Subject', 'sendpress'));
        ?>
<input type="text" class="form-control" value="<?php 
        echo stripslashes(esc_attr(htmlspecialchars($subject)));
        ?>
" disabled />
<?php 
        $this->panel_end();
        ?>
<div class="leftcol">
<?php 
        $this->panel_start('<span class="glyphicon glyphicon-calendar"></span> ' . __('Date & Time', 'sendpress'));
        if ($info['send_at'] == '0000-00-00 00:00:00') {
            echo "Your email will start sending right away!";
        } else {
            echo "Your email will start sending on " . date('Y/m/d', strtotime($info['send_at'])) . " at " . date('h:i A', strtotime($info['send_at']));
        }
        $this->panel_end();
        $this->panel_start('<span class="glyphicon glyphicon-list"></span> ' . __('Lists', 'sendpress'));
        ?>



<?php 
        if (!empty($info['listIDS'])) {
            foreach ($info['listIDS'] as $list_id) {
                $list = $sp->get_list_details($list_id);
                echo $list->post_title . " <small>(" . SendPress_Data::get_count_subscribers($list_id) . ")</small><br>";
            }
        } else {
            _e('No Lists Selected', 'sendpress');
            echo "<br>";
        }
        $this->panel_end();
        $this->panel_start('<span class="glyphicon glyphicon-tag"></span> ' . __('Mark as Test', 'sendpress'));
        $sel = '';
        if (get_post_meta($post_ID, 'istest', true) == true) {
            $sel = 'checked';
        }
        echo "<input {$sel} name='test_report' type='checkbox' id='test_report' value='1' disabled> Test<br>";
        echo "<small class='text-muted'>" . __('This puts the report into the Test tab on the Reports screen', 'sendpress') . ".</small>";
        $this->panel_end();
        ?>

</div>
<div style="margin-left: 250px;">
<div class="widerightcol">
<?php 
        $link = get_permalink($post->ID);
        $sep = strstr($link, '?') ? '&' : '?';
        $link = $link . $sep . 'inline=true';
        $open_info = array("id" => $post->ID, "view" => "email");
        $code = SendPress_Data::encrypt($open_info);
        $url = SendPress_Manager::public_url($code);
        $sep = strstr($url, '?') ? '&' : '?';
        $link = $url . $sep . 'inline=true';
        ?>
<iframe src="<?php 
        echo $link;
        ?>
" width="100%" height="600px"></iframe>

<small><?php 
        _e('Displaying a 404? Please try saving your permalinks', 'sendpress');
        ?>
 <a href="<?php 
        echo admin_url('options-permalink.php');
        ?>
"><?php 
        _e('here', 'sendpress');
        ?>
</a>.</small>
</div>
<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
<br><br>
</div>
</div>
<br class="clear" />
	</div>
	</form>
	<?php 
    }
 function send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id)
 {
     $this->emailText = $text;
     $this->sid = $sid;
     $this->list_id = $list_id;
     $this->report_id = $report_id;
     //add_filter( 'phpmailer_init' , array( $this , 'wpmail_init' ) , 90 );
     $link2 = array("id" => $sid, "report" => $list_id, "view" => "tracker", "url" => "{sp-unsubscribe-url}");
     $code2 = SendPress_Data::encrypt($link2);
     $link2 = SendPress_Manager::public_url($code2);
     $rpath = SendPress_Option::get('bounce_email');
     if ($rpath != false) {
         $rpath = SendPress_Option::get('fromname');
     }
     $headers = array('Content-Type: text/html; charset=' . SendPress_Option::get('email-charset', 'UTF-8'), 'X-SP-LIST: ' . $this->list_id . ';', 'X-SP-REPORT: ' . $this->report_id . ';', 'X-SP-SUBSCRIBER: ' . $this->sid . ';', 'X-SP-METHOD: website wp_mail', 'From: ' . SendPress_Option::get('fromname') . ' <' . SendPress_Option::get('fromemail') . '>', 'List-Unsubscribe: <' . $link2 . '>', 'Return-Path: ' . $rpath);
     $r = wp_mail($to, $subject, $html, $headers);
     //remove_filter( 'phpmailer_init' , array( $this , 'wpmail_init' ) , 90 );
     return $r;
 }