Exemplo n.º 1
0
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);
}
echo format_to_edit(mb_code_trick_reverse(mb_get_reply_content(mb_get_reply_id(), 'raw')));
?>
</textarea>
		</p>

		<p>
			<input type="submit" value="<?php 
esc_attr_e('Submit', 'message-board');
?>
" />
		</p>

		<p>
			<label>
				<input type="checkbox" name="mb_topic_subscribe" value="<?php 
echo mb_is_user_subscribed_topic(mb_get_reply_author_id(), mb_get_reply_topic_id()) ? 1 : 0;
?>
" /> 
				<?php 
_e('Notify me of follow-up posts via email', 'message-board');
?>
			</label>
		</p>

		<input type="hidden" name="mb_reply_id" value="<?php 
mb_reply_id();
?>
" />

		<?php 
wp_nonce_field('mb_edit_reply_action', 'mb_edit_reply_nonce', false);
Exemplo n.º 3
0
/**
 * Front end edit reply handler.
 *
 * @since  1.0.0
 * @access public
 * @return void
 */
function mb_handler_edit_reply()
{
    /* Verify the nonce. */
    if (!mb_check_post_nonce('mb_edit_reply_nonce', 'mb_edit_reply_action')) {
        return;
    }
    /* Make sure we have a reply ID. */
    if (!isset($_POST['mb_reply_id'])) {
        mb_bring_the_doom('what-edit');
    }
    /* Get the reply ID. */
    $reply_id = mb_get_reply_id($_POST['mb_reply_id']);
    /* Make sure the current user can edit the reply. */
    if (!current_user_can('edit_reply', $reply_id)) {
        mb_bring_the_doom('no-permission');
    }
    /* Make sure we have reply content. */
    if (empty($_POST['mb_reply_content'])) {
        mb_bring_the_doom('no-content');
    }
    /* Post content. */
    $post_content = apply_filters('mb_pre_insert_reply_content', $_POST['mb_reply_content']);
    /* Publish a new reply. */
    $published = wp_update_post(array('ID' => $reply_id, 'post_content' => $post_content));
    /* If the post was published. */
    if ($published && !is_wp_error($published)) {
        $user_id = mb_get_reply_author_id($published);
        /* If the user chose to subscribe to the topic. */
        if (isset($_POST['mb_topic_subscribe']) && 1 === absint($_POST['mb_topic_subscribe'])) {
            mb_add_user_topic_subscription($user_id, $topic_id);
        } else {
            mb_remove_topic_user_subscription($user_id, $topic_id);
        }
        /* Redirect to the published topic page. */
        wp_safe_redirect(get_permalink($published));
    }
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
0
    echo esc_url(get_the_author_meta('url'), mb_get_reply_author_id());
    ?>
"><?php 
    _e('Web Site', 'message-board');
    ?>
</a>
				<?php 
}
?>
				<br />
				<span class="mb-user-topic-count"><?php 
printf(__('Topics: %s', 'message-board'), mb_get_user_topic_count(mb_get_reply_author_id()));
?>
</span>
				<br />
				<span class="mb-user-reply-count"><?php 
printf(__('Replies: %s', 'message-board'), mb_get_user_reply_count(mb_get_reply_author_id()));
?>
</span>
			</div><!-- .mb-author-info -->

		</div><!-- .mb-author-box -->

		<div class="mb-reply-content">
			<?php 
mb_reply_content();
?>
		</div><!-- .mb-reply-content -->

	</article>
</li>
Exemplo n.º 6
0
			<?php 
    while (mb_reply_query()) {
        // Begins the loop through found posts.
        ?>

				<?php 
        mb_the_reply();
        // Loads the post data.
        ?>

				<tr>
					<td class="mb-col-title">
						<?php 
        if (!mb_is_user_page()) {
            echo get_avatar(mb_get_reply_author_id());
        }
        ?>
						<?php 
        mb_reply_link();
        ?>
						<div class="mb-reply-summary">
							<?php 
        the_excerpt();
        ?>
						</div><!-- .mb-reply-summary -->
					</td><!-- .mb-col-title -->

					<td class="mb-col-datetime">
						<?php 
        mb_reply_date();