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