コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
 /**
  * Builds an email without specific recipient info that can be used as a template for all recipients.
  *
  * The set_recipient method can be called to fill in recipient-specific fields.
  *
  * @since 2.0.0
  *
  * @param Prompt_Post_Rendering_Context $context      Rendering context for the target post
  * @param array                         $args         {
  * @type bool                           $excerpt_only Override the excerpt only checkbox in the delivery metabox.
  *                                                    }
  */
 public function __construct(Prompt_Post_Rendering_Context $context, $args = array())
 {
     $this->context = $context;
     $context->setup();
     $prompt_author = $context->get_author();
     $prompt_post = $context->get_post();
     $is_api_delivery = Prompt_Enum_Email_Transports::API == Prompt_Core::$options->get('email_transport');
     $will_strip_content = (!$is_api_delivery and $context->has_fancy_content());
     $subject = html_entity_decode($prompt_post->get_wp_post()->post_title, ENT_QUOTES);
     list($footnote_html, $footnote_text) = $this->footnote_content();
     if ('draft' == $prompt_post->get_wp_post()->post_status) {
         /* translators: %s is a post title */
         $subject = sprintf(__('PREVIEW of %s', 'Postmatic'), $subject);
         $footnote_html = $footnote_text = '';
     }
     $excerpt_only = Prompt_Admin_Delivery_Metabox::excerpt_only($prompt_post->id());
     if (isset($args['excerpt_only'])) {
         $excerpt_only = $args['excerpt_only'];
     }
     $this->comments = get_approved_comments($prompt_post->id());
     $template_data = array('prompt_author' => $prompt_author, 'prompt_post' => $prompt_post, 'featured_image_src' => $context->get_the_featured_image_src(), 'excerpt_only' => $excerpt_only, 'the_text_content' => $context->get_the_text_content(), 'subject' => $subject, 'alternate_versions_menu' => $context->alternate_versions_menu(), 'is_api_delivery' => $is_api_delivery, 'will_strip_content' => $will_strip_content, 'comments' => $this->comments);
     /**
      * Filter new post email template data.
      *
      * @param array      $template_data      {
      * @type Prompt_User $prompt_author
      * @type Prompt_Post $prompt_post
      * @type array       $featured_image_src url, width, height
      * @type bool        $excerpt_only       whether to include only the post excerpt
      * @type string      $the_text_content
      * @type string      $subject
      * @type bool        $is_api_delivery
      * @type bool        $will_strip_content
      *                                       }
      */
     $template_data = apply_filters('prompt/post_email/template_data', $template_data);
     $html_template = new Prompt_Template("new-post-email.php");
     $text_template = new Prompt_Text_Template("new-post-email-text.php");
     $batch_message_template = array('subject' => $subject, 'from_name' => '{{{from_name}}}', 'text_content' => $text_template->render($template_data), 'html_content' => $html_template->render($template_data), 'message_type' => Prompt_Enum_Message_Types::POST, 'reply_to' => '{{{reply_to}}}', 'footnote_html' => $footnote_html, 'footnote_text' => $footnote_text);
     $this->replyable = (comments_open($prompt_post->id()) and !$excerpt_only);
     if (!$this->replyable) {
         $batch_message_template['from_address'] = $prompt_author->get_wp_user()->user_email;
     }
     $default_values = array('from_name' => $this->to_utf8(get_option('blogname')));
     $context->reset();
     parent::__construct($batch_message_template, array(), $default_values);
 }