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);
}
Esempio n. 2
0
/**
 * Returns the last post author for a forum.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $forum_id
 * @return string
 */
function mb_get_forum_last_post_author($forum_id = 0)
{
    $forum_id = mb_get_forum_id($forum_id);
    $last_id = mb_get_forum_last_post_id($forum_id);
    $author = '';
    if ($last_id) {
        $author = mb_is_reply($last_id) ? mb_get_reply_author($last_id) : mb_get_topic_author($last_id);
    }
    return apply_filters('mb_get_forum_last_post_author', $author, $forum_id);
}
Esempio n. 3
0
/**
 * Displays the reply author link.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $reply_id
 * @return string
 */
function mb_get_reply_author_link($reply_id = 0)
{
    $reply_id = mb_get_reply_id($reply_id);
    $author_id = mb_get_reply_author_id($reply_id);
    $author_url = mb_get_reply_author_url($reply_id);
    $author_name = mb_get_reply_author($reply_id);
    $author_link = $author_url ? sprintf('<a class="mb-reply-author-link" href="%s">%s</a>', $author_url, $author_name) : '';
    return apply_filters('mb_get_reply_author_link', $author_link, $reply_id);
}
Esempio n. 4
0
/**
 * Returns the last post author for a topic.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $topic_id
 * @return string
 */
function mb_get_topic_last_poster($topic_id = 0)
{
    $topic_id = mb_get_topic_id($topic_id);
    $reply_id = mb_get_topic_last_reply_id($topic_id);
    $author = !empty($reply_id) ? mb_get_reply_author($reply_id) : mb_get_topic_author($topic_id);
    return apply_filters('mb_get_topic_last_poster', $author, $reply_id, $topic_id);
}