Confirmation email + Subscription pages
- form as an iframe: increased marginY - fixed issue with page titles (old themes using wp_title hook) - redirect on reinstall instead of showing a message (to avoid being able to re-save old settings)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
define('iframe', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||
'use strict';
|
||||
MailPoet.Iframe = {
|
||||
marginY: 15,
|
||||
marginY: 20,
|
||||
autoSize: function(iframe) {
|
||||
if(!iframe) return;
|
||||
|
||||
|
@ -75,8 +75,8 @@ class Widget {
|
||||
);
|
||||
|
||||
echo $this->renderer->render('form/iframe.html', $data);
|
||||
exit();
|
||||
}
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,14 +118,14 @@ class Subscriber extends Model {
|
||||
// set from
|
||||
$from = (
|
||||
!empty($signup_confirmation['from'])
|
||||
&& !empty($signup_confirmation['from']['email'])
|
||||
&& !empty($signup_confirmation['from']['address'])
|
||||
) ? $signup_confirmation['from']
|
||||
: false;
|
||||
|
||||
// set reply to
|
||||
$reply_to = (
|
||||
!empty($signup_confirmation['reply_to'])
|
||||
&& !empty($signup_confirmation['reply_to']['email'])
|
||||
&& !empty($signup_confirmation['reply_to']['address'])
|
||||
) ? $signup_confirmation['reply_to']
|
||||
: false;
|
||||
|
||||
@ -153,6 +153,10 @@ class Subscriber extends Model {
|
||||
return false;
|
||||
}
|
||||
|
||||
$signup_confirmation_enabled = (bool)Setting::getValue(
|
||||
'signup_confirmation.enabled'
|
||||
);
|
||||
|
||||
$subscriber = self::createOrUpdate($subscriber_data);
|
||||
$errors = $subscriber->getErrors();
|
||||
|
||||
@ -164,16 +168,21 @@ class Subscriber extends Model {
|
||||
$subscriber->setExpr('deleted_at', 'NULL');
|
||||
}
|
||||
|
||||
if((bool)Setting::getValue('signup_confirmation.enabled')) {
|
||||
if($subscriber->status !== self::STATUS_SUBSCRIBED) {
|
||||
$subscriber->sendConfirmationEmail();
|
||||
}
|
||||
} else {
|
||||
// auto subscribe when signup confirmation is disabled
|
||||
if($signup_confirmation_enabled === false) {
|
||||
$subscriber->set('status', self::STATUS_SUBSCRIBED);
|
||||
}
|
||||
|
||||
if($subscriber->save()) {
|
||||
// link subscriber to segments
|
||||
$subscriber->addToSegments($segment_ids);
|
||||
|
||||
// signup confirmation
|
||||
if($subscriber->status !== self::STATUS_SUBSCRIBED) {
|
||||
$subscriber->sendConfirmationEmail();
|
||||
}
|
||||
|
||||
// welcome email
|
||||
Scheduler::welcomeForSegmentSubscription($subscriber->id, $segment_ids);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class Pages {
|
||||
function init() {
|
||||
$action = $this->getAction();
|
||||
if($action !== null) {
|
||||
add_filter('wp_title', array($this,'setWindowTitle'), 10, 1);
|
||||
add_filter('wp_title', array($this,'setWindowTitle'), 10, 3);
|
||||
add_filter('document_title_parts', array($this,'setWindowTitleParts'), 10, 1);
|
||||
add_filter('the_title', array($this,'setPageTitle'), 10, 1);
|
||||
add_filter('the_content', array($this,'setPageContent'), 10, 1);
|
||||
@ -60,8 +60,17 @@ class Pages {
|
||||
return (array_key_exists('mailpoet_preview', $_GET));
|
||||
}
|
||||
|
||||
function setWindowTitle($title) {
|
||||
return $this->setPageTitle($title);
|
||||
function setWindowTitle($title, $separator, $separator_location = 'right') {
|
||||
$title_parts = explode(" $separator ", $title);
|
||||
if($separator_location === 'right') {
|
||||
// first part
|
||||
$title_parts[0] = $this->setPageTitle($title_parts[0]);
|
||||
} else {
|
||||
// last part
|
||||
$last_index = count($title_parts) - 1;
|
||||
$title_parts[$last_index] = $this->setPageTitle($title_parts[$last_index]);
|
||||
}
|
||||
return implode(" $separator ", $title_parts);
|
||||
}
|
||||
|
||||
function setWindowTitleParts($meta = array()) {
|
||||
@ -69,10 +78,23 @@ class Pages {
|
||||
return $meta;
|
||||
}
|
||||
|
||||
function isMailPoetPage($page_id = null) {
|
||||
$mailpoet_page_ids = array_unique(array_values(
|
||||
Setting::getValue('subscription', array())
|
||||
));
|
||||
|
||||
return (in_array($page_id, $mailpoet_page_ids));
|
||||
}
|
||||
|
||||
function setPageTitle($page_title = '') {
|
||||
global $post;
|
||||
|
||||
if($post->post_type === 'mailpoet_page') {
|
||||
if(
|
||||
($this->isMailPoetPage($post->ID) === false)
|
||||
||
|
||||
($page_title !== single_post_title('', false))
|
||||
) {
|
||||
return $page_title;
|
||||
} else {
|
||||
$subscriber = $this->getSubscriber();
|
||||
switch($this->getAction()) {
|
||||
case 'confirm':
|
||||
@ -98,6 +120,16 @@ class Pages {
|
||||
}
|
||||
|
||||
function setPageContent($page_content = '[mailpoet_page]') {
|
||||
global $post;
|
||||
|
||||
if(
|
||||
($this->isPreview() === false)
|
||||
&&
|
||||
($this->isMailPoetPage($post->ID) === false)
|
||||
) {
|
||||
return $page_content;
|
||||
}
|
||||
|
||||
$content = '';
|
||||
$subscriber = $this->getSubscriber();
|
||||
|
||||
|
@ -195,9 +195,7 @@
|
||||
'action': 'reset'
|
||||
}).done(function(response) {
|
||||
if(response.result === true) {
|
||||
MailPoet.Notice.success(
|
||||
"<%= __('MailPoet has been reinstalled successfully using the same version. Settings and data have been deleted.') %>",
|
||||
{ scroll: true });
|
||||
window.location = "<%= admin_url('admin.php?page=mailpoet-newsletters') %>";
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('MailPoet could not be reinstalled. You might need to remove it manually first.') %>",
|
||||
|
Reference in New Issue
Block a user