/** * @param WP_Post $post */ public function display($post) { if (!$this->prompt_post) { $this->prompt_post = new Prompt_Post($post); } if ($post->ID != $this->prompt_post->id()) { return; } $sent = (bool) $this->prompt_post->sent_recipient_ids(); if ($sent) { echo html('h3', __('This was the text version sent to subscribers.', 'Postmatic')); } $text = $this->prompt_post->get_custom_text(); if (!$sent and $text and 'publish' != $post->post_status) { echo self::render_form($text); return; } if ('publish' != $post->post_status) { echo html('input type="button" class="button prompt-customize-text"', array('value' => __('Customize', 'Postmatic'))); } if (empty($text) and 'auto-draft' != $post->post_status) { $context = new Prompt_Post_Rendering_Context($post); $text = $context->get_the_text_content(); $context->reset(); } echo html('pre class="prompt-custom-text"', $text); echo html('div class="prompt-custom-text-upgrade"', sprintf(__('This post will be sent as a multipart message. We have automatically generated a plaintext version for older email clients. You can adjust it if you need to.', 'Postmatic'), Prompt_Enum_Urls::PREMIUM)); }
public static function filter_response($response) { if (!isset($response['wp_autosave'])) { return $response; } $context = new Prompt_Post_Rendering_Context(intval($_POST['data']['wp_autosave']['post_id'])); $response['prompt_text_version'] = $context->get_the_text_content(); $context->reset(); return $response; }
/** * If replyable returns all comment reply command macros, otherwise a command macro to forward replies to * the post author. * * @since 2.0.0 * * @param int $recipient_id * @param Prompt_Interface_Subscribable $subscribed_list * @return array */ protected function mail_command_values($recipient_id, Prompt_Interface_Subscribable $subscribed_list) { $values = array(); if ($this->replyable) { $command = new Prompt_New_Post_Comment_Command(); $command->set_post_id($this->context->get_post()->id()); $command->set_user_id($recipient_id); $values = Prompt_Command_Handling::get_comment_reply_macros($this->comments, $recipient_id); } else { $command = new Prompt_Forward_Command(); $command->set_from_user_id($recipient_id); $command->set_to_user_id($this->context->get_post()->get_wp_post()->post_author); $command->set_subscription_object($subscribed_list); } $values['reply_to'] = $this->trackable_address(Prompt_Command_Handling::get_command_metadata($command)); return $values; }
/** * Handle post editor preview email requests. */ public static function action_wp_ajax_prompt_post_delivery_preview() { $post_id = absint($_GET['post_id']); if (!$post_id) { wp_die(0); } $post = get_post($post_id); $context = new Prompt_Post_Rendering_Context($post); $context->setup(); $batch = new Prompt_Post_Email_Batch($context); $batch->add_recipient(new Prompt_User(wp_get_current_user())); $context->reset(); Prompt_Factory::make_post_adhoc_mailer($batch)->send(); wp_send_json(array('message' => __('Preview email sent.', 'Postmatic'))); }
/** * @since 2.0.0 */ protected function send_post() { $post = get_post($this->post_id); $context = new Prompt_Post_Rendering_Context($post); $context->setup(); $batch = new Prompt_Post_Email_Batch($context, array('excerpt_only' => false)); $batch->add_recipient(new Prompt_User($this->user_id)); $context->reset(); Prompt_Factory::make_post_adhoc_mailer($batch)->send(); }