protected function save($post_id) { if (!isset($_POST[self::$custom_text_name]) or $post_id != $this->prompt_post->id()) { return; } if (!current_user_can('edit_post', $post_id)) { return; } $this->prompt_post->set_custom_text($_POST[self::$custom_text_name]); }
protected function send_notifications($recipient_ids) { $template_data = array('post' => $this->prompt_post, 'comment_header' => true); /** * Filter comment email template data. * * @param array $template_data { * @type Prompt_post $post * @type bool $comment_header * } */ $template_data = apply_filters('prompt/comment_flood_email/template_data', $template_data); $html_template = new Prompt_Template('comment-flood-email.php'); $text_template = new Prompt_Text_Template('comment-flood-email-text.php'); $footnote_html = sprintf(__('You received this email because you\'re subscribed to %s.', 'Postmatic'), $this->prompt_post->subscription_object_label()); $batch = new Prompt_Email_Batch(array('subject' => __('We\'re pausing comment notices for you.', 'Postmatic'), 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::SUBSCRIPTION, 'reply_to' => '{{{reply_to}}}', 'footnote_html' => $footnote_html, 'footnote_text' => Prompt_Content_Handling::reduce_html_to_utf8($footnote_html))); foreach ($recipient_ids as $recipient_id) { $subscriber = get_userdata($recipient_id); if (!$subscriber or !$subscriber->user_email) { continue; } $command = new Prompt_Comment_Flood_Command(); $command->set_post_id($this->prompt_post->id()); $command->set_user_id($recipient_id); $batch->add_individual_message_values(array('to_address' => $subscriber->user_email, 'reply_to' => Prompt_Email_Batch::trackable_address(Prompt_Command_Handling::get_command_metadata($command)))); } /** * Filter comment notification email batch. * * @param Prompt_Email_Batch $batch * @param array $template_data see prompt/comment_email/template_data */ $batch = apply_filters('prompt/comment_flood_email_batch', $batch, $template_data); Prompt_Factory::make_mailer($batch)->send(); }
/** * Add recipient-specific values for an email. * * @since 2.0.0 * * @param WP_User $recipient * @return $this */ protected function add_recipient(WP_User $recipient) { $unsubscribe_link = new Prompt_Unsubscribe_Link($recipient); $command = new Prompt_Comment_Command(); $command->set_post_id($this->prompt_post->id()); $command->set_user_id($recipient->ID); $command->set_parent_comment_id($this->comment->comment_ID); $values = array('id' => $recipient->ID, 'to_name' => $recipient->display_name, 'to_address' => $recipient->user_email, 'subject' => $this->subscriber_subject($recipient), 'unsubscribe_url' => $unsubscribe_link->url(), 'subscriber_comment_intro_html' => $this->subscriber_comment_intro_html($recipient), 'subscriber_comment_intro_text' => $this->subscriber_comment_intro_text($recipient), 'reply_to' => $this->trackable_address(Prompt_Command_Handling::get_command_metadata($command))); $values = array_merge($values, Prompt_Command_Handling::get_comment_reply_macros($this->previous_comments, $recipient->ID)); return $this->add_individual_message_values($values); }
/** * Get Postmatic's text version of the current post content. * @return mixed|string */ public function get_the_text_content() { $this->ensure_setup(); $prompt_post = new Prompt_Post($this->post); $text = $prompt_post->get_custom_text(); if ($text) { return $text; } if (Prompt_Admin_Delivery_Metabox::excerpt_only($prompt_post->id())) { return Prompt_Html_To_Markdown::convert(get_the_excerpt()); } $html = apply_filters('the_content', get_the_content()); $html = str_replace(']]>', ']]>', $html); return Prompt_Html_To_Markdown::convert($html); }