/** * 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(); }