/**
  * Builds an email batch with content and recipients based on a comment.
  *
  * @since 2.0.0
  *
  * @param object $comment Target comment
  * @param Prompt_Comment_Flood_Controller
  */
 public function __construct($comment, Prompt_Comment_Flood_Controller $flood_controller = null)
 {
     $this->comment = $comment;
     $this->prompt_post = $prompt_post = new Prompt_Post($this->comment->comment_post_ID);
     $this->flood_controller = $flood_controller ? $flood_controller : new Prompt_Comment_Flood_Controller($comment);
     $this->subscribed_post_title_link = html('a', array('href' => get_permalink($this->prompt_post->id())), get_the_title($this->prompt_post->id()));
     $comment_author = $this->comment_author_user();
     $is_api_delivery = Prompt_Enum_Email_Transports::API == Prompt_Core::$options->get('email_transport');
     $parent_comment = $parent_author = null;
     $parent_author_name = '';
     $template_file = 'new-comment-email.php';
     if ($this->comment->comment_parent) {
         $parent_comment = get_comment($this->comment->comment_parent);
         $parent_author = get_userdata($parent_comment->user_id);
         $parent_author_name = $parent_author ? $parent_author->display_name : $parent_comment->comment_author;
         $parent_author_name = $parent_author_name ? $parent_author_name : __('Anonymous', 'Postmatic');
         $template_file = $is_api_delivery ? 'comment-reply-email.php' : $template_file;
     }
     $this->parent_comment = $parent_comment;
     $this->parent_author = $parent_author;
     $this->parent_author_name = $parent_author_name;
     $commenter_name = $comment_author ? $comment_author->display_name : $this->comment->comment_author;
     $commenter_name = $commenter_name ? $commenter_name : __('Anonymous', 'Postmatic');
     $this->commenter_name = $commenter_name;
     $post_author = get_userdata($prompt_post->get_wp_post()->post_author);
     $post_author_name = $post_author ? $post_author->display_name : __('Anonymous', 'Postmatic');
     $this->set_previous_comments();
     $template_data = array('comment_author' => $comment_author, 'comment' => $this->comment, 'commenter_name' => $commenter_name, 'subscribed_post' => $prompt_post, 'subscribed_post_author_name' => $post_author_name, 'subscribed_post_title_link' => $this->subscribed_post_title_link, 'previous_comments' => $this->previous_comments, 'parent_author' => $parent_author, 'parent_author_name' => $parent_author_name, 'parent_comment' => $parent_comment, 'comment_header' => true, 'is_api_delivery' => $is_api_delivery);
     /**
      * Filter comment email template data.
      *
      * @param array $template_data {
      * @type WP_User $comment_author
      * @type WP_User $subscriber
      * @type object $comment
      * @type Prompt_post $subscribed_post
      * @type string $subscribed_post_author_name
      * @type array $previous_comments
      * @type WP_User $parent_author
      * @type string $parent_author_name
      * @type object $parent_comment
      * @type bool $comment_header
      * @type bool $is_api_delivery
      * }
      */
     $template_data = apply_filters('prompt/comment_email/template_data', $template_data);
     $html_template = new Prompt_Template($template_file);
     $text_template = new Prompt_Text_Template(str_replace('.php', '-text.php', $template_file));
     /* translators: %1$s is a subscription list title, %2$s the unsubscribe command */
     $footnote_format = __('You received this email because you\'re subscribed to %1$s. To no longer receive other comments or replies in this discussion reply with the word \'%2$s\'.', 'Postmatic');
     $message_template = array('from_name' => $commenter_name, 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::COMMENT, 'subject' => '{{{subject}}}', 'reply_to' => '{{{reply_to}}}', 'footnote_html' => sprintf($footnote_format, $this->prompt_post->subscription_object_label(), "<a href=\"{$this->unsubscribe_mailto()}\">" . Prompt_Unsubscribe_Matcher::target() . "</a>"), 'footnote_text' => sprintf($footnote_format, $this->prompt_post->subscription_object_label(Prompt_Enum_Content_Types::TEXT), Prompt_Unsubscribe_Matcher::target()));
     parent::__construct($message_template);
     $recipient_ids = array_diff($this->flood_controlled_recipient_ids(), $this->sent_recipient_ids());
     /**
      * Filter whether to send new comment notifications.
      *
      * @param boolean $send Default true.
      * @param object $comment
      * @param array $recipient_ids
      */
     if (!apply_filters('prompt/send_comment_notifications', true, $this->comment, $recipient_ids)) {
         return null;
     }
     $this->add_recipients($recipient_ids);
 }
 /**
  * Get text command from the message, if any.
  *
  * A blank message is treated as a subscribe command.
  *
  * @return string Text command if found, otherwise empty.
  */
 protected function get_text_command()
 {
     $stripped_text = $this->get_message_text();
     if (preg_match('/^\\s*$/', $stripped_text, $matches)) {
         return self::$ignore_method;
     }
     $unsubscribe_matcher = new Prompt_Unsubscribe_Matcher($stripped_text);
     if ($unsubscribe_matcher->matches()) {
         return self::$unsubscribe_method;
     }
     return '';
 }
Beispiel #3
0
 /**
  *
  * @since 2.0.0
  *
  * @return string
  */
 protected function unsubscribe_mailto()
 {
     return sprintf('mailto:{{{reply_to}}}?body=%s&subject=%s', rawurlencode(Prompt_Unsubscribe_Matcher::target()), rawurlencode(__('Unsubscribe request', 'Postmatic')));
 }
		<div id="comments">
			<?php 
        wp_list_comments(array('callback' => array('Prompt_Email_Comment_Rendering', 'render_text'), 'end-callback' => '__return_empty_string', 'style' => 'div'), $previous_comments);
        ?>
		</div>
	<?php 
    }
    ?>

<?php 
}
?>

<p>
	<?php 
printf(__('* Reply to this email to reply to %s. *', 'Postmatic'), $commenter_name);
?>
</p>

<p>
	<?php 
printf(__('Please note: Your reply will be published publicly and immediately on %s.', 'Postmatic'), get_the_title($comment->comment_post_ID));
?>
</p>

<p>
	<?php 
printf(__("To no longer receive other comments or replies in this discussion reply with the word '%s'.", 'Postmatic'), Prompt_Unsubscribe_Matcher::target());
?>
</p>
 /**
  * @since 2.0.0
  *
  * @return array Two strings, HTML then text
  */
 protected function footnote_content()
 {
     $html_parts = array();
     $text_parts = array();
     /* translators: %s is a subscription list title */
     $why = sprintf(__('You received this email because you\'re subscribed to %s.', 'Postmatic'), '{{{subscribed_object_label}}}');
     $html_parts[] = $why;
     $text_parts[] = $why;
     /**
      * Filter extra footnote content for post emails.
      *
      * @param array $content Two element array containing first HTML then text content.
      */
     list($html_parts[], $text_parts[]) = apply_filters('prompt/post_email_batch/extra_footnote_content', array('', ''));
     /* translators: %s is the unsubscribe command word */
     $unsub_format = __('To unsubscribe reply with the word \'%s\'.', 'Postmatic');
     $html_parts[] = sprintf($unsub_format, "<a href=\"{$this->unsubscribe_mailto()}\">" . Prompt_Unsubscribe_Matcher::target() . '</a>');
     $text_parts[] = sprintf($unsub_format, Prompt_Unsubscribe_Matcher::target());
     $html_parts = array(html('p', implode(' ', $html_parts)));
     $text_parts[] = "\n\n";
     if ($this->replyable) {
         $sub_mailto = sprintf('mailto:{{{reply_to}}}?subject=%s&body=%s', rawurlencode(__('Subscribe to comments', 'Postmatic')), rawurlencode(Prompt_Subscribe_Matcher::target()));
         /* translators: %s is the subscribed command word */
         $sub_format = __('To keep up to date with the conversation you can subscribe to comments. Just reply to this email with the word \'%s\'.', 'Postmatic');
         $html_parts[] = html('p', sprintf($sub_format, "<a href=\"{$sub_mailto}\">" . Prompt_Subscribe_Matcher::target() . '</a>'));
         $text_parts[] = sprintf($sub_format, Prompt_Subscribe_Matcher::target());
     }
     return array(implode(' ', $html_parts), implode(' ', $text_parts));
 }