Create a gist now

Instantly share code, notes, and snippets.

@msenateatplos /email.php Secret
Last active Oct 13, 2015

What would you like to do?
Updated to WYSIJA Version 2.4, edits wysija-newsletters/controllers/front/email.php to allow only logged in users to see HTML version of newsletter.
defined('WYSIJA') or die('Restricted access');
include_once( ABSPATH . "wp-includes/pluggable.php");
global $current_user;
class WYSIJA_control_front_email extends WYSIJA_control_front{
var $model='email';
var $view='email';
function WYSIJA_control_front_email(){
function view(){
if( is_user_logged_in() ) {
header('Content-type:text/html; charset=utf-8');
// Get email model as object.
$emailM =& WYSIJA::get('email','model');
$emailM->getFormat = OBJECT;
// Get config model
$configM =& WYSIJA::get('config','model');
// Helpers
$emailH =& WYSIJA::get('email','helper');
$mailerH =& WYSIJA::get('mailer','helper');
// Get current email object.
$current_email = $emailM->getOne((int)$_REQUEST['email_id']);
// Get current user object if possible
$current_user = null;
// Get User Model
$userM = &WYSIJA::get('user','model');
$userM->getFormat = OBJECT;
$current_user = $userM->getOne((int)$_REQUEST['user_id']);
// Parse and replace user tags.
$mailerH->replaceusertags($current_email, $current_user);
// Parse and replace old shortcodes.
// $emailObject->subject = str_replace(
// array('[total]','[number]','[post_title]'),
// array($itemCount, $totalCount, $firstSubject),
// $emailChild['subject']);
// Set Body
$email_render = $current_email->body;
// Parse old shortcodes that we are parsing in the queue.
$find = array(
$replace = array(
$email_render = str_replace($find, $replace, $email_render);
// Strip unsubscribe links.
$email_render = $emailH->stripPersonalLinks($email_render);
do_action( 'wysija_preview', array(&$this));
echo $email_render;
else {
//echo "<p>This content available only to authorized users.</p>";
global $wp_query;
header("HTTP/1.0 404 Not Found - Archive Empty");
require get_stylesheet_directory().'/404.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment