Falcon_Handler::supports_message_ids PHP Метод

supports_message_ids() публичный статический Метод

Falcon can operate in one of two modes: 1. Leader Mode - Falcon will set the message ID for each message, and assume full control over them for threading purposes. 2. Follower Mode - Falcon will observe message IDs set by the handler, and use them internally. Where possible, use leader mode, as this has cleaner handling. However, not all handlers support custom message IDs, so follower mode must exist for these.
public static supports_message_ids ( ) : boolean
Результат boolean True to operate in leader mode, false to operate in follower mode.
    public static function supports_message_ids();

Usage Example

Пример #1
0
 /**
  * Send a notification to subscribers
  */
 public function notify_on_reply($id = 0, $comment = null)
 {
     if (empty($this->handler) || !Falcon::is_enabled_for_site()) {
         return false;
     }
     if (wp_get_comment_status($comment) !== 'approved') {
         return false;
     }
     // Is the post published?
     $post = get_post($comment->comment_post_ID);
     if (get_post_status($post) !== 'publish') {
         return false;
     }
     // Grab the users we should notify
     $users = $this->get_comment_subscribers($comment);
     if (empty($users)) {
         return false;
     }
     $message = new Falcon_Message();
     // Poster name
     $message->set_author(apply_filters('falcon.connector.wordpress.comment_author', $comment->comment_author));
     // Don't send notifications to the person who made the post
     $send_to_author = Falcon::get_option('bbsub_send_to_author', false);
     if (!$send_to_author && !empty($comment->user_id)) {
         $author = (int) $comment->user_id;
         $users = array_filter($users, function ($user) use($author) {
             return $user->ID !== $author;
         });
     }
     // Sanitize the HTML into text
     $message->set_text($this->get_comment_content_as_text($comment));
     $message->set_html($this->get_comment_content_as_html($comment));
     $subject = apply_filters('bbsub_email_subject', 'Re: [' . get_option('blogname') . '] ' . html_entity_decode(get_the_title($post), ENT_QUOTES), $id, $post->ID);
     $message->set_subject($subject);
     $message->set_reply_address_handler(function (WP_User $user, Falcon_Message $message) use($comment) {
         return Falcon::get_reply_address('comment_' . $comment->comment_ID, $user);
     });
     $options = array();
     if ($this->handler->supports_message_ids()) {
         $options['references'] = $this->get_references_for_comment($comment);
         $options['message-id'] = $this->get_message_id_for_comment($comment);
         if (!empty($comment->comment_parent)) {
             $parent = get_comment($comment->comment_parent);
             $options['in-reply-to'] = $this->get_message_id_for_comment($parent);
         } else {
             $options['in-reply-to'] = $this->get_message_id_for_post($post);
         }
     } else {
         $message_ids = get_post_meta($id, self::MESSAGE_ID_KEY, $responses);
         $options['in-reply-to'] = $message_ids;
     }
     $message->set_options($options);
     $this->handler->send_mail($users, $message);
     return true;
 }