Merge pull request #949 from mailpoet/shortcodes-subject-archive

Print rendered subject in archive [MAILPOET-826]
This commit is contained in:
mrcasual
2017-06-22 07:41:11 -04:00
committed by GitHub
5 changed files with 5 additions and 8 deletions

View File

@@ -1,7 +1,6 @@
import React from 'react' import React from 'react'
import { Router, Link } from 'react-router' import { Link } from 'react-router'
import classNames from 'classnames' import classNames from 'classnames'
import jQuery from 'jquery'
import MailPoet from 'mailpoet' import MailPoet from 'mailpoet'
import Hooks from 'wp-js-hooks' import Hooks from 'wp-js-hooks'
@@ -175,7 +174,7 @@ const NewsletterListStandard = React.createClass({
<a <a
className="row-title" className="row-title"
href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` } href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }
>{ newsletter.subject }</a> >{ newsletter.queue.newsletter_rendered_subject || newsletter.subject }</a>
</strong> </strong>
{ actions } { actions }
</td> </td>

View File

@@ -89,7 +89,6 @@ class Shortcodes {
if(!empty($title)) { if(!empty($title)) {
$html .= '<h3 class="mailpoet_archive_title">'.$title.'</h3>'; $html .= '<h3 class="mailpoet_archive_title">'.$title.'</h3>';
} }
$html .= '<ul class="mailpoet_archive">'; $html .= '<ul class="mailpoet_archive">';
foreach($newsletters as $newsletter) { foreach($newsletters as $newsletter) {
$queue = $newsletter->queue()->findOne(); $queue = $newsletter->queue()->findOne();
@@ -123,7 +122,7 @@ class Shortcodes {
); );
return '<a href="'.esc_attr($preview_url).'" target="_blank" title="' return '<a href="'.esc_attr($preview_url).'" target="_blank" title="'
.esc_attr(__('Preview in a new tab', 'mailpoet')).'">' .esc_attr(__('Preview in a new tab', 'mailpoet')).'">'
.esc_attr($newsletter->subject). .esc_attr($newsletter->newsletter_rendered_subject).
'</a>'; '</a>';
} }
} }

View File

@@ -103,9 +103,6 @@ class SendingQueue {
$subscriber, $subscriber,
$queue $queue
); );
if(!$queue->newsletter_rendered_subject) {
$queue->newsletter_rendered_subject = $prepared_newsletters[0]['subject'];
}
// format subscriber name/address according to mailer settings // format subscriber name/address according to mailer settings
$prepared_subscribers[] = $this->mailer_task->prepareSubscriberForSending( $prepared_subscribers[] = $this->mailer_task->prepareSubscriberForSending(
$subscriber $subscriber

View File

@@ -85,6 +85,7 @@ class Newsletter {
// extract and save newsletter posts // extract and save newsletter posts
PostsTask::extractAndSave($rendered_newsletter, $newsletter); PostsTask::extractAndSave($rendered_newsletter, $newsletter);
// update queue with the rendered and pre-processed newsletter // update queue with the rendered and pre-processed newsletter
$queue->newsletter_rendered_subject = Shortcodes::process($newsletter->subject, $newsletter, null, $queue);
$queue->newsletter_rendered_body = $rendered_newsletter; $queue->newsletter_rendered_body = $rendered_newsletter;
$queue->save(); $queue->save();
return $newsletter; return $newsletter;

View File

@@ -860,6 +860,7 @@ class Newsletter extends Model {
static function getArchives($segment_ids = array()) { static function getArchives($segment_ids = array()) {
$orm = self::table_alias('newsletters') $orm = self::table_alias('newsletters')
->distinct()->select('newsletters.*') ->distinct()->select('newsletters.*')
->select('newsletter_rendered_subject')
->whereIn('newsletters.type', array( ->whereIn('newsletters.type', array(
self::TYPE_STANDARD, self::TYPE_STANDARD,
self::TYPE_NOTIFICATION_HISTORY self::TYPE_NOTIFICATION_HISTORY