function mb_notify_topic_subscribers($topic_id, $post)
{
    $reply_id = mb_get_reply_id($post->ID);
    $topic_id = mb_get_topic_id($topic_id);
    $forum_id = mb_get_topic_forum_id($topic_id);
    $forum_subscribers = $forum_id ? mb_get_forum_subscribers($forum_id) : array();
    $topic_subscribers = $topic_id ? mb_get_topic_subscribers($topic_id) : array();
    /* Remove users who are already subscribed to the topic's forum or who wrote the post. */
    $subscribers = array_diff($topic_subscribers, $forum_subscribers, array($post->post_author));
    /* If there are no subscribers, bail. */
    if (empty($subscribers)) {
        return false;
    }
    /* Get needed topic data. */
    $topic_title = strip_tags(mb_get_topic_title($topic_id));
    /* Get needed reply data. */
    $reply_url = mb_get_reply_url($reply_id);
    $reply_author = mb_get_reply_author($reply_id);
    $reply_author_id = mb_get_reply_author_id($reply_id);
    $reply_content = mb_get_reply_content($reply_id, 'raw');
    /* Filter the reply content for email. */
    $reply_content = apply_filters('mb_pre_email_reply_content', $reply_content, $reply_id);
    /* Build the email message. */
    $message = sprintf(__('%1$s replied: %4$s%2$s %4$sPost Link: %3$s %4$sYou are receiving this email because you subscribed to a forum topic. Log in and visit the topic to unsubscribe from these emails.', 'message-board'), $reply_author, $reply_content, $reply_url, "\n\n");
    /* Get the site name and domain. */
    $site_name = esc_html(strip_tags(get_option('blogname')));
    $site_domain = untrailingslashit(str_replace(array('http://', 'https://'), '', home_url()));
    /* Who's the message from? */
    $from = '<noreply@' . $site_domain . '>';
    /* Translators: Email subject. 1 is the blog name. 2 is the topic title. */
    $subject = sprintf(esc_attr__('[$1%s] $2%s', 'message-board'), $site_name, $topic_title);
    /* Build the email headers. */
    $headers = array();
    $headers[] = sprintf('From: %s %s', $site_name, $from);
    foreach ($subscribers as $user_id) {
        $headers[] = 'Bcc: ' . get_userdata($user_id)->user_email;
    }
    /* Send the email. */
    return wp_mail($from, $subject, $message, $headers);
}
/**
 * Returns a forum's last post URL.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $forum_id
 * @return string
 */
function mb_get_forum_last_post_url($forum_id = 0)
{
    $forum_id = mb_get_forum_id($forum_id);
    $last_id = mb_get_forum_last_post_id($forum_id);
    $url = '';
    if ($last_id) {
        $url = mb_is_reply($last_id) ? mb_get_reply_url($last_id) : mb_get_topic_url($last_id);
    }
    return apply_filters('mb_get_forum_last_post_url', $url, $forum_id);
}
/**
 * Returns the reply link.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $reply_id
 * @return string
 */
function mb_get_reply_link($reply_id = 0)
{
    $url = mb_get_reply_url($reply_id);
    $title = mb_get_reply_title($reply_id);
    return apply_filters('mb_get_reply_link', sprintf('<a class="mb-reply-link" href="%s">%s</a>', $url, $title), $reply_id);
}
/**
 * Returns a topic's last post URL.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $topic_id
 * @return string
 */
function mb_get_topic_last_post_url($topic_id = 0)
{
    $topic_id = mb_get_topic_id($topic_id);
    $reply_id = mb_get_topic_last_reply_id($topic_id);
    $url = $reply_id ? mb_get_reply_url($reply_id) : '';
    if (!$url && $topic_id) {
        $url = user_trailingslashit(mb_get_topic_url($topic_id));
        $url = $url ? "{$url}#{$topic_id}" : '';
    }
    return apply_filters('mb_get_topic_last_post_url', $url, $reply_id, $topic_id);
}