Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
a25ea3ddf6 | |||
021349caee | |||
89f2958d23 | |||
8c8435766e | |||
40dd1bbb3b | |||
ba40437eb9 | |||
813db1ae33 | |||
9588397e4e | |||
ecf83ca419 | |||
9cc494f0fa | |||
dd4b7e4d1c | |||
738b2f6c17 | |||
33289342d3 | |||
a00f1efcfe | |||
b89897e6d4 | |||
c539837896 | |||
27edf5f71d | |||
32cc5644f9 | |||
8a664aa7f1 | |||
7e5e8a4282 | |||
70d5d609e2 | |||
19160c99e1 | |||
99b2a7457e | |||
945d7edc70 | |||
6a97badfed | |||
5ec8e4ed52 | |||
1569b5f80a | |||
e62ecc5036 | |||
b0150e184b |
Binary file not shown.
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 3.8 KiB |
@ -34,13 +34,16 @@ define(
|
||||
// show sending methods
|
||||
jQuery('.mailpoet_sending_methods').fadeIn();
|
||||
} else {
|
||||
// hide DKIM option when using MailPoet's API
|
||||
jQuery('#mailpoet_mta_dkim')[
|
||||
// toggle SPF/DKIM (hidden if the sending method is MailPoet)
|
||||
jQuery('#mailpoet_mta_spf')[
|
||||
(group === 'mailpoet')
|
||||
? 'hide'
|
||||
: 'show'
|
||||
]();
|
||||
|
||||
// (HIDDEN FOR BETA)
|
||||
jQuery('#mailpoet_mta_dkim').hide();
|
||||
|
||||
// hide sending methods
|
||||
jQuery('.mailpoet_sending_methods').hide();
|
||||
|
||||
|
@ -8,38 +8,38 @@ if(!defined('ABSPATH')) exit;
|
||||
|
||||
class PublicAPI {
|
||||
public $api;
|
||||
public $section;
|
||||
public $endpoint;
|
||||
public $action;
|
||||
public $request_payload;
|
||||
public $data;
|
||||
|
||||
function __construct() {
|
||||
# http://example.com/?mailpoet-api§ion=&action=&request_payload=
|
||||
$this->api = isset($_GET['mailpoet-api']) ? true : false;
|
||||
$this->section = isset($_GET['section']) ? $_GET['section'] : false;
|
||||
# http://example.com/?mailpoet&endpoint=&action=&data=
|
||||
$this->api = isset($_GET['mailpoet']) ? true : false;
|
||||
$this->endpoint = isset($_GET['endpoint']) ?
|
||||
Helpers::underscoreToCamelCase($_GET['endpoint']) :
|
||||
false;
|
||||
$this->action = isset($_GET['action']) ?
|
||||
Helpers::underscoreToCamelCase($_GET['action']) :
|
||||
false;
|
||||
$this->request_payload = isset($_GET['request_payload']) ?
|
||||
unserialize(base64_decode($_GET['request_payload'])) :
|
||||
false;
|
||||
$this->data = isset($_GET['data']) ? $_GET['data'] : false;
|
||||
}
|
||||
|
||||
function init() {
|
||||
if(!$this->api && !$this->section) return;
|
||||
$this->_checkAndCallMethod($this, $this->section, $terminate = true);
|
||||
if(!$this->api && !$this->endpoint) return;
|
||||
$this->_checkAndCallMethod($this, $this->endpoint, $terminate_request = true);
|
||||
}
|
||||
|
||||
function queue() {
|
||||
try {
|
||||
$queue = new Daemon($this->request_payload);
|
||||
$queue = new Daemon($this->data);
|
||||
$this->_checkAndCallMethod($queue, $this->action);
|
||||
} catch(\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
private function _checkAndCallMethod($class, $method, $terminate = false) {
|
||||
private function _checkAndCallMethod($class, $method, $terminate_request = false) {
|
||||
if(!method_exists($class, $method)) {
|
||||
if(!$terminate) return;
|
||||
if(!$terminate_request) return;
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
exit;
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ class CronHelper {
|
||||
}
|
||||
|
||||
static function accessDaemon($token, $timeout = self::daemon_request_timeout) {
|
||||
$payload = serialize(array('token' => $token));
|
||||
$url = '/?mailpoet-api§ion=queue&action=run&request_payload=' .
|
||||
base64_encode($payload);
|
||||
$data = serialize(array('token' => $token));
|
||||
$url = '/?mailpoet&endpoint=queue&action=run&data=' .
|
||||
base64_encode($data);
|
||||
$args = array(
|
||||
'timeout' => $timeout,
|
||||
'user-agent' => 'MailPoet (www.mailpoet.com) Cron'
|
||||
|
@ -10,17 +10,18 @@ if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Daemon {
|
||||
public $daemon;
|
||||
public $request_payload;
|
||||
public $data;
|
||||
public $refreshed_token;
|
||||
const daemon_request_timeout = 5;
|
||||
private $timer;
|
||||
|
||||
function __construct($request_payload = array()) {
|
||||
function __construct($data) {
|
||||
if (!$data) $this->abortWithError(__('Invalid or missing cron data.'));
|
||||
set_time_limit(0);
|
||||
ignore_user_abort();
|
||||
$this->daemon = CronHelper::getDaemon();
|
||||
$this->token = CronHelper::createToken();
|
||||
$this->request_payload = $request_payload;
|
||||
$this->data = unserialize(base64_decode($data));
|
||||
$this->timer = microtime(true);
|
||||
}
|
||||
|
||||
@ -29,8 +30,8 @@ class Daemon {
|
||||
if(!$daemon) {
|
||||
$this->abortWithError(__('Daemon does not exist.'));
|
||||
}
|
||||
if(!isset($this->request_payload['token']) ||
|
||||
$this->request_payload['token'] !== $daemon['token']
|
||||
if(!isset($this->data['token']) ||
|
||||
$this->data['token'] !== $daemon['token']
|
||||
) {
|
||||
$this->abortWithError(__('Invalid or missing token.'));
|
||||
}
|
||||
@ -49,7 +50,7 @@ class Daemon {
|
||||
// after each execution, re-read daemon data in case it was deleted or
|
||||
// its status has changed
|
||||
$daemon = CronHelper::getDaemon();
|
||||
if(!$daemon || $daemon['token'] !== $this->request_payload['token']) {
|
||||
if(!$daemon || $daemon['token'] !== $this->data['token']) {
|
||||
exit;
|
||||
}
|
||||
$daemon['counter']++;
|
||||
|
@ -69,11 +69,7 @@ class Scheduler {
|
||||
->findArray();
|
||||
$subscribers = Helpers::arrayColumn($subscribers, 'subscriber_id');
|
||||
$subscribers = array_unique($subscribers);
|
||||
if(!count($subscribers)) {
|
||||
$queue->delete();
|
||||
return;
|
||||
}
|
||||
if(!$this->checkIfNewsletterChanged($newsletter)) {
|
||||
if(!count($subscribers) || !$this->checkIfNewsletterChanged($newsletter)) {
|
||||
$queue->scheduled_at = $next_run_date;
|
||||
$queue->save();
|
||||
return;
|
||||
@ -141,7 +137,7 @@ class Scheduler {
|
||||
$rendered_newsletter = $renderer->render();
|
||||
$new_hash = md5($rendered_newsletter['html']);
|
||||
$old_hash = $last_run_queue->newsletter_rendered_body_hash;
|
||||
return $new_hash !== $old_hash;
|
||||
return $new_hash === $old_hash;
|
||||
}
|
||||
|
||||
private function getQueueNextRunDate($schedule) {
|
||||
|
@ -11,7 +11,7 @@ class Setting extends Model {
|
||||
const DEFAULT_SENDING_METHOD_GROUP = 'website';
|
||||
const DEFAULT_SENDING_METHOD = 'PHPMail';
|
||||
const DEFAULT_SENDING_FREQUENCY_EMAILS = 25;
|
||||
const DEFAULT_SENDING_FREQUENCY_INTERVAL = 15; // in minutes
|
||||
const DEFAULT_SENDING_FREQUENCY_INTERVAL = 5; // in minutes
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
|
@ -13,7 +13,7 @@ class SubscriberSegment extends Model {
|
||||
}
|
||||
|
||||
function subscriber() {
|
||||
return $this->has_one(__NAMESPACE__.'\Subscriber', 'id');
|
||||
return $this->has_one(__NAMESPACE__.'\Subscriber', 'id', 'subscriber_id');
|
||||
}
|
||||
|
||||
static function setSubscriptions($subscriber, $segment_ids = array()) {
|
||||
|
@ -13,14 +13,14 @@ class Button {
|
||||
<div>
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0;">
|
||||
<tr>
|
||||
<td class="mailpoet_button-container" style="padding:8px 20px;text-align:' . $element['styles']['block']['textAlign'] . ';"><!--[if mso]>
|
||||
<td class="mailpoet_button-container" style="text-align:' . $element['styles']['block']['textAlign'] . ';"><!--[if mso]>
|
||||
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||
href="' . $element['url'] . '"
|
||||
style="height:' . $element['styles']['block']['lineHeight'] . ';
|
||||
width:' . $element['styles']['block']['width'] . ';
|
||||
v-text-anchor:middle;"
|
||||
arcsize="' . round($element['styles']['block']['borderRadius'] / $element['styles']['block']['lineHeight'] * 100) . '%"
|
||||
strokeweight="1px"
|
||||
strokeweight="' . $element['styles']['block']['borderWidth'] . '"
|
||||
strokecolor="' . $element['styles']['block']['borderColor'] . '"
|
||||
fillcolor="' . $element['styles']['block']['backgroundColor'] . '">
|
||||
<w:anchorlock/>
|
||||
|
@ -7,6 +7,9 @@ class Footer {
|
||||
static function render($element) {
|
||||
$element['text'] = preg_replace('/\n/', '<br /><br />', $element['text']);
|
||||
$element['text'] = preg_replace('/(<\/?p.*?>)/i', '', $element['text']);
|
||||
$line_height = sprintf(
|
||||
'%spx', StylesHelper::$line_height_multiplier * (int) $element['styles']['text']['fontSize']
|
||||
);
|
||||
$DOM_parser = new \pQuery();
|
||||
$DOM = $DOM_parser->parseStr($element['text']);
|
||||
if(isset($element['styles']['link'])) {
|
||||
@ -25,7 +28,7 @@ class Footer {
|
||||
$template = '
|
||||
<tr>
|
||||
<td class="mailpoet_header_footer_padded mailpoet_footer" ' . $background_color . '
|
||||
style="line-height: ' . StylesHelper::$line_height . ';' . StylesHelper::getBlockStyles($element) . StylesHelper::getStyles($element['styles'], 'text') . '">
|
||||
style="line-height: ' . $line_height . ';' . StylesHelper::getBlockStyles($element) . StylesHelper::getStyles($element['styles'], 'text') . '">
|
||||
' . $DOM->html() . '
|
||||
</td>
|
||||
</tr>';
|
||||
|
@ -6,7 +6,10 @@ use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||
class Header {
|
||||
static function render($element) {
|
||||
$element['text'] = preg_replace('/\n/', '<br /><br />', $element['text']);
|
||||
$element['text'] = preg_replace('/(<\/?p.*?>)/', '', $element['text']);
|
||||
$element['text'] = preg_replace('/(<\/?p.*?>)/i', '', $element['text']);
|
||||
$line_height = sprintf(
|
||||
'%spx', StylesHelper::$line_height_multiplier * (int) $element['styles']['text']['fontSize']
|
||||
);
|
||||
$DOM_parser = new \pQuery();
|
||||
$DOM = $DOM_parser->parseStr($element['text']);
|
||||
if(isset($element['styles']['link'])) {
|
||||
@ -25,8 +28,8 @@ class Header {
|
||||
$template = '
|
||||
<tr>
|
||||
<td class="mailpoet_header_footer_padded mailpoet_header" ' . $background_color . '
|
||||
style="' . StylesHelper::getBlockStyles($element) . StylesHelper::getStyles($element['styles'], 'text') . '">
|
||||
' . $DOM->html() . '
|
||||
style="line-height: ' . $line_height . ';' . StylesHelper::getBlockStyles($element) . StylesHelper::getStyles($element['styles'], 'text') . '">
|
||||
' . $DOM->html() . '
|
||||
</td>
|
||||
</tr>';
|
||||
return $template;
|
||||
|
@ -11,7 +11,7 @@ class Image {
|
||||
$element = self::adjustImageDimensions($element, $column_count);
|
||||
$image_template = '
|
||||
<img style="max-width:' . $element['width'] . 'px;" src="' . $element['src'] . '"
|
||||
width="' . $element['width'] . '" height="' . $element['height'] . '" alt="' . $element['alt'] . '"/>
|
||||
width="' . $element['width'] . '" alt="' . $element['alt'] . '"/>
|
||||
';
|
||||
if(!empty($element['link'])) {
|
||||
$image_template = '<a href="' . $element['link'] . '">' . $image_template . '</a>';
|
||||
|
@ -10,7 +10,7 @@ class Text {
|
||||
$html = self::convertParagraphsToTables($html);
|
||||
$html = self::styleLists($html);
|
||||
$html = self::styleHeadings($html);
|
||||
$html = self::addLineBreakAfterTags($html);
|
||||
$html = self::removeLastLineBreak($html);
|
||||
$template = '
|
||||
<tr>
|
||||
<td class="mailpoet_text mailpoet_padded_bottom mailpoet_padded_side" valign="top" style="word-break:break-word;word-wrap:break-word;">
|
||||
@ -56,6 +56,14 @@ class Text {
|
||||
</tr>
|
||||
</tbody>'
|
||||
);
|
||||
$blockquote->parent->insertChild(
|
||||
array(
|
||||
'tag_name' => 'br',
|
||||
'self_close' => true,
|
||||
'attributes' => array()
|
||||
),
|
||||
$blockquote->index() + 1
|
||||
);
|
||||
}
|
||||
return $DOM->__toString();
|
||||
}
|
||||
@ -72,16 +80,23 @@ class Text {
|
||||
continue;
|
||||
}
|
||||
$style = $paragraph->style;
|
||||
if(!preg_match('/text-align/i', $style)) {
|
||||
$style = 'text-align: left;' . $style;
|
||||
}
|
||||
$contents = $paragraph->html();
|
||||
$paragraph->setTag('table');
|
||||
$paragraph->style = 'border-spacing:0;mso-table-lspace:0;mso-table-rspace:0;';
|
||||
$paragraph->width = '100%';
|
||||
$paragraph->cellpadding = 0;
|
||||
$next_element = $paragraph->getNextSibling();
|
||||
// unless this is the last element in column, add double line breaks
|
||||
$line_breaks = ($next_element && !empty($next_element->getInnerText())) ? '<br /><br />' : '';
|
||||
// if this element is followed by a list, add single line break
|
||||
$line_breaks = ($next_element && preg_match('/<li>/i', $next_element->getInnerText())) ? '<br />' : $line_breaks;
|
||||
$paragraph->html('
|
||||
<tr>
|
||||
<td class="mailpoet_paragraph" style="line-height:' . StylesHelper::$line_height . ';word-break:break-word;word-wrap:break-word;' . $style . '">
|
||||
' . $contents . '
|
||||
<br />
|
||||
<td class="mailpoet_paragraph" style="word-break:break-word;word-wrap:break-word;' . $style . '">
|
||||
' . $contents . $line_breaks . '
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
@ -96,11 +111,13 @@ class Text {
|
||||
if(!$lists->count()) return $html;
|
||||
foreach($lists as $list) {
|
||||
if($list->tag === 'li') {
|
||||
$list->setInnertext($list->text());
|
||||
$list->class = 'mailpoet_paragraph';
|
||||
} else {
|
||||
$list->class = 'mailpoet_paragraph';
|
||||
$list->style .= 'line-height:' . StylesHelper::$line_height . ';padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;';
|
||||
$list->style .= 'padding-top:0;padding-bottom:0;margin-top:10px;';
|
||||
}
|
||||
$list->style .= 'margin-bottom:10px;';
|
||||
}
|
||||
return $DOM->__toString();
|
||||
}
|
||||
@ -111,27 +128,12 @@ class Text {
|
||||
$headings = $DOM->query('h1, h2, h3, h4');
|
||||
if(!$headings->count()) return $html;
|
||||
foreach($headings as $heading) {
|
||||
$heading->style .= 'line-height:' . StylesHelper::$line_height . ';margin:0;font-style:normal;font-weight:normal;';
|
||||
$heading->style .= 'padding:0;font-style:normal;font-weight:normal;';
|
||||
}
|
||||
return $DOM->__toString();
|
||||
}
|
||||
|
||||
static function addLineBreakAfterTags($html) {
|
||||
$DOM_parser = new \pQuery();
|
||||
$DOM = $DOM_parser->parseStr($html);
|
||||
$tags = $DOM->query('ul, ol, h1, h2, h3, h4, table.mailpoet_blockquote');
|
||||
if(!$tags->count()) return $html;
|
||||
foreach($tags as $tag) {
|
||||
$tag->parent->insertChild(
|
||||
array(
|
||||
'tag_name' => 'br',
|
||||
'self_close' => true,
|
||||
'attributes' => array()
|
||||
),
|
||||
$tag->index() + 1
|
||||
);
|
||||
}
|
||||
// remove last line break
|
||||
return preg_replace('/(^)?(<br.*?\/?>)+$/i', '', $DOM->__toString());
|
||||
static function removeLastLineBreak($html) {
|
||||
return preg_replace('/(^)?(<br.*?\/?>)+$/i', '', $html);
|
||||
}
|
||||
}
|
@ -62,25 +62,18 @@ class Renderer {
|
||||
$css = '';
|
||||
foreach($styles as $selector => $style) {
|
||||
switch($selector) {
|
||||
case 'text':
|
||||
$selector = 'td.mailpoet_paragraph, td.mailpoet_blockquote';
|
||||
break;
|
||||
case 'body':
|
||||
$selector = 'body, .mailpoet-wrapper';
|
||||
break;
|
||||
case 'link':
|
||||
$selector = '.mailpoet-wrapper a';
|
||||
break;
|
||||
case 'wrapper':
|
||||
$selector = '.mailpoet_content-wrapper';
|
||||
break;
|
||||
}
|
||||
if(isset($style['fontFamily'])) {
|
||||
$css .= StylesHelper::setFontFamily(
|
||||
$style['fontFamily'],
|
||||
$selector
|
||||
);
|
||||
unset($style['fontFamily']);
|
||||
case 'text':
|
||||
$selector = 'td.mailpoet_paragraph, td.mailpoet_blockquote, li.mailpoet_paragraph';
|
||||
break;
|
||||
case 'body':
|
||||
$selector = 'body, .mailpoet-wrapper';
|
||||
break;
|
||||
case 'link':
|
||||
$selector = '.mailpoet-wrapper a';
|
||||
break;
|
||||
case 'wrapper':
|
||||
$selector = '.mailpoet_content-wrapper';
|
||||
break;
|
||||
}
|
||||
$css .= StylesHelper::setStyle($style, $selector);
|
||||
}
|
||||
@ -88,7 +81,7 @@ class Renderer {
|
||||
}
|
||||
|
||||
function injectContentIntoTemplate($template, $data) {
|
||||
return preg_replace_callback('/{{\w+}}/', function ($matches) use (&$data) {
|
||||
return preg_replace_callback('/{{\w+}}/', function($matches) use (&$data) {
|
||||
return array_shift($data);
|
||||
}, $template);
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ class StylesHelper {
|
||||
'Trebuchet MS' => "'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif",
|
||||
'Verdana' => 'Verdana, Geneva, sans-serif'
|
||||
);
|
||||
static $line_height = 1.61803398875;
|
||||
static $line_height_multiplier = 1.6;
|
||||
static $heading_margin_multiplier = 0.3;
|
||||
static $padding_width = 20;
|
||||
|
||||
static function getBlockStyles($element, $ignore_specific_styles = false) {
|
||||
@ -52,19 +53,12 @@ class StylesHelper {
|
||||
$attribute;
|
||||
}
|
||||
|
||||
static function setFontFamily($font_family, $selector) {
|
||||
$font_family = (isset(self::$font[$font_family])) ?
|
||||
self::$font[$font_family] :
|
||||
self::$font['Arial'];
|
||||
$css = $selector . '{' . PHP_EOL;
|
||||
$css .= 'font-family:' . $font_family . ';' . PHP_EOL;
|
||||
$css .= '}' . PHP_EOL;
|
||||
return $css;
|
||||
}
|
||||
|
||||
static function setStyle($style, $selector) {
|
||||
$css = $selector . '{' . PHP_EOL;
|
||||
$style = self::applyHeadingMargin($style, $selector);
|
||||
$style = self::applyLineHeight($style, $selector);
|
||||
foreach($style as $attribute => $individual_style) {
|
||||
$individual_style = self::applyFontFamily($attribute, $individual_style);
|
||||
$css .= self::translateCSSAttribute($attribute) . ':' . $individual_style . ';' . PHP_EOL;
|
||||
}
|
||||
$css .= '}' . PHP_EOL;
|
||||
@ -80,10 +74,31 @@ class StylesHelper {
|
||||
$text_alignment = isset($block['styles']['block']['textAlign']) ?
|
||||
strtolower($block['styles']['block']['textAlign']) :
|
||||
false;
|
||||
if(!$text_alignment || !in_array($text_alignment, $alignments)) {
|
||||
if(in_array($text_alignment, $alignments)) {
|
||||
return $block;
|
||||
}
|
||||
$block['styles']['block']['textAlign'] = 'left';
|
||||
return $block;
|
||||
}
|
||||
|
||||
static function applyFontFamily($attribute, $style) {
|
||||
if($attribute !== 'fontFamily') return $style;
|
||||
return (isset(self::$font[$style])) ?
|
||||
self::$font[$style] :
|
||||
self::$font['Arial'];
|
||||
}
|
||||
|
||||
static function applyHeadingMargin($style, $selector) {
|
||||
if (!preg_match('/h[1-4]/i', $selector)) return $style;
|
||||
$font_size = (int) $style['fontSize'];
|
||||
$style['margin'] = sprintf('0 0 %spx 0', self::$heading_margin_multiplier * $font_size);
|
||||
return $style;
|
||||
}
|
||||
|
||||
static function applyLineHeight($style, $selector) {
|
||||
if (!preg_match('/mailpoet_paragraph|h[1-4]/i', $selector)) return $style;
|
||||
$font_size = (int) $style['fontSize'];
|
||||
$style['lineHeight'] = sprintf('%spx', self::$line_height_multiplier * $font_size);
|
||||
return $style;
|
||||
}
|
||||
}
|
@ -54,8 +54,8 @@
|
||||
}
|
||||
.mailpoet_button {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
padding: 5px 0 !important;
|
||||
box-sizing:border-box !important;
|
||||
}
|
||||
div, .mailpoet_cols-two, .mailpoet_cols-three {
|
||||
max-width: 100% !important;
|
||||
|
@ -43,7 +43,8 @@ class Scheduler {
|
||||
$option_field = NewsletterOptionField::where('name', 'schedule')
|
||||
->findOne()
|
||||
->asArray();
|
||||
$relation = NewsletterOption::where('option_field_id', $option_field['id'])
|
||||
$relation = NewsletterOption::where('newsletter_id', $newsletter_id)
|
||||
->where('option_field_id', $option_field['id'])
|
||||
->findOne();
|
||||
if(!$relation) {
|
||||
$relation = NewsletterOption::create();
|
||||
|
@ -157,7 +157,7 @@ class Newsletters {
|
||||
if(empty($data['subscriber'])) {
|
||||
return array(
|
||||
'result' => false,
|
||||
'errors' => array(__('Please specify receiver information'))
|
||||
'errors' => array(__('Please specify receiver information.'))
|
||||
);
|
||||
}
|
||||
|
||||
@ -165,20 +165,17 @@ class Newsletters {
|
||||
|
||||
$renderer = new Renderer($newsletter);
|
||||
$rendered_newsletter = $renderer->render();
|
||||
$divider = '***MailPoet***';
|
||||
$data_for_shortcodes =
|
||||
array_merge(array($newsletter['subject']), $rendered_newsletter);
|
||||
$body = implode($divider, $data_for_shortcodes);
|
||||
$shortcodes = new \MailPoet\Newsletter\Shortcodes\Shortcodes(
|
||||
$rendered_newsletter['html'],
|
||||
$newsletter
|
||||
);
|
||||
$processed_newsletter['html'] = $shortcodes->replace();
|
||||
$shortcodes = new \MailPoet\Newsletter\Shortcodes\Shortcodes(
|
||||
$rendered_newsletter['text'],
|
||||
$newsletter
|
||||
);
|
||||
$processed_newsletter['text'] = $shortcodes->replace();
|
||||
$newsletter['body'] = array(
|
||||
'html' => $processed_newsletter['html'],
|
||||
'text' => $processed_newsletter['text'],
|
||||
);
|
||||
list($newsletter['subject'],
|
||||
$newsletter['body']['html'],
|
||||
$newsletter['body']['text']
|
||||
) = explode($divider, $shortcodes->replace($body));
|
||||
|
||||
try {
|
||||
$mailer = new \MailPoet\Mailer\Mailer(
|
||||
|
@ -18,23 +18,6 @@ class Hosts {
|
||||
'EU (Ireland)' => 'eu-west-1'
|
||||
)
|
||||
),
|
||||
'ElasticEmail' => array(
|
||||
'name' => 'ElasticEmail',
|
||||
'emails' => 100,
|
||||
'interval' => 5,
|
||||
'fields' => array(
|
||||
'api_key'
|
||||
)
|
||||
),
|
||||
'MailGun' => array(
|
||||
'name' => 'MailGun',
|
||||
'emails' => 100,
|
||||
'interval' => 5,
|
||||
'fields' => array(
|
||||
'domain',
|
||||
'api_key'
|
||||
)
|
||||
),
|
||||
'SendGrid' => array(
|
||||
'name' => 'SendGrid',
|
||||
'emails' => 100,
|
||||
|
@ -116,6 +116,7 @@ class CSS {
|
||||
public function parseCSS($text)
|
||||
{
|
||||
$css = new csstidy();
|
||||
$css->settings['compress_colors'] = false;
|
||||
$css->parse($text);
|
||||
|
||||
$rules = array();
|
||||
|
@ -4,7 +4,7 @@ if(!defined('ABSPATH')) exit;
|
||||
use \MailPoet\Config\Initializer;
|
||||
/*
|
||||
* Plugin Name: MailPoet
|
||||
* Version: 0.0.22
|
||||
* Version: 0.0.23
|
||||
* Plugin URI: http://www.mailpoet.com
|
||||
* Description: MailPoet Newsletters.
|
||||
* Author: MailPoet
|
||||
@ -22,7 +22,7 @@ use \MailPoet\Config\Initializer;
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
define('MAILPOET_VERSION', '0.0.22');
|
||||
define('MAILPOET_VERSION', '0.0.23');
|
||||
|
||||
$initializer = new Initializer(array(
|
||||
'file' => __FILE__,
|
||||
|
@ -207,11 +207,10 @@ class NewsletterRendererTest extends MailPoetTest {
|
||||
)
|
||||
)->true();
|
||||
expect($DOM('tr > td.mailpoet_text > ul.mailpoet_paragraph', 0)->attr('style'))
|
||||
->contains('padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;');
|
||||
->contains('padding-top:0;padding-bottom:0;margin-top:10px;margin-bottom:10px;');
|
||||
// headings should be styled
|
||||
expect($DOM('tr > td.mailpoet_text > h1', 0)->attr('style'))
|
||||
->contains('margin:0;font-style:normal;font-weight:normal;');
|
||||
|
||||
->contains('padding:0;font-style:normal;font-weight:normal;');
|
||||
}
|
||||
|
||||
function testItRendersDivider() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
<% set intervals = [1, 2, 5, 10, 15, 30, 60] %>
|
||||
<% set intervals = [1, 2, 5, 10, 15] %>
|
||||
<% set default_frequency = {
|
||||
'website': {
|
||||
'emails': 25,
|
||||
'interval': 15
|
||||
'interval': 5
|
||||
},
|
||||
'smtp': {
|
||||
'emails': 100,
|
||||
@ -66,15 +66,21 @@
|
||||
<img
|
||||
src="<%= assets_url %>/img/mailpoet_logo.png"
|
||||
alt="MailPoet"
|
||||
width="222"
|
||||
width="137"
|
||||
height="54"
|
||||
/>
|
||||
</h3>
|
||||
|
||||
<p class="mailpoet_description">
|
||||
<%= __('Send to 500 subscribers per month for <strong>free</strong>. Enjoy great deliverability, and speed.') %>
|
||||
<br /><br />
|
||||
<a href="#todo"><%= __('See pricing for more.') %></a>
|
||||
<strong><%= __('Currently in closed beta.') %></strong>
|
||||
<br />
|
||||
<%= __('[link]Sign up to our newsletter[/link] to get our latest news on this, and more.')
|
||||
| replace({
|
||||
'[link]': '<a href="http://www.mailpoet.com/subscribe/" target="_blank">',
|
||||
'[/link]': '</a>'
|
||||
})
|
||||
| raw
|
||||
%>
|
||||
</p>
|
||||
|
||||
<div class="mailpoet_status">
|
||||
@ -91,10 +97,12 @@
|
||||
data-group="website"
|
||||
<% if(settings.mta_group == 'website') %>class="mailpoet_active"<% endif %>
|
||||
>
|
||||
<h3><%= __('Your own website') %></h3>
|
||||
<h3><%= __('Your web host/server') %></h3>
|
||||
|
||||
<p class="mailpoet_description">
|
||||
<%= __('The simplest solution for small lists. Your web host sets a daily email limit.') %>
|
||||
<strong><%= __('Free, but not recommended.') %></strong>
|
||||
<br />
|
||||
<%= __('Web hosts generally have a bad reputation as senders. Your newsletter might be considered spam.') %>
|
||||
</p>
|
||||
|
||||
<div class="mailpoet_status">
|
||||
@ -114,6 +122,8 @@
|
||||
<h3><%= __('Third party') %></h3>
|
||||
|
||||
<p class="mailpoet_description">
|
||||
<strong><%= __('Currently the best solution.') %></strong>
|
||||
<br />
|
||||
<%= __('Send with an alternate email provider. Usually not free.') %>
|
||||
</p>
|
||||
|
||||
@ -136,29 +146,6 @@
|
||||
data-group="mailpoet"
|
||||
style="display:none;"
|
||||
>
|
||||
<h3><%= __('Open a free account with MailPoet, and get:') %></h3>
|
||||
<ol>
|
||||
<li>
|
||||
<%=
|
||||
__('Send up to 4000 emails with good deliverability for free. %1$sNeed more?%2$s')
|
||||
| format('<a href="#todo">', '</a>')
|
||||
| raw
|
||||
%>
|
||||
</li>
|
||||
<li>
|
||||
<%= __("Test your campaign's spam score") %>
|
||||
</li>
|
||||
<li>
|
||||
<%= __('Send on time, without delay, without setting up your own "cron"') %>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<a class="button-secondary">
|
||||
<%=- __('Create a free account to get a key') -%>
|
||||
</a>
|
||||
|
||||
<hr />
|
||||
|
||||
<h3><%= __('Already have a key?') %></h3>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
@ -243,10 +230,11 @@
|
||||
type="number"
|
||||
min="1"
|
||||
max="1000"
|
||||
value="<%=
|
||||
settings.mta.frequency.emails
|
||||
| default(default_frequency.website.emails)
|
||||
%>"
|
||||
<% if(settings.mta_group == 'website') %>
|
||||
value="<%= settings.mta.frequency.emails %>"
|
||||
<% else %>
|
||||
value="<%= default_frequency.website.emails %>"
|
||||
<% endif %>
|
||||
/>
|
||||
<%= __('emails') %>
|
||||
<select id="website_frequency_interval">
|
||||
@ -264,7 +252,7 @@
|
||||
<% endif %>
|
||||
>
|
||||
<%= sending_frequency(interval) %>
|
||||
<% if(interval == 15) %>
|
||||
<% if(interval == default_frequency.website.interval) %>
|
||||
(<%= __('recommended') %>)
|
||||
<% endif %>
|
||||
</option>
|
||||
@ -274,7 +262,7 @@
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<%= __('<strong>Warning!</strong> Sending more than the recommended amount of emails might break the terms of your host or provider.') %>
|
||||
<%= __('<strong>Warning!</strong> Sending more than the recommended amount of emails might break the terms of your host or provider.') %>'
|
||||
<br />
|
||||
<%= __('Double check with them what maximum number of emails you can send daily.') %>
|
||||
</p>
|
||||
@ -335,10 +323,11 @@
|
||||
type="number"
|
||||
min="1"
|
||||
max="1000"
|
||||
value="<%=
|
||||
settings.mta.frequency.emails
|
||||
| default(default_frequency.smtp.emails)
|
||||
%>"
|
||||
<% if(settings.mta_group == 'smtp') %>
|
||||
value="<%= settings.mta.frequency.emails %>"
|
||||
<% else %>
|
||||
value="<%= default_frequency.smtp.emails %>"
|
||||
<% endif %>
|
||||
/>
|
||||
<%= __('emails') %>
|
||||
<select id="smtp_frequency_interval">
|
||||
@ -356,7 +345,7 @@
|
||||
<% endif %>
|
||||
>
|
||||
<%= sending_frequency(interval) %>
|
||||
<% if(interval == 15) %>
|
||||
<% if(interval == default_frequency.smtp.interval) %>
|
||||
(<%= __('recommended') %>)
|
||||
<% endif %>
|
||||
</option>
|
||||
@ -364,12 +353,6 @@
|
||||
</select>
|
||||
<span id="mailpoet_smtp_daily_emails"></span>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<%= __('<strong>Warning!</strong> Sending more than the recommended amount of emails might break the terms of your host or provider.') %>
|
||||
<br />
|
||||
<%= __('Double check with them what maximum number of emails you can send daily.') %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- smtp: host -->
|
||||
@ -617,13 +600,29 @@
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<!-- SPF -->
|
||||
<tr id="mailpoet_mta_spf">
|
||||
<th scope="row">
|
||||
<label>
|
||||
<%= __('SPF signature (recommended)') %>
|
||||
<p class="description">
|
||||
<%= __('Improves your spam score by allowing the recipient to verify that your website is allowed to send emails from your domain.') %>
|
||||
</p>
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
<p>
|
||||
<%= __('SPF is set in your DNS. Check the support documents of your host to set it up.') %>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- dkim -->
|
||||
<tr id="mailpoet_mta_dkim">
|
||||
<tr id="mailpoet_mta_dkim" style="display:none;">
|
||||
<th scope="row">
|
||||
<label for="settings[dkim_enabled]">
|
||||
<%= __('DKIM signature') %>
|
||||
<%= __('DKIM signature (recommended)') %>
|
||||
<p class="description">
|
||||
<%= __('Improve your spam score. Mailpoet can sign all your emails with DKIM.') %>
|
||||
<%= __('Improve your spam score. MailPoet can sign all your emails with DKIM.') %>
|
||||
<a
|
||||
href="#todo/guide-to-dkim-in-wysija/"
|
||||
target="_blank"
|
||||
@ -693,6 +692,7 @@
|
||||
<input
|
||||
id="mailpoet_mta_test_email"
|
||||
type="text"
|
||||
class="regular-text"
|
||||
value="<%= current_user.user_email %>"
|
||||
/>
|
||||
<a
|
||||
@ -745,6 +745,16 @@
|
||||
: $('#mta_group').val()
|
||||
);
|
||||
|
||||
// check that we have a from address
|
||||
if(settings.sender.address.length === 0) {
|
||||
// validation
|
||||
return MailPoet.Notice.error(
|
||||
'The email could not be sent. Make sure the option "Email notifications" has a FROM email address in the Basics tab.',
|
||||
{ scroll: true, static: true }
|
||||
);
|
||||
}
|
||||
|
||||
MailPoet.Modal.loading(true);
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'mailer',
|
||||
action: 'send',
|
||||
@ -763,16 +773,35 @@
|
||||
}
|
||||
}
|
||||
}).done(function(response) {
|
||||
MailPoet.Modal.loading(false);
|
||||
if(response.result === true) {
|
||||
MailPoet.Notice.success("The email has been sent! Check your inbox.");
|
||||
MailPoet.Notice.success(
|
||||
"<%= __('The email has been sent! Check your inbox.') %>",
|
||||
{ scroll: true }
|
||||
);
|
||||
} else {
|
||||
if (response.errors) {
|
||||
MailPoet.Notice.error("The email could not be sent. " + response.errors);
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('The email could not be sent.') %> " + response.errors,
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
else {
|
||||
MailPoet.Notice.error("The email could not be sent. Please check your settings.");
|
||||
if(mailer.method === 'PHPMail') {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('The email could not be sent. Contact your host to help you fix any sending issues with your server.') %>",
|
||||
{ scroll: true, static: true }
|
||||
);
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('The email could not be sent. Please check your settings.') %>",
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).error(function(response) {
|
||||
MailPoet.Modal.loading(false);
|
||||
});
|
||||
});
|
||||
|
||||
@ -965,7 +994,16 @@
|
||||
interval: $('#'+method+'_frequency_interval').val()
|
||||
};
|
||||
|
||||
options.daily_emails = ~~((1440 / options.interval) * options.emails);
|
||||
var MINUTES_PER_DAY = 1440;
|
||||
var SECONDS_PER_DAY = 86400;
|
||||
|
||||
options.daily_emails = ~~(
|
||||
(MINUTES_PER_DAY / options.interval) * options.emails
|
||||
);
|
||||
|
||||
options.emails_per_second = (~~(
|
||||
((options.daily_emails) / 86400) * 10)
|
||||
) / 10;
|
||||
|
||||
$('#mailpoet_'+method+'_daily_emails').html(
|
||||
sending_frequency_template(options)
|
||||
|
@ -11,4 +11,15 @@
|
||||
__("That's <strong>%1$s emails</strong> per day.")
|
||||
| format('{{ daily_emails }}')
|
||||
| raw
|
||||
%>
|
||||
%>
|
||||
|
||||
{{#ifCond emails_per_second ">" "1"}}
|
||||
<br /><br />
|
||||
<span style="color: #d54e21;">
|
||||
<%=
|
||||
__("That's %1$s emails per second. <strong>We highly recommend to send 1 email per second at most.</strong> This is the time MailPoet needs to process and send a single email from most hosts. <strong>Alternatively, send with MailPoet which can be 50 times faster.</strong>")
|
||||
| format('{{ emails_per_second }}')
|
||||
| raw
|
||||
%>
|
||||
</span>
|
||||
{{/ifCond}}
|
Reference in New Issue
Block a user