/** * @covers ::bbp_forum_permalink * @covers ::bbp_get_forum_permalink */ public function test_bbp_get_forum_permalink() { if (is_multisite()) { $this->markTestSkipped('Skipping URL tests in multiste for now.'); } // Public category. $c = $this->factory->forum->create(array('post_title' => 'Public Category')); $category = bbp_get_forum_permalink($c); $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=public-category', $category); // Public forum of public category. $f = $this->factory->forum->create(array('post_title' => 'Public Forum', 'post_parent' => $c)); $forum_permalink = bbp_get_forum_permalink($f); $this->expectOutputString($forum_permalink); bbp_forum_permalink($f); $forum = bbp_get_forum_permalink($f); $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=public-category/public-forum', $forum); // Private category. $c = $this->factory->forum->create(array('post_title' => 'Private Category')); $category = bbp_get_forum_permalink($c); $forum = bbp_get_forum_permalink($f); $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=private-category', $category); // Private forum of private category. $f = $this->factory->forum->create(array('post_title' => 'Private Forum', 'post_parent' => $c)); bbp_privatize_forum($c); $forum = bbp_get_forum_permalink($f); $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=private-category/private-forum', $forum); // Hidden category. $c = $this->factory->forum->create(array('post_title' => 'Hidden Category')); bbp_hide_forum($c); $category = bbp_get_forum_permalink($c); $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=hidden-category', $category); // Hidden forum of hidden category. $f = $this->factory->forum->create(array('post_title' => 'Hidden Forum', 'post_parent' => $c)); $forum = bbp_get_forum_permalink($f); $this->assertSame('http://' . WP_TESTS_DOMAIN . '/?forum=hidden-category/hidden-forum', $forum); }
<ul id="bbp-forum-<?php bbp_forum_id(); ?> " <?php bbp_forum_class(); ?> > <li class="bbp-forum-info"> <?php do_action('bbp_theme_before_forum_title'); ?> <a class="bbp-forum-title" href="<?php bbp_forum_permalink(); ?> "><?php bbp_forum_title(); ?> </a> <?php do_action('bbp_theme_after_forum_title'); ?> <?php do_action('bbp_theme_before_forum_description'); ?> <div class="bbp-forum-content"><?php
<li class="bboss_search_item bboss_search_item_forum"> <div class="item"> <div class="item-title"><a href="<?php bbp_forum_permalink(get_the_ID()); ?> "><?php bbp_forum_title(get_the_ID()); ?> </a></div> <div class="item-desc"><?php bbp_forum_content(get_the_ID()); ?> </div> </div> </li>
function ipt_kb_bbp_forum_title_in_list($forum_id = 0) { do_action('bbp_theme_before_forum_title'); ?> <a class="bbp-forum-title" href="<?php bbp_forum_permalink($forum_id); ?> "><?php bbp_forum_title($forum_id); ?> </a> <?php do_action('bbp_theme_after_forum_title'); ?> <?php }
if (is_user_logged_in()) { ?> <li class="topic-actions clearfix"> <?php bbp_topic_subscription_link(); ?> <?php bbp_topic_favorite_link(); ?> </li> <?php } ?> <li class="topic-info-general clearfix"> <div class="path fl"><a href="<?php bbp_forum_permalink(bbp_get_forum_id()); ?> "><?php bbp_forum_title(bbp_get_topic_forum_id(bbp_get_topic_id())); ?> </a></div> <div class="date fr"> <time datetime="<?php echo get_post_time('c', false, bbp_get_topic_id()); ?> "> <?php printf(_x('%1$s at %2$s', '1: date, 2: time'), get_post_time(bbpresskr()->forum_option('date_format'), false, bbp_get_topic_id()), get_post_time(bbpresskr()->forum_option('time_format'), false, bbp_get_topic_id())); ?> </time> </div>
/** * Displays the output, the forum list * * @since bbPress (r2653) * * @param mixed $args Arguments * @param array $instance Instance * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title * @uses get_option() To get the forums per page option * @uses current_user_can() To check if the current user can read * private() To resety name * @uses bbp_has_forums() The main forum loop * @uses bbp_forums() To check whether there are more forums available * in the loop * @uses bbp_the_forum() Loads up the current forum in the loop * @uses bbp_forum_permalink() To display the forum permalink * @uses bbp_forum_title() To display the forum title */ public function widget($args, $instance) { extract($args); $title = apply_filters('bbp_forum_widget_title', $instance['title']); $parent_forum = !empty($instance['parent_forum']) ? $instance['parent_forum'] : '0'; // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_exclude_forums filter and function. $widget_query = new WP_Query(array('post_parent' => $parent_forum, 'post_type' => bbp_get_forum_post_type(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC')); 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(); ?> <li><a class="bbp-forum-title" href="<?php bbp_forum_permalink($widget_query->post->ID); ?> " title="<?php bbp_forum_title($widget_query->post->ID); ?> "><?php bbp_forum_title($widget_query->post->ID); ?> </a></li> <?php } ?> </ul> <?php echo $after_widget; // Reset the $post global wp_reset_postdata(); } }
/** * Displays the output, the forum list * * @since bbPress (r2653) * * @param mixed $args Arguments * @param array $instance Instance * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title * @uses get_option() To get the forums per page option * @uses current_user_can() To check if the current user can read * private() To resety name * @uses bbp_has_forums() The main forum loop * @uses bbp_forums() To check whether there are more forums available * in the loop * @uses bbp_the_forum() Loads up the current forum in the loop * @uses bbp_forum_permalink() To display the forum permalink * @uses bbp_forum_title() To display the forum title */ public function widget($args, $instance) { // 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_forum_widget_title', $settings['title'], $instance, $this->id_base); // 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(array('post_type' => bbp_get_forum_post_type(), 'post_parent' => $settings['parent_forum'], 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'orderby' => 'menu_order title', 'order' => 'ASC')); // Bail if no posts 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(); ?> <li><a class="bbp-forum-title" href="<?php bbp_forum_permalink($widget_query->post->ID); ?> "><?php bbp_forum_title($widget_query->post->ID); ?> </a></li> <?php } ?> </ul> <?php echo $args['after_widget']; // Reset the $post global wp_reset_postdata(); }
?> " title="Jump to the last reply">→</a> <?php } ?> </h3> <p class="forum-description"> Started by <?php bbp_topic_author_link(array('type' => 'name')); ?> <?php if (!bbp_is_single_forum()) { ?> in <a class="topic-location" href="<?php bbp_forum_permalink(bbp_get_topic_forum_id()); ?> " title="Browse this forum"><?php bbp_forum_title(bbp_get_topic_forum_id()); ?> </a> <?php } ?> </p> </div> <div class="forum-count"> <?php bbp_topic_post_count(); ?>
/** * Displays the output, the forum list * * @since bbPress (r2653) * * @param mixed $args Arguments * @param array $instance Instance * @uses apply_filters() Calls 'bbp_forum_widget_title' with the title * @uses get_option() To get the forums per page option * @uses current_user_can() To check if the current user can read * private() To resety name * @uses bbp_has_forums() The main forum loop * @uses bbp_forums() To check whether there are more forums available * in the loop * @uses bbp_the_forum() Loads up the current forum in the loop * @uses bbp_forum_permalink() To display the forum permalink * @uses bbp_forum_title() To display the forum title */ public function widget($args, $instance) { // 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_forum_widget_title', $settings['title'], $instance, $this->id_base); // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_exclude_forums filter and function. $query_data = array('post_type' => bbp_get_forum_post_type(), 'post_parent' => $settings['parent_forum'], 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC'); //Get an array of IDs which the current user has permissions to view $allowed_posts = tehnik_bpp_get_permitted_post_ids(new WP_Query($query_data)); // The default forum query with allowed forum ids array added $query_data['post__in'] = $allowed_posts; $widget_query = new WP_Query($query_data); // Bail if no posts 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(); ?> <li><a class="bbp-forum-title" href="<?php bbp_forum_permalink($widget_query->post->ID); ?> " title="<?php bbp_forum_title($widget_query->post->ID); ?> "><?php bbp_forum_title($widget_query->post->ID); ?> </a></li> <?php } ?> </ul> <?php echo $args['after_widget']; // Reset the $post global wp_reset_postdata(); }
function td_show_forum($forum_object) { $last_active = bbp_get_forum_last_active_id($forum_object->ID); $time_since = ''; $last_updated_by_avatar = ''; if (!empty($last_active)) { $time_since = bbp_get_forum_freshness_link($forum_object->ID); $last_updated_by_avatar = bbp_get_author_link(array('post_id' => $last_active, 'size' => 40, 'type' => 'avatar')); //echo $time_since; } ?> <div class="clearfix"></div> <ul class="td-forum-list-table td-forum-content"> <li class="td-forum-category-title<?php if (empty($forum_object->post_content)) { echo ' td-forum-title-no-desc'; } ?> "> <div class="td-forum-index-padd"> <a class="bbp-forum-title" href="<?php bbp_forum_permalink($forum_object->ID); ?> "><?php bbp_forum_title($forum_object->ID); ?> </a> <?php if (!empty($forum_object->post_content)) { ?> <div class="td-forum-description"><?php echo $forum_object->post_content; ?> </div> <?php } ?> </li><li class="td-forum-replies"> <div><?php echo bbp_get_forum_topic_count($forum_object->ID); ?> topics</div> <div><?php echo bbp_get_forum_reply_count($forum_object->ID); ?> replies</div> </li><li class="td-forum-last-comment"> <div> <?php echo $last_updated_by_avatar; ?> </div> <div class="td-forum-last-comment-content"> <div class="td-forum-author-name"> by <a class="td-forum-last-author" href="<?php bbp_reply_author_url($last_active); ?> "><?php echo bbp_get_topic_author_display_name($last_active); ?> </a> </div> <div class="td-forum-time-comment"> <?php bbp_forum_freshness_link($forum_object->ID); ?> </div> </div> </li> </ul> <div class="clearfix"></div> <?php }
/** * [g1_bbp_forums] shortcode callback function. * * @param array $atts * @param string $content * @return string */ function g1_bbp_forums_shortcode($atts, $content) { /* We need a static counter to trace a shortcode without the id attribute */ static $counter = 0; $counter++; extract(shortcode_atts(array('id' => '', 'class' => ''), $atts, 'g1_bbp_forums')); // Compose final HTML id attribute $final_id = strlen($id) ? $id : 'g1-bbp-forums-' . $counter; // Compose final HTML class attribute $final_class = array('g1-bbp-forums'); $final_class = array_merge($final_class, explode(' ', $class)); // Note: private and hidden forums will be excluded via the // bbp_pre_get_posts_normalize_forum_visibility action and function. $query = new WP_Query(array('post_type' => bbp_get_forum_post_type(), 'post_parent' => $settings['parent_forum'], 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'orderby' => 'menu_order title', 'order' => 'ASC')); if (!$query->have_posts()) { return ''; } // Start output buffer ob_start(); ?> <div class="<?php echo implode(' ', array_map('sanitize_html_class', $final_class)); ?> "> <div class="g1-collection g1-collection--grid g1-collection--one-third g1-collection--simple"> <ul> <?php while ($query->have_posts()) { $query->the_post(); ?> <li class="g1-collection__item"> <article> <?php if (has_post_thumbnail()) { ?> <figure class="entry-featured-media"> <a href="<?php bbp_forum_permalink($query->post->ID); ?> "> <?php the_post_thumbnail('g1_one_third'); ?> </a> </figure> <?php } else { ?> <?php echo do_shortcode('[placeholder icon="camera" size="g1_one_third"]'); ?> <?php } ?> <div class="g1-nonmedia"> <div class="g1-inner"> <header class="entry-header"> <h3 class="entry-title"> <a href="<?php bbp_forum_permalink($query->post->ID); ?> "><?php bbp_forum_title($query->post->ID); ?> </a> </h3> <p class="entry-meta g1-meta"> <span><?php _e('Topics', 'bbpress'); ?> : <?php bbp_forum_topic_count($query->post->ID); ?> </span> <span><?php bbp_show_lead_topic() ? _e('Replies', 'bbpress') : _e('Posts', 'bbpress'); ?> : <?php bbp_show_lead_topic() ? bbp_forum_reply_count($query->post->ID) : bbp_forum_post_count($query->post->ID); ?> </span> </p> </header> <div class="entry-summary"> <?php the_excerpt(); ?> </div> </div> </div> </article> </li> <?php } ?> </ul> </div> </div> <?php // Reset the $post global wp_reset_postdata(); // Return and flush the output buffer return ob_get_clean(); }
if (bbp_is_forum_category() or !$bbp_forums_noheader) { ?> <ul id="forums-list-<?php bbp_forum_id(); ?> " class="bbp-forums"> <li class="bbp-header"> <ul class="forum-titles"> <li class="bbp-forum-info"><?php if (bbp_is_forum_category()) { ?> <a class="bbp-forum-title" href="<?php bbp_forum_permalink(bbp_get_forum_parent_id()); ?> "><?php bbp_forum_title(bbp_get_forum_parent_id()); ?> </a><?php } else { _e('Forum', 'bbpress'); } ?> </li> <li class="bbp-forum-topic-count"><?php _e('Topics', 'bbpress'); ?> /<?php bbp_show_lead_topic() ? _e('Replies', 'bbpress') : _e('Posts', 'bbpress');