static function external($template_id, $email_id, $subscriber_id, $e) { $links = SendPress_Data::build_social(); if ($links != '' && $links != false) { return $links; } return ''; }
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(']]>', ']]>', $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; } }
if ($fb = SendPress_Option::get('facebook')) { if ($social != '') { $social .= " | "; } $social .= "<a href='{$fb}' style='color: {$bg};'>Facebook</a>"; } if ($ld = SendPress_Option::get('linkedin')) { if ($social != '') { $social .= " | "; } $social .= "<a href='{$ld}' style='color: {$bg};'>LinkedIn</a>"; } //echo $social; echo SendPress_Data::build_social(); } else { echo SendPress_Data::build_social(); ?> <?php } ?> <div id="can-spam-template"> <?php if (false !== SendPress_Option::get('canspam')) { echo wpautop(SendPress_Option::get('canspam')); } else { ?> Blog/Company Name<br> Street Address<br> Anywhere, USA 01234<br>