- Updates post processing filter naming convention
- Allows returning of text or html rendered body from the renderer
This commit is contained in:
@@ -21,7 +21,7 @@ class OpenTracking {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static function addTrackingImage() {
|
static function addTrackingImage() {
|
||||||
add_filter(Renderer::POST_PROCESS_FILTER, function ($template) {
|
add_filter(Renderer::FILTER_POST_PROCESS, function ($template) {
|
||||||
return OpenTracking::process($template);
|
return OpenTracking::process($template);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@@ -11,7 +11,7 @@ class Renderer {
|
|||||||
public $newsletter;
|
public $newsletter;
|
||||||
public $preview;
|
public $preview;
|
||||||
const NEWSLETTER_TEMPLATE = 'Template.html';
|
const NEWSLETTER_TEMPLATE = 'Template.html';
|
||||||
const POST_PROCESS_FILTER = 'mailpoet_rendering_post_process';
|
const FILTER_POST_PROCESS = 'mailpoet_rendering_post_process';
|
||||||
|
|
||||||
function __construct($newsletter, $preview = false) {
|
function __construct($newsletter, $preview = false) {
|
||||||
// TODO: remove ternary condition, refactor to use model objects
|
// TODO: remove ternary condition, refactor to use model objects
|
||||||
@@ -24,7 +24,7 @@ class Renderer {
|
|||||||
$this->template = file_get_contents(dirname(__FILE__) . '/' . self::NEWSLETTER_TEMPLATE);
|
$this->template = file_get_contents(dirname(__FILE__) . '/' . self::NEWSLETTER_TEMPLATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
function render() {
|
function render($type = false) {
|
||||||
$newsletter = $this->newsletter;
|
$newsletter = $this->newsletter;
|
||||||
$body = (is_array($newsletter['body']))
|
$body = (is_array($newsletter['body']))
|
||||||
? $newsletter['body']
|
? $newsletter['body']
|
||||||
@@ -48,10 +48,14 @@ class Renderer {
|
|||||||
$template = $this->inlineCSSStyles($template);
|
$template = $this->inlineCSSStyles($template);
|
||||||
$template = $this->postProcessTemplate($template);
|
$template = $this->postProcessTemplate($template);
|
||||||
|
|
||||||
return array(
|
$rendered_newsletter = array(
|
||||||
'html' => $template,
|
'html' => $template,
|
||||||
'text' => $this->renderTextVersion($template)
|
'text' => $this->renderTextVersion($template)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return ($type && !empty($rendered_newsletter[$type])) ?
|
||||||
|
$rendered_newsletter[$type] :
|
||||||
|
$rendered_newsletter;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderBody($content) {
|
function renderBody($content) {
|
||||||
@@ -124,7 +128,7 @@ class Renderer {
|
|||||||
str_replace('&', '&', $template->html())
|
str_replace('&', '&', $template->html())
|
||||||
);
|
);
|
||||||
$template = apply_filters(
|
$template = apply_filters(
|
||||||
self::POST_PROCESS_FILTER,
|
self::FILTER_POST_PROCESS,
|
||||||
$DOM->__toString()
|
$DOM->__toString()
|
||||||
);
|
);
|
||||||
return $template;
|
return $template;
|
||||||
|
Reference in New Issue
Block a user