Example #1
0
/**
 * Format the BuddyBar/Toolbar notifications
 *
 * @since 2.5.0 bbPress (r5155)
 *
 * @package bbPress
 *
 * @param string $action The kind of notification being rendered
 * @param int $item_id The primary item id
 * @param int $secondary_item_id The secondary item id
 * @param int $total_items The total number of messaging-related notifications waiting for the user
 * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
 */
function bbp_format_buddypress_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    // Bail if not the notification action we are looking for
    if ('bbp_new_reply' !== $action) {
        return $action;
    }
    // New reply notifications
    $topic_id = bbp_get_reply_topic_id($item_id);
    $topic_title = bbp_get_topic_title($topic_id);
    $topic_link = wp_nonce_url(add_query_arg(array('action' => 'bbp_mark_read', 'topic_id' => $topic_id), bbp_get_reply_url($item_id)), 'bbp_mark_topic_' . $topic_id);
    $title_attr = __('Topic Replies', 'bbpress');
    if ((int) $total_items > 1) {
        $text = sprintf(__('You have %d new replies', 'bbpress'), (int) $total_items);
        $filter = 'bbp_multiple_new_subscription_notification';
    } else {
        if (!empty($secondary_item_id)) {
            $text = sprintf(__('You have %d new reply to %2$s from %3$s', 'bbpress'), (int) $total_items, $topic_title, bp_core_get_user_displayname($secondary_item_id));
        } else {
            $text = sprintf(__('You have %d new reply to %s', 'bbpress'), (int) $total_items, $topic_title);
        }
        $filter = 'bbp_single_new_subscription_notification';
    }
    // WordPress Toolbar
    if ('string' === $format) {
        $return = apply_filters($filter, '<a href="' . esc_url($topic_link) . '" title="' . esc_attr($title_attr) . '">' . esc_html($text) . '</a>', (int) $total_items, $text, $topic_link);
        // Deprecated BuddyBar
    } else {
        $return = apply_filters($filter, array('text' => $text, 'link' => $topic_link), $topic_link, (int) $total_items, $text, $topic_title);
    }
    do_action('bbp_format_buddypress_notifications', $action, $item_id, $secondary_item_id, $total_items);
    return $return;
}
function bbpvotes_buddypress_voted_activity($post_id, $user_id, $vote)
{
    //check vote value
    if (is_bool($vote) === false) {
        return new WP_Error('vote_is_not_bool', __('Vote is not a boolean', 'bbpvotes'));
    }
    $voteplus = $vote === true;
    $voteminus = $vote === false;
    $post = get_post($post_id);
    $user_link = bbp_get_user_profile_link($user_id);
    //build item link
    if ($post->post_type == bbp_get_topic_post_type()) {
        $topic_id = $post->ID;
        $post_permalink = get_permalink($post->ID);
    } elseif ($post->post_type == bbp_get_reply_post_type()) {
        $topic_id = bbp_get_reply_topic_id($post->ID);
        $post_permalink = bbp_get_reply_url($post->ID);
    }
    //topic infos
    $topic = get_post($topic_id);
    $topic_author_link = bbp_get_user_profile_link($topic->post_author);
    $topic_title = $topic->post_title;
    $post_link = '<a href="' . $post_permalink . '">' . $topic_title . '</a>';
    if ($voteplus) {
        $type = 'bbpvotes_voted_up';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    } else {
        $type = 'bbpvotes_voted_down';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    }
    $args = array('action' => $action, 'component' => 'bbpress', 'type' => $type, 'item_id' => $topic->ID);
    if ($post->post_type == bbp_get_reply_post_type()) {
        $args['secondary_item_id'] = $post->ID;
    }
    /*
        if ($is_update){
       $previous_activity_id = 
       $args['id'] = $previous_activity_id;
        }
    */
    bp_activity_add($args);
}
Example #3
0
 /**
  * When inserting a new reply, make sure the protected meta data is set correctly.
  *
  * We can't use WP_JSON_Posts::add_meta() here because the required meta is deemed
  * protected by @see is_protected_meta().
  *
  * @see WP_JSON_Posts::insert_post()
  * @see WP_JSON_Posts::add_meta()
  */
 public function add_protected_meta($post, $data, $update)
 {
     if (!$update && $this->type == $post['post_type']) {
         // Forum meta
         $reply_meta = array('author_ip' => bbp_current_author_ip(), 'forum_id' => bbp_get_topic_forum_id($post['post_parent']), 'topic_id' => $post['post_parent']);
         // Insert reply meta
         foreach ($reply_meta as $meta_key => $meta_value) {
             update_post_meta($post['ID'], '_bbp_' . $meta_key, $meta_value);
         }
         // Update the topic
         $topic_id = bbp_get_reply_topic_id($post['ID']);
         if (!empty($topic_id)) {
             bbp_update_topic($topic_id);
         }
     }
 }
Example #4
0
/**
 * Reply metabox
 *
 * The metabox that holds all of the additional reply information
 *
 * @since bbPress (r2464)
 *
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_dropdown() To show a dropdown of the topics for reply parent
 * @uses do_action() Calls 'bbp_reply_metabox'
 */
