コード例 #1
0
 /**
  * Get the array with the featured image url, width, and height (or false).
  */
 public function get_the_featured_image_src()
 {
     $this->ensure_setup();
     if (!is_null($this->featured_image_src)) {
         return $this->featured_image_src;
     }
     $this->featured_image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'prompt-post-featured');
     if (Prompt_Admin_Delivery_Metabox::suppress_featured_image($this->post->ID)) {
         $this->featured_image_src = false;
     }
     return $this->featured_image_src;
 }
コード例 #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);
 }
コード例 #3
0
 /**
  * Any time a post is published schedule notifications.
  *
  * @param string $new_status
  * @param string $old_status
  * @param WP_Post $post
  */
 public static function action_transition_post_status($new_status, $old_status, $post)
 {
     if (!Prompt_Core::$options->get('enable_post_delivery')) {
         return;
     }
     if ('publish' == $old_status or 'publish' != $new_status) {
         return;
     }
     // There is no way to suppress mailing when restoring a trashed post, so we always do it
     if ('trash' == $old_status) {
         return;
     }
     if (defined('WP_IMPORTING') and WP_IMPORTING) {
         return;
     }
     if (self::ignore_published_post($post->ID)) {
         return;
     }
     $prompt_post = new Prompt_Post($post);
     if (!$prompt_post->unsent_recipient_ids() or Prompt_Admin_Delivery_Metabox::suppress_email($post->ID)) {
         return;
     }
     Prompt_Post_Mailing::send_notifications($post);
 }
コード例 #4
0
ファイル: ajax-handling.php プロジェクト: postmatic/beta-dist
 /**
  * @param $post_id
  * @return array|bool
  */
 protected static function featured_image_src($post_id)
 {
     if (Prompt_Admin_Delivery_Metabox::suppress_featured_image($post_id)) {
         return false;
     }
     $featured_image = image_get_intermediate_size(get_post_thumbnail_id($post_id), 'prompt-post-featured');
     if (!$featured_image) {
         $featured_image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full');
     }
     if (!$featured_image) {
         return false;
     }
     return array($featured_image['url'], $featured_image['width'], $featured_image['height']);
 }