Пример #1
0
 /**
  * @group canonical
  * @covers ::bbp_insert_forum
  */
 public function test_bbp_insert_forum()
 {
     $f = $this->factory->forum->create(array('post_title' => 'Forum 1', 'post_content' => 'Content of Forum 1'));
     $now = time();
     $post_date = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
     $t = $this->factory->topic->create(array('post_parent' => $f, 'post_date' => $post_date, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_parent' => $t, 'post_date' => $post_date, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Get the forum.
     $forum = bbp_get_forum($f);
     // Forum post.
     $this->assertSame('Forum 1', bbp_get_forum_title($f));
     $this->assertSame('Content of Forum 1', bbp_get_forum_content($f));
     $this->assertSame('open', bbp_get_forum_status($f));
     $this->assertSame('forum', bbp_get_forum_type($f));
     $this->assertTrue(bbp_is_forum_public($f));
     $this->assertSame(0, bbp_get_forum_parent_id($f));
     $this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?forum=' . $forum->post_name, $forum->guid);
     // Forum meta.
     $this->assertSame(0, bbp_get_forum_subforum_count($f, true));
     $this->assertSame(1, bbp_get_forum_topic_count($f, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($f, true, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($f, true));
     $this->assertSame(1, bbp_get_forum_reply_count($f, false, true));
     $this->assertSame(1, bbp_get_forum_reply_count($f, true, true));
     $this->assertSame(2, bbp_get_forum_post_count($f, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($f, true, true));
     $this->assertSame($t, bbp_get_forum_last_topic_id($f));
     $this->assertSame($r, bbp_get_forum_last_reply_id($f));
     $this->assertSame($r, bbp_get_forum_last_active_id($f));
     $this->assertSame('4 days, 4 hours ago', bbp_get_forum_last_active_time($f));
 }
Пример #2
0
function kbc_forum_folder_desc()
{
    $content = bbp_get_forum_content();
    if ($content != '') {
        echo '<div id="desc-box">';
        echo $content;
        echo '</div>';
    }
}
Пример #3
0
/**
 * Output the content of the forum
 *
 * @since bbPress (r2780)
 *
 * @param int $forum_id Optional. Topic id
 * @uses bbp_get_forum_content() To get the forum content
 */
function bbp_forum_content($forum_id = 0)
{
    echo bbp_get_forum_content($forum_id);
}
function st_bbp_list_forums($args = '')
{
    // Define used variables
    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    $i = 0;
    $count = array();
    // Defaults and arguments
    $defaults = array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => ', ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true, 'show_freshness_link' => true);
    $r = bbp_parse_args($args, $defaults, 'list_forums');
    extract($r, EXTR_SKIP);
    // Bail if there are no subforums
    if (!bbp_get_forum_subforum_count($forum_id)) {
        return;
    }
    // Loop through forums and create a list
    $sub_forums = bbp_forum_get_subforums($forum_id);
    if (!empty($sub_forums)) {
        // Total count (for separator)
        $total_subs = count($sub_forums);
        foreach ($sub_forums as $sub_forum) {
            $i++;
            // Separator count
            // Get forum details
            $count = array();
            $show_sep = $total_subs > $i ? $separator : '';
            $permalink = bbp_get_forum_permalink($sub_forum->ID);
            $title = bbp_get_forum_title($sub_forum->ID);
            $description = bbp_get_forum_content($sub_forum->ID);
            // Show topic count
            if (!empty($show_topic_count) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID);
            }
            // Show reply count
            if (!empty($show_reply_count) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID);
            }
            // Counts to show
            if (!empty($count)) {
                $counts = $count_before . implode($count_sep, $count) . $count_after;
            }
            if (!empty($show_freshness_link)) {
                $freshness_link = "<div class='freshness-forum-link'>" . st_get_last_poster_block($sub_forum->ID) . "</div>";
            }
            // Build this sub forums link
            if ($i % 2) {
                $class = "odd-forum-row";
            } else {
                $class = "even-forum-row";
            }
            $output .= "<li class='{$class}'><ul>" . $link_before . '<div class="bbp-forum-title-container"><a href="' . $permalink . '" class="bbp-forum-link">' . $title . '</a><p class="bbp-forum-description">' . $description . '</p></div>' . $counts . $freshness_link . $link_after . "</ul></li>";
        }
        // Output the list
        echo apply_filters('bbp_list_forums', $before . $output . $after, $args);
    }
}
Пример #5
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));
 }