function bbp_reply_metabox()
{
    // Post ID
    $post_id = get_the_ID();
    // Get some meta
    $reply_topic_id = bbp_get_reply_topic_id($post_id);
    $reply_forum_id = bbp_get_reply_forum_id($post_id);
    // Allow individual manipulation of reply forum
    if (current_user_can('edit_others_replies') || current_user_can('moderate')) {
        // Forums
        $args = array('selected' => $reply_forum_id, 'select_id' => 'bbp_forum_id', 'show_none' => __('(Use Forum of Topic)', 'bbpress'));
        ?>

		<p><strong><?php 
        _e('Forum', 'bbpress');
        ?>
</strong></p>

		<p>
			<label class="screen-reader-text" for="bbp_forum_id"><?php 
        _e('Forum', 'bbpress');
        ?>
</label>

			<?php 
        bbp_dropdown($args);
        ?>

		</p>

	<?php 
    }
    // Topics
    $args = array('post_type' => bbp_get_topic_post_type(), 'selected' => $reply_topic_id, 'select_id' => 'parent_id', 'orderby' => 'post_date', 'numberposts' => '250', 'show_none' => is_super_admin() ? __('(No Topic)', 'bbpress') : '');
    // Allow the dropdown to be filtered, to extend or limit the available
    // topics to choose as the reply parent.
    $args = apply_filters('bbp_reply_parent_dropdown', $args);
    ?>

	<p><strong><?php 
    _e('Topic', 'bbpress');
    ?>
</strong></p>

	<p>
		<label class="screen-reader-text" for="parent_id"><?php 
    _e('Topic', 'bbpress');
    ?>
</label>

		<?php 
    bbp_dropdown($args);
    ?>

	</p>

	<?php 
    wp_nonce_field('bbp_reply_metabox_save', 'bbp_reply_metabox');
    do_action('bbp_reply_metabox', $post_id);
}
 /**
  * Runs through the various bbPress conditional tags to check the current page being viewed.  Once
  * a condition is met, add items to the $items array.
  *
  * @since  0.6.0
  * @access public
  * @return void
  */
 public function do_trail_items()
 {
     /* Add the network and site home links. */
     $this->do_network_home_link();
     $this->do_site_home_link();
     /* Get the forum post type object. */
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     /* If not viewing the forum root/archive page and a forum archive exists, add it. */
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $this->items[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
     }
     /* If viewing the forum root/archive. */
     if (bbp_is_forum_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_archive_title();
         }
     } elseif (bbp_is_topic_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_archive_title();
         }
     } elseif (bbp_is_topic_tag()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_tag_name();
         }
     } elseif (bbp_is_topic_tag_edit()) {
         $this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
         if (true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_view()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_view_title();
         }
     } elseif (bbp_is_single_topic()) {
         /* Get the queried topic. */
         $topic_id = get_queried_object_id();
         /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
         $this->do_post_parents(bbp_get_topic_forum_id($topic_id));
         /* If viewing a split, merge, or edit topic page, show the link back to the topic.  Else, display topic title. */
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $this->items[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_title($topic_id);
         }
         /* If viewing a topic split page. */
         if (bbp_is_topic_split() && true === $this->args['show_title']) {
             $this->items[] = __('Split', 'breadcrumb-trail');
         } elseif (bbp_is_topic_merge() && true === $this->args['show_title']) {
             $this->items[] = __('Merge', 'breadcrumb-trail');
         } elseif (bbp_is_topic_edit() && true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_reply()) {
         /* Get the queried reply object ID. */
         $reply_id = get_queried_object_id();
         /* Get the parent items for the reply, which should be its topic. */
         $this->do_post_parents(bbp_get_reply_topic_id($reply_id));
         /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
         if (bbp_is_reply_edit()) {
             $this->items[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_reply_title($reply_id);
         }
     } elseif (bbp_is_single_forum()) {
         /* Get the queried forum ID and its parent forum ID. */
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         /* If the forum has a parent forum, get its parent(s). */
         if (0 !== $forum_parent_id) {
             $this->do_post_parents($forum_parent_id);
         }
         /* Add the forum title to the end of the trail. */
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_title($forum_id);
         }
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_displayed_user_field('display_name');
         }
     }
     /* Return the bbPress breadcrumb trail items. */
     $this->items = apply_filters('breadcrumb_trail_get_bbpress_items', $this->items, $this->args);
 }
Example #6
0
/**
 * Return value of topic tags field
 *
 * @since 2.0.0 bbPress (r2976)
 *
 * @uses bbp_is_topic_edit() To check if it's the topic edit page
 * @uses apply_filters() Calls 'bbp_get_form_topic_tags' with the tags
 * @return string Value of topic tags field
 */
function bbp_get_form_topic_tags()
{
    // Default return value
    $topic_tags = '';
    // Get _POST data
    if ((bbp_is_topic_form_post_request() || bbp_is_reply_form_post_request()) && isset($_POST['bbp_topic_tags'])) {
        $topic_tags = wp_unslash($_POST['bbp_topic_tags']);
        // Get edit data
    } elseif (bbp_is_single_topic() || bbp_is_single_reply() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
        // Determine the topic id based on the post type
        switch (get_post_type()) {
            // Post is a topic
            case bbp_get_topic_post_type():
                $topic_id = bbp_get_topic_id(get_the_ID());
                break;
                // Post is a reply
            // Post is a reply
            case bbp_get_reply_post_type():
                $topic_id = bbp_get_reply_topic_id(get_the_ID());
                break;
        }
        // Topic exists
        if (!empty($topic_id)) {
            // Topic is spammed so display pre-spam terms
            if (bbp_is_topic_spam($topic_id)) {
                // Get pre-spam terms
                $spam_terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
                $topic_tags = !empty($spam_terms) ? implode(', ', $spam_terms) : '';
                // Topic is not spam so get real terms
            } else {
                $topic_tags = bbp_get_topic_tag_names($topic_id);
            }
        }
    }
    return apply_filters('bbp_get_form_topic_tags', $topic_tags);
}
Example #7
0
/**
 * Adjust the total anonymous reply count of a topic
 *
 * @since bbPress (r2567)
 *
 * @param int $topic_id Optional. Topic id to update
 * @uses bbp_is_reply() To check if the passed topic id is a reply
 * @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_topic_id() To get the reply topic id
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses wpdb::prepare() To prepare our sql query
 * @uses wpdb::get_col() To execute our query and get the column back
 * @uses update_post_meta() To update the topic anonymous reply count meta
 * @uses apply_filters() Calls 'bbp_update_topic_anonymous_reply_count' with the
 *                        anonymous reply count and topic id
 * @return int Anonymous reply count
 */
