<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(); ?>
} ?> <?php } ?> <?php do_action('bbp_theme_before_topic_title'); ?> <a class="bbp-topic-permalink" href="<?php bbp_topic_permalink(); ?> "><?php bbp_topic_title(); ?> </a> <?php do_action('bbp_theme_after_topic_title'); ?> <?php bbp_topic_pagination(); ?> <?php do_action('bbp_theme_before_topic_meta'); ?>
/** * Output an RSS2 feed of replies, based on the query passed. * * @since bbPress (r3171) * * @uses bbp_version() * @uses bbp_is_single_topic() * @uses bbp_user_can_view_forum() * @uses bbp_get_topic_forum_id() * @uses bbp_show_load_topic() * @uses bbp_topic_permalink() * @uses bbp_topic_title() * @uses bbp_get_topic_reply_count() * @uses bbp_topic_content() * @uses bbp_has_replies() * @uses bbp_replies() * @uses bbp_the_reply() * @uses bbp_reply_url() * @uses bbp_reply_title() * @uses bbp_reply_content() * @uses get_wp_title_rss() * @uses get_option() * @uses bloginfo_rss * @uses self_link() * @uses the_author() * @uses get_post_time() * @uses rss_enclosure() * @uses do_action() * @uses apply_filters() * * @param array $replies_query */ function bbp_display_replies_feed_rss2($replies_query = array()) { // User cannot access forum this topic is in if (bbp_is_single_topic() && !bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) { return; } // Adjust the title based on context if (bbp_is_single_topic() && bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) { $title = apply_filters('wp_title_rss', get_wp_title_rss(' » ')); } elseif (!bbp_show_lead_topic()) { $title = ' » ' . __('All Posts', 'bbpress'); } else { $title = ' » ' . __('All Replies', 'bbpress'); } // Display the feed header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true); header('Status: 200 OK'); echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>'; ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" <?php do_action('bbp_feed'); ?> > <channel> <title><?php bloginfo_rss('name'); echo $title; ?> </title> <atom:link href="<?php self_link(); ?> " rel="self" type="application/rss+xml" /> <link><?php self_link(); ?> </link> <description><?php // ?> </description> <pubDate><?php echo mysql2date('D, d M Y H:i:s O', current_time('mysql'), false); ?> </pubDate> <generator>http://bbpress.org/?v=<?php bbp_version(); ?> </generator> <language><?php bloginfo_rss('language'); ?> </language> <?php do_action('bbp_feed_head'); ?> <?php if (bbp_is_single_topic()) { ?> <?php if (bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) { ?> <?php if (bbp_show_lead_topic()) { ?> <item> <guid><?php bbp_topic_permalink(); ?> </guid> <title><![CDATA[<?php bbp_topic_title(); ?> ]]></title> <link><?php bbp_topic_permalink(); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?> </pubDate> <dc:creator><?php the_author(); ?> </dc:creator> <description> <![CDATA[ <p><?php printf(__('Replies: %s', 'bbpress'), bbp_get_topic_reply_count()); ?> </p> <?php bbp_topic_content(); ?> ]]> </description> <?php rss_enclosure(); ?> <?php do_action('bbp_feed_item'); ?> </item> <?php } ?> <?php } ?> <?php } ?> <?php if (bbp_has_replies($replies_query)) { ?> <?php while (bbp_replies()) { bbp_the_reply(); ?> <item> <guid><?php bbp_reply_url(); ?> </guid> <title><![CDATA[<?php bbp_reply_title(); ?> ]]></title> <link><?php bbp_reply_url(); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?> </pubDate> <dc:creator><?php the_author(); ?> </dc:creator> <description> <![CDATA[ <?php bbp_reply_content(); ?> ]]> </description> <?php rss_enclosure(); ?> <?php do_action('bbp_feed_item'); ?> </item> <?php } ?> <?php } ?> <?php do_action('bbp_feed_footer'); ?> </channel> </rss> <?php // We're done here exit; }
/** * Output an RSS2 feed of topics, based on the query passed. * * @since bbPress (r3171) * * @uses bbp_version() * @uses bbp_is_single_topic() * @uses bbp_user_can_view_forum() * @uses bbp_get_topic_forum_id() * @uses bbp_show_load_topic() * @uses bbp_topic_permalink() * @uses bbp_topic_title() * @uses bbp_get_topic_reply_count() * @uses bbp_topic_content() * @uses bbp_has_topics() * @uses bbp_topics() * @uses bbp_the_topic() * @uses get_wp_title_rss() * @uses get_option() * @uses bloginfo_rss * @uses self_link() * @uses the_author() * @uses get_post_time() * @uses rss_enclosure() * @uses do_action() * @uses apply_filters() * * @param array $topics_query */ function bbp_display_topics_feed_rss2($topics_query = array()) { // User cannot access this forum if (bbp_is_single_forum() && !bbp_user_can_view_forum(array('forum_id' => bbp_get_forum_id()))) { return; } // Display the feed header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true); header('Status: 200 OK'); echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>'; ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" <?php do_action('bbp_feed'); ?> > <channel> <title><?php bloginfo_rss('name'); ?> » <?php _e('All Topics', 'bbpress'); ?> </title> <atom:link href="<?php self_link(); ?> " rel="self" type="application/rss+xml" /> <link><?php self_link(); ?> </link> <description><?php // ?> </description> <pubDate><?php echo mysql2date('D, d M Y H:i:s O', current_time('mysql'), false); ?> </pubDate> <generator>http://bbpress.org/?v=<?php bbp_version(); ?> </generator> <language><?php bloginfo_rss('language'); ?> </language> <?php do_action('bbp_feed_head'); ?> <?php if (bbp_has_topics($topics_query)) { ?> <?php while (bbp_topics()) { bbp_the_topic(); ?> <item> <guid><?php bbp_topic_permalink(); ?> </guid> <title><![CDATA[<?php bbp_topic_title(); ?> ]]></title> <link><?php bbp_topic_permalink(); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_meta(bbp_get_topic_id(), '_bbp_last_active_time', true)); ?> </pubDate> <dc:creator><?php the_author(); ?> </dc:creator> <?php if (!post_password_required()) { ?> <description> <![CDATA[ <p><?php printf(esc_html__('Replies: %s', 'bbpress'), bbp_get_topic_reply_count()); ?> </p> <?php bbp_topic_content(); ?> ]]> </description> <?php rss_enclosure(); ?> <?php } ?> <?php do_action('bbp_feed_item'); ?> </item> <?php } ?> <?php } ?> <?php do_action('bbp_feed_footer'); ?> </channel> </rss> <?php exit; }
/** * Displays the output, the topic list * * @since bbPress (r2653) * * @param mixed $args * @param array $instance * @uses apply_filters() Calls 'bbp_topic_widget_title' with the title * @uses bbp_topic_permalink() To display the topic permalink * @uses bbp_topic_title() To display the topic title * @uses bbp_get_topic_last_active_time() To get the topic last active * time * @uses bbp_get_topic_id() To get the topic id * @uses bbp_get_topic_reply_count() To get the topic reply count */ public function widget($args, $instance) { extract($args); $title = apply_filters('bbp_topic_widget_title', $instance['title']); $max_shown = !empty($instance['max_shown']) ? (int) $instance['max_shown'] : 5; $show_date = !empty($instance['show_date']) ? 'on' : false; $show_user = !empty($instance['show_user']) ? 'on' : false; $parent_forum = !empty($instance['parent_forum']) ? $instance['parent_forum'] : 'any'; $order_by = !empty($instance['order_by']) ? $instance['order_by'] : false; // How do we want to order our results? switch ($order_by) { // Order by most recent replies case 'freshness': $topics_query = array('author' => 0, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => $max_shown, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'show_stickes' => false, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'meta_query' => array(bbp_exclude_forum_ids('meta_query'))); break; // Order by total number of replies // Order by total number of replies case 'popular': $topics_query = array('author' => 0, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => $max_shown, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'show_stickes' => false, 'meta_key' => '_bbp_reply_count', 'orderby' => 'meta_value', 'order' => 'DESC', 'meta_query' => array(bbp_exclude_forum_ids('meta_query'))); break; // Order by which topic was created most recently // Order by which topic was created most recently case 'newness': default: $topics_query = array('author' => 0, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $parent_forum, 'posts_per_page' => $max_shown, 'post_status' => join(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id())), 'show_stickes' => false, 'order' => 'DESC', 'meta_query' => array(bbp_exclude_forum_ids('meta_query'))); break; } // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_exclude_forums filter and function. $widget_query = new WP_Query($topics_query); // Topics exist if ($widget_query->have_posts()) { echo $before_widget; echo $before_title . $title . $after_title; ?> <ul> <?php while ($widget_query->have_posts()) { $widget_query->the_post(); $topic_id = bbp_get_topic_id($widget_query->post->ID); $author_link = bbp_get_topic_author_link(array('post_id' => $topic_id, 'type' => 'both', 'size' => 14)); ?> <li> <a class="bbp-forum-title" href="<?php bbp_topic_permalink($topic_id); ?> " title="<?php bbp_topic_title($topic_id); ?> "><?php bbp_topic_title($topic_id); ?> </a> <?php if ('on' == $show_user) { ?> <?php printf(_x('by %1$s', 'widgets', 'bbpress'), '<span class="topic-author">' . $author_link . '</span>'); ?> <?php } ?> <?php if ('on' == $show_date) { ?> <div><?php bbp_topic_last_active_time($topic_id); ?> </div> <?php } ?> </li> <?php } ?> </ul> <?php echo $after_widget; // Reset the $post global wp_reset_postdata(); } }
<li class="bboss_search_item bboss_search_item_topic"> <div class="item"> <div class="item-title"><a href="<?php bbp_topic_permalink(get_the_ID()); ?> "><?php bbp_topic_title(get_the_ID()); ?> </a></div> <div class="item-desc"><?php echo buddyboss_global_search_reply_intro(100); ?> </a> </div> </li>
/** * Output the forums for a group in the edit screens * * As of right now, bbPress only supports 1-to-1 group forum relationships. * In the future, many-to-many should be allowed. * * @since bbPress (r3653) * @uses bp_get_current_group_id() * @uses bbp_get_group_forum_ids() * @uses bbp_has_forums() * @uses bbp_get_template_part() */ public function display_forums($offset = 0) { global $wp_query; // Allow actions immediately before group forum output do_action('bbp_before_group_forum_display'); // Load up bbPress once $bbp = bbpress(); /** Query Resets ******************************************************/ // Forum data $forum_action = bp_action_variable($offset); $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id()); $forum_id = array_shift($forum_ids); // Always load up the group forum bbp_has_forums(array('p' => $forum_id, 'post_parent' => null)); // Set the global forum ID $bbp->current_forum_id = $forum_id; // Assume forum query bbp_set_query_name('bbp_single_forum'); ?> <div id="bbpress-forums"> <?php switch ($forum_action) { /** Single Forum **********************************************/ case false: case 'page': // Strip the super stickies from topic query add_filter('bbp_get_super_stickies', array($this, 'no_super_stickies'), 10, 1); // Unset the super sticky option on topic form add_filter('bbp_get_topic_types', array($this, 'unset_super_sticky'), 10, 1); // Query forums and show them if they exist if (bbp_forums()) { // Setup the forum bbp_the_forum(); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-forum'); // No forums found } else { ?> <div id="message" class="info"> <p><?php esc_html_e('This group does not currently have a forum.', 'bbpress'); ?> </p> </div> <?php } break; /** Single Topic **********************************************/ /** Single Topic **********************************************/ case $this->topic_slug: // hide the 'to front' admin links add_filter('bbp_get_topic_stick_link', array($this, 'hide_super_sticky_admin_link'), 10, 2); // Get the topic bbp_has_topics(array('name' => bp_action_variable($offset + 1), 'posts_per_page' => 1, 'show_stickies' => false)); // If no topic, 404 if (!bbp_topics()) { bp_do_404(bbp_get_forum_permalink($forum_id)); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('feedback', 'no-topics'); return; } // Setup the topic bbp_the_topic(); ?> <h3><?php bbp_topic_title(); ?> </h3> <?php // Topic edit if (bp_action_variable($offset + 2) === bbp_get_edit_rewrite_id()) { // Unset the super sticky link on edit topic template add_filter('bbp_get_topic_types', array($this, 'unset_super_sticky'), 10, 1); // Set the edit switches $wp_query->bbp_is_edit = true; $wp_query->bbp_is_topic_edit = true; // Setup the global forum ID $bbp->current_topic_id = get_the_ID(); // Merge if (!empty($_GET['action']) && 'merge' === $_GET['action']) { bbp_set_query_name('bbp_topic_merge'); bbp_get_template_part('form', 'topic-merge'); // Split } elseif (!empty($_GET['action']) && 'split' === $_GET['action']) { bbp_set_query_name('bbp_topic_split'); bbp_get_template_part('form', 'topic-split'); // Edit } else { bbp_set_query_name('bbp_topic_form'); bbp_get_template_part('form', 'topic'); } // Single Topic } else { bbp_set_query_name('bbp_single_topic'); bbp_get_template_part('content', 'single-topic'); } break; /** Single Reply **********************************************/ /** Single Reply **********************************************/ case $this->reply_slug: // Get the reply bbp_has_replies(array('name' => bp_action_variable($offset + 1), 'posts_per_page' => 1)); // If no topic, 404 if (!bbp_replies()) { bp_do_404(bbp_get_forum_permalink($forum_id)); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('feedback', 'no-replies'); return; } // Setup the reply bbp_the_reply(); ?> <h3><?php bbp_reply_title(); ?> </h3> <?php if (bp_action_variable($offset + 2) === bbp_get_edit_rewrite_id()) { // Set the edit switches $wp_query->bbp_is_edit = true; $wp_query->bbp_is_reply_edit = true; // Setup the global reply ID $bbp->current_reply_id = get_the_ID(); // Move if (!empty($_GET['action']) && 'move' === $_GET['action']) { bbp_set_query_name('bbp_reply_move'); bbp_get_template_part('form', 'reply-move'); // Edit } else { bbp_set_query_name('bbp_reply_form'); bbp_get_template_part('form', 'reply'); } } break; } // Reset the query wp_reset_query(); ?> </div> <?php // Allow actions immediately after group forum output do_action('bbp_after_group_forum_display'); }
/** * Displays the output, the topic list * * @since bbPress (r2653) * * @param mixed $args * @param array $instance * @uses apply_filters() Calls 'bbp_topic_widget_title' with the title * @uses bbp_topic_permalink() To display the topic permalink * @uses bbp_topic_title() To display the topic title * @uses bbp_get_topic_last_active_time() To get the topic last active * time * @uses bbp_get_topic_id() To get the topic id */ public function widget($args = array(), $instance = array()) { // Get widget settings $settings = $this->parse_settings($instance); // Typical WordPress filter $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base); // bbPress filter $settings['title'] = apply_filters('bbp_topic_widget_title', $settings['title'], $instance, $this->id_base); // How do we want to order our results? switch ($settings['order_by']) { // Order by most recent replies case 'freshness': $topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $settings['parent_forum'], 'posts_per_page' => (int) $settings['max_shown'], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC'); break; // Order by total number of replies // Order by total number of replies case 'popular': $topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $settings['parent_forum'], 'posts_per_page' => (int) $settings['max_shown'], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => '_bbp_reply_count', 'orderby' => 'meta_value', 'order' => 'DESC'); break; // Order by which topic was created most recently // Order by which topic was created most recently case 'newness': default: $topics_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $settings['parent_forum'], 'posts_per_page' => (int) $settings['max_shown'], 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'order' => 'DESC'); break; } // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_normalize_forum_visibility action and function. $widget_query = new WP_Query($topics_query); // Bail if no topics are found if (!$widget_query->have_posts()) { return; } echo $args['before_widget']; if (!empty($settings['title'])) { echo $args['before_title'] . $settings['title'] . $args['after_title']; } ?> <ul> <?php while ($widget_query->have_posts()) { $widget_query->the_post(); $topic_id = bbp_get_topic_id($widget_query->post->ID); $author_link = ''; // Maybe get the topic author if (!empty($settings['show_user'])) { $author_link = bbp_get_topic_author_link(array('post_id' => $topic_id, 'type' => 'both', 'size' => 14)); } ?> <li> <a class="bbp-forum-title" href="<?php bbp_topic_permalink($topic_id); ?> "><?php bbp_topic_title($topic_id); ?> </a> <?php if (!empty($author_link)) { ?> <?php printf(_x('by %1$s', 'widgets', 'bbpress'), '<span class="topic-author">' . $author_link . '</span>'); ?> <?php } ?> <?php if (!empty($settings['show_date'])) { ?> <div><?php bbp_topic_last_active_time($topic_id); ?> </div> <?php } ?> </li> <?php } ?> </ul> <?php echo $args['after_widget']; // Reset the $post global wp_reset_postdata(); }
/** * Show Support Tickets * * @param $atts * @param null $content */ function wi_bbp_support_tickets($atts, $content = null) { $tickets = get_posts(array('post_type' => 'topic', 'author' => get_current_user_id(), 'nopaging' => true)); if ($tickets) { ?> <ul id="give-support-tickets" class="list-group"> <?php foreach ($tickets as $ticket) { ?> <?php $status = get_post_meta($ticket->ID, '_bbps_topic_status', true); $status = 1 == $status ? 'Not Resolved' : 'Resolved'; ?> <li class="list-group-item"> <span class="status <?php echo sanitize_key($status); ?> "><?php echo $status; ?> </span> <a href="<?php bbp_topic_permalink($ticket->ID); ?> "><?php bbp_topic_title($ticket->ID); ?> </a> </li> <?php } ?> </ul> <?php } else { ?> <p class="give-support-no-tickets"><?php _e('You have not opened any support tickets. Need help?', 'bbpress_support'); ?> <a href="<?php echo home_url('/support'); ?> ">Open a ticket in the forums.</a></p> <?php } }
<div class="container" role="main"> <div class="row column-content-wrapper"> <div id="content" class="span12 article-container tc-gallery-style"> <article class="row-fluid"> <?php do_action( 'bbp_before_main_content' ); ?> <?php do_action( 'bbp_template_notices' ); ?> <?php while ( have_posts() ) : the_post(); ?> <?php if ( bbp_user_can_view_forum( array( 'forum_id' => bbp_get_topic_forum_id() ) ) ) : ?> <div id="bbp-topic-wrapper-<?php bbp_topic_id(); ?>" class="bbp-topic-wrapper"> <h1 class="entry-title"><?php bbp_topic_title(); ?></h1> <div class="entry-content"> <?php bbp_get_template_part( 'content', 'single-topic' ); ?> </div> </div><!-- #bbp-topic-wrapper-<?php bbp_topic_id(); ?> --> <?php else : // Forum exists, user no access ?> <?php bbp_get_template_part( 'feedback', 'no-access' ); ?> <?php endif; ?> <?php endwhile; ?>
if (!empty($author_link)) { ?> <div class="topic-avatar"> <?php printf(_x('%1$s', 'widgets', 'bbpress'), '<div class="topic-author">' . $author_link . '</div>'); ?> </div> <?php } ?> <div class="topic-content"> <h4><a class="bbp-forum-title" href="<?php bbp_topic_permalink($topic_id); ?> "><?php bbp_topic_title($topic_id); ?> </a></h4> <?php bbp_topic_last_active_time($topic_id); ?> </div> </div> <?php } ?> </div> <?php
/** * Output the forums for a group in the edit screens * * @since bbPress (r3653) * @uses bp_get_current_group_id() * @uses bbp_get_group_forum_ids() * @uses bbp_has_forums() * @uses bbp_get_template_part() */ public function display_forums($offset = 0) { global $wpdb; $bbp = bbpress(); // Forum data $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id()); $forum_args = array('post__in' => $forum_ids, 'post_parent' => null); ?> <div id="bbpress-forums"> <?php // Looking at the group forum root if (!bp_action_variable($offset)) { // Query forums and show them if if (!empty($forum_ids) && bbp_has_forums($forum_args)) { bbp_the_forum(); // Only one forum found if ($bbp->forum_query->post_count == 1) { ?> <h3><?php _e('Forum', 'bbpress'); ?> </h3> <?php bbp_set_query_name('bbp_single_forum'); ?> <?php if (bbp_has_topics(array('post_parent' => bbp_get_forum_id()))) { ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // More than 1 forum found } elseif ($bbp->forum_query->post_count > 1) { ?> <h3><?php _e('Forums', 'bbpress'); ?> </h3> <?php bbp_get_template_part('loop', 'forums'); ?> <h3><?php _e('Topics', 'bbpress'); ?> </h3> <?php if (bbp_has_topics(array('post_parent__in' => $forum_ids))) { ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // No forums found } else { ?> <div id="message" class="info"> <p><?php _e('This group does not currently have any forums.', 'bbpress'); ?> </p> </div> <?php if (bp_is_group_admin_screen($this->slug)) { bbp_get_template_part('form', 'forum'); } } // No forums found } else { ?> <div id="message" class="info"> <p><?php _e('This group does not currently have any forums.', 'bbpress'); ?> </p> </div> <?php if (bp_is_group_admin_screen($this->slug)) { bbp_get_template_part('form', 'forum'); } } // Single forum } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) != $this->topic_slug) { // Get the forum $forum_post_type = bbp_get_forum_post_type(); $forum_slug = bp_action_variable($offset); $forums = $wpdb->get_row("SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$forum_slug}' AND post_type = '{$forum_post_type}'", ARRAY_N); // Forum exists if (!empty($forums)) { $forum_id = $forums[0]; $bbp->current_forum_id = $forum_id; bbp_set_query_name('bbp_single_forum'); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-forum'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // Single topic } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) == $this->topic_slug) { // Get the topic $topic_post_type = bbp_get_topic_post_type(); $topic_slug = bp_action_variable($offset + 1); $topics = $wpdb->get_row("SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$topic_slug}' AND post_type = '{$topic_post_type}'", ARRAY_N); // Topic exists if (!empty($topics)) { $topic_id = $topics[0]; $bbp->current_topic_id = $topic_id; bbp_set_query_name('bbp_single_topic'); ?> <h3><?php bbp_topic_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-topic'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } } ?> </div> <?php }
/** * Output the forums for a group in the edit screens * * @since bbPress (r3653) * @uses bp_get_current_group_id() * @uses bbp_get_group_forum_ids() * @uses bbp_has_forums() * @uses bbp_get_template_part() */ public function display_forums($offset = 0) { // Allow actions immediately before group forum output do_action('bbp_before_group_forum_display'); // Load up bbPress once $bbp = bbpress(); // Forum data $forum_slug = bp_action_variable($offset); $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id()); $forum_args = array('post__in' => $forum_ids, 'post_parent' => null); // Unset global queries $bbp->forum_query = new stdClass(); $bbp->topic_query = new stdClass(); $bbp->reply_query = new stdClass(); // Unset global ID's $bbp->current_forum_id = 0; $bbp->current_topic_id = 0; $bbp->current_reply_id = 0; $bbp->current_topic_tag_id = 0; // Reset the post data wp_reset_postdata(); // Allow admins special views $post_status = array(bbp_get_closed_status_id(), bbp_get_public_status_id()); if (is_super_admin() || current_user_can('moderate') || bp_is_item_admin() || bp_is_item_mod()) { $post_status = array_merge($post_status, array(bbp_get_spam_status_id(), bbp_get_trash_status_id())); } ?> <div id="bbpress-forums"> <?php // Looking at the group forum root if (empty($forum_slug) || 'page' == $forum_slug) { // Query forums and show them if they exist if (!empty($forum_ids) && bbp_has_forums($forum_args)) { // Only one forum found if (1 == $bbp->forum_query->post_count) { // Remove 'name' check for paginated requests if ('page' == $forum_slug) { $forum_args = array('post_type' => bbp_get_forum_post_type()); } else { $forum_args = array('name' => $forum_slug, 'post_type' => bbp_get_forum_post_type()); } // Get the forums $forums = get_posts($forum_args); bbp_the_forum(); // Forum exists if (!empty($forums)) { $forum = $forums[0]; // Suppress subforums for now add_filter('bbp_get_forum_subforum_count', '__return_false'); // Set up forum data bbpress()->current_forum_id = $forum->ID; bbp_set_query_name('bbp_single_forum'); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-forum'); ?> <?php // Remove the subforum suppression filter remove_filter('bbp_get_forum_subforum_count', '__return_false'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // More than 1 forum found or group forum admin screen } elseif (1 < $bbp->forum_query->post_count) { ?> <h3><?php _e('Forums', 'bbpress'); ?> </h3> <?php bbp_get_template_part('loop', 'forums'); ?> <h3><?php _e('Topics', 'bbpress'); ?> </h3> <?php if (bbp_has_topics(array('post_parent__in' => $forum_ids))) { ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('loop', 'topics'); ?> <?php bbp_get_template_part('pagination', 'topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } else { ?> <?php bbp_get_template_part('feedback', 'no-topics'); ?> <?php bbp_get_template_part('form', 'topic'); ?> <?php } // No forums found } else { ?> <div id="message" class="info"> <p><?php _e('This group does not currently have any forums.', 'bbpress'); ?> </p> </div> <?php } // No forums found } else { ?> <div id="message" class="info"> <p><?php _e('This group does not currently have any forums.', 'bbpress'); ?> </p> </div> <?php } // Single forum } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) != $this->topic_slug && bp_action_variable($offset) != $this->reply_slug) { // Get forum data $forum_slug = bp_action_variable($offset); $forum_args = array('name' => $forum_slug, 'post_type' => bbp_get_forum_post_type()); $forums = get_posts($forum_args); // Forum exists if (!empty($forums)) { $forum = $forums[0]; // Set up forum data $forum_id = bbpress()->current_forum_id = $forum->ID; // Reset necessary forum_query attributes for forums loop to function $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); $bbp->forum_query->in_the_loop = true; $bbp->forum_query->post = get_post($forum_id); // Forum edit if (bp_action_variable($offset + 1) == $bbp->edit_id) { global $wp_query, $post; $wp_query->bbp_is_edit = true; $wp_query->bbp_is_forum_edit = true; $post = $forum; bbp_set_query_name('bbp_forum_form'); bbp_get_template_part('form', 'forum'); } else { bbp_set_query_name('bbp_single_forum'); ?> <h3><?php bbp_forum_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-forum'); } } else { bbp_get_template_part('feedback', 'no-topics'); bbp_get_template_part('form', 'topic'); } // Single topic } elseif (bp_action_variable($offset) == $this->topic_slug) { // Get topic data $topic_slug = bp_action_variable($offset + 1); $topic_args = array('name' => $topic_slug, 'post_type' => bbp_get_topic_post_type(), 'post_status' => $post_status); $topics = get_posts($topic_args); // Topic exists if (!empty($topics)) { $topic = $topics[0]; // Set up topic data $topic_id = bbpress()->current_topic_id = $topic->ID; $forum_id = bbp_get_topic_forum_id($topic_id); // Reset necessary forum_query attributes for topics loop to function $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); $bbp->forum_query->in_the_loop = true; $bbp->forum_query->post = get_post($forum_id); // Reset necessary topic_query attributes for topics loop to function $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); $bbp->topic_query->in_the_loop = true; $bbp->topic_query->post = $topic; // Topic edit if (bp_action_variable($offset + 2) == $bbp->edit_id) { global $wp_query, $post; $wp_query->bbp_is_edit = true; $wp_query->bbp_is_topic_edit = true; $post = $topic; // Merge if (!empty($_GET['action']) && 'merge' == $_GET['action']) { bbp_set_query_name('bbp_topic_merge'); bbp_get_template_part('form', 'topic-merge'); // Split } elseif (!empty($_GET['action']) && 'split' == $_GET['action']) { bbp_set_query_name('bbp_topic_split'); bbp_get_template_part('form', 'topic-split'); // Edit } else { bbp_set_query_name('bbp_topic_form'); bbp_get_template_part('form', 'topic'); } // Single Topic } else { bbp_set_query_name('bbp_single_topic'); ?> <h3><?php bbp_topic_title(); ?> </h3> <?php bbp_get_template_part('content', 'single-topic'); } // No Topics } else { bbp_get_template_part('feedback', 'no-topics'); bbp_get_template_part('form', 'topic'); } // Single reply } elseif (bp_action_variable($offset) == $this->reply_slug) { // Get reply data $reply_slug = bp_action_variable($offset + 1); $reply_args = array('name' => $reply_slug, 'post_type' => bbp_get_reply_post_type()); $replies = get_posts($reply_args); if (empty($replies)) { return; } // Get the first reply $reply = $replies[0]; // Set up reply data $reply_id = bbpress()->current_reply_id = $reply->ID; $topic_id = bbp_get_reply_topic_id($reply_id); $forum_id = bbp_get_reply_forum_id($reply_id); // Reset necessary forum_query attributes for reply to function $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); $bbp->forum_query->in_the_loop = true; $bbp->forum_query->post = get_post($forum_id); // Reset necessary topic_query attributes for reply to function $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); $bbp->topic_query->in_the_loop = true; $bbp->topic_query->post = get_post($topic_id); // Reset necessary reply_query attributes for reply to function $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type(); $bbp->reply_query->in_the_loop = true; $bbp->reply_query->post = $reply; if (bp_action_variable($offset + 2) == $bbp->edit_id) { global $wp_query, $post; $wp_query->bbp_is_edit = true; $wp_query->bbp_is_reply_edit = true; $post = $reply; bbp_set_query_name('bbp_reply_form'); bbp_get_template_part('form', 'reply'); } } ?> </div> <?php // Allow actions immediately after group forum output do_action('bbp_after_group_forum_display'); }