Merge pull request #1347 from mailpoet/queue_rendered_subject_improvement
Uses queue's rendered subject when sending newsletter [MAILPOET-1373]
This commit is contained in:
@ -6,9 +6,7 @@ use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class Date {
|
||||
static function process(
|
||||
$action,
|
||||
$action_argument = false,
|
||||
$action_argument_value = false
|
||||
$shortcode_details
|
||||
) {
|
||||
$action_mapping = array(
|
||||
'd' => 'd',
|
||||
@ -18,11 +16,11 @@ class Date {
|
||||
'mtext' => 'F',
|
||||
'y' => 'Y'
|
||||
);
|
||||
if(!empty($action_mapping[$action])) {
|
||||
return date_i18n($action_mapping[$action], WPFunctions::currentTime('timestamp'));
|
||||
if(!empty($action_mapping[$shortcode_details['action']])) {
|
||||
return date_i18n($action_mapping[$shortcode_details['action']], WPFunctions::currentTime('timestamp'));
|
||||
}
|
||||
return ($action === 'custom' && $action_argument === 'format') ?
|
||||
date_i18n($action_argument_value, WPFunctions::currentTime('timestamp')) :
|
||||
return ($shortcode_details['action'] === 'custom' && $shortcode_details['action_argument'] === 'format') ?
|
||||
date_i18n($shortcode_details['action_argument_value'], WPFunctions::currentTime('timestamp')) :
|
||||
false;
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Newsletter\Shortcodes\Categories;
|
||||
|
||||
use MailPoet\Models\Setting;
|
||||
@ -10,19 +11,17 @@ class Link {
|
||||
const CATEGORY_NAME = 'link';
|
||||
|
||||
static function process(
|
||||
$action,
|
||||
$action_argument,
|
||||
$action_argument_value,
|
||||
$shortcode_details,
|
||||
$newsletter,
|
||||
$subscriber,
|
||||
$queue,
|
||||
$content,
|
||||
$wp_user_preview
|
||||
) {
|
||||
switch($action) {
|
||||
switch($shortcode_details['action']) {
|
||||
case 'subscription_unsubscribe_url':
|
||||
return self::processUrl(
|
||||
$action,
|
||||
$shortcode_details['action'],
|
||||
SubscriptionUrl::getUnsubscribeUrl($wp_user_preview ? false : $subscriber),
|
||||
$queue,
|
||||
$wp_user_preview
|
||||
@ -30,7 +29,7 @@ class Link {
|
||||
|
||||
case 'subscription_manage_url':
|
||||
return self::processUrl(
|
||||
$action,
|
||||
$shortcode_details['action'],
|
||||
SubscriptionUrl::getManageUrl($wp_user_preview ? false : $subscriber),
|
||||
$queue,
|
||||
$wp_user_preview
|
||||
@ -44,10 +43,10 @@ class Link {
|
||||
$queue,
|
||||
$wp_user_preview
|
||||
);
|
||||
return self::processUrl($action, $url, $queue, $wp_user_preview);
|
||||
return self::processUrl($shortcode_details['action'], $url, $queue, $wp_user_preview);
|
||||
|
||||
default:
|
||||
$shortcode = self::getFullShortcode($action);
|
||||
$shortcode = self::getFullShortcode($shortcode_details['action']);
|
||||
$url = apply_filters(
|
||||
'mailpoet_newsletter_shortcode_link',
|
||||
$shortcode,
|
||||
@ -57,14 +56,13 @@ class Link {
|
||||
$wp_user_preview
|
||||
);
|
||||
return ($url !== $shortcode) ?
|
||||
self::processUrl($action, $url, $queue, $wp_user_preview) :
|
||||
self::processUrl($shortcode_details['action'], $url, $queue, $wp_user_preview) :
|
||||
false;
|
||||
}
|
||||
}
|
||||
|
||||
static function processUrl($action, $url, $queue, $wp_user_preview = false) {
|
||||
if ($wp_user_preview)
|
||||
return $url;
|
||||
if($wp_user_preview) return $url;
|
||||
return ($queue !== false && (boolean)Setting::getValue('tracking.enabled')) ?
|
||||
self::getFullShortcode($action) :
|
||||
$url;
|
||||
|
@ -9,15 +9,14 @@ if(!defined('ABSPATH')) exit;
|
||||
require_once(ABSPATH . "wp-includes/pluggable.php");
|
||||
|
||||
class Newsletter {
|
||||
static function process($action,
|
||||
$action_argument,
|
||||
$action_argument_value,
|
||||
static function process(
|
||||
$shortcode_details,
|
||||
$newsletter,
|
||||
$subscriber,
|
||||
$queue,
|
||||
$content
|
||||
) {
|
||||
switch($action) {
|
||||
switch($shortcode_details['action']) {
|
||||
case 'subject':
|
||||
return ($newsletter) ? $newsletter->subject : false;
|
||||
|
||||
|
@ -9,17 +9,15 @@ require_once(ABSPATH . 'wp-includes/pluggable.php');
|
||||
|
||||
class Subscriber {
|
||||
static function process(
|
||||
$action,
|
||||
$action_argument,
|
||||
$action_argument_value,
|
||||
$shortcode_details,
|
||||
$newsletter,
|
||||
$subscriber
|
||||
) {
|
||||
if($subscriber !== false && !is_object($subscriber)) return false;
|
||||
$default_value = ($action_argument === 'default') ?
|
||||
$action_argument_value :
|
||||
if($subscriber !== false && !is_object($subscriber)) return $shortcode_details['shortcode'];
|
||||
$default_value = ($shortcode_details['action_argument'] === 'default') ?
|
||||
$shortcode_details['action_argument_value'] :
|
||||
'';
|
||||
switch($action) {
|
||||
switch($shortcode_details['action']) {
|
||||
case 'firstname':
|
||||
return (!empty($subscriber->first_name)) ? $subscriber->first_name : $default_value;
|
||||
case 'lastname':
|
||||
@ -36,7 +34,7 @@ class Subscriber {
|
||||
return SubscriberModel::filter('subscribed')
|
||||
->count();
|
||||
default:
|
||||
if(preg_match('/cf_(\d+)/', $action, $custom_field) &&
|
||||
if(preg_match('/cf_(\d+)/', $shortcode_details['action'], $custom_field) &&
|
||||
!empty($subscriber->id)
|
||||
) {
|
||||
$custom_field = SubscriberCustomField
|
||||
|
Reference in New Issue
Block a user