function kleo_bbp_add_role_class($author_role, $r) { $reply_id = bbp_get_reply_id($r['reply_id']); $role = strtolower(esc_attr(bbp_get_user_display_role(bbp_get_reply_author_id($reply_id)))); $author_role = str_replace('class="', 'class="role-' . $role . ' ', $author_role); return $author_role; }
function widget($args, $instance) { extract($args, EXTR_SKIP); $title = !empty($instance['title']) ? $instance['title'] : __('Recent Topics'); $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; $orderby = !empty($instance['number']) ? strip_tags($instance['order_by']) : 'newness'; if ($orderby == 'newness') { $cb_meta_key = $cb_order_by = NULL; } elseif ($orderby == 'popular') { $cb_meta_key = '_bbp_reply_count'; $cb_order_by = 'meta_value'; } elseif ($orderby == 'freshness') { $cb_meta_key = '_bbp_last_active_time'; $cb_order_by = 'meta_value'; } if (!$number) { $number = 5; } $cb_qry = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'order' => 'DESC', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => $cb_meta_key, 'orderby' => $cb_order_by)); echo $before_widget; echo $before_title . $title . $after_title; ?> <ul class="cb-bbp-recent-topics"> <?php while ($cb_qry->have_posts()) { $cb_qry->the_post(); ?> <li> <?php $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID); $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>'; $cb_number_replies = bbp_get_topic_reply_count($cb_reply_id); $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60)); $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name')); echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_reply_url . '<div class="cb-bbp-byline">' . __('Started by', 'cubell') . ' ' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_number_replies . ' replies</div></div>'; ?> </li> <?php } ?> </ul> <?php echo $after_widget; // Reset the $post global wp_reset_postdata(); }
/** * Send a notification to subscribers * * @wp-filter bbp_new_reply 1 */ 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; }
/** * Check if the current page is forum, topic or other bbPress page. * * @return bool true if the current page is the forum related */ function d4p_is_bbpress() { $is = false; if (function_exists("bbp_get_forum_id")) { $is = bbp_get_forum_id() > 0 || bbp_get_reply_id() > 0 || bbp_get_topic_id() > 0; if (!$is) { global $template; $templates = array("single-reply-edit.php", "single-topic-edit.php"); $file = pathinfo($template, PATHINFO_BASENAME); $is = in_array($file, $templates); } } return apply_filters('d4p_is_bbpress', $is); }
public function getReplyList($topicId = -1) { $topicId = $topicId == -1 ? $_POST['param']['topicId'] : $topicId; $loadFrom = empty($_POST['param']['from']) ? 0 : $_POST['param']['from']; $loadTo = empty($_POST['param']['to']) ? 0 : $_POST['param']['to']; $return = array(); $param = array('post_parent' => $topicId, 'post_type' => 'reply'); if (!bbp_has_replies($param)) { $this->_die(); } while (bbp_replies()) { bbp_the_reply(); $reply = new ForumBbpAjaxIntegratorPost(bbp_get_reply_id(), 'reply'); $return[] = $reply->getPostData(); } return $return; }
function append_message_trigger($author_link, $r) { //we need to make sure it is a reply if (!bbp_get_reply_id()) { return $author_link; } wp_enqueue_script('popoverasync', ig_uploader()->plugin_url . 'assets/popover/popoverasync.js', array('jquery', 'ig-bootstrap', 'jquery-frame-transport')); wp_enqueue_style('igu-uploader', ig_uploader()->plugin_url . 'assets/style.css'); $new_links = explode($r['sep'], $author_link); $author_id = bbp_get_reply_author_id(bbp_get_reply_id($r['post_id'])); $message_link = do_shortcode("[pm_user user_id={$author_id} class='btn btn-xs btn-primary']"); $message_link = sprintf('<div style="%s">%s</div>', 'margin-top:5px', $message_link); array_splice($new_links, 1, 0, array($message_link)); $new_links = implode($r['sep'], $new_links); //$logger = new IG_Logger('file', 'message_bbpress.txt'); //$logger->log(var_export($new_links, true), IG_Logger::ERROR_LEVEL_DEBUG); return $new_links; }
function widget($args, $instance) { extract($args, EXTR_SKIP); $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments'); $title = apply_filters('widget_title', $title, $instance, $this->id_base); $number = !empty($instance['number']) ? absint($instance['number']) : 5; if (!$number) { $number = 5; } $cb_qry = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true)); echo $before_widget; echo $before_title . $title . $after_title; ?> <ul class="cb-bbp-recent-replies"> <?php while ($cb_qry->have_posts()) { $cb_qry->the_post(); ?> <li> <?php $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID); $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>'; $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60)); $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name')); echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_reply_url . '<div class="cb-bbp-recent-replies-time">' . bbp_get_time_since(get_the_time('U')) . '</div></div>'; ?> </li> <?php } ?> </ul> <?php echo $after_widget; // Reset the $post global wp_reset_postdata(); }
<?php if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_reply_forum_id(bbp_get_reply_id()), 'post__not_in' => array(bbp_get_reply_topic_id(bbp_get_reply_id()))))) { ?> <div> <input name="bbp_reply_move_option" id="bbp_reply_move_option_existing" type="radio" value="existing" tabindex="<?php bbp_tab_index(); ?> " /> <label for="bbp_reply_move_option_existing"><?php _e('Use an existing topic in this forum:', 'firmasite'); ?> </label> <?php bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_reply_forum_id(bbp_get_reply_id()), 'selected' => -1, 'exclude' => bbp_get_reply_topic_id(bbp_get_reply_id()), 'select_id' => 'bbp_destination_topic', 'none_found' => __('No other topics found!', 'firmasite'))); ?> </div> <?php } ?> </fieldset> <div class="bbp-template-notice error alert alert-warning"> <p><?php _e('<strong>WARNING:</strong> This process cannot be undone.', 'firmasite'); ?> </p>
/** * Update the activity stream entry when a reply status changes * * @param int $post_id * @param obj $post * @uses get_post_type() * @uses bbp_get_reply_post_type() * @uses bbp_get_reply_id() * @uses bbp_is_reply_anonymous() * @uses bbp_get_public_status_id() * @uses bbp_get_closed_status_id() * @uses bbp_get_reply_topic_id() * @uses bbp_get_reply_forum_id() * @uses bbp_get_reply_author_id() * @return Bail early if not a reply, or reply is by anonymous user */ public function reply_update($reply_id, $post) { // Bail early if not a reply if (get_post_type($post) != bbp_get_reply_post_type()) { return; } $reply_id = bbp_get_reply_id($reply_id); // Bail early if reply is by anonymous user if (bbp_is_reply_anonymous($reply_id)) { return; } $anonymous_data = array(); // Action based on new status if ($post->post_status == bbp_get_public_status_id()) { // Validate reply data $topic_id = bbp_get_reply_topic_id($reply_id); $forum_id = bbp_get_reply_forum_id($reply_id); $reply_author_id = bbp_get_reply_author_id($reply_id); $this->reply_create($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author_id); } else { $this->reply_delete($reply_id); } }
<header class="reply-header"> <time class="reply-time" datetime="<?php echo get_the_time('Y-m-d\\TH:i'); ?> "><?php echo bp_core_time_since(strtotime(get_the_time('c')), current_time('timestamp')); ?> </time> <?php apoc_report_post_button('reply'); ?> <div class="reply-admin-links"> <?php apoc_reply_admin_links(bbp_get_reply_id()); ?> <a class="reply-permalink" href="<?php bbp_reply_url(); ?> ">#<?php echo bbp_get_reply_position(); ?> </a> </div> </header> <section class="reply-body"> <div class="reply-author"> <?php echo $author->block;
/** * Add post date, author post count and author ip to the author element. */ public function add_author_post_date_count_ip() { ?> <div class="bbp-reply-post-date"><?php bbp_reply_post_date(bbp_get_reply_id()); ?> </div> <div class="bbps-post-count"><?php printf(__('Post count: %s', 'Avada'), bbp_get_user_reply_count_raw(bbp_get_reply_author_id()) + bbp_get_user_topic_count_raw(bbp_get_reply_author_id())); ?> </div> <?php if (bbp_is_user_keymaster()) { ?> <?php do_action('bbp_theme_before_topic_author_admin_details'); ?> <div class="bbp-reply-ip fusion-reply-id"><?php bbp_author_ip(bbp_get_topic_id()); ?> </div> <?php do_action('bbp_theme_after_topic_author_admin_details'); ?> <?php } }
/** * Output the required hidden fields when creating/editing a reply * * @since bbPress (r2753) * * @uses bbp_is_reply_edit() To check if it's the reply edit page * @uses wp_nonce_field() To generate hidden nonce fields * @uses bbp_reply_id() To output the reply id * @uses bbp_topic_id() To output the topic id * @uses bbp_forum_id() To output the forum id */ function bbp_reply_form_fields() { if (bbp_is_reply_edit()) { ?> <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php printf(__('Reply To: %s', 'bbpress'), bbp_get_topic_title()); ?> " maxlength="<?php bbp_get_title_max_length(); ?> " /> <input type="hidden" name="bbp_reply_id" id="bbp_reply_id" value="<?php bbp_reply_id(); ?> " /> <input type="hidden" name="action" id="bbp_post_action" value="bbp-edit-reply" /> <?php if (current_user_can('unfiltered_html')) { wp_nonce_field('bbp-unfiltered-html-reply_' . bbp_get_reply_id(), '_bbp_unfiltered_html_reply', false); } ?> <?php wp_nonce_field('bbp-edit-reply_' . bbp_get_reply_id()); } else { ?> <input type="hidden" name="bbp_reply_title" id="bbp_reply_title" value="<?php printf(__('Reply To: %s', 'bbpress'), bbp_get_topic_title()); ?> " maxlength="<?php bbp_get_title_max_length(); ?> " /> <input type="hidden" name="bbp_topic_id" id="bbp_topic_id" value="<?php bbp_topic_id(); ?> " /> <input type="hidden" name="action" id="bbp_post_action" value="bbp-new-reply" /> <?php if (current_user_can('unfiltered_html')) { wp_nonce_field('bbp-unfiltered-html-reply_' . bbp_get_topic_id(), '_bbp_unfiltered_html_reply', false); } ?> <?php wp_nonce_field('bbp-new-reply'); // Show redirect field if not viewing a specific topic if (bbp_is_query_name('bbp_single_topic')) { bbp_redirect_to_field(get_permalink()); } } }
/** * Return the value of reply to field * * @since bbPress (r4944) * * @uses bbp_get_reply_id() To validate the reply to * @uses apply_filters() Calls 'bbp_get_form_reply_to' with the reply to * @return string Value of reply to field */ function bbp_get_form_reply_to() { // Set initial value $reply_to = 0; // Get $_REQUEST data if (isset($_REQUEST['bbp_reply_to'])) { $reply_to = (int) $_REQUEST['bbp_reply_to']; } // If empty, get from meta if (empty($reply_to)) { $reply_to = bbp_get_reply_to(); } // Validate $reply_to = bbp_get_reply_id($reply_to); return (int) apply_filters('bbp_get_form_reply_to', $reply_to); }
/** * Generate post report buttons * @version 2.0 */ function apoc_report_post_button($type) { // Only let members report stuff if (!is_user_logged_in()) { return false; } // Get the data by context switch ($type) { // Forum reply case 'reply': $post_id = bbp_get_reply_id(); $reported_user = bbp_get_reply_author(); $post_number = bbp_get_reply_position(); break; // Article comment // Article comment case 'comment': global $comment, $comment_count; $post_id = $comment->comment_ID; $reported_user = $comment->comment_author; $post_number = $comment_count['count']; break; // Private message // Private message case 'message': global $thread_template; $post_id = $thread_template->message->thread_id; $reported_user = $thread_template->message->sender_id; $post_number = $thread_template->current_message + 1; break; } // Echo the button $button = '<a class="report-post" title="Report This Post" data-id="' . $post_id . '" data-number="' . $post_number . '" data-user="******" data-type="' . $type . '"><i class="fa fa-warning"></i></a>'; echo $button; }
/** * Get the position of a reply by querying the DB directly for the replies * of a given topic. * * @since bbPress (r3933) * * @param int $reply_id * @param int $topic_id */ function bbp_get_reply_position_raw($reply_id = 0, $topic_id = 0) { // Get required data $reply_id = bbp_get_reply_id($reply_id); $topic_id = !empty($topic_id) ? bbp_get_topic_id($topic_id) : bbp_get_reply_topic_id($reply_id); $reply_position = 0; // If reply is actually the first post in a topic, return 0 if ($reply_id !== $topic_id) { // Make sure the topic has replies before running another query $reply_count = bbp_get_topic_reply_count($topic_id, false); if (!empty($reply_count)) { // Get reply id's $topic_replies = bbp_get_all_child_ids($topic_id, bbp_get_reply_post_type()); if (!empty($topic_replies)) { // Reverse replies array and search for current reply position $topic_replies = array_reverse($topic_replies); $reply_position = array_search((string) $reply_id, $topic_replies); // Bump the position to compensate for the lead topic post $reply_position++; } } } return (int) $reply_position; }
function vortex_system_after_post($content) { $vortex_like_dislike = get_option("vortex_like_dislike"); if (function_exists('bbp_get_reply_id')) { if (bbp_get_reply_id() != null) { $id = bbp_get_reply_id(); } else { $id = get_the_ID(); } } else { $id = get_the_ID(); } if (!empty($vortex_like_dislike['v_exclude_category'])) { $array = $vortex_like_dislike['v_exclude_category']; if (has_category($array)) { return $content; } } if (!empty($vortex_like_dislike['v_exclude_post_types-p'])) { $array = $vortex_like_dislike['v_exclude_post_types-p']; if (in_array(get_post_type($id), $array)) { return $content; } } if ($vortex_like_dislike['v_button_show'][1] && is_page() && is_main_query()) { return $content . vortex_render_for_posts(); } elseif ($vortex_like_dislike['v_button_show'][2] && is_main_query() && !is_page() && !is_singular()) { return $content . vortex_render_for_posts(); } elseif ($vortex_like_dislike['v_button_show'][3] && is_singular('post')) { return $content . vortex_render_for_posts(); } elseif ($vortex_like_dislike['v_button_show'][4] && !is_main_query()) { return $content . vortex_render_for_posts(); } elseif ($vortex_like_dislike['v_button_show'][5] && is_singular() && !is_singular('post')) { return $content . vortex_render_for_posts(); } else { return $content; } }
/** * Performs a series of checks to ensure the current user can create replies. * * @since 2.0.0 bbPress (r3127) * * @uses bbp_is_user_keymaster() * @uses bbp_is_topic_edit() * @uses current_user_can() * @uses bbp_get_topic_id() * @uses bbp_allow_anonymous() * @uses is_user_logged_in() * * @return bool */ function bbp_current_user_can_access_create_reply_form() { // Users need to earn access $retval = false; // Always allow keymasters if (bbp_is_user_keymaster()) { $retval = true; // Looking at a single topic, topic is open, and forum is open } elseif ((bbp_is_single_topic() || is_page() || is_single()) && bbp_is_topic_open() && bbp_is_forum_open()) { $retval = bbp_current_user_can_publish_replies(); // User can edit this topic } elseif (bbp_is_reply_edit()) { $retval = current_user_can('edit_reply', bbp_get_reply_id()); } // Allow access to be filtered return (bool) apply_filters('bbp_current_user_can_access_create_reply_form', (bool) $retval); }
/** * Returns reply status downdown * * This dropdown is only intended to be seen by users with the 'moderate' * capability. Because of this, no additional capablitiy checks are performed * within this function to check available reply statuses. * * @since 2.6.0 bbPress (r5399) * * @param $args This function supports these arguments: * - select_id: Select id. Defaults to bbp_reply_status * - tab: Deprecated. Tabindex * - reply_id: Reply id * - selected: Override the selected option */ function bbp_get_form_reply_status_dropdown($args = array()) { // Parse arguments against default values $r = bbp_parse_args($args, array('select_id' => 'bbp_reply_status', 'select_class' => 'bbp_dropdown', 'tab' => false, 'reply_id' => 0, 'selected' => false), 'reply_status_dropdown'); // No specific selected value passed if (empty($r['selected'])) { // Post value is passed if (bbp_is_reply_form_post_request() && isset($_POST[$r['select_id']])) { $r['selected'] = sanitize_key($_POST[$r['select_id']]); // No Post value was passed } else { // Edit reply if (bbp_is_reply_edit()) { $r['reply_id'] = bbp_get_reply_id($r['reply_id']); $r['selected'] = bbp_get_reply_status($r['reply_id']); // New reply } else { $r['selected'] = bbp_get_public_status_id(); } } } // Used variables $tab = !empty($r['tab']) ? ' tabindex="' . (int) $r['tab'] . '"' : ''; // Start an output buffer, we'll finish it after the select loop ob_start(); ?> <select name="<?php echo esc_attr($r['select_id']); ?> " id="<?php echo esc_attr($r['select_id']); ?> _select" class="<?php echo esc_attr($r['select_class']); ?> "<?php echo $tab; ?> > <?php foreach (bbp_get_reply_statuses($r['reply_id']) as $key => $label) { ?> <option value="<?php echo esc_attr($key); ?> "<?php selected($key, $r['selected']); ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> <?php // Return the results return apply_filters('bbp_get_form_reply_status_dropdown', ob_get_clean(), $r); }
/** * Reset main query vars and filter 'the_content' to output a bbPress * template part as needed. * * @since bbPress (r3032) * @param string $template * @uses bbp_is_single_user() To check if page is single user * @uses bbp_get_single_user_template() To get user template * @uses bbp_is_single_user_edit() To check if page is single user edit * @uses bbp_get_single_user_edit_template() To get user edit template * @uses bbp_is_single_view() To check if page is single view * @uses bbp_get_single_view_template() To get view template * @uses bbp_is_forum_edit() To check if page is forum edit * @uses bbp_get_forum_edit_template() To get forum edit template * @uses bbp_is_topic_merge() To check if page is topic merge * @uses bbp_get_topic_merge_template() To get topic merge template * @uses bbp_is_topic_split() To check if page is topic split * @uses bbp_get_topic_split_template() To get topic split template * @uses bbp_is_topic_edit() To check if page is topic edit * @uses bbp_get_topic_edit_template() To get topic edit template * @uses bbp_is_reply_edit() To check if page is reply edit * @uses bbp_get_reply_edit_template() To get reply edit template * @uses bbp_set_theme_compat_template() To set the global theme compat template */ function bbp_template_include_theme_compat($template = '') { // Bail if the template already matches a bbPress template. This includes // archive-* and single-* WordPress post_type matches (allowing // themes to use the expected format) as well as all bbPress-specific // template files for users, topics, forums, etc... if (!empty(bbpress()->theme_compat->bbpress_template)) { return $template; } /** Users *************************************************************/ if (bbp_is_single_user_edit() || bbp_is_single_user()) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => esc_attr(bbp_get_displayed_user_field('display_name')), 'post_status' => bbp_get_public_status_id(), 'is_archive' => false, 'comment_status' => 'closed')); /** Forums ************************************************************/ // Forum archive } elseif (bbp_is_forum_archive()) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_forum_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed')); // Single Forum } elseif (bbp_is_forum_edit() || bbp_is_single_forum()) { // Reset post bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_forum_id()), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed')); /** Topics ************************************************************/ // Topic archive } elseif (bbp_is_topic_archive()) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed')); // Single Topic } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) { // Reset post bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_topic_id()), 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed')); /** Replies ***********************************************************/ // Reply archive } elseif (is_post_type_archive(bbp_get_reply_post_type())) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed')); // Single Reply } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) { // Reset post bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_reply_id()), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed')); /** Views *************************************************************/ } elseif (bbp_is_single_view()) { // Reset post bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed')); /** Topic Tags ********************************************************/ // Topic Tag Edit } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) { // Stash the current term in a new var set_query_var('bbp_topic_tag', get_query_var('term')); // Reset the post with our new title bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed')); } /** * If we are relying on bbPress's built in theme compatibility to load * the proper content, we need to intercept the_content, replace the * output, and display ours instead. * * To do this, we first remove all filters from 'the_content' and hook * our own function into it, which runs a series of checks to determine * the context, and then uses the built in shortcodes to output the * correct results from inside an output buffer. * * Uses bbp_get_theme_compat_templates() to provide fall-backs that * should be coded without superfluous mark-up and logic (prev/next * navigation, comments, date/time, etc...) * * Hook into the 'bbp_get_bbpress_template' to override the array of * possible templates, or 'bbp_bbpress_template' to override the result. */ if (bbp_is_theme_compat_active()) { // Remove all filters from the_content bbp_remove_all_filters('the_content'); // Add a filter on the_content late, which we will later remove add_filter('the_content', 'bbp_replace_the_content'); // Find the appropriate template file $template = bbp_get_theme_compat_templates(); } return apply_filters('bbp_template_include_theme_compat', $template); }
/** * Insert Balance * @since 0.1 * @version 1.2.1 */ public function insert_balance_reply() { $reply_id = bbp_get_reply_id(); // Skip Anonymous replies if (bbp_is_reply_anonymous($reply_id)) { return; } // Get reply author $user_id = bbp_get_reply_author_id($reply_id); // Check for exclusions and guests if ($this->core->exclude_user($user_id) || $user_id == 0) { return; } $balance = $this->core->get_users_cred($user_id, $this->mycred_type); $layout = $this->core->plural() . ': ' . $this->core->format_creds($balance); echo apply_filters('mycred_bbp_reply_balance', '<div class="users-mycred-balance">' . $layout . '</div>', $layout, $user_id, $this); }
/** * Loads up the current search result in the loop * * @since bbPress (r4579) * * @uses WP_Query bbPress::search_query::the_post() To get the current search result * @return object Search information */ function bbp_the_search_result() { $search_result = bbpress()->search_query->the_post(); // Reset each current (forum|topic|reply) id bbpress()->current_forum_id = bbp_get_forum_id(); bbpress()->current_topic_id = bbp_get_topic_id(); bbpress()->current_reply_id = bbp_get_reply_id(); return $search_result; }
/** * Return the row class of a reply * * @since bbPress (r2678) * * @param int $reply_id Optional. Reply ID * @param array Extra classes you can pass when calling this function * @uses bbp_get_reply_id() To validate the reply id * @uses bbp_get_reply_forum_id() To get the reply's forum id * @uses bbp_get_reply_topic_id() To get the reply's topic id * @uses get_post_class() To get all the classes including ours * @uses apply_filters() Calls 'bbp_get_reply_class' with the classes * @return string Row class of the reply */ function bbp_get_reply_class($reply_id = 0, $classes = array()) { $bbp = bbpress(); $reply_id = bbp_get_reply_id($reply_id); $count = isset($bbp->reply_query->current_post) ? $bbp->reply_query->current_post : 1; $classes = (array) $classes; $classes[] = (int) $count % 2 ? 'even' : 'odd'; $classes[] = 'bbp-parent-forum-' . bbp_get_reply_forum_id($reply_id); $classes[] = 'bbp-parent-topic-' . bbp_get_reply_topic_id($reply_id); $classes[] = 'bbp-reply-position-' . bbp_get_reply_position($reply_id); $classes[] = 'user-id-' . bbp_get_reply_author_id($reply_id); $classes[] = bbp_get_reply_author_id($reply_id) === bbp_get_topic_author_id(bbp_get_reply_topic_id($reply_id)) ? 'topic-author' : ''; $classes = array_filter($classes); $classes = get_post_class($classes, $reply_id); $classes = apply_filters('bbp_get_reply_class', $classes, $reply_id); $retval = 'class="' . implode(' ', $classes) . '"'; return $retval; }
?> "> <?php bbp_topic_title(bbp_get_reply_topic_id()); ?> </a> </span> <?php } ?> <?php do_action('bbp_theme_before_reply_content'); bbp_reply_content(); $post->ID = bbp_get_reply_id(); if (function_exists('wp_ulike_bbpress')) { wp_ulike_bbpress('get'); } do_action('bbp_theme_after_reply_content'); ?> <?php do_action('bbp_theme_before_reply_admin_links'); bbp_reply_admin_links(); do_action('bbp_theme_after_reply_admin_links'); ?> <a href="#toggle-replies">Toggle replies</a>
/** * Sends notification emails for new replies to subscribed topics * * Gets new post's ID and check if there are subscribed users to that topic, and * if there are, send notifications * * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email * with everyone BCC'd. This may have negative repercussions for email services * that limit the number of addresses in a BCC field (often to around 500.) In * those cases, we recommend unhooking this function and creating your own * custom emailer script. * * @since 2.6.0 bbPress (r5413) * * @param int $reply_id ID of the newly made reply * @param int $topic_id ID of the topic of the reply * @param int $forum_id ID of the forum of the reply * @param mixed $anonymous_data Array of anonymous user data * @param int $reply_author ID of the topic author ID * * @uses bbp_is_subscriptions_active() To check if the subscriptions are active * @uses bbp_get_reply_id() To validate the reply ID * @uses bbp_get_topic_id() To validate the topic ID * @uses bbp_get_forum_id() To validate the forum ID * @uses bbp_get_reply() To get the reply * @uses bbp_is_reply_published() To make sure the reply is published * @uses bbp_get_topic_id() To validate the topic ID * @uses bbp_get_topic() To get the reply's topic * @uses bbp_is_topic_published() To make sure the topic is published * @uses bbp_get_reply_author_display_name() To get the reply author's display name * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id, * topic id and user id * @uses bbp_get_topic_subscribers() To get the topic subscribers * @uses apply_filters() Calls 'bbp_subscription_mail_message' with the * message, reply id, topic id and user id * @uses apply_filters() Calls 'bbp_subscription_mail_title' with the * topic title, reply id, topic id and user id * @uses apply_filters() Calls 'bbp_subscription_mail_headers' * @uses get_userdata() To get the user data * @uses wp_mail() To send the mail * @uses do_action() Calls 'bbp_post_notify_subscribers' with the reply id, * topic id and user id * @return bool True on success, false on failure */ function bbp_notify_topic_subscribers($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0) { // Bail if subscriptions are turned off if (!bbp_is_subscriptions_active()) { return false; } /** Validation ************************************************************/ $reply_id = bbp_get_reply_id($reply_id); $topic_id = bbp_get_topic_id($topic_id); $forum_id = bbp_get_forum_id($forum_id); /** Topic *****************************************************************/ // Bail if topic is not published if (!bbp_is_topic_published($topic_id)) { return false; } /** Reply *****************************************************************/ // Bail if reply is not published if (!bbp_is_reply_published($reply_id)) { return false; } // Poster name $reply_author_name = bbp_get_reply_author_display_name($reply_id); /** Mail ******************************************************************/ // Remove filters from reply content and topic title to prevent content // from being encoded with HTML entities, wrapped in paragraph tags, etc... remove_all_filters('bbp_get_reply_content'); remove_all_filters('bbp_get_topic_title'); // Strip tags from text and setup mail data $topic_title = strip_tags(bbp_get_topic_title($topic_id)); $reply_content = strip_tags(bbp_get_reply_content($reply_id)); $reply_url = bbp_get_reply_url($reply_id); $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); // For plugins to filter messages per reply/topic/user $message = sprintf(__('%1$s wrote: %2$s Post Link: %3$s ----------- You are receiving this email because you subscribed to a forum topic. Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $reply_author_name, $reply_content, $reply_url); $message = apply_filters('bbp_subscription_mail_message', $message, $reply_id, $topic_id); if (empty($message)) { return; } // For plugins to filter titles per reply/topic/user $subject = apply_filters('bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id); if (empty($subject)) { return; } /** Users *****************************************************************/ // Get the noreply@ address $no_reply = bbp_get_do_not_reply_address(); // Setup "From" email address $from_email = apply_filters('bbp_subscription_from_email', $no_reply); // Setup the From header $headers = array('From: ' . get_bloginfo('name') . ' <' . $from_email . '>'); // Get topic subscribers and bail if empty $user_ids = bbp_get_topic_subscribers($topic_id, true); // Dedicated filter to manipulate user ID's to send emails to $user_ids = apply_filters('bbp_topic_subscription_user_ids', $user_ids); if (empty($user_ids)) { return false; } // Loop through users foreach ((array) $user_ids as $user_id) { // Don't send notifications to the person who made the post if (!empty($reply_author) && (int) $user_id === (int) $reply_author) { continue; } // Get email address of subscribed user $headers[] = 'Bcc: ' . get_userdata($user_id)->user_email; } /** Send it ***************************************************************/ // Custom headers $headers = apply_filters('bbp_subscription_mail_headers', $headers); $to_email = apply_filters('bbp_subscription_to_email', $no_reply); do_action('bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids); // Send notification email wp_mail($to_email, $subject, $message, $headers); do_action('bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids); return true; }
<?php if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_reply_forum_id(bbp_get_reply_id()), 'post__not_in' => array(bbp_get_reply_topic_id(bbp_get_reply_id()))))) { ?> <div> <input name="bbp_reply_move_option" id="bbp_reply_move_option_existing" type="radio" value="existing" tabindex="<?php bbp_tab_index(); ?> " /> <label for="bbp_reply_move_option_existing"><?php _e('Use an existing topic in this forum:', 'bbpress'); ?> </label> <?php bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_reply_forum_id(bbp_get_reply_id()), 'selected' => -1, 'exclude' => bbp_get_reply_topic_id(bbp_get_reply_id()), 'select_id' => 'bbp_destination_topic')); ?> </div> <?php } ?> </fieldset> <div class="bbp-template-notice error"> <p><?php _e('<strong>WARNING:</strong> This process cannot be undone.', 'bbpress'); ?> </p>
/** * Move reply form fields * * Output the required hidden fields when moving a reply * * @uses wp_nonce_field() To generate a hidden nonce field */ function bbp_move_reply_form_fields() { ?> <input type="hidden" name="action" id="bbp_post_action" value="bbp-move-reply" /> <input type="hidden" name="bbp_reply_id" id="bbp_reply_id" value="<?php echo absint($_GET['reply_id']); ?> " /> <?php wp_nonce_field('bbp-move-reply_' . bbp_get_reply_id()); }
bbp_reply_class(); ?> > <td class="bbp-reply-author"> <?php bbp_reply_author_link(); ?> <?php if (is_super_admin()) { ?> <div class="bbp-reply-ip"><?php bbp_author_ip(bbp_get_reply_id()); ?> </div> <?php } ?> </td> <td class="bbp-reply-content"> <?php bbp_reply_content(); ?>
/** * Update the topic with the most recent reply ID * * @since bbPress (r2625) * * @param int $topic_id Optional. Topic id to update * @param int $reply_id Optional. Reply id * @uses bbp_is_reply() To check if the passed topic id is a reply * @uses bbp_get_reply_id() To get the reply id * @uses bbp_get_reply_topic_id() To get the reply topic id * @uses bbp_get_topic_id() To get the topic id * @uses bbp_get_reply_post_type() To get the reply post type * @uses bbp_get_public_child_last_id() To get the last public reply id * @uses update_post_meta() To update the topic last reply id meta * @uses apply_filters() Calls 'bbp_update_topic_last_reply_id' with the reply * id and topic id * @return int Reply id */ function bbp_update_topic_last_reply_id($topic_id = 0, $reply_id = 0) { // If it's a reply, then get the parent (topic id) if (empty($reply_id) && bbp_is_reply($topic_id)) { $reply_id = bbp_get_reply_id($topic_id); $topic_id = bbp_get_reply_topic_id($reply_id); } else { $reply_id = bbp_get_reply_id($reply_id); $topic_id = bbp_get_topic_id($topic_id); } if (empty($reply_id)) { $reply_id = bbp_get_public_child_last_id($topic_id, bbp_get_reply_post_type()); } // Adjust last_id's based on last_reply post_type if (empty($reply_id) || !bbp_is_reply($reply_id)) { $reply_id = 0; } // Update if reply is published if (bbp_is_reply_published($reply_id)) { update_post_meta($topic_id, '_bbp_last_reply_id', (int) $reply_id); } return apply_filters('bbp_update_topic_last_reply_id', (int) $reply_id, $topic_id); }
public function quote_reply_content($content) { return '<div id="d4p-bbp-quote-' . bbp_get_reply_id() . '">' . $content . '</div>'; }
function new_reply_notification($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0, $is_edit = false, $reply_to = 0) { $admin_email = get_option('admin_email'); $user_id = (int) $reply_author_id; $reply_id = bbp_get_reply_id($reply_id); $topic_id = bbp_get_topic_id($topic_id); $forum_id = bbp_get_forum_id($forum_id); $email_subject = get_option('bbpress_notify_newreply_email_subject'); $email_body = get_option('bbpress_notify_newreply_email_body'); $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $topic_title = html_entity_decode(strip_tags(bbp_get_topic_title($topic_id)), ENT_NOQUOTES, 'UTF-8'); $topic_content = html_entity_decode(strip_tags(bbp_get_topic_content($topic_id)), ENT_NOQUOTES, 'UTF-8'); $topic_excerpt = html_entity_decode(strip_tags(bbp_get_topic_excerpt($topic_id, 100)), ENT_NOQUOTES, 'UTF-8'); $topic_author = bbp_get_topic_author($topic_id); $topic_url = bbp_get_topic_permalink($topic_id); $topic_reply = bbp_get_reply_url($topic_id); $reply_url = bbp_get_reply_url($reply_id); $reply_content = get_post_field('post_content', $reply_id, 'raw'); $reply_author = bbp_get_topic_author($user_id); $email_subject = $blog_name . " New Reply Alert: " . $topic_title; $email_body = $blog_name . ": {$topic_title}\n\r"; $email_body .= $reply_content; $email_body .= "\n\r--------------------------------\n\r"; $email_body .= "Reply Url: " . $reply_url . "\n\rAuthor: {$reply_author}" . "\n\rYou can reply at: {$reply_url}"; @wp_mail($admin_email, $email_subject, $email_body); }