Пример #6
0
    /**
     * Display the table
     *
     * @since 3.1.0
     * @access public
     */
    public function display()
    {
        $singular = $this->_args['singular'];
        $this->display_tablenav('top');
        $forum_description = bbp_get_forum_content();
        $type = 'list';
        ?>
<table class="<?php 
        echo implode(' ', $this->get_table_classes());
        ?>
" summary="<?php 
        echo esc_attr(bbp_get_forum_content());
        ?>
">
	<thead>
	<tr>
		<?php 
        $this->print_column_headers();
        ?>
	</tr>
	</thead>

	<!-- <tfoot>
	<tr>
		<?php 
        //$this->print_column_headers( false );
        ?>
	</tr>
	</tfoot> -->

	<tbody id="bbpkr-the-list"<?php 
        if ($singular) {
            echo " data-wp-lists='list:{$singular}'";
        }
        ?>
>
		<?php 
        $this->display_rows_or_placeholder();
        ?>
	</tbody>
</table>
<?php 
        $this->display_tablenav('bottom');
    }
Пример #7
0
 /**
  * @covers ::bbp_forum_content
  * @covers ::bbp_get_forum_content
  */
 public function test_bbp_get_forum_content()
 {
     $f = $this->factory->forum->create(array('post_content' => 'Content of Forum 1'));
     $forum = bbp_get_forum_content($f);
     $this->assertSame('Content of Forum 1', $forum);
 }
function custom_list_forums($args = '')
{
    // Define used variables
    global $rpg_settingsg;
    global $rpg_settingsf;
    $output = $sub_forums = $topic_count = $reply_count = $counts = '';
    $i = 0;
    $count = array();
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('before' => '<ul class="bbp-forums-list">', 'after' => '</ul>', 'link_before' => '<li class="bbp-forum">', 'link_after' => '</li>', 'count_before' => ' (', 'count_after' => ')', 'count_sep' => ', ', 'separator' => '<br> ', 'forum_id' => '', 'show_topic_count' => true, 'show_reply_count' => true), 'listb_forums');
    // Loop through forums and create a list
    $sub_forums = bbp_forum_get_subforums($r['forum_id']);
    if (!empty($sub_forums)) {
        // Total count (for separator)
        $total_subs = count($sub_forums);
        foreach ($sub_forums as $sub_forum) {
            $i++;
            // Separator count
            // Get forum details
            $count = array();
            $show_sep = $total_subs > $i ? $r['separator'] : '';
            $permalink = bbp_get_forum_permalink($sub_forum->ID);
            $title = bbp_get_forum_title($sub_forum->ID);
            $content = bbp_get_forum_content($sub_forum->ID);
            if ($rpg_settingsg['activate_descriptions'] == true) {
                $content = bbp_get_forum_content($sub_forum->ID);
            } else {
                $content = '';
            }
            // Show topic count
            if (!empty($r['show_topic_count']) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['topic'] = bbp_get_forum_topic_count($sub_forum->ID);
            }
            // Show reply count
            if (!empty($r['show_reply_count']) && !bbp_is_forum_category($sub_forum->ID)) {
                $count['reply'] = bbp_get_forum_reply_count($sub_forum->ID);
            }
            // Counts to show
            if (!empty($count)) {
                $counts = $r['count_before'] . implode($r['count_sep'], $count) . $r['count_after'];
            }
            if ($rpg_settingsg['hide_counts'] == true) {
                $counts = '';
            }
            //Build this sub forums link
            if (bbp_is_forum_private($sub_forum->ID)) {
                if (!current_user_can('read_private_forums')) {
                    if (!$rpg_settingsf['redirect_page']) {
                        $link = '/home';
                    } else {
                        $link = $rpg_settingsf['redirect_page'];
                    }
                    $output .= $r['before'] . $r['link_before'] . '<a href="' . $link . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
                } else {
                    $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
                }
            } else {
                $output .= $r['before'] . $r['link_before'] . '<a href="' . esc_url($permalink) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'] . '<div class="bbp-forum-content">' . $content . '</div>' . $r['after'];
            }
        }
        //Output the list
        return $output;
    }
}