Create a re-engagement page

[MAILPOET-3856]
This commit is contained in:
Pavel Dohnal
2021-10-22 12:43:46 +02:00
committed by Veljko V
parent 49e98ea88e
commit 39fe83b49c
2 changed files with 29 additions and 0 deletions

View File

@@ -14,6 +14,8 @@ class Subscription {
const ACTION_MANAGE = 'manage'; const ACTION_MANAGE = 'manage';
const ACTION_UNSUBSCRIBE = 'unsubscribe'; const ACTION_UNSUBSCRIBE = 'unsubscribe';
const ACTION_CONFIRM_UNSUBSCRIBE = 'confirmUnsubscribe'; const ACTION_CONFIRM_UNSUBSCRIBE = 'confirmUnsubscribe';
const ACTION_RE_ENGAGEMENT = 'reEngagement';
public $allowedActions = [ public $allowedActions = [
self::ACTION_CAPTCHA, self::ACTION_CAPTCHA,
self::ACTION_CAPTCHA_IMAGE, self::ACTION_CAPTCHA_IMAGE,
@@ -21,7 +23,9 @@ class Subscription {
self::ACTION_MANAGE, self::ACTION_MANAGE,
self::ACTION_UNSUBSCRIBE, self::ACTION_UNSUBSCRIBE,
self::ACTION_CONFIRM_UNSUBSCRIBE, self::ACTION_CONFIRM_UNSUBSCRIBE,
self::ACTION_RE_ENGAGEMENT,
]; ];
public $permissions = [ public $permissions = [
'global' => AccessControl::NO_ACCESS_RESTRICTION, 'global' => AccessControl::NO_ACCESS_RESTRICTION,
]; ];
@@ -79,6 +83,10 @@ class Subscription {
$subscription->unsubscribe(); $subscription->unsubscribe();
} }
public function reEngagement($data) {
$this->initSubscriptionPage(UserSubscription\Pages::ACTION_RE_ENGAGEMENT, $data);
}
private function initSubscriptionPage($action, $data) { private function initSubscriptionPage($action, $data) {
return $this->subscriptionPages->init($action, $data, true, true); return $this->subscriptionPages->init($action, $data, true, true);
} }

View File

@@ -24,6 +24,7 @@ class Pages {
const ACTION_CONFIRM_UNSUBSCRIBE = 'confirm_unsubscribe'; const ACTION_CONFIRM_UNSUBSCRIBE = 'confirm_unsubscribe';
const ACTION_MANAGE = 'manage'; const ACTION_MANAGE = 'manage';
const ACTION_UNSUBSCRIBE = 'unsubscribe'; const ACTION_UNSUBSCRIBE = 'unsubscribe';
const ACTION_RE_ENGAGEMENT = 're_engagement';
private $action; private $action;
private $data; private $data;
@@ -239,6 +240,9 @@ class Pages {
case self::ACTION_UNSUBSCRIBE: case self::ACTION_UNSUBSCRIBE:
return $this->getUnsubscribeTitle(); return $this->getUnsubscribeTitle();
case self::ACTION_RE_ENGAGEMENT:
return $this->getReEngagementTitle();
} }
} }
} }
@@ -272,6 +276,9 @@ class Pages {
case self::ACTION_UNSUBSCRIBE: case self::ACTION_UNSUBSCRIBE:
$content = $this->getUnsubscribeContent(); $content = $this->getUnsubscribeContent();
break; break;
case self::ACTION_RE_ENGAGEMENT:
$content = $this->getReEngagementContent();
break;
} }
return str_replace('[mailpoet_page]', trim($content), $pageContent); return str_replace('[mailpoet_page]', trim($content), $pageContent);
} else { } else {
@@ -335,6 +342,12 @@ class Pages {
} }
} }
private function getReEngagementTitle() {
if ($this->isPreview() || $this->subscriber !== null) {
return __('Thank you for letting us know!', 'mailpoet');
}
}
private function getConfirmUnsubscribeTitle() { private function getConfirmUnsubscribeTitle() {
if ($this->isPreview() || $this->subscriber !== null) { if ($this->isPreview() || $this->subscriber !== null) {
return $this->wp->__('Confirm you want to unsubscribe', 'mailpoet'); return $this->wp->__('Confirm you want to unsubscribe', 'mailpoet');
@@ -384,6 +397,14 @@ class Pages {
return $content; return $content;
} }
private function getReEngagementContent() {
$content = '';
if ($this->isPreview() || $this->subscriber !== null) {
$content .= '<p>' . __('We appreciate your continued interest in our updates. Expect to hear from us again soon!', 'mailpoet') . '</p>';
}
return $content;
}
private function getConfirmUnsubscribeContent() { private function getConfirmUnsubscribeContent() {
if (!$this->isPreview() && $this->subscriber === null) { if (!$this->isPreview() && $this->subscriber === null) {
return ''; return '';