function bbp_update_topic_anonymous_reply_count($topic_id = 0)
{
    global $wpdb;
    // If it's a reply, then get the parent (topic id)
    if (bbp_is_reply($topic_id)) {
        $topic_id = bbp_get_reply_topic_id($topic_id);
    } elseif (bbp_is_topic($topic_id)) {
        $topic_id = bbp_get_topic_id($topic_id);
    } else {
        return;
    }
    $anonymous_replies = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type()));
    update_post_meta($topic_id, '_bbp_anonymous_reply_count', (int) $anonymous_replies);
    return apply_filters('bbp_update_topic_anonymous_reply_count', (int) $anonymous_replies, $topic_id);
}
/**
 * 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;
}
Example #9
0
 function hook_bbp_new_reply($reply_id)
 {
     $topic_id = bbp_get_reply_topic_id($reply_id);
     $topic_url = bbp_get_topic_permalink($topic_id);
     //$dir = $this->get_folder() . '' . substr($topic_url, strlen(get_option('home'))) . '/';
     $dir = $this->get_folder() . '/' . substr($topic_url, strpos($topic_url, '://') + 3) . '/';
     $this->remove_dir($dir);
     $forum_id = bbp_get_reply_forum_id($reply_id);
     $forum_url = bbp_get_forum_permalink($forum_id);
     //$dir = $this->get_folder() . '' . substr($forum_url, strlen(get_option('home'))) . '/';
     $dir = $this->get_folder() . '/' . substr($topic_url, strpos($forum_url, '://') + 3) . '/';
     $this->remove_dir($dir);
 }
Example #10
0
 /**
  * @group canonical
  * @covers ::bbp_create_initial_content
  */
 public function test_bbp_create_initial_content()
 {
     $category_id = $this->factory->forum->create(array('forum_meta' => array('_bbp_forum_type' => 'category', '_bbp_status' => 'open')));
     bbp_create_initial_content(array('forum_parent' => $category_id));
     $forum_id = bbp_forum_query_subforum_ids($category_id);
     $forum_id = (int) $forum_id[0];
     $topic_id = bbp_get_forum_last_topic_id($forum_id);
     $reply_id = bbp_get_forum_last_reply_id($forum_id);
     // Forum post
     $this->assertSame('General', bbp_get_forum_title($forum_id));
     $this->assertSame('General chit-chat', bbp_get_forum_content($forum_id));
     $this->assertSame('open', bbp_get_forum_status($forum_id));
     $this->assertTrue(bbp_is_forum_public($forum_id));
     $this->assertSame($category_id, bbp_get_forum_parent_id($forum_id));
     // Topic post
     $this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame('Hello World!', bbp_get_topic_title($topic_id));
     remove_all_filters('bbp_get_topic_content');
     $topic_content = "I am the first topic in your new forums.";
     $this->assertSame($topic_content, bbp_get_topic_content($topic_id));
     $this->assertSame('publish', bbp_get_topic_status($topic_id));
     $this->assertTrue(bbp_is_topic_published($topic_id));
     // Reply post
     $this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_reply_title($reply_id));
     $this->assertSame($reply_id, bbp_get_reply_title_fallback($reply_id));
     remove_all_filters('bbp_get_reply_content');
     $reply_content = "Oh, and this is what a reply looks like.";
     $this->assertSame($reply_content, bbp_get_reply_content($reply_id));
     $this->assertSame('publish', bbp_get_reply_status($reply_id));
     $this->assertTrue(bbp_is_reply_published($reply_id));
     // Category meta
     $this->assertSame(1, bbp_get_forum_subforum_count($category_id, true));
     $this->assertSame(0, bbp_get_forum_topic_count($category_id, false, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($category_id, true));
     $this->assertSame(0, bbp_get_forum_reply_count($category_id, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($category_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($category_id, true, true));
     $this->assertSame(0, bbp_get_forum_post_count($category_id, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($category_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($category_id));
     $this->assertSame('Hello World!', bbp_get_forum_last_topic_title($category_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($category_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($category_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($category_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($category_id));
     // Forum meta
     $this->assertSame(0, bbp_get_forum_subforum_count($forum_id, true));
     $this->assertSame(1, bbp_get_forum_topic_count($forum_id, false, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($forum_id, true));
     $this->assertSame(1, bbp_get_forum_reply_count($forum_id, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($forum_id, true, true));
     $this->assertSame(2, bbp_get_forum_post_count($forum_id, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($forum_id));
     $this->assertSame('Hello World!', bbp_get_forum_last_topic_title($forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($forum_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($forum_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($forum_id));
     // Topic meta
     $this->assertSame('127.0.0.1', bbp_current_author_ip($topic_id));
     $this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
     $this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
     $this->assertSame(0, bbp_get_topic_reply_count_hidden($topic_id, true));
     $this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_topic_last_active_time($topic_id));
     // Reply Meta
     $this->assertSame('127.0.0.1', bbp_current_author_ip($reply_id));
     $this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
 }
Example #11
0
 /**
  * Map a reply permalink to its group forum
  *
  * @since bbPress (r3802)
  * @param string $url
  * @param int $reply_id
  * @uses maybe_map_permalink_to_group()
  * @return string
  */
 public function map_reply_permalink_to_group($url, $reply_id)
 {
     return $this->maybe_map_permalink_to_group(bbp_get_reply_topic_id($reply_id), $url);
 }
Example #12
0
/**
 * Reply metabox
 *
 * The metabox that holds all of the additional reply information
 *
 * @since bbPress (r2464)
 *
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses do_action() Calls 'bbp_reply_metabox'
 */
function bbp_reply_metabox()
{
    // Post ID
    $post_id = get_the_ID();
    // Get some meta
    $reply_topic_id = bbp_get_reply_topic_id($post_id);
    $reply_forum_id = bbp_get_reply_forum_id($post_id);
    $reply_to = bbp_get_reply_to($post_id);
    // Allow individual manipulation of reply forum
    if (current_user_can('edit_others_replies') || current_user_can('moderate')) {
        ?>

		<p>
			<strong class="label"><?php 
        esc_html_e('Forum:', 'bbpress');
        ?>
</strong>
			<label class="screen-reader-text" for="bbp_forum_id"><?php 
        esc_html_e('Forum', 'bbpress');
        ?>
</label>
			<?php 
        bbp_dropdown(array('post_type' => bbp_get_forum_post_type(), 'selected' => $reply_forum_id, 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'walker' => '', 'exclude' => '', 'select_id' => 'bbp_forum_id', 'tab' => bbp_get_tab_index(), 'options_only' => false, 'show_none' => __('&mdash; No parent &mdash;', 'bbpress'), 'disable_categories' => current_user_can('edit_forums'), 'disabled' => ''));
        ?>
		</p>

	<?php 
    }
    ?>

	<p>
		<strong class="label"><?php 
    esc_html_e('Topic:', 'bbpress');
    ?>
</strong>
		<label class="screen-reader-text" for="parent_id"><?php 
    esc_html_e('Topic', 'bbpress');
    ?>
</label>
		<input name="parent_id" id="bbp_topic_id" type="text" value="<?php 
    echo esc_attr($reply_topic_id);
    ?>
" />
	</p>

	<p>
		<strong class="label"><?php 
    esc_html_e('Reply To:', 'bbpress');
    ?>
</strong>
		<label class="screen-reader-text" for="bbp_reply_to"><?php 
    esc_html_e('Reply To', 'bbpress');
    ?>
</label>
		<input name="bbp_reply_to" id="bbp_reply_to" type="text" value="<?php 
    echo esc_attr($reply_to);
    ?>
" />
	</p>

	<input name="ping_status" type="hidden" id="ping_status" value="open" />

	<?php 
    wp_nonce_field('bbp_reply_metabox_save', 'bbp_reply_metabox');
    do_action('bbp_reply_metabox', $post_id);
}
Example #13
0
/**
 * Adjust the total anonymous reply count of a topic
 *
 * @since 2.0.0 bbPress (r2567)
 *
 * @param int $topic_id Optional. Topic id to update
 * @uses bbp_is_reply() To check if the passed topic id is a reply
 * @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_topic_id() To get the reply topic id
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses wpdb::prepare() To prepare our sql query
 * @uses wpdb::get_var() To execute our query and get the column back
 * @uses update_post_meta() To update the topic anonymous reply count meta
 * @uses apply_filters() Calls 'bbp_update_topic_anonymous_reply_count' with the
 *                        anonymous reply count and topic id
 * @return int Anonymous reply count
 */
function bbp_update_topic_anonymous_reply_count($topic_id = 0)
{
    // If it's a reply, then get the parent (topic id)
    if (bbp_is_reply($topic_id)) {
        $topic_id = bbp_get_reply_topic_id($topic_id);
    } elseif (bbp_is_topic($topic_id)) {
        $topic_id = bbp_get_topic_id($topic_id);
    } else {
        return;
    }
    // Query the DB to get anonymous replies in this topic
    $bbp_db = bbp_db();
    $query = $bbp_db->prepare("SELECT COUNT( ID ) FROM {$bbp_db->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type());
    $replies = (int) $bbp_db->get_var($query);
    update_post_meta($topic_id, '_bbp_anonymous_reply_count', $replies);
    return (int) apply_filters('bbp_update_topic_anonymous_reply_count', $replies, $topic_id);
}
Example #14
0
 /**
  * @covers ::bbp_reply_topic_id
  * @covers ::bbp_get_reply_topic_id
  */
 public function test_bbp_get_reply_topic_id()
 {
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     $reply_topic_id = bbp_get_reply_topic_id($r);
     $this->assertSame($t, $reply_topic_id);
 }
Example #15
0
 /**
  * @covers ::bbp_move_topic_handler
  */
 public function test_bbp_move_topic_handler()
 {
     $old_current_user = 0;
     $this->old_current_user = get_current_user_id();
     $this->set_current_user($this->factory->user->create(array('role' => 'administrator')));
     $this->keymaster_id = get_current_user_id();
     bbp_set_user_role($this->keymaster_id, bbp_get_keymaster_role());
     $old_forum_id = $this->factory->forum->create();
     $topic_id = $this->factory->topic->create(array('post_parent' => $old_forum_id, 'topic_meta' => array('forum_id' => $old_forum_id)));
     $reply_id = $this->factory->reply->create(array('post_parent' => $topic_id, 'reply_meta' => array('forum_id' => $old_forum_id, 'topic_id' => $topic_id)));
     // Topic post parent
     $topic_parent = wp_get_post_parent_id($topic_id);
     $this->assertSame($old_forum_id, $topic_parent);
     // Forum meta
     $this->assertSame(1, bbp_get_forum_topic_count($old_forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($old_forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($old_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($old_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($old_forum_id));
     // Topic meta
     $this->assertSame($old_forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
     $this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
     $this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     // Reply Meta
     $this->assertSame($old_forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
     // Create a new forum
     $new_forum_id = $this->factory->forum->create();
     // Move the topic into the new forum
     bbp_move_topic_handler($topic_id, $old_forum_id, $new_forum_id);
     // Topic post parent
     $topic_parent = wp_get_post_parent_id($topic_id);
     $this->assertSame($new_forum_id, $topic_parent);
     // Forum meta
     $this->assertSame(1, bbp_get_forum_topic_count($new_forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($new_forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($new_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($new_forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($new_forum_id));
     // Topic meta
     $this->assertSame($new_forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
     $this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
     $this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     // Reply Meta
     $this->assertSame($new_forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
     // Retore the user
     $this->set_current_user($this->old_current_user);
 }
Example #16
0
/**
 * Reply metabox
 *
 * The metabox that holds all of the additional reply information
 *
 * @since 2.0.0 bbPress (r2464)
 *
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses do_action() Calls 'bbp_reply_metabox'
 */
function bbp_reply_metabox()
{
    // Post ID
    $post_id = get_the_ID();
    $status = get_post_status($post_id);
    // Get some meta
    $reply_topic_id = bbp_get_reply_topic_id($post_id);
    $reply_forum_id = bbp_get_reply_forum_id($post_id);
    $topic_forum_id = bbp_get_topic_forum_id($reply_topic_id);
    /** Status ****************************************************************/
    ?>

	<p>
		<strong class="label"><?php 
    esc_html_e('Status:', 'bbpress');
    ?>
</strong>
		<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php 
    echo esc_attr('auto-draft' === $status ? 'draft' : $status);
    ?>
" />
		<label class="screen-reader-text" for="post_status"><?php 
    esc_html_e('Select what status to give the reply.', 'bbpress');
    ?>
</label>
		<?php 
    bbp_form_reply_status_dropdown(array('select_id' => 'post_status', 'reply_id' => $post_id));
    ?>
	</p>

	<hr />

	<?php 
    /** Forum *****************************************************************/
    // Only allow individual manipulation of reply forum if there is a mismatch
    if ($reply_forum_id !== $topic_forum_id && (current_user_can('edit_others_replies') || current_user_can('moderate'))) {
        ?>

		<p>
			<strong class="label"><?php 
        esc_html_e('Forum:', 'bbpress');
        ?>
</strong>
			<label class="screen-reader-text" for="bbp_forum_id"><?php 
        esc_html_e('Forum', 'bbpress');
        ?>
</label>
			<?php 
        bbp_dropdown(array('post_type' => bbp_get_forum_post_type(), 'selected' => $reply_forum_id, 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC', 'walker' => '', 'exclude' => '', 'select_id' => 'bbp_forum_id', 'options_only' => false, 'show_none' => __('&mdash; No reply &mdash;', 'bbpress'), 'disable_categories' => current_user_can('edit_forums'), 'disabled' => ''));
        ?>
		</p>

	<?php 
    }
    /** Topic *****************************************************************/
    ?>

	<p>
		<strong class="label"><?php 
    esc_html_e('Topic:', 'bbpress');
    ?>
</strong>
		<label class="screen-reader-text" for="parent_id"><?php 
    esc_html_e('Topic', 'bbpress');
    ?>
</label>
		<input name="parent_id" id="bbp_topic_id" type="text" value="<?php 
    echo esc_attr($reply_topic_id);
    ?>
" data-ajax-url="<?php 
    echo esc_url(wp_nonce_url(add_query_arg(array('action' => 'bbp_suggest_topic'), admin_url('admin-ajax.php', 'relative')), 'bbp_suggest_topic_nonce'));
    ?>
" />
	</p>

	<?php 
    /** Reply To **************************************************************/
    ?>

	<p>
		<strong class="label"><?php 
    esc_html_e('Reply To:', 'bbpress');
    ?>
</strong>
		<label class="screen-reader-text" for="bbp_reply_to"><?php 
    esc_html_e('Reply To', 'bbpress');
    ?>
</label>
		<?php 
    bbp_reply_to_dropdown($post_id);
    ?>
	</p>

	<input name="ping_status" type="hidden" id="ping_status" value="open" />

	<?php 
    wp_nonce_field('bbp_reply_metabox_save', 'bbp_reply_metabox');
    do_action('bbp_reply_metabox', $post_id);
}
Example #17
0
 /**
  * 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);
     }
 }
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $item = array();
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        $item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
    }
    if (bbp_is_forum_archive()) {
        $item[] = bbp_get_forum_archive_title();
    } elseif (bbp_is_topic_archive()) {
        $item[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_single_view()) {
        $item[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        $topic_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
        } else {
            $item[] = bbp_get_topic_title($topic_id);
        }
        if (bbp_is_topic_split()) {
            $item[] = __('Split', 'theme_front');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'theme_front');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
        if (!bbp_is_reply_edit()) {
            $item[] = bbp_get_reply_title($reply_id);
        } else {
            $item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
            $item[] = __('Edit', 'theme_front');
        }
    } elseif (bbp_is_single_forum()) {
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent($forum_id);
        if (0 !== $forum_parent_id) {
            $item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
        }
        $item[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
            $item[] = __('Edit');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
							<?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>
/**
 * Return value of topic tags field
 *
 * @since bbPress (r2976)
 *
 * @uses bbp_is_topic_edit() To check if it's the topic edit page
 * @uses apply_filters() Calls 'bbp_get_form_topic_tags' with the tags
 * @return string Value of topic tags field
 */
function bbp_get_form_topic_tags()
{
    // Get _POST data
    if (bbp_is_post_request() && isset($_POST['bbp_topic_tags'])) {
        $topic_tags = $_POST['bbp_topic_tags'];
        // Get edit data
    } elseif (bbp_is_single_topic() || bbp_is_single_reply() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
        // Determine the topic id based on the post type
        switch (get_post_type()) {
            // Post is a topic
            case bbp_get_topic_post_type():
                $topic_id = get_the_ID();
                break;
                // Post is a reply
            // Post is a reply
            case bbp_get_reply_post_type():
                $topic_id = bbp_get_reply_topic_id(get_the_ID());
                break;
        }
        // Topic exists
        if (!empty($topic_id)) {
            // Topic is spammed so display pre-spam terms
            if (bbp_is_topic_spam($topic_id)) {
                // Get pre-spam terms
                $new_terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
                // If terms exist, explode them and compile the return value
                if (empty($new_terms)) {
                    $new_terms = '';
                }
                // Topic is not spam so get real terms
            } else {
                $terms = array_filter((array) get_the_terms($topic_id, bbp_get_topic_tag_tax_id()));
                // Loop through them
                foreach ($terms as $term) {
                    $new_terms[] = $term->name;
                }
            }
            // Define local variable(s)
        } else {
            $new_terms = '';
        }
        // Set the return value
        $topic_tags = !empty($new_terms) ? implode(', ', $new_terms) : '';
        // No data
    } else {
        $topic_tags = '';
    }
    return apply_filters('bbp_get_form_topic_tags', esc_attr($topic_tags));
}
Example #21
0
 protected function _bbpress_items()
 {
     $item = array();
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $item[] = '<span typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '"  property="v:title" rel="v:url"><span>' . bbp_get_forum_archive_title() . '</span></a></span>';
     }
     if (bbp_is_forum_archive()) {
         $item[] = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $item[] = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $item[] = bbp_get_view_title();
     } elseif (bbp_is_single_topic()) {
         $topic_id = get_queried_object_id();
         $item = array_merge($item, $this->_get_parents(bbp_get_topic_forum_id($topic_id)));
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '"  property="v:title" rel="v:url"><span>' . bbp_get_topic_title($topic_id) . '</span></a></span>';
         } else {
             $item[] = bbp_get_topic_title($topic_id);
         }
         if (bbp_is_topic_split()) {
             $item[] = __('Split', DH_DOMAIN);
         } elseif (bbp_is_topic_merge()) {
             $item[] = __('Merge', DH_DOMAIN);
         } elseif (bbp_is_topic_edit()) {
             $item[] = __('Edit', DH_DOMAIN);
         }
     } elseif (bbp_is_single_reply()) {
         $reply_id = get_queried_object_id();
         $item = array_merge($item, $this->_get_parents(bbp_get_reply_topic_id($reply_id)));
         if (!bbp_is_reply_edit()) {
             $item[] = bbp_get_reply_title($reply_id);
         } else {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '"  property="v:title" rel="v:url"><span>' . bbp_get_reply_title($reply_id) . '</span></a></span>';
             $item[] = __('Edit', DH_DOMAIN);
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         if (0 !== $forum_parent_id) {
             $item = array_merge($item, $this->_get_parents($forum_parent_id));
         }
         $item[] = bbp_get_forum_title($forum_id);
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $item[] = '<span typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '"  property="v:title" rel="v:url" ><span>' . bbp_get_displayed_user_field('display_name') . '</span></a></span>';
             $item[] = __('Edit', DH_DOMAIN);
         } else {
             $item[] = bbp_get_displayed_user_field('display_name');
         }
     }
     return $item;
 }
Example #22
0
/**
 * Return a select box allowing to pick which topic/reply a reply belongs.
 *
 * @since 2.6.0 bbPress (r5387)
 *
 * @param int $reply_id
 *
 * @uses BBP_Reply_Walker_Dropdown() As the default walker to generate the
 *                                   dropdown
 * @uses current_user_can()          To check if the current user can read
 *                                   private forums
 * @uses bbp_get_reply_id()          To get the reply ID
 * @uses bbp_get_reply_to()          To get the reply to ID
 * @uses bbp_get_reply_topic_id()    To get the replies topic ID
 * @uses bbp_get_reply_post_type()   To get the reply post type
 * @uses bbp_get_public_status_id()  To get the reply status
 * @uses bbp_thread_replies_depth()  To get the threaded replies depth
 *
 * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown
 *                        and args
 * @return string The dropdown
 */
function bbp_get_reply_to_dropdown($reply_id = 0)
{
    // Validate the reply data
    $reply_id = bbp_get_reply_id($reply_id);
    $reply_to = bbp_get_reply_to($reply_id);
    $topic_id = bbp_get_reply_topic_id($reply_id);
    // Get the replies
    $posts = get_posts(array('post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'post_parent' => $topic_id, 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC'));
    // Append `reply_to` for each reply so it can be walked
    foreach ($posts as &$post) {
        // Check for reply post type
        $_reply_to = bbp_get_reply_to($post->ID);
        // Make sure it's a reply to a reply
        if (empty($_reply_to) || $topic_id === $_reply_to) {
            $_reply_to = 0;
        }
        // Add reply_to to the post object so we can walk it later
        $post->reply_to = $_reply_to;
    }
    // Get the dropdown and return it
    $retval = bbp_get_dropdown(array('show_none' => sprintf(esc_attr__('%1$s - %2$s', 'bbpress'), $topic_id, bbp_get_topic_title($topic_id)), 'select_id' => 'bbp_reply_to', 'select_class' => 'bbp_dropdown', 'exclude' => $reply_id, 'selected' => $reply_to, 'post_parent' => $topic_id, 'post_type' => bbp_get_reply_post_type(), 'max_depth' => bbp_thread_replies_depth(), 'page' => 1, 'per_page' => -1, 'walker' => new BBP_Walker_Reply_Dropdown(), 'posts' => $posts));
    // Filter and return
    return apply_filters('bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id);
}
Example #23
0
/**
 * 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;
}
Example #24
0
/**
 * Gets the items for the breadcrumb item if bbPress is installed.
 *
 * @since 0.4
 *
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the item.
 */
function breadcrumbs_plus_get_bbpress_items($args = array())
{
    $item = array();
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        if (function_exists('bp_is_active')) {
            global $bp;
            // we're outside the loop!
            // Assign some variables here
            $page1 = isset($bp->members->root_slug) ? $bp->members->root_slug : '';
            // slug for the Members page. The BuddyPress default is 'members'.
            $page2 = isset($bp->groups->root_slug) ? $bp->groups->root_slug : '';
            // slug for the Groups page. The BuddyPress default is 'groups'.
            $page3 = isset($bp->activity->root_slug) ? $bp->activity->root_slug : '';
            // slug for the Activity page. The BuddyPress default is 'activity'.
            $page4 = isset($bp->forums->root_slug) ? $bp->forums->root_slug : '';
            // slug for the Forums page. The BuddyPress default is 'forums'.
            $page5 = isset($bp->achievements->root_slug) ? $bp->achievements->root_slug : '';
            // slug for the Achievements page. The BuddyPress default is 'achievements'.
            if (!bp_is_blog_page() && (is_page() || is_page($page1) || is_page($page2) || is_page($page3) || is_page($page4) || is_page($page5)) && !bp_is_user() && !bp_is_single_item() && !bp_is_register_page()) {
                $item[] = '';
            }
            if (bp_is_user() && !bp_is_register_page()) {
                $item[] = '';
            }
        } else {
            //$item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
        }
    }
    if (bbp_is_forum_archive()) {
        $item[] = bbp_get_forum_archive_title();
    } else {
        $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '" rel="v:url" property="v:title">' . bbp_get_forum_archive_title() . '</a></div>';
    }
    if (bbp_is_topic_archive()) {
        $item[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_single_view()) {
        $item[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        $topic_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_topic_forum_id($topic_id)));
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_topic_permalink($topic_id) . '" rel="v:url" property="v:title">' . bbp_get_topic_title($topic_id) . '</a></div>';
        } else {
            $item[] = '';
        }
        if (bbp_is_topic_split()) {
            $item[] = __('Split', 'framework');
        } elseif (bbp_is_topic_merge()) {
            $item[] = __('Merge', 'framework');
        } elseif (bbp_is_topic_edit()) {
            $item[] = __('Edit', 'framework');
        }
    } elseif (bbp_is_single_reply()) {
        $reply_id = get_queried_object_id();
        $item = array_merge($item, breadcrumbs_plus_get_parents(bbp_get_reply_topic_id($reply_id)));
        if (!bbp_is_reply_edit()) {
            $item[] = bbp_get_reply_title($reply_id);
        } else {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_reply_url($reply_id) . '" rel="v:url" property="v:title">' . bbp_get_reply_title($reply_id) . '</a></div>';
            $item[] = __('Edit', 'framework');
        }
    } elseif (bbp_is_single_forum()) {
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent_id($forum_id);
        if (0 !== $forum_parent_id) {
            $item = array_merge($item, breadcrumbs_plus_get_parents($forum_parent_id));
        }
        $item[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $item[] = '<div class="vbreadcrumb" typeof="v:Breadcrumb"><a href="' . bbp_get_user_profile_url() . '" rel="v:url" property="v:title">' . bbp_get_displayed_user_field('display_name') . '</a></div>';
            $item[] = __('Edit', 'framework');
        } else {
            $item[] = bbp_get_displayed_user_field('display_name');
        }
    }
    return apply_filters('breadcrumbs_plus_get_bbpress_items', $item, $args);
}
			<div class="bbp-meta">
				<a href="<?php 
bbp_reply_url();
?>
" class="bbp-reply-permalink">#<?php 
bbp_reply_id();
?>
</a>
				<span class="bbp-reply-to"><?php 
_e('In reply to: ', 'bbpress');
?>
				<a class="bbp-topic-permalink" href="<?php 
bbp_topic_permalink(bbp_get_reply_topic_id());
?>
"><?php 
bbp_topic_title(bbp_get_reply_topic_id());
?>
</a> | </span>
			</div>
		</div>

		<div class="bbp-reply-entry">

		<?php 
do_action('bbp_theme_before_reply_content');
?>

		<?php 
bbp_reply_content();
?>
Example #26
0
 function mk_theme_breadcrumbs()
 {
     global $mk_options, $post;
     $post_id = global_get_post_id();
     if ($post_id) {
         $local_skining = get_post_meta($post_id, '_enable_local_backgrounds', true);
         $breadcrumb_skin = get_post_meta($post_id, '_breadcrumb_skin', true);
         if ($local_skining == 'true' && !empty($breadcrumb_skin)) {
             $breadcrumb_skin_class = $breadcrumb_skin;
         } else {
             $breadcrumb_skin_class = $mk_options['breadcrumb_skin'];
         }
     } else {
         $breadcrumb_skin_class = $mk_options['breadcrumb_skin'];
     }
     $delimiter = ' &#47; ';
     echo '<div id="mk-breadcrumbs"><div class="mk-breadcrumbs-inner ' . $breadcrumb_skin_class . '-skin">';
     if (!is_front_page()) {
         echo '<a href="';
         echo home_url();
         echo '">' . __('Home', 'mk_framework');
         echo "</a>" . $delimiter;
     }
     if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
         $shop_page_id = wc_get_page_id('shop');
         $shop_page = get_post($shop_page_id);
         $permalinks = get_option('woocommerce_permalinks');
         if ($shop_page_id && $shop_page && get_option('page_on_front') !== $shop_page_id) {
             echo '<a href="' . get_permalink($shop_page) . '">' . $shop_page->post_title . '</a> ';
         }
     }
     if (is_category() && !is_singular('portfolio')) {
         $category = get_the_category();
         $ID = $category[0]->cat_ID;
         echo is_wp_error($cat_parents = get_category_parents($ID, TRUE, '', FALSE)) ? '' : '<span>' . $cat_parents . '</span>';
     } else {
         if (is_singular('news')) {
             echo '<span>' . get_the_title() . '</span>';
         } else {
             if (is_single() && !is_attachment()) {
                 if (get_post_type() == 'product') {
                     if ($terms = wc_get_product_terms($post->ID, 'product_cat', array('orderby' => 'parent', 'order' => 'DESC'))) {
                         $main_term = $terms[0];
                         $ancestors = get_ancestors($main_term->term_id, 'product_cat');
                         $ancestors = array_reverse($ancestors);
                         foreach ($ancestors as $ancestor) {
                             $ancestor = get_term($ancestor, 'product_cat');
                             if (!is_wp_error($ancestor) && $ancestor) {
                                 echo '<a href="' . get_term_link($ancestor->slug, 'product_cat') . '">' . $ancestor->name . '</a>' . $delimiter;
                             }
                         }
                         echo '<a href="' . get_term_link($main_term->slug, 'product_cat') . '">' . $main_term->name . '</a>' . $delimiter;
                     }
                     echo get_the_title();
                 } elseif (is_singular('portfolio')) {
                     $portfolio_category = get_the_term_list($post->ID, 'portfolio_category', '', ' / ');
                     if (!empty($portfolio_category)) {
                         echo $portfolio_category . $delimiter;
                     }
                     echo '<span>' . get_the_title() . '</span>';
                 } elseif (get_post_type() != 'post') {
                     if (function_exists('is_bbpress') && is_bbpress()) {
                     } else {
                         $post_type = get_post_type_object(get_post_type());
                         $slug = $post_type->rewrite;
                         echo '<a href="' . get_post_type_archive_link(get_post_type()) . '">' . $post_type->labels->singular_name . '</a>' . $delimiter;
                         echo get_the_title();
                     }
                 } else {
                     $cat = current(get_the_category());
                     echo get_category_parents($cat, true, $delimiter);
                     echo get_the_title();
                 }
             } elseif (is_page() && !$post->post_parent) {
                 echo get_the_title();
             } elseif (is_page() && $post->post_parent) {
                 $parent_id = $post->post_parent;
                 $breadcrumbs = array();
                 while ($parent_id) {
                     $page = get_page($parent_id);
                     $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
                     $parent_id = $page->post_parent;
                 }
                 $breadcrumbs = array_reverse($breadcrumbs);
                 foreach ($breadcrumbs as $crumb) {
                     echo $crumb . '' . $delimiter;
                 }
                 echo get_the_title();
             } elseif (is_attachment()) {
                 $parent = get_post($post->post_parent);
                 $cat = get_the_category($parent->ID);
                 $cat = $cat[0];
                 /* admin@innodron.com patch:
                 			   Fix for Catchable fatal error: Object of class WP_Error could not be converted to string
                 			   ref: https://wordpress.org/support/topic/catchable-fatal-error-object-of-class-wp_error-could-not-be-converted-to-string-11
                 			*/
                 echo is_wp_error($cat_parents = get_category_parents($cat, TRUE, '' . $delimiter . '')) ? '' : $cat_parents;
                 /* end admin@innodron.com patch */
                 echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>' . $delimiter;
                 echo get_the_title();
             } elseif (is_search()) {
                 echo __('Search results for &ldquo;', 'mk_framework') . get_search_query() . '&rdquo;';
             } elseif (is_tag()) {
                 echo __('Tag &ldquo;', 'mk_framework') . single_tag_title('', false) . '&rdquo;';
             } elseif (is_author()) {
                 $userdata = get_userdata(get_the_author_meta('ID'));
                 echo __('Author:', 'mk_framework') . ' ' . $userdata->display_name;
             } elseif (is_day()) {
                 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
                 echo '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a>' . $delimiter;
                 echo get_the_time('d');
             } elseif (is_month()) {
                 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a>' . $delimiter;
                 echo get_the_time('F');
             } elseif (is_year()) {
                 echo get_the_time('Y');
             }
         }
     }
     if (get_query_var('paged')) {
         echo ' (' . __('Page', 'mk_framework') . ' ' . get_query_var('paged') . ')';
     }
     if (is_tax()) {
         $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
         if (function_exists('is_woocommerce') && is_woocommerce() && is_archive()) {
             echo $delimiter;
         }
         echo '<span>' . $term->name . '</span>';
     }
     if (function_exists('is_bbpress') && is_bbpress()) {
         $item = array();
         $post_type_object = get_post_type_object(bbp_get_forum_post_type());
         if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
             $item[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
         }
         if (bbp_is_forum_archive()) {
             $item[] = bbp_get_forum_archive_title();
         } elseif (bbp_is_topic_archive()) {
             $item[] = bbp_get_topic_archive_title();
         } elseif (bbp_is_single_view()) {
             $item[] = bbp_get_view_title();
         } elseif (bbp_is_single_topic()) {
             $topic_id = get_queried_object_id();
             $item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_topic_forum_id($topic_id)));
             if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
                 $item[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
             } else {
                 $item[] = bbp_get_topic_title($topic_id);
             }
             if (bbp_is_topic_split()) {
                 $item[] = __('Split', 'mk_framework');
             } elseif (bbp_is_topic_merge()) {
                 $item[] = __('Merge', 'mk_framework');
             } elseif (bbp_is_topic_edit()) {
                 $item[] = __('Edit', 'mk_framework');
             }
         } elseif (bbp_is_single_reply()) {
             $reply_id = get_queried_object_id();
             $item = array_merge($item, mk_breadcrumbs_get_parents(bbp_get_reply_topic_id($reply_id)));
             if (!bbp_is_reply_edit()) {
                 $item[] = bbp_get_reply_title($reply_id);
             } else {
                 $item[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
                 $item[] = __('Edit', 'mk_framework');
             }
         } elseif (bbp_is_single_forum()) {
             $forum_id = get_queried_object_id();
             $forum_parent_id = bbp_get_forum_parent_id($forum_id);
             if (0 !== $forum_parent_id) {
                 $item = array_merge($item, mk_breadcrumbs_get_parents($forum_parent_id));
             }
             $item[] = bbp_get_forum_title($forum_id);
         } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
             if (bbp_is_single_user_edit()) {
                 $item[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
                 $item[] = __('Edit', 'mk_framework');
             } else {
                 $item[] = bbp_get_displayed_user_field('display_name');
             }
         }
         echo implode($delimiter, $item);
     }
     echo "</div></div>";
 }
Example #27
0
 /**
  * Custom user feedback messages for reply post type
  *
  * @since 2.0.0 bbPress (r3080)
  *
  * @global int $post_ID
  * @uses bbp_get_topic_permalink()
  * @uses wp_post_revision_title()
  * @uses esc_url()
  * @uses add_query_arg()
  *
  * @param array $messages
  *
  * @return array
  */
 public function updated_messages($messages)
 {
     global $post_ID;
     if ($this->bail()) {
         return $messages;
     }
     // URL for the current topic
     $topic_url = bbp_get_topic_permalink(bbp_get_reply_topic_id($post_ID));
     // Current reply's post_date
     $post_date = bbp_get_global_post_field('post_date', 'raw');
     // Messages array
     $messages[$this->post_type] = array(0 => '', 1 => sprintf(__('Reply updated. <a href="%s">View topic</a>', 'bbpress'), $topic_url), 2 => __('Custom field updated.', 'bbpress'), 3 => __('Custom field deleted.', 'bbpress'), 4 => __('Reply updated.', 'bbpress'), 5 => isset($_GET['revision']) ? sprintf(__('Reply restored to revision from %s', 'bbpress'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Reply created. <a href="%s">View topic</a>', 'bbpress'), $topic_url), 7 => __('Reply saved.', 'bbpress'), 8 => sprintf(__('Reply submitted. <a target="_blank" href="%s">Preview topic</a>', 'bbpress'), esc_url(add_query_arg('preview', 'true', $topic_url))), 9 => sprintf(__('Reply scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview topic</a>', 'bbpress'), date_i18n(__('M j, Y @ G:i', 'bbpress'), strtotime($post_date)), $topic_url), 10 => sprintf(__('Reply draft updated. <a target="_blank" href="%s">Preview topic</a>', 'bbpress'), esc_url(add_query_arg('preview', 'true', $topic_url))));
     return $messages;
 }
Example #28
0
 function cupid_breadcrumb_get_bbpress_items()
 {
     $item = array();
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a></li>';
     }
     if (bbp_is_forum_archive()) {
         $item['last'] = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $item['last'] = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $item['last'] = bbp_get_view_title();
     } elseif (bbp_is_single_topic()) {
         $topic_id = get_queried_object_id();
         $item = array_merge($item, cupid_breadcrumb_get_parents(bbp_get_topic_forum_id($topic_id)));
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a></li>';
         } else {
             $item['last'] = bbp_get_topic_title($topic_id);
         }
         if (bbp_is_topic_split()) {
             $item['last'] = __('Split', 'cupid');
         } elseif (bbp_is_topic_merge()) {
             $item['last'] = __('Merge', 'cupid');
         } elseif (bbp_is_topic_edit()) {
             $item['last'] = __('Edit', 'cupid');
         }
     } elseif (bbp_is_single_reply()) {
         $reply_id = get_queried_object_id();
         $item = array_merge($item, cupid_breadcrumb_get_parents(bbp_get_reply_topic_id($reply_id)));
         if (!bbp_is_reply_edit()) {
             $item['last'] = bbp_get_reply_title($reply_id);
         } else {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a></li>';
             $item['last'] = __('Edit', 'cupid');
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         if (0 !== $forum_parent_id) {
             $item = array_merge($item, cupid_breadcrumb_get_parents($forum_parent_id));
         }
         $item['last'] = bbp_get_forum_title($forum_id);
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $item[] = '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a></li>';
             $item['last'] = __('Edit', 'cupid');
         } else {
             $item['last'] = bbp_get_displayed_user_field('display_name');
         }
     }
     return apply_filters('cupid_breadcrumb_get_bbpress_items', $item);
 }
							<?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>
Example #30
0
/**
 * Display nested subforums with a hierarchical structure using their parent category
 * @version 2.0
 */
function apoc_loop_subforums()
{
    // Exclude private forums
    $private = apoc_private_forum_ids();
    // Check for subforums
    $subs = bbp_forum_get_subforums(array('post__not_in' => $private));
    if (empty($subs)) {
        return;
    }
    // Buffer output
    ob_start();
    // Print a header
    ?>
	<header class="forum-header">
		<div class="forum-content"><h2><?php 
    bbp_forum_title();
    ?>
</h2></div>
		<div class="forum-count">Topics</div>
		<div class="forum-freshness">Latest Post</div>
	</header>
	<ol class="forums category <?php 
    bbp_forum_status();
    ?>
"><?php 
    // Loop over forums
    foreach ($subs as $count => $sub) {
        // Get forum details
        $sub_id = $sub->ID;
        $title = $sub->post_title;
        $desc = $sub->post_content;
        $permalink = bbp_get_forum_permalink($sub_id);
        // Get topic counts
        $topics = bbp_get_forum_topic_count($sub_id, false);
        // Get the most recent reply and its topic
        $reply_id = bbp_get_forum_last_reply_id($sub_id);
        $topic_id = bbp_is_reply($reply_id) ? bbp_get_reply_topic_id($reply_id) : $reply_id;
        $topic_title = bbp_get_topic_title($topic_id);
        $link = bbp_get_reply_url($reply_id);
        // Get the author avatar
        $user_id = bbp_get_reply_author_id($reply_id);
        $avatar = apoc_get_avatar(array('user_id' => $user_id, 'link' => true, 'size' => 50));
        // Toggle html class
        $class = $count % 2 ? 'odd' : 'even';
        // Print output
        ?>
		<li id="forum-<?php 
        echo $sub_id;
        ?>
" class="forum <?php 
        echo $class;
        ?>
">
			<div class="forum-content">
				<h3 class="forum-title"><a href="<?php 
        echo $permalink;
        ?>
" title="Browse <?php 
        echo $title;
        ?>
"><?php 
        echo $title;
        ?>
</a></h3>
				<p class="forum-description"><?php 
        echo $desc;
        ?>
</p>
			</div>

			<div class="forum-count">
				<?php 
        echo $topics;
        ?>
			</div>

			<div class="forum-freshness">
				<?php 
        echo $avatar;
        ?>
				<div class="freshest-meta">
					<a class="freshest-title" href="<?php 
        echo $link;
        ?>
" title="<?php 
        echo $topic_title;
        ?>
"><?php 
        echo $topic_title;
        ?>
</a>
					<span class="freshest-author">By <?php 
        bbp_author_link(array('post_id' => $reply_id, 'type' => 'name'));
        ?>
</span>
					<span class="freshest-time"><?php 
        bbp_topic_last_active_time($topic_id);
        ?>
</span>
				</div>
			</div>
		</li>
	<?php 
    }
    ?>
	</ol>
		
	<?php 
    // Retrieve from buffer
    $output = ob_get_contents();
    ob_end_clean();
    echo $output;
}