Falcon_Connector_bbPress::notify_on_reply PHP Метод

notify_on_reply() публичный Метод

Send a notification to subscribers
public notify_on_reply ( $reply_id, $topic_id, $forum_id, $anonymous_data = false, $reply_author )
    public function notify_on_reply($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0)
    {
        if ($this->handler === null) {
            return false;
        }
        global $wpdb;
        if (!bbp_is_subscriptions_active()) {
            return false;
        }
        $reply_id = bbp_get_reply_id($reply_id);
        $topic_id = bbp_get_topic_id($topic_id);
        $forum_id = bbp_get_forum_id($forum_id);
        if (!bbp_is_reply_published($reply_id)) {
            return false;
        }
        if (!bbp_is_topic_published($topic_id)) {
            return false;
        }
        $user_ids = bbp_get_topic_subscribers($topic_id, true);
        if (empty($user_ids)) {
            return false;
        }
        // Poster name
        $reply_author_name = apply_filters('bbsub_reply_author_name', bbp_get_reply_author_display_name($reply_id));
        do_action('bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids);
        // 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($reply_author)) {
            $user_ids = array_filter($user_ids, function ($id) use($reply_author) {
                return (int) $id !== (int) $reply_author;
            });
        }
        // Get userdata for all users
        $user_ids = array_map(function ($id) {
            return get_userdata($id);
        }, $user_ids);
        // Sanitize the HTML into text
        $content = apply_filters('bbsub_html_to_text', bbp_get_reply_content($reply_id));
        // Build email
        $text = "%1\$s\n\n";
        $text .= "---\nReply to this email directly or view it online:\n%2\$s\n\n";
        $text .= "You are receiving this email because you subscribed to it. Login and visit the topic to unsubscribe from these emails.";
        $text = sprintf($text, $content, bbp_get_reply_url($reply_id));
        $text = apply_filters('bbsub_email_message', $text, $reply_id, $topic_id, $content);
        $subject = apply_filters('bbsub_email_subject', 'Re: [' . get_option('blogname') . '] ' . bbp_get_topic_title($topic_id), $reply_id, $topic_id);
        $options = array('id' => $topic_id, 'author' => $reply_author_name);
        $this->handler->send_mail($user_ids, $subject, $text, $options);
        do_action('bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids);
        return true;
    }