static function render_template_example($post) { $html = self::render_html_base_by_post($post); $return = spnl_do_content_tags($html, $post->ID, $post->ID, 0, true); $return = spnl_do_email_tags($return, $post->ID, $post->ID, 0, true); $return = spnl_do_subscriber_tags($return, $post->ID, $post->ID, 0, true); //$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($return); $pTags = $dom->getElementsByTagName('p'); foreach ($pTags as $pElement) { $px = $pElement->getAttribute('style'); $pElement->setAttribute('style', $px . ' margin-top:0;margin-bottom:10px;'); } $return = $dom->saveHtml(); } return $return; }
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; }