Updated shortcodes for unsubscribe/manage/browser links
- fixed all issues in #387 except the custom mailpoet pages
This commit is contained in:
@ -16,7 +16,7 @@ define([
|
|||||||
defaults: function() {
|
defaults: function() {
|
||||||
return this._getDefaults({
|
return this._getDefaults({
|
||||||
type: 'footer',
|
type: 'footer',
|
||||||
text: '<a href="[unsubscribeUrl]">Unsubscribe</a> | <a href="[manageSubscriptionUrl]">Manage subscription</a><br /><b>Add your postal address here!</b>',
|
text: '<a href="[subscription:unsubscribe_url]">Unsubscribe</a> | <a href="[subscription:manage_url]">Manage subscription</a><br /><b>Add your postal address here!</b>',
|
||||||
styles: {
|
styles: {
|
||||||
block: {
|
block: {
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
|
@ -16,7 +16,7 @@ define([
|
|||||||
defaults: function() {
|
defaults: function() {
|
||||||
return this._getDefaults({
|
return this._getDefaults({
|
||||||
type: 'header',
|
type: 'header',
|
||||||
text: 'Display problems? <a href="[viewInBrowserUrl]">View it in your browser</a>',
|
text: 'Display problems? <a href="[newsletter:view_in_browser_url]">View it in your browser</a>',
|
||||||
styles: {
|
styles: {
|
||||||
block: {
|
block: {
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
|
@ -284,7 +284,7 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent') &&
|
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent') &&
|
||||||
JSON.stringify(jsonObject).indexOf("[unsubscribeUrl]") < 0) {
|
JSON.stringify(jsonObject).indexOf("[subscription:unsubscribe_url]") < 0) {
|
||||||
this.showValidationError(App.getConfig().get('translations.unsubscribeLinkMissing'));
|
this.showValidationError(App.getConfig().get('translations.unsubscribeLinkMissing'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,9 @@ class Populator {
|
|||||||
$mailpoet_page_id = $page->ID;
|
$mailpoet_page_id = $page->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
Setting::setValue('subscription.page', $mailpoet_page_id);
|
Setting::setValue('subscription.unsubscribe_page', $mailpoet_page_id);
|
||||||
Setting::setValue('signup_confirmation.page', $mailpoet_page_id);
|
Setting::setValue('subscription.manage_page', $mailpoet_page_id);
|
||||||
|
Setting::setValue('subscription.confirmation_page', $mailpoet_page_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createDefaultSettings() {
|
private function createDefaultSettings() {
|
||||||
|
@ -142,7 +142,7 @@ class BlankTemplate {
|
|||||||
"blocks" => array(
|
"blocks" => array(
|
||||||
array(
|
array(
|
||||||
"type" => "footer",
|
"type" => "footer",
|
||||||
"text" => "<a href=\"[unsubscribeUrl]\">Unsubscribe</a> | <a href=\"[manageSubscriptionUrl]\">Manage subscription</a><br /><b>Add your postal address here!</b>",
|
"text" => "<a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a> | <a href=\"[subscription:manage_url]\">Manage subscription</a><br /><b>Add your postal address here!</b>",
|
||||||
"styles" => array(
|
"styles" => array(
|
||||||
"block" => array(
|
"block" => array(
|
||||||
"backgroundColor" => "transparent"
|
"backgroundColor" => "transparent"
|
||||||
|
@ -46,7 +46,7 @@ class FranksRoastHouseTemplate {
|
|||||||
"blocks" => array(
|
"blocks" => array(
|
||||||
array(
|
array(
|
||||||
"type" => "header",
|
"type" => "header",
|
||||||
"text" => __("Display problems? <a href=\"[viewInBrowserUrl]\">View it in your browser</a>"),
|
"text" => __("Display problems? <a href=\"[newsletter:view_in_browser_url]\">View it in your browser</a>"),
|
||||||
"styles" => array(
|
"styles" => array(
|
||||||
"block" => array(
|
"block" => array(
|
||||||
"backgroundColor" => "#ccc6c6"
|
"backgroundColor" => "#ccc6c6"
|
||||||
@ -280,7 +280,7 @@ class FranksRoastHouseTemplate {
|
|||||||
"blocks" => array(
|
"blocks" => array(
|
||||||
array(
|
array(
|
||||||
"type" => "footer",
|
"type" => "footer",
|
||||||
"text" => __("<p><a href=\"[unsubscribeUrl]\">Unsubscribe</a> | <a href=\"[manageSubscriptionUrl]\">Manage subscription</a><br />12345 MailPoet Drive, EmailVille, 76543</p>"),
|
"text" => __("<p><a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a> | <a href=\"[subscription:manage_url]\">Manage subscription</a><br />12345 MailPoet Drive, EmailVille, 76543</p>"),
|
||||||
"styles" => array(
|
"styles" => array(
|
||||||
"block" => array(
|
"block" => array(
|
||||||
"backgroundColor" => "#a9a7a7"
|
"backgroundColor" => "#a9a7a7"
|
||||||
|
@ -242,7 +242,7 @@ class PostNotificationsBlankTemplate {
|
|||||||
"blocks" => array(
|
"blocks" => array(
|
||||||
array(
|
array(
|
||||||
"type" => "footer",
|
"type" => "footer",
|
||||||
"text" => __("<a href=\"[unsubscribeUrl]\">Unsubscribe</a> | <a href=\"[manageSubscriptionUrl]\">Manage subscription</a><br /><b>Add your postal address here!</b>"),
|
"text" => __("<a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a> | <a href=\"[subscription:manage_url]\">Manage subscription</a><br /><b>Add your postal address here!</b>"),
|
||||||
"styles" => array(
|
"styles" => array(
|
||||||
"block" => array(
|
"block" => array(
|
||||||
"backgroundColor" => "transparent"
|
"backgroundColor" => "transparent"
|
||||||
|
@ -46,7 +46,7 @@ class WelcomeTemplate {
|
|||||||
"blocks" => array(
|
"blocks" => array(
|
||||||
array(
|
array(
|
||||||
"type" => "header",
|
"type" => "header",
|
||||||
"text" => __("Display problems? <a href=\"[viewInBrowserUrl]\">View it in your browser</a>"),
|
"text" => __("Display problems? <a href=\"[newsletter:view_in_browser_url]\">View it in your browser</a>"),
|
||||||
"styles" => array(
|
"styles" => array(
|
||||||
"block" => array(
|
"block" => array(
|
||||||
"backgroundColor" => "transparent"
|
"backgroundColor" => "transparent"
|
||||||
@ -224,7 +224,7 @@ class WelcomeTemplate {
|
|||||||
"blocks" => array(
|
"blocks" => array(
|
||||||
array(
|
array(
|
||||||
"type" => "footer",
|
"type" => "footer",
|
||||||
"text" => __("<a href=\"[unsubscribeUrl]\">Unsubscribe</a> | <a href=\"[manageSubscriptionUrl]\">Manage subscription</a><br /><b>Add your postal address here!</b>"),
|
"text" => __("<a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a> | <a href=\"[subscription:manage_url]\">Manage subscription</a><br /><b>Add your postal address here!</b>"),
|
||||||
"styles" => array(
|
"styles" => array(
|
||||||
"block" => array(
|
"block" => array(
|
||||||
"backgroundColor" => "transparent"
|
"backgroundColor" => "transparent"
|
||||||
|
@ -203,7 +203,9 @@ class SendingQueue {
|
|||||||
$queue->subscribers->failed
|
$queue->subscribers->failed
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$queue->subscribers->to_process = array_values($queue->subscribers->to_process);
|
$queue->subscribers->to_process = array_values(
|
||||||
|
$queue->subscribers->to_process
|
||||||
|
);
|
||||||
$queue->count_processed =
|
$queue->count_processed =
|
||||||
count($queue->subscribers->processed) + count($queue->subscribers->failed);
|
count($queue->subscribers->processed) + count($queue->subscribers->failed);
|
||||||
$queue->count_to_process = count($queue->subscribers->to_process);
|
$queue->count_to_process = count($queue->subscribers->to_process);
|
||||||
|
@ -112,4 +112,17 @@ abstract class Base {
|
|||||||
&& strlen(trim($block['params']['value'])) > 0)
|
&& strlen(trim($block['params']['value'])) > 0)
|
||||||
? esc_attr(trim($block['params']['value'])) : '';
|
? esc_attr(trim($block['params']['value'])) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function getInputModifiers($block = array()) {
|
||||||
|
$modifiers = array();
|
||||||
|
|
||||||
|
if(isset($block['params']['readonly'])) {
|
||||||
|
$modifiers[] = 'readonly';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($block['params']['disabled'])) {
|
||||||
|
$modifiers[] = 'disabled';
|
||||||
|
}
|
||||||
|
return join(' ', $modifiers);
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ class Text extends Base {
|
|||||||
static function render($block) {
|
static function render($block) {
|
||||||
$type = 'text';
|
$type = 'text';
|
||||||
if($block['id'] === 'email') {
|
if($block['id'] === 'email') {
|
||||||
$type = 'email';
|
$type = 'email';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
@ -27,6 +27,8 @@ class Text extends Base {
|
|||||||
|
|
||||||
$html .= static::getInputValidation($block);
|
$html .= static::getInputValidation($block);
|
||||||
|
|
||||||
|
$html .= static::getInputModifiers($block);
|
||||||
|
|
||||||
$html .= '/>';
|
$html .= '/>';
|
||||||
|
|
||||||
$html .= '</p>';
|
$html .= '</p>';
|
||||||
|
@ -19,6 +19,8 @@ class Textarea extends Base {
|
|||||||
|
|
||||||
$html .= static::getInputValidation($block);
|
$html .= static::getInputValidation($block);
|
||||||
|
|
||||||
|
$html .= static::getInputModifiers($block);
|
||||||
|
|
||||||
$html .= '></textarea>';
|
$html .= '></textarea>';
|
||||||
|
|
||||||
$html .= '</p>';
|
$html .= '</p>';
|
||||||
|
@ -35,4 +35,8 @@ class SendingQueue extends Model {
|
|||||||
$this->save();
|
$this->save();
|
||||||
return ($this->getErrors() === false && $this->id() > 0);
|
return ($this->getErrors() === false && $this->id() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
return $this->delete();
|
||||||
|
}
|
||||||
}
|
}
|
@ -336,6 +336,9 @@ class Subscriber extends Model {
|
|||||||
|
|
||||||
static function createOrUpdate($data = array()) {
|
static function createOrUpdate($data = array()) {
|
||||||
$subscriber = false;
|
$subscriber = false;
|
||||||
|
if(is_array($data) && !empty($data)) {
|
||||||
|
$data = stripslashes_deep($data);
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($data['id']) && (int)$data['id'] > 0) {
|
if(isset($data['id']) && (int)$data['id'] > 0) {
|
||||||
$subscriber = self::findOne((int)$data['id']);
|
$subscriber = self::findOne((int)$data['id']);
|
||||||
@ -361,16 +364,25 @@ class Subscriber extends Model {
|
|||||||
|
|
||||||
foreach($data as $key => $value) {
|
foreach($data as $key => $value) {
|
||||||
if(strpos($key, 'cf_') === 0) {
|
if(strpos($key, 'cf_') === 0) {
|
||||||
|
if(is_array($value)) {
|
||||||
|
$value = array_filter($value);
|
||||||
|
$value = reset($value);
|
||||||
|
}
|
||||||
$custom_fields[(int)substr($key, 3)] = $value;
|
$custom_fields[(int)substr($key, 3)] = $value;
|
||||||
unset($data[$key]);
|
unset($data[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$old_status = false;
|
||||||
|
$new_status = false;
|
||||||
|
|
||||||
if($subscriber === false) {
|
if($subscriber === false) {
|
||||||
$subscriber = self::create();
|
$subscriber = self::create();
|
||||||
$subscriber->hydrate($data);
|
$subscriber->hydrate($data);
|
||||||
} else {
|
} else {
|
||||||
|
$old_status = $subscriber->status;
|
||||||
$subscriber->set($data);
|
$subscriber->set($data);
|
||||||
|
$new_status = $subscriber->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($subscriber->save()) {
|
if($subscriber->save()) {
|
||||||
@ -379,8 +391,19 @@ class Subscriber extends Model {
|
|||||||
$subscriber->setCustomField($custom_field_id, $value);
|
$subscriber->setCustomField($custom_field_id, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($segment_ids !== false) {
|
|
||||||
SubscriberSegment::setSubscriptions($subscriber, $segment_ids);
|
// check for status change
|
||||||
|
if(
|
||||||
|
($old_status === self::STATUS_SUBSCRIBED)
|
||||||
|
&&
|
||||||
|
($new_status === self::STATUS_UNSUBSCRIBED)
|
||||||
|
) {
|
||||||
|
// make sure we unsubscribe the user from all lists
|
||||||
|
SubscriberSegment::setSubscriptions($subscriber, array());
|
||||||
|
} else {
|
||||||
|
if($segment_ids !== false) {
|
||||||
|
SubscriberSegment::setSubscriptions($subscriber, $segment_ids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $subscriber;
|
return $subscriber;
|
||||||
|
@ -16,18 +16,19 @@ class SubscriberSegment extends Model {
|
|||||||
if($subscriber->id > 0) {
|
if($subscriber->id > 0) {
|
||||||
// unsubscribe from current subscriptions
|
// unsubscribe from current subscriptions
|
||||||
SubscriberSegment::where('subscriber_id', $subscriber->id)
|
SubscriberSegment::where('subscriber_id', $subscriber->id)
|
||||||
->whereNotIn('segment_id', $segment_ids)
|
|
||||||
->findResultSet()
|
->findResultSet()
|
||||||
->set('status', Subscriber::STATUS_UNSUBSCRIBED)
|
->set('status', Subscriber::STATUS_UNSUBSCRIBED)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
// subscribe to segments
|
// subscribe to segments
|
||||||
foreach($segment_ids as $segment_id) {
|
foreach($segment_ids as $segment_id) {
|
||||||
self::createOrUpdate(array(
|
if((int)$segment_id > 0) {
|
||||||
'subscriber_id' => $subscriber->id,
|
self::createOrUpdate(array(
|
||||||
'segment_id' => $segment_id,
|
'subscriber_id' => $subscriber->id,
|
||||||
'status' => Subscriber::STATUS_SUBSCRIBED
|
'segment_id' => $segment_id,
|
||||||
));
|
'status' => Subscriber::STATUS_SUBSCRIBED
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace MailPoet\Newsletter\Shortcodes\Categories;
|
|
||||||
use MailPoet\Subscription;
|
|
||||||
|
|
||||||
require_once(ABSPATH . 'wp-includes/pluggable.php');
|
|
||||||
|
|
||||||
class Link {
|
|
||||||
/*
|
|
||||||
{
|
|
||||||
text: '<%= __('Unsubscribe link') %>',
|
|
||||||
shortcode: 'global:unsubscribe',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '<%= __('Edit subscription page link') %>',
|
|
||||||
shortcode: 'global:manage',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '<%= __('View in browser link') %>',
|
|
||||||
shortcode: 'global:browser',
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
static function process(
|
|
||||||
$action,
|
|
||||||
$default_value,
|
|
||||||
$newsletter = false,
|
|
||||||
$subscriber = false
|
|
||||||
) {
|
|
||||||
|
|
||||||
$actions = array(
|
|
||||||
'unsubscribe' =>
|
|
||||||
'<a
|
|
||||||
target="_blank"
|
|
||||||
href="'.esc_attr(Subscription\Url::getUnsubscribeUrl($subscriber)).'">'.
|
|
||||||
__('Unsubscribe').
|
|
||||||
'</a>',
|
|
||||||
'manage' =>
|
|
||||||
'<a
|
|
||||||
target="_blank"
|
|
||||||
href="'.esc_attr(Subscription\Url::getManageUrl($subscriber)).'">'.
|
|
||||||
__('Manage subscription').
|
|
||||||
'</a>',
|
|
||||||
'browser' => 'TODO'
|
|
||||||
);
|
|
||||||
return (isset($actions[$action])) ? $actions[$action] : false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,6 +18,14 @@ class Newsletter {
|
|||||||
{
|
{
|
||||||
text: '<%= __('Issue number') %>',
|
text: '<%= __('Issue number') %>',
|
||||||
shortcode: 'newsletter:number',
|
shortcode: 'newsletter:number',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '<%= __('Issue number') %>',
|
||||||
|
shortcode: 'newsletter:number',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '<%= __('View in browser link') %>',
|
||||||
|
shortcode: 'newsletter:view_in_browser',
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
static function process($action, $default_value = false, $newsletter) {
|
static function process($action, $default_value = false, $newsletter) {
|
||||||
@ -27,17 +35,34 @@ class Newsletter {
|
|||||||
switch($action) {
|
switch($action) {
|
||||||
case 'subject':
|
case 'subject':
|
||||||
return ($newsletter) ? $newsletter['subject'] : false;
|
return ($newsletter) ? $newsletter['subject'] : false;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'total':
|
case 'total':
|
||||||
$posts = wp_count_posts();
|
$posts = wp_count_posts();
|
||||||
return $posts->publish;
|
return $posts->publish;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'post_title':
|
case 'post_title':
|
||||||
$post = wp_get_recent_posts(array('numberposts' => 1));
|
$post = wp_get_recent_posts(array('numberposts' => 1));
|
||||||
return (isset($post[0])) ? $post[0]['post_title'] : false;
|
return (isset($post[0])) ? $post[0]['post_title'] : false;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'number':
|
case 'number':
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
return;
|
return 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'view_in_browser':
|
||||||
|
return '<a href="#TODO">'.__('View in your browser').'</a>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'view_in_browser_url':
|
||||||
|
return '#TODO';
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
48
lib/Newsletter/Shortcodes/Categories/Subscription.php
Normal file
48
lib/Newsletter/Shortcodes/Categories/Subscription.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
namespace MailPoet\Newsletter\Shortcodes\Categories;
|
||||||
|
use MailPoet\Subscription\Url as SubscriptionUrl;
|
||||||
|
|
||||||
|
class Subscription {
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
text: '<%= __('Unsubscribe') %>',-
|
||||||
|
shortcode: 'subscription:unsubscribe',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '<%= __('Manage subscriptions') %>',
|
||||||
|
shortcode: 'subscription:manage',
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
static function process(
|
||||||
|
$action,
|
||||||
|
$default_value = false,
|
||||||
|
$newsletter = false,
|
||||||
|
$subscriber = false
|
||||||
|
) {
|
||||||
|
switch($action) {
|
||||||
|
case 'unsubscribe':
|
||||||
|
return '<a target="_blank" href="'.
|
||||||
|
esc_attr(SubscriptionUrl::getUnsubscribeUrl($subscriber))
|
||||||
|
.'">'.__('Unsubscribe').'</a>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'unsubscribe_url':
|
||||||
|
return SubscriptionUrl::getUnsubscribeUrl($subscriber);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'manage':
|
||||||
|
return '<a target="_blank" href="'.
|
||||||
|
esc_attr(SubscriptionUrl::getManageUrl($subscriber))
|
||||||
|
.'">'.__('Manage subscription').'</a>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'manage_url':
|
||||||
|
return SubscriptionUrl::getManageUrl($subscriber);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -35,20 +35,31 @@ class User {
|
|||||||
switch($action) {
|
switch($action) {
|
||||||
case 'firstname':
|
case 'firstname':
|
||||||
return ($subscriber) ? $subscriber['first_name'] : $default_value;
|
return ($subscriber) ? $subscriber['first_name'] : $default_value;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'lastname':
|
case 'lastname':
|
||||||
return ($subscriber) ? $subscriber['last_name'] : $default_value;
|
return ($subscriber) ? $subscriber['last_name'] : $default_value;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'email':
|
case 'email':
|
||||||
return ($subscriber) ? $subscriber['email'] : false;
|
return ($subscriber) ? $subscriber['email'] : false;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'displayname':
|
case 'displayname':
|
||||||
if($subscriber && $subscriber['wp_user_id']) {
|
if($subscriber && $subscriber['wp_user_id']) {
|
||||||
$wp_user = get_userdata($subscriber['wp_user_id']);
|
$wp_user = get_userdata($subscriber['wp_user_id']);
|
||||||
return $wp_user->user_login;
|
return $wp_user->user_login;
|
||||||
}
|
}
|
||||||
return $default_value;
|
return $default_value;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'count':
|
case 'count':
|
||||||
return Subscriber::filter('subscribed')->count();
|
return Subscriber::filter('subscribed')->count();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,8 @@ class Shortcodes {
|
|||||||
function __construct(
|
function __construct(
|
||||||
$rendered_newsletter,
|
$rendered_newsletter,
|
||||||
$newsletter = false,
|
$newsletter = false,
|
||||||
$subscriber = false) {
|
$subscriber = false
|
||||||
|
) {
|
||||||
$this->rendered_newsletter = $rendered_newsletter;
|
$this->rendered_newsletter = $rendered_newsletter;
|
||||||
$this->newsletter = $newsletter;
|
$this->newsletter = $newsletter;
|
||||||
$this->subscriber = $subscriber;
|
$this->subscriber = $subscriber;
|
||||||
@ -29,14 +30,6 @@ class Shortcodes {
|
|||||||
$shortcode_details
|
$shortcode_details
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: discuss renaming "global". It is a reserved name in PHP.
|
|
||||||
if(
|
|
||||||
isset($shortcode_details['type'])
|
|
||||||
&& $shortcode_details['type'] === 'global'
|
|
||||||
) {
|
|
||||||
$shortcode_details['type'] = 'link';
|
|
||||||
}
|
|
||||||
|
|
||||||
$shortcode_class =
|
$shortcode_class =
|
||||||
__NAMESPACE__ . '\\Categories\\' . ucfirst($shortcode_details['type']);
|
__NAMESPACE__ . '\\Categories\\' . ucfirst($shortcode_details['type']);
|
||||||
if(!class_exists($shortcode_class)) return false;
|
if(!class_exists($shortcode_class)) return false;
|
||||||
|
@ -43,7 +43,6 @@ class Pages {
|
|||||||
$_POST,
|
$_POST,
|
||||||
array_flip($reserved_keywords)
|
array_flip($reserved_keywords)
|
||||||
);
|
);
|
||||||
|
|
||||||
$subscriber = Subscriber::createOrUpdate($subscriber_data);
|
$subscriber = Subscriber::createOrUpdate($subscriber_data);
|
||||||
$errors = $subscriber->getErrors();
|
$errors = $subscriber->getErrors();
|
||||||
|
|
||||||
@ -214,7 +213,8 @@ class Pages {
|
|||||||
'params' => array(
|
'params' => array(
|
||||||
'label' => __('Email'),
|
'label' => __('Email'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'value' => $subscriber->email
|
'value' => $subscriber->email,
|
||||||
|
'readonly' => true
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@ -235,7 +235,7 @@ class Pages {
|
|||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'id' => 'status',
|
'id' => 'status',
|
||||||
'type' => 'radio',
|
'type' => 'select',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
'label' => __('Status'),
|
'label' => __('Status'),
|
||||||
'values' => array(
|
'values' => array(
|
||||||
|
@ -6,17 +6,17 @@ use \MailPoet\Models\Setting;
|
|||||||
|
|
||||||
class Url {
|
class Url {
|
||||||
static function getConfirmationUrl($subscriber = false) {
|
static function getConfirmationUrl($subscriber = false) {
|
||||||
$post = get_post(Setting::getValue('signup_confirmation.page'));
|
$post = get_post(Setting::getValue('subscription.confirmation_page'));
|
||||||
return self::getSubscriptionUrl($post, 'confirm', $subscriber);
|
return self::getSubscriptionUrl($post, 'confirm', $subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getManageUrl($subscriber = false) {
|
static function getManageUrl($subscriber = false) {
|
||||||
$post = get_post(Setting::getValue('subscription.page'));
|
$post = get_post(Setting::getValue('subscription.manage_page'));
|
||||||
return self::getSubscriptionUrl($post, 'manage', $subscriber);
|
return self::getSubscriptionUrl($post, 'manage', $subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getUnsubscribeUrl($subscriber = false) {
|
static function getUnsubscribeUrl($subscriber = false) {
|
||||||
$post = get_post(Setting::getValue('subscription.page'));
|
$post = get_post(Setting::getValue('subscription.unsubscribe_page'));
|
||||||
return self::getSubscriptionUrl($post, 'unsubscribe', $subscriber);
|
return self::getSubscriptionUrl($post, 'unsubscribe', $subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,10 +28,15 @@ class Url {
|
|||||||
$url = get_permalink($post);
|
$url = get_permalink($post);
|
||||||
|
|
||||||
if($subscriber !== false) {
|
if($subscriber !== false) {
|
||||||
|
|
||||||
|
if(is_object($subscriber)) {
|
||||||
|
$subscriber = $subscriber->asArray();
|
||||||
|
}
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'mailpoet_action='.$action,
|
'mailpoet_action='.$action,
|
||||||
'mailpoet_token='.Subscriber::generateToken($subscriber->email),
|
'mailpoet_token='.Subscriber::generateToken($subscriber['email']),
|
||||||
'mailpoet_email='.$subscriber->email
|
'mailpoet_email='.$subscriber['email']
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$params = array(
|
$params = array(
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"blocks": [
|
"blocks": [
|
||||||
{
|
{
|
||||||
"type": "header",
|
"type": "header",
|
||||||
"text": "Display problems? <a href=\"[viewInBrowserUrl]\">View it in your browser</a>",
|
"text": "Display problems? <a href=\"[newsletter:view_in_browser_url]\">View it in your browser</a>",
|
||||||
"styles": {
|
"styles": {
|
||||||
"block": {
|
"block": {
|
||||||
"backgroundColor": "#ffffff"
|
"backgroundColor": "#ffffff"
|
||||||
@ -1154,7 +1154,7 @@
|
|||||||
"blocks": [
|
"blocks": [
|
||||||
{
|
{
|
||||||
"type": "footer",
|
"type": "footer",
|
||||||
"text": "<p>You are receiving this email because you opted in on our website. <a href=\"[manageSubscriptionUrl]\">Update your preferences</a> or <a href=\"[unsubscribeUrl]\">Unsubscribe</a><a href=\"[manageSubscriptionUrl]\"> </a><br />123 Maple Avenue<br />93102<br />Oakland, California </p>",
|
"text": "<p>You are receiving this email because you opted in on our website. <a href=\"[subscription:manage_url]\">Update your preferences</a> or <a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a><a href=\"[subscription:manage_url]\"> </a><br />123 Maple Avenue<br />93102<br />Oakland, California </p>",
|
||||||
"styles": {
|
"styles": {
|
||||||
"block": {
|
"block": {
|
||||||
"backgroundColor": "transparent"
|
"backgroundColor": "transparent"
|
||||||
|
@ -1022,7 +1022,7 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
text: '<a href="[unsubscribeUrl]"><%= __('Unsubscribe') %></a> | <a href="[manageSubscriptionUrl]"><%= __('Manage subscription') %></a><br /><b><%= __('Add your postal address here!') %></b>',
|
text: '<a href="[subscription:unsubscribe_url]"><%= __('Unsubscribe') %></a> | <a href="[subscription:manage_url]"><%= __('Manage subscription') %></a><br /><b><%= __('Add your postal address here!') %></b>',
|
||||||
styles: {
|
styles: {
|
||||||
block: {
|
block: {
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
@ -1147,7 +1147,7 @@
|
|||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
text: '<%= __('Display problems?') %> '+
|
text: '<%= __('Display problems?') %> '+
|
||||||
'<a href="[viewInBrowserUrl]"><%= __('View it in your browser') %></a>',
|
'<a href="[newsletter:view_in_browser_url]"><%= __('View it in your browser') %></a>',
|
||||||
styles: {
|
styles: {
|
||||||
block: {
|
block: {
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
@ -1237,15 +1237,15 @@
|
|||||||
'<%= __('Links') %>': [
|
'<%= __('Links') %>': [
|
||||||
{
|
{
|
||||||
text: '<%= __('Unsubscribe link') %>',
|
text: '<%= __('Unsubscribe link') %>',
|
||||||
shortcode: 'global:unsubscribe',
|
shortcode: 'subscription:unsubscribe',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '<%= __('Edit subscription page link') %>',
|
text: '<%= __('Edit subscription page link') %>',
|
||||||
shortcode: 'global:manage',
|
shortcode: 'subscription:manage',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '<%= __('View in browser link') %>',
|
text: '<%= __('View in browser link') %>',
|
||||||
shortcode: 'global:browser',
|
shortcode: 'newsletter:view_in_browser',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
<% if customFields %>
|
<% if customFields %>
|
||||||
|
@ -270,7 +270,6 @@
|
|||||||
<option
|
<option
|
||||||
value="<%= page.id %>"
|
value="<%= page.id %>"
|
||||||
data-preview-url="<%= page.preview_url|raw %>&mailpoet_action=unsubscribe"
|
data-preview-url="<%= page.preview_url|raw %>&mailpoet_action=unsubscribe"
|
||||||
data-edit-url="<%= page.edit_url|raw %>"
|
|
||||||
<% if(page.id == settings.subscription.unsubscribe_page) %>
|
<% if(page.id == settings.subscription.unsubscribe_page) %>
|
||||||
selected="selected"
|
selected="selected"
|
||||||
<% endif %>
|
<% endif %>
|
||||||
@ -281,11 +280,7 @@
|
|||||||
class="mailpoet_page_preview"
|
class="mailpoet_page_preview"
|
||||||
href="javascript:;"
|
href="javascript:;"
|
||||||
title="<%= __('Preview page') %>"
|
title="<%= __('Preview page') %>"
|
||||||
><%= __('Preview') %></a> | <a
|
><%= __('Preview') %></a>
|
||||||
class="mailpoet_page_edit"
|
|
||||||
href="javascript:;"
|
|
||||||
title="<%= __('Edit page') %>"
|
|
||||||
><%= __('Edit') %></a>
|
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -151,14 +151,13 @@
|
|||||||
<p>
|
<p>
|
||||||
<select
|
<select
|
||||||
class="mailpoet_page_selection"
|
class="mailpoet_page_selection"
|
||||||
name="signup_confirmation[page]"
|
name="subscription[confirmation_page]"
|
||||||
>
|
>
|
||||||
<% for page in pages %>
|
<% for page in pages %>
|
||||||
<option
|
<option
|
||||||
value="<%= page.id %>"
|
value="<%= page.id %>"
|
||||||
data-preview-url="<%= page.preview_url|raw %>&mailpoet_action=confirm"
|
data-preview-url="<%= page.preview_url|raw %>&mailpoet_action=confirm"
|
||||||
data-edit-url="<%= page.edit_url|raw %>"
|
<% if(page.id == settings.subscription.confirmation_page) %>
|
||||||
<% if(page.id == settings.signup_confirmation.page) %>
|
|
||||||
selected="selected"
|
selected="selected"
|
||||||
<% endif %>
|
<% endif %>
|
||||||
><%= page.title %></option>
|
><%= page.title %></option>
|
||||||
@ -168,11 +167,7 @@
|
|||||||
class="mailpoet_page_preview"
|
class="mailpoet_page_preview"
|
||||||
href="javascript:;"
|
href="javascript:;"
|
||||||
title="<%= __('Preview page') %>"
|
title="<%= __('Preview page') %>"
|
||||||
><%= __('Preview') %></a> | <a
|
><%= __('Preview') %></a>
|
||||||
class="mailpoet_page_edit"
|
|
||||||
href="javascript:;"
|
|
||||||
title="<%= __('Edit page') %>"
|
|
||||||
><%= __('Edit') %></a>
|
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Reference in New Issue
Block a user