function send_newsletter($post_ID) { $sendit = new Actions(); $article = get_post($post_ID); $send_now = get_post_meta($post_ID, 'send_now', true); $sendit_list = get_post_meta($post_ID, 'sendit_list', true); $table_liste = SENDIT_LIST_TABLE; $list_detail = $sendit->GetListDetail($sendit_list); $subscribers = $sendit->GetSubscribers($sendit_list); //only confirmed $css = ''; /*+++++++++++++++++++ TEMPLATE pro EMAIL +++++++++++++++++++++++++++++++++++++++++*/ //to do: templatizer, if exixts get the template from template_id $header = $list_detail->header; $footer = $list_detail->footer; $css = ''; include_once ABSPATH . 'wp-admin/includes/plugin.php'; if (is_plugin_active('sendit-pro-template-manager/sendit-pro-template-manager.php')) { //custom post type template $template_id = get_post_meta($post_ID, 'template_id', true); $template = get_post($template_id); $title = $newsletter->post_title; //echo 'template id '.$template_id; $header = get_post_meta($template_id, 'headerhtml', true); $header = str_replace('[style]', '<style>' . $css . '</style>', $header); if (has_post_thumbnail($template_id)) { $header_image = get_the_post_thumbnail($template_id); } else { $header_image = '<img alt="" src="http://placehold.it/300x50/" />'; } $header = str_replace('[logo]', $header_image, $header); $header = str_replace('[homeurl]', get_bloginfo('siteurl'), $header); $footer = get_post_meta($template_id, 'footerhtml', true); $content = apply_filters('the_content', $newsletter->post_content); } $email_from = $list_detail->email_lista; /*+++++++++++++++++++ HEADERS EMAIL +++++++++++++++++++++++++++++++++++++++++*/ $email = $email_from; $headers = "MIME-Version: 1.0\n" . "From: " . $email . " <" . $email . ">\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n"; /*+++++++++++++++++++ CONTENT EMAIL +++++++++++++++++++++++++++++++++++++++++*/ $title = $article->post_title; //$content = apply_filters('the_content',$article->post_content); $content = apply_filters('the_content', $article->post_content); //$newsletter_content=$header.$content.$footer; //new 2.1.2 content is already with footer and header $newsletter_content = $content; //CSS get template id comment tag parse and extract css.... v 2.2.2 $get_template_id = getStylesheet($newsletter_content); $css_id = $get_template_id[1][0]; $css = get_post_meta($css_id, 'newsletter_css', true); $readonline = get_permalink($post_ID); if ($send_now == 1) { foreach ($subscribers as $subscriber) { if (get_option('sendit_unsubscribe_link') == 'yes') { //aggiungo messaggio con il link di cancelazione che cicla il magic_string.. $delete_link = "\n\t\t\t\t<center>\n\t \t\t\t-------------------------------------------------------------------------------\n\t\t\t\t<p>" . __('To unsubscribe, please click on the link below', 'sendit') . "<br />\n\t\t\t\t<a href=\"" . get_bloginfo('siteurl') . '/' . "?action=unsubscribe&c=" . $subscriber->magic_string . "\">" . __('Unsubscribe now', 'sendit') . "</a></p>\n\t\t\t\t</center>"; } else { $delete_link = ''; } //send the newsletter! //verify if inliner is installed if (is_plugin_active('sendit-css-inliner/sendit-pro-css-inliner.php')) { $newsletter_content = inline_newsletter($css, $newsletter_content); $response = preg_replace('/(Â| )+/i', ' ', $response); } if (is_plugin_active('sendit-pro-analytics-campaign/sendit-pro-analytics-campaign.php')) { $newsletter_content = AppendCampaignToString($newsletter_content); } wp_mail($subscriber->email, $title, $newsletter_content . $delete_link, $headers, $attachments); } //set to 5 status : sent with classic plugin update_post_meta($post_ID, 'send_now', '5'); } }
<head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1"> <title><?php echo $site->title()->html(); ?> | <?php echo $page->title()->html(); ?> </title> <!-- Styles --> <?php echo css(getStylesheet($site->colorbase(), $site->coloraccent(), $site->colorlink())); ?> <?php echo css('assets/css/font.naksh.css'); ?> <?php echo css('assets/css/font.asap.css'); ?> <?php snippet('header.background.style'); ?> </head> <body> <div class="uk-container uk-container-center">
}'; $header = str_replace('[style]', '<style>' . $css . $box_styles . '</style>', $header); if (has_post_thumbnail($template_id)) { $header_image = get_the_post_thumbnail($template_id); } else { $header_image = '<img alt="" src="http://placehold.it/300x50/" />'; } $header = str_replace('[logo]', $header_image, $header); $header = str_replace('[homeurl]', get_bloginfo('siteurl'), $header); $footer = get_post_meta($template_id, 'footerhtml', TRUE); } //plugin is active //$newsletter_content=$header.get_the_content().$footer; $newsletter_content = get_the_content(); //CSS get template id comment tag parse and extract css.... $get_template_id = getStylesheet($newsletter_content); $css_id = $get_template_id[1][0]; $css = get_post_meta($css_id, 'newsletter_css', true); //verify if inliner is installed if (function_exists('inline_newsletter')) { $newsletter_content = inline_newsletter($css, $newsletter_content); } //verify if analytics is installed if (function_exists('AppendCampaignToString')) { echo AppendCampaignToString($newsletter_content); } } } else { ?> <!-- Stuff to do if there are no posts--> <h2>No Newsletter</h2>